ZhenlongDai/ACPR huggingface dataset:
Problem: p02867
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

compression_dict={a: ind+1 for ind, a in enumerate(sorted(set(A)|set(B)))}

SA=sorted(A)
SB=sorted(B)

for i in range(N):
    if SA[i]>SB[i]:
        print("No")
        sys.exit()

for i in range(N-1):
    if SB[i]>SA[i+1]:
        print("Yes")
        sys.exit()

AB=[(B[i],A[i]) for i in range(N)]
AB.sort()

DICT={a:ind for ind,a  in enumerate(A)}

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

def find(x):
    while Group[x] != x:
        x=Group[x]
    return x

def Union(x,y):  
    if find(x) != find(y):
        Group[find(y)]=Group[find(x)]=min(find(y),find(x))

for i in range(N):
    _,a=AB[i]

    Union(DICT[a],i)

if len(set([find(i) for i in range(N)]))==1:
    print("No")
else:
    print("Yes")


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

Expected output:
Yes


Actual output:
No


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

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

compression_dict={a: ind+1 for ind, a in enumerate(sorted(set(A)|set(B)))}

SA=sorted(A)
SB=sorted(B)

for i in range(N):
    if SA[i]>SB[i]:
        print("No")
        sys.exit()

for i in range(N-1):
    if SB[i]>=SA[i+1]:
        print("Yes")
        sys.exit()

AB=[(B[i],A[i]) for i in range(N)]
AB.sort()

DICT={a:ind for ind,a  in enumerate(SA)}

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

def find(x):
    while Group[x] != x:
        x=Group[x]
    return x

def Union(x,y):  
    if find(x) != find(y):
        Group[find(y)]=Group[find(x)]=min(find(y),find(x))

for i in range(N):
    _,a=AB[i]

    Union(DICT[a],i)

if len(set([find(i) for i in range(N)]))==1:
    print("No")
else:
    print("Yes")

Problem: p02867
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(zip(B, A))
B, A = zip(*C)
D = sorted((a, i) for i, a in enumerate(A))
for i, (d, idx) in enumerate(D):
  if idx <= i and d <= B[idx]:
    s, t = i, idx
    break
else:
  print("No")
  exit()
A, indices = zip(*D)
A = list(A)
A[s], A[t] = A[t], A[s]
for a, b in zip(A, B):
  if a > b:
    print("No")
    exit()
print("Yes")

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

Expected output:
Yes


Actual output:
No


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

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = sorted(zip(B, A))
B, A = zip(*C)
D = sorted((a, i) for i, a in enumerate(A))
E, indices = zip(*D)
for e, b in zip(E, B):
  if e > b:
    print("No")
    exit()
S = {0}
now = 0
for _ in range(n-1):
  if indices[now] in S:
    print("Yes")
    exit()
  now = indices[now]
  S.add(now)
for i in range(n-1):
  if E[i+1] <= B[i]:
    print("Yes")
    exit()
print("No")
Problem: p02867
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]

AA = sorted(A)
BB = sorted(B)

IA = {}
IB = {}
for i in range(N):
    IA[A[i]] = i
    IB[B[i]] = i

for i in range(N):
    if AA[i] > BB[i]:
        print("No")
        break
else:
    i = 0
    j = 0
    k = 0
    X = [0] * N
    Y = [0] * N
    for j in range(N):
        while i < N - 1 and AA[i+1] <= BB[j]:
            i += 1
        X[j] = i
        Y[j] = k
        if i == j: k = i + 1
    
    for i in range(N):
        if IA[AA[Y[i]]] <=  IB[BB[i]] <= IA[AA[X[i]]]:
            print("Yes")
            break
    else:
        print("No")



Failing test case input:
3
0 -3 -1
-1 18 5

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
A = [(A[i]<<18) + i for i in range(N)]
B = [(B[i]<<18) + i + (1<<17) for i in range(N)]
AA = sorted(A)
BB = sorted(B)

IA = {}
IB = {}
for i in range(N):
    IA[AA[i]] = i
    IB[BB[i]] = i

for i in range(N):
    if AA[i] > BB[i]:
        print("No")
        break
else:
    for i in range(1, N):
        if AA[i] <= BB[i-1]:
            print("Yes")
            break
    else:
        for i in range(N):
            if IA[A[i]] == IB[B[i]]:
                print("Yes")
                break
        else:
            c = 1
            i = 0
            P = [-1] * N
            for i in range(N):
                P[IA[A[i]]] = IB[B[i]]
            i = P[0]
            while i != 0:
                i = P[i]
                c += 1
            if c < N:
                print("Yes")
            else:
                print("No")
Problem: p02867
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



from collections import Counter
def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    la = rli()
    lb = rli()
    ll = []
    pb = []
    for i in range(n):
        ll.append([la[i], lb[i]])
    ll.sort()
    for i in range(n):
        pb.append([ll[i][1], i])
    pb.sort()
    pc = [0 for _ in range(n)]
    for i in range(n):
        pc[pb[i][1]] = i
    
    

    la.sort()
    lb.sort()
    for i in range(n):
        if la[i] > lb[i]:
            print("No")
            return

    cnt = 0
    
    for i in range(n):
        j = pc[i]
        if i == j:
            continue
        while i != j:
            if ll[i][0] != ll[j][0] and ll[i][1] != ll[j][1]:
                cnt += 1
            ll[i][1], ll[j][1] = ll[j][1], ll[i][1]
            pc[i], pc[j] = pc[j], pc[i]
            
            j = pc[i]
    
    if cnt <= n-2:
        print("Yes")
    else:
        print("No")
    

    


if __name__ == '__main__':
    main()


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

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):



from collections import Counter
def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    la = rli()
    lb = rli()
    lab = []
    for i in range(n):
        lab.append([la[i], lb[i]])

    la.sort()
    lb.sort()
    for i in range(n):
        if la[i] > lb[i]:
            print("No")
            return

    
    lab.sort()
    
    for i in range(n):
        lab[i].append(i)
    
    lab.sort(key=lambda x: x[1])
    
    length = 1
    fr = 0
    to = lab[0][2]
    while to != 0:
        fr = to
        to = lab[fr][2]
        length += 1
    
    if length < n:
        print("Yes")
        return

    
    for i in range(n-1):
        if lb[i] >= la[i+1]:
            print("Yes")
            return
    
    
    print("No")


if __name__ == '__main__':
    main()
Problem: p02401
Buggy submission (Python3, verdict: Wrong Answer):


while True:
    a,op,b=map(str,input().split())
    if op=="?":
        break
    
    if op=="+":
        print(int(a)+int(b))
    elif op=="-":
        print(int(a)-int(b))
    elif op=="*":
        print(int(a)*int(b))
    elif op=="/":
        print("%.0f" %(int(a)/int(b)))


Failing test case input:
1 , 2
56 - 18
2 * 2
100 / 7
2 , 81
-1 ? 0

Expected output:
(1, 2)
38
4
14
(2, 81)


Actual output:
38
4
14


Fixed submission (verdict: Accepted):


while True:
    a,op,b=map(str,input().split())
    if op=="?":
        break
    
    if op=="+":
        print(int(a)+int(b))
    elif op=="-":
        print(int(a)-int(b))
    elif op=="*":
        print(int(a)*int(b))
    elif op=="/":
        print((int(a)

Problem: p02401
Buggy submission (Python3, verdict: Wrong Answer):
while True:
  a, op, b = map(str, input().split())
  a = int(a)
  b = int(b)
  if op == "+":
    print(a + b)
  elif op == "-":
    print(a - b)
  elif op == "*":
    print(a * b)
  elif op == "/":
    print(a / b)
  elif op == "?":
    break
  else:
    break


Failing test case input:
1 , 2
56 - 18
21 * 2
100 / 7
1 , 81
-1 ? 0

Expected output:
(1, 2)
38
42
14
(1, 81)


Actual output:

Fixed submission (verdict: Accepted):
while True:
  a, op, b = map(str, input().split())
  a = int(a)
  b = int(b)
  if op == "+":
    print(a + b)
  elif op == "-":
    print(a - b)
  elif op == "*":
    print(a * b)
  elif op == "/":
    print(a 
  elif op == "?":
    break

Problem: p02401
Buggy submission (Python3, verdict: Wrong Answer):
while 1:
  a,o,b = input().split()
  if o=='?': break
  a,b = map(int,(a,b))
  print(a+b if o=='+' else a-b if o=='-' else a*b if o=='*' else a/b)


Failing test case input:
1 + 2
56 - 18
13 * 0
100 / 10
27 , 81
-1 ? 0

Expected output:
3
38
0
10
(27, 81)


Actual output:
3
38
0
10.0
0.3333333333333333


Fixed submission (verdict: Accepted):
while 1:
  a,o,b = input().split()
  if o=='?': break
  a,b = map(int,(a,b))
  print(a+b if o=='+' else a-b if o=='-' else a*b if o=='*' else a

Problem: p02401
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    if op == '+':
        print(a+b)
    if op == '-':
        print(a-b)
    if op == '*':
        print(a*b)
    if op == '/':
        print(a/b)

Failing test case input:
1 + 2
56 - 18
13 * 2
100 / 10
27 , 81
-1 ? 0

Expected output:
3
38
26
10
(27, 81)


Actual output:
3
38
26
10.0


Fixed submission (verdict: Accepted):
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    if op == '+':
        print(a+b)
    if op == '-':
        print(a-b)
    if op == '*':
        print(a*b)
    if op == '/':
        print(a
Problem: p02401
Buggy submission (Python3, verdict: Wrong Answer):
a,o,b = input().split()
a,b = map(int,(a,b))
print(a+b if o=='+' else a-b if o=='-' else a*b if o=='*' else a/b)


Failing test case input:
1 + 2
56 - 18
21 * 4
100 / 10
1 , 81
-1 ? -1

Expected output:
3
38
84
10
(1, 81)


Actual output:
3


Fixed submission (verdict: Accepted):
while 1:
  a,o,b = input().split()
  if o=='?': break
  a,b = map(int,(a,b))
  print(a+b if o=='+' else a-b if o=='-' else a*b if o=='*' else a

Problem: p02401
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    a,op,b=input().split()
    a=int(a)
    b=int(b)
    if op == "+":
        print(a+b)
    elif op =="-":
        print(a-b)
    elif op =="*":
        print(a*b)
    elif op =="/":
        print(a/float(b))
    elif a=="?" or b=="?" or op=="?":
        break


Failing test case input:
1 + 2
56 - 18
21 * 3
100 / 10
31 , 81
-1 ? -1

Expected output:
3
38
63
10
(31, 81)


Actual output:
3
38
63
10.0


Fixed submission (verdict: Accepted):
while True:
  a,op,b = input().split()
  a=int(a)
  op=str(op)
  b=int(b)
  
  if op=='?':
    break
  elif  op=='+':
    print("{:d}".format(a+b))
  elif op=='-':
    print("{:d}".format(a-b))
  elif op=='/':
    print("{:d}".format(a
  elif op=="*":
    print("{:d}".format(a*b))

Problem: p02401
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    a, op, b = map(str, input().split())
    if op == "+":
        print(int(a) + int(b))
    elif op == "-":
        print(int(a) - int(b))
    elif op == "*":
        print(int(a) * int(b))
    elif op == "/":
        print(int(a) / int(b))
    else:
        break

Failing test case input:
1 , 2
56 - 18
2 * 2
100 / 7
1 , 81
-1 ? 0

Expected output:
(1, 2)
38
4
14
(1, 81)


Actual output:

Fixed submission (verdict: Accepted):
while True:
    a, op, b = map(str, input("").split())
    a = int(a)
    b = int(b)
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a 
    elif op == "?":
        break

Problem: p02401
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    a,op,b = input().split()
    a =int(a)
    b =int(b)
    
    if op == '?':
        break
     
    if op == '+':
        print(a+b)

    if op == '-':
        print(a-b)

    if op == '*':
        print(a*b)
 
    if op == '/':
        print(a/b)

Failing test case input:
2 + 2
25 , 18
10 * 1
000 / 22
28 - 6
0 ? 0

Expected output:
4
(25, 18)
10
0
22


Actual output:
4
10
0.0
22


Fixed submission (verdict: Accepted):
while True:
    a,op,b = input().split()
    a =int(a)
    b =int(b)
    
    if op == '?':
        break
     
    if op == '+':
        print(a+b)

    if op == '-':
        print(a-b)

    if op == '*':
        print(a*b)
 
    if op == '/':
        print(a
Problem: p02401
Buggy submission (Python3, verdict: Wrong Answer):
while 1:
    k=input().split()
    k[0]=int(k[0])
    k[2]=int(k[2])
    
    if k[1]=="?":
        break
    elif k[1]=="+":
        print(k[0]+k[2])
    elif k[1]=="-":
        print(k[0]-k[2])
    elif k[1]=="*":
        print(k[0]*k[2])
    elif k[1]=="/":
        print(k[0]/k[2])



Failing test case input:
4 , 4
25 , 18
10 * 2
000 / 29
28 , 81
0 ? 0

Expected output:
(4, 4)
(25, 18)
20
0
(28, 81)


Actual output:
20
0.0


Fixed submission (verdict: Accepted):
while 1:
    k=input().split()
    k[0]=int(k[0])
    k[2]=int(k[2])
    
    if k[1]=="?":
        break
    elif k[1]=="+":
        print(k[0]+k[2])
    elif k[1]=="-":
        print(k[0]-k[2])
    elif k[1]=="*":
        print(k[0]*k[2])
    elif k[1]=="/":
        print(k[0]

Problem: p02401
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    a,op,b = input().split()
    A = int(a)
    B = int(b)

    if op == '?': break
    elif op == '+':
        print(A+B)
    elif op == '-':
        print(A-B)
    elif op == '*':
        print(A*B)
    elif op == '/':
        print(A/B)
        


Failing test case input:
1 , 4
25 - 18
10 * 2
001 / 29
28 , 81
0 ? 0

Expected output:
(1, 4)
7
20
0
(28, 81)


Actual output:
7
20
0.034482758620689655


Fixed submission (verdict: Accepted):
while True:
    a,op,b = input().split()

    A = int(a)
    B = int(b)

    if op == '?': break
    elif op == '+':
        print(A+B)
    elif op == '-':
        print(A-B)
    elif op == '*':
        print(A*B)
    elif op == '/':
        print(A
Problem: p00602
Buggy submission (Python3, verdict: Wrong Answer):
while 1:
    try:
        v,d=map(int,input().split())
        f=[0]*(v+1)
        f[0],f[1]=1,2
        for i in range(2,v+1):
            f[i]=f[i-1]+f[i-2]
        f.sort()
        c=1
        for i in range(2,v+1):
            if f[i]-f[i-1]>=d: c+=1
        print(c)
    except:break

Failing test case input:
20 2
30 2
22 25

Expected output:
19
29
12


Actual output:
19
29
15


Fixed submission (verdict: Accepted):
while 1:
    try:
        v,d=map(int,input().split())
        f=[0]*(v+1)
        f[0],f[1]=1,2
        for i in range(2,v+1):
            f[i]=(f[i-1]+f[i-2])%1001
        f.sort()
        c=1
        for i in range(2,v+1):
            if f[i]-f[i-1]>=d: c+=1
        print(c)
    except:break
Problem: p03838
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x, y = map(int, input().split())

if x >= 0:
    sgnx = 1
else:
    sgnx = -1

if y >= 0:
    sgny = 1
else:
    sgny = -1

if abs(x) > abs(y):
    if sgnx == 1 and sgny == 1:
        ans = 1 + y + x
    if sgnx == -1 and sgny == -1:
        ans = abs(x) - abs(y)
    elif sgnx == -1 and sgny == 1:
        ans = 1 + abs(x) - abs(y)
    elif sgnx == 1 and sgny == -1:
        ans = 1 + abs(x) - abs(y)

elif abs(x) < abs(y):
    if sgnx == 1 and sgny == 1:
        ans = y - x
    if sgnx == -1 and sgny == -1:
        ans = 2 + abs(y) - abs(x)
    elif sgnx == -1 and sgny == 1:
        ans = 1 + abs(y) - abs(x)
    elif sgnx == 1 and sgny == -1:
        ans = 1 + abs(y) - abs(x)

else:
    if sgnx == sgny:
        ans = 0
    if sgnx != sgny:
        ans = 1

print(ans)


Failing test case input:
101 1

Expected output:
102


Actual output:
103


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

if x >= 0:
    sgnx = 1
else:
    sgnx = -1

if y > 0:
    sgny = 1
else:
    sgny = -1

if abs(x) > abs(y):
    if sgnx == 1 and sgny == 1:
        ans = 2 + abs(x) - abs(y)
    if sgnx == -1 and sgny == -1:
        ans = abs(x) - abs(y)
    elif sgnx == -1 and sgny == 1:
        ans = 1 + abs(x) - abs(y)
    elif sgnx == 1 and sgny == -1:
        ans = 1 + abs(x) - abs(y)

elif abs(x) < abs(y):
    if sgnx == 1 and sgny == 1:
        ans = y - x
    if sgnx == -1 and sgny == -1:
        ans = 2 + abs(y) - abs(x)
    elif sgnx == -1 and sgny == 1:
        ans = 1 + abs(y) - abs(x)
    elif sgnx == 1 and sgny == -1:
        ans = 1 + abs(y) - abs(x)

else:
    if sgnx == sgny:
        ans = 0
    if sgnx != sgny:
        ans = 1

print(ans)

Problem: p03838
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
x,y = map(int, input().split())
if x == y :
    print(0)
elif (-x) == y:
    print(1)
elif x >= 0 and x <= y:
    print(y-x)
elif x >= 0 and x > y:
    if x <= (-y): 
        print(abs(x-(-y))+1)
    else: 
        print(abs(y-(-x))+1)
elif x < 0 and x > y: 
    print(min(abs(x-y)+2, -y -x+1))
elif x < 0 and x < y: 
    if (-x) < y: 
        print(min(abs(y-x),abs(y-(-x))+1))
    else:
        print(abs(y - x))



Failing test case input:
101 1

Expected output:
102


Actual output:
103


Fixed submission (verdict: Accepted):
x,y = map(int, input().split())
if x == y :
    print(0)
elif (-x) == y:
    print(1)
elif x >= 0 and x < y: 
    print(y-x)
elif x >= 0 and x > y: 
    if x <= (-y): 
        print(abs(x-(-y))+1)
    else: 
        print(min(abs(y-(-x))+1,abs(x-y)+2))
elif x < 0 and x > y: 
    print(min(abs(x-y)+2, -y -x+1))
elif x < 0 and x < y: 
    if y > 0: 
        print(min(abs(y-x),abs((-y)-x)+1))
    else:
        print(abs(y - x))
Problem: p03838
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x, y = map(int, readline().split())
if x <= y:
    if (x > 0 and y > 0) or (x <= 0 and y <= 0):
        ans = y - x
    else:
        ans = y + x + 1
else:
    if (x >= 0 and y >= 0) or (x < 0 and y < 0):
        ans = min(abs(x) + abs(y) + 1, abs(y) - abs(x) + 2)
    else:
        ans = - x - y + 1
print(ans)


Failing test case input:
370 -1

Expected output:
370


Actual output:
-368


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

x, y = map(int, readline().split())
if x <= y:
    if (x >= 0 and y >= 0) or (x <= 0 and y <= 0):
        ans = y - x
    else:
        ans = abs(abs(x) - y) + 1
else:
    if (x > 0 and y > 0) or (x < 0 and y < 0):
        ans = min(abs(x) + abs(y) + 1, abs(abs(y) - abs(x)) + 2)
    elif y == 0:
        ans = abs(x) + 1
    elif x == 0:
        ans = abs(y) + 1
    else:
        ans = abs(x - abs(y)) + 1
print(ans)

Problem: p03838
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
x, y = map(int, input().split())



abs_cost = 0
if x == y:
    print(0)
    exit()
if y >= 0 and x >= 0:
    if y > x:
        print(y - x)
    else:
        print(abs(x) - abs(y) + 2)
elif y < 0 and x >= 0:
    if abs(y) > abs(x):
        print(abs(y) - x + 1)
    else:
        print(x - abs(y) + 1)
elif y >= 0 and x < 0:
    print(y - abs(x) + 1)
else:
    if y > x:
        print(y - x)
    else:
        print(abs(y) - abs(x) + 2)




Failing test case input:
370 0

Expected output:
371


Actual output:
372


Fixed submission (verdict: Accepted):

x, y = map(int, input().split())



if x == 0:
    if y >= 0:
        print(y)
    else:
        print(abs(y) + 1)
    exit()
elif y == 0:
    if x >= 0:
        print(1 + abs(x))
    else:
        print(abs(x))
    exit()
if y > 0 and x > 0:
    if y >= x:
        print(y - x)
    else:
        print(abs(x) - abs(y) + 2)
elif y < 0 and x > 0:
    if abs(y) > abs(x):
        print(abs(y) - x + 1)
    else:
        print(x - abs(y) + 1)
elif y > 0 and x < 0:
    if abs(x) < abs(y):
        print(y - abs(x) + 1)
    else:
        print(abs(x) - y + 1)
else:
    if y >= x:
        print(y - x)
    else:
        print(abs(y) - abs(x) + 2)
Problem: p03838
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x,y = map(int,input().split())
suma = abs(abs(x)-abs(y))
if abs(x) == abs(y):
    if x*y < 0:
        suma += 1
elif abs(x) < abs(y):
    if x < 0:
        suma += 1
        if y < 0:
            suma += 1
    else:
        if y < 0:
            suma += 1
else:
    if x < 0:
        if y < 0:
            suma += 2
        else:
            suma += 1
    else:
        if y < 0:
            suma += 1
        else:
            suma += 2
print(suma)

Failing test case input:
40 0

Expected output:
41


Actual output:
42


Fixed submission (verdict: Accepted):
x,y = map(int,input().split())
suma = abs(abs(x)-abs(y))
if x == 0:
    if y < 0:
        suma += 1
elif y == 0:
    if x > 0:
        suma += 1
elif abs(x) == abs(y):
    if x*y < 0:
        suma += 1
elif abs(x) < abs(y):
    if x < 0:
        suma += 1
        if y < 0:
            suma += 1
    else:
        if y < 0:
            suma += 1
else:
    if x < 0:
        if y < 0:
            pass
        else:
            suma += 1
    else:
        if y < 0:
            suma += 1
        else:
            suma = min(x+y,(x-y)+2)
print(suma)

Problem: p03838
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x, y = map(int, input().split())
dist = abs(abs(x) - abs(y))
if x <= y:
  x, y = y, x
if x + dist == y:
  ans = dist
elif - x + dist == y:
  ans = dist + 1
elif - x + dist == -y:
  ans = dist + 2
elif x + dist == -y:
  ans = dist + 1
print(ans)

Failing test case input:
0 -32

Expected output:
33


Actual output:
34


Fixed submission (verdict: Accepted):
x, y = map(int, input().split())
dist = abs(abs(x) - abs(y))

if x + dist == y:
  ans = dist
elif - x + dist == y:
  ans = dist + 1
elif x + dist == -y:
  ans = dist + 1
elif - x + dist == -y:
  ans = dist + 2

print(ans)

Problem: p03838
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x, y = map(int, input().split())
a_cnt = abs(abs(x) - abs(y))
if y >= x:
    print(a_cnt)
elif abs(y) == abs(x):
    print(1)
else:
    print(a_cnt + 2)


Failing test case input:
100 -1

Expected output:
100


Actual output:
101


Fixed submission (verdict: Accepted):
x, y = map(int, input().split())
a_cnt = abs(abs(x) - abs(y))

if x + a_cnt == y:
    print(a_cnt)
elif x + a_cnt == -y:
    print(a_cnt + 1)
elif x - a_cnt == -y:
    print(a_cnt + 1)
else:
    print(a_cnt + 2)

Problem: p03838
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x,y=map(int,input().split())
ans=abs(abs(x)-abs(y))
if x>=0:
    if y<0:
        ans+=1
    elif x>y:
        ans+=2
else:
    if y>0:
        ans+=1
    elif x>y:
        ans+=2

print(ans)

Failing test case input:
664 0

Expected output:
665


Actual output:
666


Fixed submission (verdict: Accepted):
x,y=map(int,input().split())
ans=abs(abs(x)-abs(y))
if y==0:
    if x>0:
        ans+=1
elif x>=0:
    if y<0:
        ans+=1
    elif x>y:
        ans+=2
else:
    if y>0:
        ans+=1
    elif x>y:
        ans+=2

print(ans)
Problem: p03838
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
x,y=[int(i) for i in input().split()]
if 0<=x and 0<=y:
    if x>y:
        print(x-y+1)
    else:
        print(y-x)

elif 0<=x and y<0:
    if y==0:
        print(abs(abs(x)-y)+1)
    elif abs(y)==abs(x):
        print(1)
    else:
        print(abs(abs(x)-y)+1)

elif x<0 and 0<=y:
    if y==0:
        print(abs(abs(x)-y))
    elif abs(y)==abs(x):
        print(1)
    else:
        print(abs(abs(x)-y)+1)

elif x<0 and y<0:
    if abs(x)<abs(y):
        print(abs(abs(x)-abs(y))+2)
    else:
        print(abs(abs(x)-abs(y)))



Failing test case input:
53 6

Expected output:
49


Actual output:
48


Fixed submission (verdict: Accepted):
import sys
x,y=[int(i) for i in input().split()]
if 0<=x and 0<=y:
    if y==0:
        print(x+1)
        sys.exit()
    if x>y:
        print(x-y+2)
        sys.exit()
    else:
        print(y-x)
        sys.exit()

elif 0<=x and y<0:
    print(abs(abs(y)-x)+1)
    sys.exit()

elif x<0 and 0<=y:
    if y==0:
        print(abs(abs(x)-y))
        sys.exit()
    else:
        print(abs(abs(x)-y)+1)
        sys.exit()

elif x<0 and y<0:
    if abs(x)<abs(y):
        print(abs(abs(x)-abs(y))+2)
        sys.exit()
    else:
        print(abs(abs(x)-abs(y)))
        sys.exit()

a=1
a+='a'

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

x, y = map(int, input() .split())


if y > x:
	if abs(x) > abs(y):
		a = y-x
	else:
		a = min(y-x, y-abs(x)+1)
else:
	if x < 0:
		a = abs(abs(x) - abs(y)) + 2
	else:
		a = abs(abs(x) - abs(y)) + 1

print (a)



Failing test case input:
101 1

Expected output:
102


Actual output:
101


Fixed submission (verdict: Accepted):

x, y = map(int, input() .split())


if y > x:
	if x*y >= 0:
		a = y-x
	else:
		a = abs(abs(x) - abs(y)) + 1
else:
	if x*y > 0:
		a = abs(abs(x) - abs(y)) + 2
	else:
		a = abs(abs(x) - abs(y)) + 1

print (a)
Problem: p02929
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from sys import stdin

N = int(stdin.readline().rstrip())
S = stdin.readline().rstrip()

ans = 1
inf = 10 ** 9 + 7
d = 'L'
l_count = 1
r_count = 0
for i in range(1, 2 * N):
    if S[i] != S[i - 1]:
        if d == 'R':
            ans *= l_count - r_count
            ans %= inf
            r_count += 1
        else:
            l_count += 1
    else:
        if d == 'R':
            d = 'L'
            l_count += 1
        else:
            ans *= l_count - r_count
            ans %= inf
            d = 'R'
            r_count += 1

for j in range(1, N + 1):
    ans *= j
    ans %= inf

print(ans % inf)

Failing test case input:
5
WWWWWXWWWU

Expected output:
0


Actual output:
360


Fixed submission (verdict: Accepted):
from sys import stdin

N = int(stdin.readline().rstrip())
S = stdin.readline().rstrip()

ans = 1
inf = 10 ** 9 + 7
d = 'L'
l_count = 1
r_count = 0

if S[0] == 'W' or S[2 * N - 1] == 'W':
    print(0)
    exit()

for i in range(1, 2 * N):
    if S[i] != S[i - 1]:
        if d == 'R':
            ans *= l_count - r_count
            ans %= inf
            r_count += 1
        else:
            l_count += 1
    else:
        if d == 'R':
            d = 'L'
            l_count += 1
        else:
            ans *= l_count - r_count
            ans %= inf
            d = 'R'
            r_count += 1

if l_count != r_count:
    print(0)
    exit()

for j in range(1, N + 1):
    ans *= j
    ans %= inf

print(ans % inf)

Problem: p02929
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from math import factorial
N = int(input())
S = input()
MOD = 10 ** 9 + 7

LR = [True]  
for i in range(N*2-1):
    LR += [LR[-1]] if S[i+1] != S[i] else [not LR[-1]]


cmb = 1
cr = 0
for i in range(N*2-1, -1, -1):
    if not LR[i]:
        cr += 1
    else:
        cmb *= cr
        cmb %= MOD
        cr -= 1

print((factorial(N) * cmb) % MOD)


Failing test case input:
5
WXWWVWWWWW

Expected output:
0


Actual output:
720


Fixed submission (verdict: Accepted):
from math import factorial
N = int(input())
S = input()
MOD = 10 ** 9 + 7

LR = [True]  
for i in range(N*2-1):
    LR += [LR[-1]] if S[i+1] != S[i] else [not LR[-1]]

valid = S[0] == S[-1] == 'B' and not LR[-1] and LR.count(True) == N

if valid:
    
    cmb = 1
    cr = 0
    for i in range(N*2-1, -1, -1):
        if not LR[i]:
            cr += 1
        else:
            cmb *= cr
            cmb %= MOD
            cr -= 1

    print((factorial(N) * cmb) % MOD)
else:
    print(0)
Problem: p02929
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

MOD = 10**9 + 7
n = int(input())
s = input()
d = 1
ans = 1
for i in range(1, 2 * n):
    if (s[i] == 'B') ^ (d % 2 != 0):
        d += 1
    else:
        ans *= max(1, d)
        ans %= MOD
        d -= 1
if d != 0 or s[0] == 'W' or s[-1] == 'W':
    print(0)
    exit()
for i in range(1, n + 1):
    ans *= i
    ans %= MOD
print(ans)


Failing test case input:
4
BWBBWBWX

Expected output:
0


Actual output:
144


Fixed submission (verdict: Accepted):

MOD = 10**9 + 7
n = int(input())
s = input()
d = 0
ans = 1
for i in range(2 * n):
    if (s[i] == 'B') ^ (d % 2 != 0):
        d += 1
    else:
        ans *= d
        ans %= MOD
        d -= 1
if d != 0:
    print(0)
    exit()
for i in range(1, n + 1):
    ans *= i
    ans %= MOD
print(ans)
Problem: p02929
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))



def fact(a,M=mod):
    ans = 1
    for i in range(2,a+1):
        ans = ans*i
        ans = ans%M
    return ans

N = I()
S = str(input())

if S[0]=='W':
    print(0)
    exit()

d = ['L']*(2*N)
for i in range(1,2*N):
    if S[i]!=S[i-1]:
        d[i]=d[i-1]
    else:
        if d[i-1]=='L':
            d[i] = 'R'
        else:
            d[i] = 'L'

temp = 0
x = [0]*(2*N)
for i in range(2*N):
    if d[i]=='L':
        temp += 1
    else:
        x[i] = temp

ans = 1
rnum = 0
for i in range(2*N):
    if d[i]=='R':
        ans *= x[i]-rnum
        ans %= mod
        rnum += 1

ans *= fact(N)
ans %= mod

print(ans)

Failing test case input:
4
BWABWCWW

Expected output:
0


Actual output:
168


Fixed submission (verdict: Accepted):

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))



def fact(a,M=mod):
    ans = 1
    for i in range(2,a+1):
        ans = ans*i
        ans = ans%M
    return ans

N = I()
S = str(input())

if S[0]=='W':
    print(0)
    exit()

if S[2*N-1]=='W':
    print(0)
    exit()

d = ['L']*(2*N)

for i in range(1,2*N):
    if S[i]!=S[i-1]:
        d[i]=d[i-1]
    else:
        if d[i-1]=='L':
            d[i] = 'R'
        else:
            d[i] = 'L'

nr = 0
nl = 0
for i in range(2*N):
    if d[i]=='L':
        nl += 1
    else:
        nr += 1
if nl != nr:
    print(0)
    exit()



temp = 0
x = [0]*(2*N)
for i in range(2*N):
    if d[i]=='L':
        temp += 1
    else:
        x[i] = temp

ans = 1
rnum = 0
for i in range(2*N):
    if d[i]=='R':
        ans *= x[i]-rnum
        ans %= mod
        rnum += 1

ans *= fact(N)
ans %= mod

print(ans)
Problem: p02929
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import math

n=int(input())
s=list(input())

for i in range(0,2*n,2):
    if s[i]=='W':
        s[i]='B'
    else:
        s[i]='W'


countL=0
ans=1
for i in range(2*n):
    if s[i]=='W':
        countL+=1
    else:
        ans*=countL
        if countL==0:
            print(0)
            exit()
        countL-=1


x=math.factorial(n)
x=x%(10**9+7)
ans=ans%(10**9+7)
print((ans*x)%(10**9+7))




Failing test case input:
4
BBAWVCWW

Expected output:
0


Actual output:
144


Fixed submission (verdict: Accepted):
mod=10**9+7
n=int(input())
s=list(input())

for i in range(0,2*n,2):
    if s[i]=='W':
        s[i]='B'
    else:
        s[i]='W'


countL=0
ans=1
for i in range(2*n):
    if s[i]=='W':
        countL+=1
    else:
        ans*=countL
        if countL==0:
            print(0)
            exit()
        ans%=mod
        countL-=1
if countL!=0:
    print(0)
    exit()

for i in range(1,n+1):
    ans*=i
    ans%=mod
print(ans)

Problem: p02929
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
Q = 10**9+7
def main():
    N = int( input())
    S = input()
    left = 0
    ans = 1
    for s in S:
        if s == "B":
            if left%2 == 0:
                left += 1
            else:
                if left == 0:
                    print(0)
                    return
                ans *= left
                left -= 1
        else:
            if left%2 == 1:
                left += 1
            else:
                if left == 0:
                    print(0)
                    return
                ans *= left
                left -= 1
        ans %= Q
    if left > 0:
        print(0)
        return
    for i in range(1,N+1):
        ans *= i
        ans %= Q
    print(ans)
if __name__ == '__main__':
    main()


Failing test case input:
2
BWWB

Expected output:
4

Actual output:
0


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
Q = 10**9+7
def main():
    N = int( input())
    S = input()
    left = 0
    ans = 1
    for i in range(N*2):
        s = S[i]
        if s == "B":
            if left%2 == 0:
                left += 1
            else:
                ans *= left
                left -= 1
        else:
            if left%2 == 1:
                left += 1
            else:
                ans *= left
                left -= 1
        ans %= Q
    if left > 0 or ans == 0:
        print(0)
        return
    for i in range(1,N+1):
        ans *= i
        ans %= Q
    print(ans)
if __name__ == '__main__':
    main()
Problem: p02929
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,S = open(0).read().split()
N = int(N)
T = []
MOD = 10**9+7
for i,c in enumerate(S):
  if i%2==0:
    if c=='B':
      T.append('W')
    else:
      T.append('B')
  else:
    T.append(c)

pre = 0
ans = 1
for c in T:
  if c=='B':
    ans *= pre
    ans %= MOD
    pre -= 1
  else:
    pre += 1
coef = 1
for i in range(1,N+1):
  coef *= i
  coef %= MOD
print(ans*coef%MOD)

Failing test case input:
4
BWBBWCWW

Expected output:
0


Actual output:
288


Fixed submission (verdict: Accepted):


N,S = open(0).read().split()
N = int(N)
T = []
MOD = 10**9+7
for i,c in enumerate(S):
  if i%2==0:
    if c=='B':
      T.append('W')
    else:
      T.append('B')
  else:
    T.append(c)

pre = 0
ans = 1
for c in T:
  if c=='B':
    ans *= pre
    ans %= MOD
    pre -= 1
    flag = False
  else:
    pre += 1
if T.count('B')!=T.count('W'):
  ans = 0
coef = 1
for i in range(1,N+1):
  coef *= i
  coef %= MOD
print(ans*coef%MOD)
Problem: p02929
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from collections import Counter

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


class FactMod():
    

    def __init__(self, n, mod):
        
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        
        return self.f[n]

    def comb(self, n, r):
        
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret

    def perm(self, n, r):
        
        ret = self.f[n] * self.inv[n-r]
        ret %= self.mod
        return ret

    def fact(self, n):
        return self.f[n]


MOD = 10**9+7
N = int(input())
S = input()[:-1]
F = FactMod(N+1, MOD)

cnt_W = 0
cnt = 0
ans = 1
for i, c in enumerate(S):
    if c == "B":
        tmp = 1
    else:
        tmp = 0
    if i % 2 == 0:
        tmp ^= 1

    if tmp == 0:
        cnt += 1
    else:
        ans *= cnt
        ans %= MOD
        cnt -= 1
        cnt_W += 1
if cnt != N:
    ans = 0
else:
    ans *= F.fact(N)
    ans %= MOD
print(ans)


Failing test case input:
4
BWWWBBWB

Expected output:
288


Actual output:
0


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

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


class FactMod():
    

    def __init__(self, n, mod):
        
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        
        return self.f[n]

    def comb(self, n, r):
        
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret

    def perm(self, n, r):
        
        ret = self.f[n] * self.inv[n-r]
        ret %= self.mod
        return ret

    def fact(self, n):
        return self.f[n]


MOD = 10**9+7
N = int(input())
S = input()[:-1]
F = FactMod(N+1, MOD)

cnt_W = 0
cnt = 0
ans = 1
for i, c in enumerate(S):
    if c == "B":
        tmp = 1
    else:
        tmp = 0
    if i % 2 == 0:
        tmp ^= 1

    if tmp == 0:
        cnt += 1
    else:
        ans *= cnt
        ans %= MOD
        cnt -= 1
        cnt_W += 1
if cnt_W != N:
    ans = 0
else:
    ans *= F.fact(N)
    ans %= MOD
print(ans)
Problem: p02929
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from math import factorial

n = int(input())
s = input()


MOD = 10**9+7


lr = ''
for i, x in enumerate(s):
    if i % 2 == 0:
        if x == 'B':
            lr += 'L'
        else:
            lr += 'R'
    else:
        if x == 'B':
            lr += 'R'
        else:
            lr += 'L'

cnt = 0
point = 1
for x in lr:
    if x == 'L':
        cnt += 1
    else:
        point *= cnt
        cnt -= 1


print(point*factorial(n) % MOD)

Failing test case input:
4
BWBBWCWW

Expected output:
0


Actual output:
288


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)


n = int(input())
s = input().rstrip()
MOD = 10**9+7

cnt = 0
point = 1
for i, x in enumerate(s):
    if (x == 'B' and i % 2 == 0) or (x == 'W' and i % 2 != 0):
        cnt += 1
    else:
        point *= cnt
        cnt -= 1
        point %= MOD


if cnt != 0:
    print(0)
else:
    
    for x in range(1, n+1):
        point *= x
        point %= MOD

    print(point)

Problem: p02929
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
S=input()
l=0
a=1
for i in range(2*N):
    if S[i]=="W":
        if l%2==0:
            a=a*l%(10**9+7)
            l-=1
        else:
            l+=1
    else:
        if l%2==0:
            l+=1
        else:
            a=a*l%(10**9+7)
            l-=1
if l!=1:
    a=0
for i in range(1,N+1):
    a=a*i%(10**9+7)
print(a)

Failing test case input:
4
BWWWBBWB

Expected output:
288


Actual output:
0


Fixed submission (verdict: Accepted):
N=int(input())
S=input()
l=0
a=1
for i in range(2*N):
    if S[i]=="W":
        if l%2==0:
            a=a*l%(10**9+7)
            l-=1
        else:
            l+=1
    else:
        if l%2==0:
            l+=1
        else:
            a=a*l%(10**9+7)
            l-=1
if l!=0:
    a=0
for i in range(1,N+1):
    a=a*i%(10**9+7)
print(a)
Problem: p03977
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
T = int(input())
ts = [tuple(map(int,input().split())) for i in range(T)]

def solve(n,d):
    if n%2:
        return d + 127*(n-1)
    else:
        return d^127 + 127*(n-1)

for n,d in ts:
    print(solve(n,d))

Failing test case input:
3
1 3
6 25
1 9

Expected output:
3
737
9


Actual output:
3
739
9


Fixed submission (verdict: Accepted):
T = int(input())
ts = [tuple(map(int,input().split())) for i in range(T)]

def solve(n,d):
    if n%2:
        return d + 127*(n-1)
    else:
        return 127*n - d

for n,d in ts:
    print(solve(n,d))

Problem: p03977
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
T = int(input())
ts = [tuple(map(int,input().split())) for i in range(T)]

def solve(n,d):
    if n%2:
        return d + 127*(n-1)
    else:
        tmp = 0
        for a in range(128):
            tmp = max(tmp, a + a^d)
        return tmp - d + 127*(n-2)

for n,d in ts:
    print(solve(n,d))

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

Expected output:
255
471
2


Actual output:
255
472
2


Fixed submission (verdict: Accepted):
T = int(input())
ts = [tuple(map(int,input().split())) for i in range(T)]

def solve(n,d):
    if n%2:
        return d + 127*(n-1)
    else:
        return 127*n - d

for n,d in ts:
    print(solve(n,d))

Problem: p03977
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N,T=0,0
for i in range(int(input())):
  N,T=map(int,input().split())
  if N&1:
    T^=127
  print(T+(N-1)*127)

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

Expected output:
2
558
11


Actual output:
125
585
116


Fixed submission (verdict: Accepted):
N,T=0,0
for i in range(int(input())):
  N,T=map(int,input().split())
  if N&1==0:
    T^=127
  print(T+(N-1)*127)

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

for i in range(T):
    N, D = map(int, input().split())
    ans = D
    h = []
    heappush(h,D)
    for _ in range(N - 1):
        k = heappop(h)
        z = bin(k)[2:].zfill(7)
        t = int(z,2)
        heappush(h,t)
        ans += (127 + t - k)
    print(ans)



Failing test case input:
3
1 1
6 25
1 18

Expected output:
1
737
18


Actual output:
1
660
18


Fixed submission (verdict: Accepted):
from heapq import heappush, heappop
T = int(input())
A = []
for i in range(T):
    N, D = map(int, input().split())
    ans = D
    h = []
    heappush(h,D)
    for _ in range(N - 1):
        k = heappop(h)
        t = 127 ^ k
        heappush(h,t)
        ans += (127 + t - k)
    A.append(ans)
for i in range(len(A)):
    print(A[i])
Problem: p00613
Buggy submission (Python3, verdict: Wrong Answer):
while True:
    K = int(input())
    if K == 0:
        break
    else:
        po = [int(i) for i in input().split()]
        print(sum(po)/(K-1))

Failing test case input:
2
2
2
2 21 1
0

Expected output:
2
24


Actual output:
2.0
24.0


Fixed submission (verdict: Accepted):
while True:
    K = int(input())
    if K == 0:
        break
    elif K == 1:
        print(int(input()))
    else:
        po = [int(i) for i in input().split()]
        print(int(sum(po)/(K-1)))
Problem: p02345
Buggy submission (Python3, verdict: Wrong Answer):
M = 2147483647
a = [M for i in range(100000)]

def find(x,y,i,l,r):
    if r<=x or y<=l:return M
    if x<=l and r<=y: return a[i]
    return min(find(x,y,i*2,l,(l+r)/2),find(x,y,i*2+1,(l+r)/2,r))

if __name__=='__main__':
    n, m = (int(x) for x in input().split())
    t=1
    while t<n :t *= 2
    for i in range(1,t*2):
        a[i]=M

    for i in range(m-1,-1,-1):
        com,x,y = (int(x) for x in input().split())
        if com :print(find(x,y+1,1,0,t))
        else:
            x+=t
            a[x]=y
            while isinstance(x, int):
               a[int(x/2)]=min(a[int(x)],a[int(x)^1])
               x/=2



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

Expected output:
1
1
2


Actual output:
2147483647
1
2


Fixed submission (verdict: Accepted):
M = 2147483647
a = [M for i in range(1000000)]

def j_min(x,y):
    if x < y:return x
    else: return y

def find(x,y,i,l,r):
    if r<=x or y<=l:return M
    if x<=l and r<=y: return a[i]
    return j_min(find(x,y,i*2,l,(l+r)/2),find(x,y,i*2+1,(l+r)/2,r))

if __name__=='__main__':
    n, m = (int(x) for x in input().split())
    t=1
    while t<n :t *= 2

    for i in range(m-1,-1,-1):
        com,x,y = (int(x) for x in input().split())
        if com :
            
            print(find(x,y+1,1,0,t))
        else:
            x+=t
            a[x]=y
            while isinstance(x, int) or x >= 2:
               a[int(x/2)]=j_min(a[int(x)],a[int(x)^1])
               x/=2
Problem: p02345
Buggy submission (Python3, verdict: Wrong Answer):
import sys
sys.setrecursionlimit(10000)


def initRMQ(n, D):
    n_ = 1

    while n_ < n:
        n_ *= 2

    for i in range(2*n_ - 1):
        D.append(2147483647)

    return n_


def update(k, a):
    k += n_ - 1
    D[k] = a
    while k > 0:
        k = int((k - 1) / 2)
        D[k] = min(D[k*2 + 1], D[k*2 + 2])


def findMin(a, b):
    return query(a, b + 1, 0, 0, n)


def query(a, b, k, l, r):
    
    if r <= a or b <= l:
        return 2147483647

    if a <= l and r <= b:
        return D[k]

    vl = query(a, b, k*2 + 1, l, int((l + r)/2))
    vr = query(a, b, k*2 + 2, int((l + r)/2), r)

    return min(vl, vr)


if __name__ == '__main__':
    n, q = map(int, input().split())

    D = []
    n_ = initRMQ(n, D)

    for _ in range(q):
        
        c, x, y = map(int, input().split())

        if c == 0:
            update(x, y)

        else :
            print(findMin(x, y))



Failing test case input:
5 5
0 0 0
1 2 2
1 0 1
0 1 9
1 1 2

Expected output:
2147483647
0
9


Actual output:
2147483647
0
2147483647


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10000)


def initRMQ(n, D):
    n_ = 1

    while n_ < n:
        n_ *= 2

    for i in range(2*n_ - 1):
        D.append(2147483647)

    return n_


def update(k, a):
    k += n_ - 1
    D[k] = a
    while k > 0:
        k = int((k - 1) / 2)
        D[k] = min(D[k*2 + 1], D[k*2 + 2])


def findMin(a, b):
    return query(a, b + 1, 0, 0, n_)


def query(a, b, k, l, r):
    
    if r <= a or b <= l:
        return 2147483647

    if a <= l and r <= b:
        return D[k]

    vl = query(a, b, k*2 + 1, l, int((l + r)/2))
    vr = query(a, b, k*2 + 2, int((l + r)/2), r)

    return min(vl, vr)


if __name__ == '__main__':
    n, q = map(int, input().split())

    D = []
    n_ = initRMQ(n, D)

    for _ in range(q):
        
        c, x, y = map(int, input().split())

        if c == 0:
            update(x, y)

        else :
            print(findMin(x, y))
Problem: p02345
Buggy submission (Python3, verdict: Wrong Answer):
M = 2147483647
a = [M for i in range(100000)]

def j_min(x,y):
    if x < y:return x
    else: return y

def find(x,y,i,l,r):
    if r<=x or y<=l:return M
    if x<=l and r<=y: return a[i]
    return min(find(x,y,i*2,l,(l+r)/2),find(x,y,i*2+1,(l+r)/2,r))

if __name__=='__main__':
    n, m = (int(x) for x in input().split())
    t=1
    while t<n :t *= 2

    for i in range(m-1,-1,-1):
        com,x,y = (int(x) for x in input().split())
        if com :
            print(find(x,y+1,1,0,t))
        else:
            x+=t
            a[x]=y
            while isinstance(x, int):
               a[int(x/2)]=j_min(a[int(x)],a[int(x)^1])
               x/=2



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

Expected output:
2147483647
2147483647
3
3


Actual output:
2147483647
2147483647
2147483647
3


Fixed submission (verdict: Accepted):
M = 2147483647
a = [M for i in range(1000000)]

def j_min(x,y):
    if x < y:return x
    else: return y

def find(x,y,i,l,r):
    if r<=x or y<=l:return M
    if x<=l and r<=y: return a[i]
    return j_min(find(x,y,i*2,l,(l+r)/2),find(x,y,i*2+1,(l+r)/2,r))

if __name__=='__main__':
    n, m = (int(x) for x in input().split())
    t=1
    while t<n :t *= 2

    for i in range(m-1,-1,-1):
        com,x,y = (int(x) for x in input().split())
        if com :
            
            print(find(x,y+1,1,0,t))
        else:
            x+=t
            a[x]=y
            while isinstance(x, int) or x >= 2:
               a[int(x/2)]=j_min(a[int(x)],a[int(x)^1])
               x/=2