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

Fixed submission:
a,b,c,x,y=[int(s) for s in input().split()]
if x<=y:
  A=a
  B=b
  C=c
  X=x
  Y=y
else:
  A=b
  B=a
  C=c
  X=y
  Y=x
#print([Y*2*C,X*2*C+(Y-X)*B,X*A+Y*B])
print(min([Y*2*C,X*2*C+(Y-X)*B,X*A+Y*B]))

Buggy submission (verdict: Runtime Error):
a,b,c,x,y=[int(s) for s in input().split()]
if x<=y:
  A=a
  B=b
  C=c
  X=x
  Y=y
else:
  A=b
  B=a
  C=c
  X=y
  Y=x
print(min[Y*2*C,X*2*C+(Y-X)*B,X*A+(Y-X)*B])
Problem p03385 (python)

Fixed submission:
x=list(input())
x.sort()
if x==["a","b","c"]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
x=list(input())
x.sort()
if x==[a,b,c]:
  print("Yes")
else:
  print("No")
Problem p03399 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(min([a+c,a+d,b+c,b+d]))

Buggy submission (verdict: Runtime Error):
a,b,c,d=[int(s) for s in input().split()]
print(min([a+c,a+d,b+c,c+d]))
Problem p03408 (python)

Fixed submission:
dicN={}
for i in range(int(input())):
  x=input()
  if x in dicN:
    dicN[x]+=1
  else:
    dicN[x]=1
dicM={}
for i in range(int(input())):
  x=input()
  if x in dicM:
    dicM[x]+=1
  else:
    dicM[x]=1
ls=[0]
for k,v in dicN.items():
  if k in dicM:
    ls.append(v-dicM[k])
  else:
    ls.append(v)
print(max(ls))

Buggy submission (verdict: Runtime Error):
dicN={}
for i in range(int(input())):
  x=input()
  if x in dicN:
    dicN[x]+=1
  else:
    dicN[x]=1
dicM={}
for i in range(int(input())):
  x=input()
  if x in dicM:
    dicM[x]+=1
  else:
    dicM[x]=1
print(max([dicN[e]-dicM[e] for e in dicN.keys()]+[0]))
Problem p03416 (python)

Fixed submission:
def palindromeQ(num):
  if num%10==num//10000:
    if (num%100)//10==(num//1000)%10:
      return(1)
    else:
      return(0)
  else:
    return(0)
ans=0
A,B=[int(s) for s in input().split()]
for i in range(A,B+1):
  ans+=palindromeQ(i)
print(ans)

Buggy submission (verdict: Runtime Error):
def palindromeQ(num):
  if num%10==num//10000:
    if (num%100)//10==(num//1000)%10:
      return(1)
    else:
      return(0)
  else:
    return(0)
ans=0
for i in range(A,B+1):
  ans+=palindromeQ(i)
print(ans)
Problem p03424 (python)

Fixed submission:
N=int(input())
ls=input().split()
for i in range(N):
  x=ls[i]
  if x=="Y":
    print("Four")
    break
else:
  print("Three")

Buggy submission (verdict: Runtime Error):
N=int(input())
for i in range(N):
  x=int(input())
  if x=="Y":
    print("Four")
    break
else:
  print("Three")
Problem p03455 (python)

Fixed submission:
a,b=[int(s) for s in input().split()]
if (a*b)%2==0:
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
a,b=[int(s) for s in input().split()]
if (a*b)%2==1:
  Print("Odd")
else:
  Print("Even")
Problem p03456 (python)

Fixed submission:
import math
S,T=input().split()
x=int(S+T)
if int(math.sqrt(x))**2==x:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S,T=input().split()
x=int(S+T)
if int(math.sqrt(x))**2==x:
  print('Yes')
else:
  print('No')
Problem p03494 (python)

Fixed submission:
N=int(input())
ls=[int(s) for s in input().split()]
count=-1
flag=1
while(flag==1):
  count+=1
  for i in range(N):
    if ls[i]%2==1:
      flag=0
      break
    ls[i]=ls[i]//2
print(count)

Buggy submission (verdict: Runtime Error):
N=int(input())
ls=[int(s) for s in input().split()]
count=0
i=0
while(True):
  if ls[i]%2==1:
    break
  ls[i]=ls[i]//2
  if i<N:
    i+=1
  else:
    count+=1
    i=0    
print(count)
Problem p03544 (python)

Fixed submission:
N=int(input())
L=[0 for _ in range(N+1)]
L[0]=2
L[1]=1
for i in range(2,N+1):
  L[i]=L[i-1]+L[i-2]
print(L[N])

Buggy submission (verdict: Runtime Error):
N=int(input())
L=[0 for _ in range(N+1)]
L[0]=2
L[1]=1
for i in range(2,N+1):
  L[i]=L[i-1]+L[i-2]
print(L[N+1])
Problem p03555 (python)

Fixed submission:
S=input()
T=input()
if [S[0],S[1],S[2]]==[T[2],T[1],T[0]]:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
import math
x=int(input())
print(int(math.sqrt(x))**2)
Problem p03623 (python)

Fixed submission:
x,a,b=[int(s) for s in input().split()]
if abs(a-x)<abs(b-x):
  print('A')
else:
  print('B')

Buggy submission (verdict: Runtime Error):
x,a,b=[int(s) for s in input().split()]
if abs(a-x)<abs(b-x):
  print('A'):
else:
  print('B')
Problem p02795 (python)

Fixed submission:
def countChange(inputNum, divNum):
    tmp = inputNum // divNum
    if inputNum % divNum != 0:
        tmp += 1

    return tmp

height = int(input())
width = int(input())
goal = int(input())

if height > width:
    divNum = height
else:
    divNum = width

ans = countChange(goal, divNum)
print(ans)

Buggy submission (verdict: Runtime Error):
lengthNum, countNum, sumNum = map(int, input().split())

aryAns = []
tmp = lengthNum - countNum
tNum = 2 if sumNum == 1 else sumNum-1
aryAns = [sumNum]*countNum + [sumNum-1]*tmp

print(" ".join([str(x) for x in aryAns]))
Problem p02898 (python)

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

count = 0
for i in range(N):
    if ar[i] >= K:
        count += 1

print(count)

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

count = 0
for i in range(N):
    if ar[i] >= K:
        count += 1

print(count)

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

count = 0
for n in ar:
    if n >= K:
        count += 1

print(count)
Problem p02899 (python)

Fixed submission:
N = int(input())
ar = list(map(int, input().split()))
dic = {}
for i in range(len(ar)):
    dic[i] = ar[i]

arFast = sorted(dic.items(), key=lambda x: x[1], reverse=False)
for n in arFast:
    print(n[0]+1, end=" ")

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

arFast = sorted(ar, key=lambda x: x[1], reverse=True)
print(arFast)
Problem p02952 (python)

Fixed submission:
n = int(input())

if n < 10:  # < 10^1
    # 1-n
    print(n)

elif n < 100:  # < 10^2
    # 1-9
    print(9)

elif n < 1000:  # < 10^3
    # 1-9, 100-n
    print(n-99+9)

elif n < 10000:  # < 10^4
    # 1-9, 100-999
    print(9+900)

elif n < 100000:  # < 10^5
    # 1-9 + 100-999 + 10000-n
    print(n-9999+900+9)

else:  # == 10^5
    # 1-9 + 100-999 + 10000-90000
    print(9+900+90000)

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

intCount = 0

for idx in range(1, n+1):
    if len(str(idx) % 2 == 1:
        intCount += 1

print(intCount)

Buggy submission (verdict: Runtime Error):
intCount = 0

for idx in range(1, n+1):
    if len(str(idx) % 2 == 1:
        intCount += 1

print(intCount)
Problem p02658 (python)

Fixed submission:
n = int(input())
arr = []

z=False
for x in input().split(' '):
    if x == '0':
        z = True
    arr.append(int(x))
if z == True:
    print(0)

else:
    ans = 1
    for x in arr:
        ans *= x
        if ans > int(1e18):
            print(-1)
            exit(0)
    
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
arr = []

z=False
for x in input().split(' '):
    if x == 0:
        z = True
    arr.append(x)
if z == True:
    print(0)

else:
    ans = 1
    for x in arr:
        ans *= x
        if ans > int(1e18):
            print(-1)
    else:
        print(ans)
Problem p02548 (python)

Fixed submission:
n=int(input())

ans=0
for i in range(1,n):
    ans+=(n-1)//i
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
import sympy
ans=0
for i in range(1,n):
    ans+=len(sympy.divisors(i))
print(ans)
Problem p02702 (python)

Fixed submission:
s=input()
l=len(s)
amari=[0]*2019
amari[0]=1

d=0
digi=1

for c in s[::-1]:
    d=(int(c)*digi + d)%2019
    amari[d]+=1
    digi=(digi*10)%2019

ans=0
for i in amari:
    ans+=i*(i-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
        
ngram=[]
for i in range(4,len(s)):
    for j in range(len(s)-i+1):

ans=0
for i in range(len(ngram)):
    if int(ngram[i])%2019==0:
        ans+=1
print(ans)
Problem p02713 (python)

Fixed submission:
k=int(input())
import math
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        a=math.gcd(i,j)
        for l in range(1,k+1):
            ans+=math.gcd(a,l)
print(ans)

Buggy submission (verdict: Runtime Error):
k=int(input())
import math
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
          	a=math.gcd(i,j)
            ans+=math.gcd(a,l)
print(ans)

Buggy submission (verdict: Runtime Error):
k=int(input())
import math
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
          	a=math.gcd(i,j)
            ans+=math.gcd(a,l)
print(ans)
Problem p02714 (python)

Fixed submission:
n=int(input())
s=list(input())
from collections import Counter
myc= Counter(s)
val=list(myc.values())
if len(val)!=3:
    print(0)
else:
    ans=val[0]*val[1]*val[2]
    for i in range(n-2):
        for j in range(i+1,n-1):
            if 2*j-i < n:
                if len(set(list((s[i],s[j],s[2*j-i]))))==3:
                    ans-=1
    print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=list(input())
from collections import Counter
myc= Counter(s)
val=list(myc.values())
ans=val[0]*val[1]*val[2]
for i in range(n-2):
    for j in range(i+1,n-1):
        if 2*j-i < n:
            if len(set(list((s[i],s[j],s[2*j-i]))))==3:
                ans-=1
print(ans)
Problem p02720 (python)

Fixed submission:
k=int(input())
lun=[1,2,3,4,5,6,7,8,9]
for i in range(10**5+1):
    if len(lun)>=k:
        break
    di=lun[i]%10
    for j in range(max(0,di-1),min(9,di+1)+1):
        lun.append(lun[i]*10+j)
print(lun[k-1])

Buggy submission (verdict: Runtime Error):
k=int(input())
dp=[[0]*10 for _ in range(5)]
dp[0]=[1]*10
for i in range(4):
    dp[i+1][0]=dp[i][0]+dp[i][1]
    for j in range(1,9):
        dp[i+1][j]=dp[i][j-1]+dp[i][j]+dp[i][j+1]
    dp[i+1][9]=dp[i][8]+dp[i][9]

a=0
h=0
s=0
for i in range(5):
    for j in range(1,10):
        a+=dp[i][j]
        if a>=k:
            a-=dp[i][j]
            s=k-a
            h=j
            d=i
            break
        else:
            continue
    if h!=0:
        break
ans=str(h)
q=0
w=0
for p in range(d):
    for j in range(max(0,h-1),min(h+2,10)):
        q+=dp[p][j]
        if q>=s:
            q-=dp[p][j]
            s=s-a
            ans+=str(j)

            q=0
        elif q==s:
            ans+=str(j)
            w=1
            break
            
        if s==0:
            w=1
            break
    if w==1:
        break
print(int(ans))

Buggy submission (verdict: Runtime Error):
k=int(input())
dp=[[0]*10 for _ in range(5)]
dp[0]=[1]*10
for i in range(4):
    dp[i+1][0]=dp[i][0]+dp[i][1]
    for j in range(1,9):
        dp[i+1][j]=dp[i][j-1]+dp[i][j]+dp[i][j+1]
    dp[i+1][9]=dp[i][8]+dp[i][9]

a=0
h=0
s=0
for i in range(5):
    for j in range(1,10):
        a+=dp[i][j]
        if a>=k:
            a-=dp[i][j]
            s=k-a
            h=j
            d=i
            break
        else:
            continue
    if h!=0:
        break
ans=str(h)
q=0
w=0
for p in range(d):
    for j in range(max(0,h-1),min(h+2,10)):
        q+=dp[p][j]
        if q>s:
            q-=dp[p][j]
            s=s-a
            ans+=str(j)

            q=0
        elif q==s:
            ans+=str(j)
            w=1
            break
            
        if s==0:
            w=1
            break
    if w==1:
        break
print(int(ans))
Problem p02741 (python)

Fixed submission:
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[int(input())-1])

Buggy submission (verdict: Runtime Error):
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[int(input())])
Problem p02761 (python)

Fixed submission:
n,m=map(int, input().split())
list1=[list(map(int,input().split())) for i in range(m)]

ans=['x']*n
non=0
for i in range(m):
    if ans[list1[i][0]-1]!='x':
        if int(ans[list1[i][0]-1])==list1[i][1]:
            continue
        else:
            non=-1
            break
    else:
        ans[list1[i][0]-1]=str(list1[i][1])

if non==-1:
    print(-1)
else:
    if ans[0]=='0' and n!=1:
        print(-1)
    else:
        if 'x' in ans:
            if ans[0]=='x' and n!=1:
                ans[0]='1'
            for i in range(n):
                if ans[i]=='x':
                    ans[i]='0'
        K=''
        for i in range(n):
            K+=ans[i]
        print(int(K))

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
list1=[list(map(int,input().split())) for i in range(m)]

ans=['x']*n
non=0
for i in range(m):
    if ans[list1[i][0]-1]!='x':
        if int(ans[list1[i][0]-1])==list1[i][1]:
            continue
        else:
            non=-1
            break
    else:
        ans[list1[i][0]-1]=str(list1[i][1])

if non==-1:
    print(-1)
else:
    if ans[0]=='0':
        print(-1)
    else:
        if 'x' in ans:
            if ans[0]=='x':
                ans[0]='1'
            else:
                for i in range(n):
                    if ans[i]=='x':
                        ans[i]='0'
        K=''
        for i in range(n):
            K+=ans[i]
        print(int(K))

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
list1=[list(map(int,input().split())) for i in range(m)]

if m

ans=['x']*n
non=0
for i in range(m):
    if ans[list1[i][0]-1]!='x':
        if int(ans[list1[i][0]-1])==list1[i][1]:
            continue
        else:
            non=-1
            break
    else:
        ans[list1[i][0]-1]=str(list1[i][1])

if non==-1:
    print(-1)
else:
    if ans[0]=='0':
        print(-1)
    else:
        if 'x' in ans:
            if ans[0]=='x':
                ans[0]='1'
            else:
                for i in range(n):
                    if ans[i]=='x':
                        ans[i]='0'
        K=''
        for i in range(n):
            K+=ans[i]
        print(int(K))

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
list1=[list(map(int,input().split())) for i in range(m)]

ans=['x']*3
non=0
for i in range(m):
    if ans[list1[i][0]-1]!='x':
        if int(ans[list1[i][0]-1])==list1[i][1]:
            continue
        else:
            non=-1
            break
    else:
        ans[list1[i][0]-1]=str(list1[i][1])

if non==-1:
    print(-1)
else:
    if ans[0]=='0':
        print(-1)
    else:
        if 'x' in ans:
            if ans[0]=='x':
                ans[0]='1'
            else:
                for i in range(n):
                    if ans[i]=='x':
                        ans[i]='0'
        K=''
        for i in range(n):
            K+=ans[i]
        print(int(K))
Problem p02767 (python)

Fixed submission:
n=int(input())
xl=list(map(int,input().split()))
xl.sort()
ans=[]
for p in range(xl[-1]-xl[0]+1):
    sum1=0
    for xi in xl:
        sum1+=(xi-xl[0]-p)**2
    ans.append(sum1)
print(min(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
xl=list(map(int,input().split()))
ans=[]
for p in range(xl[-1]-xl[0]+1):
    sum1=0
    for xi in xl:
        sum1+=(xi-xl[0]-p)**2
    ans.append(sum1)
print(min(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
xl=list(map(int,input().split()))
ans=[]
for i in range(xl[-1]-xl[0]+1):
    sum1=0
    for xi in xl:
        sum1+=(xi-xl[0]-i)**2
    ans.append(sum1)
print(ans)
print(min(ans))
Problem p02780 (python)

Fixed submission:
import numpy as np
n,k=map(int, input().split())
exp=list(map(lambda x:(int(x)+1)/2,input().split())) # 入力と同時に期待値計算

l=np.cumsum(exp) # 累積和の計算

ans=l[k-1]
for i in range(n-k):
    ans=max(ans,l[i+k]-l[i])
    
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,k=map(int, input().split())
exp=list(map(lambda x:(int(x)+1)/2,input().split())) # 入力と同時に期待値計算

l=np.cumsum(exp) # 累積和の計算

ans=l[k-1]
for i in range(n-k):
    ans=max(ans,l[i+k]-l[i])
    
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
n,k=map(int, input().split())
exp=list(map(lambda x:(int(x)+1)/2,input().split())) # 入力と同時に期待値計算

l=np.cumsum(exp) # 累積和の計算

ans=l[k-1]
for i in range(n-k):
    ans=max(ans,l[i+k]-l[i])
    
print(ans)
Problem p02803 (python)

Fixed submission:
from collections import deque

h,w=map(int, input().split())
S = [input() for _ in range(h)]

move=((1,0),(-1,0),(0,1),(0,-1))

def bfs(i,j): # 幅優先探索、マス i,j から始まる時の最長経路
    if S[i][j] == '#': # そのマスが壁ならスタート地点にならないのでパス
        return 0
    
    visited=[[0]*w for _ in range(h)] # 探索済のリスト
    visited[i][j]=1 # 最初のマスは探索済へ
    
    que=deque([(i,j,0)]) # キューの作成（queueは待ち行列）
    
    while len(que)>0:
        ci,cj,d = que.popleft() #キューの左側から取り出してキューから削除

        for mi,mj in move: #moveで定義したそれぞれの動きについて
            ni,nj = ci+mi,cj+mj # 移動先の座標をni,njとしている。
            if 0 <= ni < h and 0 <= nj < w and visited[ni][nj]==0:
                if S[ni][nj] == '.':
                    visited[ni][nj] = 1
                    que.append((ni, nj, d+1))
    return d
ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, bfs(i, j))
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
an=[int(i) for i in input().split()]
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
p = 10 ** 9 + 7
N = 10 ** 5
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

an=sorted(an)
r_an=list(reversed(an))

max1=0
min1=0
for i in range(1,n-k+2):
    c=cmb(n-i,k-1,mod)
    max1=max1 + an[-i]*c%p
    min1=min1 + r_an[-i]*c%p
print((max1-min1)%p)
Problem p02804 (python)

Fixed submission:
n,k=map(int, input().split())
an=[int(i) for i in input().split()]

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r=min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 5
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2,N+1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

an=sorted(an)
r_an=list(reversed(an))

max1=0
min1=0
for i in range(1,n-k+2):
    c=cmb(n-i,k-1,p)
    max1=max1 + an[-i]*c%p
    min1=min1 + r_an[-i]*c%p
print((max1-min1)%p)

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
an=[int(i) for i in input().split()]

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 5
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

an=sort(an)
r_an=list(reversed(an))

mod=10**9+7
max1=0
min1=0
for i in range(1,n-k+2):
    c=cmb(n-i,k-1,mod)
    max1=max1 + an[-i]*c%mod
    min1=min1 + r_an[-i]*c%mod
print((max1-min1)%mod)

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
an=[int(i) for i in input().split()]
from scipy.misc import comb

an=sorted(an)
r_an=list(reversed(an))

max1=0
min1=0
for i in range(1,n-k+2):
    max1+=an[-i]*comb(n-i,k-1,exact=True)
    min1+=r_an[-i]*comb(n-i,k-1,exact=True)
print((max1-min1)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
an=[int(i) for i in input().split()]
from scipy.special import comb

an=sorted(an)
r_an=list(reversed(an))

max1=0
min1=0
for i in range(1,n-k+2):
    max1+=an[-i]*comb(n-i,k-1,exact=True)
    min1+=r_an[-i]*comb(n-i,k-1,exact=True)
print((max1-min1)%(10**9+7))
Problem p02814 (python)

Fixed submission:
n,m=map(int, input().split())
an=[int(i) for i in input().split()]
import fractions
ans=an[0]
for i in range(1, n):
    ans = ans * an[i] // fractions.gcd(ans, an[i])

def count2(i):
    if i%2==0:
        c=0
        while i%2==0:
            i//=2
            c+=1
        return c
    else:
        return 0
    
c2=count2(ans)

for ak in an:
    if ak%(2**c2)==0:
        d=1
        pass
    else:
        d=0
        break

if d==0:
    print(0)
else:
    lca=ans//2
    if (m//lca)%2==0:
        print((m//lca)//2)
    else:
        print(((m//lca)+1)//2)

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
an=[int(i)//2 for i in input().split()]
ma=max(an)
count=0
q=1
mk=0
while m>=ma*q:
    for ak in an:
        if (ma*q)%ak==0 and ((ma*q)//ak)%2==1:
            mk=ma*q
        else:
            break
    q+=2
    if mk!=0
        break
print(m//mk)
Problem p02838 (python)

Fixed submission:
n=int(input())
lis=list(map(lambda x:format(int(x),'b'),input().split()))
l=0
for i in range(n):
    l=max(l,len(lis[i]))

d0=[0]*60
d1=[0]*60

for i in range(n):
    lis[i]=lis[i].zfill(l)
    for j in range(l):
        if lis[i][-j-1]=='0':
            d0[j]+=1
        else:
            d1[j]+=1

ans=0
for i in range(60):
    ans+=(d0[i]*d1[i]*2**i)%(10**9+7)
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
N=int(input())
a_l=[int(i) for i in input().split()]

sum1=0
for (i,j) in it.combinations(a_l, 2):
        sum1+=i^j
print(sum1%(7+10**9))

Buggy submission (verdict: Runtime Error):
N=int(input())
a_l=[int(i) for i in input().split()]

sum1=0
for (i,j) in it.combinations(a_l, 2):
        sum1+=i^j
print(sum1%(7+10**9))
Problem p03162 (python)

Fixed submission:
n = int(input())
abc = [list(map(int, input().split())) for i in range(n)]
a,b,c=abc[0][0],abc[0][1],abc[0][2]
for i in range(1,n):
    a,b,c = abc[i][0]+max(b,c),abc[i][1]+max(a,c),abc[i][2]+max(a,b)
print(max(a,b,c))

Buggy submission (verdict: Runtime Error):
n = int(input())
abc = [list(map(int, input().split())) for i in range(N)]
a,b,c=abc[0][0],abc[0][1],abc[0][2]
for i in range(1,n):
    a,b,c = abc[i][0]+max(b,c),abc[i][1]+max(a,c),abc[i][2]+max(a,b)
print(max(a,b,c))
Problem p03565 (python)

Fixed submission:
s_prime=list(input())
t=list(input())
ls=len(s_prime)
lt=len(t)
s_prime.reverse()
t.reverse()


if lt>ls:
    print('UNRESTORABLE')
else:
    def check(t,s):
        l=len(t)
        c=0
        for i in range(l):
            if s[i]!='?' and s[i]!=t[i]:
                c=1
        return True if c==0 else False
    c=0            
    for i in range(ls-lt+1):
        print()
        if check(t,s_prime[i:i+lt])==1:
            t_in=s_prime[:i]+t+s_prime[i+lt:] 
            for k in range(ls):
                if t_in[k]=='?':
                    t_in[k]='a'
            t_in.reverse()   
            print(''.join(t_in))
            c=1
            break
    print('UNRESTORABLE') if c==0 else exit()

Buggy submission (verdict: Runtime Error):
zS=input()
T=input()
ls=len(S)
lt=len(T)

ans='UNRESTORABLE'

if ls<lt:
    print(ans)
    exit()
for i in range(ls-lt,-1,-1):
    c=0
    for j in range(lt):
        if T[j]==S[i+j] or S[i+j]=='?':
            continue
        else:
            c=1
            break
    if c==0:
        ans=S.replace('?','a')
        ans=ans[:i] + T + ans[i+lt+1:]
        break
print(ans)

Buggy submission (verdict: Runtime Error):
S=input()
T=input()
ls=len(S)
lt=len(T)

ans='UNRESTORABLE'

if ls<lt:
    print(ans)
    exit()
for i in range(ls-lt,0,-1):
    c=0
    for j in range(lt):
        if T[j]==S[i+j] or S[i+j]=='?':
            continue
        else:
            c=1
            break
    if c==0:
        ans=S.replace('?','a')
        ans=ans[:i] +z T + ans[i+lt:]
print(ans)
Problem p02713 (python)

Fixed submission:
from math import gcd 
N = int(input())
i = 0
 
for a in range(1, N+1):
    for b in range(1, N+1):
        for c in range(1, N+1):
            i += gcd(gcd(a, b), c)
            
print(i)

Buggy submission (verdict: Runtime Error):
from math import gcd 
N = int(input())
i = 0
 
for a in range(1, N+1):
    for b in range(1, N+1):
        for c in range(1, N+1):
            i += gcd(a, b, c)
            
print(i)