Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
h = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]

f = [[] for i in range(n)]

for i in ab:
    if not (i[1]-1) in f[i[0]-1]:
        f[i[0]-1].append(i[1]-1)
    if not (i[0]-1) in f[i[1]-1]:
        f[i[1]-1].append(i[0]-1)
ans = 0
#print(f)
for i in range(n):
    flag = True
    for j in range(len(f[i])):
        #print("比べ,",i,f[i][j], h[i], h[f[i][j]])
        if h[i] <= h[f[i][j]]:
            #print("低い")
            flag = False
            break
    if flag:
        #print("good",i)
        ans += 1

print(ans)


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

f = [[] for i in range(n)]

for i in ab:
    f[i[0]-1].append(i[1]-1)
    f[i[1]-1].append(i[0]-1)
ans = 0
#print(f)
for i in range(n):
    flag = True
    for j in range(len(f[i])):
        #print("比べ,",i,f[i][j], h[i], h[f[i][j]])
        if h[i] <= h[f[i][j]]:
            #print("低い")
            flag = False
            break
    if flag:
        #print("good",i)
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
# 1 <= x <= 10^9
a, b = 0, 0

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

d = make_divisors(x)
d.sort()

for i in d:
    #print("div:",i)
    a, b = i, 0
    z = x//i
    while(b != -i):
        #print("sw:",a, b)
        if z == (a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4 ):
            print(a, b)
            exit()
        else:
            a -= 1
            b -= 1


Fixed submission:
x = int(input())
# 1 <= x <= 10^9
a, b = 0, 0

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

d = make_divisors(x)
d.sort()

for i in d:
    #print("div:",i)
    a, b = i, 0
    while(b != -1000):
        #print("sw:",a, b)
        if x == pow(a,5) - pow(b,5):
            print(a, b)
            exit()
        else:
            a -= 1
            b -= 1
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i+1, n):
        if abs(i-j) == a[i]+a[j]:
            ans += 1
print(ans)


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

L = {}
R = {}

for i in range(n):
    if i + a[i] in L:
        L[i + a[i]] = L[i + a[i]] + 1
    else:
        L[i + a[i]] = 1

    if i - a[i] in R:
        R[i - a[i]] = R[i - a[i]] + 1
    else:
        R[i - a[i]] = 1

#print(L,R,sep="\n")
ans = 0
for key in L.keys():
    if key in R:
        #print(L[key], R[key])
        ans += L[key] * R[key]
print(ans)

"""
ans = 0
for i in range(n):
    for j in range(i+1, n):
        if abs(i-j) == a[i]+a[j]:
            ans += 1
print(ans)
"""
Buggy python submission (verdict: Runtime Error):
import math
a, b, n = map(int, input().split())
if n < b:
    x = n
else b < n:
    x = b-1
new = math.floor(a*x/b) - a * math.floor(x/b)
print(new)


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

if b <= n:
    x = b-1

new = math.floor(a*x/b) - a * math.floor(x/b)
print(new)

Buggy python submission (verdict: Runtime Error):
import math
a, b, n = map(int, input().split())
if n < b:
    x = n
elif b < n:
    x = b-1
new = math.floor(a*x/b) - a * math.floor(x/b)
print(new)


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

if b <= n:
    x = b-1

new = math.floor(a*x/b) - a * math.floor(x/b)
print(new)

Buggy python submission (verdict: Runtime Error):
import math
a, b , n = map(int, input().split())

max = -1

if n < b:
    x = n
elif b < n:
    x = b-1

new = math.floor(a*x/b) - a * math.floor(x/b)

print(new)


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

if b <= n:
    x = b-1

new = math.floor(a*x/b) - a * math.floor(x/b)
print(new)

Buggy python submission (verdict: Time Limit Exceeded):
import math
a, b , n = map(int, input().split())

max = -1
x = 0

while(x < n):
    x += 1
    new = math.floor(a*x/b) - a * math.floor(x/b)
    #print(math.floor(a*x/b), " - ",  a * math.floor(x/b))
    #print(new)
    if max < new:
        max = new


print(max)


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

if b <= n:
    x = b-1

new = math.floor(a*x/b) - a * math.floor(x/b)
print(new)
Buggy python submission (verdict: Runtime Error):
s = input()
ans = 0
for i in range(len(s)-1):
    for j in range(i+1,len(s)):
        #print(i,j)
        num = int(s[i:j+1])

        if num % 2019 == 0:
            print(i,j, num)
            ans += 1

print(ans)


Fixed submission:
s, w = map(int, input().split())
if s > w:
    print("safe")
else:
    print("unsafe")
Buggy python submission (verdict: Time Limit Exceeded):
import math

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


Fixed submission:
import math

k = int(input())
ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1, k+1):
            d = math.gcd(i,j)
            ans += math.gcd(d, l)

print(ans)
Buggy python submission (verdict: Runtime Error):
s = list(input())
q = int(input())
lines = [list(input().split()) for i in range(q)]
 
def q1(s):
    for i in range(len(s) // 2):
        s[i],s[-1-i] = s[-1-i],s[i]
    return s
 
def q2(s, l):
    if int(l[1]) == 1:
        s.insert(0,l[2])
    else:
        s.extend(l[2])
    return s
 
for l in lines:
    if int(len(l)) == 1:
        q1(s)
    else:
        q2(s, l)
 
print(*s, sep='')
s = list(input())
q = int(input())
lines = [list(input().split()) for i in range(q)]

def q1(s):
    for i in range(len(s) // 2):
        s[i],s[-1-i] = s[-1-i],s[i]
    return s

def q2(s, l):
    if int(l[1]) == 1:
        s.insert(0,l[2])
    else:
        s.extend(l[2])
    return s

for l in lines:
    if int(len(l)) == 1:
        q1(s)
    else:
        q2(s, l)

print(*s, sep='')

Fixed submission:
s = input()
if all(i == "A" for i in s):
    print("No")
elif all(i == "B" for i in s):
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
q = int(input())
lines = [list(input().split()) for i in range(q)]
 
def q1(s):
    for i in range(len(s) // 2):
        s[i],s[-1-i] = s[-1-i],s[i]
    return s
 
def q2(s, l):
    if int(l[1]) == 1:
        s.insert(0,l[2])
    else:
        s.extend(l[2])
    return s
 
for l in lines:
    if int(len(l)) == 1:
        q1(s)
    else:
        q2(s, l)
 
print(*s, sep='')

Fixed submission:
from collections import deque

def check(reverse_cnt, t):

    if reverse_cnt%2 == 0 and t == 1:
        return True
    elif reverse_cnt%2 == 0 and t == 2:
        return False
    elif reverse_cnt%2 == 1 and t == 1:
        return False
    elif reverse_cnt%2 == 1 and t == 2:
        return True

def solve(s, q, qs):
    reverse_cnt = 0

    for item in qs:

        if len(item) == 1:
            # T = 1 文字列を反転
            reverse_cnt += 1
        else:
            # T = 2

            if check(reverse_cnt, int(item[1])):
                # 先頭に追加
                s.appendleft(item[2])

            else:
                # 末尾に追加
                s.append(item[2])


    if reverse_cnt%2 == 1:
        ans = "".join(s)
        ans = ans[::-1]
    else:
        ans = "".join(s)

    return ans

if __name__ == '__main__':

    s = deque() # queue

    str = input()
    q = int(input())
    qs = [list(input().split()) for i in range(q)]

    s.append(str)

    ans = solve(s, q, qs)
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
q = int(input())
lines = [list(input().split()) for i in range(q)]

def q1(s):
    for i in range(len(s) // 2):
        s[i],s[-1-i] = s[-1-i],s[i]
    return s

def q2(s, l):
    if int(l[1]) == 1:
        s.insert(0,l[2])
    else:
        s.extend(l[2])
    return s

for l in lines:
    if int(len(l)) == 1:
        q1(s)
    else:
        q2(s, l)

print(*s, sep='')


Fixed submission:
from collections import deque

def check(reverse_cnt, t):

    if reverse_cnt%2 == 0 and t == 1:
        return True
    elif reverse_cnt%2 == 0 and t == 2:
        return False
    elif reverse_cnt%2 == 1 and t == 1:
        return False
    elif reverse_cnt%2 == 1 and t == 2:
        return True

def solve(s, q, qs):
    reverse_cnt = 0

    for item in qs:

        if len(item) == 1:
            # T = 1 文字列を反転
            reverse_cnt += 1
        else:
            # T = 2

            if check(reverse_cnt, int(item[1])):
                # 先頭に追加
                s.appendleft(item[2])

            else:
                # 末尾に追加
                s.append(item[2])


    if reverse_cnt%2 == 1:
        ans = "".join(s)
        ans = ans[::-1]
    else:
        ans = "".join(s)

    return ans

if __name__ == '__main__':

    s = deque() # queue

    str = input()
    q = int(input())
    qs = [list(input().split()) for i in range(q)]

    s.append(str)

    ans = solve(s, q, qs)
    print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = list(map(int, input().split()))

p0 = math.floor(sum(x)/len(x))
# 123
cost = 10**9
for i in range(0,100):
    now = 0
    for i in x:
        now += abs(p0-i)**2
    if cost > now:
        cost = now

print(now)


Fixed submission:

n = int(input())
x = list(map(int, input().split()))
cost = 10**9
for i in range(1,100):
    now = 0
    for j in x:
        now += (i-j)**2
    if cost > now:
        cost = now
print(cost)

Buggy python submission (verdict: Time Limit Exceeded):
'''
n = int(input())
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [int(input()) for i in range n]
p = [list(map(int, input().split()))]

a = input()
a, b = input().split()
a = [input() for i in range n]
'''
n = int(input())
x = list(map(int, input().split()))


import math
p0 = math.floor(sum(x)/len(x))
# 123
cost = 0
for i in x:
    cost += abs(p0-i)**2

new = 10**9
while cost < new:
    p0 += 1
    new_cost = 0
    for i in x:
        new_cost += abs(p0-i)**2
    new = new_cost
print(new)


Fixed submission:

n = int(input())
x = list(map(int, input().split()))
cost = 10**9
for i in range(1,100):
    now = 0
    for j in x:
        now += (i-j)**2
    if cost > now:
        cost = now
print(cost)

Buggy python submission (verdict: Time Limit Exceeded):
'''
n = int(input())
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [int(input()) for i in range n]
p = [list(map(int, input().split()))]

a = input()
a, b = input().split()
a = [input() for i in range n]
'''
n = int(input())
x = list(map(int, input().split()))


import math
p0 = math.floor(sum(x)/len(x))
# 123
cost = 0
for i in x:
    cost += abs(p0-i)**2

new = 10**9
while cost < new:
    p0 += 1
    new_cost = 0
    for i in x:
        new_cost += abs(p0-i)**2
    new = new_cost
print(new)


Fixed submission:

n = int(input())
x = list(map(int, input().split()))
cost = 10**9
for i in range(1,100):
    now = 0
    for j in x:
        now += (i-j)**2
    if cost > now:
        cost = now
print(cost)
Buggy python submission (verdict: Time Limit Exceeded):
H = int(input())

time = 0
now = H

while True:
    now = now//2
    time += 1
    if now == 1:
        break
pow2list = [2**i for i in range(50)]
ans = sum(pow2list[0:time+1])
print(ans)


Fixed submission:
H = int(input())

time = 0
now = H
pow2list = [2**i for i in range(50)]

import math
a = math.log(now, 2)
print(sum(pow2list[0:math.floor(a+1)]))
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

def gcd(a,b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
A = list(map(int,input().split()))
B = 0
div = 10**9+7

lcm_A = lcm_list(A)

for item in A:
    B+=(lcm_A//item)

print(B%div)


Fixed submission:
from functools import reduce
import fractions

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
A = list(map(int,input().split()))
B = 0
div = 10**9+7

lcm_A = lcm_list(A)

for item in A:
    B+=(lcm_A//item)

print(B%div)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

def gcd(a,b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
A = list(map(int,input().split()))
B = []
div = 10**9+7

lcm_A = lcm_list(A)

for item in A:
    B.append(lcm_A//item)

print(sum(B)%div)


Fixed submission:
from functools import reduce
import fractions

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
A = list(map(int,input().split()))
B = 0
div = 10**9+7

lcm_A = lcm_list(A)

for item in A:
    B+=(lcm_A//item)

print(B%div)
Buggy python submission (verdict: Runtime Error):
N,K,S = map(int,input().split())

if K == 0:
    anslist = []
    for i in range(N):
        ramdam = S+1 // (10**9)
        anslist.append(str(ramdam))
    print(" ".join(anslist))


elif N == K:
    anslist = [str(S) for i in range(N)]
    ansString = " ".join(anslist)
    print(ansString)
    exit()

else:
    if S%2 == 0:
        anslist = [str(S//2) for i in range(K+1)]
        for i in range(N - len(anslist)):
            ramdam = S+1 // 10**9
            anslist.append(str(ramdam))
        print(" ".join(anslist))

    elif S == 1:
        anslist = []
        for i in range(K):
            item = [str(1)]
            anslist.extend(item)
        for i in range(N - len(anslist)):
            ramdam = S+1 // 10**9
            anslist.append(str(ramdam))
        print(" ".join(anslist))


    else:
        anslist = []
        t = 1
        for i in range(K-1):
            item = [str(t),str(S-t)]
            anslist.extend(item)
            t += 1
        anslist.append(str(S))
        for i in range(N - len(anslist)):
            ramdam = S+1 // 10**9
            anslist.append(str(ramdam))
        print(" ".join(anslist))


Fixed submission:
import math
H = int(input())
W = int(input())
N = int(input())

long = W

if H > W:
    long = H

ans = math.ceil(N/long)

print(ans)
Buggy python submission (verdict: Runtime Error):
import random

N,K,S = map(int,input().split())

limit = 0

if K == 0:
    for i in range(N):
        ramdam = 0
        while(True):
            ramdam = random.randint(1, 10**9)
            if not ramdam == S:
                break
        anslist.append(str(ramdam))
    print(" ".join(anslist))


elif N == K:
    anslist = [str(S) for i in range(N)]
    ansString = " ".join(anslist)
    print(ansString)
    exit()

else:
    if S%2 == 0:
        anslist = [str(S//2) for i in range(K+1)]
        for i in range(N - len(anslist)):
            ramdam = 0
            while(True):
                ramdam = random.randint(1, 10**9)
                if not ramdam == S:
                    break
            anslist.append(str(ramdam))
        print(" ".join(anslist))
    else:
        anslist = []
        t = 1
        for i in range(K-1):
            item = [str(t),str(S-t)]
            anslist.extend(item)
            t += 1
        anslist.append(str(S))
        for i in range(N - len(anslist)):
            ramdam = 0
            while(True):
                ramdam = random.randint(1, 10**9)
                if not ramdam == S:
                    break
            anslist.append(str(ramdam))
        print(" ".join(anslist))


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

anslist = []

if S < 10**9:
    for i in range(K):
        anslist.append(S)
    for i in range(N-K):
        anslist.append(S+1)
elif S == 10**9:
    for i in range(K):
        anslist.append(S)
    for i in range(N-K):
        anslist.append(1)

ansString = [str(i) for i in anslist]

print(" ".join(ansString))

Buggy python submission (verdict: Runtime Error):
import random

N,K,S = map(int,input().split())

limit = 0
if N == K:
    anslist = [str(S) for i in range(N)]
    ansString = anslist.join(anslist)
    print(ansString)
    exit()

else:
    if S%2 == 0:
        anslist = [str(S//2) for i in range(K+1)]
        for i in range(N - len(anslist)):
            ramdam = 0
            while(True):
                ramdam = random.randint(1, 10**9)
                if not ramdam == S:
                    break
            anslist.append(str(ramdam))
        print(" ".join(anslist))
    else:
        anslist = []
        t = 1
        for i in range(K-1):
            item = [str(t),str(S-t)]
            anslist.extend(item)
            t += 1
        anslist.append(str(S))
        for i in range(N - len(anslist)):
            ramdam = 0
            while(True):
                ramdam = random.randint(1, 10**9)
                if not ramdam == S:
                    break
            anslist.append(str(ramdam))
        print(" ".join(anslist))


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

anslist = []

if S < 10**9:
    for i in range(K):
        anslist.append(S)
    for i in range(N-K):
        anslist.append(S+1)
elif S == 10**9:
    for i in range(K):
        anslist.append(S)
    for i in range(N-K):
        anslist.append(1)

ansString = [str(i) for i in anslist]

print(" ".join(ansString))
Buggy python submission (verdict: Runtime Error):
N ,M = map(int, input().split())
ps = [list(input().split()) for i in range(M)]

ac = [0 for i in range(N)]
wa = [0 for i in range(N)]

for i in range(M):
    s = int(ps[i][0])-1
    if ps[i][1] == "WA" and ac[s] == 0:
        wa[s] += 1

    if ps[i][1] == "AC" and ac[s] == 0:
        ac[s] = 1

for i in range(M):
    if ac[i] == 0:
        wa[i] = 0

print(str(sum(ac)) + " " + str(sum(wa)))


Fixed submission:
N ,M = map(int, input().split())
ps = [list(input().split()) for i in range(M)]

ac = [0 for i in range(N)]
wa = [0 for i in range(N)]

for i in range(M):
    s = int(ps[i][0])-1
    if ps[i][1] == "WA" and ac[s] == 0:
        wa[s] += 1

    if ps[i][1] == "AC" and ac[s] == 0:
        ac[s] = 1

for i in range(N):
    if ac[i] == 0:
        wa[i] = 0

print(str(sum(ac)) + " " + str(sum(wa)))

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

ac = [0 for i in range(N)]
wa = [0 for i in range(N)]

for i in range(M):
    s = int(ps[i][0])-1
    if ps[i][1] == "WA" and ac[s] == 0:
        wa[s] += 1

    if ps[i][1] == "AC" and ac[s] == 0:
        ac[s] = 1

for i in range(M):
    if ac[i] == 0:
        wa[i] == 0

print(str(sum(ac)) + " " + str(sum(wa)))


Fixed submission:
N ,M = map(int, input().split())
ps = [list(input().split()) for i in range(M)]

ac = [0 for i in range(N)]
wa = [0 for i in range(N)]

for i in range(M):
    s = int(ps[i][0])-1
    if ps[i][1] == "WA" and ac[s] == 0:
        wa[s] += 1

    if ps[i][1] == "AC" and ac[s] == 0:
        ac[s] = 1

for i in range(N):
    if ac[i] == 0:
        wa[i] = 0

print(str(sum(ac)) + " " + str(sum(wa)))
Buggy python submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = []
for i in range(h):
    a.extend(list(input()))

#print(*a, sep = "\n")

l = h*w
INF = 10**5

dp = [[INF]*(l) for i in range(l)]

for i in range(l):
    if a[i] == "#":
        for j in range(l):
            dp[i][j] = "#"
            dp[j][i] = "#"
            continue

    for j in range(l):
        if i == j:
            dp[i][j] = 0

    #左右上下を1にする
    #右
    if i%w+1 < w:
        dp[i][i+1] = 1
        dp[i+1][i] = 1
    #左
    if i%w-1 > 0:
        dp[i][i-1] = 1
        dp[i-1][i] = 1
    #上
    if i//h-1 > 0:
        dp[i][i-w] = 1
        dp[i-w][i] = 1
    #下
    if i//h+1 < h:
        dp[i][i+w] = 1
        dp[i+w][i] = 1

max = 0
for k in range(l):
    for i in range(l):
        for j in range(l):
            if dp[i][j] == -1:
                continue
            try:
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            except:
                dp[i][j] = dp[i][j]
max = 0
for i in dp:
    for j in i:
        try:
            if max < j:
                max = j
        except:
            pass

#print(*dp, sep="\n")
print(max)


Fixed submission:
from collections import deque

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

# 最大値の格納する
ans = 0

def bfs(y,x,m):#未実装
    #表の初期化
    graph = [[None] * w for i in range(h)]
    #最初の地点のコストは0
    graph[y][x] = 0

    q = deque()
    q.append((y,x))

    for i in range(h):
        for j in range(w):
            if l[i][j] == '#':
                graph[i][j] = -1

    #ノードの移動方向 左が縦軸, 右が横軸
    move = ((0, 1), (0, -1), (1, 0), (-1, 0))

    while q: #wがからになるまで続ける while len(q):でもOK
        #que左端から取り出す
        i, j = q.popleft()

        for di, dj in move:
            #ni, nj 遷移先の座標
            ni , nj = i + di, j + dj
            #遷移先がフィールド内であるか、Noneかどうかをチェックする
            if 0 <= ni < h and 0 <= nj < w and graph[ni][nj] is None:
                #遷移可能であれば現在のコストに1足して渡す
                #print(type(graph[i][j]))
                graph[ni][nj] = graph[i][j] + 1
                #queに格納する
                q.append((ni, nj))

    #queが空になると移動コストtableが完成
    #表中の最大値返す
    return max(max(r) for r in graph)

for i in range(h):
    for j in range(w):
        #'.'であればスタート地点になり得るので、それをbfsにかける
        if l[i][j] == '.':
            d = bfs(i,j,l) # (x, y) = (j, i), lは入力の表の情報
            #返り値が現在の最大値より大きければ値を更新する
            if ans < d:
                ans = d
print(ans)
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    while b: a, b = b, a % b
    return a

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers, N):

    ans = numbers[0]

    for i in range(1,N):
        ans = lcm_base(ans,numbers[i])

    return ans

N ,M = map(int, input().split())
A_n = list(map(int,input().split()))

a_lcm = lcm_list(A_n,N)
ans = 0
interval = a_lcm//2

amari = M // interval

if amari%2 == 1:
    amari = (amari+1)//2
else:
    amari = amari//2
print(amari)


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

ans  = 500*A - B

if ans >= 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n,k,q = map(int,input().split())
a_n = [int(input()) for i in range(q)]

p_n = [k-q for i in range(n)]

for a_i in a_n:
    p_n[a_i] += 1

[print("Yes") if p_i > 0 else print("No") for p_i in p_n]


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

p_n = [k-q for i in range(n)]

for a_i in a_n:
    p_n[a_i-1] += 1

[print("Yes") if p_i > 0 else print("No") for p_i in p_n]
Buggy python submission (verdict: Runtime Error):
list = list(map(int, input().split()))

amount = 0
count = 0

while amount < list[1]:
    count += 1
    amount = count * (list[0] - 1) + 1 

print(count)


Fixed submission:
predict = list(input())
result = list(input())

count = 0

for i in range(len(predict)):
    if predict[i] == result[i]:
        count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
a = int(input())
sum=0
for i in range(1,a):
    sum+=i
print(sum)


Fixed submission:
a = int(input())
print(a*(a-1)//2)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input())

_sum = A + B
_sub = A - B
_mul = A * B

_list = [_sum,_sub,_mul]

print(max(_list))


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

_sum = A + B
_sub = A - B
_mul = A * B

_list = [_sum,_sub,_mul]

print(max(_list))