ZhenlongDai/ACPR huggingface dataset:
Problem: p03363
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import *
from itertools import *
n = int(input())
a = list(map(int, input().split()))
b = list(accumulate(a))
c = Counter(b)
r = 0
for i in range(n):
    c[b[i]] -= 1
    r += c[b[i]-a[i]]
print(r)

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

Expected output:
4


Actual output:
2


Fixed submission (verdict: Accepted):
from collections import *
from itertools import *
n = int(input())
a = list(map(int, input().split()))
b = list(accumulate(a))
c = Counter(b)
r = 0
for i in range(n):
    r += c[b[i]-a[i]]
    c[b[i]] -= 1
print(r)

Problem: p03363
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = map(int, input().split())
d = set()
s = 0
c = 0
for i in a:
    s += i
    if s == 0:
        c+=1
    elif s in d:
        c+=1
    d.add(s)
print(c)

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

Expected output:
4


Actual output:
3


Fixed submission (verdict: Accepted):
n = int(input())
a = map(int, input().split())
d = {}
s = 0
c = 0
for i in a:
    s += i
    if s == 0:
        c+=1
    if s in d:
        c+=d[s]
        d[s]+=1
    else:
        d[s]=1

print(c)

Problem: p03363
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(i) for i in input().split()]
ca = [A[0]] + [0]*(N-1)

for i in range(1,N):
    ca[i] = ca[i-1] + A[i]

count = 1
number = 0
number += ca.count(0)
sca = sorted(ca) + ['hoge']
print(sca)
for i in range(1,N+1):
    if sca[i] == sca[i-1]:
        count += 1
    else:
        number += count*(count - 1)/2
        count = 1


print(int(number))

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

Expected output:
5


Actual output:
[-3, -3, -1, -1, 0, 0, 'hoge']
5


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

for i in range(1,N):
    ca[i] = ca[i-1] + A[i]

count = 1
number = 0
number += ca.count(0)
sca = sorted(ca) + ['hoge']
for i in range(1,N+1):
    if sca[i] == sca[i-1]:
        count += 1
    else:
        number += count*(count - 1)/2
        count = 1


print(int(number))

Problem: p03363
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
list_a = list((map(int, input().split())))
memo = 0
memo_dict = {0:1}
for i in range(0,n):
    memo += list_a[i]
    if memo in memo_dict:
        memo_dict[memo] += 1
    else:
        memo_dict[memo] = 1
print(memo_dict)
ans = 0
for number in memo_dict.values():
    ans += number * (number-1) / 2
print(int(ans))


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

Expected output:
2


Actual output:
{0: 1, 1: 1, 4: 2, 2: 2, 6: 1}
2


Fixed submission (verdict: Accepted):
n = int(input())
list_a = list((map(int, input().split())))
memo = 0
memo_dict = {0:1}
for i in range(0,n):
    memo += list_a[i]
    if memo in memo_dict:
        memo_dict[memo] += 1
    else:
        memo_dict[memo] = 1
ans = 0
for number in memo_dict.values():
    ans += number * (number-1) / 2
print(int(ans))
Problem: p04000
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict

h, w, n = list(map(int, input().split()))
ans = [0 for i in range(10)]

if n != 0:
    board = defaultdict(int)
    for i in range(n):
        a, b = list(map(int, input().split()))
        a = a - 1
        b = b - 1
        for dx in range(b-1, b+2):
            if dx < 0 or dx >= w:
                continue
            for dy in range(a-1, a+2):
                if dy < 0 or dy >= h:
                    continue
                board[(dx, dy)] += 1

    for x in range(1, w-1):
        for y in range(1, h-1):
            num = board[(x, y)]
            ans[num] += 1

for i in range(10):
    print(ans[i])


Failing test case input:
1000100000 1001001010 0

Expected output:
1001101106098797984
0
0
0
0
0
0
0
0
0


Actual output:
0
0
0
0
0
0
0
0
0
0


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

h, w, n = list(map(int, input().split()))
ans = [0 for i in range(10)]

board = defaultdict(int)
for i in range(n):
    a, b = list(map(int, input().split()))
    a = a - 1
    b = b - 1
    for dx in range(b-1, b+2):
        if dx <= 0 or dx >= w - 1:
            continue
        for dy in range(a-1, a+2):
            if dy <= 0 or dy >= h - 1:
                continue
            board[(dx, dy)] += 1

for v in board.values():
    ans[v] += 1
ans[0] = (h - 2) * (w - 2) - sum(ans)

for i in range(10):
    print(ans[i])

Problem: p04000
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict


def main():
    H, W, N = map(int, input().split())

    d = defaultdict(int)
    for _ in range(N):
        a, b = map(int, input().split())
        for y in range(-2, 1):
            for x in range(-2, 1):
                n_y, n_x = y + a, x + b
                if 0 < n_y <= H - 2 and 0 < n_x <= W - 2:
                    d[(n_y, n_x)] += 1

    ans = [0] * 10
    for k, v in d.items():
        ans[v] += 1

    print(*ans, sep="\n")

if __name__ == '__main__':
    main()


Failing test case input:
10 10 20
0 1
1 4
1 9
2 7
3 5
4 2
1 7
5 9
6 4
6 6
6 7
2 2
7 3
7 5
16 1
8 5
8 10
9 4
10 4
10 9

Expected output:
6
25
21
8
4
0
0
0
0
0


Actual output:
0
25
21
8
4
0
0
0
0
0


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


def main():
    H, W, N = map(int, input().split())

    d = defaultdict(int)
    for _ in range(N):
        a, b = map(int, input().split())
        for y in range(-2, 1):
            for x in range(-2, 1):
                n_y, n_x = y + a, x + b
                if 0 < n_y <= H - 2 and 0 < n_x <= W - 2:
                    d[(n_y, n_x)] += 1

    ans = [0] * 10
    for k, v in d.items():
        ans[v] += 1
    ans[0] = (H - 2) * (W - 2) - sum(ans)

    print(*ans, sep="\n")

if __name__ == '__main__':
    main()
Problem: p04000
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict

h, w, n = list(map(int, input().split()))
ans = [0 for i in range(10)]

if n != 0:
    board = defaultdict(int)
    for i in range(n):
        a, b = list(map(int, input().split()))
        a = a - 1
        b = b - 1
        for dx in range(b-1, b+2):
            if dx <= 0 or dx >= w - 1:
                continue
            for dy in range(a-1, a+2):
                if dy <= 0 or dy >= h - 1:
                    continue
                board[(dx, dy)] += 1

    for v in board.values():
        ans[v] += 1

for i in range(10):
    print(ans[i])


Failing test case input:
10 10 20
0 1
1 4
1 9
2 5
2 6
4 1
1 7
5 9
6 4
6 6
6 5
2 2
10 3
7 8
16 1
8 5
11 10
9 5
17 4
4 9

Expected output:
12
20
24
7
1
0
0
0
0
0


Actual output:
0
20
24
7
1
0
0
0
0
0


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

h, w, n = list(map(int, input().split()))
ans = [0 for i in range(10)]

board = defaultdict(int)
for i in range(n):
    a, b = list(map(int, input().split()))
    a = a - 1
    b = b - 1
    for dx in range(b-1, b+2):
        if dx <= 0 or dx >= w - 1:
            continue
        for dy in range(a-1, a+2):
            if dy <= 0 or dy >= h - 1:
                continue
            board[(dx, dy)] += 1

for v in board.values():
    ans[v] += 1
ans[0] = (h - 2) * (w - 2) - sum(ans)

for i in range(10):
    print(ans[i])

Problem: p04000
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
H, W, N = [int(v) for v in input().split()]
points = (map(int, input().split()) for _ in range(N))
memory = {}

for ai, bi in points:
    for i in range(max(2, ai - 1), min(H - 1, ai + 1) + 1):
        for j in range(max(2, bi - 1), min(W - 1, bi + 1) + 1):
            key = (i, j)
            if not key in memory:
                memory[key] = 0
            memory[key] += 1

counter = {i: 0 for i in range(1, 9 + 1)}
for v in memory.values():
    counter[v] += 1

for i in range(1, 9 + 1):
    print(counter[i])

Failing test case input:
10 10 20
1 2
1 4
1 9
2 5
3 10
4 2
4 7
5 9
6 4
6 6
6 7
7 1
7 3
7 7
8 1
9 5
8 10
9 2
10 0
10 9

Expected output:
4
28
22
9
1
0
0
0
0
0


Actual output:
28
22
9
1
0
0
0
0
0


Fixed submission (verdict: Accepted):
H, W, N = [int(v) for v in input().split()]
points = (map(int, input().split()) for _ in range(N))
memory = {}
for ai, bi in points:
    for i in range(max(2, ai - 1), min(H - 1, ai + 1) + 1):
        for j in range(max(2, bi - 1), min(W - 1, bi + 1) + 1):
            key = (i, j)
            if not key in memory:
                memory[key] = 0
            memory[key] += 1

counter = {i: 0 for i in range(1, 10)}
for v in memory.values():
    counter[v] += 1

print((H - 2) * (W - 2) - sum(counter.values()))
for i in range(1, 10):
    print(counter[i])
Problem: p04000
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter, defaultdict

ans = defaultdict(lambda: 0)
h, w, n = map(int, input().split())
for _ in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for a_i in range(a - 2, a + 1):
        for b_i in range(b - 2, b + 1):
            if (0 <= a_i < h - 2) & (0 <= b_i < w - 2):
                ans[(a_i, b_i)] += 1

k = Counter(ans.values())
ans_0 = (h - 2) * (w - 2) - sum(k.values())
for i in range(10):
    if i in k.keys():
        print(k[i])
    else:
        print(0)

Failing test case input:
10 10 20
1 1
1 4
1 9
2 5
3 10
4 2
2 7
5 9
6 4
6 6
6 7
7 2
7 3
7 7
8 1
8 5
8 10
9 2
10 4
10 9

Expected output:
5
24
23
10
2
0
0
0
0
0


Actual output:
0
24
23
10
2
0
0
0
0
0


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

ans = defaultdict(lambda: 0)
h, w, n = map(int, input().split())
for _ in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for a_i in range(a - 2, a + 1):
        for b_i in range(b - 2, b + 1):
            if (0 <= a_i < h - 2) & (0 <= b_i < w - 2):
                ans[(a_i, b_i)] += 1

k = Counter(ans.values())
print((h - 2) * (w - 2) - sum(k.values()))
for i in range(1, 10):
    if i in k.keys():
        print(k[i])
    else:
        print(0)

Problem: p04000
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter, defaultdict

ans = defaultdict(lambda: 0)
h, w, n = map(int, input().split())
for _ in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for a_i in range(a - 2, a + 1):
        for b_i in range(b - 2, b + 1):
            if (0 <= a_i < h - 2) & (0 <= b_i < w - 2):
                ans[(a_i, b_i)] += 1

k = Counter(ans.values())
for i in range(10):
    if i in k.keys():
        print(k[i])
    else:
        print(0)

Failing test case input:
10 10 20
0 1
1 4
1 9
2 4
0 6
4 1
1 7
5 9
6 4
6 6
6 5
2 1
10 3
7 8
16 1
8 5
11 10
9 5
17 4
4 4

Expected output:
13
23
21
5
2
0
0
0
0
0


Actual output:
0
23
21
5
2
0
0
0
0
0


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

ans = defaultdict(lambda: 0)
h, w, n = map(int, input().split())
for _ in range(n):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    for a_i in range(a - 2, a + 1):
        for b_i in range(b - 2, b + 1):
            if (0 <= a_i < h - 2) & (0 <= b_i < w - 2):
                ans[(a_i, b_i)] += 1

k = Counter(ans.values())
print((h - 2) * (w - 2) - sum(k.values()))
for i in range(1, 10):
    if i in k.keys():
        print(k[i])
    else:
        print(0)
Problem: p04000
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import defaultdict

H,W,N = map(int,input().split())
D = defaultdict(bool)
B = []

for _ in range(N):
    a,b = map(lambda x: int(x)-1,input().split())
    D[(a,b)] = True
    B.append((a,b))

ans = [0 for _ in range(10)]

for a,b in B:
    for i in range(9):
        ix,iy = divmod(i,3)
        if a-ix<0 or b-iy<0:
            continue
        black_count = 0
        for j in range(9):
            jx,jy = divmod(j,3)
            if H<=a-ix+jx or W<=b-iy+jy:
                break
            if D[(a-ix+jx,b-iy+jy)]:
                if -ix+jx<0 or (-ix+jx==0 and -iy+jy<0):
                    print(a,b,ix,iy,jx,jy,-ix+jx,-iy+jy)
                    break
                black_count += 1
        else:
            ans[black_count] += 1

ans[0] = (H-2)*(W-2)-sum(ans)
print(*ans,sep='\n')

Failing test case input:
10 10 20
0 1
1 4
1 9
2 5
3 6
4 1
1 7
5 9
6 4
6 6
6 7
2 2
7 3
7 8
16 1
8 5
8 10
9 4
17 4
4 9

Expected output:
5
23
26
10
0
0
0
0
0
0


Actual output:
0 8 0 2 0 0 0 -2
1 4 1 0 0 2 -1 2
1 4 1 1 0 0 -1 -1
1 4 1 2 0 1 -1 -1
2 5 1 1 0 0 -1 -1
2 5 1 2 0 1 -1 -1
2 5 2 0 0 1 -2 1
2 5 2 1 0 2 -2 1
2 5 2 2 0 0 -2 -2
3 0 2 0 0 1 -2 1
4 8 1 0 0 0 -1 0
4 8 1 1 0 1 -1 0
4 8 1 2 0 2 -1 0
4 8 2 1 1 1 -1 0
4 8 2 2 1 2 -1 0
5 5 0 2 0 0 0 -2
5 5 1 2 1 0 0 -2
5 5 2 2 2 0 0 -2
5 6 0 1 0 0 0 -1
5 6 0 2 0 1 0 -1
5 6 1 0 0 2 -1 2
5 6 1 1 1 0 0 -1
5 6 1 2 1 1 0 -1
5 6 2 0 0 2 -2 2
5 6 2 1 2 0 0 -1
5 6 2 2 2 1 0 -1
1 1 1 0 0 2 -1 2
6 2 1 0 0 1 -1 1
6 2 1 1 0 2 -1 1
6 2 2 0 1 1 -1 1
6 2 2 1 1 2 -1 1
6 7 1 1 0 0 -1 -1
6 7 1 2 0 0 -1 -2
6 7 2 0 0 1 -2 1
6 7 2 1 0 2 -2 1
6 7 2 2 1 0 -1 -2
7 4 1 2 0 0 -1 -2
7 4 2 0 0 1 -2 1
7 4 2 1 0 0 -2 -1
7 4 2 2 0 1 -2 -1
7 9 1 2 0 0 -1 -2
7 9 2 2 1 0 -1 -2
8 3 1 0 0 1 -1 1
8 3 1 1 0 2 -1 1
8 3 2 0 1 1 -1 1
8 3 2 1 0 0 -2 -1
8 3 2 2 0 1 -2 -1
5
23
26
10
0
0
0
0
0
0


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

H,W,N = map(int,input().split())
D = defaultdict(bool)
B = []

for _ in range(N):
    a,b = map(lambda x: int(x)-1,input().split())
    D[(a,b)] = True
    B.append((a,b))

ans = [0 for _ in range(10)]

for a,b in B:
    for i in range(9):
        ix,iy = divmod(i,3)
        if a-ix<0 or b-iy<0:
            continue
        black_count = 0
        for j in range(9):
            jx,jy = divmod(j,3)
            if H<=a-ix+jx or W<=b-iy+jy:
                break
            if (a-ix+jx,b-iy+jy) in D:
                if -iy+jy<0 or (-iy+jy==0 and -ix+jx<0):
                    break
                black_count += 1
        else:
            ans[black_count] += 1

ans[0] = (H-2)*(W-2)-sum(ans)
print(*ans,sep='\n')
Problem: p04000
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h, w, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

sa = {}
for a,b in ab:
    for i in range(3):
        aa = a + i
        if aa < 3 or h < aa:
            continue
        for j in range(3):
            bb = b + j
            if bb < 3 or w < bb:
                continue
            id = "%d,%d" % (aa, bb)
            sa[id] = sa.get(id, 0) + 1

s = {}
for x in sa.values():
    s[x] = s.setdefault(x, 0) + 1
print((w - 2) * (h - 2) - len(sa.keys()))
for i in range(10):
    print(s.get(i, 0))

Failing test case input:
10 10 20
1 1
1 4
1 9
2 5
3 10
4 2
4 7
5 9
6 4
6 6
6 7
7 2
7 3
7 7
8 1
8 5
8 10
9 2
10 4
10 9

Expected output:
4
26
19
13
2
0
0
0
0
0


Actual output:
4
0
26
19
13
2
0
0
0
0
0


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

sa = {}
for a,b in ab:
    for i in range(3):
        aa = a + i
        if aa < 3 or h < aa:
            continue
        for j in range(3):
            bb = b + j
            if bb < 3 or w < bb:
                continue
            id = "%d,%d" % (aa, bb)
            sa[id] = sa.get(id, 0) + 1

s = {}
for x in sa.values():
    s[x] = s.setdefault(x, 0) + 1
print((w - 2) * (h - 2) - len(sa.keys()))
for i in range(1, 10):
    print(s.get(i, 0))

Problem: p04000
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter, defaultdict

h, w, n = map(int, input().split())
dd = defaultdict(int)

for a, b in (map(int, input().split()) for _ in range(n)):
    for y in range(max(0, a - 3), min(a, h - 2)):
        for x in range(max(0, b - 3), min(b, w - 2)):
            dd[(y, x)] += 1

c = Counter(dd.values())
for i in range(10):
    print(c[i] if i in c else 0)


Failing test case input:
1000000000 1001001010 0

Expected output:
1001001005997997984
0
0
0
0
0
0
0
0
0


Actual output:
0
0
0
0
0
0
0
0
0
0


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

h, w, n = map(int, input().split())
hs, ws = h - 2, w - 2
dd = defaultdict(int)

for a, b in (map(int, input().split()) for _ in range(n)):
    for y in range(max(0, a - 3), min(a, hs)):
        for x in range(max(0, b - 3), min(b, ws)):
            dd[(y, x)] += 1

print(hs * ws - len(dd))

c = Counter(dd.values())
for i in range(1, 10):
    print(c[i] if i in c else 0)
Problem: p04000
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

h,w,n=map(int,input().split())
dic={}
for  _ in range(n):
    a,b=map(int,input().split())
    for i in range(a-1,a+2):
        for j in range(b-1,b+2):
            if (i,j) in dic.keys():
                dic[(i,j)]+=1
            else:
                dic[(i,j)]=1
              
howmany=[0 for i in range(10)]
for some in dic.keys():
    a,b=some[0],some[1]
    if 2<=a<=h-1 and 2<=b<=w-1:
        howmany[dic[some]]+=1
for i in range(10):
    print(howmany[i])

Failing test case input:
10 10 20
0 1
1 4
1 9
2 5
3 6
4 2
1 7
5 9
6 4
6 6
6 7
2 2
7 3
7 8
16 1
8 5
8 10
9 4
10 4
4 9

Expected output:
4
21
27
12
0
0
0
0
0
0


Actual output:
0
21
27
12
0
0
0
0
0
0


Fixed submission (verdict: Accepted):

h,w,n=map(int,input().split())
dic={}
for  _ in range(n):
    a,b=map(int,input().split())
    for i in range(a-1,a+2):
        for j in range(b-1,b+2):
            if (i,j) in dic.keys():
                dic[(i,j)]+=1
            else:
                dic[(i,j)]=1
              
howmany=[0 for i in range(10)]
for some in dic.keys():
    a,b=some[0],some[1]
    if 2<=a<=h-1 and 2<=b<=w-1:
        howmany[dic[some]]+=1
J=(h-2)*(w-2)-sum(howmany)
print(J)
for i in range(1,10):
    print(howmany[i])
Problem: p02720
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def dfs(r):
    global l
    if len(r) == 11:
        return
    l.append(int(r))
    for i in range(-1, 2):
        tmp = int(r[-1]) + i
        if 0 <= tmp <= 9:
            dfs(r + str(tmp))


k = int(input())
l = []
for i in range(1, 10):
    dfs(str(i))
print(sorted(l)[k])

Failing test case input:
179

Expected output:
3434


Actual output:
3443


Fixed submission (verdict: Accepted):
def dfs(r):
    global l
    if len(r) == 11:
        return
    l.append(int(r))
    for i in range(-1, 2):
        tmp = int(r[-1]) + i
        if 0 <= tmp <= 9:
            dfs(r + str(tmp))


k = int(input())
l = []
for i in range(1, 10):
    dfs(str(i))
print(sorted(l)[k - 1])
Problem: p02720
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
k = int(input())

dp = [[[] for j in range(11)] for i in range(11)]


for i in range(10):
    dp[1][i].append(i)
    dp[0][i].append(0)


if k<=9:
    print(k)
    exit()

k-=9

for i in range(2, 11):
    for j in range(1, 10):
        if j==1:
            for z in range(i):
                for x in dp[i-z-1][j]:
                    dp[i][j].append(j*10**(i-1)+x)
                    k-=1
                    if k==0:
                        print(dp[i][j][-1])
                        exit()
            for x in dp[i - 1][j + 1]:
                dp[i][j].append(j * 10 ** (i-1) + x)
                k-=1
                if k==0:
                    print(dp[i][j][-1])
                    exit()
        else:
            for x in dp[i-1][j-1]:
                dp[i][j].append(j*10**(i-1)+x)
                k-=1
                if k==0:
                    print(dp[i][j][-1])
                    exit()
            for x in dp[i - 1][j]:
                dp[i][j].append(j * 10 ** (i-1) + x)
                k-=1
                if k==0:
                    print(dp[i][j][-1])
                    exit()
            for x in dp[i - 1][j + 1]:
                dp[i][j].append(j * 10 ** (i-1) + x)
                k-=1
                if k==0:
                    print(dp[i][j][-1])
                    exit()




Failing test case input:
333

Expected output:
10100


Actual output:
11121


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

dp = [[[] for j in range(11)] for i in range(11)]


for i in range(10):
    dp[1][i].append(i)
    dp[0][i].append(0)


if k<=9:
    print(k)
    exit()

k-=9

for i in range(2, 11):
    for j in range(1, 10):
        if j==1:
            for z in range(i):
                for x in dp[z][j]:
                    dp[i][j].append(j*10**(i-1)+x)
                    k-=1
                    if k==0:
                        print(dp[i][j][-1])
                        exit()
            for x in dp[i - 1][j + 1]:
                dp[i][j].append(j * 10 ** (i-1) + x)
                k-=1
                if k==0:
                    print(dp[i][j][-1])
                    exit()
        else:
            for x in dp[i-1][j-1]:
                dp[i][j].append(j*10**(i-1)+x)
                k-=1
                if k==0:
                    print(dp[i][j][-1])
                    exit()
            for x in dp[i - 1][j]:
                dp[i][j].append(j * 10 ** (i-1) + x)
                k-=1
                if k==0:
                    print(dp[i][j][-1])
                    exit()
            for x in dp[i - 1][j + 1]:
                dp[i][j].append(j * 10 ** (i-1) + x)
                k-=1
                if k==0:
                    print(dp[i][j][-1])
                    exit()
Problem: p02720
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import collections

k = int(input())
li = [str(i) for i in range(1,10)]
str_li = li[:]
q = collections.deque(li)
count = 0
n = 10**10

for i in range(1,n):
    a = q.popleft()
    num = int(a[-1])
    if num != 0:
        aa = a + str(num-1)
        str_li.append(aa)
        count+=1
    aa = a + str(num)
    str_li.append(aa)
    q.append(aa)
    count+=1
    if num != 9:
        aa = a + str(num+1)
        str_li.append(aa)
        q.append(aa)
        count+=1
    if count > k:
        print(str_li[k-1])
        break



Failing test case input:
333

Expected output:
10100


Actual output:
78889


Fixed submission (verdict: Accepted):
import collections
k = int(input())
li = [str(i) for i in range(1,10)]
st_li = li[:]

q = collections.deque(li)
count = 0
n = 10 ** 10

for i in range(1,n):
    
    a = q.popleft()
    num = int(a[-1])
    
    if num != 0:
        aa = a + str(num-1)
        st_li.append(aa)
        q.append(aa)
        count += 1
    aa = a + str(num)
    st_li.append(aa)
    q.append(aa)
    count += 1
    if num != 9:
        aa = a + str(num+1)
        st_li.append(aa)
        q.append(aa)
        count += 1
    if count > k:
        print(st_li[k-1])
        exit(0)

Problem: p02720
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import deque
K = int(input())

d = deque()

for i in range(1,10):
	d.append(i)

for i in range(K):
	x = d.popleft()
	if x % 10 != 0:
		d.append(10*x+x-1)
	d.append(10*x+x)
	if x % 10 != 9:
		d.append(10*x+x+1)

print(x)


Failing test case input:
333

Expected output:
10100


Actual output:
13420


Fixed submission (verdict: Accepted):
from collections import deque
K = int(input())

d = deque()

for i in range(1,10):
	d.append(i)

for i in range(K):
	x = d.popleft()
	if x % 10 != 0:
		d.append(10*x+(x%10)-1)
	d.append(10*x+(x%10))
	if x % 10 != 9:
		d.append(10*x+(x%10)+1)

print(x)

Problem: p02720
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import queue

k = int(input())
q = queue.Queue()
x = -1
for i in range(1,10):
    q.put(i)
for i in range(1,k+1):
    x = q.get()
    if x % 10 != 0:
        q.put(10 * x + (x % 10) - 1)
    q.put(10 * x + (x % 10))
    if x % 9 != 0:
        q.put(10 * x + (x % 10) + 1)
print(x)

Failing test case input:
179

Expected output:
3434


Actual output:
3445


Fixed submission (verdict: Accepted):
import queue

k = int(input())
q = queue.Queue()
x = -1
for i in range(1,10):
    q.put(i)
for i in range(1,k+1):
    x = q.get()
    if x % 10 != 0:
        q.put(10 * x + (x % 10) - 1)
    q.put(10 * x + (x % 10))
    if x % 10 != 9:
        q.put(10 * x + (x % 10) + 1)
print(x)
Problem: p02720
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import deque

k = int(input())

que = deque([1,2,3,4,5,6,7,8,9])

for n in range(0, k):
  x = que.popleft()
  if x % 10 != 0:
    que.append(x * 10 + x % 10 - 1)
  que.append(10*x)
  if x % 10 != 9:
    que.append(x * 10 + x % 10 + 1)

print(x)

Failing test case input:
333

Expected output:
10100


Actual output:
21201


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

k = int(input())

que = deque([1,2,3,4,5,6,7,8,9])

for n in range(0, k):
  x = que.popleft()
  if x % 10 != 0:
    que.append(x * 10 + x % 10 - 1)
  que.append(x * 10 + x % 10)
  if x % 10 != 9:
    que.append(x * 10 + x % 10 + 1)

print(x)

Problem: p02720
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from heapq import heappop, heappush, heapify
K = int(input())

que = list(range(1, 10))
V = set()
heapify(que)

while K >= 1:
    top = heappop(que)
    if top in V:
        continue
    V.add(top)
    K -= 1

    top = str(top)
    L = int(top[0])
    R = int(top[-1])

    for i in (L - 1, L, L + 1):
        if 1 <= i <= 9:
            heappush(que, int(str(i) + top))
    for i in (R - 1, R, R + 1):
        if 0 <= i <= 9:
            heappush(que, int(top + str(i)))

print(que[0])


Failing test case input:
333

Expected output:
10100


Actual output:
10101


Fixed submission (verdict: Accepted):
from heapq import heappop, heappush, heapify
K = int(input())
M = K

que = list(range(1, 10))
V = set()
heapify(que)

while M + 100 >= 0:
    top = heappop(que)
    if top in V:
        continue
    V.add(top)
    M -= 1

    top = str(top)
    L = int(top[0])
    R = int(top[-1])

    for i in (L - 1, L, L + 1):
        if 1 <= i <= 9:
            heappush(que, int(str(i) + top))
    for i in (R - 1, R, R + 1):
        if 0 <= i <= 9:
            heappush(que, int(top + str(i)))

V = [int(d) for d in V]
V.sort()
print(V[K - 1])
Problem: p02720
Buggy submission (Python (2.7.6), verdict: Wrong Answer):
import heapq
import sys

def solve(k):
    if k < 10:
        return k
    
    heap = [1,2,3,4,5,6,7,8,9]
    heapq.heapify(heap)

    for i in range(k-1):
        lunlun = heapq.heappop(heap)
        lastDigit = lunlun  % 10
        
        heapq.heappush(heap, (lunlun*10) + lastDigit)

        if lastDigit == 0:
            newlunlun = (lunlun * 10) + 1
            heapq.heappush(heap, newlunlun)    
        elif lastDigit == 9:
            newlunlun = (lunlun * 10) + 8
            heapq.heappush(heap, newlunlun)  
        else:
            newlunlun1 = (lunlun * 10) + lastDigit + 1
            newlunlun2 = (lunlun * 10) + lastDigit - 1
            heapq.heappush(heap, newlunlun1)
            heapq.heappush(heap, newlunlun2)

    return heapq.heappop(heap)


k = 100000
print(solve(int(k)))

Failing test case input:
179

Expected output:
3434


Actual output:
3234566667


Fixed submission (verdict: Accepted):
import heapq
import sys

def solve(k):
    if k < 10:
        return k
    
    heap = [1,2,3,4,5,6,7,8,9]
    heapq.heapify(heap)

    for i in range(k-1):
        lunlun = heapq.heappop(heap)
        lastDigit = lunlun  % 10
        
        heapq.heappush(heap, (lunlun*10) + lastDigit)

        if lastDigit == 0:
            newlunlun = (lunlun * 10) + 1
            heapq.heappush(heap, newlunlun)    
        elif lastDigit == 9:
            newlunlun = (lunlun * 10) + 8
            heapq.heappush(heap, newlunlun)  
        else:
            newlunlun1 = (lunlun * 10) + lastDigit + 1
            newlunlun2 = (lunlun * 10) + lastDigit - 1
            heapq.heappush(heap, newlunlun1)
            heapq.heappush(heap, newlunlun2)

    return heapq.heappop(heap)

k = input()

print(solve(int(k)))
Problem: p02720
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
K=int(input())
x=[[0] for _ in range(11)]
y=[ 0 for _ in range(11)]

x[1]=[1,2,3,4,5,6,7,8,9]
y[1]=9

for i in range(2,11):
  x[i].pop()
  for num in x[i-1]:
    last = num%10
    if last==0:
      x[i].append(10*num)
      x[i].append(10*num+1)
      y[i] +=2
    elif last==9:
      x[i].append(10*num+8)
      x[i].append(10*num+9)
      y[i] +=2
    else:
      x[i].append(10*num+(last-1))
      x[i].append(10*num+last)
      x[i].append(10*num+(last+1))
      y[i] +=3
      



z=[0,y[1]]
for i in range(2,11):
 z.append(z[-1]+y[i])


maxi=0
for r in range(11):
  if z[r]<=K:
    maxi=max(maxi,r)
    
keta=maxi+1

print(x[keta][K-y[maxi]-1])

Failing test case input:
179

Expected output:
3434


Actual output:
5433


Fixed submission (verdict: Accepted):
K=int(input())
x=[[0] for _ in range(11)]
y=[ 0 for _ in range(11)]

x[1]=[1,2,3,4,5,6,7,8,9]
y[1]=9

for i in range(2,11):
  x[i].pop()
  for num in x[i-1]:
    last = num%10
    if last==0:
      x[i].append(10*num)
      x[i].append(10*num+1)
      y[i] +=2
    elif last==9:
      x[i].append(10*num+8)
      x[i].append(10*num+9)
      y[i] +=2
    else:
      x[i].append(10*num+(last-1))
      x[i].append(10*num+last)
      x[i].append(10*num+(last+1))
      y[i] +=3
      



z=[0,y[1]]
for i in range(2,11):
 z.append(z[-1]+y[i])


keta=0
for i,num in enumerate(z):
  if num<=K:
    keta=i+1

s= K-z[keta-1]

print(x[keta][s-1])
Problem: p00015
Buggy submission (Python3, verdict: Wrong Answer):
import sys
f = sys.stdin
n = int(f.readline())
for _ in range(n):
    a = f.readline().strip()
    b = f.readline().strip()
    c = int(a) + int(b)
    c = '{}'.format(c)
    print(c if len(c) else 'overflow')

Failing test case input:
6
1101
510
11150581741799452420768643548247021706207
8
940241109576576259861480672250431087579815558778668516145336988025960960181876147
-1
30649081726584987569566544405667724154727609853023356866994194873421704913983049
1
101000000000100000000000000000000000000000000000000000000001000000000000000001000
1
100000000001000000000000000000000000000000000001000000000001000000000000000000000
100000010000000000000000000000001000000001000100000000000000000000000000000010000

Expected output:
1611
11150581741799452420768643548247021706215
overflow
30649081726584987569566544405667724154727609853023356866994194873421704913983050
overflow
overflow


Actual output:
1611
11150581741799452420768643548247021706215
940241109576576259861480672250431087579815558778668516145336988025960960181876146
30649081726584987569566544405667724154727609853023356866994194873421704913983050
101000000000100000000000000000000000000000000000000000000001000000000000000001001
200000010001000000000000000000001000000001000101000000000001000000000000000010000


Fixed submission (verdict: Accepted):
import sys
f = sys.stdin
n = int(f.readline())
for _ in range(n):
    a = f.readline().strip()
    b = f.readline().strip()
    c = int(a) + int(b)
    c = '{}'.format(c)
    print(c if len(c) <= 80 else 'overflow')

Problem: p00015
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
for n in range(n):
	a=int(input())
	b=int(input())
	c=a+b
	if a>=int(1e79) or b>=int(1e79) or c>=int(1e79):
		print("overflow")
	else:
		print(c)

Failing test case input:
6
1001
755
9999999999999999999999999999999999999999
2
193919268602104111709736623030259273252485145760643079255618727884865768962159432
0
99999999999999999999999999999999999999999999999999999999999999999999999999999999
0
101000000000100000000000000000000000000000000000000000000000000000000000000000000
1
100000000000000000000000000000000000000000000000000000000000000000000000000000000
100000010000000000000000000000001000000000000000000000000000000000000000000000000

Expected output:
1756
10000000000000000000000000000000000000001
overflow
99999999999999999999999999999999999999999999999999999999999999999999999999999999
overflow
overflow


Actual output:
1756
10000000000000000000000000000000000000001
overflow
overflow
overflow
overflow


Fixed submission (verdict: Accepted):
n=int(input())
for i in range(n):
	a=int(input())
	b=int(input())
	c=a+b
	c=str(c)
	if len(c)>80:
		print("overflow")
	else:
		print(c)
Problem: p00015
Buggy submission (Python3, verdict: Wrong Answer):
def main():
    n = int(input())

    for i in range(n):
        val1 = int(input())
        val2 = int(input())
        print(str(val1 + val2))

if __name__ == '__main__':
    main()

Failing test case input:
6
1000
38
38060050512103967751821046555123274986471
3
748965102781050937681387220428718693622269067764748925491378558113447551883527603
0
14923344184498858993988796745669562170196205905706056613273758587721771662780252
2
101000000000100000000000000000000000000000000000000000000001000000000000100001000
0
110000000001000000000000000000000000000000001001000000000001000000000000000000000
110000010000000000000000000000001000000001000000000000000000000000000000000010000

Expected output:
1038
38060050512103967751821046555123274986474
overflow
14923344184498858993988796745669562170196205905706056613273758587721771662780254
overflow
overflow


Actual output:
1038
38060050512103967751821046555123274986474
748965102781050937681387220428718693622269067764748925491378558113447551883527603
14923344184498858993988796745669562170196205905706056613273758587721771662780254
101000000000100000000000000000000000000000000000000000000001000000000000100001000
220000010001000000000000000000001000000001001001000000000001000000000000000010000


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

    for i in range(n):
        result = str(int(input()) + int(input()))

        if len(result) > 80:
            print("overflow")
        else:
            print(result)

if __name__ == '__main__':
    main()

Problem: p00015
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
for i in range(n):
	s = int(input())+int(input())
	if len(str(s))>=10**80:
		print("overflow")
	else:
		print(s)

Failing test case input:
6
1000
800
9999999999999999999999999999999999999999
2
101324030029434858112167499308639520871934406912468763412863813360414081674525193
1
99999999999999999999999999999999999999999999999999999999999999999999999999999999
0
101000000000000000000000000000000000000000000000000000000000000000000000000000000
1
100000000000000000000000000000000000000000000000000000000000000000000000000000000
100000000000000000000000000000000000000000000000000000000000000000000000000000000

Expected output:
1800
10000000000000000000000000000000000000001
overflow
99999999999999999999999999999999999999999999999999999999999999999999999999999999
overflow
overflow


Actual output:
1800
10000000000000000000000000000000000000001
101324030029434858112167499308639520871934406912468763412863813360414081674525194
99999999999999999999999999999999999999999999999999999999999999999999999999999999
101000000000000000000000000000000000000000000000000000000000000000000000000000001
200000000000000000000000000000000000000000000000000000000000000000000000000000000


Fixed submission (verdict: Accepted):
n = int(input())
for i in range(n):
	s = int(input())+int(input())
	if len(str(s))>80:
		print("overflow")
	else:
		print(s)
Problem: p00015
Buggy submission (Python3, verdict: Wrong Answer):
N=int(input())
A=[]
B=[]
for i in range(N):
    a = int(input())
    b = int(input())
    A.append(a)
    B.append(b)

for i in range(N):
    if A[i] >= 10 ** 79 or B[i] >= 10 ** 79:
        print("overflow")
    elif A[i] + B[i]>= 10 ** 79:
        print("overflow")
    else:
        print(str(A[i]+B[i]))

Failing test case input:
6
1000
476
9999999999999999999999999999999999999999
1
193919268602104111709736623030259273252485145760643079255618727884865768962159432
0
99999999999999999999999999999999999999999999999999999999999999999999999999999999
0
101000000000100000000000000000000000000000000000000000000000000000000000000000000
1
100000000000000000000000000000000000000000000000000000000000000000000000000000000
100000010000000000000000000000001000000000000000000000000000000000000000000000000

Expected output:
1476
10000000000000000000000000000000000000000
overflow
99999999999999999999999999999999999999999999999999999999999999999999999999999999
overflow
overflow


Actual output:
1476
10000000000000000000000000000000000000000
overflow
overflow
overflow
overflow


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

for i in range(N):
    if A[i] >= 10 ** 80 or B[i] >= 10 ** 80:
        print("overflow")
    elif A[i] + B[i] >= 10 ** 80:
        print("overflow")
    else:
        print(str(A[i] + B[i]))

Problem: p00015
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
for _ in range(n):
	s=int(input())+int(input())
	print('overflow' if s/1e80>1 else s)

Failing test case input:
6
1000
800
167319819924237415589807736201027599985
1
99999999999999999999999999999999999999999999999999999999999999999999999999999999
1
99999999999999999999999999999999999999999999999999999999999999999999999999999999
0
101000000000000000000000000000000000000000000000000000000000000000000000000000000
1
100000000000000000000000000000000000000000000000000010000000000000000000000000000
100000000000000000000000000000000000000000000000000000000000000000000000000000000

Expected output:
1800
167319819924237415589807736201027599986
overflow
99999999999999999999999999999999999999999999999999999999999999999999999999999999
overflow
overflow


Actual output:
1800
167319819924237415589807736201027599986
100000000000000000000000000000000000000000000000000000000000000000000000000000000
99999999999999999999999999999999999999999999999999999999999999999999999999999999
overflow
overflow


Fixed submission (verdict: Accepted):
n=int(input())
for _ in range(n):
	s=int(input())+int(input())
	print('overflow' if len(str(s))>80 else s)
Problem: p00015
Buggy submission (Python3, verdict: Wrong Answer):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n = int(input())
ans = []
for _ in range(n):
    a = int(input())
    b = int(input())
    s = a+b
    if s >= 10**79:
        ans.append("overflow")
    else:
        ans.append(str(s))
print("\n".join(ans))



Failing test case input:
6
1000
800
9999999999999999999999999999999999999999
2
101324030029434858112167499308639520871934406912468763412863813360414081674525193
1
99999999999999999999999999999999999999999999999999999999999999999999999999999999
0
101000000000000000000000000000000000000000000000000000000000000000000000000000000
1
100000000000000000000000000000000000000000000000000000000000000000000000000000000
100000000000000000000000000000000000000000000000000000000000000000000000000000000

Expected output:
1800
10000000000000000000000000000000000000001
overflow
99999999999999999999999999999999999999999999999999999999999999999999999999999999
overflow
overflow


Actual output:
1800
10000000000000000000000000000000000000001
overflow
overflow
overflow
overflow


Fixed submission (verdict: Accepted):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n = int(input())
ans = []
for _ in range(n):
    a = int(input())
    b = int(input())
    s = a+b
    if s > 10**80-1:
        ans.append("overflow")
    else:
        ans.append(str(s))
print("\n".join(ans))

Problem: p00015
Buggy submission (Python3, verdict: Wrong Answer):
n = int(input())
for i in range(n):
	s = int(input())+int(input())
	if len(str(s))>=80:
		print("overflow")
	else:
		print(s)

Failing test case input:
6
1010
30
11150581741799452420768643548247021706207
8
314411289867618232702241807880438703320781023701160407692239774484611399304275912
-1
14923344184498858993988796745669562170196205905706056613273758587721771662780252
1
101000000000100000000000000000000000000000000000000000000001000000000000000001000
1
100000000001000000000000000000000000000000001001000000000001000000000000000000000
110000010000000000000000000000001000000001000100000000000000000000000000000010000

Expected output:
1040
11150581741799452420768643548247021706215
overflow
14923344184498858993988796745669562170196205905706056613273758587721771662780253
overflow
overflow


Actual output:
1040
11150581741799452420768643548247021706215
overflow
overflow
overflow
overflow


Fixed submission (verdict: Accepted):
n = int(input())
for i in range(n):
	s = int(input())+int(input())
	if len(str(s))>80:
		print("overflow")
	else:
		print(s)
Problem: p00015
Buggy submission (Python3, verdict: Wrong Answer):
n=int(input())
for n in range(n):
	a=int(input())
	b=int(input())
	c=a+b
	if a>=int(1e80) or b>=int(1e80) or c>=int(1e80):
		print("overflow")
	else:
		print(c)

Failing test case input:
6
1000
800
9999999999999999999999999999999999999999
1
99999999999999999999999999999999999999999999999999999999999999999999999999999999
1
99999999999999999999999999999999999999999999999999999999999999999999999999999999
0
100000000000000000000000000000000000000000000000000000000000000000000000000000000
1
100000000000000000000000000000000000000000000000000000000000000000000000000000000
100000000000000000000000000000000000000000000000000000000000000000000000000000000

Expected output:
1800
10000000000000000000000000000000000000000
overflow
99999999999999999999999999999999999999999999999999999999999999999999999999999999
overflow
overflow

Actual output:
1800
10000000000000000000000000000000000000000
100000000000000000000000000000000000000000000000000000000000000000000000000000000
99999999999999999999999999999999999999999999999999999999999999999999999999999999
100000000000000000000000000000000000000000000000000000000000000000000000000000001
overflow


Fixed submission (verdict: Accepted):
n=int(input())
for i in range(n):
	a=int(input())
	b=int(input())
	c=a+b
	c=str(c)
	if len(c)>80:
		print("overflow")
	else:
		print(c)

Problem: p00015
Buggy submission (Python3, verdict: Wrong Answer):
upper = 10**81
n = int(input())
for i in range(n):
    n1 = int(input())
    if n1 >= upper:
        print("overflow")
        continue
    n2 = int(input())
    if n2 >= upper:
        print("overflow")
        continue
    print( n1 + n2 if n1+n2 < upper else "overflow")

Failing test case input:
6
1001
510
9999999999999999999999999999999999999999
8
406457296153147731569431812193957336633213953097465104312094248394524915238944551
-2
58309788833475244131751092110501484455671325624249551256800630673736756882679442
1
101000000000100000000000000000000000000000000000000000000001000000000000000001000
-1
100000000000000000000000000000000000000000000001000000000001000000000000000000000
100000010000000000000000000000001000000001000000000000000000000000000000000010000

Expected output:
1511
10000000000000000000000000000000000000007
overflow
58309788833475244131751092110501484455671325624249551256800630673736756882679443
overflow
overflow


Actual output:
1511
10000000000000000000000000000000000000007
406457296153147731569431812193957336633213953097465104312094248394524915238944549
58309788833475244131751092110501484455671325624249551256800630673736756882679443
101000000000100000000000000000000000000000000000000000000001000000000000000000999
200000010000000000000000000000001000000001000001000000000001000000000000000010000


Fixed submission (verdict: Accepted):
upper = 10**80
n = int(input())
for i in range(n):
    n1 = int(input())
    n2 = int(input())
    if n1 >= upper or n2 >= upper:
        print("overflow")
        continue
    print( n1 + n2 if n1+n2 < upper else "overflow")
Problem: p03139
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,a,b = map(int,input().split())
print(min(a,b))

Failing test case input:
101 110 000

Expected output:
0 9


Actual output:
0


Fixed submission (verdict: Accepted):
n,a,b = map(int,input().split())
print(min(a,b),max(a+b-n,0))

Problem: p03139
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n_k = list(map(int, input().split()))
n,a,b = n_k[0],n_k[1],n_k[2]
max,min = 0,0
if n > a+b:
    min=0
    if a<b:
        max=a
    else:
        max=b
else:
    if a < b:
        min=b-a
        max=a
    else:
        min=a-b
        max=b
print(str(max)+' '+str(min))


Failing test case input:
110 000 111

Expected output:
0 1


Actual output:
0 111


Fixed submission (verdict: Accepted):
n_k = list(map(int, input().split()))
n,a,b = n_k[0],n_k[1],n_k[2]
max,min = 0,0
if n > a+b:
    min=0
    if a<b:
        max=a
    else:
        max=b
else:
    min=a+b-n
    if a<b:
        max=a
    else:
        max=b
print(str(max)+' '+str(min))

Problem: p03139
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, A, B = (int(x) for x in input().split())
c=0
if(A <= B):
    c = A
else:
    c = B
if(A+B > N and A+B == 2*N ):
    print("{} {}".format(c, A+B-N))
else:
    print("{} {}".format(c, 0))


Failing test case input:
101 001 111

Expected output:
1 11


Actual output:
1 0


Fixed submission (verdict: Accepted):
N, A, B = (int(x) for x in input().split())
c=0
if(A <= B):
    c = A
else:
    c = B
if(A+B > N):
    print("{} {}".format(c, A+B-N))
else:
    print("{} {}".format(c, 0))

Problem: p03139
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N, A, B = map(int, input().split())

ans1 = B if A>B else A
ans2 = A+B-N

print("{} {}".format(ans1, ans2))

Failing test case input:
5 -3 -1

Expected output:
-3 0


Actual output:
-3 -9


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

ans1 = B if A>B else A
ans2 = A+B-N if A+B-N >= 0 else 0

print("{} {}".format(ans1, ans2))
Problem: p03139
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    N, a, b = il()
    return "{} {}".format(min(a, b), b if a == b else max(0, a - b))


if __name__ == "__main__":
    print(solve())


Failing test case input:
1 5 0

Expected output:
0 4


Actual output:
0 5


Fixed submission (verdict: Accepted):
import bisect
import sys

sys.setrecursionlimit(200000)


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


def solve():
    N, a, b = il()
    return "{} {}".format(min(a, b), max(0, a - (N - b)))


if __name__ == "__main__":
    print(solve())

Problem: p03139
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x, y, z = map(int,input().split())
print(min(y,z), max(0, x-y-z))

Failing test case input:
000 011 100

Expected output:
11 111


Actual output:
11 0


Fixed submission (verdict: Accepted):
x, y, z = map(int,input().split())
print(min(y,z), max(0,y+z-x))

Problem: p03139
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B=map(int,input().split())
print(max(0,min(A,B) -(N-max(A,B))),min(A,B))

Failing test case input:
000 110 100

Expected output:
100 210


Actual output:
210 100


Fixed submission (verdict: Accepted):
N,A,B=map(int,input().split())
print(min(A,B),max(0,min(A,B) -(N-max(A,B))))

Problem: p03139
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
if __name__ == '__main__':
    n, a, b = input().split()
    N, A, B = int(n), int(a), int(b)

    ans_max = min(A, B)

    n_mid = N / 2
    if A <= (n_mid) and B <= (n_mid):
        ans_min = 0
    else:
        ans_min = max((A - n_mid) + (B - n_mid), 0)

    print('{0} {1}'.format(ans_max, ans_min))


Failing test case input:
000 101 100

Expected output:
100 201


Actual output:
100 201.0


Fixed submission (verdict: Accepted):
if __name__ == '__main__':
    n, a, b = input().split()
    N, A, B = int(n), int(a), int(b)

    ans_max = min(A, B)

    if (A + B) <= N:
        ans_min = 0
    else:
        ans_min = max((A + B - N), 0)

    print('{0} {1}'.format(ans_max, ans_min))
Problem: p03139
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def read():
    N, A, B = map(int, input().strip().split())
    return N, A, B


def solve(N, A, B):
    intersect_max = min(A, B)
    intersect_min = max(0, A + B - N)
    return intersect_max, intersect_min


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


Failing test case input:
101 110 000

Expected output:
0 9


Actual output:
(0, 9)


Fixed submission (verdict: Accepted):
def read():
    N, A, B = map(int, input().strip().split())
    return N, A, B


def solve(N, A, B):
    intersect_max = min(A, B)
    intersect_min = max(0, A + B - N)
    return intersect_max, intersect_min


if __name__ == '__main__':
    inputs = read()
    print("%d %d" % solve(*inputs))