ZhenlongDai/ACPR huggingface dataset:
Problem: p02714
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N=int(input())

S=input()
LEN=len(S)
END='EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE'
S += END

R=S.count('R')
G=S.count('G')
B=S.count('B')


cnt=0
for j in range(1, int((LEN-1)/2)):
    for i in range(LEN):
        if S[i+j+j]=='E':
            break
        if (S[i] != S[i+j]) and (S[i+j] != S[i+j+j]) and (S[i] != S[i+j+j]):
            cnt+=1

print(R*G*B-cnt)

Failing test case input:
4
RBRG

Expected output:
1


Actual output:
2


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

S=input()
LEN=len(S)
END='EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE'
S += END

R=S.count('R')
G=S.count('G')
B=S.count('B')


cnt=0
for j in range(1, int((LEN-1)/2)+1):
    for i in range(LEN-j*2):
        if S[i+j+j]=='E':
            break
        if (S[i] != S[i+j]) and (S[i+j] != S[i+j+j]) and (S[i] != S[i+j+j]):
            cnt+=1

print(R*G*B-cnt)

Problem: p02714
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
S = input()

R = [i+1 for i, x in enumerate(S) if x == 'R']
G = [i+1 for i, x in enumerate(S) if x == 'G']
B = [i+1 for i, x in enumerate(S) if x == 'B']

print(R)
print(G)
print(B)
ans = len(R) * len(G) * len(B)

count = 0

for r in R:
    for g in G:
        if (r+g)/2 in B:
            count += 1

for r in R:
    for b in B:
        if (r+b)/2 in G:
            count += 1

for g in G:
    for b in B:
        if (g+b)/2 in R:
            count += 1

print(ans - count)


Failing test case input:
39
RRBBGRRGGBBRRGBBRGBBGGBRBRBRBGBBBBBGBBR

Expected output:
1803


Actual output:
[1, 2, 6, 7, 12, 13, 17, 24, 26, 28, 39]
[5, 8, 9, 14, 18, 21, 22, 30, 36]
[3, 4, 10, 11, 15, 16, 19, 20, 23, 25, 27, 29, 31, 32, 33, 34, 35, 37, 38]
1803


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

R = [i+1 for i, x in enumerate(S) if x == 'R']
G = [i+1 for i, x in enumerate(S) if x == 'G']
B = [i+1 for i, x in enumerate(S) if x == 'B']

ans = len(R) * len(G) * len(B)

count = 0

for r in R:
    for g in G:
        a = r+g
        if a % 2 == 0:
            if S[int(a/2)-1] == 'B':
                count += 1

for r in R:
    for b in B:
        a = r+b
        if a % 2 == 0:
            if S[int(a/2)-1] == 'G':
                count += 1

for g in G:
    for b in B:
        a = g+b
        if a % 2 == 0:
            if S[int(a/2)-1] == 'R':
                count += 1

print(ans - count)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()
r,g,b = 0,0,0
r = s.count("R");g = s.count("G");b = s.count("B")
k=0    
count = r*g*b
print(count)
for j in range(n):
  for i in range(j):
    if (k==2*j-i)<n:
      if s[i]!=s[k]!=s[j]!=s[i]:
        count-=1   
print(count)

Failing test case input:
39
RBBGBBBBBGBRBBBBBGGBBGRBBGRRRBGGBRGRRRR

Expected output:
1817


Actual output:
1881
1710


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
ans=s.count("R")*s.count("G")*s.count("B")
for j in range(n):
  for i in range(j):
    if (k:=2*j-i)<n:
      if s[i]!=s[k]!=s[j]!=s[i]:
        ans-=1   
print(ans)
Problem: p02714
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = input()
s = list(input())
n = int(n)

r = s.count("R")
g = s.count("G")
b = s.count("B")
ans = r*g*b

for i in range(n):
    for a in range(i, n):
        j = i + a
        k = i +j
        if k >= n or j>= n:
            break
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            ans -= 1

print(ans)

Failing test case input:
39
RRRBRRBGGBBRRGGBRGBBGBBRGRBBBGBBBBBGBBR

Expected output:
1810


Actual output:
1826


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

r = s.count("R")
g = s.count("G")
b = s.count("B")
ans = r*g*b

for i in range(1,n):
    for j in range(min(i+1,n-i)):
        k = j*2 -i
        if j - i == k -j:
            if k <= n and s[i] != s[i+j] and s[i] != s[i-j] and s[i+j] != s[i-j]:
                ans -= 1
print(ans)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n= int(input())
s_list= list(input())
count=0
rr,bb,gg=0,0,0
for i in range(0,n):
    if s_list[i]=="R":
        rr=rr+1
    elif s_list[i]=="G":
        gg=gg+1
    else:
        bb=bb+1
sum=rr*gg*bb

for p in range(0,n-2):
    for q in range(p+1,n-1):
        if s_list[p] == s_list[q]:
            break
        else:
            for r in range(q+1,n):
                if s_list[r]==s_list[p] or s_list[r]==s_list[q] :
                    break
                elif r-q==q-p:
                    count = count+1
                    print(p,q,r)
print(sum-count)

Failing test case input:
39
BBBGBBBRBGBRBGBRBGGBRRGBBGRRBBGGBRRBRBR

Expected output:
1796


Actual output:
7 8 9
9 10 11
11 12 13
13 14 15
15 16 17
18 19 20
21 22 23
24 25 26
25 27 29
27 29 31
31 32 33
1870


Fixed submission (verdict: Accepted):
n= int(input())
s_list= list(input())
count=0
rr,bb,gg=0,0,0
for i in range(0,n):
    if s_list[i]=="R":
        rr=rr+1
    elif s_list[i]=="G":
        gg=gg+1
    else:
        bb=bb+1
sum=rr*gg*bb

for p in range(0,n-2):
    for q in range(p+1,n-1):
        if s_list[p] == s_list[q]:
            continue
        elif 2*q-p<n and s_list[2*q-p]!=s_list[p] and s_list[2*q-p]!=s_list[q]:
            count= count+1
print(sum-count)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
 
str = input()
sum = 0
pointer = n
for i in range(n-2):
  if i == pointer:
    break
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      if str[i] == str[j]:
        pointer = j
        break
      elif str[i] != str[k] and str[j] != str[k] and j - i != k - j:
        sum += 1
print(sum)

Failing test case input:
39
RRBBGRRBGBBRRGBBBGBBGGBRBRRRBGBBBBGGBBR

Expected output:
1808


Actual output:
1772


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

r = str.count('R')
g = str.count('G')
b = str.count('B')
sum = r * g * b
for i in range(n-2):
  for j in range(i+1, n-1):
    k = 2 * j - i
    if k < n:
      if str[i] != str[j] and str[i] != str[k] and str[j] != str[k] :
        sum -= 1
    
print(sum)
Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = input()

    ans = s.count('R') * s.count('G') * s.count('B')
    
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            k = (j - i) + j
            if k > n:
                
                break

            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                ans -= 1

    print(ans)


if __name__ == '__main__':
    main()


Failing test case input:
39
RRRRGRBGGBRRRGBBRGBBGGBBBBBRBGBBBBBGBBR

Expected output:
1817


Actual output:
1803


Fixed submission (verdict: Accepted):

import sys
input = sys.stdin.readline


def main():
    n = int(input())
    s = input()

    ans = s.count('R') * s.count('G') * s.count('B')
    
    for i in range(n - 2):
        for j in range(i + 1, n - 1):
            k = (j - i) + j
            if k >= n:
                
                break

            if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                ans -= 1

    print(ans)


if __name__ == '__main__':
    main()

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())  
S = input()  
L = {
    'R': tuple(i for i, v in enumerate(S) if v == 'R'),
    'G': tuple(i for i, v in enumerate(S) if v == 'G'),
    'B': tuple(i for i, v in enumerate(S) if v == 'B')
}
print(type(L['R']))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        if S[i] != S[j]:
            other = list({'R', 'G', 'B'} - {S[i], S[j]})[0]
            tmp = j + j - i
            ans += len([k for k in L[other] if (k > j) and (tmp != k)])
print(ans)





Failing test case input:
4
RGBR

Expected output:
0


Actual output:
<class 'tuple'>
0


Fixed submission (verdict: Accepted):
N = int(input())  
S = input()  
L = {
    'R': tuple(i for i, v in enumerate(S) if v == 'R'),
    'G': tuple(i for i, v in enumerate(S) if v == 'G'),
    'B': tuple(i for i, v in enumerate(S) if v == 'B')
}
R_length = len(L['R'])
G_length = len(L['G'])
B_length = len(L['B'])

ans = R_length * G_length * B_length
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if k >= N:
            break
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            ans -= 1
print(ans)
Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
S = input()

R = [i for i, x in enumerate(S) if x == 'R']
G = [j for j, y in enumerate(S) if y == 'G']
B = [k for k, z in enumerate(S) if z == 'B']
print(R, G, B)

cnt=0
for r in R:
    for g in G:
        for b in B:
            if abs(g-r) != abs(b-g) and \
                abs(b-r) != abs(g-b) and \
                abs(r-b) != abs(g-r):
                cnt+=1

print(cnt)


Failing test case input:
39
RRRBGRBGGBBRRGBBRGBBGGBRBRBRBGBBBBBGBBR

Expected output:
1806


Actual output:
[0, 1, 2, 5, 11, 12, 16, 23, 25, 27, 38] [4, 7, 8, 13, 17, 20, 21, 29, 35] [3, 6, 9, 10, 14, 15, 18, 19, 22, 24, 26, 28, 30, 31, 32, 33, 34, 36, 37]
1806


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

R = [X for X, x in enumerate(S) if x == 'R']
G = [Y for Y, y in enumerate(S) if y == 'G']
B = [Z for Z, z in enumerate(S) if z == 'B']

mae = len(R)*len(G)*len(B)

cnt=0
for i in range(0,N-2):
    for j in range(i+1,N-1):
        k = 2*j-i
        if k >=N:
            break
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            cnt+=1

print(mae-cnt)

Problem: p02714
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
S = input()
 
r = S.count('R')
g = S.count('G')
b = S.count('B')
max = r * g * b 
 
count = 0
for i in range(N-2):
	for j in range(i+1, N-1):
		k = 2 * j - i
		if k > N - 1:
			break
	
		if S[i] != S[j] and S[j] != S[k] and S[i] == S[k]:
			count += 1
		
		
 
print(max - count)

Failing test case input:
39
RRRBGRBGGBBRRGBBRBBBGGBRRGBRBGBRBBBGBBB

Expected output:
1804


Actual output:
1802


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
 
r = S.count('R')
g = S.count('G')
b = S.count('B')
max = r * g * b 
 
count = 0
for i in range(N-2):
	for j in range(i+1, N-1):
		k = 2 * j - i
		if k > N - 1:
			break
	
		if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
			count += 1
		
		
 
print(max - count)
Problem: p02714
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys

input = sys.stdin.readline

N = int(input())
S = input().strip()

dic = {}
ans = 0

for i in range(N-2):
    dic['R'] = S[i+1:].count('R')
    dic['G'] = S[i+1:].count('G')
    dic['B'] = S[i+1:].count('B')
    for j in range(i+1, N-1):
        dic[S[j]] -= 1
        arr = ['R', 'G', 'B']
        if S[i] != S[j]:
            arr.remove(S[i])
            arr.remove(S[j])
            ans += dic[arr[0]]
        if j+j-i <= N-1 and S[j+j-i] == arr[0]:
            ans -= 1

        

print(ans)

Failing test case input:
39
RGBBGRRGGBBRRGBBRRBBGGBRBRBBBRBBBBBGBGR

Expected output:
1807


Actual output:
1776


Fixed submission (verdict: Accepted):
import sys

input = sys.stdin.readline

N = int(input())
S = input().strip()

dic = {}
ans = 0

for i in range(N-2):
    dic['R'] = S[i+1:].count('R')
    dic['G'] = S[i+1:].count('G')
    dic['B'] = S[i+1:].count('B')
    for j in range(i+1, N-1):
        dic[S[j]] -= 1
        arr = ['R', 'G', 'B']
        if S[i] != S[j]:
            arr.remove(S[i])
            arr.remove(S[j])
            ans += dic[arr[0]]
            if j+j-i <= N-1 and S[j+j-i] == arr[0]:
                ans -= 1

print(ans)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

N = int(input())
S = input()

idxs = [i for i in range(N)]

ris = [i for i, s in enumerate(S) if s == "R"]
gis = [i for i, s in enumerate(S) if s == "G"]
bis = [i for i, s in enumerate(S) if s == "B"]

ans = 0
for ri in ris:
    for gi in gis:
        for bi in bis:
            i, j, k = sorted([ri, gi, bi])
            if k - j != j - i:
                ans += 1


Failing test case input:
39
RRRBGRBGGBRRRGBBBBBBGGBRBGBRBGRBBBBGBBR

Expected output:
1814


Actual output:

Fixed submission (verdict: Accepted):

N = int(input())
S = input()

ris = [i for i, s in enumerate(S) if s == "R"]
gis = [i for i, s in enumerate(S) if s == "G"]
bis = [i for i, s in enumerate(S) if s == "B"]

all = len(ris) * len(gis) * len(bis)

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = 2*j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                cnt += 1

ans = all - cnt


print(ans)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
S = list(input())
A = S.count("R") * S.count("G") * S.count("B")

for i in range(N-3):
  for j in range(i+1, N-1):
    k = j-i+j
    if k<N and S[k] != S[j] and S[k] != S[i] and S[i] !=S[j]:
      A -= 1

print(A)


Failing test case input:
4
RBGR

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
A = S.count("R") * S.count("G") * S.count("B")

for i in range(N):
  for j in range(i+1, N):
    k = j-i+j
    if k<N and S[k] != S[j] and S[k] != S[i] and S[i] !=S[j]:
      A -= 1    

print(A)
Problem: p02714
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
s = input()
r = s.count("R")
g = s.count("G")
b = s.count("B")

ans = 0
if r > 1 and g > 1 and b > 1:
    ans = r*g*b
    for i in range(1,n):
        m = min(i,n-i-1)
        for j in range(1,m+1):
            A,B,C = s[i],s[i-j],s[i+j]
            if A != B and A != C and B != C:
                ans -= 1
else:
    ans = 1
print(ans)


Failing test case input:
4
RGBR

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
r = s.count("R")
g = s.count("G")
b = s.count("B")
ret = 0
for i in range(1,n-1):
    m = min(i,n-i-1)
    for j in range(1,m+1):
        A,B,C = s[i],s[i-j],s[i+j]
        if A != B and A != C and B != C:
            ret += 1
ans = r*g*b - ret
print(ans)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
S = input()
R = 0
G = 0
B = 0
ans = 0
for i in range(N):
    if S[i] == 'R':
        R+= 1
    elif S[i] =='G':
        G+= 1
    else:
        B+= 1
ans = R*G*B
for i in range(int(N/2)):
    for j in range(i,N-i):
        if S[j-i] != S[j] and S[j] != S[j+i] and S[j+i] != S[j-i]:
            ans -= 1

print(ans)

Failing test case input:
39
RRGRRRBGGBBRRBBBRRBBRGBBBBBRBGBGGBBGBBG

Expected output:
1827


Actual output:
1828


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
R = 0
G = 0
B = 0
ans = 0
for i in range(N):
    if S[i] == 'R':
        R+= 1
    elif S[i] =='G':
        G+= 1
    else:
        B+= 1
ans = R*G*B
for i in range(int((N+1)/2)):
    for j in range(i,N-i):
        if S[j-i] != S[j] and S[j] != S[j+i] and S[j+i] != S[j-i]:
            ans -= 1

print(ans)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
S = "A"
S += input()
print(S)
r = 0
g = 0
b = 0
k = 0
for i in range(1, N+1):
    if S[i] == "R":
        r += 1
    elif S[i] == "G":
        g += 1
    else:
        b += 1

sum = r * g * b
for i in range(1, N-1):
    for j in range(i+1,N):
        if 2*j - i <= N:
            k = 2*j - i
            if S[j] != S[i] and S[k] != S[j] and S[i] != S[k]:
                sum -= 1

print(sum)


Failing test case input:
39
RRBBGRRGGBBRRGBBRGBBGGBRBRBGBRBBBBBGBBR

Expected output:
1807


Actual output:
ARRBBGRRGGBBRRGBBRGBBGGBRBRBGBRBBBBBGBBR
1807


Fixed submission (verdict: Accepted):
N = int(input())
S = "A"
S += input()
r = 0
g = 0
b = 0
k = 0
for i in range(1, N+1):
    if S[i] == "R":
        r += 1
    elif S[i] == "G":
        g += 1
    else:
        b += 1

sum = r * g * b
for i in range(1, N-1):
    for j in range(i+1,N):
        k = 2*j - i
        if k <= N:
            if S[j] != S[i] and S[k] != S[j] and S[i] != S[k]:
                sum -= 1

print(sum)
Problem: p02714
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
s = input()
 
r = s.count('R')
g = s.count('G')
b = s.count('B')
 
ans = r*g*b
 
for i in range(n):
  for j in range(i+1, n):
    if s[i] != s[j] and s[i] != s[int((i+j)/2)] and s[int((i+j)/2)] != s[j]:
      ans -= 1
print(ans)

Failing test case input:
39
RBBGBBBBBRBRBRGRBBGBBGRBGGGRBBGGBRBBRRR

Expected output:
1810


Actual output:
1737


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
 
r = s.count('R')
g = s.count('G')
b = s.count('B')
 
ans = r*g*b
 
for i in range(n):
  for j in range(i+2, n, 2):
    if s[i] != s[j] and s[i] != s[int((i+j)/2)] and s[int((i+j)/2)] != s[j]:
      ans -= 1
print(ans)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N= int(input())
S=input()
r=[]
g=[]
b=[]
A=0
B=0
C=0
for i in range(N):
    if S[i]=="R":
        r.append(i)
        A+=1
    elif S[i]=="G":
        g.append(i)
        B+=1
    else:
        b.append(i)
        C+=1
k=0
for i in range(N-2):
    for j in range(i+1,N-1):
        t=2*j-i
        if t<N:
            if S[i]!=S[j] and S[i]!=S[t] and S[t]!=S[j] :
                k+=1
                print(i,j,t)
print(k)
print(A*B*C-k)

Failing test case input:
39
RRRBGRBGGBBRRGBBRRBBGGBRBGBRBGBBBBBGBBR

Expected output:
1811


Actual output:
0 7 14
0 10 20
0 13 26
1 8 15
1 15 29
1 18 35
2 3 4
2 4 6
2 8 14
2 13 24
3 4 5
3 5 7
3 7 11
3 12 21
3 13 23
3 16 29
4 5 6
4 10 16
4 11 18
4 16 28
4 17 30
5 6 7
5 7 9
5 9 13
5 15 25
5 21 37
7 9 11
7 11 15
7 15 23
8 10 12
8 11 14
8 16 24
8 17 26
9 11 13
9 13 17
9 17 25
10 13 16
11 13 15
11 18 25
11 21 31
12 13 14
12 20 28
12 21 30
13 15 17
13 16 19
13 18 23
13 23 33
14 17 20
15 21 27
16 18 20
16 20 24
16 21 26
16 25 34
17 19 21
17 25 33
17 26 35
19 21 23
19 27 35
20 23 26
20 27 34
21 22 23
21 24 27
21 27 33
23 24 25
23 26 29
25 26 27
27 28 29
27 29 31
27 31 35
32 35 38
70
1811


Fixed submission (verdict: Accepted):
N= int(input())
S=input()
r=[]
g=[]
b=[]
A=0
B=0
C=0
for i in range(N):
    if S[i]=="R":
        r.append(i)
        A+=1
    elif S[i]=="G":
        g.append(i)
        B+=1
    else:
        b.append(i)
        C+=1
k=0
for i in range(N-2):
    for j in range(i+1,N-1):
        t=2*j-i
        if t<N:
            if S[i]!=S[j] and S[i]!=S[t] and S[t]!=S[j] :
                k+=1

print(A*B*C-k)
Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
_input = input





N=int(input())
S=input()

RGB_num=[0]*3

for c in S:
	if c=='R':
		RGB_num[0] += 1
	elif c=='G':
		RGB_num[1] += 1
	else:
		RGB_num[2] += 1


joken2=0

print(S[0])
for i in range(N-2):
	
	for j in range(min(i+1,N-i-2)):
		if S[i+1] != S[i-j] and S[i+1] != S[i+j+2] and S[i-j] != S[i+j+2]:
			joken2 += 1
			
		
			

joken1=RGB_num[0]*RGB_num[1]*RGB_num[2]

print(joken1-joken2)

input = _input


Failing test case input:
39
RBBGRBBBBGBBBBBBBGGBBGRBBGRRRBGGBRGRRRR

Expected output:
1823


Actual output:
R
1823


Fixed submission (verdict: Accepted):
_input = input





N=int(input())
S=input()

RGB_num=[0]*3

for c in S:
	if c=='R':
		RGB_num[0] += 1
	elif c=='G':
		RGB_num[1] += 1
	else:
		RGB_num[2] += 1


joken2=0

for i in range(N-2):
	
	for j in range(min(i+1,N-i-2)):
		if S[i+1] != S[i-j] and S[i+1] != S[i+j+2] and S[i-j] != S[i+j+2]:
			joken2 += 1
			
		
			

joken1=RGB_num[0]*RGB_num[1]*RGB_num[2]

print(joken1-joken2)

input = _input
Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int,input().split())

ablist=[]
aslist=[]
s=0
for _ in range(N):
  a,b=map(int,input().split())
  ablist.append((a,b))
  s+=b
  aslist.append((a,s))


for a,s in aslist:
  if s>=K:
    print(a)
    break

Failing test case input:
3 3
2 2
1 1
8 3

Expected output:
2


Actual output:
1


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

ablist=[]
for _ in range(N):
  a,b=map(int,input().split())
  ablist.append((a,b))
ablist.sort()
  
aslist=[]
s=0
for a,b in ablist:
  s+=b
  aslist.append((a,s))


for a,s in aslist:
  if s>=K:
    print(a)
    break

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

count = 0
for x in ab:
    count += x[1]
    if k <= count:
        print(x[0])
        break

Failing test case input:
3 3
2 2
1 1
3 3

Expected output:
2


Actual output:
1


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

count = 0
for x in ab:
    count += x[1]
    if k <= count:
        print(x[0])
        break

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
d={}
for i in range(n):
	a,b=map(int,input().split())
	if a in d:d[a]+=b
	else:d[a]=b
cnt=0
for i in d.items():
	if cnt+i[1]>=k:
		print(i[0]);quit()
	cnt+=i[1]

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

Expected output:
8


Actual output:
3


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
d={}
for i in range(n):
	a,b=map(int,input().split())
	if a in d:d[a]+=b
	else:d[a]=b
cnt=0
d=sorted(tuple(d.items()),key=lambda a:a[0])
for i in d:
	if cnt+i[1]>=k:
		print(i[0]);quit()
	cnt+=i[1]

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = [int(x) for x in input().split()]

array = []
count = 0
for i in range(N):
    array.append(tuple(map(int, input().split())))

array.sort()
K -= 1
for tup in array:
    if K < tup[1]:
        print(tup[0])
    else:
        K -= tup[1]

Failing test case input:
6 500000
1 100000
1 110000
1 100100
1 101000
1 100100
100000 100000
100000 100010
100000 100000
000100 100110
100000 100000

Expected output:
1


Actual output:
1
100000


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

array = []
count = 0
for i in range(N):
    array.append(tuple(map(int, input().split())))

array.sort()
K -= 1
for tup in array:
    if K < tup[1]:
        print(tup[0])
        break
    else:
        K -= tup[1]
Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for i in range(N):
    cnt += ab[i][1]
    if cnt >= K:
        print(ab[i][0])
        break


Failing test case input:
3 3
2 2
1 1
5 3

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N,K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
ab.sort(key=lambda x: x[0])
cnt = 0
for i in range(N):
    cnt += ab[i][1]
    if cnt >= K:
        print(ab[i][0])
        break

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    len_s = 0
    ans = -1
    N, K = map(int, input().split())
    for _ in range(N):
        a, b = map(int, input().split())
        len_s += b
        if ans == -1 and len_s >= K:
            ans = a
    print(ans)
if __name__ == '__main__':
    main()

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

Expected output:
8


Actual output:
3


Fixed submission (verdict: Accepted):
def main():
    len_s = 0
    ans = -1
    dic = {}
    N, K = map(int, input().split())
    for _ in range(N):
        a, b = map(int, input().split())
        if a not in dic:
            dic[a] = b
        else:
            dic[a] += b
    dic = sorted(dic.items())
    for key, value in dic:
        len_s += value
        if len_s >= K and ans == -1:
            ans = key
    print(ans)
if __name__ == '__main__':
    main()

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
a,b=map(int,input().split())
l=[a]
numl=[0,b]
for i in range(n-1):
    a,b=map(int,input().split())
    l.append(a)
    numl.append(numl[-1]+b)
for i in range(n,-1,-1):
    if k>numl[i]:
        print(l[i])
        break

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

Expected output:
8


Actual output:
3


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
l=[0]*(10**5+1)
for i in range(n):
    a,b=map(int,input().split())
    l[a]+=b
inc=0
for i in range(10**5+1):
    inc+=l[i]
    if inc>=k:
        print(i)
        break

Problem: p03721
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N,K = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(N)]
cnt  = 0
for i in range(N):
    cnt += a[i][1]
    if cnt >= K:
        print(a[i][0])
        exit()

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

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N,K = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(N)]
a.sort()
cnt = 0
for i in range(N):
    cnt += a[i][1]
    if cnt >= K:
        print(a[i][0])
        exit()
Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
num = 0
for i in range(N): 
    num += ab[i][1]
    if num >= K:
        del ab[i+1:]
        ab.sort()
        print(ab[i][0])
        break

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

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):

import sys
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
now = 0
ab.sort()
for a, b in ab:
    now += b
    if now >= K:
            print(a)
            sys.exit()

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict
N, K = map(int, input().split())
seq = defaultdict(lambda: 0) 
values = []
for i in range(N):
    a, b = map(int, input().split())
    seq[a] += b
    values.append(a)

values.sort()
ans = 0
for i in range(len(values)):
    K -= seq[values[i]]
    if(K<=0):
        print(values[i])
        break



Failing test case input:
10 878093
1 100000
1 110001
1 100000
1 100001
1 100000
100000 100000
100000 100000
100000 100000
100000 100000
100000 100000

Expected output:
100000


Actual output:
1


Fixed submission (verdict: Accepted):
from collections import defaultdict
N, K = map(int, input().split())
seq = defaultdict(lambda: 0) 
for i in range(N):
    a, b = map(int, input().split())
    seq[a] += b

values = list(seq.keys())

values.sort()
ans = 0
for i in range(len(values)):
    K -= seq[values[i]]
    if(K<=0):
        print(values[i])
        break

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int, input().split())
for _ in range(n):
    a,b = map(int, input().split())
    if k>b:
        k -= b
    else:
        print(a)
        exit()

Failing test case input:
3 0
2 2
0 0
3 6

Expected output:
0


Actual output:
2


Fixed submission (verdict: Accepted):
n,k = map(int, input().split())
res = [0]*(10**5+1)
for _ in range(n):
    a,b = map(int, input().split())
    res[a] += b

for i, x in enumerate(res):
    if k>x:
        k -= x
    else:
        print(i)
        exit()

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int,input().split())
D,L={},[]
for _ in range(N):
    a,b=map(int,input().split())
    L.append(a)
    if a in D:D[a]=D[a]+b
    else:D[a]=b
L.sort()
for i in L:
    K-=D[i]
    if K<=0:
        print(i)
        exit()

Failing test case input:
3 5
4 2
4 1
8 5

Expected output:
8


Actual output:
4


Fixed submission (verdict: Accepted):
N,K=map(int,input().split())
D,L={},[]
for _ in range(N):
    a,b=map(int,input().split())
    L.append(a)
    if a in D:D[a]=D[a]+b
    else:D[a]=b
l=list(set(L))
l.sort()
for i in l:
    K-=D[i]
    if K<=0:
        print(i)
        exit()
Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int,input().split())
X=[]
for i in range (N):
	A=list(map(int,input().split()))
	X.append(A)
Y=sorted(X, key=lambda x:x[0])
tmp=0
for i in range (len(Y)):
	M=X[i][1]
	tmp+=int(M)
	if tmp>K-1:
		print(X[i][0])
		exit()

Failing test case input:
3 3
2 2
1 1
3 3

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N,K=map(int,input().split())
X=[]
for i in range (N):
	A=list(map(int,input().split()))
	X.append(A)
Y=sorted(X, key=lambda x:x[0])
tmp=0
for i in range (len(Y)):
	M=Y[i][1]
	tmp+=int(M)
	if tmp>=K:
		print(Y[i][0])
		exit()

Problem: p03721
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N,K = map(int,input().split())

count = 0

for i in range(N):
  a,b  = map(int,input().split())
  count += b
  if count >= K:
    print(a)
    break

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

Expected output:
8


Actual output:
3


Fixed submission (verdict: Accepted):
N,K = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N)]
ab.sort()
count = 0

for i in range(N):
  a,b  = ab[i][0],ab[i][1]
  count += b
  if count >= K:
    print(a)
    break

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

import sys
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
now = 0
ans = ""
for a, b in ab:
    for i in range(b):
        now += 1
        if now == K:
            print(a)
            sys.exit()

Failing test case input:
3 3
2 2
1 1
3 3

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):

import sys
N, K = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
now = 0
ab.sort()
for a, b in ab:
    now += b
    if now >= K:
            print(a)
            sys.exit()

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

ans = 0
flag = True
for i in range(N):
    a,b = map(int,input().split())
    K -= b
    if K <= 0 and flag:
        ans = a
        flag = False

print(ans)

Failing test case input:
3 3
2 2
1 1
3 3

Expected output:
2


Actual output:
1


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

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

ab.sort()

tmp = 0
for a,b in ab:
    tmp += b
    if tmp >= K:
        print(a)
        break

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = [int(x) for x in input().split()]

A = [[0]*2 for i in range(N)]



for i in range(N):
	A[i] = [int(x) for x in input().split()]

counter = 0
for i in range(N):
	counter += A[i][1]
	if counter >= K:
		break

print(A[i][0])

Failing test case input:
3 3
2 2
1 1
3 3

Expected output:
2


Actual output:
1


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

A = [[0]*2 for i in range(N)]



for i in range(N):
	A[i] = [int(x) for x in input().split()]

A.sort()

counter = 0
for i in range(N):
	counter += A[i][1]
	if counter >= K:
		break

print(A[i][0])
Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K =map(int,input().split())

LIST=[[0,0] for i in range(N)]

for i in range(N):
    LIST[i][0],LIST[i][1]=map(int,input().split())

sorted(LIST)

c=0
for i in range(N):
    c+=LIST[i][1]
    if(c>=K):
        print(LIST[i][0])
        exit()



Failing test case input:
3 0
2 2
0 0
3 6

Expected output:
0


Actual output:
2


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

LIST=[[0,0] for i in range(N)]

for i in range(N):
    LIST[i][0],LIST[i][1]=map(int,input().split())

LIST=sorted(LIST)

c=0
for i in range(N):
    c+=LIST[i][1]
    if(c>=K):
        print(LIST[i][0])
        exit()

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

for i in range(N):
    if cnt <= K <= cnt + B[i]:
        print(A[i]) 
        break
    cnt += B[i]

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

Expected output:
8


Actual output:
3


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
lis = []
for i in range(N):
    a, b = map(int, input().split())
    lis.append([a,b])
lis = sorted(lis)
cnt = 0
for x, y in lis:
    if cnt <= K <= cnt + y: 
        print(x)
        break
    else:
        cnt += y

Problem: p03721
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n, k = map(int, input().split())
a = []
b = []
for i in range(n):
  a_, b_ = map(int, input().split())
  a.append(a_)
  b.append(b_)

for i in range(n):
  k = k-b[i]
  if k <= 0:
    print(a[i])
    exit()

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

Expected output:
4


Actual output:
3


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

ab.sort()

for i in range(n):
  k = k-ab[i][1]
  if k <= 0:
    print(ab[i][0])
    exit()

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

num = 0
for i in range(N):
    a, b = map(int, input().split())
    num += b
    if num >= K:
        print(a)
        break


Failing test case input:
3 3
2 2
1 1
8 3

Expected output:
2


Actual output:
1


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

num = 0
for i in range(N):
    num += l[i][1]
    if num >= K:
        print(l[i][0])
        break
Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict as dd
def main():
    N, K = map(int, input().split())

    d = dd(int)
    for n in range(N):
        a,b = map(int, input().split())
        d[a] += b

    count = 0
    for k, v in d.items():
        
        count += v
        if count >= K:
            print(k)
            return


if __name__ == "__main__":
    
    
    main()



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

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
from collections import defaultdict as dd
def main():
    N, K = map(int, input().split())

    d = dd(int)
    for n in range(N):
        a,b = map(int, input().split())
        d[a] += b

    count = 0
    A = sorted(d.keys())
    for k in A:
        
        count += d[k]
        if count >= K:
            print(k)
            break

if __name__ == "__main__":
    
    
    main()

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

sums = 0

nums = []

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

for i in range(len(nums)):
  if nums[i][0] > 4:
    print(nums[i][1])
    break

Failing test case input:
3 5
2 2
1 1
8 5

Expected output:
8


Actual output:
5


Fixed submission (verdict: Accepted):
N , K = map(int,(input().split()))
 
sums = 0
nums = [0] * (10 ** 5 + 1) 
con = 0
ans = 0
 
for i in range(N):
  a,b = map(int,(input().split()))
  nums[a] += b
  
for i in range(len(nums)):
  con += nums[i]
  if K > con:
    continue
  elif K <= con:
    ans = i
    break

    
print(ans)

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
list=[]
for i in range(n):
    a,b=map(int,input().split())
    for j in range(b): list.append(a)
    if len(list)>=k: break

ans=list[k-1]
print(ans)

Failing test case input:
3 3
2 2
1 1
5 3

Expected output:
2


Actual output:
1


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

count=0
for i in range(n):
    count+=list[i][1]
    if count>=k: ans=list[i][0]; break


print(ans)

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
for i in range(n):
    a, b = map(int, input().split())
    k -= b
    if k <= 0:
        print(a)
        break


Failing test case input:
3 3
2 2
1 1
8 3

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
l = [0] * 100001
for i in range(n):
    a, b = map(int, input().split())
    l[a] += b
for i, j in enumerate(l):
    k -= j
    if k <= 0:
        print(i)
        break
Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict

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

a = []
b = []

for i in range(N):
	a_i, b_i = map(int, input().split( ))
	a.append(a_i)
	b.append(b_i)

d = defaultdict(int)

for i in range(N):
    if a[i] in d:
        d[a[i]] += b[i]
    else:
        d[a[i]] = b[i]

d_sorted = sorted(d.items())

l = 0
for a_i,b_i in d.items():
	l += b_i
	if l >= K:
		print(a_i)
		break

Failing test case input:
3 3
2 2
1 1
3 3

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
from collections import defaultdict

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

a = []
b = []

for i in range(N):
	a_i, b_i = map(int, input().split( ))
	a.append(a_i)
	b.append(b_i)

d = defaultdict(int)

for i in range(N):
    if a[i] in d:
        d[a[i]] += b[i]
    else:
        d[a[i]] = b[i]

d_sorted = sorted(d.items())

l = 0

for i in range(N):
	a_i = d_sorted[i][0]
	b_i = d_sorted[i][1]
	l += b_i
	if l >= K:
		print(a_i)
		break

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int,input().split())
ans={}
for i in range(N):
    a,b=map(int,input().split())
    if a in ans:ans[a]+=b
    else :ans[a]=b
ans=sorted(ans.items(),key=lambda x:x[0])
print(ans)
for key,value in ans:
    K-=value
    if K<=0:break
print(key)

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

Expected output:
3


Actual output:
[(3, 5), (4, 1)]
3


Fixed submission (verdict: Accepted):
N,K=map(int,input().split())
ans={}
for i in range(N):
    a,b=map(int,input().split())
    if a in ans:ans[a]+=b
    else :ans[a]=b
ans=sorted(ans.items(),key=lambda x:x[0])
for key,value in ans:
    K-=value
    if K<=0:break
print(key)

Problem: p03721
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N, K = map(int, input().split())
a = []
b = []
Sum = 0
for i in range(N):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
s = [*range(len(a))]
sort_s = sorted(s, key = lambda i: a[i])
sort_a = [a[i] for i in sort_s]
sort_b = [b[i] for i in sort_s]
for i in range(N):
    Sum += b[i]
    if Sum >= K:
        print(a[i])
        break

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

Expected output:
8


Actual output:
3


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
a = []
b = []
Sum = 0
for i in range(N):
    x, y = map(int, input().split())
    a.append(x)
    b.append(y)
s = [*range(len(a))]
sort_s = sorted(s, key = lambda i: a[i])
sort_a = [a[i] for i in sort_s]
sort_b = [b[i] for i in sort_s]
for i in range(N):
    Sum += sort_b[i]
    if Sum >= K:
        print(sort_a[i])
        break
Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
a = [0] * n
b = [0] * n
sum = 0
arr = []
for i in range(n):
    a[i], b[i] = map(int, input().split())

arr_list = list(zip(a, b))

arr_list.sort()


for i in range(n):
    
    sum += arr_list[i][1]
    if sum >= k:
        answer = a[i]
        break

print(answer)


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

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
a = [0] * n
b = [0] * n
sum = 0
arr = []
for i in range(n):
    a[i], b[i] = map(int, input().split())
arr_list = list(zip(a, b))
arr_list = sorted(arr_list)

for i in range(n):
    sum += arr_list[i][1]
    
    if sum >= k:
        answer = arr_list[i][0]
        break

print(answer)

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



N, K = list(map(int, input().split()))
ab_list = []

for _ in range(N):
    a, b = list(map(int, input().split()))
    ab_list.append((a, b))

ab_list = sorted(ab_list, key=lambda x: x[0])
c = 0
for a, b in ab_list:
    c += a ** b
    if c > K:
        ans = a

print(ans)



Failing test case input:
3 4
1 2
2 5
3 2

Expected output:
2


Actual output:
3


Fixed submission (verdict: Accepted):



N, K = list(map(int, input().split()))
ab_list = []

for _ in range(N):
    a, b = list(map(int, input().split()))
    ab_list.append((a, b))

ab_list = sorted(ab_list, key=lambda x: x[0])
c = 0
for a, b in ab_list:
    c += b
    if c >= K:
        ans = a
        break

print(ans)

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
AB = []
N, K = map(int, input().split())

for _ in range(N):
    a, b = map(int, input().split())
    for _ in range(a):
        AB.append((a, b))

AB.sort()
for ab in AB:
    K -= ab[1]
    if K <= 0:
        print(ab[0])
        exit()

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

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
AB = []
N, K = map(int, input().split())

for _ in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))

AB.sort()
for ab in AB:
    K -= ab[1]
    if K <= 0:
        print(ab[0])
        exit()

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

ans = 0
flag = True
for i in range(N):
    a,b = map(int,input().split())
    K -= b
    if K < 0 and flag:
        ans = a
        flag = False

print(ans)

Failing test case input:
3 3
2 2
1 1
5 3

Expected output:
2


Actual output:
5


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

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

ab.sort()

tmp = 0
for a,b in ab:
    tmp += b
    if tmp >= K:
        print(a)
        break
Problem: p03721
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    count = 0
    d = []
    l = {}
    for i in range(N):
        a,b = map(int, input().split())
        d.append(a)
        l[a] = b
    d.sort()
    
    for i in d:
        count += l[i]
        if count >= K:
            print(i)
            break
        

        

if __name__ == "__main__":
    main()


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

Expected output:
1


Actual output:
4


Fixed submission (verdict: Accepted):
import sys
from collections import defaultdict
def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    count1 = 0
    count2 = 0
    d = []
    l = defaultdict(int)
    
    for i in range(N):
        a,b = map(int, input().split())
        l[a] += b


    for i, j in sorted(l.items()):
        count2 += j
        if count2 >= K:
            print(i)
            break
        

        

if __name__ == "__main__":
    main()

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int,input().split())
s = [list(map(int,input().split())) for i in range(n)]
y = 0 

for i in range(n):
    y = y + s[i][1]
    if y >= k:
        print(s[i][0])
        break

Failing test case input:
3 3
2 2
1 1
5 3

Expected output:
2


Actual output:
1


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

x = 0

for i in range(len(s)):
    x = x + s[i][1]
    if x >= k:
        print(s[i][0])
        break

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n)]
A.sort()
i=-1
count=0
ans=0
while count<k:
  i+=1
  ans=A[i][0]
  count+=A[i][1]
  print(ans)
  print(count)
print(ans)

Failing test case input:
10 500000
1 110000
1 100000
1 100000
1 100100
1 100000
100000 100000
100000 100000
100000 100000
100000 100000
100000 100000

Expected output:
1


Actual output:
1
100000
1
200000
1
300000
1
400100
1
510100
1


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n)]
A.sort()
i=-1
count=0
ans=0
while count<k:
  i+=1
  ans=A[i][0]
  count+=A[i][1]
print(ans)

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))
s = 0
for a, b in ab:
    if s+b>=k:
        print(a)
        break
    s += b

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

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
di = {}
for _ in range(n):
    a, b = map(int, input().split())
    if a in di:
        di[a] += b
    else:
        di[a] = b
di = list(di.items())
di.sort()
s = 0
for a, b in di:
    if s+b>=k:
        print(a)
        break
    s += b
Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    k -= b
    
    if k <= 0:
        print(a)
        break

Failing test case input:
3 3
2 2
1 1
3 3

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n,k = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(n)]
AB = sorted(AB)

for i in AB:
    a = i[0]
    b = i[1]
    
    k -= b
    
    if k < 1:
        print(a)
        break

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
s=sorted([list(map(int,input().split())) for _ in range(n)])
ans=0
for a,b in s:
    if b<=k:
        print(a)
        exit()

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

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
s=sorted([list(map(int,input().split())) for _ in range(n)])
ans=0
for a,b in s:
    ans+=b
    if k<=ans:
        print(a)
        exit()

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
total = 0
for i in range(n):
    total += ab[i][1]
    if total >= k:
        print(ab[i][0])
        exit()

Failing test case input:
3 3
2 2
1 1
8 3

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
total = 0
for i in range(n):
    total += ab[i][1]
    if total >= k:
        print(ab[i][0])
        exit()

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
    a,b = ab[i]
    k -= b
    if k <= 0:
        print(a)
        break

Failing test case input:
3 4
2 2
4 5
3 2

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
n,k = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
ab.sort()
for i in range(n):
    a,b = ab[i]
    k -= b
    if k <= 0:
        print(a)
        break

Problem: p03721
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from itertools import accumulate
n, k = map(int, input().split())
a = []
b = []
for _ in range(n):
    a_, b_ = map(int, input().split())
    a.append(a_)
    b.append(b_)
b_acc = list(accumulate(b))
for i in range(n):
    if b_acc[i] >= k:
        print(a[i])
        exit()

Failing test case input:
3 3
2 2
1 1
8 3

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
from itertools import accumulate
n, k = map(int, input().split())
memo = [0] * (10 ** 5 + 1)
for _ in range(n):
    i, j = map(int, input().split())
    memo[i] += j
cnt = 0
for i, j in enumerate(memo):
    cnt += j
    if cnt >= k:
        print(i)
        exit()