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

Fixed submission:
import fractions
n=int(input())
a=list(map(int,input().split()))
a=[0]+a+[0]
l=[0]*(n+2)
r=[0]*(n+2)
for i in range(1,n+1):
    l[i]=fractions.gcd(l[i-1],a[i])
for i in range(n,0,-1):
    r[i]=fractions.gcd(r[i+1],a[i])
print(max(fractions.gcd(l[i-1],r[i+1]) for i in range(1,n+1)))

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

def gcd(t1,t2):
    while t2:
        t1,t2=t2,t1%t2
    return t1

if n==2:
    print(max(a))
    exit()

ans=[gcd(a[0],a[1]),gcd(a[0],a[2]),gcd(a[1],a[2])]
ans=list(set(ans))
tmp1=max(ans)
tmp2=tmp1
for i in range(2,n):
    tmp1=gcd(tmp1,a[i])
    if tmp1!=tmp2:
        ans+=[tmp1]
        tmp2=tmp1
ans.sort()
print(ans[1])
Problem p03069 (python)

Fixed submission:
n=int(input())
s=input()
w=s.count('.')
b=0
ans=w
for i in range(n):
    if s[i]=='#':
        b+=1
    else:
        w-=1
    ans=min(ans,w+b)
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
S=S+'9'
ans=0
for i in range(N):
    if S[i]=='#' and S[i+1]=='.':
        cntj=0
        for j in range(i,-1,-1):
            if S[j]=='#':
                cntj+=1
            else:
                break
        cntk=0
        for k in range(i+1,N+1):
            if S[k]=='.':
                cntk+=1
            else:
                break
        if cntj < cntk:
            ans += cntj
            S = S[:i-cntj]+'.'*cntj+S[i+1:]
        else:
            ans += cntk
            S = S[:i]+'#'*cntk+S[i+1+cntk:]
print(ans)
Problem p03078 (python)

Fixed submission:
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()))
e=[]
for ai in a:
    for bi in b:
        e.append(ai+bi)
e.sort(reverse=True)
e=e[:k]
ans=[]
for ci in c:
    for ei in e:
        ans.append(ci+ei)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
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()))

ABl = []
for a in Al:
    for b in Bl:
        ABl.append(a+b)

result = []
ABl = sorted(ABl,reverse=True)[:K]
for ab in ABl:
    for c in Cl:
        result.append(ab+c)

result.sort(reverse=True)

for i in range(K):
    print(result[i])
Problem p03086 (python)

Fixed submission:
S = input()
cnt = 0
max = 0

for str in S:
  if str in {'A', 'C', 'G', 'T'}:
    cnt += 1
  else:
    if max < cnt:
      max = cnt
    cnt = 0
    
if max < cnt:
  max = cnt
  
print(max)

Buggy submission (verdict: Runtime Error):
    S = input()
     
    cnt = 0
    max = 0
    for str in S:
      if str in {'A', 'C', 'G', 'T'}:
        cnt += 1
      else:
        if max < cnt:
          max = cnt
        cnt = 0
     
    print(cnt)
Problem p03126 (python)

Fixed submission:
n,m=map(int,input().split())
ans=[0]*m
for i in range(n):
    a=list(map(int,input().split()))
    for j in range(len(a)):
        if j!=0:
            ans[a[j]-1]+=1
print(ans.count(n))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans=[0]*m
for i in range(n):
    a=list(map(int,input().split()))
    for j in range(len(a)):
        if j!=0:
            ans[a[j-1]]+=1
print(ans.count(n))
Problem p03139 (python)

Fixed submission:
n,a,b=map(int,input().split())
print(min(a,b),max(0,a+b-n))

Buggy submission (verdict: Runtime Error):
n,a,b=map(int,input().split())
print(min(a,b),max(0,a+b-n)))
Problem p03150 (python)

Fixed submission:
s=input()
n=len(s)
for i in range(n):
    for j in range(i,n+1):
        if 'keyence'==s[:i]+s[j:]:
            print('YES')
            exit()
print('NO')

Buggy submission (verdict: Runtime Error):
s=input()
a='keyence'
i=0
f1=False
f2=False
for c in s:
    if c==a[i]:
        f1=False
        i+=1
    else:
        if not f1 and f2:
            print('NO')
            exit()
        else:
            f1=True
            f2=True
if i==7:
    print('YES')
else:
    print('NO')
Problem p03163 (python)

Fixed submission:
n,w=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(n)]
dp=[[0]*(w+1) for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(1,w+1):
        if wv[i-1][0]<=j:
            dp[i][j]=max(dp[i-1][j],dp[i-1][max(0,j-wv[i-1][0])]+wv[i-1][1])
        else:
            dp[i][j]=dp[i-1][j]
print(dp[-1][-1])

Buggy submission (verdict: Runtime Error):
N,W=map(int,input().split())
wv=[list(map(int,input().split())) for _ in range(n)]
dp=[[0 for _ in range(W+1) for _ in range(N+1)]
for i in range(1,N+1):
    for j in range(1,W+1):
        if wv[i-1][0]<=j:
            dp[i][j]=max(dp[i-1][j],dp[i-1][max(0,j-wv[i-1][0])]+wv[i-1][1])
        else:
            dp[i][j]=dp[i-1][j]
print(dp[-1][-1])
Problem p03282 (python)

Fixed submission:
s=input()
k=int(input())
for i in range(min(len(s),k)):
    if int(s[i])>1:
            print(s[i])
            exit()
print(1)

Buggy submission (verdict: Runtime Error):
s=input()
k=input()
if s[0]=='1' or len(s)==1:
    print(s[1])
else:
    for i in s:
        if int(i)>1:
            print(i)

Buggy submission (verdict: Runtime Error):
s=input()
k=input()
if s[0]=='1':
    print(s[1])
else:
    print(s[0])
Problem p03612 (python)

Fixed submission:
n=int(input())
pl=list(map(int,input().split()))
ans=0
for i in range(n):
    if pl[i]==i+1:
        ans+=1
        if i<n-1:
            pl[i+1]=pl[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
pl=list(map(int,input().split()))
ans=0
for i in range(n):
    if pl[i]==i+1:
        ans+=1
        pl[i+1]=pl[i]
print(ans)
Problem p03659 (python)

Fixed submission:
n=int(input())
al=list(map(int,input().split()))
sm=sum(al)
t=0
ans=10**15
for i in range(n-1):
    t+=al[i]
    ans=min(ans,abs(sm-t*2))
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
n=int(input())
al=list(map(int,input().split()))
tl=al[:]
for i in range(1,n):
    tl[i]=(tl[i-1]+tl[i])
ta=bisect.bisect_left(tl,tl[-1]/2)
print(abs(al[ta+1]-al[ta]))
Problem p02657 (python)

Fixed submission:
a, b = map(int, input().split(' '))
print(a*b)

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
        return
    prod = 1
    for i in a:
        prod *= i
        if prod > 1000000000000000000:
            print(-1)
            return
main()

Buggy submission (verdict: Runtime Error):
def main ():
	N = int(input())
	A = list(map(int,input(). split ()))
	if 0 in A:
		print(0)
		return
	prod = 1
	for a in A:
		prod *= a
		if prod > 1000000000000000000:
		print(-1)
		return
	print(prod)
main ()

Buggy submission (verdict: Runtime Error):
def main ():
N = int(input())
A = list(map(int,input(). split ()))
if 0 in A:
print(0)
return
prod = 1
for a in A:
prod *= a
if prod > 1000000000000000000:
print(-1)
return
print(prod)
main ()

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 1
nums = map(int, input().split(' '))
for i in nums:
    ans *= i
if ans > 10**18:
    print(-1)
else:
    print(ans)
Problem p02658 (python)

Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
        return
    prod = 1
    for i in a:
        prod *= i
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
main()

Buggy submission (verdict: Runtime Error):
def main ():
N = int(input())
A = list(map(int,input(). split ()))
if 0 in A:
    print(0)
    return
prod = 1
for a in A:
    prod *= a
    if prod > 1000000000000000000:
        print(-1)
        åçreturn
print(prod)
main ()
Problem p03136 (python)

Fixed submission:
l = input()
n = int(l)
l = input()
a = list(map(int, l.split(' ')))

if max(a) < sum(a)-max(a):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
l = input()
n = int(l)
l = input()
a = list(map(int, input().split(' ')))

if max(a) < sum(a)-max(a):
  print('Yes')
else:
  print('No')
Problem p03200 (python)

Fixed submission:
# -*- coding: utf-8 -*-
def main():
    S = list(input())
    Bcnt = 0
    ans = 0
    for i in range(len(S)):
        if S[i] == 'B':
            Bcnt += 1
        else:
            ans += Bcnt
    print(ans)
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def main():
    S = list(input())
    state = 0
    CNT = 0
    while(state != 1):
    # for x in range(50):
        first_W = 0
        for i in range(len(S)):
            if state == 0:
                if S[i] == 'B':
                    B_cnt = 1
                    state = 1
                else:
                    first_W += 1
            elif state == 1:
                if S[i] == 'B':
                    B_cnt += 1
                else:
                    W_cnt = 1
                    state = 2
            elif state == 2:
                if S[i] == 'W':
                    W_cnt += 1
                else:
                    state = 0
                    break
        # print(state)
        if state == 2:
            state = 0
            S = ['W']*(W_cnt+first_W) + ['B']*B_cnt
        else:
            CNT += W_cnt*B_cnt
            S = ['W']*(W_cnt+first_W) + ['B']*B_cnt + S[i:]
        # print(S)
    print(CNT)
        
if __name__ == '__main__':
    main()

    # S = list(input())
    # check = 0
    # cnt = 0
    # i = 0
    # while(check == 0) :
    #     check = 1
    #     for i in range(len(S)-1):
    #         if S[i] == 'B' and S[i+1] == 'W':
    #             S[i], S[i+1] = 'W', 'B'
    #             cnt += 1
    #             check = 0
    #             break
    # print(cnt)
Problem p02630 (python)

Fixed submission:
import collections
n = int(input())
a = list(map(int,input().split()))
q = int(input())
l = [list(map(int,input().split())) for i in range(q)]
b,c = [list(i) for i in zip(*l)]
x = collections.Counter(a)
y = sum(a)
for i in range(q):
    if b[i] in x:
        y -= x[b[i]] * b[i]
        y += x[b[i]] * c[i]
        x[c[i]] += x[b[i]]
        x[b[i]] = 0
    print(y)

Buggy submission (verdict: Runtime Error):
a = input()
q = int(input())
b = list(input().split() for i in range(q))

for i in range(q):
    j = b[i][0]
    k = b[i][1]
    a = a.replace(j,k)
    l = a.split(' ')
    l = [int(i) for i in l]
    print(sum(l))
Problem p02639 (python)

Fixed submission:
x1,x2,x3,x4,x5 = map(int,input().split())

if x1 == 0:
    print(1)
elif x2 == 0:
    print(2)
elif x3 == 0:
    print(3)
elif x4 == 0:
    print(4)
else:
    print(5)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
p = 0

for i in range(n):
    j = i + 1
    for j in range(n):
        if i == j:
            pass
        elif a[i] % a[j] == 0:
            break
        else:
            pass
        if j == n - 1:
                p += 1

print(p)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a.sort()
print(a)
p = 0

for i in range(n):
    for j in range(n):
        if i == j:
            pass
        elif a[i] % a[j] == 0:
            break
        else:
            pass
        if j == n - 1:
                p += 1

print(p)
Problem p02642 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
m = max(a)
flag = [True]*(m+1)
c = [0]*(m+1)
b = list(sorted(a))
for i in b:
    x = i + i
    while x <= m:
        flag[x] = False
        x += i
    c[i] += 1
ans = 0
x = 0
l = []
ans = 0
for i in a:
    if flag[i] and c[i] <= 1:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
p = 0

for i in range(n):
    j = i + 1
    while j < n:
        if i == j:
            pass
        elif a[i] % a[j] == 0:
            break
        else:
            pass
        if j == n - 1:
            p += 1
	    j += 1

print(p)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse = True)
p = 0
 
for i in range(n):
    j = i + 1 
        while j < n:
            if i == j:
                pass
            elif a[i] % a[j] == 0:
                break
            else:
                pass
            if j == n - 1:
                p += 1
	    j += 1
 
print(p)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a = list(set(a))
j = 0

if len(a) == 1:
    print(0)
    exit(0)

a.sort(reverse = True)
p = 0

for i in range(n):
    j = i + 1
    while j < n:
        if a[i] % a[j] == 0:
            break
        if j == n-1:
            p += 1
        j += 1

print(p+1)
Problem p02657 (python)

Fixed submission:
a,b = map(int,input().split())
print(a * b)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
c = 1

for i in range(len(a)):
    c = c * a[i]

if c > pow(10,18):
    print(-1)
else:
    print(c)
Problem p02658 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
c = 1

if 0 in a:
    print(0)
    exit()

for i in range(len(a)):
    c = c * a[i]
    if c > pow(10,18):
        print(-1)
        exit(0)

print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
c = 1

if a in 0:
    print(0)
    exit()

for i in range(len(a)):
    c = c * a[i]
    if c > pow(10,18):
        print(-1)
        exit(0)

print(c)
Problem p02660 (python)

Fixed submission:
n = int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
p = make_divisors(n)
x = 0
i = 1
ans = 0
def countf(x):
    for j in range(1,x+2):
        if (1+j)*j//2 > x:
            return j - 1
while n != 1:
    if n % p[i] == 0:
        x += 1
        n = n // p[i]
    else:
        if x != 0:
            ans += countf(x)
            x = 0
        i += 1
ans += countf(x)
print(ans)

Buggy submission (verdict: Runtime Error):
import sympy
n = int(input())
p = sympy.divisors(n)
x = 0
i = 1
ans = 0
def countf(x):
    for j in range(1,x+2):
        if (1+j)*j//2 > x:
            return j - 1
while n != 1:
    if n % p[i] == 0:
        x += 1
        n = n // p[i]
    else:
        if x != 0:
            ans += countf(x)
            x = 0
        i += 1
ans += countf(x)
print(ans)
Problem p02678 (python)

Fixed submission:
# 参考にした提出:https://atcoder.jp/contests/abc168/submissions/16604668 #
from collections import deque
n,m = map(int,input().split())
l = [[] for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    l[a].append(b)
    l[b].append(a)
d = [-1] * (n+1)
d[0],d[1] = 0,0
queue = deque()
queue.append(1)
while queue:
    x = queue.popleft()
    for i in l[x]:
        if d[i] == -1:
            d[i] = x
            queue.append(i)
if -1 in d:
    print('No')
else:
    print('Yes')
    for i in d[2:]:
        print(i)

Buggy submission (verdict: Runtime Error):
from collections import deque
n,m = map(int,input().split())
l = [list(map(int,input().split())) for i in range(m)]
for i in range(m):
    x,y = l[i][0],l[i][1]
    x,y = x-1,y-1
    if x > y:
        x,y = y,x
    l[i] = [x,y]
l.sort()
print(l)
a,b = deque(),deque()
for i in range(m):
    a.append(l[i][0])
    b.append(l[i][1])
ans = [-1] * n
ans[0] = 0
queue = deque()
for i in range(n):
    queue.append(i)
while queue:
    h = queue.popleft()
    flg = False
    p = 0
    q = len(a)
    while p < q:
        x = a.popleft()
        y = b.popleft()
        if h == x or h == y:
            if ans[x] == -1 and ans[y] == -1:
                a.append(x)
                b.append(y)
                flg = True
            elif ans[x] == -1:
                ans[x] = ans[y] + 1
            elif ans[y] == -1:
                ans[y] = ans[x] + 1
            else:
                ans[x] = min(ans[x],ans[y]+1)
                ans[y] = min(ans[y],ans[x]+1)
        else:
            a.append(x)
            b.append(y)
        p += 1
    if flg:
        queue.append(h)
    print(ans)
if -1 in ans:
    print('No')
else:
    print('Yes')
    for i in ans[1:]:
        print(i)
Problem p02681 (python)

Fixed submission:
s = input()
t = input()
if s == t[:-1]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
r = t.len()
if s in t[0,r]:
    print('Yes')
else:
    print('No')
Problem p02730 (python)

Fixed submission:
s = list(input()) 
l = len(s) # l = 29
j = l - 1 # j = 28

for i in range(l // 2):
    if s[i] != s[j]:
        print('No')
        exit(0)
    j -= 1


h = (l + 3) // 2 - 1 # h = 15
j = h - 2

for h in range(l // 2):
    if s[h] != s[j]:
        print('No')
        exit(0)
    j -= 1

print('Yes')

Buggy submission (verdict: Runtime Error):
s = list(input())
j = -1

for i in range(len() // 2):
    if s[i] != s[j]:
        print('No')
        exit(0)

    j -= 1

print('Yes')
Problem p02741 (python)

Fixed submission:
k = int(input())
li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(li[k-1])

Buggy submission (verdict: Runtime Error):
k = int(input)
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])
Problem p02760 (python)

Fixed submission:
x = list(map(int,input().split()))
y = list(map(int,input().split()))
z = list(map(int,input().split()))
n = int(input())
b = list(int(input()) for i in range(n))

for i in range(n):
    if b[i] in x:
        x[x.index(b[i])] = 'T'
    if b[i] in y:
        y[y.index(b[i])] = 'T'
    if b[i] in z:
        z[z.index(b[i])] = 'T'

if x[0] == 'T' and x[1] == 'T' and x[2] == 'T':
    print('Yes')
elif y[0] == 'T' and y[1] == 'T' and y[2] == 'T':
    print('Yes')
elif z[0] == 'T' and z[1] == 'T' and z[2] == 'T':
    print('Yes')
elif x[0] == 'T' and y[0] == 'T' and z[0] == 'T':
    print('Yes')
elif x[1] == 'T' and y[1] == 'T' and z[1] == 'T':
    print('Yes')
elif x[2] == 'T' and y[2] == 'T' and z[2] == 'T':
    print('Yes')
elif x[0] == 'T' and y[1] == 'T' and z[2] == 'T':
    print('Yes')
elif x[2] == 'T' and y[1] == 'T' and z[0] == 'T':
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a11,a12,a13 = input().split()
a21,a22,a23 = input().split()
a31,a32,a33 = input().split()

n = int(input())
b = list()
i = 0

for i in range(n):
    b.append(int(input()))

if a11 in b:
    a11 = 'T'

if a12 in b:
    a12 = 'T'

if a13 in b:
    a13 = 'T'

if a21 in b:
    a21 = 'T'

if a22 in b:
    a22 = 'T'

if a23 in b:
    a23 = 'T'

if a31 in b:
    a31 = 'T'

if a32 in b:
    a32 = 'T'

if a33 in b:
    a33 = 'T'

if a11 == 'T':
    if a12 == 'T':
        if a13 == 'T':
            print('Yes')
            exit()
    
    if a22 == 'T':
        if a33 == 'T':
            print('Yes')
            exit()
    
    if a21 == 'T':
        if a31 == 'T':
            print('Yes')
            exit()

elif a12 == 'T':
    if a22 == 'T':
        if a32 == 'T':
            print('Yes')
            exit()

elif a13 == 'T':
    if a22 == 'T':
        if a31 == 'T':
            print('Yes')
            exit()

     if a23 == 'T':
        if a33 == 'T':
            print('Yes')
            exit()

elif a21 == 'T':
    if a22 == 'T':
        if a23 == 'T':
            print('Yes')
            exit()

elif a31 == 'T':
    if a32 == 'T':
        if a33 == 'T':
            print('Yes')
            exit()

else:
    print('No')
Problem p02761 (python)

Fixed submission:
n,m = map(int,input().split())
if m != 0:
    l = [list(map(int,input().split())) for i in range(m)]
    s,c = [list(i) for i in zip(*l)]
z = ['a'] * n
for i in range(m):
    if z[s[i]-1] == 'a':
        z[s[i]-1] = str(c[i])
    elif z[s[i]-1] == str(c[i]):
        pass
    else:
        print('-1')
        exit(0)
if n == 1:
    if z[0] == 'a':
        print(0)
    else:
        print(z[0])
else:
    if z[0] == '0':
        print(-1)
    else:
        if z[0] == 'a':
            z[0] = '1'
        for i in range(1,n):
            if z[i] == 'a':
                z[i] = '0'
        print(''.join(z))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
l = [list(map(int,input().split())) for i in range(m)]
s,c = [list(i) for i in zip(*l)]
z = ['a'] * n
for i in range(m):
    if z[s[i]-1] == 'a':
        z[s[i]-1] = str(c[i])
    elif z[s[i]-1] == str(c[i]):
        pass
    else:
        print('-1')
        exit(0)
if n == 1:
    if z[0] == 'a':
        print(0)
    else:
        print(z[0])
else:
    if z[0] == '0':
        print(-1)
    else:
        if z[0] == 'a':
            z[0] = '1'
        for i in range(1,n):
            if z[i] == 'a':
                z[i] = '0'
        print(''.join(z))
Problem p02765 (python)

Fixed submission:
n,r = map(int,input().split())
if n >= 10:
    print(r)
else:
    k = 10 - n
    print(100 * k + r)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
j = max(x)
m = 0
y = True

for i in range(n):
    if x[0] != x[i]:
        y = False

if y:
    print(0)
    exit(0)

for p in range(j):
    c = 0
    z = 0
    for i in range(n):
        z = x[i] - p
        c = c + (z * z)
    
    if m == 0:
        m = c
    else:
        if m > c:
            m = c

print(m)
Problem p02767 (python)

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
j = max(x)
m = 0
y = True

for i in range(n):
    if x[0] != x[i]:
        y = False

if y:
    print(0)
    exit(0)

for p in range(j):
    c = 0
    z = 0
    for i in range(n):
        z = x[i] - p
        c = c + (z * z)
    
    if m == 0:
        m = c
    else:
        if m > c:
            m = c

print(m)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
j = max(x)
m = 0
y = True

for p in range(n):
    if x[0] != x[i]:
        y = False

if y:
    print(0)
    exit(0)

for p in range(j):
    c = 0
    z = 0
    for i in range(n):
        z = x[i] - p
        c = c + (z * z)
    
    if m == 0:
        m = c
    else:
        if m > c:
            m = c

print(m)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
j = max(x)
m = 0
y = True

for p in range(n):
    if x[0] != x[i]:
        y = False

if y:
    print(0)
    exit(0)

for p in range(j):
    c = 0
    z = 0
    for i in range(n):
        z = x[i] - p
        c = c + (z * z)
    
    if m == 0:
        m = c
    else:
        if m > c:
            m = c

print(m)

Buggy submission (verdict: Runtime Error):
n = int(input())
x = list(map(int,input().split()))
j = max(x)
m = 0
y = True

for p in range(n):
    if x[0] != x[i]:
        y = False

if y:
    print(0)
    exit(0)

for p in range(j):
    c = 0
    z = 0
    for i in range(n):
        z = x[i] - p
        c = c + (z * z)
    
    if m == 0:
        m = c
    else:
        if m > c:
            m = c

print(m)
Problem p02795 (python)

Fixed submission:
h = int(input())
w = int(input())
n = int(input())

if h < w:
    if n % w == 0:
        print(n // w)
    else:
        print(n // w + 1)
else:
    if n % h == 0: 
        print(n // h)
    else:
        print(n // h + 1)

Buggy submission (verdict: Runtime Error):
h = int(input())
w = int(input())
n = int(input())

if h < w:
    if n % w == 0:
        print(n % w)
    else:
        print(n % w + 1)
if n % h == 0:
        print(n % h)
    else:
        print(n % h + 1)
Problem p02801 (python)

Fixed submission:
c = input()
c = ord(c) + 1
print(chr(c))

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

L = N * M
S = sum(A)

if L - S > K or S >= L:
    print(-1)
else:
    print(L - S)

Buggy submission (verdict: Runtime Error):
c = input()
c = ord(c + 1)
print(c)

Buggy submission (verdict: Runtime Error):
c = input()
c = c + 1
print(c)