ZhenlongDai/ACPR huggingface dataset:
Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

import sys
from itertools import chain





def solve(N: int, A: "List[int]"):
    return sum(A) - min(A)


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    answer = solve(N, A)
    print(answer)

if __name__ == '__main__':
    main()


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

Expected output:
110


Actual output:
104


Fixed submission (verdict: Accepted):

import sys
from itertools import chain















def solve(N: int, A: "List[int]"):
    A = sorted(A, reverse=True)
    if N == 1:
        return
    N -= 1
    if N % 2 == 0:
        return A[0] + 2 * sum(A[1 : N 
    else:
        return A[0] + 2 * sum(A[1 : (N - 1) 


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    
    N = int(next(tokens))  
    A = list(map(int, (tokens)))
    answer = solve(N, A)
    print(answer)


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.sort()
m=A[-1]
ans=0
for i in range(N-1):
    n=A[N-i-1]
    ans+=m if m<n else n
    m=n
print(ans)

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

Expected output:
124


Actual output:
118


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
A.sort()
ans=0
for i in range(N-1):ans+=A[N-(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()
A.reverse()

list = []
ans = 0
list.append(A[0])
for i in range(len(A)):
        ans += list[i]
        list.append(A[i])
        list.append(A[i])

print(ans)

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

Expected output:
106


Actual output:
306


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

A.sort()
A.reverse()

list = []
ans = 0
list.append(A[0])
for i in range(1, len(A)):
        ans += list[i - 1]
        list.append(A[i])
        list.append(A[i])

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

import sys


def solve(N: int, A: "List[int]"):
    A = sorted(A, reverse=True)
    print(sum(A[:-1]))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)

if __name__ == '__main__':
    main()


Failing test case input:
4
1 2 1 3

Expected output:
7


Actual output:
6


Fixed submission (verdict: Accepted):

import sys
import heapq


def solve(N: int, A: "List[int]"):
    A = sorted(A, reverse=True)

    queue = [-A[0]]
    heapq.heapify(queue)

    answer = 0
    for i, a in enumerate(A[1:]):
        max_val = heapq.heappop(queue)
        answer += -max_val

        heapq.heappush(queue, -a)
        heapq.heappush(queue, -a)
    print(answer)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int(next(tokens)) for _ in range(N)]  
    solve(N, A)

if __name__ == '__main__':
    main()

Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from collections import deque


def main():
    input()  
    friendliness = [int(x) for x in input().split()]
    friendliness.sort()
    friendliness = deque(friendliness)
    tmp_queue = deque()
    ans = friendliness.pop()
    tmp_queue.appendleft(ans)
    tmp_queue.appendleft(friendliness.pop())
    while friendliness:
        ans += tmp_queue[0]
        tmp_queue.pop()
        tmp_queue.appendleft(friendliness.pop())
    print(ans)


if __name__ == '__main__':
    main()


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

Expected output:
82


Actual output:
77


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


def main():
    n = int(input())  
    friendliness = [int(x) for x in input().split()]
    friendliness.sort()
    friendliness = deque(friendliness)
    edges = deque()
    popped = friendliness.pop()
    edges.append(popped)
    ans = 0
    counter = 0
    while friendliness:
        ans += edges.popleft()
        counter += 1
        popped = friendliness.pop()
        edges.append(popped)
        edges.append(popped)
    print(ans)


if __name__ == '__main__':
    main()

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

n=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)

hp=[]

ans=-A[0]
heapq.heappush(hp,-A[0])
heapq.heappush(hp,-A[1])

for a in A[2:]:
    ans+=heapq.heappop(hp)
    heapq.heappush(hp,-a)
    heapq.heappush(hp,-a)
print(-ans)

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

Expected output:
13


Actual output:
15


Fixed submission (verdict: Accepted):
import heapq

n=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)

hp=[]

ans=0
heapq.heappush(hp,-A[0])

for a in A[1:]:
    ans+=heapq.heappop(hp)
    heapq.heappush(hp,-a)
    heapq.heappush(hp,-a)
print(-ans)
Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
cnt = n-2
ans = a[0]
for i in a[1:]:
  if cnt==0: break
  elif cnt>2:
    cnt -= 2
    ans += (i*2)
  else:
    cnt -=1
    ans += i
print(ans)

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

Expected output:
-6


Actual output:
-10


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
cnt = n-2
ans = a[0]
for i in a[1:]:
  if cnt==0: break
  elif cnt>=2:
    cnt -= 2
    ans += (i*2)
  else:
    cnt -=1
    ans += i
print(ans)

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())

A = sorted(list(map(int, input().split())), reverse=True)

score_list = [0]
for i in range(1, len(A)):
    score_list.append(A[i])
    score_list.append(A[i])
    
print(sum(score_list[:n-1]))

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

Expected output:
121


Actual output:
10


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

A = sorted(list(map(int, input().split())), reverse=True)

score_list = [0, A[0]]
for i in range(1, len(A)):
    score_list.append(A[i])
    score_list.append(A[i])
    
print(sum(score_list[:n]))

Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

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

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

Expected output:
125


Actual output:
111


Fixed submission (verdict: Accepted):
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
A = list(map(int,input().split()))
A.sort(reverse = True)
for i in range(1,n):
  ans += A[i
print(ans)

Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import heapq

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

comfort = A[0]
edges = [A[1], A[1]]

for ai in A[2:]:
    m = edges.pop(-1)
    comfort += m
    heapq.heappush(edges, ai)
    heapq.heappush(edges, ai)
print(comfort)


Failing test case input:
4
1 5 1 10

Expected output:
20


Actual output:
16


Fixed submission (verdict: Accepted):
import heapq

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

comfort = A[0]
edges = [-A[1], -A[1]]

for ai in A[2:]:
    m = heapq.heappop(edges) * -1
    comfort += m
    heapq.heappush(edges, -ai)
    heapq.heappush(edges, -ai)
print(comfort)
Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math

N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(1, N):
	ans += A[math.ceil(i / 2)]
print(ans)

Failing test case input:
4
-2 -67 0 -2

Expected output:
-4


Actual output:
-134


Fixed submission (verdict: Accepted):
import math
 
N = int(input())
A = list(map(int, input().split()))
A.sort()
A.reverse()
ans = 0
for i in range(1, N):
	ans += A[math.floor(i / 2)]
print(ans)

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
ans = 0
A = sorted(A, reverse = True)
 
la = len(A)
 
for i in range(la-1):
   ans += A[i]
 
print(ans)

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

Expected output:
104


Actual output:
100


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

A = sorted(A, reverse = True)

B = [A[0]] + [A[i] for i in range(1,N)] * 2

B = sorted(B, reverse = True)

ans = 0

for i in range(N - 1):
   ans +=  B[i]
print(ans)

Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
ans=0
ans+=max(a)
w=[a.pop()]*2
for i in range(n-2):
    ans+=max(w)
    if w[0]>=w[1]: w[0]=a.pop()
    else: w[1]=a.pop()
print(ans)

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

Expected output:
128


Actual output:
314


Fixed submission (verdict: Accepted):
n=int(input())
a=[int(i) for i in input().split()]
a.sort()
ans=0
ans+=max(a)
a.pop()
n-=2
while n:

    if n>=2:
        ans+=a.pop()*2
        n-=2
    else:
        ans+=a.pop()
        n-=1
print(ans)

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

ans = 0
for i in range(N-1):
  a = math.floor(i)
  ans += A[a]
    
print(ans)

Failing test case input:
7
-1 100 -4 1 -1 -2 2

Expected output:
105


Actual output:
99


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

ans = 0
for i in range(1,N):
  a = math.floor(i/2)
  ans += A[a]
    
print(ans)

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

Failing test case input:
7
0 011 -2 2 -3 -16 10

Expected output:
35


Actual output:
18


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
a = a + a
a.sort(reverse=True)
a = a[1:n]
print(sum(a))

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = [int(a) for a in input().split()]
print(sum(A)-min(A))

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

Expected output:
82


Actual output:
77


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(a) for a in input().split()] *2
A.sort()
A.reverse()
print(sum(A[1:N]))
Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys

N=int(sys.stdin.readline())

A=[int(i) for i in sys.stdin.readline().split()]

A.sort(reverse=True)

ans=0
ctr=0
i=0

while(ctr<N-1):
	if(i==0):
		ans+=A[i]
		i+=1
		ctr+=1
	else:
		ans+=A[i]
		i+=1
		ctr+=1
		if(ctr<N-1):
			ans+=A[i]
			ctr+=1

print(ans)


Failing test case input:
7
-1 100 -2 1 -1 -1 18

Expected output:
137


Actual output:
118


Fixed submission (verdict: Accepted):
import sys

N=int(sys.stdin.readline())

A=[int(i) for i in sys.stdin.readline().split()]

A.sort(reverse=True)

ans=0
ctr=0
i=0

while(ctr<N-1):
	if(i==0):
		ans+=A[i]
		i+=1
		ctr+=1
	else:
		ans+=A[i]
		ctr+=1
		if(ctr<N-1):
			ans+=A[i]
			ctr+=1
			i+=1

print(ans)

Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import heapq

n = int(input())
data = list(map(int, input().split()))
data.sort(reverse=True)

q = []
heapq.heappush(q, data[0])
heapq.heappush(q, data[1])
result = data[0]

for i in range(2, n):
    result += heapq.heappop(q)
    heapq.heappush(q, data[i])
    heapq.heappush(q, data[i])

print(result)

Failing test case input:
4
-11 -96 -2 -1

Expected output:
-5


Actual output:
-14


Fixed submission (verdict: Accepted):
import heapq

n = int(input())
data = list(map(int, input().split()))
data.sort(reverse=True)

q = []
heapq.heappush(q, -data[1])
heapq.heappush(q, -data[1])
result = data[0]

for i in range(2, n):
    result += -heapq.heappop(q)
    heapq.heappush(q, -data[i])
    heapq.heappush(q, -data[i])

print(result)

Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
arr=list(map(int,input().split()))
arr.sort(reverse=True)
print(sum(arr[:n-1]))

Failing test case input:
7
1 110 -5 2 8 2 -2

Expected output:
132


Actual output:
121


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

Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
print(sum(A)-A[-1])

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

Expected output:
83


Actual output:
81


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
P=A[0]
for i in range(2,N):
  P+=A[i
print(P)

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from math import *
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse = True)
ans = 0
for i in range(1,n):
	ans+=a[int(log2(i))]
print(ans)


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

Expected output:
38


Actual output:
39


Fixed submission (verdict: Accepted):
from math import *
n = int(input())
a = [int(i) for i in input().split()]
a.sort(reverse = True)
ans = 0
for i in range(1,n):
	ans+=a[i
print(ans)
Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
import time
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()
a.sort()
print(sum(a) - a[0])

Failing test case input:
4
1 5 1 10

Expected output:
20


Actual output:
16


Fixed submission (verdict: Accepted):
import sys
import time
import math
from collections import deque
import heapq
import itertools
from decimal import Decimal
import bisect
from operator import itemgetter
MAX_INT = int(10e18)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()
a.sort(reverse=True)

ans = a[0]
i = 1
cnt = 2
while True:
  if cnt == N:
    break
  ans += a[i]
  cnt += 1
  if cnt == N:
    break
  ans += a[i]
  cnt += 1
  i += 1
print(ans)

Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def main():
    n = int(input())
    a=[int(i) for i in input().split()]
    a.sort(reverse = True)

    
    res = a[0]
    tmp = a[1]
    k = 1
    cnt = 0
    for i in range(2,n):
        res += tmp
        cnt+=1
        if(cnt == 2):
            k+=1
            tmp = a[k]
    print(res)

if __name__ == '__main__':
    main()


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

Expected output:
108


Actual output:
109


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    a=[int(i) for i in input().split()]
    a.sort(reverse = True)

    
    res = a[0]
    tmp = a[1]
    k = 1
    cnt = 0
    for i in range(2,n):
        res += tmp
        cnt+=1
        if(cnt == 2):
            k+=1
            tmp = a[k]
            cnt = 0
    print(res)

if __name__ == '__main__':
    main()

Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):


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

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

Expected output:
81


Actual output:
76


Fixed submission (verdict: Accepted):


N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
ind=[(i+1)
print(sum([A[i] for i in ind]))

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
arr=[int(i) for i in input().split()]
arr.sort(reverse=True)
i=0
j=0
res=0
n-=1
while n:
    k=min(2**i,n)
    res+=(k)*arr[j]
    
    n-=k
    j+=1
    i+=1
print(res)

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

Expected output:
106


Actual output:
107


Fixed submission (verdict: Accepted):
n=int(input())
arr=[int(i) for i in input().split()]
arr.sort(reverse=True)
i=0
j=1
res=arr[0]
n-=2
while n:
    k=min(2,n)
    res+=arr[j]*k
    n-=k
    j+=1
print(res)
Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):


import copy
import random
import bisect 
import fractions 
import math
import sys
import collections
from decimal import Decimal 

mod = 10**9+7
sys.setrecursionlimit(mod) 

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()

A.sort()
ans = sum(A[1:])
print(ans)

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

Expected output:
106


Actual output:
101


Fixed submission (verdict: Accepted):


import copy
import random
import bisect 
import fractions 
import math
import sys
import collections
from decimal import Decimal 

mod = 10**9+7
sys.setrecursionlimit(mod) 

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
A = LI()

A.sort(reverse=1)
ans = 0
ans += A[0]

tmp = 1
for i in range(1, N - 1):
    ans += A[tmp]
    if i % 2 == 0:
        tmp += 1
print(ans)

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

list.sort(a, reverse=True)

if N %2== 0:
	for i in range(int(N/2)):
		if i == 0:
			total += a[i]
		else:
			total += a[i]*2
else:
	for i in range(int((N-1)/2)):
		if i == 0:
			total += a[i]
		else:
			total += a[i]*2
	total += a[int(N/2 - 1)]
print(total)


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

Expected output:
117


Actual output:
118


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int,input().split()))
total=0

list.sort(a, reverse=True)

if N %2== 0:
	for i in range(int(N/2)):
		if i == 0:
			total += a[i]
		else:
			total += a[i]*2
else:
	for i in range(int((N-1)/2)):
		if i == 0:
			total += a[i]
		else:
			total += a[i]*2
	total += a[int((N-1)/2 )]
print(total)

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    n  = int(input())
    a = [int(i) for i in input().split()]
    a.sort(reverse = True)
    
    print(sum(a[:n-1]))

main()

Failing test case input:
4
1 0 13 5

Expected output:
23


Actual output:
19


Fixed submission (verdict: Accepted):
def main():
    n  = int(input())
    a = [int(i) for i in input().split()]
    a.sort()
    ans = 0
    for i in range(1,n):
        ans += a[n-1-(i
    print(ans)

main()

Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
A = [int(i) for i in input().split()]


A.sort()
s = 0
for i in range(1, N):
    s += A[i]
print(s)

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

Expected output:
112


Actual output:
105


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(i) for i in input().split()]


A.sort(reverse=1)
s = A[0]
for i in range(N-2):
    p = i
    if i % 2 == 1:
        p -= 1
    s += A[p
print(s)
Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
A = sorted([int(i) for i in input().split()], reverse=True)

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

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

Expected output:
102


Actual output:
97


Fixed submission (verdict: Accepted):
N = int(input())
A = sorted([int(i) for i in input().split()])

ans = 0
for i in range(1, N):
	ans += A[(N-1) - (i 
	
print(ans)

Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from heapq import *

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

r = 0
Q = [A[0]]
for v in A[1:]:
	c = heappop(Q)
	r += c
	heappush(Q, v)
	heappush(Q, v)

print(r)


Failing test case input:
7
0 101 -2 4 -1 -16 10

Expected output:
129


Actual output:
112


Fixed submission (verdict: Accepted):
from heapq import *

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

r = 0
Q = [-A[0]]
for v in A[1:]:
	c = -heappop(Q)
	r += c
	heappush(Q, -v)
	heappush(Q, -v)

print(r)

Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
lst1 = list(map(int,readline().split()))

lst1.sort(reverse=True)
ans = 0
res = 0
for i in range(n):
    if i == 0:
        res = lst1[i]
        continue
    ans += res
    res = lst1[i]

print(ans)

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

Expected output:
145


Actual output:
122


Fixed submission (verdict: Accepted):
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
lst1 = list(map(int,readline().split()))

lst1.sort(reverse=True)
ans = 0
idx = 0
remain = 1
for i in range(n):
    if i == 0:
        continue
    if remain:
        remain -= 1
    else:
        remain = 1
        idx += 1
    ans += lst1[idx]
    


print(ans)

Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
sum_com = 0
distinct_a = sorted(list(set(a)), reverse=True)
comfort = {i: 0 for i in distinct_a}
comfort[a[0]] = 1
max_com = 0

for ai in a[1:]:
    sum_com += distinct_a[max_com]
    if distinct_a[max_com] == ai:
        comfort[distinct_a[max_com]]+= 1
    else:
        comfort[distinct_a[max_com]] -= 1
        max_com += 1
        comfort[distinct_a[max_com]] += 2

print(sum_com)


Failing test case input:
7
-1 100 -2 1 -1 -1 18

Expected output:
137


Actual output:
116


Fixed submission (verdict: Accepted):
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
sum_com = 0
distinct_a = sorted(list(set(a)), reverse=True)
comfort = {i: 0 for i in distinct_a}
comfort[a[0]] = 1
max_com = 0

for ai in a[1:]:
    sum_com += distinct_a[max_com]
    if distinct_a[max_com] == ai:
        comfort[distinct_a[max_com]] += 1
    else:
        comfort[distinct_a[max_com]] -= 1
        comfort[ai] += 2
        if comfort[distinct_a[max_com]] == 0:
            max_com += 1

print(sum_com)
Problem: p02615
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import heapq
n=int(input())
a=list(map(int,input().split()))
b=[]
for i in a:
  b.append(-i)
b.sort()
heapq.heapify(b)
ans=0
for i in range(n-1):
  tmp=heapq.heappop(b)
  ans+=(-tmp)
print(ans)

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

Expected output:
115


Actual output:
112


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

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

import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
A.sort()
ans =A[1:]
print(sum(ans))

Failing test case input:
4
1 7 1 13

Expected output:
27


Actual output:
21


Fixed submission (verdict: Accepted):

import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse =True)
A1 =A[1:] +A[1:]
A1.sort(reverse =True)
ans =[A[0]] +A1


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

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

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
h = [A[0]]
ans = 0
for i in range(1,N):
    ans += heapq.heappop(h)
    heapq.heappush(h, A[i])
    heapq.heappush(h, A[i])
print(ans)


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

Expected output:
113


Actual output:
111


Fixed submission (verdict: Accepted):
import heapq

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
h = [-A[0]]
ans = 0
for i in range(1,N):
    ans -= heapq.heappop(h)
    heapq.heappush(h, -A[i])
    heapq.heappush(h, -A[i])
print(ans)

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

maxval = a[0]
cc = {maxval: 1}

ans = 0

for i in range(1, n):
    if a[i] in cc:
        cc[a[i]] += 2
    else:
        cc[a[i]] = 2
    cc[maxval] -= 1
    ans += maxval
    if cc[maxval] == 0:
        maxval = a[i]

print(ans)


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

Expected output:
81


Actual output:
77


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

maxval = a[0]
cc = {maxval: 1}

ans = 0
idx = 0

for i in range(1, n):
    if a[i] in cc:
        cc[a[i]] += 2
    else:
        cc[a[i]] = 2
    cc[maxval] -= 1
    ans += maxval
    if cc[maxval] == 0:
        while 1:
            idx += 1
            if maxval > a[idx]:
                maxval = a[idx]
                break

print(ans)
Problem: p02615
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
order = [a[0]]
ans = 0
for i in range(1,n):
    ans += min(order[-1],order[0])
    order.append(a[i])
print(ans)


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

Expected output:
38


Actual output:
33


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

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

A.sort(reverse=True)
wa=A[0]
i=0
amari=len(A)%2

while(1):

    if(amari==0):

        if(len(A)-1==1+2*i):
            print(wa)
            break
        wa=A[1+2*i]*2+wa


    elif(amari==1):
        if(len(A)-2==1+2*i):
            print(A[1+2*i-1]+wa)
            break
        wa=A[1+2*i]*2+wa

    i=i+1


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

Expected output:
130


Actual output:
121


Fixed submission (verdict: Accepted):
N=int(input())
A=[0]
A=list(map(int,input().split()))

A.sort(reverse=True)
wa=A[0]
i=0
amari=len(A)%2

while(1):

    if(amari==0):

        if(len(A)-1==1+2*i):
            print(wa)
            break
        wa=A[i+1]*2+wa


    elif(amari==1):
        if(len(A)-2==1+2*i):
            print(A[i+1]+wa)
            break
        wa=A[i+1]*2+wa

    i=i+1
Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
K = int(input())

for i in range(len(S)):
    if S[i] != '1':
        print(S[i])
        break
    else:
        if i == len(S) - 1:
            print(1)

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
S = input()
K = int(input())
one_count = 0
ans = 0

for i in range(len(S)):
    if S[i] != '1':
        ans = S[i]
        break
    else:
        one_count += 1

if one_count >= K:
    print('1')
else:
    print(ans)

Problem: p03282
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S=list(input())
K=int(input())

i=0;p=0
while i!=len(S):
  if S[i]!="1":
    print(S[i])
    p=1
    break
  i=i+1
if p==0:
  print("1")

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
S=list(input())
K=int(input())

i=0;p=0;q=0
while i!=len(S):
  if S[i]!="1":
    p=1
    q=i
    if K<i+1:
      print("1")
    else:
      print(S[i])
    break
  i=i+1
if p==0:
  print("1")

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
k=int(input())
for x in s:
  if x=='1':
    k-=1
    if k==0:
      print(1,k)
      exit()
  else:
    print(x)
    exit()

Failing test case input:
1214
1

Expected output:
1


Actual output:
1 0


Fixed submission (verdict: Accepted):
s=input()
k=int(input())
for x in s:
  if x=='1':
    k-=1
    if k==0:
      print(1)
      exit()
  else:
    print(x)
    exit()

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = str(input())
K = int(input())

count = 5 * (10**15)

for i in range(len(S)):
        if K < 0:
                print(S[i-1])
                exit(0)
        elif S[i] != '1':
                K -= int(S[i]) * count
        else:
                K -= 1

print(S[-1])

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
S = str(input())
K = int(input())

if len(S) == 1:
        print(S[0])
        exit(0)

i = 0
while S[i] == '1' and i <= len(S)-2:
        if K <= i + 1:
                print(S[i])
                exit(0)
        i += 1
print(S[i])

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
K = int(input())

if all([c == '1' for c in S]):
    print(1)
    exit(0)

first_not1 = None
for i in range(len(S)):
    if S[i] != '1':
        first_not1 = i
        break

if K < first_not1:
    print(1)
else:
    print(S[first_not1])


Failing test case input:
1214
1

Expected output:
1


Actual output:
2


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

if all([c == '1' for c in S]):
    print(1)
    exit(0)

first_not1 = None
for i in range(len(S)):
    if S[i] != '1':
        first_not1 = i
        break

if K - 1 < first_not1:
    print(1)
else:
    print(S[first_not1])
Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input()
K=int(input())
if K<=len(S):
    for s in S[:K]:
        if s!="1":
            break
    else:
        print("1")
for s in S:
    if s!="1" :
        print(s)
        break

Failing test case input:
1214
1

Expected output:
1


Actual output:
1
2


Fixed submission (verdict: Accepted):
S=input()
K=int(input())
f=0
if(K<=len(S)):
    for s in S[:K]:
        if s!="1":
            break
    else:
        print("1")
        f=1
if f==0:      
    for s in S:
        if(s!="1"):
            print(s)
            break

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
S=input()
li=''.join(S)
S1=len(li)
m=[]

K=int(input())
for i in range(0,S1):
    if li[i]!='1' and (i+1)<K:
        print(li[i])
        sys.exit()

print('1')


Failing test case input:
299792458
1

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
import sys
S=input()
li=''.join(S)
S1=len(li)
m=[]

K=int(input())
ans=str(K)
k1=''.join(ans)
k2=len(k1)

for i in range(0,S1):
    if li[i]!='1' and i<K:
        print(li[i])
        sys.exit()

print('1')

Problem: p03282
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys

S = sys.stdin.readline().strip()
K = int(sys.stdin.readline())

for s_i in S:
    if s_i == "1":
        K -= 1
    else:
        break
print(s_i)

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
import sys

S = sys.stdin.readline().strip()
K = int(sys.stdin.readline())

for s_i in S:
    if s_i == "1":
        K -= 1
    else:
        break
    if K <= 0:
        break
print(s_i)

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(str(input()))
k = int(input())

s = [int(i) for i in s]

for i in s:
    if i == 1:
        continue
    else:
        print(i)
        exit(0)

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


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

s = [int(i) for i in s]

for i in range(k):
    if s[i] == 1:
        continue
    else:
        print(s[i])
        exit(0)

print(1)

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
K = int(input())

if len(S)==1:
    print(S[0])
    
else:
    lst = []
    for i in range(len(S)):
        if S[i]!='1':
            lst.append(i)
        
    if lst==[]:
        print('1')
    else:
        if K<lst[0]:
            print('1')
        else:
            print(S[lst[0]])

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


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

if len(S)==1:
    print(S[0])
    
else:
    lst = []
    for i in range(len(S)):
        if S[i]!='1':
            lst.append(i)
        
    if lst==[]:
        print('1')
    else:
        if K<lst[0]+1:
            print('1')
        else:
            print(S[lst[0]])
Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = list(input())
K = int(input())
ans = '1'
for s in S:
    if s != '1':
        ans = s
        break
print(ans)



Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
S = list(input())
K = int(input())
ans = '1'
for i in range(min(len(S),K)):
    s = S[i]
    if s != '1':
        ans = s
        break
print(ans)

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(input())
k = int(input())
if len(s) == 1:
    print(s)
elif k == 1:
    print(s[0])
else:
    for i in range(k):
        if s[i] != "1":
            print(s[i])
            exit()
    print(s[k-1])

Failing test case input:
3
74

Expected output:
3


Actual output:
3

Fixed submission (verdict: Accepted):
import sys
s = list(input())
k = int(input())
if len(s) == 1:
    print(s[0])
elif k == 1:
    print(s[0])
else:
    for i in range(k):
        if s[i] != "1":
            print(s[i])
            sys.exit()
    print(1)

Problem: p03282
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s = list(input())
k = int(input())

n_L = s[:k]
for i in n_L:
    if i != 1:
        print(i)
        exit()
print(1)

Failing test case input:
1214
4

Expected output:
2

Actual output:
1


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


for i in range(k):
    
    if int(s[i]) != 1:
        print(s[i])
        exit()
print(1)

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
K = int(input())

cnt = 0
for i in range(len(S)):
  if S[i] == '1':
    cnt += 1
  
  else:
    print(S[i])
    break
    
  if cnt == len(S):
    print(1)
    break

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


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

cnt = 0
for i in S:
  if i == '1':
    cnt += 1
  
  else:
    print(int(i))
    break
    
  if cnt == K:
    print(1)
    break

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input()
K=int(input())
for s in S:
    if s!="1":
        print(s)
        break
else:
    print(1)

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
S=input()
K=int(input())
k=0
for s in S:
    k+=1
    if k==K:
        print(s)
        exit()
    if s!="1":
        print(s)
        break
else:
    print(1)

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

if k > len(s):
  for i in s:
    if not i == '1':
      print(i)
      break
  
elif len(s) >= k:

  for i in s:
    if not i == '1':
      print(i)
      break
  else:
    print(1)



Failing test case input:
1214
1

Expected output:
1


Actual output:
2


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


if k <= len(s):
  for i in range(k):
    if not s[i] == '1':
      print(s[i])
      break
  else:
    print(1)
elif k > len(s):
  for i in s:
    if not i == '1':
      print(i)
      break
Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
k = int(input())


for i in range(0, len(s)):
	if s[i] != '1':
		print(s[i])
		break
else:
	print(1)

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


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

ans = s[0]

for i in range(0, k):
	if s[i] != '1':
		ans = s[i]
		break
		
print(ans)

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=list(input())
K=int(input())
l=0
for i in range(len(S)):
    if S[i]==1:
        l+=1
    else:
        a=S[i]
        break
if l>=K:
    print(1)
else:
    print(a)


Failing test case input:
1214
3

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
S=list(input())
K=int(input())
l=0
for i in range(len(S)):
    if S[i]=='1':
        l+=1
    else:
        a=S[i]
        break
if l>=K:
    print(1)
else:
    print(a)

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
n=int(input())
l=[]
for x in s:
    l.append(x)
    if x!="1":break
print(l[min(len(l)-1,n)])

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
s=input()
n=int(input())
l=[]
for x in s:
    l.append(x)
    if x!="1":break
print(l[min(len(l)-1,n-1)])

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
l=list(input())
k=int(input())
m=[0]*len(l)
for i in range(len(l)):
    var=pow(int(l[i]),int(l[i]))
    if(i==0):
        m[i]+=var
    if(i>=1):
        m[i]+=(m[i-1]+var)
    if(k<=m[i]):
        print(l[i])
        exit()

Failing test case input:
299792458
29610

Expected output:
2


Actual output:
9


Fixed submission (verdict: Accepted):
l=list(input())
k=int(input())
m=[0]*len(l)
for i in range(len(l)):
    var=pow(int(l[i]),100)
    if(i==0):
        m[i]+=var
    if(i>=1):
        m[i]+=(m[i-1]+var)
    if(k<=m[i]):
        print(l[i])
        exit()

Problem: p03282
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
S = input()
K = input()
ans = 1
for i in range(len(S)):
    if S[i] != '1':
        ans = int(S[i])
        break
print(ans)

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
S = input()
K = input() 
ans = 1
if not all([i == '1' for i in S[:int(K)]]):
    for i in range(len(S)):
        if S[i] != '1':
            ans = int(S[i])
            break
print(ans)

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

s = input()
k = int(input())
for si in s:
    if si != '1' or k == 0:
        print(si)
        break
    else:
        k -= 1
else:
    print(1)


Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):

s = input()
k = int(input())
for si in s:
    if si != '1':
        print(si)
        break
    else:
        k -= 1
        if k == 0:
            print(1)
            break
Problem: p03282
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
K = int(input())

for i in range(K):
    if S[i] != '1':
        print(S[i])
        exit()




Failing test case input:
1214
1

Expected output:
1


Actual output:

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

for i in range(K):
    if S[i] != '1':
        print(S[i])
        exit()
    
    if i == K - 1:
        print('1')
        exit()

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
k = int(input())
for i in s:
    if i != "1":
        print(i)
        exit()
print(1)

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
s = input()
k = int(input())
for i in range(k):
    if s[i] != "1":
        print(s[i])
        exit()
print(1)

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = list(input())
print(S)
size = len(S)
K = int(input())
for i in range(size):
    if S[i] == "1" and K == 1 :
        print("1")
        exit()
    else :
        if S[i] == "1":
            K -= 1
        else : 
            print(S[i])
            exit()

Failing test case input:
299792458
790

Expected output:
2


Actual output:
['2', '9', '9', '7', '9', '2', '4', '5', '8']
2


Fixed submission (verdict: Accepted):
S = list(input())
size = len(S)
K = int(input())
for i in range(size):
    if S[i] == "1" and K == 1 :
        print("1")
        exit()
    else :
        if S[i] == "1":
            K -= 1
        else : 
            print(S[i])
            exit()

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
n=int(input())

for i in range(n):
    if s[i]!='1':
        print(s[i])
        break
    else:
        print(1)


Failing test case input:
1214
5

Expected output:
2


Actual output:
1
2


Fixed submission (verdict: Accepted):
s=input()
n=int(input())
ans=1
for i in range(n):
    if s[i]!='1':
        ans=s[i]
        break
    else:
        continue
print(ans)

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
k=int(input())
for i in range(len(s)):
  if s[i]!=1:
    print(s[i])
    exit()
print(1)

Failing test case input:
1214
2

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
s=input()
k=int(input())
for i in range(k):
  if s[i]!="1":
    print(s[i])
    exit()
print(1)

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
k = int(input())
n = len(s)
index = 0
num = 0
for i in range(n):
    if s[i] != "1":
        index = i
        num = s[i]
        break

if k < index:
    print(1)
else:
    print(num)

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
s = input()
k = int(input())
n = len(s)
index = float("inf")
num = 0
for i in range(n):
    if s[i] != "1":
        index = i + 1
        num = s[i]
        break

if k < index:
    print(1)
else:
    print(num)
Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(input())
k = int(input())
for i in range(k):
  s_ = s[i]
  if not s_=='1':
    print(s_)
    break
print('1')

Failing test case input:
299792458
141808873

Expected output:
2


Actual output:
2
1


Fixed submission (verdict: Accepted):
s = list(input())
k = int(input())
for i in range(k):
  s_ = s[i]
  if not s_=='1':
    print(s_)
    exit()
print('1')

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

def solve():
    for i in s:
        if i == 1:
            continue
        else:
            print(i)
            exit()
if __name__=="__main__":
    S = input()
    K = int(input())

    s = [int(c) for c in S]

    solve()


Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):

def solve():
    j = 1
    for i in s:
        if i != 1:
            print(i)
            exit()
        if j==K:
            print(i)
            exit()
        j += 1
    print(1)

if __name__=="__main__":
    S = input()
    K = int(input())

    s = [int(c) for c in S]

    solve()

Problem: p03282
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
k = int(input())
ans = 1
for i in range(len(s)):
    if s[i] != '1':
        ans = int(s[i])
        break
print(ans)


Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
s = input()
k = int(input())
ans = 1
for i in range(k):
    if s[i] != '1':
        ans = int(s[i])
        break
print(ans)

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
numstr = input()
num = int(input())
def check():
    infinity = ""
    for i in range(len(numstr)):
        if numstr[i] is not "1":
            infinity = infinity + numstr[i]
            return infinity
        else:
            infinity = infinity + "1"
    return "1"
infinity = check()
print(infinity[len(infinity)-1])
        


Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
numstr = input()
num = int(input())
def check():
    infinity = ""
    for i in range(num):
        if numstr[i] is not "1":
            infinity = infinity + numstr[i]
            return infinity
        else:
            infinity = infinity + "1"
    return "1"
infinity = check()
print(infinity[len(infinity)-1])

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input()
K=int(input())
one = True
for i in range(len(S)):
  one = one and S[i]=='1'
  if not one: break
print(S[i])

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


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

one = True
for i in range(K):
  one = one and S[i]=='1'
  if not one:
    print(S[i])
    break
if one:
  print(1)
Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()
k = int(input())
for c in s:
  if not int(c) == 1:
    print(c)
    break
else:
  print(1)

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
s = input()
k = int(input())
for i in range(min(len(s), k)):
  if not s[i] == '1':
    print(s[i])
    break
else:
  print(1)

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input()
K=int(input())
co=0	
a=0
for j in S:
	a=a+1
	if j!='1':
		print(j)
		co=1
		break
	if a>K:
		break
if co==0:
	print('1')

Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
S=input()
K=int(input())
co=0	
a=0
for j in S:
	a=a+1
	if j!='1':
		print(j)
		co=1
		break
	if a==K:
		break
if co==0:
	print('1')

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def logic(S, K):
    if len(S) == 1:
        return int(S)
    if S[0:5] == "11111":
        return 1
    a = S.replace("1", "")
    if len(a) == 0:
        return 1
    return int(a[0])


if __name__ == '__main__':
    print(logic(input(), input()))


Failing test case input:
1214
1

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
def logic(S, K):
    if len(S) == 1:
        return int(S)
    if S[0:int(K)].replace("1","") == "":
        return 1
    a = S.replace("1", "")
    if len(a) == 0:
        return 1
    return int(a[0])


if __name__ == '__main__':
    print(logic(input(), input()))

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
K = int(input())

S_list = list(map(int, list(S)))
i = 0
while True:
  if S_list[i] == 1:
    i += 1
    if K == i:
      print("1")
      break
  else:
    if K == 1:
      print("1")
      break
    else:
      print(S_list[i])
      break
  

Failing test case input:
299792458
1

Expected output:
2


Actual output:
1


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

S_list = list(map(int, list(S)))
i = 0
while True:
  if S_list[i] == 1:
    i += 1
    if K == i:
      print(S_list[i-1])
      break
  else:
    if K == 1:
      print(S_list[i])
      break
    else:
      print(S_list[i])
      break

Problem: p03282
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = input()
K = int(input())
i = 0
while True:
    if S[i] == '1':
        if K == 1:
            break
        else:
            K-=1
            i+=1
    else:
        break

Failing test case input:
299792458
8222

Expected output:
2


Actual output:

Fixed submission (verdict: Accepted):
S = input()
K = int(input())
i = 0
while True:
    if S[i] == '1':
        if K == 1:
            break
        else:
            K-=1
            i+=1
    else:
        break
print(S[i])