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

Fixed submission:
import math
n,k=map(int,input().split())
temp=0
for i in range(1,n+1):
  if k<i:temp+=1
  else:temp+=2**(-math.ceil(math.log(k/i,2)))
  
print(temp/n)

Buggy submission (verdict: Runtime Error):
import math
n,k=map(int,input().split())
temp=0
for i in range(1,n+1):
  temp+=2**(-math.ceil(log(k/i,2)))
  
print(temp/n)
Problem p03061 (python)

Fixed submission:
def main():
    import sys 
    from fractions import gcd 
    input = sys.stdin.readline 

    def init(init_val):
        for i in range(n):
            seg[i+num-1] = init_val[i]
        for i in range(num-2,-1,-1):
            seg[i] = gcd(seg[2*i+1], seg[2*i+2])

    def update(k, x):
        k += num - 1
        seg[k] = x 
        while k:
            k = (k-1)//2
            seg[k] = gcd(seg[2*k+1], seg[2*k+2])

    def query(p, q):
        if q <= p:
            return 0
        p += num - 1
        q += num - 2
        res = 0
        while q - p > 1:
            if p & 1 == 0:
                res = gcd(res, seg[p])
            if q & 1 == 1:
                res = gcd(res, seg[q])
                q -= 1
            p //= 2
            q = (q - 1)//2

        if p==q:
            res = gcd(res, seg[p])
        else:
            res = gcd(gcd(res, seg[p]), seg[q])
        return res
         
    n= int(input())
    a = tuple(map(int, input().split()))
    num = 2**(n-1).bit_length()
    seg = [0]*2*num
    init(a)    
                
    ans = -1
    for i in range(n):
        ans = max(ans, gcd(query(0,i), query(i+1,n)))
    print(ans) 

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys 
    from fractions import gcd 
    input = sys.stdin.readline 

    def init(init_val):
        for i in range(n):
            seg[i+num-1] = init_val[i]
        for i in range(num-2,-1,-1):
            seg[i] = gcd(seg[2*i+1], seg[2*i+2])

    def update(k, x):
        k += num - 1
        seg[k] = x 
        while k:
            k = (k-1)//2
            seg[k] = gcd(seg[2*k+1], seg[2*k+2])

    def query(p, q):
        if q <= p:
            return ide_ele
        p += num - 1
        q += num - 2
        res = ide_ele
        while q - p > 1:
            if p & 1 == 0:
                res = gcd(res, seg[p])
            if q & 1 == 1:
                res = gcd(res, seg[q])
                q -= 1
            p //= 2
            q = (q - 1)//2

        if p==q:
            res = gcd(res, seg[p])
        else:
            res = gcd(gcd(res, seg[p]), seg[q])
        return res
         
    n= int(input())
    a = tuple(map(int, input().split())
    ide_ele = 0
    num = 2**(n-1).bit_length()
    seg = [ide_ele]*2*num
    init(a)    
                
    ans = -1
    for i in range(n):
        ans = max(ans, gcd(query(0,i), query(i+1,n)))
    print(ans) 

if __name__ == '__main__':
    main()
Problem p03103 (python)

Fixed submission:
n,m=map(int,input().split())
AB=[]
for i in range(n):
    a,b=map(int,input().split())
    AB.append((a,b))

AB.sort()

cnt=0
ans=0
for a,b in AB:

    temp=min(m-cnt,b)
    ans+=a*temp
    cnt+=temp
    if cnt==m:
        print(ans)
        break

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
AB=[]
for i in range(n):
    a,b=map(int,input().split())
    AB.append((b,a))

AB.sort()

cnt=0
ans=0
for b,a in AB:
    if cnt==k:
        print(ans)
        break
    temp=min(k-cnt,a)
    ans+=b*temp
    cnt+=temp
Problem p03112 (python)

Fixed submission:
import bisect,sys 
input=sys.stdin.readline 
a,b,Q=map(int,input().split())
INF=10**18
s=[-INF]+[int(input()) for _ in range(a)]+[INF]
t=[-INF]+[int(input()) for _ in range(b)]+[INF]
for q in range(Q):
    x=int(input())
    b,d=bisect.bisect_right(s,x),bisect.bisect_right(t,x)
    res=INF 
    for S in [s[b-1],s[b]]:
        for T in [t[d-1],t[d]]:
            d1,d2=abs(S-x)+abs(T-S),abs(T-x)+abs(T-S)
            res=min(res,d1,d2)
    print(res)

Buggy submission (verdict: Runtime Error):
import bisect,sys 
input=sys.stdin.readline 
a,b,Q=map(int,input().split())
INF=10**18
s=[-INF]+[int(input()) for _ in range(a)]+[INF]
t=[-INF]+[int(input()) for _ in range(b)]+[INF]
for q in range(Q):
    x=int(input())
    b,d=bisect.bisect_right(s,x),bisect.bisect_right(t,x)
    res=INF 
    for S in [s(b-1),s(b)]:
        for T in [t(d-1),t(d)]:
            d1,d2=abs(S-x)+abs(T-S),abs(T-x)+abs(T-S)
            res=min(res,d1,d2)
    print(res)

Buggy submission (verdict: Runtime Error):
import bisect,sys 
input=sys.stdin.readline 
a,b,Q=map(int,input().split())
INF=10**18
s=[-INF]+[int(input()) for _ in range(A)]+[INF]
t=[-INF]+[int(input()) for _ in range(B)]+[INF]
for q in range(Q):
    x=int(input())
    b,d=bisect.bisect_right(s,x),bisect.bisect_right(t,x)
    res=INF 
    for S in [s(b-1),s(b)]:
        for T in [t(d-1),t(d)]:
            d1,d2=abs(S-x)+abs(T-S),abs(T-x)+abs(T-S)
            res=min(res,d1,d2)
    print(res)
Problem p03160 (python)

Fixed submission:
n=int(input())
H=list(map(int,input().split()))
dp=[10**9]*(n)
dp[0]=0
for i in range(n):
    if i==1:
        dp[i]=min(dp[i],dp[i-1]+abs(H[i]-H[i-1]))
    elif i>1:
        dp[i]=min(dp[i],dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))

print(dp[-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
H=list(map(int,input().split()))
dp=[10**9]*(n)
dp[0]=0
for i in range(n):
    if i==1:
        dp[i]=min(dp[i],dp[i-1]+abs(H[i]-H[i-1]))
    elif i>1:
        dp[i]=min(dp[i],dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))

print(dp[n])
Problem p03162 (python)

Fixed submission:
import sys
input=sys.stdin.readline
def main():
    n=int(input())
    #H=[list(map(int,input().split())) for _ in range(n)]
    dp=[[-10**9]*3 for _ in range(n)]
    
    for i in range(n):
        a,b,c=map(int,input().split())
        t=[a,b,c]
        if i==0:
            dp[0][0],dp[0][1],dp[0][2]=a,b,c 
        else:
            for j in range(3):
                dp[i][j]=max(dp[i-1][j-1]+t[j],dp[i-1][j-2]+t[j])
    #print(dp)

    print(max(dp[-1]))
main()

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
def main():
    n=int(input())
    #H=[list(map(int,input().split())) for _ in range(n)]
    dp=[[-10**9]*3 for _ in range(n)]
    
    for i in range(n):
        a,b,c=map(int,input().split())
        t=[a,b,c]
        if i==0:
            dp[0][0],dp[0][1],dp[0][2]=a,b,c 
        else:
            for j in range(3):
                dp[i][j]=max(dp[i-1][j-1]+t[j-1],dp[i-2]+t[j-2])

        print(max(dp[-1]))
main()
Problem p03220 (python)

Fixed submission:
n = int(input())
t, a = map(int,input().split())
beta = 0.006
H = list(map(int,input().split()))
import numpy as np 
H = np.array(H) 
use = t - beta * H - a 
use = use**2 
pre_answer = min(use)
use = list(use) 
ans = 1 + use.index(pre_answer) 
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
t, a = map(int,input().split())
beta = 0.006
H = list(map(int,input().split()))
import numpy as np 
H = np.array(H) 
use = t - beta * H - a 
use = use**2 
pre_answer = min(use) 
ans = 1 + use.index(pre_answer) 
print(ans)
Problem p03246 (python)

Fixed submission:
def ma():
  return map(int,input().split())

def main():
  from collections import Counter
  N=int(input())
  A=list(ma())
  evens = Counter(A[::2])
  odds = Counter(A[1::2])
  evens[0]=0 #この部分は文字列が小さい時に必要
  odds[0]=0 #
  
  e1, e2=evens.most_common(2) #上位２つを実際の数字をⅠ番目に、出てきた回数を２こめ
  o1, o2=odds.most_common(2) #
  
  if e1[0]!=o1[0]:
    print(N - (e1[1] + o1[1]))
  else: 
    print(N - max(e1[1]+o2[1], e2[1]+o1[1]))
  
if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):

def main():
  from collections import Counter
  N=int(input())
  A=list(ma())
  evens = Counter(A[::2])
  odds = Counter(A[1::2])
  evens[0]=0 #この部分は文字列が小さい時に必要
  odds[0]=0 #
  
  e1, e2=evens.most_common(2) #上位２つを実際の数字をⅠ番目に、出てきた回数を２こめ
  o1, o2=odds.most_common(2) #
  
  if e1[0]!=o1[0]:
    print(N - (e1[1] + o1[1]))
  else: 
    print(N - max(e1[1]+o2[1], e2[1]+o1[1]))
  
if __name__ == '__main__':
  main()
Problem p03268 (python)

Fixed submission:
N,K=map(int,input().split())
u1=N//K
u2=N%K
ans=u1**3

A=[u1]*K
for i in range(u2):
    A[i+1]+=1
if K%2==0:
    ans+=A[K//2]**3
print(ans)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
u1, u2=divmod(N,K)
ans=u1**3

A=[u1]*K
for i in range(u2):
    A[i+1]+=1
if K%2==0:
    ans+=A[K//2+1]**3
print(ans)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
u1, u2=divmod(N,K)
ans=u1*3

A=[u1]*K
for i in range(u2):
    A[i+1]+=1
if K%2==0:
    ans+=A[K//2+1]*3
print(ans)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
u1, u2=divmod(N,K)
ans=u1*3

A=[u1]*K
for i in range(u2):
    A[i+1]+=1
if K%2==0:
    ans+=A[K//2+1]*3
print(ans)
Problem p03308 (python)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
A.sort()
print(abs(A[0]-A[-1]))

Buggy submission (verdict: Runtime Error):

n = int(input())
A = list(map(int,input().split())))
A.sort()
print(abs(A[0]-A[-1]))
Problem p03324 (python)

Fixed submission:
a,b=map(int,input().split())
if b==100:
  b+=1

print(b*(100**a))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if b=100:
  b+=1

print(b*(100**a))
Problem p03325 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
  k=0
  while 1:
    if a[i]%2==0:
      a[i]=a[i]//2
      k+=1
    else:break
  cnt+=k    
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
cnt=10**9
for i in range(n):
  k=0
  while (a-1):
    if a%2==0:
      a=a//2
      k+=1
    else:break
  cnt=min(cnt,k)    
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(n):
  while a-1:
    if a%2==0:
      a=a//2
      cnt+=1
    else:break
      
print(cnt)
Problem p03355 (python)

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

a=sorted({s[i:i+j+1] for i in range(len(s)) for j in range(k)})[k-1]
print(a)

Buggy submission (verdict: Runtime Error):
s=input();k=int(input())    

a=sorted({s[i:i+j+1] for i in range(len(s)) for j in range(k)})[k-1])
print(a)

Buggy submission (verdict: Runtime Error):
s=input();k=int(input())    
a=sorted({s[i:i+j+1] for i in range(len(s)) for j in range(k)}[k-1])
print(a)

Buggy submission (verdict: Runtime Error):
from collections import deque 
def k_sub():
    s=input()
    k=int(input())
    dq=deque()
    for i in range(1,len(s)+1):
        for j in range(k):
            a.append(s[j:j+i])
    a.sort()
    print(a[k-1])
if __name__=='__main__':
    k_sub()

Buggy submission (verdict: Runtime Error):
def k_sub():
    s=input()
    k=int(input())
    a=[]
    for i in range(1,len(s)+1):
        for j in range(len(s)+1-i):
            a.append(s[j:j+i])
    a.sort()
    print(a[k])

if __name__=='__main__':
    k_sub()
Problem p03356 (python)

Fixed submission:
n,m=map(int,input().split())
p=list(map(int,input().split()))
uf={i:i for i in range(1,n+1)}
def get_p(i):
    lst=[]
    while uf[i]!=i:
        lst.append(i)
        i=uf[i]
    for l in lst[:-1]:
        uf[l]=i 
    return i 

def unite(i,j):
    uf[get_p(i)]=get_p(j)
def same(i,j):
    return get_p(i)==get_p(j)

def main():
    for i in range(m):
        x,y=map(int,input().split())
        unite(x,y)
    cnt=0
    for i in range(1,n+1):
        cnt+=same(p[i-1],uf[i])
    print(cnt)    
if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):

n,m=map(int,input().split())
root=[i for i in range(n+1)]
rank=[0]*(n+1)
def find(x):
    if x==root(x):
        return x 
    else:
        return find(root[x])

def union(x,y):
    x=find(x)
    y=find(y)
    if rank[x]>rank[y]:
        root[y]=x 
    else rank[x]<rank[y]:
        root[x]=y
        if rank[x]==rank[y]:
            rank[y]+=1
def k_sub():
    
    p=list(map(int,input().split()))
    p=[-1]+p 
    for _ in range(m):
        x,y=map(int,input().split())
        union(x,y)
    d=[[] for i in range(n+1)]
    u=[[] for i in range(n+1)]
    for i in range(1,n+1):
        d[find[i]].append(i)
        u[find[i]].append(p[i])
    cnt=0
    for i in range(n):
        for candidate in d[i]:
            if candidate in u[i]:
                cnt+=1
    print(cnt)
if __name__=='__main__':
    k_sub()
Problem p03357 (python)

Fixed submission:
N=int(input())
Ball=[]
for i in range(2*N):
  c,a=input().split()
  Ball.append((c,int(a)))
B=[0]*N
W=[0]*N
B_table=[[0]*(N+1) for i in range(N)]
W_table=[[0]*(N+1) for i in range(N)]
for i in range(2*N):
  c=Ball[i][1]-1
  if Ball[i][0]=="B":
    B[c]=i+1
    for j in range(i+1,2*N):
      if Ball[j][0]=="B":
        if Ball[j][1]<Ball[i][1]:
          B_table[Ball[i][1]-1][0]+=1
      elif Ball[j][0]=="W":
        B_table[c][Ball[j][1]]+=1
    for k in range(N):
      B_table[c][k+1]+=B_table[c][k]
  elif Ball[i][0]=="W":
    W[c]=i+1
    for j in range(i+1,2*N):
      if Ball[j][0]=="W":
        if Ball[j][1]<Ball[i][1]:
          W_table[c][0]+=1
      elif Ball[j][0]=="B":
        W_table[c][Ball[j][1]]+=1
    for k in range(N):
      W_table[c][k+1]+=W_table[c][k]
dp=[[0]*(N+1) for i in range(N+1)]
for s in range(1,2*N+1):
  for b in range(max(0,s-N),min(s,N)+1):
    if b==0:
      dp[0][s]=dp[0][s-1]+(W[s-1]+W_table[s-1][0]-s)
    elif b==s:
      dp[s][0]=dp[s-1][0]+(B[s-1]+B_table[s-1][0]-s)
    else:
      dp[b][s-b]=min(dp[b-1][s-b]+(B[b-1]+B_table[b-1][s-b]-s),dp[b][s-b-1]+(W[s-b-1]+W_table[s-b-1][b]-s))
print(dp[N][N])

   #

Buggy submission (verdict: Runtime Error):
class BIT():
    def __init__(self, size):
        self.table = [0 for _ in range(size + 2)]
        self.size = size 
    def Sum(self, i):
        s = 0
        while i>0:
            s+= self.table[i]
            i-=(i&-i)
        return s 

    def Add(self,i,x):
        while i<= self.size:
            self.table[i]+=x 
            i+=(i&-i) 
        return

n=int(input())
s=[input().split() for _ in range(2*n)]
costb = [[0 for _ in range(n+1)] for _ in range(n+1)]
costw = [[0 for _ in range(n+1)] for _ in range(n+1)]
bitb, bitw = BIT(n), BIT(n)
for i in range(2*n-1,-1,-1):
    c,x=s[i][0], int(s[i][1])
    if c=="B":
        base=bitb.Sum(x-1)
        for j in range(n+1):
            costb[x-1][j]= base+bitw.Sum(j)
        bitb.Add(x,1)
    else:
        base=bitw.Sum(x-1)
        for j in range(n+1):
            cost[j][x-1]=base+bitb.Sum(j)
        bitw.Add(x,1)

dp=[[0 for _ in range(n+1)] for _ in range(n+1)]
for i in range(n+1):
    for j in range(n+1):
        if i+j==0:
            continue
        if i==0:
            dp[i][j]=dp[i][j-1]+costw[i][j-1]
        elif j==0:
            dp[i][j]=dp[i-1][j]+costb[i-1][j]
        else:
            dp[i][j]=min(dp[i][j-1]+costw[i][j-1], dp[i-1][j]+costb[i-1][j])

print(dp[n][n])
Problem p03374 (python)

Fixed submission:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,C = LI()
    a = [LI() for _ in range(n)]
    u = [_[0] for _ in a]
    x = [_[1] for _ in a]
    b = [0] * n
    c = [0] * n
    d = [0] * n
    e = [0] * n
    b[0] = x[0]
    c[-1] = x[-1]
    for i in range(1, n):
        b[i] = b[i-1] + x[i]
    for i in range(n-2, -1, -1):
        c[i] = c[i+1] + x[i]
    d[0] = x[0] - u[0]
    e[-1] = x[-1] - (C-u[-1])
    for i in range(1, n):
        d[i] = max(b[i]-u[i], d[i-1])
    for i in range(n-2, -1, -1):
        e[i] = max(c[i]-(C-u[i]), e[i+1])

    r = max(d[-1], e[0], 0)
    for i in range(n):
        if i < n-1 and r < b[i] - u[i] * 2 + e[i+1]:
            r = b[i] - u[i] * 2 + e[i+1]
        if i > 0 and r < c[i] - (C-u[i]) * 2 + d[i-1]:
            r = c[i] - (C-u[i]) * 2 + d[i-1]


    return r



print(main())

###

Buggy submission (verdict: Runtime Error):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,C = LI()
    a = [LI() for _ in range(n)]
    u = [_[0] for _ in a]
    x = [_[1] for _ in a]
    b=c=d=e=[0] * n
    b[0] = x[0]
    c[-1] = x[-1]
    for i in range(1, n):
        b[i] = b[i-1] + x[i]
    for i in range(n-2, -1, -1):
        c[i] = c[i+1] + x[i]
    d[0] = x[0] - u[0]
    e[-1] = x[-1] - (C-u[-1])
    for i in range(1, n):
        d[i] = max(b[i]-u[i], d[i-1])
    for i in range(n-2, -1, -1):
        e[i] = max(c[i]-(C-u[i]), e[i+1])
    r = max(d[-1], e[0], 0)
    for i in range(n):
        try:
            r = max(r,b[i]-u[i]*2+e[i+1])
        try:
            r = max(r,c[i]-(C-u[i])*2+d[i-1])
            
    return r

print(main())
Problem p03378 (python)

Fixed submission:
N, M, X = map(int, input().split())
*A, = map(int, input().split())

print(min(len([x for x in A if x < X]), len([x for x in A if x > X])))

Buggy submission (verdict: Runtime Error):
n,m,x=map(int,input().split())
a=[int(input()) for i in range(m)]
cnt=0
for i in range(m):
  if x<a[i]:
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n,m,x=map(int,input().split())
a=[int(input())>x for i in range(m)]
print(a.count(True))

Buggy submission (verdict: Runtime Error):
n,m,x=map(int,input().split())
a=[int(input())>x for i in range(m)]
print(sum(a))
Problem p03380 (python)

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

b=len(a)
Z=a[-1]
X=0
for i in range(1,n-1):
  if abs((Z/2)-a[X])>abs((Z/2)-a[i]):
    X=i



print(a[-1],a[X])

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

b=len(a)
Z=a[-1]
X=0
for i in range(1,N-1):
  if abs((Z/2)-A[X])>abs((Z/2)-A[i]):
    X=i



print(a[-1],a[X])

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

b=len(a)
Z=a[-1]
X=0
for i in range(1,N-1):
  if abs((Z/2)-A[X])>abs((Z/2)-A[i]):
    X=i



print(a[-1],a[l])
Problem p03386 (python)

Fixed submission:
a,b,k=map(int,input().split())
d=set()
f=min(b-a+1,k)
for i in range(f):
  d.add(a+i)
for i in range(f):
  d.add(b-i)
d=sorted(list(d))
for i in d:
  print(i)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
d=set()
f=min(b-a+1,k)
for i in range(f):
  d.add(a+i)
for i in range(f):
  d.add(b-i)
d.sort()
for i in d:
  print(i)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
d=set()
for i in range(k):
  d.add(a+i)
for i in range(k):
  d.add(b-i)
d.sort()
for i in d:
  print(i)

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
d=set()
for i in range(k):
  d.add(a+i)
for i in range(k):
  d.add(b-i)
d.sort()
for i in d:
  print(d)
Problem p03419 (python)

Fixed submission:
n,m=map(int,input().split())
n,m=min(n,m),max(n,m)
if n==1:
    if m==1:
        print(1)
    else:
        print(max(0,m-2))
        exit()
else:
    print(max(0,(n-2)*(m-2)))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input())
n,m=min(n,m),max(n,m)
if n==1:
    print(max(0,m-2))
    exit()
else:
    print(max(0,(n-2)*(m-2)))
Problem p03435 (python)

Fixed submission:
import numpy as np
c1 = list(map(int,input().split()))
A = np.array(c1)
c1 = list(map(int,input().split()))
B = np.array(c1)
c1 = list(map(int,input().split()))
C = np.array(c1)

D = A-B 
D1 = list(D)
D1 = set(D1)
if len(D1) == 1:
    pass 
else:
    print('No')
    exit()

E = B-C
E1 = list(E)
E1 = set(E1) 
if len(E1)== 1:
    print('Yes') 
else:
    print('No')

Buggy submission (verdict: Runtime Error):
c1 = list(map(int,input().split()))
A = np.array(c1)
c1 = list(map(int,input().split()))
B = np.array(c1)
c1 = list(map(int,input().split()))
C = np.array(c1)

D = A-B 
D1 = list(D)
D1 = set(D1)
if len(D1) == 1:
    continue 
else:
    print('No')
    exit()

E = B-C
E1 = list(E)
E1 = set(E1) 
if len(E1)== 1:
    print('Yes') 
else:
    print('No')
Problem p03451 (python)

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

temp=0
for i in range(N):
    temp=max(temp, sum(A[0][:i+1])+sum(A[1][i:]))

print(temp)

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

temp=0
for i in range(n):
    temp=max(temp, sum(A[0][:i+1])+sum(A[1][i:]))

print(ans)
Problem p03495 (python)

Fixed submission:
N,K = map(int,input().split()) 
A = list(map(int,input().split()))
A.sort()
temp = 1
V = [] 
for i in range(N-1):
    if A[i] == A[i+1]:
        temp+=1 
    else:
        V.append(temp)
        temp = 1

V.append(temp)
V.sort() 
ans = N- sum(V[-K:])
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split()) 
A = list(map(int,input().split()))
A.sort()
temp = 1
V = [] 
for i in range(n-1):
    if A[i] == A[i+1]:
        temp+=1 
    else:
        V.append(temp)
        temp = 1

V.append(temp)
V.sort() 
ans = N- sum(V[-k:])
print(ans)
Problem p03564 (python)

Fixed submission:
n=int(input())
k=int(input())
ans=1
for i in range(n):
  ans=min(ans*2,ans+k)
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
ans=1
for i in range(n):
  ans=min(ans*2,ans+k)
print(ans)
Problem p03573 (python)

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

if a==b:
  print(c)
  exit()
if c==a:
  print(b)
else:
  print(a)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a==b:
  print(int(input()))
  exit()
if int(input())==a:
  print(b)
else:
  print(a)
Problem p03624 (python)

Fixed submission:
alphabeta = "abcdefghijklmnopqrstuvwxyz"
all_str  = set(alphabeta) 
str = input() 
str = set(str)


use = all_str-str 
if use == set():
  print("None")
else:
  print(sorted(use)[0])

Buggy submission (verdict: Runtime Error):
alphabeta = "abcdefghijklmnopqrstuvwxyz"
all_str  = set(alphabeta) 
str = input() 
str = set(str)
use = all_str-str 
print(sorted(use)[0])
Problem p03644 (python)

Fixed submission:
n = int(input())

for i in range(8):
    if 2**i> n:
        break

print(2**(i-1))

Buggy submission (verdict: Runtime Error):
for i in range(7):
    if 2**i> n:
        break

print(2**(i-1))
Problem p03665 (python)

Fixed submission:
N,P=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
    A[i]%=2

odds=sum(A)
evens=N-odds 
if odds>0:
    ans=2**evens 
    ans*=2**(odds-1)
    print(ans)
else:
    if P==0:
        print(2**evens)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
odds=sum(A)
evens=N-odds 
if odds>0:
    ans=2**evens 
    ans*=2**(odds-1)
    print(ans)
else:
    if P==0:
        print(2**evens)
    else:
        print(0)
Problem p03679 (python)

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

if a - b >= 0:
    print('delicious')
elif b - a <= x:
    print('safe')
else:
    print('dangerous')

Buggy submission (verdict: Runtime Error):
n=int(input())
A=[int(input()) for _ in range(n)]
A=[0]+A
cnt=1
for i in range(1,n+1):
  cnt=A[cnt]
  if cnt==2:
    print(i)
    exit()
  
print(-1)
Problem p03680 (python)

Fixed submission:
n=int(input())
A=[int(input()) for _ in range(n)]
A=[0]+A
cnt=1
for i in range(1,n+1):
  cnt=A[cnt]
  if cnt==2:
    print(i)
    exit()
  
print(-1)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=[int(input()) for _ in range(n)]
A=[0]+A
cnt=1
for ? in range(1,n+1):
  cnt=A[cnt]
  if cnt==2:
    print(?)
    exit()
  
print(-1)