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

Fixed submission:
A,B=map(int,input().split())
if A<=2*B:
  print(0)
else:
  print(A-2*B)

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

ans=0
for i in range(N-2):
  a=L[i]
  for j in range(i+1,N-1):
    b=L[j]
    for k in range(j+1,N):
      c=L[k]
      if a<b+c and b<c+a and c<a+b:
        ans+=1
      else:
        break
        
print(ans)

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

ans=0
for i in range(N-2):
  a=L[i]
  for j in range(i+1,N-1):
    b=L[j]
    for k in range(j+1,N):
      c=L[k]
      if a<b+c and b<c+a and c<a+b:
        ans+=1
      else:
        break
        
print(ans)
Problem p02909 (python)

Fixed submission:
S=input()
if S=="Sunny":
  print("Cloudy")
elif S=="Cloudy":
  print("Rainy")
elif S=="Rainy":
  print("Sunny")

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

dp=[[0 for _ in range(i)] for i in range(N)]
#dp[i][j]:i文字目とj文字目からの共通文字の最大長さ(i>j)

for i in range(N-1):
  if S[i]==S[N-1]:
    dp[N-1][i]=1

for i in reversed(range(N-1)):
  for j in range(i):
    if S[i]==S[j]:
      dp[i][j]=dp[i+1][j+1]+1
      if j+dp[i][j]-1>=i:
        dp[i][j]=i-j

A=[]
for i in range(N):
  for j in range(i):
    A.append(dp[i][j])

print(max(A))
Problem p02927 (python)

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

cal=[[m+1,d+1] for m in range(M) for d in range(D)]

ans=0
for i in cal:
  day=[(i[1]-i[1]%10)/10,i[1]%10]
  if day[0]>1 and day[1]>1:
    if day[0]*day[1]==i[0]:
      ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=list(input())
mod=10**9+7

rl=["L"]
for i in range(1,2*N):
  if S[i]==S[i-1]:
    if rl[i-1]=="R":
      rl.append("L")
    elif rl[i-1]=="L":
      rl.append("R")
  elif S[i]!=S[i-1]:
    if rl[i-1]=="R":
      rl.append("R")
    elif rl[i-1]=="L":
      rl.append("L")

if rl.count("L")!=N or S[0]=="W" or S[2*N-1]=="W":
  print(0)
  exit()

ans=1
for i in range(2*N):
  if rl[i]=="R":
    if rl[:i].count("L")-rl[:i].count("R")<0:
      print(0)
      exit()
    else:
      ans*=(rl[:i].count("L")-rl[:i].count("R"))%mod

for i in range(1,N+1):
  ans=ans%mod*i

print(ans%mod)
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
input=lambda :sys.stdin.readline()
N,Q=map(int,input().split())
ab=[[] for _ in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  ab[a-1].append(b)
  ab[b-1].append(a)

P=[0 for _ in range(N)]
for i in range(Q):
  p,x=map(int,input().split())
  P[p-1]+=x

def dfs(p,par):
  for i in ab[p-1]:
    if i!=par:
      P[i-1]+=P[p-1]
      dfs(i,p)

dfs(1,-12345)
print(" ".join(map(str,P)))

Buggy submission (verdict: Runtime Error):
N,Q=map(int,input().split())
ab=[[] for _ in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  ab[a-1].append(b)
  ab[b-1].append(a)

P=[0 for _ in range(N)]
for i in range(Q):
  p,x=map(int,input().split())
  P[p-1]+=x


count=[-1]*N
c=0
def dfs(p):
  global c
  c+=P[p-1]
  count[p-1]=c
  for i in ab[p-1]:
    if count[i-1]==-1:
      dfs(i)
  c-=P[p-1]

dfs(1)
print(" ".join(map(str,count)))
Problem p02957 (python)

Fixed submission:
A,B=input().split(" ")
A,B=int(A),int(B)

K=A+B
if K%2==0:
  print(int(K/2))
else:
  print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
S=list(input())
mod=10**9+7

dp=[[0]*13 for _ in range(len(S)+1)]
#dp[i][j] :先頭 i 文字として考えられるもののうち、13 で割ったあまりが j であるものの数
dp[0][0]=1

for i in range(1,len(S)+1):
  if S[i-1]=="?":
    for k in range(10):
      for j in range(13):
        dp[i][(10*j+k)%13]+=dp[i-1][j]
    
    
  else:
    for j in range(13):
      dp[i][(10*j+int(S[i-1]))%13]+=dp[i-1][j]
      
print(dp[len(S)][5]%mod)

Buggy submission (verdict: Runtime Error):
A,B=input().sprit(" ")
A,B=int(A),int(B)

K=A+B
if K%2==0:
  print(K/2)
else:
  print("IMPOSSIBLE")
Problem p02975 (python)

Fixed submission:
from collections import Counter
N=int(input())
A=Counter(map(int,input().split()))

if len(A)==1:
  if 0 in A:
    print("Yes")
  else:
    print("No")
elif len(A)==2:
  if A[0]==N/3:
    print("Yes")
  else:
    print("No")
elif len(A)==3:
  if list(A.values())==[N/3]*3 and list(A.keys())[0]^list(A.keys())[1]^list(A.keys())[2]==0:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
from collections import Counter
N=int(input())
A=Counter(map(int,input().split()))

if len(A)==1:
  if 0 in A:
    print("Yes")
  else:
    print("No")
elif len(A)==2:
  if A[0]==N/3:
    print("Yes")
  else:
    print("No")
elif len(A)==3:
  if list(A.values())==[N/3]*3 and A.keys()[0]^A.keys()[1]^A.keys()[2]==0:
    print("Yes")
  else:
    print("No")
else:
  print("No")
Problem p03005 (python)

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

if K==1:
  print(0)
else:
  print(N-K)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N=int(input())
xy=[list(map(int,input().split())) for _ in range(N)]
xy.sort()

if N==1:
  print(1)
  exit()

pq=[]
for i in range(N):
  for j in range(i+1,N):
    pq.append([xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]])

print(Counter(map(lambda x:x[0]*10**10+x[1],pq)).most_common())
print(N-Counter(map(lambda x:x[0]*10**10+x[1],pq)).most_common()[0][1])
Problem p03006 (python)

Fixed submission:
from collections import Counter
N=int(input())
xy=[list(map(int,input().split())) for _ in range(N)]
xy.sort()

if N==1:
  print(1)
  exit()

pq=[]
for i in range(N):
  for j in range(i+1,N):
    pq.append([xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]])

print(N-Counter(map(lambda x:x[0]*10**10+x[1],pq)).most_common()[0][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter
N=int(input())
xy=[list(map(int,input().split())) for _ in range(N)]

pq=[]
for i in range(N):
  for j in range(i+1,N):
    pq.append([xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]])

print(N-Counter(map(lambda x:x[0]*10**10+x[1],pq)).most_common()[0][1])
Problem p03014 (python)

Fixed submission:
H,W=map(int,input().split())
field=[list(input()) for _ in range(H)]

l=[[0]*W for _ in range(H)]
r=[[0]*W for _ in range(H)]
u=[[0]*W for _ in range(H)]
d=[[0]*W for _ in range(H)]

for j in range(H):
  for i in range(W):
    if field[j][i]==".":
      if i==0:
        l[j][i]=1
      else:
        l[j][i]=l[j][i-1]+1
      if j==0:
        u[j][i]=1
      else:
        u[j][i]=u[j-1][i]+1
        

for j in reversed(range(H)):
  for i in reversed(range(W)):
    if field[j][i]==".":
      if i==W-1:
        r[j][i]=1
      else:
        r[j][i]=r[j][i+1]+1
      if j==H-1:
        d[j][i]=1
      else:
        d[j][i]=d[j+1][i]+1

A=[]
for j in range(H):
  for i in range(W):
    A.append(l[j][i]+r[j][i]+d[j][i]+u[j][i]-3)

print(max(A))

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
field=[]
for i in range(H):
  field.append(list(input()))

l=[[[-1,-1] for _ in range(W)] for _ in range(H)]

def xp(x,y):
  global xn
  if x>=W:
    pass
  elif field[y][x]=="#":
    l[y][x][0]=0
  else:
    xn+=1
    xp(x+1,y)
    l[y][x][0]=xn


def yp(x,y):
  global yn
  if y>=H:
    pass
  elif field[y][x]=="#":
    l[y][x][1]=0
  else:
    yn+=1
    yp(x,y+1)
    l[y][x][1]=yn


for j in range(H):
  for i in range(W):
    xn=0
    yn=0
    if l[j][i][0]==-1:
      xp(i,j)
    if l[j][i][1]==-1:
      yp(i,j)

print(max([max([i[0]+i[1]-1 for i in j]) for j in l]))

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
field=[]
for i in range(H):
  field.append(list(input()))

l=[[[-1,-1] for _ in range(W)] for _ in range(H)]

def xp(x,y):
  global xn
  if x>=W:
    pass
  elif field[y][x]=="#":
    l[y][x][0]=0
  else:
    xn+=1
    xp(x+1,y)
    l[y][x][0]=xn


def yp(x,y):
  global yn
  if y>=H:
    pass
  elif field[y][x]=="#":
    l[y][x][1]=0
  else:
    yn+=1
    yp(x,y+1)
    l[y][x][1]=yn


for j in range(H):
  for i in range(W):
    xn=0
    yn=0
    if l[j][i][0]==-1:
      xp(i,j)
    if l[j][i][1]==-1:
      yp(i,j)

print(max([max([i[0]+i[1]-1 for i in j]) for j in l]))
Problem p03061 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
N=int(input())
A=list(map(int,input().split()))

def gcd(x,y):
  if y==0:
    return x
  else:
    return gcd(y,x%y)

L=[0]*(N+2)
R=[0]*(N+2)

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

for i in reversed(range(1,N+1)):
  R[i]=gcd(R[i+1],A[i-1])

M=[gcd(L[i-1],R[i+1]) for i in range(1,N+1)]

print(max(M))

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

def gcd(x,y):
  if y==0:
    return x
  else:
    return gcd(y,x%y)


dp=[0]*N
dp[1]=max(A[0],A[1])
dp[2]=max(gcd(A[0],A[1]),gcd(A[1],A[2]),gcd(A[2],A[0]))
for i in range(3,N):
  dp[i]=gcd(dp[i-1],A[i])

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

Fixed submission:
N=int(input())
ans=0
for _ in range(N):
  x,u=input().split()
  if u=="JPY":
    ans+=int(x)
  else:
    ans+=float(x)*380000
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=0
for _ in range(N):
  x,u=map(int,input().split())
  if u=="JPY":
    ans+=x
  else:
    ans+=x*380000
print(ans)
Problem p03142 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
N,M=map(int,input().split())
par=[[] for _ in range(N)]
for _ in range(N-1+M):
  a,b=map(int,input().split())
  par[b-1].append(a)

dep=[-1]*N
def depth(n):
  if dep[n-1]!=-1:
    return dep[n-1]
  else:
    if len(par[n-1])==0:
      dep[n-1]=0
      return 0
    else:
      dep[n-1]=max([depth(i) for i in par[n-1]])+1
      return dep[n-1]

for i in range(N):
  if len(par[i])==0:
    print(0)
  elif len(par[i])==1:
    print(par[i][0])
  else:
    m=-1
    a=par[i][0]
    for j in par[i]:
      d=depth(j)
      if m<d:
        m=d
        a=j
    print(a)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
par=[[] for _ in range(N)]
for _ in range(N-1+M):
  a,b=map(int,input().split())
  par[b-1].append(a)

dep=[-1]*N
def depth(n):
  if dep[n-1]!=-1:
    return dep[n-1]
  else:
    if len(par[n-1])==0:
      dep[n-1]=0
      return 0
    else:
      dep[n-1]=max([depth(i) for i in par[n-1]])+1
      return dep[n-1]

for i in range(N):
  if len(par[i])==0:
    print(0)
  elif len(par[i])==1:
    print(par[i][0])
  else:
    m=-1
    a=par[i][0]
    for j in par[i]:
      d=depth(j)
      if m<d:
        m=d
        a=j
    print(a)
Problem p03231 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000)
N,M=map(int,input().split())
S=list(input())
T=list(input())

def gcd(x,y):
  if x==0:
    return y
  else:
    return gcd(y%x,x)

k=N*M//gcd(N,M)
X=[0]*N
for i,s in enumerate(S):
  X[i]=s
  
for i,t in enumerate(T):
  if (i*k//M)%(k//N)!=0:
    pass
  elif (i*k//M)%(k//N)==0 and X[(i*k//M)//(k//N)]==t:
    pass
  else:
    print(-1)
    exit()
    
print(k)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000000)
N,M=map(int,input().split())
S=list(input())
T=list(input())

def gcd(x,y):
  if x==0:
    return y
  else:
    return gcd(y%x,x)

k=N*M//gcd(N,M)
X=[0]*k
for i,s in enumerate(S):
  X[i*k//N]=s
  
for i,t in enumerate(T):
  if X[i*k//M]==t or X[i*k//M]==0:
    pass
  else:
    print(-1)
    exit()
    
print(k)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)
N,M=map(int,input().split())
S=list(input())
T=list(input())

def gcd(x,y):
  if x==0:
    return y
  else:
    return gcd(y%x,x)

k=N*M//gcd(N,M)
X=[0]*k
for i,s in enumerate(S):
  X[i*k//N]=s
  
for i,t in enumerate(T):
  if X[i*k//M]==t or X[i*k//M]==0:
    pass
  else:
    print(-1)
    exit()
    
print(k)

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

def gcd(x,y):
  if x==0:
    return y
  else:
    return gcd(y%x,x)

k=N*M//gcd(N,M)
X=[0]*k
for i,s in enumerate(S):
  X[i*k//N]=s
  
for i,t in enumerate(T):
  if X[i*k//M]==t or X[i*k//M]==0:
    pass
  else:
    print(-1)
    exit()
    
print(k)
Problem p03292 (python)

Fixed submission:
A=list(map(int,input().split()))
print(max(A)-min(A))

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

ans=0
while AB:
  a=AB[-1][0]
  AB=list(filter(lambda x:x[1]<=a,AB))
  ans+=1
  
print(ans)
Problem p03355 (python)

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

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

ans=[]
if K<=len(S):
  s0=sorted(S[:-K+1])[0]
  for j,e in enumerate(S[:-K+1]):
    if e==s0:
      for i in range(1,K+1):
        a="".join(S[j:j+i])
        if a not in ans:
          ans.append(a)
      
sl=S[-K+1:]
for i in range(K-1):
  for j in range(i+1,K):
    a="".join(sl[i:j])
    if a not in ans:
      ans.append(a)

ans.sort()
print(ans[K-1])

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

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

ans=[]
if K<len(S):
  s0=sorted(S[:-K+1])[0]
  for j,e in enumerate(S[:-K+1]):
    if e==s0:
      for i in range(1,K+1):
        a="".join(S[j:j+i])
        if a not in ans:
          ans.append(a)
      
sl=S[-K+1:]
for i in range(K-1):
  for j in range(i+1,K):
    a="".join(sl[i:j])
    if a not in ans:
      ans.append(a)

ans.sort()
print(ans[K-1])
Problem p03660 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
N=int(input())
ab=[[] for _ in range(N)]
for _ in range(N-1):
  a,b=map(int,input().split())
  ab[a-1].append(b)
  ab[b-1].append(a)
"""
N=10**5
ab=[[]]*N
ab[0]=[2]
ab[N-1]=[N-1]
for i in range(1,N-1):
  ab[i]=[i,i+2]
"""
par=[0]*N
  
def dfs(pre,p):
  global path
  par[p-1]=pre
  if p==N:
    pass
  else:
    for i in ab[p-1]:
      if i!=pre:
        dfs(p,i)

dfs(-1,1)
path=[N]
p=N
while p!=1:
  p=par[p-1]
  path.append(p)
path.reverse()

spath=set(path)

def dfs2(pre,p):
  a=0
  for i in ab[p-1]:
    if i in spath:
      pass
    elif i==pre:
      pass
    else:
      a+=dfs2(p,i)
  return 1+a

ff=0
sf=0
L=len(path)
for i in range(L):
  if i<=(L-1)//2:
    ff+=dfs2(-1,path[i])
  else:
    sf+=dfs2(-1,path[i])
    
if ff>sf:
  print("Fennec")
else:
  print("Snuke")

Buggy submission (verdict: Runtime Error):
N=int(input())
ab=[[] for _ in range(N)]
for _ in range(N-1):
  a,b=map(int,input().split())
  ab[a-1].append(b)
  ab[b-1].append(a)


def dfs(p,pa):
  global path
  if p==N:
    path=pa
  else:
    for i in ab[p-1]:
      if i not in pa:
        dfs(i,pa+[i])

dfs(1,[1])

def dfs2(p):
  a=0
  seen.append(p)
  for i in ab[p-1]:
    if i in path:
      pass
    elif i in seen:
      pass
    else:
      a+=dfs2(i)
  return 1+a

ff=0
sf=0
L=len(path)
for i in range(L):
  seen=[]
  if i<=(L-1)//2:
    ff+=dfs2(path[i])
  else:
    sf+=dfs2(path[i])
    
if ff>sf:
  print("Fennec")
else:
  print("Snuke")
Problem p03761 (python)

Fixed submission:
from collections import Counter
N=int(input())
S=Counter(list(input()))

for i in range(1,N):
  S_=Counter(list(input()))
  for s in S:
    if S_[s]<S[s]:
      S[s]=S_[s]

ans=[]
for s in S:
  for _ in range(S[s]):
    ans.append(s)
print("".join(sorted(ans)))

Buggy submission (verdict: Runtime Error):
from collections import Counter
N=int(input())
S=Counter(list(input()))

for i in range(1,N):
  S_=Counter(list(input()))
  for s in S:
    if S_[s]<S[s]:
      S[s]=S_[s]

ans=[]
for s in S:
  for _ in range(S[s]):
    ans.append(s)
print("".join(sorted(ans))
Problem p03997 (python)

Fixed submission:
x=[]
for i in range(3):
  x.append(int(input()))
print(int((x[0]+x[1])*x[2]/2))

Buggy submission (verdict: Runtime Error):
x=[]
for i in range(3):
  x[i]=int(input())
print((x[0]+x[1])*x[2]/2)

Buggy submission (verdict: Runtime Error):
x=[]
for i in range(3):
  x[i]=int(input())
 print((x[0]+x[1])*x[2]/2)
Problem p02765 (python)

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

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
cnt=0
while n!=0:
    n=n//k
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
sum = 0
while N!=0:
    N = N//K
    sum+=1
print(sum)
Problem p02772 (python)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
for a in A:
    if a%2 == 0 and ( a%3 != 0 and a%5 != 0 ):
        print('DENIED')
        exit()
print('APPROVED')

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split())
for a in A:
  if a % 2 == 0 and (a % 3 != and a % 5 != 0):
    print("DENIED")
    exit()
print("APPROVED")
Problem p02811 (python)

Fixed submission:
K, X = map(int, input().split())
print("No" if 500*K < X else "Yes")

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

print(S.count("ABC"))
Problem p02812 (python)

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

print(S.count("ABC"))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
count = 0
for i in range(N):
  if S[i]=="A" and S[i+1]=="B" and S[i+2]=="C":
    count = count + 1

print(count)
Problem p02848 (python)

Fixed submission:
N=int(input())
S=input()
a=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
ans=''
for i in (S):
  num=a.index(i)+N
  if(num>25):
    num-=26
  ans+=a[num]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
a="abcdefghijklmnopqrstuvwxyz"
ans=''
for i in S:
  num = a.index(i) + N
  if(num > 25):
    num -= 26
  ans += a[num]
print(ans)
Problem p03138 (python)

Fixed submission:
import math
n,k = map(int,input().split())
a_list = [i for i in map(int,input().split())]
cnt_list = [0 for i in range(40)]
maxi = 0
if k == 0:
    maxi = sum(a_list)
else:
    for i in a_list:
        b = bin(i)[2:]
        b = b[::-1]
        for index,j in enumerate(b):
            cnt_list[-(index+1)] += int(j)
    goukei = 0
    for i in range(40):
        if cnt_list[i] <= n/2 and (goukei + 2**(39-i)) <= k:
            goukei += 2**(39-i)
            maxi += (2**(39-i)) * (n - cnt_list[i])
        else:
            maxi += (2**(39-i)) * (cnt_list[i])

print(maxi)

Buggy submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
a_list = [i for i in map(int,input().split())]
a_list.sort()
maxi = 0
if k == 0:
    maxi = sum(a_list)
else:
    max_keta = math.floor(math.log(a_list[-1],2))+1
    k_keta = math.floor(math.log(k,2))+1
    cnt_list = [0 for i in range(k_keta)]
    for i in a_list:
        tmp = i
        keta = -1
        while tmp != 0:
            a = tmp % 2
            tmp = int(tmp/2)
            if a == 1:
                cnt_list[keta] += 1
            keta = keta -1

    goukei = 0
    for i in range(k_keta-1,-1,-1):
        if cnt_list[-1*(i+1)] <= n / 2 and (goukei + 2**i) <= k:
            goukei +=  2**i
            maxi += (2**i) * (n - cnt_list[-1*(i+1)])

        else:
            maxi += (2**i) * (cnt_list[-1*(i+1)])
print(maxi)

Buggy submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
a_list = [i for i in map(int,input().split())]
a_list.sort()
"""
2進数での各bitが立ってる回数をカウントして少ない方()の値を採用する
"""
max_keta = math.floor(math.log(a_list[-1],2))+1
k_keta = math.floor(math.log(k,2))+1
cnt_list = [0 for i in range(k_keta)]
for i in a_list:
    tmp = i
    keta = -1
    while tmp != 0:
        a = tmp % 2
        tmp = int(tmp/2)
        if a == 1:
            cnt_list[keta] += 1
        keta = keta -1
maxi = 0
"""
単純に1からkまで2進数に直して足し合わせて最大かどうかを確かめる
"""
#print(cnt_list)
for i in range(1,k+1):
    k_list = [0 for i in range(k_keta)]
    tmp = i
    keta = -1
    while tmp != 0:
        a = tmp % 2
        tmp = int(tmp/2)
        if a == 1:
            k_list[keta] = 1
        keta = keta-1
    """
    それぞれの桁について1にできるかどうか
    """
    tmp = 0
    kake = 1
    #print(k_list)
    for j in range(k_keta-1,-1,-1):
        if k_list[j] == 1:
            tmp += kake * (n-cnt_list[j])
        else:
            tmp += kake * cnt_list[j]
        kake *= 2
    #print("tmp:{}".format(tmp))
    maxi = max(maxi , tmp)

print(maxi)
Problem p03206 (python)

Fixed submission:
a = int(input())
str = "Christmas"
for i in range(25 - a):
    str += " Eve"

print(str)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
hei_list = []
for i in range(n):
    tmp = int(input())
    hei_list.append(tmp)
hei_list.sort()
for i in range(n-k+1):
    tmp_dist = hei_list[i + k - 1] - hei_list[i]
    if i == 0:
        min_dist = tmp_dist
    elif tmp_dist < min_dist:
        min_dist = tmp_dist
print(min_dist)
Problem p02717 (python)

Fixed submission:
X, Y, Z =map(int, input().split())
X, Y = Y, X
X, Z = Z, X


print(X, Y, Z)

Buggy submission (verdict: Runtime Error):
X = int(input())
Y = int(input())
Z = int(input())

A = X
B = Y
C = Z

X, Y = Y, X
Y, Z = Z, Y
print(A, B, C)

Buggy submission (verdict: Runtime Error):
X = input()
Y = input()
Z = input()

X, Y = Y, X
Y, Z = Z, Y
print(X, Y, Z)
Problem p02724 (python)

Fixed submission:
n = int(input())
print(int(n//500*1000+(n%500)//5*5))

Buggy submission (verdict: Runtime Error):
n = int(input)
print(int(n//500*1000+(n%500)//5*5))
Problem p02885 (python)

Fixed submission:
A, B = map(int, input().split())
 
value = A - B * 2
if value >= 0:
  print(value)
else:
  print(0)

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

value = A - B * 2
if value >= 0:
  return value
else:
  return 0
Problem p02934 (python)

Fixed submission:
N = input()
nums = map(int, input().split())
 
print(1 / sum(1 / num for num in nums))

Buggy submission (verdict: Runtime Error):
N = input()
nums = map(int, input().split())
 
return 1 / sum(1 / num for num in nums)

Buggy submission (verdict: Runtime Error):
N = input()
nums = input().split()
 
return 1 / sum(1 / int(num) for num in nums)

Buggy submission (verdict: Runtime Error):
N = input()
nums = input().split()
 
return 1 / sum(1 / int(num) for num in nums)

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

return 1 / sum(1 / num for num in nums)
Problem p02817 (python)

Fixed submission:
S,T = input().split()
ans = T+S
print(ans)

Buggy submission (verdict: Runtime Error):
S,T = map(input().split())
ans = T+S
print(ans)

Buggy submission (verdict: Runtime Error):
S,T = list(input())
ans = T+S
print(ans)
Problem p03060 (python)

Fixed submission:
n=int(input())
v_list=list(map(int,input().split()))
c_list=list(map(int,input().split()))

diff_list = [v_list[i]-c_list[i] for i in range(n) if v_list[i] - c_list[i] > 0]
diff_list.append(0)
print(sum(diff_list))

Buggy submission (verdict: Runtime Error):
n = input()
v_list = list(map(int,input().split()))
c_list = list(map(int,input().split())
 
diff_list = [v_list[i]-c_list[i] for i in range(n) if v_list[i] - c_list[i] > 0]
diff_list.append(0)
print(sum(diff_list))

Buggy submission (verdict: Runtime Error):
N = input()
v_list = list(map(int,input().split()))
c_list = list(map(int,input().split())
diff_list = [v_list[i]-c_list[i] for i in range(n) if v_list[i] - c_list[i] > 0]
print(diff_list)
diff_list.append(0)
print(diff_list)
print(sum(diff_list))

Buggy submission (verdict: Runtime Error):
N = input()
V_list = list(map(int,input().split()))
C_list = list(map(int,input().split())
 
diff_list = [v_list[i]-c_list[i] for i in range(n) if v_list[i] - c_list[i] > 0]
diff_list.append(0)
print(sum(diff_list))

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

diff_list = [v_list[i]-c_list[i] for i in range(n) if v_list[i] - c_list[i] > 0]
print(diff_list)
diff_list.append(0)
print(diff_list)
print(sum(diff_list))
Problem p03110 (python)

Fixed submission:
n=int(input())
sum = 0
for i in range(n):
    x,u = input().split()
    sum += int(x) if u == 'JPY' else float(x) *380000
print(sum)

Buggy submission (verdict: Runtime Error):

sum = 0
for i in range(n):
    x,u = input().split()
    sum += int(n) if u == "JPY" else float(x) * 380000
print(sum)
Problem p03238 (python)

Fixed submission:
n = int(input())
if n == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a+b)

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
print(6 - A - B)