ZhenlongDai/ACPR huggingface dataset:
Problem: p02887
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
from itertools import accumulate
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N = int(input())
S= list(input())
s = []
cnt= 1
for i in range(len(S)-1):
  if S[i]==S[i+1]:
    cnt+=1
  else:
    s.append(cnt)
    cnt=1
s.append(cnt)
print(len(s))



Failing test case input:
5
__baa

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
import sys
from itertools import accumulate
input = sys.stdin.readline
def inputs():return [int(x) for x in input().split()]
N = int(input())
S= list(input())
s = []
cnt= 1
for i in range(len(S)-2):
  if S[i]==S[i+1]:
    cnt+=1
  else:
    s.append(cnt)
    cnt=1
s.append(cnt)
print(len(s))

Problem: p02887
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
a = 1
for i in range(n-1):
  if s[i] != s[i+1]:
    a += 1

Failing test case input:
5
_abb_

Expected output:
4


Actual output:

Fixed submission (verdict: Accepted):
n = int(input())
s = input()
a = 1
for i in range(n-1):
  if s[i] != s[i+1]:
    a += 1
print(a)

Problem: p02887
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def solve():
    N = int(input())
    S = input()

    ans = 1
    pre = S[0]
    for i in range(2,int(len(S))):
        if S[i] != pre:
            ans += 1
            pre = S[i]
    
    print(ans)

solve()

Failing test case input:
10
acaaabaaaa

Expected output:
5


Actual output:
3


Fixed submission (verdict: Accepted):
def solve():
    N = int(input())
    S = input()

    ans = 1
    pre = S[0]
    for i in range(1,int(len(S))):
        if S[i] != pre:
            ans += 1
            pre = S[i]
    
    print(ans)

solve()

Problem: p02887
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N=int(input())
S=input()
ct=0
for i in range(N-1):
  if S[i]!=S[i+1]:
    ct+=1
print(ct)

Failing test case input:
20
qlmkkkkxdeeedfezaefx

Expected output:
15


Actual output:
14


Fixed submission (verdict: Accepted):
N=int(input())
S=input()
ct=1
for i in range(N-1):
  if S[i]!=S[i+1]:
    ct+=1
print(ct)

Problem: p02887
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
S=input()
d=[]
for i in range(N):
    if i==1:
        d.append(S[i])
    elif S[i]!=S[i-1]:
        d.append(S[i])
print(len(d))

Failing test case input:
10
``bcbaaaca

Expected output:
7


Actual output:
8


Fixed submission (verdict: Accepted):
N=int(input())
S=input()
d=[]
for i in range(N):
    if i==0:
        d.append(S[i])
    elif S[i]!=S[i-1]:
        d.append(S[i])
print(len(d))
Problem: p02887
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = str(input())
fusion = []
for i in range(N-1):
    if S[i+1] != S[i]:
        fusion +=(S[i])
fusion +=S[N-1]
print(fusion)
print(len(fusion))

Failing test case input:
20
wkeklzfmedendeedbkjx

Expected output:
19


Actual output:
['w', 'k', 'e', 'k', 'l', 'z', 'f', 'm', 'e', 'd', 'e', 'n', 'd', 'e', 'd', 'b', 'k', 'j', 'x']
19


Fixed submission (verdict: Accepted):
N = int(input())
S = str(input())
fusion = []
for i in range(N-1):
    if S[i+1] != S[i]:
        fusion +=(S[i])
fusion +=S[N-1]

print(len(fusion))

Problem: p02887
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
S = str(input())

ans = ""
ans += S[0]

for i in range(1,N-1):
  if S[i] != S[i+1]:
    ans += S[i+1]
print(len(ans))


Failing test case input:
5
caaa_

Expected output:
3


Actual output:
2


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

ans = ""
ans += S[0]

for i in range(N-1):
  if S[i] != S[i+1]:
    ans += S[i+1]
print(len(ans))

Problem: p02887
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
s=input()
k=0
l=set(s)
if len(l)==1:
    print(len(l))
    exit()
for i in range(n-1):
    if s[i]==s[i+1]:
        k+=1
print(k)

Failing test case input:
20
qlmkkkkxdeeedfezaefx

Expected output:
15


Actual output:
5


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
k=0
l=set(s)
k=s[0]
ans=1
if len(l)==1:
    print("1")
    exit()
for i in range(1,n):
    if k!=s[i]:
        ans+=1
        k=s[i]
print(ans)

Problem: p02887
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = list(input().split())
 
ans = 1
for i in range(N - 1):
    if i != i + 1:
        ans = ans + 1
print(ans)

Failing test case input:
20
xekbdekdeeedmfzlkpkw

Expected output:
18


Actual output:
20


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
 
ans = 1
for i in range(N - 1):
    if S[i] != S[i + 1]:
        ans = ans + 1
print(ans)

Problem: p02887
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline

N = int(input())
s= list(input())

s0 = s.pop()

cnt = 1

while s:
    s1 = s.pop()
    if s1!=s0:
        cnt += 1
        s0 = s1
print(cnt)


Failing test case input:
5
aab__

Expected output:
3


Actual output:
4


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

s0 = s.pop()

cnt = 1

while s:
    s1 = s.pop()
    if s1!=s0:
        cnt += 1
        s0 = s1
print(cnt)

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

count=0
for i in range(1,n-1):
  if s[i-1]==s[i]:
    count=count+1
print(count)

Failing test case input:
10
acaaabbaab

Expected output:
6


Actual output:
4


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

count=1
for i in range(1,n):
  if s[i-1]==s[i]:
    count=count+0
  else:
    count+=1
print(count)
Problem: p02887
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
S = input()
tmp = ''
count = 0
for s in S:
    if s == tmp:
        count += 1
    tmp = s
print(count)

Failing test case input:
20
mlqkkzkxdeeedfekaefx

Expected output:
17


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
tmp = ''
count = 0
for s in S:
    if s != tmp:
        count += 1
    tmp = s
print(count)

Problem: p02887
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
cur = s[0]
l = []
for i in range(n - 1):
    if cur != s[i + 1]:
        l.append(cur)
print(len(l))

Failing test case input:
10
acaa`baaaa

Expected output:
6


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
cur = s[0]
l = []
for i in range(n - 1):
    if cur != s[i + 1]:
        l.append(cur)
        cur = s[i + 1]
l.append(cur)
print(len(l))

Problem: p02887
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = int(input().split()[0])
b = list(map(str, input().split()[0]))
k = 0
s = 1


while k<len(b) -1:
 t = b[k]
 u = b[k+1]
 
 if not t == u:
  s = s + 1
  print(s)
 k = k + 1
print(s)

Failing test case input:
20
xfeakefdeeedmkzkkplx

Expected output:
17


Actual output:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
17


Fixed submission (verdict: Accepted):
a = int(input().split()[0])
b = list(map(str, input().split()[0]))
k = 0
s = 1


while k<len(b) -1:
 t = b[k]
 u = b[k+1]
 
 if not t == u:
  s = s + 1
  
 k = k + 1
print(s)

Problem: p02887
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
s = input()
count = 0

for i in range(n - 1):
    if s[i] != s[i + 1]:
        count += 1

print(count)

Failing test case input:
20
xedakefdeeedmkzlkplx

Expected output:
18


Actual output:
17


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

for i in range(n - 1):
    if s[i] != s[i + 1]:
        count += 1

print(count + 1)

Problem: p02887
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = str(input())

ans = [S[-1]]

for i in range(N):
    if(ans[-1] != S[i]):
        ans.append(S[i])

print(len(ans))


Failing test case input:
5
a_`ac

Expected output:
5


Actual output:
6


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

ans = [S[0]]

for i in range(N):
    if(ans[-1] != S[i]):
        ans.append(S[i])

print(len(ans))

Problem: p02887
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=str(input())
same=0
i=0
for i in range(n-2):
  if s[i]==s[i+1]:
    same+=1
    i+=1
print(n-same)


Failing test case input:
10
acaabcbbaa

Expected output:
7


Actual output:
8


Fixed submission (verdict: Accepted):
n=int(input())
s=str(input())
count=0
for i in range(n-1):
  if s[i]!=s[i+1]:
    count+=1
print(count+1)
Problem: p02887
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()

S = S + 'A'
last = S[0]
cnt = 0
for s in S[1:]:
    if last == s:
        continue
    else:
        cnt += 1
        last = s
print(cnt-1)

Failing test case input:
20
xekbdekdeeeemfzlkpkw

Expected output:
17


Actual output:
16


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

S = S + 'A'
last = S[0]
cnt = 0
for s in S[1:]:
    if last == s:
        continue
    else:
        cnt += 1
        last = s
print(cnt)

Problem: p02887
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
s=list(input())
prev=s[0]
sum=1
for i in range(n-1):
    if(prev!=s[i]):
        sum+=1
    prev=s[i]
print(sum)

Failing test case input:
20
xfzaffeeeeedxkkkkllq

Expected output:
11


Actual output:
10


Fixed submission (verdict: Accepted):
n=int(input())
s=list(input())
prev=s[0]
sum=1
for i in range(1,n):
    if(prev!=s[i]):
        sum+=1
    prev=s[i]
print(sum)

Problem: p02887
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
colors = list(input())
before = ""
ans = 0
for color in colors:
  if color != before:
    ans += 1
  else:
    before = color
print(ans)

Failing test case input:
5
cb__a

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
N = int(input())
colors = list(input())
before = ""
ans = 0
for color in colors:
  if color != before:
    ans += 1
    before = color
print(ans)
Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,i=list(map(int,input().split()))
print(n-i)

Failing test case input:
44 -2

Expected output:
47


Actual output:
46


Fixed submission (verdict: Accepted):
n,i=list(map(int,input().split()))
print(n-i+1)

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,i=map(int,input().split())
print(n-i-1)

Failing test case input:
-74 71

Expected output:
-144


Actual output:
-146


Fixed submission (verdict: Accepted):
n,i=map(int,input().split())
print(n-i+1)

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,i = map(int, input().split())
print(int(N - i))


Failing test case input:
25 -10

Expected output:
36


Actual output:
35


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

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A = [int(i) for i in input().split(" ")]
ans = A[0] + A[1] + 1

print(ans)


Failing test case input:
17 -2

Expected output:
20


Actual output:
16


Fixed submission (verdict: Accepted):
A = [int(i) for i in input().split(" ")]
ans = A[0] - A[1] + 1

print(ans)

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,i = map(int,input().split())
print(i-n+1)

Failing test case input:
-108 71

Expected output:
-178


Actual output:
180


Fixed submission (verdict: Accepted):
n,i = map(int,input().split())
print(n-i+1)

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A = [int(i) for i in input().split(" ")]
ans = A[0] + A[1] -1

print(ans)

Failing test case input:
17 -2

Expected output:
20


Actual output:
14


Fixed submission (verdict: Accepted):
A = [int(i) for i in input().split(" ")]
ans = A[0] - A[1] + 1

print(ans)

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,i = map(int,input().split())
print(N-1+1)

Failing test case input:
17 -2

Expected output:
20


Actual output:
17


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

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,i=map(int,input().split())
print(N-1+1)

Failing test case input:
25 -6

Expected output:
32


Actual output:
25


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

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, i = [int(n) for n in range(2)]

print(N + 1 - i)

Failing test case input:
-74 71

Expected output:
-144


Actual output:
0


Fixed submission (verdict: Accepted):
N, i = [int(n) for n in input().split()]

print(N + 1 - i)

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, i = list(map(int,input().split()))
print(i+1 -N)


Failing test case input:
-93 71

Expected output:
-163


Actual output:
165


Fixed submission (verdict: Accepted):
N, i = list(map(int,input().split()))
print(N+1 -i)
Problem: p03272
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,i = map(int,input().split())

print(n-1+1)


Failing test case input:
194 0

Expected output:
195


Actual output:
194


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

print(n-i+1)

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
l = list(map(int, input().split()))
print((l[0] + l[1]) -1)


Failing test case input:
25 -6

Expected output:
32


Actual output:
18


Fixed submission (verdict: Accepted):
l = list(map(int, input().split()))
print(l[0] + 1 - l[1])

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b = map(int, input().split())
print(b - a + 1)

Failing test case input:
-116 71

Expected output:
-186


Actual output:
188


Fixed submission (verdict: Accepted):
a, b = map(int, input().split())
print(a - b + 1)

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, i = map(int, input().split())
print(i - N + 1)

Failing test case input:
-52 36

Expected output:
-87


Actual output:
89


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

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
info = input()
info = info.split()
print(info)
backward = int(info[0]) - int(info[1]) + 1
print(backward)

Failing test case input:
-116 71

Expected output:
-186


Actual output:
['-116', '71']
-186


Fixed submission (verdict: Accepted):
info = input()
info = info.split()
backward = int(info[0]) - int(info[1]) + 1
print(backward)

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
print((a - 1) * (b - 1))

Failing test case input:
-52 14

Expected output:
-65


Actual output:
-689


Fixed submission (verdict: Accepted):
n,i = map(int,input().split())
print((n - i) + 1)

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b = map(int,input().split())
print(b-a+1)

Failing test case input:
-15 2

Expected output:
-16


Actual output:
18


Fixed submission (verdict: Accepted):
a,b = map(int,input().split())
print(a-b+1)

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
print(b-a-1)

Failing test case input:
-97 71

Expected output:
-167


Actual output:
167


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())
print(a-b+1)

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, i = [int(x) for x in input().split()]
print(N+i-i)

Failing test case input:
-19 4

Expected output:
-22


Actual output:
-19


Fixed submission (verdict: Accepted):
N, i = [int(x) for x in input().split()]
print(N+1-i)

Problem: p03272
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,i=map(int,input().split())
print(n-1+1)

Failing test case input:
-4 32

Expected output:
-35


Actual output:
-4


Fixed submission (verdict: Accepted):
n,i=map(int,input().split())
print(n-i+1)
Problem: p02886
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n=int(input())
*l,=map(int,input().split())
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    ans+=l[i]+l[j]
print(ans)

Failing test case input:
3
0 -4 -6

Expected output:
24


Actual output:
-20


Fixed submission (verdict: Accepted):

n=int(input())
*l,=map(int,input().split())
ans=0
for i in range(n-1):
  for j in range(i+1,n):
    ans+=l[i]*l[j]
print(ans)

Problem: p02886
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
k=list(map(int,input().split()))
ans=0
for i in range(n):
  for j in range(n):
    if i==j:
      continue
    ans+=k[i]*k[j]
print(ans)

Failing test case input:
7
5 0 7 8 3 3 2

Expected output:
312

Actual output:
624


Fixed submission (verdict: Accepted):
n=int(input())
k=list(map(int,input().split()))
ans=0
for i in range(n):
  for j in range(n):
    if i==j:
      break
    ans+=k[i]*k[j]
print(ans)

Problem: p02886
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
D=list(map(int,input().split()))
from itertools import combinations
ans=0
comb=combinations(D,2)
for c in comb:
  ans+=c[0]+c[1]
print(ans)

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

Expected output:
877


Actual output:
414


Fixed submission (verdict: Accepted):
N=int(input())
D=list(map(int,input().split()))
from itertools import combinations
comb=combinations(D, 2)
ans=0
for c in comb:
    ans+=c[0]*c[1]
print(ans)

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


import sys
from itertools import product

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    d = i2nn()
    r = 0
    for i, j in product(range(N), range(N)):
        r += d[i] * d[j] if i == j else 0
    print(r)
main()


Failing test case input:
7
-1 -1 395 -2 0 10 9

Expected output:
5944


Actual output:
156212


Fixed submission (verdict: Accepted):


import sys
from itertools import combinations

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    d = i2nn()
    print(sum(a*b for a, b in combinations(d, 2)))
main()
Problem: p02886
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
d=list(map(int, input().split()))
a=(sum(d))**2

def square(list):
    return [i ** 2 for i in list]

b=sum(square(d))
result=(a-b)/2
print(result)

Failing test case input:
7
-1 -1 395 -2 0 10 9

Expected output:
5944


Actual output:
5944.0


Fixed submission (verdict: Accepted):
N=int(input())
d=list(map(int, input().split()))
a=(sum(d))**2

def square(list):
    return [i ** 2 for i in list]

b=sum(square(d))
result=(a-b)/2
print(int(result))

Problem: p02886
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import copy
x = input()
y = list(map(int,input().split()))

result = 0
for i, j in enumerate(y):
    if i == (len(y) - 1):
        break
    array = copy.deepcopy(y)
    b = array.pop(i)
    a_sum = sum(array)
    result = result + b * len(y) + a_sum

print(result)


Failing test case input:
7
0 -1 105 1 3 5 8

Expected output:
1758


Actual output:
1404


Fixed submission (verdict: Accepted):
import copy
x = int(input())
y = list(map(int,input().split()))

result = 0
for (i, v) in enumerate(y):
  z = copy.deepcopy(y)
  c = copy.deepcopy(x) - 1 - i
  r = 0
  for j in range(c):
    r = r + z.pop()
  result = result + r * v

print(result)

Problem: p02886
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
d=map(int,input().split(" "))
wa=[]
for i in range(1,n+1):
  for j in range(i,n+1):
    wa.append(i*j)
print(sum(wa))


Failing test case input:
7
0 -1 281 -2 1 6 9

Expected output:
3676


Actual output:
462


Fixed submission (verdict: Accepted):
n=int(input())
d=list(map(int,input().split(" ")))
wa=[]
for i in range(0,n):
  for j in range(i+1,n):
    wa.append(d[i]*d[j])

print(sum(wa))

Problem: p02886
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
d=map(int,input().split())
d=list(d)
kotae=0
for i in range(n):
  for j in range(n-i-1):
    kotae=kotae+d[i]*d[j]
print(kotae)

Failing test case input:
3
0 -4 -17

Expected output:
68


Actual output:
0


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

kotae=0
for i in range(n):
  for j in range(i+1,n):
    kotae=kotae+d[i]*d[j]
print(kotae)

Problem: p02886
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = input(int())
d = list(map(int, input().split()))

ans = 0
for i in range(len(d)):
    for j in range(i+1, len(d)):
        ans += d[i] * d[j]

print(ans)


Failing test case input:
7
0 -1 50 0 3 5 8

Expected output:
813


Actual output:
0813


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

ans = 0
for i in range(len(d)):
    for j in range(i+1, len(d)):
        ans += d[i] * d[j]

print(ans)
Problem: p02886
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
l=list(mi())
s=0
t=0
for i in l:
  s+=i
  t+=i**2
print(s**2-t)

Failing test case input:
7
0 0 68 -3 0 5 13

Expected output:
1031


Actual output:
2062


Fixed submission (verdict: Accepted):
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
l=list(mi())
s=0
t=0
for i in l:
  s+=i
  t+=i**2
print(int((s**2-t)/2))

Problem: p02886
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
ans=0
n=int(input())
li=list(map(int,input().split()))
for i in li:
  for j in li:
    if i==j:
      break
    ans+=i*j
print(ans)


Failing test case input:
7
-1 -1 281 -2 0 6 9

Expected output:
3090


Actual output:
3089


Fixed submission (verdict: Accepted):
ans=0
n=int(input())
li=list(map(int,input().split()))
for i in range(len(li)):
  for j in range(len(li)):
    if i==j:
      break
    ans+=li[i]*li[j]
print(ans)

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

ret = 0

for i in range(N):
    for j in range(N):
        if i == j:
            continue
        
        ret += D[i] * D[j]
        
print(ret)

Failing test case input:
7
1 -1 7 2 23 3 2

Expected output:
386


Actual output:
772


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

ret = 0

for i in range(N):
    for j in range(i+1, N):
        if i == j:
            continue

        ret += D[i] * D[j]

print(ret)

Problem: p02886
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
d = list(map(int, input().split()))

print(n)
i = 0
j = 0
p = 0

while i < n - 1:
    while j < n - 1:
        p += d[i] * d[j + 1]
        j = j + 1 
    i = i + 1
    j = i
print(p)

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

Expected output:
877


Actual output:
7
877


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

i = 0
j = 0
p = 0

while i < n - 1:
    while j < n - 1:
        p += d[i] * d[j + 1]
        j = j + 1 
    i = i + 1
    j = i
print(p)

Problem: p02886
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
d = [int(i) for i in input().split()]
sum = 0

for i in range(N):
  for j in range(N):
    if i != j:
      sum += d[i] * d[j]

print(sum)

Failing test case input:
7
5 0 7 8 6 3 2

Expected output:
387


Actual output:
774


Fixed submission (verdict: Accepted):
N = int(input())
d = [int(i) for i in input().split()]
sum = 0

for i in range(N):
  for j in range(N):
    if i != j:
      sum += d[i] * d[j]

print(int(sum/2))
Problem: p02886
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
d = [int(i) for i in input().split()]
s = n * (n-1)

ans = 0
for i in range(n):
  for j in range(s):
      if j < n:
        ans += d[i] * d[j]

print(ans)

Failing test case input:
7
-2 0 165 -4 -1 5 12

Expected output:
1605


Actual output:
30625


Fixed submission (verdict: Accepted):
n = int(input())
d = [int(i) for i in input().split()]
s = n * (n-1)

ans = 0
for i in range(n):
  for j in range(s):
      if j < i:
        ans += d[i] * d[j]

print(ans)

Problem: p02886
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = int(input())
b = [int(i) for i in input().split()]
ans = 0
for i in range(a):
  ans += b[i]*(sum(b)-b[i])
print(ans)

Failing test case input:
7
-1 0 395 -2 0 10 9

Expected output:
6355


Actual output:
12710


Fixed submission (verdict: Accepted):
a = int(input())
b = [int(i) for i in input().split()]
ans = 0
for i in range(a):
  ans += b[i]*(sum(b)-b[i])
print(ans

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

sum_all = 0
for i in range(N):
  for s in range(i, N):
    sum_all += D[i] * D[s]
    
print(sum_all)

Failing test case input:
7
0 -1 136 1 5 5 8

Expected output:
2552


Actual output:
21164


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

sum_all = 0
for i in range(N):
  for s in range(i+1, N):
    sum_all += D[i] * D[s]
    
print(sum_all)

Problem: p02886
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split())) 
X = 0
for a in range(1,N+1):
    if a < N:
        X += A[a]*(sum(A[(a+1):(N+1)]))
print(X)

Failing test case input:
3
1 -12 -11

Expected output:
109


Actual output:
132


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split())) 
X = 0
for a in range(N):
    if a+1 < N:
        x = A[a]
        y = sum(A[(a+1):(N+1)])
        X += x*y

print(X)

Problem: p02886
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    print(i, j)
    ans += d[i] * d[j]
print(ans)
    

Failing test case input:
7
0 0 68 -2 0 3 15

Expected output:
1097


Actual output:
0 1
0 2
0 3
0 4
0 5
0 6
1 2
1 3
1 4
1 5
1 6
2 3
2 4
2 5
2 6
3 4
3 5
3 6
4 5
4 6
5 6
1097


Fixed submission (verdict: Accepted):
n = int(input())
d = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
  for j in range(i + 1, n):
    ans += d[i] * d[j]
print(ans)

Problem: p02886
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
d=list(map(int, input().split()))
a=(sum(d))**2

def square(list):
    return [i ** 2 for i in list]

b=sum(square(d))
result=a-b
print(result)

Failing test case input:
7
0 -1 105 1 5 5 8

Expected output:
1994


Actual output:
3988


Fixed submission (verdict: Accepted):
N=int(input())
d=list(map(int, input().split()))
a=(sum(d))**2

def square(list):
    return [i ** 2 for i in list]

b=sum(square(d))
result=(a-b)/2
print(int(result))
Problem: p02299
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
g = []
for i in range(n):
    g.append([int(i) for i in input().split()])
q = int(input())

def dot(a, b):
    return sum([i * j for i,j in zip(a, b)])
def sub(a, b):
    return [a[0] - b[0],a[1] - b[1]]
def cross(a, b):
    return  a[0] * b[1] - a[1] * b[0]
def contains(g, p):
    x = False
    for i in range(n):
        a = sub(g[i], p)
        b = sub(g[(i+1)%n], p)
        if abs(cross(a, b)) == 0 and dot(a, b) < 0: 
            return 1
        if a[1] > b[1]:
            a,b=b,a
        if a[1] < 0 and 0 < b[1] and abs(cross(a,b)) > 0:
            x = not x
    return 2 if x else 0
for i in range(q):
    x,y = map(int, input().split())
    print(contains(g, [x,y]))



Failing test case input:
4
0 0
3 -1
2 7
0 1
3
2 2
0 2
0 2

Expected output:
2
0
0


Actual output:
0
0
0


Fixed submission (verdict: Accepted):
n = int(input())
g = []
for i in range(n):
    g.append([int(i) for i in input().split()])
q = int(input())
EPS = 0.001
def dot(a, b):
    return sum([i * j for i,j in zip(a, b)])
def sub(a, b):
    return [a[0] - b[0],a[1] - b[1]]
def cross(a, b):
    return  a[0] * b[1] - a[1] * b[0]
def contains(g, p):
    x = False
    for i in range(n):
        a = sub(g[i], p)
        b = sub(g[(i+1)%n], p)
        if abs(cross(a, b)) < EPS and dot(a, b) < EPS: 
            return 1
        if a[1] > b[1]:
            a,b=b,a
        if a[1] < EPS and EPS < b[1] and cross(a,b) > EPS:
            x = not x
    return 2 if x else 0
for i in range(q):
    x,y = map(int, input().split())
    print(contains(g, [x,y]))
Problem: p02299
Buggy submission (Python3, verdict: Wrong Answer):
from sys import stdin
readline = stdin.readline


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def eq(a, b):
    return abs(a - b) < 1e-10


def on_line(p, s, e):
    d = dot(p - s, e - s)
    c = cross(p - s, e - s)
    if c == 0 and 0 <= d <= abs(e - s) ** 2:
        return True
    return False


def on_polygon_line(xy, p):
    for i in range(len(p)):
        j = i - 1
        if on_line(xy, p[i], p[j]):
            return True
    return False


def in_polygon(xy, p):
    wn = 0
    for i in range(len(p)):
        j = i - 1
        if 0 == (p[i] - p[j]).imag:
            continue
        vt = (xy - p[j]).imag / (p[i] - p[j]).imag
        tmp = p[i] + vt * (p[i] - p[j])
        if xy.real < tmp.real:
            wn += 1 if p[j].imag < xy.imag <= p[i].imag else\
                 -1 if p[i].imag < xy.imag <= p[j].imag else 0
    return wn

n = int(readline())
p = [map(int, readline().split()) for _ in range(n)]
p = [x + y * 1j for x, y in p]

q = int(readline())
for _ in range(q):
    x, y = map(int, readline().split())
    xy = x + y * 1j
    print(1 if on_polygon_line(xy, p) else 2 if in_polygon(xy, p) else 0)

Failing test case input:
4
0 0
3 0
2 7
0 1
3
2 1
0 2
0 2

Expected output:
2
0
0


Actual output:
0
2
2


Fixed submission (verdict: Accepted):
from sys import stdin
readline = stdin.readline


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def dot(a, b):
    return a.real * b.real + a.imag * b.imag


def eq(a, b):
    return abs(a - b) < 1e-10


def on_line(p, s, e):
    d = dot(p - s, e - s)
    c = cross(p - s, e - s)
    if c == 0 and 0 <= d <= abs(e - s) ** 2:
        return True
    return False


def on_polygon_line(xy, p):
    for i in range(len(p)):
        j = i - 1
        if on_line(xy, p[i], p[j]):
            return True
    return False


def in_polygon(xy, p):
    wn = 0
    for i in range(len(p)):
        j = i - 1
        if 0 == (p[i] - p[j]).imag:
            continue
        vt = (xy - p[j]).imag / (p[i] - p[j]).imag
        tmp = p[j] + vt * (p[i] - p[j])
        if xy.real < tmp.real:
            wn += 1 if p[j].imag <= xy.imag < p[i].imag else\
                 -1 if p[i].imag <= xy.imag < p[j].imag else 0
    return wn

n = int(readline())
p = [map(int, readline().split()) for _ in range(n)]
p = [x + y * 1j for x, y in p]

q = int(readline())
for _ in range(q):
    x, y = map(int, readline().split())
    xy = x + y * 1j
    print(1 if on_polygon_line(xy, p) else 2 if in_polygon(xy, p) else 0)
Problem: p03103
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b=map(int,input().split())
e=[]
for i in range(a):
    c,d=map(int, input().split())
    e+=[[c,d]]
e.sort()
print(e)
a=i=j=0
while i < b:
    a+=(e[j][0]*e[j][1])
    i+=e[j][1]
    j+=1
print(a-((i-b)*e[j-1][0]))

Failing test case input:
4 12
10 18
1 0
3 9
13 0

Expected output:
57


Actual output:
[[1, 0], [3, 9], [10, 18], [13, 0]]
57


Fixed submission (verdict: Accepted):
a,b=map(int,input().split())
e=[]
for i in range(a):
    c,d=map(int, input().split())
    e+=[[c,d]]
e.sort()
a=i=j=0
while i < b:
    a+=(e[j][0]*e[j][1])
    i+=e[j][1]
    j+=1
print(a-((i-b)*e[j-1][0]))

Problem: p03103
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = [int(x) for x in input().split(' ')]
AB = {}
for i in range(N):
  a,b = [int(x) for x in input().split(' ')]
  AB[a] = b
  
dc = sorted(AB.items())

c = 0
m = M
for s in dc:
  d = m - s[1]
  if d >= 0:
    m -= s[1]
    c += s[0] * s[1]
    
    if d == 0:
      break
  else:
    print(s[1] + d,"xx")
    c += s[0] * (s[1] + d)
    
    break
print(c)

Failing test case input:
4 30
6 12
2 1
3 10
7 9

Expected output:
153


Actual output:
7 xx
153


Fixed submission (verdict: Accepted):
N,M = [int(x) for x in input().split(' ')]
AB = {}
for i in range(N):
  a,b = [int(x) for x in input().split(' ')]
  if a in AB:
    AB[a] += b
  else:
    AB[a] = b
    
dc = sorted(AB.items())

c = 0
m = M
for s in dc:
  price, stock = s
  if stock >= m:
    c += price * m
    break
  else:
    c += stock * price
    m -= stock
    
print(c)

Problem: p03103
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int,input().split())
L = []
ans, cnt = 0, 0
for i in range(n):
  ab = list(map(int,input().split()))
  L.append(ab)
L.sort()
for j in range(n):
  if m-cnt>=L[j][1]:
    cnt+=L[j][1]
    ans+=L[j][0]*L[j][1]
  else:
    ans+=L[j][0]*(m-cnt)
    break
  if ans==m:
    break
print(ans)

Failing test case input:
4 30
6 18
2 0
3 10
7 9

Expected output:
152


Actual output:
30


Fixed submission (verdict: Accepted):
n, m = map(int,input().split())
L = []
ans, cnt = 0, 0
for i in range(n):
  ab = list(map(int,input().split()))
  L.append(ab)
L.sort()
for j in range(n):
  if m-cnt>L[j][1]:
    cnt+=L[j][1]
    ans+=L[j][0]*L[j][1]
  else:
    ans+=L[j][0]*(m-cnt)
    break
print(ans)

Problem: p03103
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = map(int,input().split())
ab = []
for i in range(n):
	ab.append(list(map(int,input().split())))
    
sab = sorted(ab,key=lambda x:x[0])
cost = 0
for i in sab:
	print(cost,m)
	if m - i[1] > 0:
		m -= i[1]
		cost += i[0] * i[1]
	else:
		for j in range(m):
			cost += i[0]
		break
print(cost)

Failing test case input:
4 25
6 18
2 6
3 10
7 9

Expected output:
96


Actual output:
0 25
12 19
42 9
96


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())
ab = []
for i in range(n):
	ab.append(list(map(int,input().split())))
    
sab = sorted(ab,key=lambda x:x[0])
cost = 0
for i in sab:
	if m - i[1] > 0:
		m -= i[1]
		cost += i[0] * i[1]
	else:
		for j in range(m):
			cost += i[0]
		break
print(cost)
Problem: p03103
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M=map(int,input().split())


AB=[]
for i in range(N):
  ab=list(map(int,input().split()))
  AB.append(ab)


list.sort(AB,key=lambda x:x[0])


m=0 
cost=0 
for i in range(N):
 
 if M-m==AB[i][1]:
     m+=AB[i][1]
     cost+=AB[i][0]*AB[i][1]
     break

 elif M-m<AB[i][1] :
      for j in range(AB[i][1]+1):
         cost=cost+AB[i][0]*j
         m=m+j
         if m==M:
             break
         else:
             cost=cost-AB[i][0]*j
 else:
      cost+=AB[i][0]*AB[i][1]
      m+=AB[i][1]
    
print(cost)

Failing test case input:
4 30
6 18
2 8
3 10
2 8

Expected output:
86


Actual output:
62


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


AB=[]
for i in range(N):
  ab=list(map(int,input().split()))
  AB.append(ab)


list.sort(AB,key=lambda x:x[0])


m=0 
cost=0 
for i in range(N):
 
 if M-m==AB[i][1]:
     m+=AB[i][1]
     cost+=AB[i][0]*AB[i][1]
     break
 elif M-m<AB[i][1] :
      for j in range(AB[i][1]+1):
         cost=cost+AB[i][0]*j
         m=m+j
         if m==M:
             break
         elif m<M:
             cost=cost-AB[i][0]*j
             m=m-j
 else:
      cost+=AB[i][0]*AB[i][1]
      m+=AB[i][1]
    
print(cost)

Problem: p03103
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())

shop_dic = {}
for _ in range(N):
    a, b = map(int, input().split())
    shop_dic[a] = b

total = 0
for a in sorted(shop_dic.keys()):
    b = shop_dic[a]
    if M < b:
        total += a * M
        break
    else:
        total += a * b
        M -= b
print(total)


Failing test case input:
4 30
6 18
2 3
3 10
2 9

Expected output:
102


Actual output:
114


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

shop_list = [None] * N
for n in range(N):
    a, b = map(int, input().split())
    shop_list[n] = [a, b]

total = 0
for a, b in sorted(shop_list, key = lambda x: x[0]):
    if M > b:
        total += a * b
        M -= b
    else:
        total += a * M
        break
print(total)

Problem: p03103
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
read = sys.stdin.readline


def readln():
    return list(map(int, read().split()))


N, M = readln()

data = {}
for _ in range(N):
    a, b = readln()
    data[a] = b

ans = 0
drink = 0
for k, v in sorted(data.items()):
    ans += k * v
    drink += v
    if drink > M:
        break
print(ans-k*(drink-M))


Failing test case input:
4 30
5 18
2 8
4 10
2 9

Expected output:
89


Actual output:
113


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


def readln():
    return list(map(int, read().split()))


N, M = readln()

A = []
B = []
data = {}
for _ in range(N):
    a, b = readln()
    A.append(a)
    B.append(b)
    data[a] = 0

for a, b in zip(A, B):
    data[a] += b

ans = 0
drink = 0
for k, v in sorted(data.items()):
    ans += k * v
    drink += v
    if drink > M:
        break
print(ans-k*(drink-M))
Problem: p03103
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


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

A = [list(map(int, input().split())) for i in range(N)]
A = sorted(dict(A).items())

ans = 0
m = M
for a, b in A:
    if m <= b:
        ans += m*a
        break
    else:
        ans += b*a
        m -= b

print(ans)


Failing test case input:
4 30
5 18
2 8
5 10
2 9

Expected output:
99


Actual output:
68


Fixed submission (verdict: Accepted):


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

A = [list(map(int, input().split())) for i in range(N)]
A = sorted(A)

ans = 0
m = M
for a, b in A:
    if m <= b:
        ans += m*a
        break
    else:
        ans += b*a
        m -= b

print(ans)

Problem: p03103
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n,m=map(int,input().split())
dic={}
doll=0
for i in range(n):
  a,b=map(int,input().split())
  dic[a]=b
  
con=sorted(dic.items())

for k,v in con:
  if v<m:
    doll+=k*v
    m-=v
  else:
    doll+=k*m
    break
print(doll)

Failing test case input:
2 9
3 9
3 8

Expected output:
27


Actual output:
24


Fixed submission (verdict: Accepted):
n,m=map(int,input().split())
dic={}
doll=0
AB=[list(map(int,input().split())) for _ in range(n)]

AB.sort()

for k,v in AB:
  if v<m:
    doll+=k*v
    m-=v
  else:
    doll+=k*m
    break
print(doll)

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

sortedAB = sorted(AB, key=lambda x:x[0])

ans = 0
for i in range(N):
    a = sortedAB[i][0]
    b = sortedAB[i][1]
    if M == 0:
        print(ans)
        exit()
    if b <= M:
        M -= b
        ans += a*b
    else:
        ans += a*M


Failing test case input:
4 6
6 25
2 0
4 2
7 1

Expected output:
32


Actual output:

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

sortedAB = sorted(AB, key=lambda x:x[0])

ans = 0
for i in range(N):
    a = sortedAB[i][0]
    b = sortedAB[i][1]
    if M == 0:
        print(ans)
        exit()
    if b <= M:
        ans += a*b
        M -= b
    else:
        ans += a*M
        M = 0

print(ans)
Problem: p03103
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

a, b = map(int, input().split())
d = defaultdict(list)
array = []
for i in range(a):
    x, y = map(int, input().split())
    d[x].append(y)
    array.append(x)
array.sort()
count = 0
for i in array:
    if b <= d[i][0]:
        count += max(b, 0) * i
        break
    else:
        t = d[i][0]
        b -= t
        count += t * i
    d[i].pop()
print(count)

Failing test case input:
4 30
6 18
2 5
3 10
2 10

Expected output:
90


Actual output:
110


Fixed submission (verdict: Accepted):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

a, b = map(int, input().split())
d = []
for i in range(a):
    x, y = map(int, input().split())
    d.append((x, y))
d.sort()
count = 0
for i in range(a):
    if b <= d[i][1]:
        count += b * d[i][0]
        break
    else:
        b -= d[i][1]
        count += d[i][0] * d[i][1]
print(count)

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

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

a, b = map(int, input().split())
d = defaultdict(int)
array = []
for i in range(a):
    x, y = map(int, input().split())
    d[x] = y
    array.append(x)
array.sort()


count = 0
for i in array:
    if b <= d[i]:
        count += max(b, 0) * i
        break
    else:
        t = d[i]
        b -= t
        count += t * i
print(count)

Failing test case input:
4 10
10 25
2 0
2 2
1 1

Expected output:
75


Actual output:
59


Fixed submission (verdict: Accepted):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

a, b = map(int, input().split())
d = []
for i in range(a):
    x, y = map(int, input().split())
    d.append((x, y))
d.sort()
count = 0
for i in range(a):
    if b <= d[i][1]:
        count += b * d[i][0]
        break
    else:
        b -= d[i][1]
        count += d[i][0] * d[i][1]
print(count)
Problem: p03103
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())

A = []
for i in range(N):
    a, b = map(int, input().split())
    A.append([a, b])

A.sort(key=lambda x:x[0])

money = 0
cnt = 0
for i in range(N):
    for j in range(A[i][1]):
        money += A[i][0]
        if cnt == N:
            print(money)
            break

Failing test case input:
2 3
3 4
1 6

Expected output:
3


Actual output:

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

A = []
for i in range(N):
    a, b = map(int, input().split())
    A.append([a, b])

A.sort(key=lambda x:x[0])

money = 0
cnt = 0
for i in range(N):
    if cnt + A[i][1] < M: 
        money += A[i][0]*A[i][1]
        cnt += A[i][1]
    else: 
        money += A[i][0]*(M-cnt)
        print(money)
        break

Problem: p03103
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int, input().split())  

ans = 0





shop_list = []
for _ in range(N):
    hoge = {}
    A, B = map(int, input().split())
    hoge['price'] = A
    hoge['amount'] = B
    shop_list.append(hoge)
    hoge = {}

shop_list.sort(key=lambda x: x['price'])

quontity = 0
money = 0
for i in range(len(shop_list)):
    money += shop_list[i]['price']*shop_list[i]['amount']
    
    quontity += shop_list[i]['amount']
    
    if quontity >= M:
        money -= shop_list[i]['price']*(quontity-M)

print(money)


Failing test case input:
2 5
3 4
1 6

Expected output:
5


Actual output:
2


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

ans = 0





shop_list = []
for _ in range(N):
    hoge = {}
    A, B = map(int, input().split())
    hoge['price'] = A
    hoge['amount'] = B
    shop_list.append(hoge)
    hoge = {}

shop_list.sort(key=lambda x: x['price'])

quontity = 0
money = 0
for i in range(N):
    money += shop_list[i]['price']*shop_list[i]['amount']
    
    quontity += shop_list[i]['amount']
    
    if quontity >= M:
        money -= shop_list[i]['price']*(quontity-M)
        break

print(money)

Problem: p03103
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,m = map(int,input().split())
drink = dict()
cost = set()
ans = 0
for i in range(n):
    ab = [int(i) for i in input().split()]
    cost.add(ab[0])
    if ab[0] in drink:
        drink[ab[0]] += ab[1]
    else:
        drink[ab[0]] = ab[1]

sorted(cost)
for i in cost:
    if m <= drink[i]:
        ans += m*i
        break
    else:
        m -= drink[i]
        ans += i * drink[i] 
    
print(ans)

Failing test case input:
4 11
6 25
0 0
4 4
8 1

Expected output:
58


Actual output:
60


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())
drink = dict()
cost = list()
ans = 0
for i in range(n):
    ab = [int(i) for i in input().split()]
    if ab[0] in drink:
        drink[ab[0]] += ab[1]
    else:
        cost.append(ab[0])
        drink[ab[0]] = ab[1]

cost.sort()
for i in cost:
    if m <= drink[i]:
        ans += m*i
        break
    else:
        m -= drink[i]
        ans += i * drink[i] 
    
print(ans)
Problem: p03103
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, m = map(int, input().split())
t = {}
for i in range(n):
    a,b = map(int, input().split())
    t[a] = b
t = sorted(t.items())
print(t)
r = 0
for i in t:
    if i[1] < m:
        r += i[0]*i[1]
        m -= i[1]
    else:
        r += i[0]*(m)
        break
print(r)


Failing test case input:
4 30
0 18
2 5
3 10
7 9

Expected output:
31


Actual output:
[(0, 18), (2, 5), (3, 10), (7, 9)]
31


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
l = []
for i in range(n):
    a, b = map(int, input().split())
    l.append((a, b))

l = sorted(l)


r = 0
for i in l:
    if i[1] < m:
        r += i[0]*i[1]
        m -= i[1]
    else:
        r += i[0]*(m)
        break
print(r)

Problem: p03103
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]

ab_sorted = sorted(ab, key=lambda x:(x[0], -x[1]))
print(ab_sorted)

num = 0
amount_of_money = 0
for i in range(n):
  buy = min(ab_sorted[i][1], m-num)
  num += buy
  amount_of_money += ab_sorted[i][0] * buy
    
  if num >= m:
    print(amount_of_money)


Failing test case input:
2 1
4 9
1 2

Expected output:
1


Actual output:
[[1, 2], [4, 9]]
1
1


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

ab_sorted = sorted(ab, key=lambda x:(x[0], -x[1]))

num = 0
amount_of_money = 0
for i in range(n):
  buy = min(ab_sorted[i][1], m-num)
  num += buy
  amount_of_money += ab_sorted[i][0] * buy
    
  if num >= m:
    print(amount_of_money)
    exit(0)

Problem: p03103
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M = map(int,input().split())
li={}
for i in range(N):
	a,b = map(int,input().split())
	li[a]=b
li=sorted(li.items())
m_sum=0
for k,v in li:
	if v<M:
		M-=v
		m_sum+=k*v
	else:
		m_sum+=k*M
		break
print(m_sum)


Failing test case input:
4 30
6 18
2 8
2 10
2 9

Expected output:
72


Actual output:
126


Fixed submission (verdict: Accepted):
N,M = map(int,input().split())
li = [list(map(int,input().split())) for i in range(N)]
li=sorted(li,key=lambda x: x[0])
m_sum=0
for i in li:
	buy=min(M,i[1])
	m_sum+=i[0]*buy
	M-=buy
print(m_sum)

Problem: p03103
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, M = map(int,input().split())

A = []
for i in range(N):
  a,b = map(int,input().split())
  A.append([a,b])

A.sort()
print(A)

nokori = M
yen = 0
mise = 0
while nokori > 0:
  if A[mise][1] >= nokori: 
    yen += A[mise][0]*nokori
    break
  else:
    yen += A[mise][0]*A[mise][1]
    nokori -= A[mise][1]
    mise += 1
print(yen)
  

Failing test case input:
2 9
6 9
2 6

Expected output:
30


Actual output:
[[2, 6], [6, 9]]
30


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

A = []
for i in range(N):
  a,b = map(int,input().split())
  A.append([a,b])

A.sort()


nokori = M
yen = 0
mise = 0
while nokori > 0:
  if A[mise][1] >= nokori: 
    yen += A[mise][0]*nokori
    break
  else:
    yen += A[mise][0]*A[mise][1]
    nokori -= A[mise][1]
    mise += 1
print(yen)