ZhenlongDai/ACPR huggingface dataset:
Problem: p02959
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))

A_0 = A_list.pop(0)


A_list[0] = A_list[0] + A_0


taos = 0
nokori = 0
keep = 0

for i, (a, b) in enumerate(zip(A_list, B_list)):
  if i == 0:
    if a >= b:
      taos += b
    else:
      taos += b-a
  else: 
    if (a + nokori) >= (b + keep) :
      taos += (b + keep)
      nokori = (a + nokori) - (b + keep)
      keep = 0
    else:
      taos += (a + nokori)
      nokori = 0
      keep = (b + keep) - (a + nokori)
 
print(taos)

Failing test case input:
3
1 2 0 1
0 011 27

Expected output:
3


Actual output:
1


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

taos = 0
keep = 0

for i, (a, b) in enumerate(zip(A_list, B_list)):
  if a >= (b + keep) :
    taos += (b + keep)
    keep = 0
  else:
    taos += a
    if keep > a:
      keep = b
    else:
      keep = (b + keep) - a 
  

if A_list[-1] >= keep:
  taos += keep
else:
  taos += A_list[-1]
print(taos)

Problem: p02959
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")


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

    counter = 0
    for i in range(N):
        if A[i] < B[i]:
            
            if (A[i] + A[i + 1]) > B[i]:
                counter += B[i]
                A[i + 1] = A[i + 1] - B[i] + A[i]
                B[i] = 0
            else:
                counter += (A[i] + A[i + 1])
                B[i] = B[i] - A[i] - A[i + 1]
                A[i + 1] = 0
        
        else:
            counter += B[i]

    if B[N - 1] > A[N]:
        counter += A[N]
    else:
        counter += B[N - 1]

    print(counter)
            
    
if __name__ == "__main__":
    main()


Failing test case input:
2
2 5 1
0 5

Expected output:
5


Actual output:
6


Fixed submission (verdict: Accepted):
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")


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

    counter = 0
    for i in range(N):
        if A[i] < B[i]:
            
            if (A[i] + A[i + 1]) > B[i]:
                counter += B[i]
                A[i + 1] = A[i + 1] - B[i] + A[i]
                B[i] = 0
            else:
                counter += (A[i] + A[i + 1])
                B[i] = B[i] - A[i] - A[i + 1]
                A[i + 1] = 0
                
        elif A[i] == B[i]:
            counter += A[i]
            B[i] = 0
            A[i] = 0
                
        else:
            counter += B[i]
            B[i] = 0

    if B[N - 1] > A[N]:
        counter += A[N]
    elif B[N - 1] != 0:
        counter += B[N - 1]

    print(counter)
            
    
if __name__ == "__main__":
    main()
Problem: p02959
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
for i in range(N):
    print(i)
    if A[i] > B[i]:
        ans += B[i]
        A[i] -= B[i]
        B[i] -= B[i]
    else:
        ans += A[i]
        B[i] -= A[i]
        A[i] -= A[i]
    if A[i+1] > B[i]:
        ans += B[i]
        A[i+1] -= B[i]
        B[i] -= B[i]
    else:
        ans += A[i+1]
        B[i] -= A[i+1]
        A[i+1] -= A[i+1]
print(ans)


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

Expected output:
-3


Actual output:
0
1
-3


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
for i in range(N):
    if A[i] > B[i]:
        ans += B[i]
        A[i] -= B[i]
        B[i] -= B[i]
    else:
        ans += A[i]
        B[i] -= A[i]
        A[i] -= A[i]
    if A[i+1] > B[i]:
        ans += B[i]
        A[i+1] -= B[i]
        B[i] -= B[i]
    else:
        ans += A[i+1]
        B[i] -= A[i+1]
        A[i+1] -= A[i+1]
print(ans)

Problem: p02959
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=min(A[0],B[0])
B[0]-=ans
for i in range(N-1):
    score=min(A[i+1],B[i]+B[i+1])
    ans+=score
    B[i+1]-=min(0,score-B[i])
print(ans+min(B[N-1],A[N]))

Failing test case input:
3
0 0 0 13
3 100 8

Expected output:
8


Actual output:
13


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
ans=min(A[0],B[0])
B[0]-=ans
for i in range(N-1):
    score=min(A[i+1],B[i]+B[i+1])
    ans+=score
    B[i+1]-=max(0,score-B[i])
print(ans+min(B[N-1],A[N]))

Problem: p02959
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ans = 0

for i in range(n):
  sa = a[i] - b[i]
  
  if sa < 0:
    b[i] -= a[i]
    ans += a[i]
    sa2 = a[i+1] - b[i]
    
    if sa2 < 0:
      ans += a[i+1]
      a[i+1] = 0
    else:
      a[i+1] -= sa2
      ans += b[i]
      b[i] -= sa2
      
  else:
    ans += b[i]
    
print(ans)
    

Failing test case input:
3
0 4 0 13
3 100 8

Expected output:
12


Actual output:
14


Fixed submission (verdict: Accepted):
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    ans = 0

    for i in range(n):
        beat_now = min(a[i], b[i])
        ans += beat_now
        beat_next = min(a[i + 1], b[i] - min(a[i], b[i]))
        ans += beat_next
        a[i + 1] -= beat_next

    print(ans)


resolve()
Problem: p02959
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
count = 0
ad = 0

for i in range(N):
  if A[i] <= B[i] + ad:
    count += A[i]
    ad = max(0, B[i] + ad - A[i])
    
  else:
    count += B[i] + ad
    ad = 0
    

count += min(A[N], ad)     

print(count)

Failing test case input:
3
0 1 0 21
2 100 8

Expected output:
9


Actual output:
22


Fixed submission (verdict: Accepted):

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

for i in range(N):
  if A[i] <= B[i] + ad:
    count += A[i]
    ad = max(0, B[i] - max(A[i] - ad, 0))
    
  else:
    count += B[i] + ad
    ad = 0
    

count += min(A[N], ad)     

print(count)

Problem: p02959
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
    if A[i] < B[i]:
        ans += A[i]
        if A[i+1] >= (B[i] - A[i]):
            A[i+1] -= B[i] - A[i]
            ans += B[i] - A[i]
        else:
            A[i+1] = 0
            ans += A[i+1]
print(ans)

Failing test case input:
2
100 0 1
1 100

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    if A[i] >= B[i]:
        ans += B[i]
    if A[i] < B[i]:
        ans += A[i]
        if A[i+1] >= (B[i] - A[i]):
            A[i+1] -= B[i] - A[i]
            ans += B[i] - A[i]
        else:
            ans += A[i+1]
            A[i+1] = 0
print(ans)
Problem: p02274
Buggy submission (Python3, verdict: Wrong Answer):



global cnt
cnt=0

def merge(A,left,mid,right):
    L=A[left:mid]
    R=A[mid:right]
    L.append(float("inf"))
    R.append(float("inf"))
    
    i=0
    j=0
    for k in range(left,right):
        global cnt
        if L[i]<=R[j]:
            A[k]=L[i]
            i=i+1
        else:
            A[k]=R[j]
            j=j+1
            cnt+=mid-left-i

def mergeSort(A,left,right):
    if left+1<right:
        mid=(int)((left+right)/2)
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)

n=int(input())
S=list(map(int,input().split()))

mergeSort(S,0,n)
print(*S)
print(cnt)


Failing test case input:
3
-5 0 -3

Expected output:
1


Actual output:
-5 -3 0
1


Fixed submission (verdict: Accepted):



global cnt
cnt=0

def merge(A,left,mid,right):
    L=A[left:mid]
    R=A[mid:right]
    L.append(float("inf"))
    R.append(float("inf"))
    
    i=0
    j=0
    for k in range(left,right):
        global cnt
        if L[i]<=R[j]:
            A[k]=L[i]
            i=i+1
        else:
            A[k]=R[j]
            j=j+1
            cnt+=mid-left-i

def mergeSort(A,left,right):
    if left+1<right:
        mid=(int)((left+right)/2)
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)

n=int(input())
S=list(map(int,input().split()))

mergeSort(S,0,n)
print(cnt)
Problem: p03303
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=list(input())
w=int(input())
x=[]
y=''
ans=''
count=[]
for i in range(len(s)):
    y+=s[i]
    if len(list(y))==w:
        x.append(y)
        y=''
    if i==len(s)-1:
        x.append(y)
for j in range(len(x)-1):
    count=list(x[j])
    ans+=count[0]
print(ans)


Failing test case input:
gggedcca
10

Expected output:
g


Actual output:

Fixed submission (verdict: Accepted):
s=list(input())
w=int(input())
x=[]
y=''
ans=''
count=[]
for i in range(len(s)):
    y+=s[i]
    if len(list(y))==w:
        x.append(y)
        y=''
    if i==len(s)-1 and y!='':
        x.append(y)
for j in range(len(x)):
    count=list(x[j])
    ans+=count[0]
print(ans)

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

for index, s in enumerate(S):
    if index % w == 0:
        print(s)



Failing test case input:
llmln
4

Expected output:
ln


Actual output:
l
n


Fixed submission (verdict: Accepted):
import sys

S = input()
w = int(input())

for index, s in enumerate(S):
    if index % w == 0:
        sys.stdout.write(s)

Problem: p03303
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
st = input()
skpe = int(input())
st_len = len(st)
count = st_len 
top_list = []

for i in range(count):
    top_list.append(st[3 * i:3 * i + 3])


for x in top_list:
    try:
        print(x[0], end="")
    except IndexError:
        pass


Failing test case input:
mlmlk
5

Expected output:
m


Actual output:
ml

Fixed submission (verdict: Accepted):
st = input()
skpe = int(input())
st_len = len(st)
count = (st_len 
top_list = []
s = ""

for i in range(count):
    top_list.append(st[skpe * i:skpe * i + skpe])


for x in top_list:
    try:
        s += x[0]
    except IndexError:
        pass
print(s)

Problem: p03303
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(input())
w = int(input())
index = 0
l = []
while index <= len(s) - 1:
  print(index)
  l.append(s[index])
  index += w
print(*l, sep="")

Failing test case input:
gggeadbc
1

Expected output:
gggeadbc


Actual output:
0
1
2
3
4
5
6
7
gggeadbc


Fixed submission (verdict: Accepted):
s = list(input())
w = int(input())
index = 0
l = []
while index <= len(s) - 1:
  l.append(s[index])
  index += w
print(*l, sep="")

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

strings=[input() for string in range(2)]
string=strings[0]
num=int(strings[1])
i=0
check=True

while check:
    s=string[i:i+num]
    if len(s)<num:
        check=False
    print(s)
    i=i+num

Failing test case input:
accdefgh
5

Expected output:
af


Actual output:
accde
fgh


Fixed submission (verdict: Accepted):

strings=[input() for string in range(2)]
string=strings[0]
num=int(strings[1])
result=""
for i in range(len(string)):
    if i% num==0:
        result=result+string[i]
    i=i+1
print(result)
Problem: p03303
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    s_i = input()
    n_i = int(input())
    ans = ""
    while True:
        if len(s_i) < n_i:
            if n_i == 1:
                break
            else:
                if s_i == "":
                    break
                else:
                    ans += s_i[0]
                    break
        else:
            ans += s_i[:n_i][0]
            s_i = s_i[n_i:]
            print(ans)


if __name__ == "__main__":
    main()

Failing test case input:
dnuondouuuhs
3

Expected output:
doou


Actual output:
d
do
doo
doou


Fixed submission (verdict: Accepted):
def main():
    s_i = input()
    n_i = int(input())
    ans = ""
    while True:
        if len(s_i) < n_i:
            if s_i != "":
               ans += s_i[0]
               break
            else:
                break
        else:
            ans += s_i[:n_i][0]
            s_i = s_i[n_i:]
    print(ans)


if __name__ == "__main__":
    main()

Problem: p03303
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = list(input())
w = int(input())

L = len(S)

ans = []

for i in range(0,L,w):
	if i < L-1:
		ans.append(S[i])


print (''.join(ans))

Failing test case input:
mklll
1

Expected output:
mklll


Actual output:
mkll


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

L = len(S)

ans = []

for i in range(0,L,w):
	if i <= L-1:
		ans.append(S[i])


print (''.join(ans))

Problem: p03303
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
x=''
for i in range(len(s)):
        if i%3==0:
                x+=s[i]
print(x)

Failing test case input:
dnvondouuuhs
1

Expected output:
dnvondouuuhs


Actual output:
doou


Fixed submission (verdict: Accepted):
s=input()
l=int(input())
x=''
for i in range(len(s)):
        if i%l==0:
                x+=s[i]
print(x)

Problem: p03303
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S,w=input(),int(input())
print(S[0::3])

Failing test case input:
siuuuodnound
1

Expected output:
siuuuodnound


Actual output:
sudu


Fixed submission (verdict: Accepted):
S,w=input(),int(input())
print(S[0::w])

Problem: p03303
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
s = input()
n = int(input())
print(s[0::3])

Failing test case input:
llmln
4

Expected output:
ln


Actual output:
ll


Fixed submission (verdict: Accepted):
s = input()
n = int(input())
print(s[0::n])

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

length = len(s)

output = s[0]
i = w

while(i<length):
    output += s[w]
    i += w

print(output)


Failing test case input:
dnuohdnuuuos
2

Expected output:
duhnuo


Actual output:
duuuuu


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

length = len(s)

output = s[0]
i = w

while(i<length):
    output += s[i]
    i += w

print(output)
Problem: p03303
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = list(input())
ans =[]

for i in range(len(s)):
    if i%3 == 0:
        ans.append(s[i])
        
print("".join(ans))

Failing test case input:
dntoodouuuhs
1

Expected output:
dntoodouuuhs


Actual output:
doou


Fixed submission (verdict: Accepted):
s = list(input())
w = int(input())
ans =[]
 
for i in range(len(s)):
    if i%w == 0:
        ans.append(s[i])
        
print("".join(ans))

Problem: p03303
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=input().strip()
print(a[::3])

Failing test case input:
llmll
2

Expected output:
lml


Actual output:
ll


Fixed submission (verdict: Accepted):
a=input().strip()
n=int(input())
print(a[::n])

Problem: p03303
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
n=int(input())
ans=''
for i in range(n):
  if i%n==0:
    ans+=s[i]
print(ans)
    

Failing test case input:
abcdefgh
4

Expected output:
ae


Actual output:
a


Fixed submission (verdict: Accepted):
s=input()
n=int(input())
ans=''
for i in range(len(s)):
  if i%n==0:
    ans+=s[i]
print(ans)

Problem: p03303
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
step = int(input())
for i in range(0, len(s), step):
  print(s[i])


Failing test case input:
lllll
2

Expected output:
lll


Actual output:
l
l
l


Fixed submission (verdict: Accepted):
s = input()
step = int(input())
print(''.join([s[i] for i in range(0, len(s), step)]))

Problem: p03303
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
w=int(input())
a=[]
for i in range(len(s)):
  if (i+1)%w==1:a.append(s[i])
print(''.join(a))

Failing test case input:
mllll
1

Expected output:
mllll


Actual output:

Fixed submission (verdict: Accepted):
s=input()
w=int(input())
a=[]
for i in range(len(s)):
  if i%w==0:a.append(s[i])
print(''.join(a))

Problem: p03303
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=input()
b=int(input())
print(a[::3])

Failing test case input:
llnlm
2

Expected output:
lnm


Actual output:
ll


Fixed submission (verdict: Accepted):
a=input()
b=int(input())
print(a[::b])

Problem: p03303
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
w = int(input())
for i in range(len(S)):
  if (i + 1) % w == 1:
    print(S[i], end = "")

Failing test case input:
shutuodonvnd
1

Expected output:
shutuodonvnd


Actual output:

Fixed submission (verdict: Accepted):
S = input()
w = int(input())
for i in range(len(S)):
  if w != 1 and (i + 1) % w == 1 :
    print(S[i], end = "")
  elif w == 1:
    print(S[i], end = "")

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

import sys
S = input()
w = int(input())
x = 0

S_list = list(S)

while True:
    sys.stdout.write(S_list[x])
    x = x + w
    if x > len(S_list) or x + w > len(S_list):
        break


Failing test case input:
dnuoodnuuuhs
7

Expected output:
du


Actual output:
d

Fixed submission (verdict: Accepted):

import sys
S = input()
w = int(input())
x = 0

S_list = list(S)

sys.stdout.write(S_list[0])
while True:
    x = x + w
    if x >= len(S_list):
        break
    sys.stdout.write(S_list[x])
Problem: p03303
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
S = input()
w = int(input())
for i in range(len(S)):
  if w != 1 and (i + 1) % w == 1 :
    print(S[i], end = "")
  elif w == 1:
    print(S[i])


Failing test case input:
shuuuodonvnd
1

Expected output:
shuuuodonvnd


Actual output:
s
h
u
u
u
o
d
o
n
v
n
d


Fixed submission (verdict: Accepted):
S = input()
w = int(input())
for i in range(len(S)):
  if w != 1 and (i + 1) % w == 1 :
    print(S[i], end = "")
  elif w == 1:
    print(S[i], end = "")
Problem: p02917
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
bs = list(map(int, input().split()))

res = bs[0]
for i in range(n - 2):
	res += min(bs[i], bs[i + 1])

if n == 2:
	res += bs[-1]
else:
	res += max(bs[-1], bs[-2])

print(res)

Failing test case input:
3
-1 -2

Expected output:
-5


Actual output:
-4


Fixed submission (verdict: Accepted):
n = int(input())
bs = list(map(int, input().split()))

res = bs[0]
for i in range(n - 2):
	res += min(bs[i], bs[i + 1])
res += bs[-1]

print(res)

Problem: p02917
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    n = int(input())
    array = list(map(int, input().split()))
    sum_value = array[-1]
    for i in reversed(range(n-1)):
        if array[i - 1] <= array[i]:
            sum_value += array[i - 1]
        else:
            array[i - 1] = array[i]
            sum_value += array[i - 1]
    print(sum_value)

if __name__ == "__main__":
    main()


Failing test case input:
6
1 155 10 0 3

Expected output:
15


Actual output:
3


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    array = list(map(int, input().split()))
    sum_value = array[-1] + array[0]
    for i in range(n-2):
        sum_value += min(array[i], array[i+1])
        
    print(sum_value)

if __name__ == "__main__":
    main()

Problem: p02917
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
B = [int(i) for i in input().split()]

    
A = [0] * N
for i in range(1, N - 1):
    A[i] = min(B[i - 1], B[i])

A[N - 1] = B[N - 2]
print(sum(A))

Failing test case input:
2
-31

Expected output:
-62


Actual output:
-31


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

    
A = [0] * N
A[0] = B[0]
for i in range(1, N - 1):
    A[i] = min(B[i - 1], B[i])

A[N - 1] = B[N-2]

print(sum(A))

Problem: p02917
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
Bi = list(map(int, input().split()))
listA = [0 for i in range(N)]
listA[N-1] = Bi[N-2]
gokei = 0
for j in reversed(range(N-1)):
    listA[j] = min(Bi[j], Bi[j-1])

for k in listA:
    gokei += k
print(gokei)

Failing test case input:
3
-1 -2

Expected output:
-5


Actual output:
-6


Fixed submission (verdict: Accepted):
N = int(input())
Bi = list(map(int, input().split()))
listA = [0 for i in range(N)]
listA[N-1] = Bi[N-2]
gokei = 0
listA[0] = Bi[0]
for j in range(N-2, 0, -1):
    listA[j] = min(Bi[j], Bi[j-1])

for k in listA:
    gokei += k
print(gokei)

Problem: p02917
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
B = list(map(int,input().split()))
A = [0]*N
A[N-1] = B[N-1-1]
for i in range(1,N):
    A[N-1-i] = min(B[N-1-i],B[N-1-i-1])
print(sum(A))

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

Expected output:
-7


Actual output:
-8


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

A = [0]*N
A[0] = B[0]
A[N-1] = B[N-1-1]
for i in range(1,N-1):
    A[N-1-i] = min(B[N-1-i],B[N-1-i-1])
print(sum(A))
Problem: p02917
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
b=list(map(int,input().split()))
for j in range(n-2):
    if b[j]>min(b[j:]):
        b[j]=min(b[j:])

print(sum(b)+b[0])

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

Expected output:
-7


Actual output:
-9


Fixed submission (verdict: Accepted):
n=int(input())
b=list(map(int,input().split()))
ans=[]
for j in range(n-2):
    ans.append(min(b[j],b[j+1]))

print(sum(ans)+b[0]+b[-1])

Problem: p02917
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
B = list(map(int, input().split()))
A = []

A.append(B[0])

for i in range(N-2):
    A.append(min(B[i], B[i+1]))

A.append(max(B[N-3], B[N-2]))

print(sum(A))


Failing test case input:
6
0 164 10 7 6

Expected output:
29


Actual output:
30


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

A.append(B[0])

for i in range(N-2):
    A.append(min(B[i], B[i+1]))

A.append(B[N-2])

print(sum(A))

Problem: p02917
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
B=[10**6]
B.extend([int(b) for b in input().split()])
B.append(10**6)
print(N, B)

A=[None]*N
for i in range(N):
  A[i] = min(B[i], B[i+1])
  
print(sum(A))

Failing test case input:
2
-31

Expected output:
-62


Actual output:
2 [1000000, -31, 1000000]
-62


Fixed submission (verdict: Accepted):
N=int(input())
B=[10**6]
B.extend([int(b) for b in input().split()])
B.append(10**6)


A=[None]*N
for i in range(N):
  A[i] = min(B[i], B[i+1])
  
print(sum(A))

Problem: p02917
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
b = [int(i) for i in input().split()] 

l = [b[0], b[0]]
if n>=3:
  for i in range(1, len(b)-1):
      test =  b[i+1] - b[i]
      if test>=0:
          l.append(b[i])
      else:
          l.append(b[i+1])
  l.append(b[-1])
  print(sum(l))
else:
  print(b[0]*2)

Failing test case input:
3
-1 -2

Expected output:
-5


Actual output:
-4


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

l = [b[0]]
if n>=3:
  for i in range(0, len(b)-1):
      test =  b[i+1] - b[i]
      if test>=0:
          l.append(b[i])
      else:
          l.append(b[i+1])
  l.append(b[-1])
  print(sum(l))
else:
  print(b[0]*2)

Problem: p02917
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [0] * n
b = [int(i) for i in input().split()]
ans = 0
a[0] = b[0]
a[1] = b[0]

for i in range(2, n-1):
    a[i] = min(b[i], b[i-1])
a += [b[-1]]
print(sum(a))



Failing test case input:
2
-394

Expected output:
-788


Actual output:
-1182


Fixed submission (verdict: Accepted):
n = int(input())
a = [0] * n
b = [int(i) for i in input().split()]
a[0] = b[0]
for i in range(1, n-1):
    a[i] = min(b[i], b[i-1])
a[-1] = b[-1]
print(sum(a))
Problem: p02917
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
B = list(map(int, input().split()))

ans = B[-1]

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

if N == 2:
    ans += B[0]


print(ans)

Failing test case input:
3
-1 54

Expected output:
52


Actual output:
53


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

ans = sum(B)*2

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


print(ans)

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

sum = 0
if N==2:
    sum += B[0]*2
else:
    sum += min([B[0], B[1]])
    for i in range(N-2):
        sum += min([B[i], B[i+1]])
    sum += B[N-2]

print(sum)

Failing test case input:
3
-1 -2

Expected output:
-5


Actual output:
-6


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

sum = 0
if N==2:
    sum += B[0]+B[0]
else:
    sum += B[0]
    for i in range(N-2):
        sum += min([B[i], B[i+1]])
    sum += B[N-2]
print(sum)

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

A = [max(B)] * N

for n in range(N, 0, -1):
    if A[n-1] > B[n-2]:
        A[n-1] = B[n-2]
    if A[n-2] > B[n-2]:
        A[n-2] = B[n-2]
print(sum(A))

Failing test case input:
3
-1 -2

Expected output:
-5


Actual output:
-6


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

A = [max(B)] * N

for n in range(N-1):
    if B[n] < A[n]:
        A[n] = B[n]
    if B[n] < A[n+1]:
        A[n+1] = B[n]
print(sum(A))

Problem: p02917
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
b = list(map(int, input().split()))

a = [0]*n
for i in range(n-1):
    if n == 0:
        a[0] = b[0]
        a[1] = b[0]
    elif b[i] >= b[i-1]:
        a[i+1] = b[i]
    elif b[i] < b[i-1]:
        a[i+1] = b[i]
        a[i] = b[i]
print(sum(a))

Failing test case input:
2
24

Expected output:
48


Actual output:
24


Fixed submission (verdict: Accepted):
n = int(input())
b = list(map(int, input().split()))

a = [0]*n
for i in range(n-1):
    if i == 0:
        a[0] = b[0]
        a[1] = b[0]
    elif b[i] >= b[i-1]:
        a[i+1] = b[i]
    elif b[i] < b[i-1]:
        a[i+1] = b[i]
        a[i] = b[i]
print(sum(a))

Problem: p02917
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
B = list(map(int,(input().split())))

list_A = [0]*n

list_A[0] = B[0]
list_A[n-1] = B[n-2]
for i in range(1,n-2):
    list_A[i] = min(B[i],B[i+1])

print(list_A)
print(sum(list_A))




Failing test case input:
2
-15

Expected output:
-30


Actual output:
[-15, -15]
-30


Fixed submission (verdict: Accepted):
n = int(input())
B = list(map(int,(input().split())))

list_A = [0]*n

list_A[0] = B[0]
list_A[n-1] = B[n-2]
for i in range(1,n-1):
    list_A[i] = min(B[i-1],B[i])

print(sum(list_A))
Problem: p02917
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n=int(input())
b=input()

b=b.split()

b=list(map(int,b))
a=list()
a.append(b[0])
a.append(b[0])
for i in range(1,len(b)-1):
    
    
    a.append(min(b[i],b[i+1]))
if(n>2):
    a.append(max(b[len(b)-1],a[len(a)-1]))
sum=0 
for i in range(len(a)):
    sum+=a[i]
print(sum)


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

Expected output:
-7


Actual output:
-5


Fixed submission (verdict: Accepted):

n=int(input())
b=input()

b=b.split()

b=list(map(int,b))
a=list()
a.append(b[0])

for i in range(1,len(b)):
    
    
    a.append(min(b[i],b[i-1]))
if(n>2):
    a.append(b[len(b)-1])
if(n==2):
    a.append(b[0])
sum=0 
for i in range(len(a)):
    sum+=a[i]
print(sum)

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

A=[0 for i in range(N)] 
A[0]=B[0]
A[N-2]=min(B[N-2],B[N-3])
A[N-1]=B[N-2]

for i in range(1,N-2):
  A[i] = min(B[i-1],B[i],B[i+1])
  
print(sum(A))

Failing test case input:
6
0 164 10 7 26

Expected output:
50


Actual output:
47


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

A=[0 for i in range(N)] 
A[0]=B[0]
A[N-1]=B[N-2]
if N > 2:
  for i in range(1,N-1):
    A[i] = min(B[i-1],B[i])
  
print(sum(A))

Problem: p02917
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
b = list(map(int, input().split()))

sum = b[0]*2
if n >= 4:
    for i in range(n-2):
        if b[i] > b[i+1]:
            b[i] = b[i+1]
        sum += b[i]

sum += b[-1]
print(sum)


Failing test case input:
2
-427

Expected output:
-854


Actual output:
-1281


Fixed submission (verdict: Accepted):
n = int(input())
b = list(map(int, input().split()))

a = [0]*n
a[0] = b[0]
a[-1] = b[-1]
for i in range(n-2):
    if b[i] > b[i+1]:
        b[i] = b[i+1]
    a[i+1] = b[i]

print(sum(a))

Problem: p02917
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
b_list = [int(i) for i in input().split()]
a_list = [0] * n
before_val = 0
for i in range(n-1):
    target = b_list[i]
    if a_list[i] == before_val:
        a_list[i], a_list[i+1] = b_list[i], b_list[i]
    else:
        a_list[i+1] = b_list[i]
print(sum(a_list))

Failing test case input:
3
0 88

Expected output:
88


Actual output:
176


Fixed submission (verdict: Accepted):
n = int(input())
b_list = [int(i) for i in input().split()]
a_list = [0] * n
before_val = 0
for i in range(n-1):
    target = b_list[i]
    if i == 0:
        a_list[i], a_list[i+1] = target, target
    elif before_val >= target:
        a_list[i], a_list[i+1] = target, target
    else:
        a_list[i], a_list[i+1] = before_val, target
    before_val = target
print(sum(a_list))
Problem: p02917
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

 
N = int(input())

B = [int(e) for e in input().split()]

A = [0] * N
A[N - 1] = B[N - 2]
A[N - 2] = B[N -2]


for i in reversed(range(0, N - 1)):
	A[i] = min(A[i], B[i - 1])
	A[i - 1] = B[i - 1]


print(sum(A))


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

Expected output:
-7


Actual output:
-8


Fixed submission (verdict: Accepted):

 
N = int(input())

B = [int(e) for e in input().split()]

A = [0] * N

A[0] = B[0]
A[1] = B[0]

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

print(sum(A))
Problem: p03078
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

AB = []
for a in A:
    for b in B:
        AB.append(a+b)
AB.sort(reverse=True)

AB = AB[:K]
C.sort(reverse=True)
ABC = []
i = 0
for ab in AB:
    if i >= K: break
    for c in C:
        ABC.append(ab+c)
        i += 1

ABC.sort(reverse=True)

for i in range(K): print(ABC[i])

Failing test case input:
10 10 10 20
7467038376 5724769290 292794712 2843504496 3381970101 14107954240 249131806 11770255275 2323224880 6082257488
1873977926 2576529623 1479553652 1379118507 6003234687 4925540914 3902539811 3326692703 233755778 2877436338
4975681328 8700180183 2882263257 4734915691 514305523 6679823484 3306606453 585966808 3752282379 620585736

Expected output:
28811369110
27733675337
26791012411
26710674234
26473670145
26134827126
25713318638
25685570761
25395976372
25384664046
25086870255
24846104618
24690317535
24682112349
24453313446
24372975269
24287688075
24187252930
24114470427
24009176482


Actual output:
28811369110
27733675337
26791012411
25713318638
25086870255
24846104618
24009176482
23863471306
23768410845
23417795380
22993452184
22785777533
22340101607
21915758411
20731774663
20697155735
20625494450
19654080890
19619461962
19547800677


Fixed submission (verdict: Accepted):
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ans = []
for i in range(X):
    for j in range(Y):
        for k in range(Z):
            if (i+1)*(j+1)*(k+1) <= K: ans.append(A[i]+B[j]+C[k])
            else: break
ans.sort(reverse=True)
for i in range(K): print(ans[i])
Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

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

cnt = 0
for i in range(1,min(a,b)+1):
  if a%i == 0 and b%i == 0:
    cnt+=1
    if cnt == k:
      print(k)
      break


Failing test case input:
33 11 1

Expected output:
11


Actual output:
1


Fixed submission (verdict: Accepted):

def gcd(a,b):
    if b == 0:return a
    return gcd(b,a%b)

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

g = gcd(a,b)

cnt = 0
for i in range(g,0,-1):
  if a%i == 0 and b%i == 0:
    
    cnt+=1
    if cnt == k:
      print(i)
      break

Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=[0,0]
s=[]
a[0],a[1],k=map(int,input().split())
for i in range(1,max(a)+1):
  if a[0]%i==0 and a[1]%i==0:
    s.append(i)
print(s[k-1])

Failing test case input:
51 18 1

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
a=[0,0]
s=[]
a[0],a[1],k=map(int,input().split())
for i in range(1,min(a)+1):
  if a[0]%i==0 and a[1]%i==0:
    s.append(i)
print(s[len(s)-k])

Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,k=map(int,input().split())
temp=[]
for i in range(1,min(a,b)+1):
  if a%i==0 and b%i==0:
    temp.append(i)
print(temp[k-1])
  

Failing test case input:
110 50 2

Expected output:
5


Actual output:
2


Fixed submission (verdict: Accepted):
a,b,k=map(int,input().split())
temp=[]
for i in range(1,min(a,b)+1):
  if a%i==0 and b%i==0:
    temp.append(i)
print(temp[len(temp)-k])

Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A,B,K=(int(x) for x in input().split())

val = 1
lcnt = 0
while True:
  if A % val == 0 and B % val == 0:
    lcnt += 1
  if lcnt == K:
    break
  val += 1
print(val)

Failing test case input:
51 12 2

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
A,B,K=(int(x) for x in input().split())

val = 1
valSet = []
while True:
  if A % val == 0 and B % val == 0:
    valSet.append(val)
  val += 1
  if val > min(A, B):
    break
print(valSet[-1*K])

Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, K = [int(i) for i in input().split()]
tmp = []
for j in range(1, 101):
    if A % j == 0 and B % j == 0:
        tmp.append(j)
print(tmp[K - 1])

Failing test case input:
28 22 2

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
A, B, K = [int(i) for i in input().split()]
tmp = []
for j in range(1, 101):
    if A % j == 0 and B % j == 0:
        tmp.append(j)
tmp = tmp[::-1]
print(tmp[K - 1])
Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,c= input().split()
x,y,z=(int(a),int(b),int(c))
ans_list =[]
for i in range(min(x,y)):
    
    if x % (i+1) == 0 and y % (i+1) == 0:
        ans_list.append(i+1)
        print(ans_list)
print(ans_list[len(ans_list)-z])

Failing test case input:
189 63 1

Expected output:
63


Actual output:
[1]
[1, 3]
[1, 3, 7]
[1, 3, 7, 9]
[1, 3, 7, 9, 21]
[1, 3, 7, 9, 21, 63]
63


Fixed submission (verdict: Accepted):
a,b,c= input().split()
x,y,z=(int(a),int(b),int(c))
ans_list =[]
for i in range(min(x,y)):
    
    if x % (i+1) == 0 and y % (i+1) == 0:
        ans_list.append(i+1)
print(ans_list[len(ans_list)-z])

Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, K = map(int, input().split())

max_num = max(A, B)
count = 0

for i in range(max_num, 0, -1):
    if A % i == 0 and B % i == 0:
        count += 1
        if count == K:
            break


Failing test case input:
27 25 1

Expected output:
1


Actual output:

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

max_num = max(A, B)
count = 0

for i in range(max_num, 0, -1):
    if A % i == 0 and B % i == 0:
        count += 1
        if count == K:
            print(i)
            break

Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,k = map(int,input().split())



c = 0
ans = 0
for i in range(min(a,b),1,-1):
  if(a%i == 0 and b%i == 0):
    c += 1
    print(i)
    if(c == k):
      ans = i
      break

print(ans)

Failing test case input:
27 25 1

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
a,b,k = map(int,input().split())



c = 0
ans = 0
for i in range(min(a,b),0,-1):
  if(a%i == 0 and b%i == 0):
    c += 1
    if(c == k):
      ans = i
      break

print(ans)

Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = list(map(int, input().split()))
num1 = a[0]
num2 = a[1]
list1 = []
list2 = []
max = a[2]
for i in range(1, num1 + 1):
  if num1 % i == 0:
    list1.append(i)
    
for i in range(1, num2 + 1):
  if num2 % i == 0:
    list2.append(i)

list3 = list(set(list1) & set(list2))
list3.sort()

print(list3[max -1])

Failing test case input:
27 18 1

Expected output:
9


Actual output:
1


Fixed submission (verdict: Accepted):
a = list(map(int, input().split()))
num1 = a[0]
num2 = a[1]
list1 = []
list2 = []
max = a[2]
for i in range(1, num1 + 1):
  if num1 % i == 0:
    list1.append(i)
    
for i in range(1, num2 + 1):
  if num2 % i == 0:
    list2.append(i)

list3 = list(set(list1) & set(list2))
list3.sort()
list3.reverse()

print(list3[max -1])

Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, K = map(int,input().split())

count = 0

for i in range(1, min(A, B) + 1, 1):
  if A % i and B % i:
    count += 1
    
  if count == K:
    print(i)

Failing test case input:
100 70 3

Expected output:
2


Actual output:
8


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

count = []

for i in range(1, min(A, B) + 1, 1):
  if (A % i == 0) and (B % i == 0):
    count.append(i)

count.sort(reverse = True)
print(count[K - 1])
Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,k=list(map(int,input().split()))
cnt=1
for i in range(1,min(a,b)+1):
  if a%i==0 and b%i==0:
    if cnt==k:
      print(i)
      break
    cnt+=1

Failing test case input:
27 12 2

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
a,b,k=list(map(int,input().split()))
ans=[]
for i in range(1,min(a,b)+1):
  if a%i==0 and b%i==0:
    ans.append(i)
print(ans[-k])

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

a, b, k = map(int, sys.stdin.readline().split())
m = min(a, b)+1
cnt = 0
for i in range(1, m):
    if a % i == 0 and b % i == 0:
        cnt += 1
        if cnt == k:
            print(i)
            break


Failing test case input:
27 21 1

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
import sys

a, b, k = map(int, sys.stdin.readline().split())
m = min(a, b) + 1
anslist = []
cnt = 0
for i in range(1, m):
    if a % i == 0 and b % i == 0:
        anslist.append(i)
anslist.reverse()
print(anslist[k-1])

Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%i == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

Failing test case input:
72 63 2

Expected output:
3


Actual output:

Fixed submission (verdict: Accepted):
a, b, k = map(int, input().split())
da = []
db = []
dc = []
for i in range(1,a+1):
    if a%i == 0:
    	da.append(i)

for j in range(1, b+1):
    if b%j == 0:
    	db.append(j)

for l in da:
    if l in db:
    	dc.append(l)

dc.sort(reverse = True)
print(dc[k-1])

Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, k = map(int, input().split())
l = []

for i in range((min(a,b))):
    if a%(i+1)==0 and b%(i+1)==0:
        l.append(i+1)

print(l[k-1])

Failing test case input:
100 50 5

Expected output:
2


Actual output:
25


Fixed submission (verdict: Accepted):
a, b, k = map(int, input().split())
l = []

for i in range((min(a,b))):
    if a%(i+1)==0 and b%(i+1)==0:
        l.append(i+1)
l.sort(reverse=True)
print(l[k-1])

Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,k=map(int,input().split())
numlst=[]
for i in range(max(a,b)):
    if a%(i+1)==0 and b%(i+1)==0:
        numlst.append(i+1)
print(numlst)
print(numlst[len(numlst)-k])

Failing test case input:
33 26 1

Expected output:
1


Actual output:
[1]
1


Fixed submission (verdict: Accepted):
a,b,k=map(int,input().split())
numlst=[]
for i in range(max(a,b)):
    if a%(i+1)==0 and b%(i+1)==0:
        numlst.append(i+1)

print(numlst[len(numlst)-k])
Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A, B, K=map(int, input().split())
if A>B:
    tmp=A
    A=B
    B=tmp
count=0
for i in range(1,A+1):
    if A%i ==0 & B%i==0:
        count+=1
    if count ==K:
        break
print(i)

Failing test case input:
27 72 1

Expected output:
9


Actual output:
1


Fixed submission (verdict: Accepted):
A, B, K=map(int, input().split())
if A>B:
    tmp=A
    A=B
    B=tmp
count=0
for i in range(A, 0, -1):
    if A%i ==0 and B%i==0:
        count+=1
    if count ==K:
        break
print(i)

Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, n = map(int, input().split())
 
num = min(a, b)
answer = []
for i in range(1, num+1):
    if (a % i == 0 and b % i == 0):
        answer.append(i)
        
print(answer[n-1])

Failing test case input:
19 114 1

Expected output:
19


Actual output:
1


Fixed submission (verdict: Accepted):
a, b, k = map(int, input().split())
 
num = min(a, b)
answer = []
for i in range(1, num+1):
    if (a % i == 0 and b % i == 0):
        answer.append(i)
        
print(answer[-k])

Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a,b,k=map(int, input().split())
cnt=1
for i in range(1,max(a,b)+1):
    if a%i==0 and b%i==0:
        cnt+=1
        if cnt==k:
            print(i)

Failing test case input:
16 12 2

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
a,b,k=map(int, input().split())
cnt=0
for i in range(min(a,b)+1,0,-1):
    if a%i==0 and b%i==0:
        cnt+=1
        if cnt==k:
            print(i)

Problem: p03106
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a, b, k = map(int, input().split())

n = 0
cd_list = []

if a < b:
  n = a
else:
  n = b

i = 1

while i <= n:
  if a % i == 0 and b % i == 0:
    cd_list.append(i)
  i += 1

print(cd_list[k-1])
  

Failing test case input:
100 44 3

Expected output:
1


Actual output:
4


Fixed submission (verdict: Accepted):
a, b, k = map(int, input().split())

n = 0
if a < b:
  n = a
else:
  n = b

cd_list = []
i = 1
while i <= n:
  if a % i == 0 and b % i == 0:
    cd_list.append(i)
  i += 1

cd_list.reverse()
print(cd_list[k-1])

Problem: p03106
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
a,b,k=map(int,input().split())
res=[]
for i in range(1,min(a,b)+1):
    if a%i==0 and b%i==0:
        res.append(i)
print(res[k-1])

Failing test case input:
4 8 1

Expected output:
4


Actual output:
1


Fixed submission (verdict: Accepted):
a,b,k=map(int,input().split())
res=[]
for i in range(1,min(a,b)+1):
    if a%i==0 and b%i==0:
        res.append(i)
print(res[-k])
Problem: p03546
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h,w=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(10)]
for i in range(10):
  for j in range(10):
    for k in range(10):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
ans=0
for _ in range(h):
  arr=list(map(int,input().split()))
  for i in range(w):
    if arr[i]==-1:
      continue
    elif arr[i]==1:
      continue
    else:
      ans+=d[arr[i]][1]
print(ans)

Failing test case input:
3 5
0 4 3 6 2 7 2 5 3 0
4 0 5 3 12 5 3 7 2 11
5 7 0 7 0 18 1 2 9 0
3 0 2 0 2 7 6 4 2 3
3 5 7 0 0 6 1 7 6 7
9 8 5 2 2 0 2 7 6 10
5 4 6 3 2 3 0 5 1 0
3 6 0 0 4 2 4 0 11 9
4 6 5 5 3 5 3 2 0 8
3 1 3 4 5 7 8 6 4 0
-1 5 2 6 1
2 5 4 2 1
8 9 2 6 6

Expected output:
10


Actual output:
14


Fixed submission (verdict: Accepted):
h,w=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(10)]
for k in range(10):
  for i in range(10):
    for j in range(10):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
ans=0
for _ in range(h):
  arr=list(map(int,input().split()))
  for i in arr:
    if abs(i)!=1:
      ans+=d[i][1]
print(ans)

Problem: p03546
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h,w=map(int,input().split())
c=[]
for i in range(10):
	c.append(list(map(int,input().split())))
a=[]
ans=0
for i in range(h):
	a.append(list(map(int,input().split())))
for i in range(10):
	for j in range(10):
		for k in range(10):
			c[i][j]=min(c[i][j],c[i][k]+c[k][j])
for j in range(h):
	for k in range(w):
		if a[j][k]==-1 or a[j][k]==1:
			continue
		else:
			ans+=c[a[j][k]][1]
print(ans)
					

Failing test case input:
3 5
0 4 3 6 2 7 2 5 3 0
4 0 5 3 12 5 3 7 2 11
5 7 0 7 0 18 1 2 9 0
3 0 2 0 2 7 6 4 2 3
3 5 7 0 0 6 1 7 6 7
9 8 5 2 2 0 2 7 6 10
5 4 6 3 2 3 0 5 1 3
3 6 2 0 4 2 4 0 8 9
4 6 5 4 3 5 3 2 0 8
3 1 3 4 5 7 8 6 4 0
-1 5 2 6 1
2 5 4 2 1
8 9 2 6 6

Expected output:
13


Actual output:
17


Fixed submission (verdict: Accepted):
h,w=map(int,input().split())
c=[]
for i in range(10):
	c.append(list(map(int,input().split())))
a=[]
ans=0
for i in range(h):
	a.append(list(map(int,input().split())))
for i in range(10):
    for j in range(10):
        for k in range(10):
            c[j][k]=min(c[j][k],c[j][i]+c[i][k])
for j in range(h):
	for k in range(w):
		if a[j][k]==-1:
			continue
		else:
			ans+=c[a[j][k]][1]
print(ans)
Problem: p03546
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
H,W=map(int,input().split())

A=[]
for i in range(10):
    B=list(map(int,input().split()))
    A.append(B)


for a in range(10):
    for b in range(10):
        for c in range(10):
            A[a][b]=min(A[a][b],A[a][c]+A[c][b])

ans=0
D=[]
for j in range(H):
    C=list(map(int,input().split()))
    D.append(C)
        
for k in range(H):
    for l in range(W):
        if D[k][l]!=(-1):
            ans+=A[D[k][l]][1]
print(ans)

Failing test case input:
3 5
0 4 3 6 2 7 2 5 3 0
4 0 5 3 12 5 3 7 2 11
5 7 0 7 0 18 1 2 9 0
3 0 2 0 2 7 6 4 2 3
3 5 7 0 0 6 9 7 6 7
9 8 5 2 2 0 4 7 6 5
0 4 6 3 2 3 0 5 2 3
3 6 2 0 4 2 4 0 8 9
4 6 5 4 3 5 3 2 0 8
3 1 3 4 5 7 8 6 4 0
-1 5 2 6 1
2 5 3 2 1
6 9 2 6 6

Expected output:
9


Actual output:
13


Fixed submission (verdict: Accepted):
H,W=map(int,input().split())

A = [list(map(int, input().split())) for _ in range(10)]

for a in range(10):
    for b in range(10):
        for c in range(10):
            A[b][c]=min(A[b][c],A[b][a]+A[a][c])

ans=0
D=[]
for j in range(H):
    C=list(map(int,input().split()))
    D.append(C)
        
for k in range(H):
    for l in range(W):
        if D[k][l]!=(-1) and D[k][l]!=(1):
            ans+=A[D[k][l]][1]
print(ans)

Problem: p03546
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
H, W=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(10)]
a=[list(map(int,input().split())) for _ in range(H)]
ans=0

for i in range(10):
    for j in range(10):
        for k in range(10):
            c[i][j]=min(c[i][j],c[i][k]+c[k][j])

for i in range(H):
    for j in range(W):
        if a[i][j]>=0:
            ans += c[a[i][j]][1]

print(ans)

Failing test case input:
3 5
0 4 3 6 2 7 2 5 3 0
4 0 5 3 12 5 3 7 2 11
5 7 0 7 0 18 1 2 9 0
3 0 2 0 2 7 6 4 2 3
3 5 7 0 0 6 9 7 6 7
9 8 5 2 2 0 4 7 6 5
5 4 6 3 2 3 0 5 4 3
3 6 2 0 4 2 4 0 8 9
4 6 5 4 3 5 3 2 0 8
2 1 3 4 5 7 8 6 4 0
-1 5 2 6 1
2 5 3 2 1
6 9 2 6 6

Expected output:
13


Actual output:
17


Fixed submission (verdict: Accepted):
H, W=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(10)]
a=[list(map(int,input().split())) for _ in range(H)]
ans=0

for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j]=min(c[i][j],c[i][k]+c[k][j])

for i in range(H):
    for j in range(W):
        if a[i][j]>=0:
            ans += c[a[i][j]][1]

print(ans)