Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = sorted(a)
maxcomb = 0
x=0
def comb(n,r):
    npr = 1
    rp1 = 1
    for i in range(n-r+1,n+1):
        npr *= i
    for j in range(1,r+1):
        rp1 *= j
    return npr // rp1

comb(10,2)

for i in range(0,n):
    if maxcomb < comb(max(b),b[i]):
        maxcomb = comb(max(b),b[i])            
        x=b[i]
print(max(b),x)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = sorted(a)
maxb = max(b)
mini = b[0]
for i in b:
    if abs(maxb/2 - i) < abs(maxb/2 - mini):
        mini = i
print(maxb,mini)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = sorted(a)
maxcomb = 0
x=0
y=0
def comb(n,r):
    npr = 1
    rp1 = 1
    for i in range(n-r+1,n+1):
        npr *= i
    for j in range(1,r+1):
        rp1 *= j
    return npr // rp1

comb(10,2)

for i in range(1,n):
    for j in range(0,i):
        if maxcomb < comb(b[i],b[j]):
            maxcomb = comb(b[i],b[j])
            x=b[i]
            y=b[j]
print(x,y)
    

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = sorted(a)
maxb = max(b)
mini = b[0]
for i in b:
    if abs(maxb/2 - i) < abs(maxb/2 - mini):
        mini = i
print(maxb,mini)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = sorted(a)
maxcomb = 0
x=0
y=0
def comb(n,r):
    npr = 1
    rp1 = 1
    for i in range(n-r+1,n+1):
        npr *= i
    for j in range(1,r+1):
        rp1 *= j
    return npr // rp1

comb(10,2)

for i in range(1,n):
    for j in range(0,i):
        if maxcomb < comb(b[i],b[j]):
            maxcomb = comb(b[i],b[j])
            x=b[i]
            y=b[j]
print(x,y)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = sorted(a)
maxb = max(b)
mini = b[0]
for i in b:
    if abs(maxb/2 - i) < abs(maxb/2 - mini):
        mini = i
print(maxb,mini)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
sum = 0
for i in range(n):
    if a[i] - b[i] > 0:
        sum += a[i]- b[i]
    else:
        sum += (b[i] - a[i]) / 2
sum_a = 0
sum_b = 0
for i in range(n):
    sum_a += a.pop(0)
    sum_b += b.pop(0)
if sum <= sum_b - sum_a:
    print ('YES')
else:
    print ('NO')

Fixed submission:
x,y=map(int,input().split())
if x%y == 0:
    print(-1)
else:
    print(x)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
sum = 0
for i in range(n):
    if a[i] - b[i] > 0:
        sum += a[i]- b[i]
    else:
        sum += (b[i] - a[i]) / 2
sum_a = 0
sum_b = 0
for i in range(n):
    sum_a += a.pop(0)
    sum_b += b.pop(0)
if sum <= sum_b - sum_a:
    print ('YES')
else:
    print ('NO')

Fixed submission:
x,y=map(int,input().split())
if x%y == 0:
    print(-1)
else:
    print(x)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
m = 0
for i in range(n):
    m = max(m, sum(a1[:i+1])+sum(b1[i:]))
print (m)

Fixed submission:
x = int(input())
a = int(input())
b = int(input())
print ((x-a)%b)

Buggy python submission (verdict: Runtime Error):
l = [int(input()) for i in range(4)]
#ABCX
count = 0
for i in range(l[2]+1):
    for j in range(l[1]+1):
        for k in range(l[0]+1):
            if (i*500+j*100+k*50)==l[3]:
                count += 1
print (count)    

Fixed submission:
x = int(input())
a = int(input())
b = int(input())
print ((x-a)%b)
Buggy python submission (verdict: Time Limit Exceeded):
n,y = list(map(int,input().split()))
if y/10000 > n:
    print('-1 -1 -1')
if y/10000 ==n:
    print('%d %d %d' % (y/10000, 0, 0))
else:
    b = False
    YY =[]
    Y10=int(y/10000)
    Y5 =int(y/5000)
    Y1 =int(y/1000)
    for i in range(Y10,-1,-1):
        if b== True or i > n:
            break
        for j in range(Y5+1-2*i):
            if b == True or i+j > n:
                break
            for k in range(Y1+1-10*i):
                if i+j+k == n and i*10000+j*5000+k*1000 ==y:
                    YY = [i,j,k]
                    print('%d %d %d' % (YY[0], YY[1], YY[2]))
                    b = True
                    break
                else:
                    YY=[]
        if i == 0 and b == False:
            print('-1 -1 -1')

Fixed submission:
n,y = list(map(int,input().split()))
if y/10000 > n:
    print('-1 -1 -1')
if y/10000 ==n:
    print('%d %d %d' % (y/10000, 0, 0))
else:
    b = False
    YY =[]
    Y10=int(y/10000)
    Y5 =int(y/5000)
    Y1 =int(y/1000)
    for i in range(Y10,-1,-1):
        if b== True or i > n:
            break
        for j in range(Y5+1-2*i):
            if b == True or i+j > n:
                break
            k = n - i - j
            if i*10000+j*5000+k*1000 ==y:
                YY = [i,j,k]
                print('%d %d %d' % (YY[0], YY[1], YY[2]))
                b = True
                break
            else:
                YY=[]
        if i == 0 and b == False:
            print('-1 -1 -1')
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
s = list(input())
ans = Yes
if len(s) != a+b+1:
    ans = 'No'
else:
    for i in range(a+b+1):
        if i == a and s[i] != '-':
            ans = 'No'
            break
        if (not s[i].isdigit()) and i != a:
            ans ='No'
            break
print (ans)


Fixed submission:
a,b = map(int,input().split())
s = list(input())
ans = 'Yes'
if len(s) != a+b+1:
    ans = 'No'
else:
    for i in range(a+b+1):
        if i == a and s[i] != '-':
            ans = 'No'
            break
        if (not s[i].isdigit()) and i != a:
            ans ='No'
            break
print (ans)

Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
s = list(input())
ans = True
for i in range(a+b+2):
    if i == a and s[i] != '-':
        ans = 'No'
    if not s[i].isdigit() and i != a:
        ans ='No'
        break
    if s[i].isdigit() and i != a:
        if 0>int(s[i]) or int(s[i]) > 9:
            ans ='No'
            
print (ans)

Fixed submission:
a,b = map(int,input().split())
s = list(input())
ans = 'Yes'
if len(s) != a+b+1:
    ans = 'No'
else:
    for i in range(a+b+1):
        if i == a and s[i] != '-':
            ans = 'No'
            break
        if (not s[i].isdigit()) and i != a:
            ans ='No'
            break
print (ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
f = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]

a     = []
count = 0
point = []
PP = []

for _ in range(1025,2048):
    a.append(list(map(int,list(bin(_)[3:]))))

for k in range(1024):
    for i in range(n):
        for j in range(10):
            if f[i][j]&a[k][j] == 1:
                count += 1
        point.append(p[i][count])
        count = 0
    PP.append(sum(point))
    point = []
print (max(PP))

Fixed submission:
n = int(input())
f = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]

a     = []
count = 0
point = []
PP = []

for _ in range(2**10+1,2**10*2):
    a.append(list(map(int,list(bin(_)[3:]))))

for k in range(2**10-1):
    for i in range(n):
        for j in range(10):
            if f[i][j]&a[k][j] == 1:
                count += 1
        point.append(p[i][count])
        count = 0
    PP.append(sum(point))
    point = []
print (max(PP))
Buggy python submission (verdict: Runtime Error):
import sys
import math
import numpy as np
INF = 1000000000
MOD = 2019


def input():
    return sys.stdin.readline().rstrip()


def main():
    l, r = [int(e) for e in input().split()]
    ans = INF
    for i in range(l, min(l + MOD, r + 1)):
        for j in range(j + 1, min(l + MOD, r + 1)):
            ans = min(ans, ((i % MOD) * (j % MOD)) % MOD)
    print(ans)


main()


Fixed submission:
import sys
import math
import numpy as np
INF = 1000000000
MOD = 2019


def input():
    return sys.stdin.readline().rstrip()


def main():
    l, r = [int(e) for e in input().split()]
    ans = INF
    for i in range(l, min(l + MOD, r + 1)):
        for j in range(i + 1, min(l + MOD, r + 1)):
            ans = min(ans, ((i % MOD) * (j % MOD)) % MOD)
    print(ans)


main()
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np


def input():
    return sys.stdin.readline().rstrip()


def main():
    n = int(input())
    a = [int(e) for e in input().split()]
    va = np.array(a)
    m = np.identity(n, dtype=int)
    for i in range(n):
        if i < n - 1:
            m[i][i + 1] = 1
        else:
            m[i][0] = 1
    vx = np.linalg.solve(m, va).astype(np.int) * 2
    print(*vx)


main()


Fixed submission:
import sys
import numpy as np


def input():
    return sys.stdin.readline().rstrip()


def main():
    n = int(input())
    a = [int(e) for e in input().split()]
    x = [0 for _ in range(n)]
    x[0] = sum(a) - (sum(a[1:n:2]) * 2)
    for i in range(2, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    x[1] = sum(a) - (sum(a[2:n:2]) * 2)
    for i in range(3, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    print(*x)


main()
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np


def main():
    n = int(input())
    balls = [[int(e) for e in input().split()] for _ in range(n)]
    diff = {}
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            if ((balls[i][0] - balls[j][0]), (balls[i][1] - balls[j][1])) in diff:
                diff[((balls[i][0] - balls[j][0]), (balls[i][1] - balls[j][1]))] += 1
            else:
                diff[((balls[i][0] - balls[j][0]), (balls[i][1] - balls[j][1]))] = 1
    print(n - max(diff.values()))


main()


Fixed submission:
import sys
import numpy as np


def main():
    n = int(input())
    balls = [[int(e) for e in input().split()] for _ in range(n)]
    if n == 1:
        print(n)
        sys.exit()
    diff = {}
    for i in range(n):
        for j in range(n):
            if i == j:
                continue
            if ((balls[i][0] - balls[j][0]), (balls[i][1] - balls[j][1])) in diff:
                diff[((balls[i][0] - balls[j][0]), (balls[i][1] - balls[j][1]))] += 1
            else:
                diff[((balls[i][0] - balls[j][0]), (balls[i][1] - balls[j][1]))] = 1
    print(n - max(diff.values()))


main()
Buggy python submission (verdict: Runtime Error):
import sys
import collections as col
import numpy as np


def main():
    n = int(input())
    aarray = [int(e) for e in input().split()]
    aqueue = col.deque(sorted(aarray))
    record = []
    while len(aqueue) > 2:
        amin = aqueue.popleft()
        amax = aqueue.pop()
        record.append((amin, amax))
        anext = aqueue.pop()
        record.append((anext, (amin - amax)))
        aqueue.append(anext - (amin - amax))
        aqueue = sorted(aqueue)
    if len(aqueue) == 2:
        amin = aqueue.popleft()
        amax = aqueue.pop()
        print(amax - amin)
        record.append((amax, amin))
    else:
        print(aqueue.pop())
    for r in record:
        print(r[0], r[1])


main()


Fixed submission:
import sys
import collections as col
import bisect
import numpy as np


def main():
    n = int(input())
    aarray = [int(e) for e in input().split()]
    aarray.sort()
    record = []
    endpoint = max(1, bisect.bisect(aarray, 0))
    aqueue = col.deque(aarray)
    while len(aqueue) > endpoint + 1:
        amax = aqueue.pop()
        amin = aqueue.popleft()
        record.append((amin, amax))
        aqueue.appendleft(amin - amax)
    amax = aqueue.pop()
    while len(aqueue) > 0:
        amin = aqueue.popleft()
        record.append((amax, amin))
        amax -= amin
    print(amax)
    for r in record:
        print(r[0], r[1])


main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
MOD = 1000000007


def main():
    bits = input()
    ans = 1
    for i, b in enumerate(reversed(bits)):
        if b == '1':
            ans = ((ans * 2 % MOD) + pow(3, i)) % MOD
    print(ans)


main()


Fixed submission:
import sys
import numpy as np
MOD = 1000000007


def main():
    bits = input()
    ans = 1
    pow3 = 1
    for i, b in enumerate(reversed(bits)):
        if b == '1':
            ans = ((ans * 2 % MOD) + pow3) % MOD
        pow3 = (pow3 * 3) % MOD
    print(ans)


main()
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
cntA = 0
for i in range(0, len(s) - 1):
    if s[i] == 'A':
        cntA += 1
    elif s[i: i + 2] == "BC":
        cntANext = 0
        for j in range(0, cntA):
            ans += 1
            cntANext += 1
        cntA = cntANext
    elif i > 0 and s[i - 1: i + 1] == "BC":
        continue
    else:
        cntA = 0
print(ans)
# print(*data, sep='\n')


Fixed submission:
s = input()
ans = 0
cntA = 0
for i in range(0, len(s) - 1):
    if s[i] == 'A':
        cntA += 1
    elif s[i: i + 2] == "BC":
        ans += cntA
    elif i > 0 and s[i - 1: i + 1] == "BC":
        continue
    else:
        cntA = 0
print(ans)
# print(*data, sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
cntA = 0
for i in range(0, len(s) - 1):
    if s[i] == 'A':
        cntA += 1
    elif s[i: i + 2] == "BC":
        cntANext = 0
        for j in range(0, cntA):
            ans += 1
            cntANext += 1
        cntA = cntANext
    elif i > 0 and s[i - 1: i + 1] == "BC":
        continue
    else:
        cntA = 0
print(ans)
# print(*data, sep='\n')


Fixed submission:
s = input()
ans = 0
cntA = 0
for i in range(0, len(s) - 1):
    if s[i] == 'A':
        cntA += 1
    elif s[i: i + 2] == "BC":
        ans += cntA
    elif i > 0 and s[i - 1: i + 1] == "BC":
        continue
    else:
        cntA = 0
print(ans)
# print(*data, sep='\n')
Buggy python submission (verdict: Runtime Error):
import sys
MOD = 1_000_000_007


def main():
    h, w, k = [int(x) for x in input().split()]
    fibonacci = [1, 2]
    for i in range(w - 2):
        fibonacci.append(fibonacci[i] + fibonacci[i + 1])
    pattern = [0 for _ in range(w)]
    pattern[0] = 1
    for _ in range(h):
        nextp = [0 for _ in range(w)]
        for i in range(w):
            nextp[i] = (pattern[i] * (fibonacci[max(0, i - 1)] * fibonacci[max(0, w - (i + 2))])) % MOD
            if i > 0:
                nextp[i] += (pattern[i - 1] * (fibonacci[max(0, i - 2)] * fibonacci[max(0, w - (i + 2))])) % MOD
            if i < w - 1:
                nextp[i] += (pattern[i + 1] * (fibonacci[max(0, i - 1)] * fibonacci[max(0, w - (i + 3))])) % MOD
            nextp[i] %= MOD
        pattern = nextp
    print(pattern[k-1])


main()


Fixed submission:
import sys
MOD = 1000000007


def main():
    h, w, k = [int(x) for x in input().split()]
    fibonacci = [1, 2]
    for i in range(w - 2):
        fibonacci.append(fibonacci[i] + fibonacci[i + 1])
    pattern = [0 for _ in range(w)]
    pattern[0] = 1
    for _ in range(h):
        nextp = [0 for _ in range(w)]
        for i in range(w):
            nextp[i] = (pattern[i] * (fibonacci[max(0, i - 1)] * fibonacci[max(0, w - (i + 2))])) % MOD
            if i > 0:
                nextp[i] += (pattern[i - 1] * (fibonacci[max(0, i - 2)] * fibonacci[max(0, w - (i + 2))])) % MOD
            if i < w - 1:
                nextp[i] += (pattern[i + 1] * (fibonacci[max(0, i - 1)] * fibonacci[max(0, w - (i + 3))])) % MOD
            nextp[i] %= MOD
        pattern = nextp
    print(pattern[k-1])


main()
Buggy python submission (verdict: Runtime Error):
import sys
import itertools
import numpy as np
MOD = 3
INF = 1000000000


def input():
    return sys.stdin.readline().rstrip()


def main():
    n, c = [int(e) for e in input().split()]
    dMat = [[int(e) for e in input().split()] for _ in range(c)]
    cMat = [[int(e) for e in input().split()] for _ in range(n)]

    cost = [[0 for _ in range(c)] for _ in range(MOD)]
    for hi in range(n):
        for wi in range(n):
            cMod = ((hi + 1) + (wi + 1)) % MOD
            for ci in range(c):
                cost[cMod][ci] += dMat[cMat[hi][wi] - 1][ci]

    ans = INF
    for perm in itertools.permutations(range(c), MOD):
        costSum = 0
        for di in range(MOD):
            costSum += cost[di][perm[di]]
        ans = min(ans, costSum)
    print(ans)


main()


Fixed submission:
import sys
import itertools
import numpy as np
MOD = 3
INF = 1000000000


def input():
    return sys.stdin.readline().rstrip()


def main():
    n, c = [int(e) for e in input().split()]
    dMat = [[int(e) for e in input().split()] for _ in range(c)]
    cMat = [[int(e) for e in input().split()] for _ in range(n)]

    cost = [[0 for _ in range(c)] for _ in range(MOD)]
    for hi in range(n):
        for wi in range(n):
            cMod = ((hi + 1) + (wi + 1)) % MOD
            for ci in range(c):
                cost[cMod][ci] += dMat[cMat[hi][wi] - 1][ci]

    ans = INF
    for perm in itertools.permutations(range(c), MOD):
        costSum = 0
        for di in range(MOD):
            costSum += cost[di][perm[di]]
        ans = min(ans, costSum)
    print(ans)


main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin


def resolve():
    n = int(stdin.readline().rstrip())
    # s = stdin.readline().rstrip()
    # A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
    a = [int(x) for x in stdin.readline().rstrip().split()]

    a = sorted(a)
    if n % 2 == 1:
        if a[0] != 0:
            return 0
        a = a[1:]

    predict = 1 + (n % 2)
    while len(a) > 0:
        if a[0] != predict or a[1] != predict:
            return 0
        a = a[2:]
        predict += 2

    ret = 1
    for i in range(0, n // 2):
        ret = (ret * 2) % 1000000007
    return ret


print(resolve(), '\n')
# print(*data, sep='\n')


Fixed submission:
from sys import stdin


def resolve():
    n = int(stdin.readline().rstrip())
    # s = stdin.readline().rstrip()
    # A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
    a = [int(x) for x in stdin.readline().rstrip().split()]

    a = sorted(a)
    predict = [n - (((n - i + 1) // 2) * 2) + 1 for i in range(0, n)]
    if a != predict:
        return 0

    ret = 1
    for i in range(0, n // 2):
        ret = (ret * 2) % 1000000007
    return ret


print(resolve(), '\n')
# print(*data, sep='\n')
Buggy python submission (verdict: Runtime Error):
s=list(input())
k=int(input())
s.append(-1)
i=0
ans=-1
while True:
    if s[i]=="-1":
        ans=s[i]
        break
    if s[i]!="1":
        ans=s[i]
        if i+1>k:
            ans="1"   
        break
    i+=1
print(ans)


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

print(ls[n//2]-ls[n//2-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys

n=int(input())
ls=list(map(int,input().split()))
ls.sort()
end_k=ls[len(ls)//2]

cnt=0

for i in range(end_k):
    num=0
    for j in range(n):
        if ls[j]>i:
            num+=1
    if num==n//2:
        cnt+=1

print(cnt)


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

print(ls[n//2]-ls[n//2-1])
Buggy python submission (verdict: Runtime Error):
import math

a,b,c,d=map(int,input().split())
cn1=0
cn2=0
cn3=0
an1=0
an2=0
an3=0
cnt=0
ans=0
lm=(c*d)//math.gcd(c,d)

#bまで
cn1=b//c
cn2=b//d
cn3=b//lm
#aまで
an1=(a-1)//c
an2=(a-1)//d
an3=(a-1)//lm
#aからbまで
cn1=cn1-an1
cn2=cn2-an2
cn3=cn3-an3

cnt=cn1+cn2-cn3
ans=b-a-cnt

print(ans+1)


Fixed submission:
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return(a)

a,b,c,d=map(int,input().split())
cn1=0
cn2=0
cn3=0
an1=0
an2=0
an3=0
cnt=0
ans=0
lm=(c*d)//gcd(c,d)

#bまで
cn1=b//c
cn2=b//d
cn3=b//lm
#aまで
an1=(a-1)//c
an2=(a-1)//d
an3=(a-1)//lm
#aからbまで
cn1=cn1-an1
cn2=cn2-an2
cn3=cn3-an3

cnt=cn1+cn2-cn3
ans=b-a-cnt

print(ans+1)

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

def lcm(x,y):
    return (x*y)//math.gcd(x,y)

a,b,c,d=map(int,input().split())
cn1=0
cn2=0
cn3=0
an1=0
an2=0
an3=0
cnt=0
ans=0
lm=lcm(c,d)

#bまで
cn1=b//c
cn2=b//d
cn3=b//lm
#aまで
an1=(a-1)//c
an2=(a-1)//d
an3=(a-1)//lm
#aからbまで
cn1=cn1-an1
cn2=cn2-an2
cn3=cn3-an3

cnt=cn1+cn2-cn3
ans=b-a-cnt

print(ans+1)


Fixed submission:
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return(a)

a,b,c,d=map(int,input().split())
cn1=0
cn2=0
cn3=0
an1=0
an2=0
an3=0
cnt=0
ans=0
lm=(c*d)//gcd(c,d)

#bまで
cn1=b//c
cn2=b//d
cn3=b//lm
#aまで
an1=(a-1)//c
an2=(a-1)//d
an3=(a-1)//lm
#aからbまで
cn1=cn1-an1
cn2=cn2-an2
cn3=cn3-an3

cnt=cn1+cn2-cn3
ans=b-a-cnt

print(ans+1)

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

def lcm(x,y):
    return (x*y)//math.gcd(x,y)

def hantei(A,B,C,D):
    if (A%C==0 or A%D==0) and (B%C==0 or B%D==0):
        return False
    return True

a,b,c,d=map(int,input().split())
cn1=0
cn2=0
cn3=0
an1=0
an2=0
an3=0
cnt=0
ans=0
lm=lcm(c,d)

#bまで
cn1=b//c
cn2=b//d
cn3=b//lm
#aまで
an1=a//c
an2=a//d
an3=a//lm
#aからbまで
cn1=cn1-an1
cn2=cn2-an2
cn3=cn3-an3

cnt=cn1+cn2-cn3
ans=b-a-cnt

if hantei(a,b,c,d):
    ans+=1

print(ans)


Fixed submission:
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return(a)

a,b,c,d=map(int,input().split())
cn1=0
cn2=0
cn3=0
an1=0
an2=0
an3=0
cnt=0
ans=0
lm=(c*d)//gcd(c,d)

#bまで
cn1=b//c
cn2=b//d
cn3=b//lm
#aまで
an1=(a-1)//c
an2=(a-1)//d
an3=(a-1)//lm
#aからbまで
cn1=cn1-an1
cn2=cn2-an2
cn3=cn3-an3

cnt=cn1+cn2-cn3
ans=b-a-cnt

print(ans+1)
Buggy python submission (verdict: Runtime Error):
a=input().split()
if a[0]>a[1]:
    print("GREATER\n")
elif a[0]==a[1]:
    print("EQUAL\n")
else:
    print("LESS\n")

Fixed submission:
a=int(input())
b=int(input())
if a>b:
    print("GREATER\n")
elif a==b:
    print("EQUAL\n")
else:
    print("LESS\n")

Buggy python submission (verdict: Runtime Error):
a=input().split()
if a[0]>a[1]:
    print("GREATER")
elif a[0]==a[1]:
    print("EQUAL")
else:
    print("LESS")

Fixed submission:
a=int(input())
b=int(input())
if a>b:
    print("GREATER\n")
elif a==b:
    print("EQUAL\n")
else:
    print("LESS\n")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
cnt = [0]*n
for i in range(n):
    cnt[i] = s[0:i].count("W") + s[i+1:n].count("E")
print(min(cnt))

Fixed submission:
n = int(input())
s = input()
cnt = [0]*n
cnt_e = [0]*n
cnt_w = [0]*n
e = 0
w = 0
for i in range(n):
    if s[i] == "E":
        e += 1
    else :
        w += 1
    cnt_e[i] = e
    cnt_w[i] = w

cnt[0] =  e - cnt_e[0]
for i in range(1,n):
    cnt[i] = cnt_w[i-1] + e - cnt_e[i]

print(min(cnt))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
 
c = a*b
 
if c%2 == 0:
    print("Even")
else :
    print("Odd")

Fixed submission:
a, b = map(int,input().split())
c = a*b
 
if c%2 == 0:
    print("Even")
else :
    print("Odd")

Buggy python submission (verdict: Runtime Error):
a = int(input("aa= "))
b = int(input("bb= "))

c = a*b

if c%2 == 0:
    print("Even")
else :
    print("Odd")

Fixed submission:
a, b = map(int,input().split())
c = a*b
 
if c%2 == 0:
    print("Even")
else :
    print("Odd")

Buggy python submission (verdict: Runtime Error):
a = int(input("aa= "))
b = int(input("bb= "))

c = a*b

if c%2 == 0:
    print("even")
else :
    print("odd")

Fixed submission:
a, b = map(int,input().split())
c = a*b
 
if c%2 == 0:
    print("Even")
else :
    print("Odd")

Buggy python submission (verdict: Runtime Error):
a = int(input("aa= "))
b = int(input("bb= "))

c = a*b

print(c%2)
if c%2 == 0:
    print("even")
else :
    print("odd")

Fixed submission:
a, b = map(int,input().split())
c = a*b
 
if c%2 == 0:
    print("Even")
else :
    print("Odd")
Buggy python submission (verdict: Runtime Error):
a = [int(input()) for _ in range(n)]
a.sort(reverse = True)
print(len(list(set(a))))

Fixed submission:
n = int(input())
a = [0]*n
for i in range(n):
    a[i] = int(input())
a.sort(reverse = True)

s = set(a)
a_list = list(s)
print(len(a_list))