ZhenlongDai/ACPR huggingface dataset:
Problem: p03082
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
mod = 10**9+7

n,m = map(int,input().split())

s = list(map(int,input().split()))

s.sort()

s = [None] + s

dp = [[0 for i in range(m+1)] for j in range(n+1)]
dp[1] = [i % s[1] for i in range(m+1)]

for i in range(2,n+1):
    for j in range(m+1):
        dp[i][j] = (dp[i-1][j] * (n-1) + dp[n-1][j%s[i]]) % mod
print(dp[n][m])

Failing test case input:
10 100001
13715 64565 14615 43639 20289 59986 79355 23347 62439 69981

Expected output:
367458865


Actual output:
908143862


Fixed submission (verdict: Accepted):
mod = 10**9+7

n,m = map(int,input().split())

s = list(map(int,input().split()))

s.sort()

s = [None] + s

dp = [[0 for i in range(m+1)] for j in range(n+1)]
dp[1] = [i % s[1] for i in range(m+1)]

for i in range(2,n+1):
    for j in range(m+1):
        dp[i][j] = (dp[i-1][j] * (i-1) + dp[i-1][j%s[i]]) % mod
print(dp[n][m])

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



import math
MOD=10**9+7
N,x=map(int,input().split())

a=list(map(int,input().split()))
a.sort()
a.reverse()
table=[[0 for i in range(N+1)] for j in range(x+1)]
for i in range(x+1):
	table[i][N]=i

for i in range(N-1,-1,-1):
	for x in range(x+1):
		table[x][i]=table[x][i+1]*(N-1-i)+table[x%a[i]][i+1] % MOD

print(table[x][0])

Failing test case input:
10 100000
13715 50001 13306 50003 50004 79705 50006 86630 97937 36071

Expected output:
835757008


Actual output:
16835757120


Fixed submission (verdict: Accepted):
import math

def cul(i,x):
    if tmp[i][x]==-1:
        tmp[i][x]=( cul(i+1,x)*(N-1-i) + cul(i+1,x%a[i]) )%MOD
    return tmp[i][x]

MOD=10**9+7
N,x=map(int,input().split())

a=list(map(int,input().split()))
a.sort(reverse=True)
tmp= [[-1 for j in range(x+1)] for i in range(N)] + [[j for j in range(x+1)]]

print(cul(0,x))

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

MOD = 1000000007
numbers = S[:]
numbers.sort(reverse=True)


dp = {X: 1}

for i, n in enumerate(numbers):
    tmp_dp = dp.copy()
    for k, v in tmp_dp.items():
        tmp = k % n
        dp[k] = v * (N-i-1)
        dp[tmp] = dp.get(tmp, 0) + v
    
        
ans = 0
for k, v in dp.items():
    ans += k *  v

print(ans % MOD)
        
    

Failing test case input:
5 82
27 11 6 7 13

Expected output:
456


Actual output:
240


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

MOD = 1000000007
numbers = S[:]
numbers.sort(reverse=True)


dp = {X: 1}

for i, n in enumerate(numbers):
    tmp_dp = {}
    for k, v in dp.items():
        if k < n:
            tmp_dp[k] = (tmp_dp.get(k,0)+v*(N-i))
        else:
            tmp_dp[k]=(tmp_dp.get(k,0)+v*(N-i-1)) 
            tmp_dp[k%n]=(tmp_dp.get(k%n,0)+v) 
    dp = tmp_dp.copy()
        
ans = 0
for k, v in dp.items():
    ans += k *  v

print(ans % MOD)
Problem: p03179
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
s = input()

mod = 10**9 + 7

dp = [[0] * n for _ in range(n)]

for more in range(n):
    dp[0][more] = 1

for i in range(n-1):
    if s[i] == "<":
        cum = 0
        for more in reversed(range(n-1)):
            cum += dp[i][more+1]
            cum %= mod
            dp[i + 1][more] += cum
            dp[i + 1][more] %= mod
    else:
        cum = 0
        for more in range(n):
            cum += dp[i][more]
            cum %= mod
            dp[i+1][more] += cum
            dp[i+1][more] %= mod

print(dp[n-1][0])


Failing test case input:
20
>><<>>><>>>>>>><>><

Expected output:
709329473


Actual output:
264846023


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

mod = 10**9 + 7

dp = [[0] * n for _ in range(n)]

for more in range(n):
    dp[0][more] = 1

for i in range(n-1):
    if s[i] == "<":
        cum = 0
        for more in reversed(range(n-1-i)):
            cum += dp[i][more+1]
            cum %= mod
            dp[i + 1][more] += cum
            dp[i + 1][more] %= mod
    else:
        cum = 0
        for more in range(n-1-i):
            cum += dp[i][more]
            cum %= mod
            dp[i+1][more] += cum
            dp[i+1][more] %= mod

print(dp[n-1][0])
Problem: p04026
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
for i in range(len(s)-3):
    if s[i] == s[i+1] or s[i] == s[i+2] or s[i+1] == s[i+2]:
        print(i+1, i+3)
        break
else:
    print(-1, -1)


Failing test case input:
efndfd

Expected output:
4 6


Actual output:
-1 -1


Fixed submission (verdict: Accepted):
s = input()
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        print(i+1, i+2)
        break
    try:
        if s[i] == s[i+2] or s[i+1] == s[i+2]:
            print(i+1, i+3)
            break
    except :
        pass
else:
    print(-1, -1)

Problem: p04026
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
for i in range(3,len(s)+1):
    a=s[i-3:i]
    if len(set(a))!=3:
        print(i-2,i+1)
        break
else:print(-1,-1)

Failing test case input:
bncptee

Expected output:
5 7


Actual output:
5 8


Fixed submission (verdict: Accepted):
s=input()
if len(s)==2 and s[0]==s[1]:print(1,2)
else:
    for i in range(3,len(s)+1):
        a=s[i-3:i]
        if len(set(a))!=3:
            print(i-2,i)
            break
    else:print(-1,-1)

Problem: p04026
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
result = [-1, -1]
for i in range(len(s)-3):
    x = s[i:i+3]
    if x[0]==x[1]or x[0]==x[2]or x[1]==x[2]:
        result = [i+1, i+3]
        break
print(*result)

Failing test case input:
aecsepp

Expected output:
5 7


Actual output:
-1 -1


Fixed submission (verdict: Accepted):
s = input()
result = [-1, -1]
for i in range(len(s)-2):
    x = s[i:i+3]
    if x[0]==x[1]or x[0]==x[2]or x[1]==x[2]:
        result = [i+1, i+3]
        break
if len(s)==2 and s[0]==s[1]:
    result = [1,2]
print(*result)

Problem: p04026
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
for i in range(3,len(s)+1):
    a=s[i-3:i]
    if len(set(a))!=3:
        print(i-3,i)
        break
else:print(-1,-1)

Failing test case input:
ancteep

Expected output:
4 6


Actual output:
3 6


Fixed submission (verdict: Accepted):
s=input()
if len(s)==2 and s[0]==s[1]:print(1,2)
else:
    for i in range(3,len(s)+1):
        a=s[i-3:i]
        if len(set(a))!=3:
            print(i-2,i)
            break
    else:print(-1,-1)
Problem: p04026
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys


def solve(s: str):
    N = len(s)

    if N == 2:
        if s[0] == s[1]:
            print(1,2)
        else:
            print(-1,-1)
        return 

    for i in range(N-2):
        ss = s[i:i+3]
        if ss[0] == ss[1] or ss[1]==ss[2] or ss[2] == ss[1]:
            print(i+1,i+3)
            return
        
    print(-1,-1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  
    solve(s)

if __name__ == '__main__':
    main()


Failing test case input:
fedndd

Expected output:
3 5


Actual output:
4 6


Fixed submission (verdict: Accepted):

import sys


def solve(s: str):
    N = len(s)

    if N == 2:
        if s[0] == s[1]:
            print(1,2)
        else:
            print(-1,-1)
        return 

    for i in range(N-2):
        ss = s[i:i+3]
        if ss[0] == ss[1] or ss[1]==ss[2] or ss[2] == ss[0]:
            print(i+1,i+3)
            return
        
    print(-1,-1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  
    solve(s)

if __name__ == '__main__':
    main()

Problem: p04026
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
result = [-1, -1]
for i in range(len(s)-3):
    x = s[i:i+3]
    if x[0]==x[1]or x[0]==x[2]or x[1]==x[2]:
        result = [i+1, i+4]
        break
print(*result)

Failing test case input:
effdnd

Expected output:
1 3


Actual output:
1 4


Fixed submission (verdict: Accepted):
s = input()
result = [-1, -1]
for i in range(len(s)-2):
    x = s[i:i+3]
    if x[0]==x[1]or x[0]==x[2]or x[1]==x[2]:
        result = [i+1, i+3]
        break
if len(s)==2 and s[0]==s[1]:
    result = [1,2]
print(*result)

Problem: p04026
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
sys.setrecursionlimit(10 ** 7)

s = read().rstrip().decode()
for i, (af, s, bf) in enumerate(zip(s, s[1:], s[2:])):
    if af == s or af == bf or s == bf:
        print(i, i + 2)
        exit()
print(-1, -1)


Failing test case input:
aocuqee

Expected output:
5 7


Actual output:
4 6


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

s = readline().rstrip().decode()
if s[0] == s[1]:
    print(1, 2)
    exit()
for i, (af, s, bf) in enumerate(zip(s, s[1:], s[2:])):
    if af == s or af == bf or s == bf:
        print(i + 1, i + 3)
        exit()
print(-1, -1)
Problem: p04026
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    s = input()
    group = [[s[0], 1, 1]]
    for i in range(1, len(s)):
        if s[i] == group[-1][0]:
            group[-1][1] += 1
        else:
            group.append([s[i], 1, i + 1])
    group.sort(key=lambda x: x[1], reverse=True)
    if group[0][1] > 1:
        print(group[0][2], min(group[0][1] + group[0][2], len(s)))
    else:
        print(-1, -1)


if __name__ == '__main__':
    main()



Failing test case input:
efnded

Expected output:
4 6


Actual output:
-1 -1


Fixed submission (verdict: Accepted):
def main():
    s = input() + "
    group = [[s[0], 1, 1, 0]]
    for i in range(1, len(s)):
        if s[i] == group[-1][0]:
            group[-1][1] += 1
        else:
            group[-1][3] = i
            group.append([s[i], 1, i + 1, -1])
    group.sort(key=lambda x: x[1], reverse=True)
    if group[0][1] > 1:
        print(group[0][2], group[0][3])
    else:
        for i in range(len(s) - 4):
            if s[i] == s[i + 2] and s[i] != s[i + 1]:
                print(i + 1, i + 3)
                break
        else:
            print(-1, -1)


if __name__ == '__main__':
    main()

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

S = input()
N = len(S)
for i in range(1,N-1):
    c2 = S[i:i+2]
    c3 = S[i:i+3]
    if len(set(c2)) == 1:
        print(i+1, i+2)
        exit()
    if  i != N-2 and len(set(c3)) == 2:
        print(i+1, i+3)
        exit()

print(-1, -1)

Failing test case input:
efenee

Expected output:
1 3


Actual output:
3 5


Fixed submission (verdict: Accepted):

S = input()
N = len(S)
for i in range(N-1):
    c2 = S[i:i+2]
    c3 = S[i:i+3]
    if len(set(c2)) == 1:
        print(i+1, i+2)
        exit()
    if  i != N-2 and len(set(c3)) == 2:
        print(i+1, i+3)
        exit()

print(-1, -1)

Problem: p04026
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    s = input()
    group = [[s[0], 1, 1]]
    for i in range(1, len(s)):
        if s[i] == group[-1][0]:
            group[-1][1] += 1
        else:
            group.append([s[i], 1, i + 1])
    group.sort(key=lambda x: x[1], reverse=True)
    if group[0][1] > 1:
        print(group[0][2], group[0][1] + group[0][2])
    else:
        print(-1, -1)


if __name__ == '__main__':
    main()



Failing test case input:
bocptee

Expected output:
5 7


Actual output:
6 8


Fixed submission (verdict: Accepted):
def main():
    s = input() + "
    group = [[s[0], 1, 1, 0]]
    for i in range(1, len(s)):
        if s[i] == group[-1][0]:
            group[-1][1] += 1
        else:
            group[-1][3] = i
            group.append([s[i], 1, i + 1, -1])
    group.sort(key=lambda x: x[1], reverse=True)
    if group[0][1] > 1:
        print(group[0][2], group[0][3])
    else:
        for i in range(len(s) - 4):
            if s[i] == s[i + 2] and s[i] != s[i + 1]:
                print(i + 1, i + 3)
                break
        else:
            print(-1, -1)


if __name__ == '__main__':
    main()
Problem: p04026
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input()
a=0
for i in range(len(S)-2):
  if S[i]==S[i+1] or S[i]==S[i+2] or S[i+1]==S[i+2]:
    a=1
    print(i+1,i+3)
    break

if a==0 and len(S)>1 and S[-1]==S[-2]:
  print(len(S)-1,len(S))
else:
  print(-1,-1)



Failing test case input:
actoeer

Expected output:
4 6


Actual output:
4 6
-1 -1


Fixed submission (verdict: Accepted):
S=input()
a=0
for i in range(len(S)-2):
  if S[i]==S[i+1] or S[i]==S[i+2] or S[i+1]==S[i+2]:
    a=1
    print(i+1,i+3)
    break

if a==0:
 if len(S)>1 and S[-1]==S[-2]:
  print(len(S)-1,len(S))
 else:
  print(-1,-1)

Problem: p04026
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
ans = s[0]
for i in range(1,len(s)):
    ans += s[i]
    if len(ans)==2 and ans[0]==ans[1]:
        print('{0} {1}'.format(i,i+1))
        break
    if len(ans)==3:
        if ans[0]==ans[2] or ans[1]==ans[2]:
            print('{0} {1}'.format(i-1,i+1))
        else:
            ans = ans[1:3]
print('-1 -1')


Failing test case input:
efenee

Expected output:
1 3


Actual output:
1 3
-1 -1


Fixed submission (verdict: Accepted):
s = input()
ans = s[0]
OK = True
for i in range(1,len(s)):
    ans += s[i]
    if len(ans)==2 and ans[0]==ans[1]:
        print('{0} {1}'.format(i,i+1))
        OK=False
        break
    if len(ans)==3:
        if ans[0]==ans[2] or ans[1]==ans[2]:
            OK=False
            print('{0} {1}'.format(i-1,i+1))
        else:
            ans = ans[1:3]
if OK:
    print('-1 -1')

Problem: p04026
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def is_umbalance(s):
    if s[0] == s[1] or s[1] == s[2] or s[2] == s[1]:
        return True
    else:
        return False


def main(s):
    for i in range(len(s) - 2):
        if is_umbalance(s[i:i+3]):
            print(i + 1, i + 3)
            return
    print(-1, -1)


if __name__ == '__main__':
    main(input())

Failing test case input:
efnded

Expected output:
4 6


Actual output:
-1 -1


Fixed submission (verdict: Accepted):
def is_umbalance(s):
    if len(s) == 2:
        return s[0] == s[1]
    if s[0] == s[1] or s[1] == s[2] or s[2] == s[0]:
        return True
    else:
        return False


def main(s):
    for i in range(len(s) - 1):
        if is_umbalance(s[i:i+2]):
            print(i + 1, i + 2)
            return
        if i + 2 < len(s) and is_umbalance(s[i:i+3]):
            print(i + 1, i + 3)
            return
    print(-1, -1)


if __name__ == '__main__':
    main(input())

Problem: p04026
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
S = input()

for i in range(len(S)-3):
  if any([S[i:i+3].count(S[j]) >= 2 for j in range(i,i+3)]):
    print(i+1,i+3)
    exit()
print('-1 -1')


Failing test case input:
aecsepp

Expected output:
5 7


Actual output:
-1 -1


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

if len(S) == 2:
  if S[0] == S[1]:
    print('1 2')
    exit()
else:
  for i in range(len(S)-2):
    if any([S[i:i+3].count(S[j]) >= 2 for j in range(i,i+3)]):
      print(i+1,i+3)
      exit()
print('-1 -1')
Problem: p04026
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    for i in range(len(s)-2):
        ts = s[i:i+3]
        if ts[0] == ts[1] or ts[1] == ts[2] or ts[0] == ts[2]:
            print(i, i + 3)
            exit()
    print(-1, -1)


if __name__ == '__main__':
    solve()


Failing test case input:
ndeedd

Expected output:
2 4


Actual output:
1 4


Fixed submission (verdict: Accepted):
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s = str(readline().rstrip().decode('utf-8'))
    if len(s) == 2:
        if s[0] == s[1]:
            print(1, 2)
        else:
            print(-1, -1)
    else:
        for i in range(len(s)-2):
            ts = s[i:i+3]
            if ts[0] == ts[1] or ts[1] == ts[2] or ts[0] == ts[2]:
                print(i+1, i + 3)
                exit()
        print(-1, -1)


if __name__ == '__main__':
    solve()

Problem: p04026
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input()
a=0
for i in range(len(S)-2):
  if S[i]==S[i+1] or S[i]==S[i+2] :
    a=1
    print(i+1,i+3)
    break
if a==0:
    print(-1,-1)


Failing test case input:
ndeedd

Expected output:
2 4


Actual output:
3 5


Fixed submission (verdict: Accepted):
S=input()
a=0
for i in range(len(S)-2):
  if S[i]==S[i+1] or S[i]==S[i+2] or S[i+1]==S[i+2]:
    a=1
    print(i+1,i+3)
    break

if a==0:
 if len(S)>1 and S[-1]==S[-2]:
  print(len(S)-1,len(S))
 else:
  print(-1,-1)

Problem: p04026
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
p2 = s[0]
p1 = s[1]
ans = ""
if p2 == p1 :
  ans = '1 2'
else:
  for i in range(2,len(s)):
    if p2 == s[i] or p1 == s[i]:
      ans = str(i-1)+" "+str(i+1)
      break
    p2 = s[i-1]
    p1 = s[i]
print(ans)

Failing test case input:
reboate

Expected output:
-1 -1


Actual output:

Fixed submission (verdict: Accepted):
s = input()
p2 = s[0]
p1 = s[1]
ans = "-1 -1"
if p2 == p1 :
  ans = '1 2'
else:
  for i in range(2,len(s)):
    if p2 == s[i] or p1 == s[i]:
      ans = str(i-1)+" "+str(i+1)
      break
    p2 = s[i-1]
    p1 = s[i]
print(ans)

Problem: p04026
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import collections
s = input()
ls = len(s)
if ls <=2:
    print(-1,-1)
for i in range(2,ls):
    tmp = collections.Counter(s[i-2:i])
    if len(tmp.keys())<=2:
        print(i-1,i+1)
        exit()
print(-1,1)

Failing test case input:
ancteep

Expected output:
4 6


Actual output:
1 3


Fixed submission (verdict: Accepted):
import collections
s = input()
ls = len(s)
if ls ==2 and s[0]!=s[1]:
    print(-1,-1)
    exit()
elif ls ==2 and s[0]==s[1]:
    print(1,2)
    exit()
for i in range(2,ls):
    tmp = collections.Counter(s[i-2:i+1])
    if len(tmp.keys())<=2:
        print(i-1,i+1)
        exit()
print(-1,-1)
Problem: p00638
Buggy submission (Python3, verdict: Wrong Answer):
def sky(x):
    return x[1]


while True:
    n = int(input())
    if n == 0:
        break
    
    arr = [[] for i in range(n)]
    sumh = 0
    for i in range(n):
        arr[i] = list(map(int, input().split()))
        sumh += arr[i][0]
    arr.sort(key=sky, reverse=True)
    res = True
    for e in arr:
        if sumh < e[1]:
            res = False
            break
        sumh -= e[0]
    if res:
        print("Yes")
    else:
        print("No")



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

Expected output:
No
No


Actual output:
Yes
No


Fixed submission (verdict: Accepted):
def sky(x):
    return x[1]


while True:
    n = int(input())
    if n == 0:
        break
    
    arr = [[] for i in range(n)]
    sumh = 0
    for i in range(n):
        arr[i] = list(map(int, input().split()))
    arr.sort(key=sky)
    res = True
    for e in arr:
        sumh += e[0]
        if sumh > e[1]:
            res = False
            break
    if res:
        print("Yes")
    else:
        print("No")

Problem: p00638
Buggy submission (Python3, verdict: Wrong Answer):
def sky(x):
    return x[1]


while True:
    n = int(input())
    if n == 0:
        break
    
    brimax = 0
    sumz = 0
    for i in range(n):
        inp = list(map(int, input().split()))
        brimax = max(brimax, inp[1])
        sumz += inp[0]
    if brimax < sumz:
        print("No")
    else:
        print("Yes")



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

Expected output:
No
No


Actual output:
Yes
Yes


Fixed submission (verdict: Accepted):
def sky(x):
    return x[1]


while True:
    n = int(input())
    if n == 0:
        break
    
    arr = [[] for i in range(n)]
    sumh = 0
    for i in range(n):
        arr[i] = list(map(int, input().split()))
    arr.sort(key=sky)
    res = True
    for e in arr:
        sumh += e[0]
        if sumh > e[1]:
            res = False
            break
    if res:
        print("Yes")
    else:
        print("No")
Problem: p00638
Buggy submission (Python3, verdict: Wrong Answer):
def sky(x):
    return x[1]


while True:
    n = int(input())
    if n == 0:
        break
    
    arr = [[] for i in range(n)]
    sumh = 0
    for i in range(n):
        arr[i] = list(map(int, input().split()))
        sumh += arr[i][0]
    arr.sort(key=sky, reverse=True)
    print(arr)
    res = True
    for e in arr:
        if sumh > e[1]:
            res = False
            break
        sumh -= e[0]
    if res:
        print("Yes")
    else:
        print("No")



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

Expected output:
Yes
No


Actual output:
[[2, 6], [2, 3], [1, 2]]
Yes
[[3, 6], [3, 3], [2, 2]]
No


Fixed submission (verdict: Accepted):
def sky(x):
    return x[1]


while True:
    n = int(input())
    if n == 0:
        break
    
    arr = [[] for i in range(n)]
    sumh = 0
    for i in range(n):
        arr[i] = list(map(int, input().split()))
    arr.sort(key=sky)
    res = True
    for e in arr:
        sumh += e[0]
        if sumh > e[1]:
            res = False
            break
    if res:
        print("Yes")
    else:
        print("No")
Problem: p02882
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

a, b, x = map(int, input().split())

if a ** 2 * b <= x:
    print(math.degrees(math.atan(2 * (a ** 2 * b - x) / (a ** 3))))
else:
    print(180 - 90 - math.degrees(math.atan(2 * x / (b ** 2 * a))))


Failing test case input:
34 21 10

Expected output:
89.9235751027


Actual output:
89.92357510266389


Fixed submission (verdict: Accepted):
import math

a, b, x = map(int, input().split())

if a ** 2 * b / 2 <= x:
    print(round(math.degrees(math.atan(2 * (a ** 2 * b - x) / (a ** 3))), 10))
else:
    print(round(180 - 90 - math.degrees(math.atan(2 * x / (b ** 2 * a))), 10))

Problem: p02882
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

def volume(a,b,x):
  if a**2*b <= x:
  	k = 2*(b*a**2-x)/(a**3)
  	print(math.degrees(math.atan(k)))
  else:
    k = a*b**2/(2*x)
    print(math.degrees(math.atan(k)))
    
a,b,x = map(int,input().split())
volume(a,b,x)

Failing test case input:
2 21 10

Expected output:
88.7009985883


Actual output:
88.70099858833915


Fixed submission (verdict: Accepted):
import math

def volume(a,b,x):
  if a**2*b
  	k = 2*(b*a**2-x)/(a**3)
  	print(math.degrees(math.atan(k)))
  else:
    k = a*b**2/(2*x)
    print(math.degrees(math.atan(k)))
    
a,b,x = map(int,input().split())
volume(a,b,x)

Problem: p02882
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
s = input().split()
a = int(s[0])
b = int(s[1])
x = int(s[2])

if x <= a*a*b/2:
    y = (2*x)/(a*b)
    print(y)
    print(round(90-math.degrees(math.atan(y/b)), 10))
else:
   y = 2*b-((2*x)/(a*a))
   print(round(math.degrees(math.atan(y/a)), 10))

Failing test case input:
9 28 5

Expected output:
89.9187985528


Actual output:
0.03968253968253968
89.9187985528


Fixed submission (verdict: Accepted):
import math
s = input().split()
a = int(s[0])
b = int(s[1])
x = int(s[2])

if x < a*a*b/2.0:
    y = (2*x)/(a*b)
    print(round(90-math.degrees(math.atan(y/b)), 10))
else:
    y = 2*b-((2*x)/(a*a))
    print(round(math.degrees(math.atan(y/a)), 10))

Problem: p02882
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
s = input().split()
a = int(s[0])
b = int(s[1])
x = int(s[2])

if x < a*a*b/2.0:
    y = (2*x)/(a*b)
    print(y)
    print(round(90-math.degrees(math.atan(y/b)), 10))
else:
   y = 2*b-((2*x)/(a*a))
   print(round(math.degrees(math.atan(y/a)), 10))

Failing test case input:
2 35 7

Expected output:
89.6725991092


Actual output:
0.2
89.6725991092


Fixed submission (verdict: Accepted):
import math
s = input().split()
a = int(s[0])
b = int(s[1])
x = int(s[2])

if x < a*a*b/2.0:
    y = (2*x)/(a*b)
    print(round(90-math.degrees(math.atan(y/b)), 10))
else:
    y = 2*b-((2*x)/(a*a))
    print(round(math.degrees(math.atan(y/a)), 10))
Problem: p02882
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

A,B,X = map(int, input().split())

x=X/(A*A)
x2=X/A

if(x2>=((A*B)/2)):
    
    
    tmp=(2*A*A*B-2*X)
    tmp2=A*A*A
    print(round(math.degrees(math.atan(tmp/tmp2)),10))
else:
    a2=x2/B
    tmp=(A*B*B)
    tmp2=X
    print(round(math.degrees(math.atan(tmp/tmp2)),10))



Failing test case input:
2 62 2

Expected output:
89.9701895035


Actual output:
89.9850947507


Fixed submission (verdict: Accepted):
import math

A,B,X = map(int, input().split())

x=X/(A*A)
x2=X/A

if(x2>=((A*B)/2)):
    
    
    tmp=(2*A*A*B-2*X)
    tmp2=A*A*A
    print(round(math.degrees(math.atan(tmp/tmp2)),10))
else:
    tmp=(A*B*B)
    tmp2=2*X
    print(round(math.degrees(math.atan(tmp/tmp2)),10))

Problem: p02882
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
s = input().split()
a = int(s[0])
b = int(s[1])
x = int(s[2])

if x <= a*a*b/2:
    y = (2*x)/(a*b)
    print(y)
    print(90-math.degrees(math.atan(y/b)))
else:
   y = 2*b-((2*x)/(a*a))
   print(math.degrees(math.atan(y/a)))

Failing test case input:
34 21 10

Expected output:
89.9235751027


Actual output:
0.028011204481792718
89.92357510266389


Fixed submission (verdict: Accepted):
import math
s = input().split()
a = int(s[0])
b = int(s[1])
x = int(s[2])

if x < a*a*b/2.0:
    y = (2*x)/(a*b)
    print(round(90-math.degrees(math.atan(y/b)), 10))
else:
    y = 2*b-((2*x)/(a*a))
    print(round(math.degrees(math.atan(y/a)), 10))

Problem: p02882
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

A,B,X = map(int, input().split())

x=X/(A*A)
x2=x*A

if(x2>=((A*B)/2)):
    b2=B - (2*x2-A*B)/A
    
    print(math.degrees(math.atan(b2/A)))
else:
    a2=x2/B
    print(math.degrees(math.atan(B/a2)))



Failing test case input:
5 30 14

Expected output:
89.6434975282


Actual output:
89.8217470388398


Fixed submission (verdict: Accepted):
import math

A,B,X = map(int, input().split())

x=X/(A*A)
x2=X/A

if(x2>=((A*B)/2)):
    
    
    tmp=(2*A*A*B-2*X)
    tmp2=A*A*A
    print(round(math.degrees(math.atan(tmp/tmp2)),10))
else:
    tmp=(A*B*B)
    tmp2=2*X
    print(round(math.degrees(math.atan(tmp/tmp2)),10))

Problem: p02882
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

A,B,X = map(int, input().split())

x=X/(A*A)
x2=x*A

if(x2>=((A*B)/2)):
    b2=B - (2*x2-A*B)/A
    
    print(round(math.degrees(math.atan(b2/A)),10))
else:
    a2=x2/B
    print(round(math.degrees(math.atan(B/a2)),10))



Failing test case input:
5 72 14

Expected output:
89.9381064351


Actual output:
89.9690532085


Fixed submission (verdict: Accepted):
import math

A,B,X = map(int, input().split())

x=X/(A*A)
x2=X/A

if(x2>=((A*B)/2)):
    
    
    tmp=(2*A*A*B-2*X)
    tmp2=A*A*A
    print(round(math.degrees(math.atan(tmp/tmp2)),10))
else:
    tmp=(A*B*B)
    tmp2=2*X
    print(round(math.degrees(math.atan(tmp/tmp2)),10))
Problem: p02955
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,k=map(int,input().split())
a=list(map(int,input().split()))
cnt=1
for i in range(2,max(a)+k):
    x=[0]*n
    for j in range(n):
        x[j]=a[j]%i
    s=sum(x)
    l=0
    x.sort(reverse=True)
    for j in range(n):
        if s<=k and l<=k:
            if (s-l)%i==0:
                cnt=i
                break
        l+=i-x[j]
        s-=x[j]

print(cnt)


Failing test case input:
2 4
4 36

Expected output:
40


Actual output:
20


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
a=list(map(int,input().split()))
cnt=1
A=sum(a)
l=[]
for i in range(1,int(A**(1/2))+1):
    if A%i!=0:continue
    l.append(i)
    if  A
        l.append(A 
for i in l:
    x=[0]*n
    for j in range(n):
        x[j]=a[j]%i
    s=sum(x)
    l=0
    x.sort(reverse=True)
    for j in range(n):
        if s<=k and l<=k:
            if (s-l)%i==0:
                if i>cnt:
                    cnt=i
                break
        l+=i-x[j]
        s-=x[j]

print(cnt)
Problem: p02677
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math

INF = 10 ** 9
A,B,H,M = map(int,input().split())

rad_H = 360*H
rad_M = 360*M
diff = abs(rad_H-rad_M)

if diff > 180:
	diff = diff - 180

temp = (A ** 2) + (B ** 2) -(2*A*B*math.cos(math.radians(diff))) 
ans = math.sqrt(temp)

print(ans % INF)

Failing test case input:
2 3 8 1

Expected output:
4.4686055396


Actual output:
5.0


Fixed submission (verdict: Accepted):
import math

INF = 10 ** 9
A,B,H,M = map(int,input().split())

rad_H = (360*H
rad_M = 360*M
diff = abs(rad_H-rad_M)




temp = (A ** 2) + (B ** 2) -(2*A*B*math.cos(math.radians(diff))) 
ans = math.sqrt(temp)

print(ans)

Problem: p02677
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math

def main():
  a, b, h, m = map(int, input().split())
  h_rad = h / 12 * 360
  m_rad = m / 60 * 360
  s = 0
  if h_rad > m_rad:
    s = min(h_rad - m_rad, 360 - h_rad + m_rad)
  else:
    s = min(m_rad - h_rad, 360 - m_rad + h_rad)


  s = math.radians(s)

  print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(s)))


main()


Failing test case input:
14 3 0 90

Expected output:
16.2602881161


Actual output:
17.0


Fixed submission (verdict: Accepted):
import math

def main():
  a, b, h, m = map(int, input().split())
  m_rad = m / 60 * 360
  h_rad = h / 12 * 360 + (m / 60) * (360 
  s = 0
  if h_rad > m_rad:
    s = min(h_rad - m_rad, 360 - h_rad + m_rad)
  else:
    s = min(m_rad - h_rad, 360 - m_rad + h_rad)

  s = math.radians(s)

  print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(s)))


main()
Problem: p03447
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X = int(input())
A = int(input())
B = int(input())
ans = X - A
ans -= (ans / B ) * B
print(ans)

Failing test case input:
579
0
236

Expected output:
107


Actual output:
0.0


Fixed submission (verdict: Accepted):
X = int(input())
A = int(input())
B = int(input())
ans = X - A
ans -= (ans 
print(ans)

Problem: p03447
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X = int(input())
A = int(input())
B = int(input())
ans = X - A
ans -= ans / B
print(ans)

Failing test case input:
579
-1
1190

Expected output:
580


Actual output:
579.5126050420168


Fixed submission (verdict: Accepted):
X = int(input())
A = int(input())
B = int(input())
ans = X - A
ans -= (ans 
print(ans)

Problem: p03447
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X = int(input())
A = int(input())
B = int(input())

X = X - A
X = X - (X%B)*B
print(int(X))

Failing test case input:
7477
375
5

Expected output:
2


Actual output:
7092


Fixed submission (verdict: Accepted):
X = int(input())
A = int(input())
B = int(input())
 
X = X - A
X = X - (X
print(int(X))
Problem: p03347
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
if A[0]:
    print(-1)
    exit()
for i in range(1, N):
    if A[i - 1] < A[i]:
        ans += A[i] - A[i - 1]
    else:
        ans += A[i]
print(ans)


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

Expected output:
-1


Actual output:
7


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(input()) for _ in range(N)]
if A[0]:
    print(-1)
    exit()
ans = 0
dp = A[-1]
for i in range(N - 1, 0, -1):
    if A[i - 1] == A[i] - 1:
        continue
    elif A[i - 1] >= A[i]:
        ans += dp
        dp = A[i - 1]
    else:
        print(-1)
        exit()
print(ans + dp)

Problem: p03347
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input());ans=0
l=[int(input()) for i in range(n)]
if l[0]!=0:
  print(-1);exit
for i in range(n-1):
  if l[i+1]>l[i]+1:
    print(-1);exit
for i in range(1,n):
  if l[i]==l[i-1]+1:
    ans+=1
  else:
    ans+=l[i]
print(ans)

Failing test case input:
3
-8
1
-2

Expected output:
-1


Actual output:
-1
-1
-1


Fixed submission (verdict: Accepted):
n=int(input());ans=0
l=[int(input()) for i in range(n)]
if l[0]!=0:
  print(-1);exit()
for i in range(n-1):
  if l[i+1]>l[i]+1:
    print(-1);exit()
for i in range(1,n):
  if l[i]==l[i-1]+1:
    ans+=1
  else:
    ans+=l[i]
print(ans)

Problem: p03347
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = []
for i in range(n):
    a.append(inn())
if a[0]!=0:
    print(-1)
    exit()
cnt = 0
for i in range(1,n):
    if i==n-1:
        cnt += a[n-1]
    elif a[i]!=a[i-1]+1:
        cnt += a[i-1]
print(cnt)


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

Expected output:
-1


Actual output:
0


Fixed submission (verdict: Accepted):
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True 
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = []
for i in range(n):
    a.append(inn())
    if len(a)>=2 and a[-1]>a[-2]+1:
        print(-1)
        exit()
if a[0]!=0:
    print(-1)
    exit()
cnt = 0
for i in range(1,n):
    if i==n-1:
        cnt += a[n-1]
    if a[i]!=a[i-1]+1:
        cnt += a[i-1]
print(cnt)
Problem: p03347
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = []
for i in range(n):
    temp = int(input())
    a.append(temp)
if a[0] != 0:
    print("-1")
else:
    check = True
    for i in range(n-1):
        if a[i+1] >= a[i] + 2:
            print("-1")
            check = False
    if check:
        ans = sum(a)
        for i in range(n-1):
            if a[i+1] == a[i]+1:
                ans -= a[i]
        print(ans)

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

Expected output:
-1


Actual output:
-1
-1
-1


Fixed submission (verdict: Accepted):
n = int(input())
a = []
for i in range(n):
    temp = int(input())
    a.append(temp)
if a[0] != 0:
    print("-1")
else:
    check = True
    for i in range(n-1):
        if a[i+1] >= a[i] + 2:
            print("-1")
            check = False
            break
    if check:
        ans = sum(a)
        for i in range(n-1):
            if a[i+1] == a[i]+1:
                ans -= a[i]
        print(ans)

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

n = int(input())
a = [int(input()) for i in range(n)]

ans = 0
for i in range(n):
    if i == 0:
        if a[i] != 0:
            ans = -1
            break
    elif a[i] > i:
        ans = -1
        break

    else:

        if a[i] == a[i-1] + 1:
            continue
        else:
            ans += a[i-1]

if ans == -1:
    print(-1)
    sys.exit()

ans += a[n-1]

print(ans)


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

Expected output:
-1


Actual output:
9


Fixed submission (verdict: Accepted):
import sys

n = int(input())
a = [int(input()) for i in range(n)]

ans = 0
for i in range(n):
    if i == 0:
        if a[i] != 0:
            ans = -1
            break
    elif a[i] > i:
        ans = -1
        break

    else:
        if a[i] == a[i-1] + 1:
            continue
        else:
            if a[i] >= a[i-1] + 2:
                ans = -1
                break
            ans += a[i-1]

if ans == -1:
    print(-1)
    sys.exit()

ans += a[n-1]

print(ans)

Problem: p03347
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(input()) for _ in range(N)]
ans, temp = 0, 0
for i in range(N-1, -1, -1):
    if A[i] != 0:
        if A[i] == temp:
            temp -= 1
        elif A[i] < temp:
            print(-1)
            exit()            
        else:
            if i  >= A[i]:
                ans += A[i]
                temp = A[i] - 1
            else:
                print(-1)
                exit()
print(ans)

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

Expected output:
-1


Actual output:
6


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(input()) for _ in range(N)]
ans, temp = 0, 0
for i in range(N-1, -1, -1):
    if A[i] < temp:
        print(-1)
        exit() 
    elif A[i] != 0:
        if A[i] == temp:
            temp -= 1    
        else:
            if i  >= A[i]:
                ans += A[i]
                temp = A[i] - 1
            else:
                print(-1)
                exit()
print(ans)
Problem: p03347
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
A = [int(input()) for i in range(n)]

if A[0] != 0:
    print(-1)
    exit()

ans = 0
for i in reversed(range(1, n)):
    if A[i-1] >= A[i]-1:
        ans += 1
    else:
        ans += A[i]

print(ans)

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

Expected output:
-1


Actual output:
9


Fixed submission (verdict: Accepted):
n = int(input())
A = [int(input()) for i in range(n)]

if A[0] != 0:
    print(-1)
    exit()

for i in range(1, n):
    if A[i] > A[i-1]+1:
        print(-1)
        exit()

ans = 0
for i in reversed(range(1, n)):
    if A[i-1] == A[i]-1:
        ans += 1
    else:
        ans += A[i]

print(ans)

Problem: p03347
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
A=[int(input()) for i in range(N)]
if A[0]!=0:
  print(-1)
  exit()
for i in range(N-1):
  if A[i+1]-A[i]>1:
    print(-1)
    exit()
    
B=A[::-1]
cnt=0
for i in range(1,N):
  if B[i-1]==B[i]:
    cnt+=(B[i]-1)
print(N-A.count(0)+cnt)

Failing test case input:
4
0
1
0
0

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N=int(input())
A=[int(input()) for i in range(N)]
if A[0]!=0:
  print(-1)
  exit()
ans=0
for i in range(N-1):
  if A[i+1]-A[i]>1:
    print(-1)
    exit()
  elif A[i+1]-A[i]==1:
    ans+=1
  else:
    ans+=A[i+1]
print(ans)

Problem: p03347
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
n=int(input())
l=[0]*(n+1)
for i in range(n):
    l[i]=int(input())
    if l[i]>i:print(-1);sys.exit()
for i in range(n-1):
    if l[i]-l[i-1]>=2:print(-1);sys.exit()
ans=0
for i in range(n+1):
    if l[i]<=l[i-1]:
        ans+=l[i-1]
print(ans)


Failing test case input:
4
0
0
0
2

Expected output:
-1


Actual output:
2


Fixed submission (verdict: Accepted):
import sys
n=int(input())
l=[0]*(n+1)
for i in range(n):
    l[i]=int(input())
    if l[i]>i:print(-1);sys.exit()
for i in range(n):
    if l[i]-l[i-1]>=2:print(-1);sys.exit()
ans=0
for i in range(n+1):
    if l[i]<=l[i-1]:
        ans+=l[i-1]
print(ans)

Problem: p03347
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
As = [int(input()) for i in range(N)]

if As[0] != 0:
    print(-1)
    exit()

ans = 0
for i in range(1, N):
    if As[i] > i:
        ans = -1
        break

    if As[i - 1] + 1 == As[i]:
        ans += 1
    else:
        if As[i] != 0 and As[i - 1] == 0:
            ans = -1
            break
        ans += As[i]

print(ans)


Failing test case input:
9
0
1
1
-1
2
1
2
3
0

Expected output:
-1


Actual output:
6


Fixed submission (verdict: Accepted):
N = int(input())
As = [int(input()) for i in range(N)]

if As[0] != 0:
    
    print(-1)
    exit()

ans = 0
for i in reversed(range(1, N)):
    if As[i - 1] + 1 < As[i]:
        
        ans = -1
        break
    elif As[i - 1] + 1 == As[i]:
        
        ans += 1
    else:
        
        ans += As[i]

print(ans)
Problem: p03347
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(input()) for _ in range(N)]
if A[0] != 0:
    print(-1)
    exit()
ans = 0
for i in range(1, N):
    if A[i - 1] < A[i] and abs(A[i] - A[i - 1]) == 1:
        ans += 1
    else:
        ans += A[i]
print(ans)

Failing test case input:
4
0
0
0
2

Expected output:
-1


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(input()) for _ in range(N)]
if 0 < A[0]:
    print(-1)
    exit()
ans = 0
for i in range(1, N):
    if 1 < A[i] - A[i - 1]:
        print(-1)
        exit()
    elif A[i] - A[i - 1] == 1:
        ans += 1
    elif A[i] == A[i - 1]:
        ans += A[i]
    else:
        ans += A[i]
print(ans)

Problem: p03347
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    if A[0] != 0:
        print(-1)
        exit()
    cnt = 0
    for i in range(1,N):
        if A[i] <= A[i-1] + 1:
            cnt += 1
        elif A[i] > A[i-1] + 1:
            cnt += A[i] - A[i-1]

    print(cnt)


if __name__ == "__main__":
    main()

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

Expected output:
-1


Actual output:
9


Fixed submission (verdict: Accepted):
def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]
    if A[0] != 0:
        print(-1)
        exit()
    cnt = A[-1]

    for i in range(N-2,-1,-1):
        if A[i] >= A[i+1]:
            cnt += A[i]
        elif A[i] == A[i+1] - 1:
            continue
        else:
            print(-1)
            exit()

    print(cnt)

if __name__ == "__main__":
    main()

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

ans = 0

L = []
isok = True
for i in range(N):
    n = int(input())
    if n>i: isok = False
    L.append(n)
    

for i in range(N-1):
    if L[i+1] <= L[i]:
        ans += L[i+1]
    elif L[i+1] == L[i]+1:
        ans += 1
    elif L[i+1] > L[i]:
        ans += L[i+1]
    
if isok:
    print(ans)
else:
    print(-1)

Failing test case input:
9
0
1
1
-1
2
1
2
3
-1

Expected output:
-1


Actual output:
5


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

ans = 0

L = []
isok = True
for i in range(N):
    n = int(input())
    if n>i: isok = False
    L.append(n)

for i in range(N-1):
    if L[i+1] <= L[i]:
        ans += L[i+1]
    elif L[i+1] == L[i]+1:
        ans += 1
    elif L[i+1] > L[i]:
        isok=False
        break
    
if isok:
    print(ans)
else:
    print(-1)
Problem: p03347
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
if A[0] != 0:
    print(-1)
    exit()

for i in range(1, N):
    if A[i] - A[i-1] > 1:
        print(-1)
        break

now = A[0]
for i in range(1, N):
    if A[i] == now+1:
        ans += 1
        now = A[i]
    else:
        ans += A[i]
        now = A[i]
print(ans)


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

Expected output:
-1


Actual output:
-1
-1


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
if A[0] != 0:
    print(-1)
    exit()

for i in range(1, N):
    if A[i] - A[i-1] > 1:  
        print(-1)
        exit()

now = A[0]
for i in range(1, N):
    if A[i] == now+1:
        ans += 1
        now = A[i]
    else:
        ans += A[i]
        now = A[i]
print(ans)

Problem: p03347
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(input()) for _ in range(n)]
c = 0
for i in range(n-1):
    if a[i] > i:
        c = -1
        break
    if a[i]+1 != a[i+1]:
        c += a[i]
if c != -1:
    if a[n-1] > n-1:
        c = -1
    else:
        c += a[n-1]
print(c)


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

Expected output:
-1


Actual output:
1


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

Problem: p03347
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

flag = True
for i in range(n - 1):
    if a[i + 1] - a[i] >= 2:
        flag = False
if a[0] != 0:
    flag = False

count = 0
if flag == True:
    for i in range(n - 1):
        if a[i] != 0:
            count = count + 1
        if a[i] >= a[i + 1]:
            count = count + max(0, a[i + 1] - 1)
   
if flag == False:
    print(-1)
else:
    print(count + 1)

Failing test case input:
4
0
1
0
0

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

flag = True
for i in range(n - 1):
    if a[i + 1] - a[i] >= 2:
        flag = False
if a[0] != 0:
    flag = False

count = 0
if flag == True:
    for i in range(n - 1):
        if a[i] != 0:
            count = count + 1
        if a[i] >= a[i + 1]:
            count = count + max(0, a[i + 1] - 1)
   
if flag == False:
    print(-1)
elif a[n - 1] != 0:
    print(count + 1)
else:
    print(count)
Problem: p03347
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):


n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))

ans=0
pos=n
pre=0
b=a[0]
for i in range(n):
    x=a.pop()
    if x==0:
        continue
    elif x>pos-1:
        ans=-1
        break
    else:
        if x==pre-1:
            pre=x
            continue
        else:
            if x>=pre:
                pre=x
                ans+=x
            else:
                ans=-1
                break
    pos-=1
if b>0:
    ans=-1
print(ans)


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

Expected output:
-1


Actual output:
8


Fixed submission (verdict: Accepted):


n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))

ans=0
pos=n
pre=0
b=a[0]
for i in range(n):
    x=a.pop()
    if x==0 and pre<=1:
        continue
    elif x>pos-1:
        ans=-1
        break
    else:
        if x==pre-1:
            pre=x
            continue
        else:
            if x>=pre:
                pre=x
                ans+=x
            else:
                ans=-1
                break
    pos-=1
if b>0:
    ans=-1
print(ans)

Problem: p03347
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(input()) for _ in range(N)]
if A[0] != 0:
    print(-1)
    exit()
ans = 0
for i in range(1, N):
    if A[i - 1] < A[i]:
        ans += (A[i] - A[i - 1])
    else:
        ans += A[i]
print(ans)

Failing test case input:
9
0
1
1
-1
2
1
2
3
-1

Expected output:
-1


Actual output:
6


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(input()) for _ in range(N)]
if 0 < A[0]:
    print(-1)
    exit()
ans = 0
for i in range(1, N):
    if 1 < A[i] - A[i - 1]:
        print(-1)
        exit()
    elif A[i] - A[i - 1] == 1:
        ans += 1
    elif A[i] == A[i - 1]:
        ans += A[i]
    else:
        ans += A[i]
print(ans)

Problem: p03347
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
ans = 0
prior = 0
for i in range(N):
  a = int(input())
  if a == 0:
    prior = a
  elif a == 1:
    prior = a
    ans += 1
  elif a == prior + 1:
    ans += 1
    prior = a
  elif a == prior:
    ans += a
    prior = a
  else:
    ans = -1
    break
print(ans)

Failing test case input:
4
1
0
1
2

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
ans = 0
prior = 0
for i in range(N):
  a = int(input())
  if i == 0 and a != 0:
    ans = -1
    break
  if a == 0:
    prior = a
  elif a == 1:
    prior = a
    ans += 1
  elif a == prior + 1:
    ans += 1
    prior = a
  elif a <= prior:
    ans += a
    prior = a
  else:
    ans = -1
    break
print(ans)