ZhenlongDai/ACPR huggingface dataset:
Problem: p02939
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
def main():
    S = input()
    N = len(S)
    from collections import deque
    cur = deque([S[:2]])
    ans2 = 1
    i = 2
    plus = 1
    while i < N:
        if i+plus > N:
            ans2 = -1
            break
        if S[i:i+plus] in cur:
            plus += 1
        else:
            cur.pop()
            cur.append(S[i:i+plus])
            i = i+plus
            plus = 1
            ans2 += 1

    print(ans2)


if __name__ == '__main__':
    main()


Failing test case input:
a`a`_`

Expected output:
6


Actual output:
5


Fixed submission (verdict: Accepted):
def main():
    S = input()
    N = len(S)
    pre = ''
    i = 0
    plus = 1
    ans = 0
    while i < N:
        if pre != S[i:i+plus]:
            ans += 1
            pre = S[i:i+plus]
            i = i+plus
            plus = 1
        else:
            plus += 1
            if i + plus > N:
                break
    print(ans)


if __name__ == '__main__':
    main()

Problem: p02939
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
S = input()
N = len(S)

ans_l = 0
idx = 0
tmp = S[0]
while idx < N:
    for i in range(N-1):
        if i + idx > N-1:
            break
        if tmp != S[idx:idx+i+1]:
            ans_l += 1
            tmp = S[idx:idx+i+1]
            break
    idx += (i+1)

print(ans_l)



Failing test case input:
b`c`bbbbc`baba`

Expected output:
14


Actual output:
13


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

ans_l = 1
idx = 1
tmp = S[0]
while idx < N:
    for i in range(N-1):
        if tmp != S[idx:idx+i+1]:
            ans_l += 1
            tmp = S[idx:idx+i+1]
            break
        if i + idx == N-1:
            break
    idx += (i+1)

print(ans_l)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
s_len = len(s)
check = s[0]
s = s+"1"
ind = 0
ans = 1
for i in range(1,s_len):
    if check == s[ind+1]:
        check = s[ind+1:ind+3]
        ind += 1
    else:
        check = s[ind+1]
    ind += 1
    ans += 1
    if ind >= s_len-1:
        break
if s[s_len-1] == s[s_len-2]:
    ans -= 1
print(ans)

Failing test case input:
`bbac``abbaabbb

Expected output:
11


Actual output:
10


Fixed submission (verdict: Accepted):
s = input()
s_len = len(s)
check = s[0]
if s_len == 2 and s[0] != s[1]:
    print(2)
    exit()
s = s+"1"
ind = 0
ans = 1
for i in range(1,s_len):
    if check == s[ind+1]:
       check = s[ind+1:ind+3]
       ind += 1
    else:
       check = s[ind+1]
    ind += 1
    ans += 1
    if ind >= s_len-1:
        break
if ind == s_len and s[s_len-1] == s[s_len-2]:
    ans -= 1
print(ans)
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input()
k=0
s=''
ex_s=''
pos=0

for i in range(len(S)):
  print(i)
  if pos > i:
    
    continue
  if pos > len(S):
    break
    
  for j in range(1,len(S)-i+1):    
    s=S[i:i+j]    
    print(i,j)
    if ex_s==s:
      
      continue
    else:
      
      if   len(s)==2 and i+j+2==len(S):
        continue
      ex_s=s
      k += 1
      pos = i+j
      print(s,i,j,'ok')
      break;

print(k)
  

Failing test case input:
`^b``^

Expected output:
5


Actual output:
0
0 1
` 0 1 ok
1
1 1
^ 1 1 ok
2
2 1
b 2 1 ok
3
3 1
` 3 1 ok
4
4 1
4 2
`^ 4 2 ok
5
5


Fixed submission (verdict: Accepted):
S=input()
k=0
s=''
ex_s=''
pos=0

for i in range(len(S)):
  
  if pos > i:
    
    continue
  if pos >= len(S):
    break
    
  for j in range(1,len(S)-i+1):    
    s=S[i:i+j]    
    
    if ex_s==s:
      
      continue
    else:
      
      if   len(s)==2 and i+j+2==len(S) and s==S[-2:]:
        continue
      ex_s=s
      k += 1
      pos = i+j
      
      break;

print(k)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    S = input()
    buf = S[0]
    num = 1
    N = len(S)
    for i in range(1, N):
        if buf != S[i]:
            num += 1
            buf = S[i]
        else:
            if i == N-1:
                num += 1
            buf = buf + S[i]
    print(num)
main()

Failing test case input:
bbabaabacaccbaa

Expected output:
11


Actual output:
12


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

    N = len(S)
    ans = 1

    i = 1
    chars = ''
    buf = S[0]
    while i < N:
        chars += S[i]
        if buf == chars:
            pass
        else:
            ans += 1
            buf = chars
            chars = ''
        i += 1
    print(ans)
main()

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
l=len(s)
c=0
x=0
while x<l-1:
  if s[x]==s[x+1]:
    if x==l-2:
      c+=1
      x+=3
    else:
      c+=2
      x+=3
  else:
    if x==l-2:
      c+=2
      x+=2
    else:
      c+=1
      x+=1
print(c)

Failing test case input:
a`aa_`

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
s=input()
l=len(s)
c=0
x=0
while x<l-1:
  if s[x]==s[x+1]:
    if x==l-2:
      c+=1
      x+=2
    else:
      c+=2
      x+=3
  else:
    if x==l-2:
      c+=2
      x+=2
    else:
      c+=1
      x+=1
if l==1:
  c=1
if x==l-1:
  c+=1
print(c)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
if len(s)<=2:
    print(len(set(list(s))));exit()
dp=[0]*(len(s)+ 1)
dp[0]=1
dp[1]=1
dp[2]=(len(set(list(s[:2]))))

for i in range(3,1+len(s)):
    dp[i]=(dp[i-1]+1) if s[i-1]!=s[i-2]else (dp[i-3]+2)
print(dp[-1])

Failing test case input:
a``a``

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):
s=input()
if len(s)<=2:
    print(len(set(list(s))));exit()
dp=[0]*(len(s)+ 1)
dp[0]=0
dp[1]=1
dp[2]=(len(set(list(s[:2]))))

for i in range(3,1+len(s)):
    dp[i]=(dp[i-1]+1) if s[i-1]!=s[i-2]else (dp[i-3]+2)
print(dp[-1])
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
def S(): return stdin.readline().rstrip()

s = S()
ls = list(s)
l = []

tmp = ''
for i in ls:
    if len(l)<1:
        l.append(i)
    else:
        tmp += i
        if tmp != l[len(l)-1]:
            l.append(tmp)
            tmp = ''
        else:
            if i == ls[len(l)-1]:
                a = l.pop()
                l.append(a+tmp)

print(len(l))

Failing test case input:
bbbbacbba`cbbba

Expected output:
12


Actual output:
11


Fixed submission (verdict: Accepted):
from sys import stdin
def S(): return stdin.readline().rstrip()

s = S()
ls = list(s)
l = []

tmp = ''
k = 0
for i in ls:
    k += 1
    if len(l)<1:
        l.append(i)
    else:
        tmp += i
        if tmp != l[len(l)-1]:
            l.append(tmp)
            tmp = ''
        else:
            if k == len(ls):
                a = l.pop()
                tmp = a+tmp
                l.append(tmp)

print(len(l))

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(input())

g = []

g.append(0)
g.append(1)
if len(s) > 1:
    if s[1] == s[2]:
        g.append(1)
    else:
        g.append(2)

    for i in range(3,len(s)+1):
        if s[i-1] != s[i-2]:
            g.append(g[i-1]+1)
        else:
            g.append(g[i-3]+2)

print(g[len(s)])

Failing test case input:
abbbb`acbcabbbb

Expected output:
13


Actual output:
12


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

g = []

g.append(0)
g.append(1)
if len(s) > 1:
    if s[0] == s[1]:
        g.append(1)
    else:
        g.append(2)

    for i in range(3,len(s)+1):
        if s[i-1] != s[i-2]:
            g.append(g[i-1]+1)
        else:
            g.append(g[i-3]+2)

print(g[len(s)])

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
str = input()
li = list(str)

tmp = ''
cnt = 0

for i in li:
  if tmp==i:
    tmp += i  
  else:
    tmp = i
    cnt += 1

print(cnt)

Failing test case input:
bbbbacbba`cbbba

Expected output:
12


Actual output:
11


Fixed submission (verdict: Accepted):
str = input()
li = list(str)

tmp = ''
pre = ''
cnt = 0

for i in li:
  tmp+=i

  if pre!=tmp:
    cnt+=1
    pre=tmp
    tmp=''

print(cnt)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
t = len(s) - 1
c = 0

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

print(c + 2)


Failing test case input:
`_`c_`

Expected output:
6


Actual output:
7


Fixed submission (verdict: Accepted):
s = input()
t = [0, 1]

for i in range(len(s) - 1):
    i += 2
    if s[t[-2] : t[-1]] != s[t[-1] : i]:
        t.append(i)

a = len(t) - 1

print(a)
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(input())
if len(s) == 1:
    print(1)
    exit()
elif len(s) == 2:
    if s[0] == s[1]:
        print(1)
    else:
        print(2)
    exit()
else:
    dp = [0]*len(s)
    dp[0] = 1
    if s[0]==s[1]:
        dp[1]=dp[0]
    else:
        dp[1]=dp[0]+1
    if s[1]==s[2]:
        dp[2]=dp[1]
    else:
        dp[2]=dp[1]+1

for i in range(3, len(s)):
    if s[i] != s[i-1]:
        dp[i] += dp[i-1]+1
    else:
        dp[i] += dp[i-3]+2

print(dp[-1])

Failing test case input:
bbb`abba``cabb`

Expected output:
11


Actual output:
10


Fixed submission (verdict: Accepted):
s = list(input())
if len(s) == 1:
    print(1)
    exit()
elif len(s) == 2:
    if s[0] == s[1]:
        print(1)
    else:
        print(2)
    exit()
else:
    dp = [0]*len(s)
    if s[0]==s[1] and s[1]==s[2]:
        dp[0:3]=[1,1,2]
    elif s[0]==s[1] and s[1]!=s[2]:
        dp[0:3]=[1,1,2]
    elif s[0]!=s[1] and s[1]==s[2]:
        dp[0:3]=[1,2,2]
    else:
        dp[0:3]=[1,2,3]

for i in range(3, len(s)):
    if s[i] != s[i-1]:
        dp[i] += dp[i-1]+1
    else:
        dp[i] += dp[i-3]+2

print(dp[-1])

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
l=len(s)
c=0
x=0
while x<l-1:
  if s[x]==s[x+1]:
    if x==l-2:
      c+=1
      x+=3
    else:
      c+=2
      x+=3
  else:
    if x==l-2:
      c+=2
      x+=2
    else:
      c+=1
      x+=1
if l==1:
  c=1
print(c)

Failing test case input:
b`aa`a

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
s=input()
l=len(s)
c=0
x=0
while x<l-1:
  if s[x]==s[x+1]:
    if x==l-2:
      c+=1
      x+=2
    else:
      c+=2
      x+=3
  else:
    if x==l-2:
      c+=2
      x+=2
    else:
      c+=1
      x+=1
if l==1:
  c=1
if x==l-1:
  c+=1
print(c)

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
k_list = []
cnt = 0
one = ""

for i in s:
  if len(k_list) == 0:
    k_list.append(i)
    cnt += 1
  elif k_list[cnt-1] == i:
    one += i
    pass
  else:
    k_list.append(one + i)
    one = ""
    cnt += 1
  
print(len(k_list))

Failing test case input:
b`aaaa

Expected output:
5


Actual output:
3


Fixed submission (verdict: Accepted):
s = input()
k_list = []
cnt = 0
one = ""

for i in s:
  if len(k_list) == 0:
    k_list.append(i)
    cnt += 1
  elif k_list[cnt-1] == one + i:
    one += i
    pass
  else:
    k_list.append(one + i)
    one = ""
    cnt += 1
  
print(len(k_list))

Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S=input()
tmp=S[0]
i=1
ans=1
while i<len(S):
    
    if S[i]!=tmp:
        ans+=1
        tmp=S[i]
        i+=1
    else:
        ans+=1
        tmp=S[i:i+2]
        i+=2
if S[-2]==S[-1] and tmp!=S[-2:]:
    ans-=1
print(ans)

Failing test case input:
a`bbaa

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
S=input()
tmp=S[0]
i=1
ans=1
while i<len(S)-1:
    
    if S[i]!=tmp:
        ans+=1
        tmp=S[i]
        i+=1
    else:
        ans+=1
        tmp=S[i:i+2]
        i+=2
if i>=len(S):
    print(ans)
elif tmp==S[i]:
    print(ans)
else:
    print(ans+1)
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()

if(len(s) <= 2):
    print(len(set(list(s))))
    exit()
dp = [0 for _ in range(len(s))]
dp[0] = 1
for i in range(1,len(s)):
    if(s[i] != s[i-1]):dp[i] = dp[i-1] + 1
    else:
        if(i >= 3):dp[i] = dp[i-3] + 2
        else:dp[i] = dp[i-1]
print(dp[-1])

Failing test case input:
```b^^

Expected output:
4


Actual output:
3


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

if(len(s) <= 2):
    print(len(set(list(s))))
    exit()
dp = [0 for _ in range(len(s)+1)]
dp[0] = 0
dp[1] = 1
dp[2] = len(set(list(s[:2])))
for i in range(3,len(s)+1):
    if(s[i-1] != s[i-2]):dp[i] = dp[i-1] + 1
    else:dp[i] = dp[i-3] + 2
print(dp[-1])

Problem: p02939
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s=list(input())
c=1
i=1
f=1
w=[s[0]]
while i<len(s)-1:
    if s[i]==s[i-1] and f:
        w.append(s[i]+s[i+1])
        i+=1
        c+=1
        i+=1
        f=0
    else:
        w.append(s[i])
        f=1
        c+=1
        i+=1
if s[-1]!=w[-1]:
    w.append(s[-1])
print(len(w))


Failing test case input:
bbb`abba``cabb`

Expected output:
11


Actual output:
12


Fixed submission (verdict: Accepted):
s=list(input())
i=1
f=1
w=[s[0]]
while i<len(s)-1:
    if s[i]==s[i-1] and f:
        w.append(s[i]+s[i+1])
        i+=1
        i+=1
        f=0
    else:
        w.append(s[i])
        f=1
        i+=1
if s[-1]!=w[-1] and i<len(s):
    w.append(s[-1])
print(len(w))

Problem: p02939
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
txt=input()
N=len(txt)
see=0
count=1


now=1
while(see+now<N):

  if(now==2):
    now=1
 
  elif(txt[see+1]==txt[see]):
    now=2
 
  else:
    now=1
  count=count+1
  see=see+now
if (now==2):
  if(see+now>N and txt[-1]==txt[-2]):
    count=count-1
print(count)

Failing test case input:
c`aaaa

Expected output:
5


Actual output:
4


Fixed submission (verdict: Accepted):
txt=input()
N=len(txt)
see=0
count=1


now=1
while(see<N-1):

  if(now==2):
    now=1
 
  elif(txt[see+1]==txt[see]):
    now=2
 
  else:
    now=1
  count=count+1
  see=see+now
if (now==2):
  if(see==N and txt[-1]==txt[-2]):
    count=count-1
print(count)

Problem: p02939
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = list(input())
i = len(s)
p = 0
while i >= 3:
    if s[i-1] == s[i-2]:
        i -= 3
        p += 2
    else:
        i -= 1
        p += 1

if i == 0:
    print(p)
else:
    print(p+1)

Failing test case input:
b`c`bbbbc`baba`

Expected output:
14


Actual output:
13


Fixed submission (verdict: Accepted):
s = list(input())
i = len(s)
p = 0
while i >= 3:
    if s[i-1] == s[i-2]:
        i -= 3
        p += 2
    else:
        i -= 1
        p += 1

if i <= 1:
    print(p+i)
else:
    if s[i-1] == s[i-2]:
        print(p+1)
    else:
        print(p+2)
Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin

s = stdin.readline().rstrip()
N = len(s)

if N == 1:
    print(1)
    exit()
elif N == 2:
    if s[0] == s[1]:
        print(1)
        exit()
    else:
        print(2)
        exit()

dp = [0]*(N+1)

if s[0] == s[1]:
    dp[1] = 0
    dp[2] = 1
else:
    dp[1] = 1
    dp[2] = 2

for i in range(2,N):
    if s[i] == s[i-1]:
        dp[i+1] = dp[i-2] + 2
    else:
        dp[i+1] = dp[i] + 1

print(dp[N])

Failing test case input:
bbbbacbaa`cbbba

Expected output:
12


Actual output:
11


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

s = stdin.readline().rstrip()
N = len(s)

if N == 1:
    print(1)
    exit()
elif N == 2:
    if s[0] == s[1]:
        print(1)
        exit()
    else:
        print(2)
        exit()

dp = [0]*N
dp[0] = 1
if s[0] == s[1]:
    dp[1] = 1
else:
    dp[1] = 2
for i in range(2,N):
    if s[i] == s[i-1]:
        dp[i] = dp[i-3] + 2
    else:
        dp[i] = dp[i-1] + 1

print(dp[N-1])

Problem: p02939
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
si = s[0]
ans = 1
for i in range(len(s)):
    if s[i] != si:
        ans += 1
        si = s[i]
    else:
        si = s[i:i + 2]
print(ans)

Failing test case input:
``cbbaccc`babb_

Expected output:
11


Actual output:
12


Fixed submission (verdict: Accepted):
s = input()
ans = 0

si = ''
now = ''

for i in s:
    now += i
    if si != now:
        ans += 1
        si = now
        now = ''

print(ans)

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


def count_substrings(first_substring):

	arr = [first_substring]
	i = len(first_substring)

	while i < len(S):
		s = S[i]
	
		if s == arr[-1]:
			if i + 1 < len(S):
				i += 1
				s += S[i]
			else:
				arr[-1] += s
				break
	
		arr.append(s)
		i += 1

	ans = len(arr)

	if arr[-1] == arr[-2]:
		ans -= 1	

	return ans


S = input()

ans1 = count_substrings(S[:1])
ans2 = count_substrings(S[:2])

print(max(ans1, ans2))

Failing test case input:
aaa``b

Expected output:
4


Actual output:
5


Fixed submission (verdict: Accepted):

def count_substrings(first_substring):

	arr = [first_substring]
	i = len(first_substring)

	while i < len(S):
		s = S[i]
	
		if s == arr[-1]:
			if i + 1 < len(S):
				i += 1
				s += S[i]
			else:
				arr[-1] += s
				break
	
		arr.append(s)
		i += 1

	return len(arr)


S = input()

ans1 = count_substrings(S[:1])
ans2 = count_substrings(S[:2])

print(max(ans1, ans2))
Problem: p02846
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

a, b, ans = 0, 0, 0
n1 = (A1-B1)*T1
n2 = n1 + (A2-B2)*T2
if n2 == 0:
  print('infinity')
elif n1*n2 < 0:
  ans += abs(n1) 
  print(2*ans+1)
else:
  print(0)

Failing test case input:
30901 15700
2647944172 11366428589
5864465524 4464634034

Expected output:
23


Actual output:
198787452596305


Fixed submission (verdict: Accepted):
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

a, b, ans = 0, 0, 0
n1 = (A1-B1)*T1
n2 = n1 + (A2-B2)*T2
if n2 == 0:
  print('infinity')
elif n1*n2 < 0:
  ans += 2 * (abs(n1)
  if abs(n1)%abs(n2) > 0:
    ans += 1
  print(ans)
else:
  print(0)

Problem: p02846
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
T1,T2 = map(int, input().split())
A1,A2 = map(int, input().split())
B1,B2 = map(int, input().split())

d1 = A1 - B1
d2 = A2 - B2
if d1*T1 + d2*T2 == 0: print("infinity")
elif abs(d1*T1) > abs(d2*T2): print(0)
else: print(1)

Failing test case input:
15726 13168
4972022622 14054634373
777243341 4464634034

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
T1,T2 = map(int, input().split())
A1,A2 = map(int, input().split())
B1,B2 = map(int, input().split())
d1,d2 = (A1-B1)*T1,(A2-B2)*T2
if d1 < 0: d1,d2 = -d1,-d2
if d1+d2 == 0: print("infinity")
elif d1+d2>0: print(0)
elif d1 % (-(d1+d2)) == 0: print(d1
else: print(d1

Problem: p02846
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

P = (A1 - B1) * T1
Q = (A2 - B2) * T2

if P + Q < 0:
    print(0)
elif P + Q == 0:
    print('infinity')
else:
    S, T = divmod(-P, P+Q)
    if T != 0:
        print(S * 2 + 1)
    else:
        print(S * 2)


Failing test case input:
15726 6815
7256311188 12527402928
404901817 3680927238

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

P = (A1 - B1) * T1
Q = (A2 - B2) * T2

if P > 0:
    P *= -1
    Q *= -1

if P + Q < 0:
    print(0)
elif P + Q == 0:
    print('infinity')
else:
    S, T = divmod(-P, P+Q)
    if T != 0:
        print(S * 2 + 1)
    else:
        print(S * 2)

Problem: p02846
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
t1, t2, a1, a2, b1, b2 = [int(_) for _ in open(0).read().split()]
c1 = (b1 - a1) * t1
c2 = c1 + (b2 - a2) * t2
if c1 * c2 > 0:
    print(0)
    exit()
if c2 == 0:
    print('infinity')
    exit()
ans = 2 * math.ceil(abs(c1) / abs(c2)) - 1 - (abs(c1) % abs(c2) == 0)
print(ans)


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

Expected output:
0


Actual output:
-2


Fixed submission (verdict: Accepted):
import math
t1, t2, a1, a2, b1, b2 = [int(_) for _ in open(0).read().split()]
c1 = (b1 - a1) * t1
c2 = c1 + (b2 - a2) * t2
if c1 * c2 > 0:
    print(0)
    exit()
if c2 == 0:
    print('infinity')
    exit()
if c1 < 0:
    c1 *= -1
    c2 *= -1
ans = 2 * (c1 
print(ans)
Problem: p02846
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

T1, T2 = list(map(int, input().split()))
A1, A2 = list(map(int, input().split()))
B1, B2 = list(map(int, input().split()))


L1 = T1 * (A1- B1)
L2 = L1 + T2 * (A2- B2)

if L1 * L2 > 0:
    print(0)
elif L2 == 0:
    print("infinity")
else:
    M = (-L1) / L2
    ans = 2 * M + 1
    if float(int(M)) == M:
        ans -= 1
    print(ans)



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

Expected output:
0


Actual output:
0.0


Fixed submission (verdict: Accepted):

T1, T2 = list(map(int, input().split()))
A1, A2 = list(map(int, input().split()))
B1, B2 = list(map(int, input().split()))


L1 = T1 * (A1- B1)
L2 = L1 + T2 * (A2- B2)

if L1 * L2 > 0:
    print(0)
elif L2 == 0:
    print("infinity")
else:
    M = (-L1) / L2
    ans = 2 * int(M) + 1
    if float(int(M)) == M:
        ans -= 1
    print(ans)

Problem: p02846
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())

p=(a1-b1)*t1
q=(a2-b2)*t2
if p+q<0:
  print(0)
elif p+q==0:
  print('infinity')
else:
  s,t=divmod(-p,p+q)
  if t!=0:
    print(s*2+1)
  else:
    print(s*2)

Failing test case input:
15726 13168
2647944172 11366428589
777243341 4464634034

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())

p=(a1-b1)*t1
q=(a2-b2)*t2
if p>0:
  p*=-1
  q*=-1

if p+q<0:
  print(0)
elif p+q==0:
  print('infinity')
else:
  s,t=divmod(-p,p+q)
  if t!=0:
    print(s*2+1)
  else:
    print(s*2)

Problem: p02846
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
mid = (A1 - B1) * T1
end = mid + (A2 - B2) * T2
if end == 0:
	print("infinity")
elif mid*end > 0:
	print(0)
else:
	print(1-2*int(mid/end))

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

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
mid = (A1 - B1) * T1
end = mid + (A2 - B2) * T2
if end == 0:
	print("infinity")
elif mid*end > 0:
	print(0)
else:
	if mid % end == 0:
		print(-2*(int(mid/end)))
	else:
		print(1-2*(int(mid/end)))

Problem: p02846
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
t1, t2, a1, a2, b1, b2 = [int(_) for _ in open(0).read().split()]
c1 = (b1 - a1) * t1
c2 = c1 + (b2 - a2) * t2
if c1 * c2 > 0:
    print(0)
    exit()
if c2 == 0:
    print('infinity')
    exit()
if c1 < 0:
    c1 *= -1
    c2 *= -1
ans = 2 * math.ceil(c1 / (-c2)) - 1 - (c1 % c2 == 0)
print(ans)


Failing test case input:
1 1
1 17
12 5

Expected output:
22


Actual output:
20


Fixed submission (verdict: Accepted):
import math
t1, t2, a1, a2, b1, b2 = [int(_) for _ in open(0).read().split()]
c1 = (b1 - a1) * t1
c2 = c1 + (b2 - a2) * t2
if c1 * c2 > 0:
    print(0)
    exit()
if c2 == 0:
    print('infinity')
    exit()
if c1 < 0:
    c1 *= -1
    c2 *= -1
ans = 2 * (c1 
print(ans)
Problem: p02384
Buggy submission (Python3, verdict: Wrong Answer):
pattern = {
           "12651":3,
           "15621":4,
           "13641":5,
           "14631":2,
           "23542":1,
           "24532":6,
          }

label = input().split()
l2d = {label[i]:str(i+1) for i in range(6)}
print(l2d)

qn = int(input())
for i in range(qn):
    top, front = input().split()
    tf = l2d[top]+l2d[front]

    for p in pattern:
        if tf in p:
            print(label[pattern[p]-1])

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

Expected output:
6
5
4


Actual output:
{'1': '1', '2': '2', '3': '3', '4': '4', '5': '5', '6': '6'}
6
5
4


Fixed submission (verdict: Accepted):
pattern = {
           "12651":3,
           "15621":4,
           "13641":5,
           "14631":2,
           "23542":1,
           "24532":6,
          }

label = input().split()
l2d = {label[i]:str(i+1) for i in range(6)}

qn = int(input())
for i in range(qn):
    top, front = input().split()
    tf = l2d[top]+l2d[front]

    for p in pattern:
        if tf in p:
            print(label[pattern[p]-1])

Problem: p02384
Buggy submission (Python3, verdict: Wrong Answer):
label = input().split()

right = {
           "12651":3,
           "15621":4,
           "13641":5,
           "14631":2,
           "23542":1,
           "24532":6,
           }

q = int(input())
for i in range(q):
    s = input().split()
    s = ''.join(s)
    for pattern in right:
        if s in pattern:
            print(label[right[pattern]-1])

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

Expected output:
8
2


Actual output:
8


Fixed submission (verdict: Accepted):
pattern = {
           "12651":3,
           "15621":4,
           "13641":5,
           "14631":2,
           "23542":1,
           "24532":6,
          }

label = input().split()
l2d = {label[i]:str(i+1) for i in range(6)}

qn = int(input())
for i in range(qn):
    top, front = input().split()
    tf = l2d[top]+l2d[front]

    for p in pattern:
        if tf in p:
            print(label[pattern[p]-1])
Problem: p02384
Buggy submission (Python3, verdict: Wrong Answer):



class Dice() :
    rightlist = ((-1,3,1,4,2,-1),
                 (2,-1,5,0,-1,3),
                 (4,0,-1,-1,5,2),
                 (1,5,-1,-1,0,4),
                 (3,-1,0,5,-1,2),
                 (-1,2,4,1,3,-1))

    def __init__(self, data):
        self.label = data

    def get_up(self):
        return self.label[0]

    def get_rightdata(self, up, front):
        upidx = self.label.index(up);
        fridx = self.label.index(front)
        return self.label[self.rightlist[fridx][upidx]]


dicedata = input().split()
count = int(input())
queslist = []
[queslist.append(input().split()) for i in range(count)]

newdice = Dice(dicedata)

[print(newdice.get_rightdata(queslist[i][0], queslist[i][1])) for i in range(count)]





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

Expected output:
2
5
6


Actual output:
3
5
6


Fixed submission (verdict: Accepted):



class Dice() :
    rightlist = ((-1,3,1,4,2,-1),
                 (2,-1,5,0,-1,3),
                 (4,0,-1,-1,5,1),
                 (1,5,-1,-1,0,4),
                 (3,-1,0,5,-1,2),
                 (-1,2,4,1,3,-1))

    def __init__(self, data):
        self.label = data

    def get_up(self):
        return self.label[0]

    def get_rightdata(self, up, front):
        upidx = self.label.index(up);
        fridx = self.label.index(front)
        return self.label[self.rightlist[fridx][upidx]]


dicedata = input().split()
count = int(input())
queslist = []
[queslist.append(input().split()) for i in range(count)]

newdice = Dice(dicedata)

[print(newdice.get_rightdata(queslist[i][0], queslist[i][1])) for i in range(count)]

Problem: p02384
Buggy submission (Python3, verdict: Wrong Answer):
d=input().split()
for _ in range(int(input())):
 t,f=[d.index(s) for s in input().split()]
 n={0:(1,2,4,3,1),1:(0,3,5,2,0),2:(0,1,5,4,0),3:(1,0,4,5,1),4:(0,2,5,3,0),5:(1,3,4,2,1)}[int(t)]
 print(n[n.index(int(f))+1]+1)

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

Expected output:
7
1
7


Actual output:
4
1
4


Fixed submission (verdict: Accepted):
d=input().split()
for _ in range(int(input())):
 t,f=[d.index(s) for s in input().split()]
 n={0:(1,2,4,3,1),1:(0,3,5,2,0),2:(0,1,5,4,0),3:(1,0,4,5,1),4:(0,2,5,3,0),5:(1,3,4,2,1)}[int(t)]
 print(d[n[n.index(int(f))+1]])
Problem: p02384
Buggy submission (Python3, verdict: Wrong Answer):
axis_1 = '0154' * 2  
axis_2 = '0253' * 2  
axis_3 = '3124' * 2  

right = [axis_3, axis_2[::2], axis_1, axis_1[::-1], axis_2, axis_3[::-1], ]
a = list(map(int, input().split()))
n = int(input())
for _ in range(n):
    top, front = map(a.index, map(int, input().split()))
    x = '%d%d' % (top, front)
    for i, axis in enumerate(right):
        if x in axis:
            print(a[i])

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

Expected output:
14
2
6


Actual output:
14
6


Fixed submission (verdict: Accepted):
axis_1 = '0154' * 2  
axis_2 = '0253' * 2  
axis_3 = '3124' * 2  

right = [axis_3, axis_2[::-1], axis_1, axis_1[::-1], axis_2, axis_3[::-1], ]
a = list(map(int, input().split()))
n = int(input())
for _ in range(n):
    top, front = map(a.index, map(int, input().split()))
    x = '%d%d' % (top, front)
    for i, axis in enumerate(right):
        if x in axis:
            print(a[i])
            break
    else:
        print('------------------')
        print(x)

Problem: p02384
Buggy submission (Python3, verdict: Wrong Answer):
class Dice:
    def __init__(self, num_list):
        self.faces = num_list

    def find_rf(self, top, front):
        tf = str(self.faces.index(top)) + str(self.faces.index(front))
        if tf in '12431':
            return self.faces[0]
        elif tf in '03520':
            return self.faces[1]
        elif tf in '01540':
            return self.faces[2]
        elif tf in '04519':
            return self.faces[3]
        elif tf in '02530':
            return self.faces[4]
        else:
            return self.faces[5]

num_list = tuple(map(int, input().split()))

dice = Dice(num_list)

q = int(input())

for i in range(q):
    top, front = map(int, input().split())
    right_face = dice.find_rf(top, front)
    print(right_face)

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

Expected output:
4
2


Actual output:
6
2


Fixed submission (verdict: Accepted):
class Dice:
    def __init__(self, num_list):
        self.faces = num_list

    def find_rf(self, top, front):
        tf = str(self.faces.index(top)) + str(self.faces.index(front))
        if tf in '12431':
            return self.faces[0]
        elif tf in '03520':
            return self.faces[1]
        elif tf in '01540':
            return self.faces[2]
        elif tf in '04510':
            return self.faces[3]
        elif tf in '02530':
            return self.faces[4]
        else:
            return self.faces[5]

num_list = tuple(map(int, input().split()))

dice = Dice(num_list)

q = int(input())

for i in range(q):
    top, front = map(int, input().split())
    right_face = dice.find_rf(top, front)
    print(right_face)
Problem: p02384
Buggy submission (Python3, verdict: Wrong Answer):
class Dice:
    def __init__(self, num_list):
        self.faces = num_list

    def find_rf(self, top, front):
        tf = str(self.faces.index(top)) + str(self.faces.index(front))
        if tf in '12431':
            return 1
        elif tf in '03520':
            return 2
        elif tf in '01540':
            return 3
        elif tf in '04519':
            return 4
        elif tf in '02530':
            return 5
        else:
            return 6

num_list = tuple(map(int, input().split()))

dice = Dice(num_list)

q = int(input())

for i in range(q):
    top, front = map(int, input().split())
    right_face = dice.find_rf(top, front)
    print(right_face)

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

Expected output:
9
9


Actual output:
5
5


Fixed submission (verdict: Accepted):
class Dice:
    def __init__(self, num_list):
        self.faces = num_list

    def find_rf(self, top, front):
        tf = str(self.faces.index(top)) + str(self.faces.index(front))
        if tf in '12431':
            return self.faces[0]
        elif tf in '03520':
            return self.faces[1]
        elif tf in '01540':
            return self.faces[2]
        elif tf in '04510':
            return self.faces[3]
        elif tf in '02530':
            return self.faces[4]
        else:
            return self.faces[5]

num_list = tuple(map(int, input().split()))

dice = Dice(num_list)

q = int(input())

for i in range(q):
    top, front = map(int, input().split())
    right_face = dice.find_rf(top, front)
    print(right_face)
Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
sumA = 0
for x in range(N):
    if x == 0:
        sumA += 0
    elif x == 1:
        sumA += A[0]
    elif x == 2:
        sumA += A[1]
    else:
        sumA += A[x - 2]
print(sumA)


Failing test case input:
7
-1 101 -2 1 -1 0 12

Expected output:
127


Actual output:
125


Fixed submission (verdict: Accepted):
N = int(input())
A = sorted(list(map(int, input().split())), reverse=True)
sumA = 0
for x in range(N):
    if x == 0:
        sumA += 0
    elif x == 1:
        sumA += A[0]
    else:
        div, mod = divmod(x - 1, 2)
        sumA += A[div + mod]
print(sumA)

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
que = [x*-1 for x in list(map(int,input().split()))]

import heapq
heapq.heapify(que)

ans = 0
for _ in range(n-1):
  ans += heapq.heappop(que)*-1

print(ans)

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

Expected output:
6


Actual output:
5


Fixed submission (verdict: Accepted):
n = int(input())
que = [x*-1 for x in list(map(int,input().split()))]

que.sort()
ans = 0
que = list(que)
for i in range(1,n):
  ans -= que[i

print(ans)

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
list.sort(a, reverse=True)

if n % 2 == 0:
    ans = sum(a[: int(n/2)])*2 - a[0]
if n % 2 == 1:
    ans = sum(a[: int(n/2 + 0.5)])*2 -a[0] - a[int(n/2 + 0.5)]
    
print(int(ans))

Failing test case input:
7
-1 81 0 -2 1 1 -2

Expected output:
85


Actual output:
86


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
list.sort(a, reverse=True)

if n % 2 == 0:
    ans = sum(a[: int(n/2)])*2 - a[0]
if n % 2 == 1:
    ans = sum(a[: int(n/2 + 0.5)])*2 -a[0] - a[int(n/2 - 0.5)]
    
print(int(ans))

Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
A_new = sorted(A, reverse=True)
A_feel = []
sum = 0
for i in range(N):
  if A_feel == [] or A_new[i] == A_new[0]:
    count = 1
  else:
    count = 2
  for j in range(count):
    A_feel.append(A_new[i])

for i in range(N-1):
  sum += A_feel[i]
  
print(sum)

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

Expected output:
6


Actual output:
5


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
A_new = sorted(A, reverse=True)
A_feel = []
sum = 0
for i in range(N):
  if A_feel == []:
    count = 1
  else:
    count = 2
  for j in range(count):
    A_feel.append(A_new[i])

for i in range(N-1):
  sum += A_feel[i]
  
print(sum)
Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):



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





K = sorted(K,reverse=True)

before_data = 0
ans = 0 
for i in K :
    ans += before_data
    before_data = i

print(ans)

Failing test case input:
7
-1 101 -1 0 -1 1 2

Expected output:
107


Actual output:
102


Fixed submission (verdict: Accepted):



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





K = sorted(K,reverse=True)

ans = 0 
for i,l in enumerate(K) :
    if (i == 0 ):
        ans += 0
    
    else :
        ans += K[i 

    


print(ans)

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys;input = lambda : sys.stdin.readline()
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
print(max(sum(a[:n-1]),sum(a[1:])))


Failing test case input:
4
-6 -30 -1 -4

Expected output:
-9


Actual output:
-11


Fixed submission (verdict: Accepted):
import sys;input=lambda:sys.stdin.readline()
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=1)
b=[]
for i in range(n):
  b.append(a[i])
  if i:
    b.append(a[i])
print(sum(b[:n-1]))

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




import sys
input = sys.stdin.readline



def main():
    N = int(input())
    A = list(map(int,input().split()))

    As = sorted(A)

    res = 0
    pre = As[N-1]

    for i in range(1,N):
        res += As[i]

    print(res)



main()


Failing test case input:
7
0 100 -8 3 18 3 -2

Expected output:
145


Actual output:
122


Fixed submission (verdict: Accepted):




import sys
input = sys.stdin.readline



def main():
    N = int(input())
    A = list(map(int,input().split()))

    As = sorted(A)

    res = 0

    for i in range(1,N):
        res += As[N-1-i

    print(res)



main()
Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = k()
A = l()
A.sort()
A.reverse()
b = list(itertools.accumulate(A))

print(b[N-2])


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

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 1
ans = 0
inf = float("inf")

n = k()
a = l()

a.sort(reverse = True)

for i in range(1,n):
    ans += a[i

print(ans)

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy
from functools import reduce

def main():

    n = int(input())
    lists = list(map(int, input().split()))
    lists.sort(reverse=True)
    print(sum(lists[:-1]))

if __name__ == "__main__":
    main()

Failing test case input:
7
-2 59 -2 -2 0 1 -2

Expected output:
59


Actual output:
54


Fixed submission (verdict: Accepted):
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy
from functools import reduce

def main():

    n = int(input())
    lists = list(map(int, input().split()))
    lists.sort(reverse=True)
    ans = 0
    count = n-1
    for i in range(n):
        if i == 0:
            ans += lists[i]
            count -= 1
        else:
            for j in range(2):
                if count > 0:
                    ans += lists[i]
                    count -= 1
        

    print(ans)

        

if __name__ == "__main__":
    main()
Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
ans = 0
for i in range(1,n):
    ans += a[i-1]
print(ans)

Failing test case input:
7
0 100 -2 4 -1 -27 10

Expected output:
128


Actual output:
111


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
a = a + a
a.sort(reverse=True)
ans = 0
for i in range(1,n):
    ans += a[i]

print(ans)

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import itertools
import copy
from collections import deque
import heapq
n = int(input())
a = list(map(int,input().split()))
flag = True
check = min(a)
ans = 0
for i in a:
    if flag and i == check:
        flag = False
    else:
        ans += i
print(ans)

Failing test case input:
7
-2 59 -2 -2 -1 1 -2

Expected output:
57


Actual output:
53


Fixed submission (verdict: Accepted):
import itertools
import copy
from collections import deque
import heapq
n = int(input())
a = list(map(int,input().split()))
a.sort()
a = a[::-1]
p = a[0]
c = 1
ans = 0
cnt = 0
for i in range(n-1):
    ans += p
    if c == 0:
        c += 1
    else:
        c = 0
        cnt += 1
        p = a[cnt]
    
print(ans)

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

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

import itertools as it

N=one_int()
A=many_int()

sort_A = sorted(A,reverse=True)

print(sum(sort_A) - sort_A[-1])

Failing test case input:
7
1 1 1 0 1 0 1

Expected output:
6


Actual output:
5


Fixed submission (verdict: Accepted):
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

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

import heapq

N=one_int()
A=many_int()

sort_A = sorted(A,reverse=True)



sukima = [-sort_A[0]]
heapq.heapify(sukima)

sort_A = sort_A[1:]
sums = 0
for a in sort_A:
    sums += heapq.heappop(sukima)
    heapq.heappush(sukima, -a)
    heapq.heappush(sukima, -a)

print(-sums)

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
input()
a=list(map(int,input().split()))
a.sort(reverse=True)

import collections
count=len(a)-1
ans=0
c = collections.Counter(a)
for i in c.keys():
    if count<=c[i]+1:
        ans+=i*count
        break
    else:
        ans+=i*(c[i]+1)
        count-=c[i]+1
print(ans)

Failing test case input:
4
2 4 1 10

Expected output:
18


Actual output:
24


Fixed submission (verdict: Accepted):
input()
a=list(map(int,input().split()))
a.sort(reverse=True)

import collections
count=len(a)
ans=0
c = collections.Counter(a)
for i in c.keys():
    tmp = c[i]*2
    if count<=tmp:
        ans+=i*count
        break
    else:
        ans+=i*tmp
        count-=tmp
print(ans-max(a))
Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
A=list(map(int,input().split()))
print(sum(A)-min(A))

Failing test case input:
7
-1 111 -2 2 -1 -16 3

Expected output:
120


Actual output:
112


Fixed submission (verdict: Accepted):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=1)
ans=0
for i in range(N-1):
    if i==0:
        ans+=A[0]
    else:
        ans+=A[(i+1)
print(ans)

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
A.sort()

ans = 0

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

print(ans)


Failing test case input:
4
-9 -30 -1 -7

Expected output:
-15


Actual output:
-17


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

ans = A[0]
for i in range(2, N):
  ans += A[i 

print(ans)

Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

A_sorted = sorted(A,reverse = True)

import heapq

circle = []
heapq.heappush(circle, -A_sorted[1])
heapq.heappush(circle, -A_sorted[1])
answer = A_sorted[0]

for i in range(2,N):
    target = A[i]
    popped = heapq.heappop(circle)
    answer -= popped
    heapq.heappush(circle, -target)
    heapq.heappush(circle, -target)

print(answer)

Failing test case input:
7
1 110 -1 0 2 -1 2

Expected output:
119


Actual output:
118


Fixed submission (verdict: Accepted):
import heapq

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

A_sorted = sorted(A,reverse = True)

circle = []
heapq.heappush(circle, -A_sorted[1])
heapq.heappush(circle, -A_sorted[1])
answer = A_sorted[0]

for i in range(2,N):
    target = A_sorted[i]
    popped = heapq.heappop(circle)
    answer -= popped
    heapq.heappush(circle, -target)
    heapq.heappush(circle, -target)

print(answer)

Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def main():
    _ = input()
    A = sorted(list(map(int, input().split())))[::-1]
    print(sum(A[:-1]))


if __name__ == '__main__':
    main()


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

Expected output:
106


Actual output:
101


Fixed submission (verdict: Accepted):
def main():
    N = int(input())
    A = sorted(list(map(int, input().split())))[::-1]
    if N % 2 == 1:
        print(sum(A[:N
    else:
        print(sum(A[:N


if __name__ == '__main__':
    main()
Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import collections

N = int(input())
As = list(map(int, input().split()))

As.sort(reverse = True)

print(As)

circle_que = collections.deque()

circle_que.append(As[0])

ans = 0
for A in As[1:]:
    circle_que.append(A)
    circle_que.append(A)

    ans += circle_que.popleft()
    

print(ans)

Failing test case input:
7
0 111 -1 1 0 1 -1

Expected output:
115


Actual output:
[111, 1, 1, 0, 0, -1, -1]
115


Fixed submission (verdict: Accepted):
import collections

N = int(input())
As = list(map(int, input().split()))

As.sort(reverse = True)



circle_que = collections.deque()

circle_que.append(As[0])

ans = 0
for A in As[1:]:
    circle_que.append(A)
    circle_que.append(A)

    ans += circle_que.popleft()
    

print(ans)

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
alist = list(map(int, input().split()))
alist.sort(reverse=True)
sumscore=alist[0]
for n in range(1,int(N/2)):
  sumscore = sumscore + alist[n]*2
if N%2==1:
  sumscore += alist[n]

print(sumscore)

Failing test case input:
7
-1 111 -2 2 -1 -16 3

Expected output:
120


Actual output:
123


Fixed submission (verdict: Accepted):
N = int(input())
alist = list(map(int, input().split()))
alist.sort(reverse=True)
sumscore=alist[0]
for n in range(1,int(N/2)):
  sumscore = sumscore + alist[n]*2
if N%2==1:
  sumscore += alist[n+1]

print(sumscore)

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
li = list(map(int,input().split()))
li.sort(reverse=True)

print(sum(li[:-1]))

Failing test case input:
4
1 5 1 3

Expected output:
11


Actual output:
9


Fixed submission (verdict: Accepted):
n = int(input())
li = list(map(int,input().split()))
li.sort(reverse=True)
ans = [li[0]] + li[1:]*2
ans.sort(reverse=True)

print(sum(ans[:n-1]))

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
num = (int)(input())
a = sorted(list(map(int, input().split(" "))), reverse=True)
b = [a[0]]
total = 0
for i in range(1, num):
  if i >= 4:
    total += min(b[:-1])
  else:
    total += min(b)
  b.append(a[i])
print(total)

Failing test case input:
4
1 3 1 3

Expected output:
9


Actual output:
7


Fixed submission (verdict: Accepted):
num = (int)(input())
a = sorted(list(map(int, input().split(" "))), reverse=True)
b = [a[0]]
total = a[0]
for i in range(3, num + 1):
    total += a[(i - 1) 
print(total)

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import heapq

N = int(input())
A = [-int(x) for x in input().split()]
A.sort()
pq = []
heapq.heapify(pq)
heapq.heappush(pq, A[0])
ans = 0
for a in A[1:]:
    ans += heapq.heappop(pq)
    heapq.heappush(pq, a)
print(-ans)


Failing test case input:
4
0 10 1 2

Expected output:
14


Actual output:
13


Fixed submission (verdict: Accepted):
import heapq

N = int(input())
A = [-int(x) for x in input().split()]
A.sort()
pq = []
heapq.heapify(pq)
heapq.heappush(pq, A[0])
ans = 0
for a in A[1:]:
    ans += heapq.heappop(pq)
    heapq.heappush(pq, a)
    heapq.heappush(pq, a)
print(-ans)