Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03088 (python)

Fixed submission:
N = int(input())

modd = 1000000007
dp = [[[[0 for k in range(4)] for i in range(4) ]for j in range(4) ]for n in range(N+1)]

dp[0][3][3][3] = 1


for L in range(N):
    for i in range(4):
        
        for j in range(4):
        
            for k in range(4):
                if (dp[L][i][j][k]==0): continue
                for a in range(4):
                    if (a == 2 and i == 1 and j == 0):    continue
                    if (a == 2 and i == 0 and j == 1):    continue
                    if (a == 1 and i == 2 and j == 0):    continue
                    if (a == 2 and i == 1 and k == 0):    continue
                    if (a == 2 and j == 1 and k == 0):    continue
                    
                    dp[L+1][a][i][j] += dp[L][i][j][k]
                    dp[L+1][a][i][j] %= modd
  
ans = 0         
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans += dp[N][i][j][k]
            ans %= modd
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())

modd = 1000_000_007
dp = [[[[0 for k in range(4)] for i in range(4) ]for j in range(4) ]for n in range(N+1)]

dp[0][3][3][3] = 1


for L in range(N):
    for i in range(4):
        
        for j in range(4):
        
            for k in range(4):
                if (dp[L][i][j][k]==0): continue
                for a in range(4):
                    if (a == 2 and i == 1 and j == 0):    continue
                    if (a == 2 and i == 0 and j == 1):    continue
                    if (a == 1 and i == 2 and j == 0):    continue
                    if (a == 2 and i == 1 and k == 0):    continue
                    if (a == 2 and j == 1 and k == 0):    continue
                    
                    dp[L+1][a][i][j] += dp[L][i][j][k]
                    dp[L+1][a][i][j] %= modd
  
ans = 0         
for i in range(4):
    for j in range(4):
        for k in range(4):
            ans += dp[N][i][j][k]
            ans %= modd
print(ans)
Problem p03126 (python)

Fixed submission:
N,M = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
like = [0] * M

for i in range(N):
    for j in range(A[i][0]):
        like[A[i][j+1]-1] += 1
        
cnt = 0
for i in range(M):
    if like[i] == N:
        cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = [list(map(int,input.split())) for _ in range(N)]

like = [0] * M

for i in range(N):
    for j in range(A[i][0]):
        like[A[i][j+1]] += 1
        
cnt = 0
for i in range(M):
    if like[i] == M:
        cnt += 1

print(cnt)
Problem p03160 (python)

Fixed submission:
N = int(input())
h = list(map(int,input().split()))

dp = [0] * 100010

dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,N):
    dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]) 
    
print(dp[N-1])

Buggy submission (verdict: Runtime Error):

N = int(input())
H = list(map(int,input().split()))
inf = 10**9+7
dp = [inf] * (N+10)
import numpy as np
for i,h in enumerate(H[:N-1]):
    dp[i+1] = min(dp[i+1],dp[i] + np.abs(h[i]-h[i+1]))
    if i<N-2: dp[i+2] = min(dp[i+2],dp[i] + np.abs(h[i]-h[i+2]))
    
print(dp[N-1])

Buggy submission (verdict: Runtime Error):

N = int(input())
H = list(map(int,input().split()))
inf = 10**9+7
dp = [inf] * (N+10)
import numpy as np
for i,h in enumerate(H[:N-1]):
    dp[i+1] = min(dp[i+1],dp[i] + np.abs(h[i]-h[i+1]))
    if i>N-2: dp[i+2] = min(dp[i+2],dp[i] + np.abs(h[i]-h[i+2]))
    
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
h = list(map(int,input().split()))

dp = [0] * 10010

dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,N):
    dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]) 
    
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
h = list(map(int,input().split()))

dp = [0] * 1010

dp[0] = 0
dp[1] = abs(h[1]-h[0])

for i in range(2,N):
    dp[i] = min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]) 
    
print(dp[N-1])
Problem p03161 (python)

Fixed submission:
#import sys 
#input = sys.stdin.readline

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

dp = [0] * 100010

dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,min(K,N)):
    Minimum = dp[i-1]+abs(h[i]-h[i-1])
    for j in range(2,i+1):
        Minimum = min(dp[i-j]+abs(h[i]-h[i-j]),Minimum)
    dp[i] = Minimum
if N > K:
    if K == 1:
        for i in range(K,N):
            Minimum = dp[i-1]+abs(h[i]-h[i-1])
            dp[i] = Minimum
        
    else:
        for i in range(K,N):
            Minimum = dp[i-1]+abs(h[i]-h[i-1])
            for (j,k) in zip(dp[i-K:i-1],h[i-K:i-1]):
                Minimum = min(j+abs(h[i]-k),Minimum)
            dp[i] = Minimum
        
print(dp[N-1])

Buggy submission (verdict: Runtime Error):

N,K = map(int,input().split())
H = list(map(int,input().split()))
inf = 10**9+7
dp = [inf] * (N+10)
dp[0] = 0
import numpy as np

for i,h in enumerate(H):
    for j in range(1,K+1):
        if i+j < N:
            dp[i+j] = min(dp[i+j],dp[i] + np.abs(h-H[i+j]))

print(dp[N-1])
Problem p03274 (python)

Fixed submission:
N,K = map(int,input().split())
x = list(map(int,input().split()))

xp = []
xn = []
for i in x:
    if i >= 0:
        xp += [i]
    else:
        xn += [abs(i)]
    
xn.sort()
pl = len(xp)
pn = len(xn)

ans = 2 ** 30

for i in range(pl):
    if K-2-i < pn:
        if K-2-i >= 0:
            tmp = xp[i] * 2 + xn[K-2-i]
        elif i == K-1:
            tmp = xp[i] 
    else:
        continue
    ans = min(ans,tmp)


for i in range(pn):
    if K-2-i < pl:        
        if K-2-i >= 0:
            tmp = xn[i] * 2 + xp[K-2-i]
        elif i == K-1:
            tmp = xn[i]
    else:
        continue
    ans = min(ans,tmp)

print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
x = list(map(int,input().split()))

xp = []
xn = []
for i in x:
    if i >= 0:
        xp += [i]
    else:
        xn += [abs(i)]
    
xn.sort()
pl = len(xp)
pn = len(xn)

ans = 2 ** 30

for i in range(pl):
    if K-2-i < pn:
        if K-2-i >= 0:
            tmp = xp[i] * 2 + xn[K-2-i]
        else:
            tmp = xp[i] 
    ans = min(ans,tmp)


for i in range(pn):
    if K-2-i < pl:        
        if K-2-i >= 0:
            tmp = xn[i] * 2 + xp[K-2-i]
        else:
            tmp = xn[i]
        
    ans = min(ans,tmp)

print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
x = list(map(int,input().split()))

xp = []
xn = []
for i in x:
    if i >= 0:
        xp += [i]
    else:
        xn += [abs(i)]
    
xn.sort()
pl = len(xp)
pn = len(xn)

ans = 2 ** 30

for i in range(K):
    if i < pl and K-2-i < pn :
        if K-2-i >= 0:
            tmp = xp[i] * 2 + xn[K-2-i]
        else:
            tmp = xp[i] 
    ans = min(ans,tmp)


for i in range(K):
    if i < pn and K-2-i < pl and K-2-i >= 0:        
        if K-2-i >= 0:
            tmp = xn[i] * 2 + xp[K-2-i]
        else:
            tmp = xn[i]
        
    ans = min(ans,tmp)

print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
x = list(map(int,input().split()))

xp = []
xn = []
for i in x:
    if i >= 0:
        xp += [i]
    else:
        xn += [abs(i)]
    
xn.sort()
pl = len(xp)
pn = len(xn)

ans = 2 ** 31 - 1

for i in range(K):
    if i < pl and K-2-i < pn :
        if K-2-i >= 0:
            tmp = xp[i] * 2 + xn[K-2-i]
        else:
            tmp = xp[i] 
    ans = min(ans,tmp)


for i in range(K):
    if i < pn and K-2-i < pl and K-2-i >= 0:        
        if K-2-i >= 0:
            tmp = xn[i] * 2 + xp[K-2-i]
        else:
            tmp = xn[i]
        
    ans = min(ans,tmp)

print(ans)
Problem p03294 (python)

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

def GCD(a,b):
    c = a%b
    if c == 0:
        return b
    else:
        return GCD(b,c)


def modsum(m):
    s = 0
    for a in A:
        s += m % a
    return s


tmp = 1
for i in range(N):
    tmp = tmp * A[i] // GCD(tmp,A[i])
    
ans = modsum(tmp-1)
print(ans)

Buggy submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
abc = [A,B,C]
Even = []
Odd = []
for i in range(3):
    if min(abc) == abc[i]:
        idx1 = i
    elif max(abc) == abc[i]:
        idx3 = i
    else:
        idx2 = i
    if abc[i]%2 == 0:
       Even += [i]
    else:
       Odd += [i]
       
ans = 0

if len(Even) == 3 or len(Odd) == 3:
    ans = (abc[idx3]-abc[idx2])//2 + (abc[idx3]-abc[idx1])//2
elif len(Even) == 2:
    ans += 1
    abc[Even[0]] += 1
    abc[Even[1]] += 1
    ans += (abc[idx3]-abc[idx2])//2 + (abc[idx3]-abc[idx1])//2
elif len(Odd) == 2:
    ans += 1
    abc[Odd[0]] += 1
    abc[Odd[1]] += 1
    ans += (abc[idx3]-abc[idx2])//2 + (abc[idx3]-abc[idx1])//2
    
print(ans)
Problem p03341 (python)

Fixed submission:
N = int(input())
S = input()

East = [0] * N
West = [0] * N

for i,s in enumerate(list(S)):
    if s == 'W' : 
        if i==0:
            East[i] = 1
        else:
            East[i] = East[i-1] + 1
    else:
        if i == 0:
            East[i] = 0
        else:
            East[i] = East[i-1]
i = N-1
for s in reversed((list(S))):
    if s == 'E' : 
        if i==N-1:
            West[i] = 1
        else:
            West[i] = West[i+1] + 1
    else:
        if i == N-1:
            West[i] = 0
        else:
            West[i] = West[i+1]
    i -= 1
            
ans = 2**31-1

for i in range(N):
    if i == 1:
        ans2 = West[1]
    elif i == N-1:
        ans2 = East[N-2]
    else:
        ans2 = East[i-1]+West[i+1]
    ans = min(ans,ans2)
    
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()

East = [0] * N
West = [0] * N

for i,s in enumerate(list(S)):
    if s == 'W' : 
        if i==0:
            East[i] = 1
        else:
            East[i] = East[i-1] + 1
    else:
        East[i] = East[i-1]
i = N-1
for s in reversed((list(S))):
    if s == 'E' : 
        if i==N-1:
            West[i] = 1
        else:
            West[i] = West[i+1] + 1
    else:
        West[i] = West[i+1]
    i -= 1
            
ans = 2**31-1

for i in range(N):
    if i == 1:
        ans2 = West[1]
    elif i == N-1:
        ans2 = East[N-2]
    else:
        ans2 = East[i-1]+West[i+1]
    ans = min(ans,ans2)
    
print(ans)
Problem p03407 (python)

Fixed submission:
A,B,C = map(int,input().split())
money = A+B
if C>money:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
money = A+B
if C>money:
    print('No')
else:
    print('Yes)
Problem p03435 (python)

Fixed submission:
c = [list(map(int,input().split())) for _ in range(3)]

a = [0] * 3
b = [0] * 3

for i in range(101):
    flag = True
    a[0] = i
    b[0] = c[0][0]-a[0]
    b[1] = c[0][1]-a[0]
    b[2] = c[0][2]-a[0]
    a[1] = c[1][0]-b[0]
    a[2] = c[2][0]-b[0]
    for j in range(1,3):
        for k in range(1,3):
            if a[j] + b[k] != c[j][k]:
                flag = False
                break
        else:continue
        break
    
    if flag:
        break
    
if flag:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):

c = [list(map(int,input().split())) for _ in range(3)]
maxim = max(max(c))
for i in range(maxim):
    for j in range(maxim):
        for k in range(maxim):            
            flag = True
            a = [i,j,k]
            b = [c[0][l]-a[0] for l in range(3)]
            for l in range(1,3):
                for m in range(3):
                    if c[l][m] - a[l] != b[m]:
                        flag = False
                        break
                else:continue
                break  
            else:
                if flag:
                    break
        else:continue
        break
    else:continue
    break
if flag:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
c = [list(map(int,input().split())) for _ in range(3)]
maxim = max(max(c))
for i in range(maxim):
    for j in range(maxim):
        for k in range(maxim):            
            flag = True
            a = [i,j,k]
            b = [c[0][l]-a[0] for l in range(3)]
            for l in range(1,3):
                for m in range(3):
                    btmp = c[l][m] - a[l]
                    if btmp != b[m]:
                        flag = False
                        break
                else:continue
                break                    
            
            if flag:
                break
        else:continue
        break
    else:continue
    break
if flag:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):

c = [list(map(int,input().split())) for _ in range(3)]
maxim = max(max(c))
for i in range(maxim):
    for j in range(maxim):
        for k in range(maxim):            
            flag = True
            a = [i,j,k]
            b = [c[0][l]-a[0] for l in range(3)]
            for l in range(1,3):
                for m in range(3):
                    btmp = c[l][m] - a[l]
                    if btmp != b[m]:
                        flag = False
                        break
                else:continue
                break                    
            
            if flag:
                break
        else:continue
        break
    else:continue
    break
if flag:
    print('Yes')
else:
    print('No')
Problem p03487 (python)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
ans = 0
idx = []
for i,x in enumerate(a):
    if x > 10**5:
        ans += 1
        idx += [i]
for i in reversed(idx):
    del a[i]

import sys
if len(a) == 0:
    print(ans)
    sys.exit()

counts = [0] * (10 ** 5 + 1)

for i in a:
    counts[i] += 1
    
for i in range(len(counts)):
    if counts[i] == 0:continue
    if counts[i] < i:
        ans += counts[i]
    elif counts[i] > i:
        ans += counts[i]-i
        
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(N):
    if a[i] > 10**5:
        ans += 1
        del a[i]
        
import sys
if len(a) == 0:
    print(ans)
    sys.exit()

counts = [0] * (10 ** 5 + 1)

for i in a:
    counts[i] += 1
    
for i in range(len(counts)):
    if counts[i] == 0:continue
    if counts[i] < i:
        ans += counts[i]
    elif counts[i] > i:
        ans += counts[i]-i
        
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(N):
    if a[i] > 10**5:
        ans += 1
        del a[i]
        
import sys
if len(a) == 0:
    print(ans)
    sys.exit()

counts = [0] * (10 ** 5 + 1)

for i in a:
    counts[a] += 1
    
for i in range(len(counts)):
    if counts[i] == 0:continue
    if counts[i] < i:
        ans += counts[i]
    elif counts[i] > i:
        ans += counts[i]-i
        
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(N):
    if a[i] > 10**5+1:
        del a[i]
        ans += 1
        
counts = [0] * (10 ** 5 + 1)

for i in range(len(a)):
    counts[a[i]] += 1
    
for i in range(1,len(counts)):
    if counts[i] == 0:continue
    if counts[i] < i:
        ans += counts[i]
    elif counts[i] > i:
        ans += counts[i]-i
        
print(ans)
Problem p03495 (python)

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

nlist = [0] * N
for i in A:
    nlist[i-1] += 1

nlist.sort(reverse = True)
cnt = 0
for i in range(K,N):
    if nlist[i] == 0: break
    cnt += nlist[i]

print(cnt)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = list(map(int,input().split()))

nlist = [0] * N
for i in A:
    nlist[i] += 1

nlist.sort(reverse = True)
cnt = 0
for i in range(K,N):
    if nlist[i] == 0: break
    cnt += nlist[i]

print(cnt)
Problem p03525 (python)

Fixed submission:
N = int(input())
D = list(map(int,input().split()))

T = [0]*13
T[0] = 1
for d in D:
    T[d] += 1


Times = [0]*24
ones =[]
for i,t in enumerate(T):
    if t>=3 or (t==2 and (i==0 or i==12)):
        print(0)
        exit()
    elif t==2:
        Times[i] = 1
        Times[24-i] = 1
    elif t==1:
        ones.append(i)

ans = 0
L = len(ones)
for i in range(2**L):
    stats = [False]*L
    temp = i
    for j in range(L):
        stats[j] = temp&1
        temp >>= 1
    
    newTime = [t for t in Times]
    res = 10**9
    for j,t in enumerate(ones):
        nt = t if stats[j] else (24-t)%24
        newTime[nt] = 1
    
    gaps = []
    for j,t in enumerate(newTime):
        if t!=0:
            gaps.append(j)
    for j in range(len(gaps)-1):
        res = min(res,min(gaps[j+1]-gaps[j],gaps[j]+24-gaps[j+1]))
    if len(gaps)>=2:
        res = min(res, gaps[0]+24-gaps[-1])
    ans = max(ans, res)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
D = list(map(int,input().split()))

T = [0]*13
T[0] = 1
for d in D:
    T[d] += 1


Times = [0]*24
ones =[]
for i,t in enumerate(T):
    if t>=3 or t==2 and (i==0 or i==12):
        print(0)
        exit()
    elif t==2:
        Times[i] = 1
        Times[24-i] = 1
    elif t==1:
        ones.append(i)

ans = 0
L = len(ones)
for i in range(2**L):
    stats = [False]*L
    temp = i
    for j in range(L):
        stats[j] = temp&1
        temp >>= 1
    
    newTime = [t for t in Times]
    res = 10**9
    for j,t in enumerate(ones):
        nt = t if stats[j] else 24-t
        newTime[nt] += 1
    
    gaps = []
    for j,t in enumerate(newTime):
        if t==1:
            gaps.append(j)
    for j in range(len(gaps)-1):
        res = min(res,gaps[j+1]-gaps[j])
    if len(gaps)>=2:
        res = min(res, gaps[0]+24-gaps[1])
    ans = max(ans, res)
print(ans)
Problem p03546 (python)

Fixed submission:
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)]

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

ans = 0
for aa in A:
    for a in aa:
        if a!=-1:
           ans += d[a][1]
           
print(ans)

Buggy submission (verdict: Runtime Error):

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)]


inf = 10**9+7

point = [inf] * 10


for i in range(10):
    tmp = 0
    for j in range(10):
        tmp += C[i][j]
        point[i] = min(point[i],tmp+C[j][1])
        
ans = 0
for i in range(H):
    for j in range(W):
        if H[i][j] != -1:
            ans += point[H[i][j]]
            
print(ans)
Problem p03565 (python)

Fixed submission:

S = input()
T = input()
N = len(S)
K = len(T)

ans = []
flag = False
for i in range(N-K+1):
    for j in range(K):
        if not(S[i+j] == T[j] or S[i+j] == '?'):
            break
    else:
        flag = True
        tmp = list(S)
        for j in range(K):
            tmp[i+j] = T[j]
        for j in range(N):
            if tmp[j] == '?': tmp[j] = 'a'
        tmp = ''.join(tmp)
        ans.append(tmp)
        
if flag:
    ans.sort()
    print(ans[0])
else:
    print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
S = list(input())
T = list(input())
#S = list('??p??d??')
#T = list('abc')

Ns = len(S)
Nt = len(T)
flag = True
for i in range(Ns - Nt+1):
    for j in range(Nt):
        if not(S[i+j] == T[j] or S[i+j] == '?'):
            break
    else:
        flag = True
        break

if flag:
    
    ans = S
    for j in range(Nt):
        ans[i+j] = T[j]

    for k in range(Ns):
        if ans[k] == '?':
            ans[k] = 'a'
    ans = ''.join(ans)
else:
    ans = 'UNRESTORABLE'
    
print(ans)

Buggy submission (verdict: Runtime Error):
S = list(input())
T = list(input())
Ns = len(S)
Nt = len(T)
ans = S
flag = True
for i in range(Ns - Nt+1):
    for j in range(Nt):
        if not(S[i+j] == T[i+j] or S[i+j] == '?'):
            break
    else:
        flag = True
        break

if flag:
    for j in range(Nt):
        ans[i+j] = T[j]

    for k in range(Ns):
        if ans[k] == '?':
            ans[k] = 'a'
    ans = ''.join(ans)
else:
    ans = 'UNRESTORABLE'
    
print(ans)
Problem p03583 (python)

Fixed submission:
import sys
N = int(input())

for h in range(1,3501):
    for n in range(1,3501):
        tmp = 4*h*n-N*(h+n)
        if tmp == 0:continue
        if (N*h*n)%(tmp) == 0:
            w = N*h*n // (tmp)
            if w <= 0:continue
            if h*n*w % N == 0:
                print(h,n,w)
                sys.exit()
        
print(-1)

Buggy submission (verdict: Runtime Error):
import sys
N = int(input())

for h in range(1,3501):
    for n in range(1,3501):
        if (N*h*n)%(4*h*n-N*(h+n)) == 0:
            w = N*h*n // (4*h*n-N*(h+n))
            if w <= 0:continue
            if h*n*w % N == 0:
                print(h,n,w)
                sys.exit()
        
print(-1)
Problem p03599 (python)

Fixed submission:
A,B,C,D,E,F = map(int,input().split())
ans = [0,0]
maxconc = -1
for i in range(31):
    for j in range(31):
        water = A*i + B*j
        if 100 * water > F:continue
        loopk = E*water // C + 1
        
        for k in range(loopk):
            loopl = (E*water-C*k)// D + 1
            for l in range(loopl):
                sugar = C*k + D*l
                if 100*water + sugar > F or 100*water + sugar == 0:continue
                if sugar <= water * E:
                    conc = (sugar)/(sugar+100*water)
                    if conc > maxconc:
                        ans = [100*water+sugar,sugar]
                        maxconc = conc
                    
print(*ans)

Buggy submission (verdict: Runtime Error):
A,B,C,D,E,F = map(int,input().split())

maxconc = 0
for i in range(31):
    for j in range(31):
        water = A*i + B*j
        if 100 * water > F:continue
        loopk = E*water // C + 1
        loopl = E*water // D + 1
        
        for k in range(loopk):
            for l in range(loopl):
                sugar = C*k + D*l
                if 100*water + sugar > F or 100*water + sugar == 0:continue
                if sugar <= water * E:
                    conc = (sugar)/(sugar+100*water)
                    if conc > maxconc:
                        ans = [100*water+sugar,sugar]
                        maxconc = conc
                    
print(*ans)

Buggy submission (verdict: Runtime Error):
A,B,C,D,E,F = map(int,input().split())

maxconc = 0
for i in range(31):
    for j in range(31):
        for k in range(31):
            for l in range(31):
                water = A*i + B*j
                sugar = C*k + D*l
                if 100*water + sugar > F or 100*water + sugar == 0:continue
                if sugar <= water * E:
                    conc = (sugar)/(sugar+100*water)
                    if conc > maxconc:
                        ans = [100*water+sugar,sugar]
                        maxconc = conc
                    
print(*ans)

Buggy submission (verdict: Runtime Error):
A,B,C,D,E,F = map(int,input().split())

maxconc = 0
for i in range(31):
    for j in range(31):
        for k in range(31):
            for l in range(31):
                water = A*i + B*j
                sugar = C*k + D*l
                if 100*water + sugar > F or 100*water + sugar == 0:continue
                if sugar <= water * E:
                    conc = (sugar)/(sugar+100*water)
                    if conc > maxconc:
                        ans = [100*water+sugar,sugar]
                        maxconc = conc
                    
print(*ans)
Problem p03612 (python)

Fixed submission:

N = int(input())
P = list(map(int,input().split()))
#PS = [i for i in range(1,N+1)]

cnt = 0
i = 0
while i < N:
    if P[i] == i+1:
        if i < N-1 and P[i+1] == i+2:
            cnt += 1
            i += 1
        else:
            cnt += 1
                   
    i += 1   
print(cnt)

Buggy submission (verdict: Runtime Error):

N = int(input())
P = list(map(int,input().split()))
#PS = [i for i in range(1,N+1)]

cnt = 0
i = 0
idx = []
while i < N:
    if P[i] == i+1:
        if P[i+1] == i+2:
            cnt += 1
            i += 1
        else:
            cnt += 1
                   
    i += 1   
print(cnt)