Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
b = input()

if b == "A":
  ans = T
elif b == "T":
  ans = A
elif b == "G":
  ans = C
else:
  ans = G
  
print(ans)

Fixed submission:
b = input()

if b == "A":
  ans = "T"
elif b == "T":
  ans = "A"
elif b == "G":
  ans = "C"
else:
  ans = "G"
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = str(input())

for i in range(q):
  l, r = map(int, input().split())
  slice = s[l-1:r]
  print(slice.count("AC"))


Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])
Buggy python submission (verdict: Runtime Error):
D, G = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(D)]

ans = float("inf")

for bit in range(1 << D):
    count = 0
    sum = 0
    rest = list(range(1, D+1))

    for i in range(D):
        if bit & (1 << i):
            sum += 100 * i * pc[i][0] + pc[i][1]
            count += pc[i][0]
            rest.remove(i+1)
    if sum < G:
        max_num = max(rest)
        n = min(pc[max_num - 1][0], (G - sum) // (max_num * 100))
        count += n
        sum += n*max_num * 100
    if sum >= G:
        ans = min(ans, count)

print(ans)


Fixed submission:
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]

ans = float("inf")

for bit in range(1 << d):
    count = 0
    sum = 0
    nokori = set(range(1, d + 1))

    for i in range(d):
        if bit & (1 << i):
            sum += pc[i][0] * (i + 1) * 100 + pc[i][1]
            count += pc[i][0]
            nokori.discard(i + 1)

    # G 点に満たなければ nokori のうち一番大きいものを解く
    if sum < g:
        use = max(nokori)
        n = min(pc[use - 1][0], -(-(g - sum) // (use * 100)))
        count += n
        sum += n * use * 100

    if sum >= g:
        ans = min(ans, count)

print(ans)
Buggy python submission (verdict: Runtime Error):
def make7(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        make7(i+1, f+"+"+S[i+1], sum+S[i+1])
        make7(i+1, f+"-"+S[i+1], sum-S[i+1])


S = input()
n = len(S)

make7(0, S[0], S[0])


Fixed submission:
def make7(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        make7(i+1, f+"+"+S[i+1], sum+int(S[i+1]))
        make7(i+1, f+"-"+S[i+1], sum-int(S[i+1]))


S = input()
n = len(S)

make7(0, S[0], int(S[0]))

Buggy python submission (verdict: Runtime Error):
def make7(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        make7(i+1, f+"+"+S[i+1], sum+S[i+1])
        make7(i+1, f+"-"+S[i+1], sum+S[i+1])


S = input()
n = len(S)

make7(0, S[0], 0)


Fixed submission:
def make7(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        make7(i+1, f+"+"+S[i+1], sum+int(S[i+1]))
        make7(i+1, f+"-"+S[i+1], sum-int(S[i+1]))


S = input()
n = len(S)

make7(0, S[0], int(S[0]))

Buggy python submission (verdict: Runtime Error):
def make7(i, f):
    if i == 3:
        if sum(map(int, f.split("+"))) == 7:
            print(f + "=7")
            exit()
    else:
        make7(i+1, f+"+"+S[i+1])
        make7(i+1, f+"-"+S[i+1])


S = input()
n = len(S)

make7(0, S[0])


Fixed submission:
def make7(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    else:
        make7(i+1, f+"+"+S[i+1], sum+int(S[i+1]))
        make7(i+1, f+"-"+S[i+1], sum-int(S[i+1]))


S = input()
n = len(S)

make7(0, S[0], int(S[0]))
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
count = 0

for i in range(0, k+1):
    for j in range(0, k+1):
        for k in range(0, k+1):
            if s == i+j+k:
                count += 1

print(count)


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

for i in range(0, K+1):
    for j in range(0, K+1):
        k = S-j-i
        if k >= 0 and k <= K:
            count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a=[]
b=[]
for i in range(n):
    aa,bb = map(int,input().split())
    a.append(aa)
    b.append(bb)
sum = 0
for i in range(n):
    bb=b.index(min(b))
    bbuf = b.pop(bb)
    sum += a[bb]
    a.pop(bb)
    if sum>bbuf:
        print("No")
        exit()
print("Yes")


Fixed submission:
n = int(input())
ab=[]
for i in range(n):
    ab.append(list(map(int,input().split())))
sum = 0
ab.sort(key=lambda x:x[1])
for i in range(n):
    sum += ab[i][0]
    if sum>ab[i][1]:
        print("No")
        exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
l=[0]
for _ in range(n):
  l.append(int(input()))
cnt=0
sum=0
for i in range(n):
  sum+=l[i]
  if sum<=x:
    cnt+=1
print(cnt)

Fixed submission:
n,x = map(int,input().split())
l=list(map(int,input().split()))
cnt=1
suml=0
for i in range(n):
  suml+=l[i]
  if suml<=x:
    cnt+=1
print(cnt)
Buggy python submission (verdict: Runtime Error):
#3.7.3 -> import math
from fractions import gcd

# [0,--list--,0]
N = int(input())
A = [0]+list(map(int,input().split()))+[0]
L = [0]*(N+2)
R = [0]*(N+2)
#0,A[1]->L[i-1],A[i]->L[N-1],A[N]
for i in range(1,N+1):
    L[i] = math.gcd(L[i-1],A[i])
#0,A[N]->R[i+1],A[i]->R[2],A[1]
for i in range(N,0,-1):
    R[i] = math.gcd(R[i+1],A[i])
#A[i]を含めないL,Rのgcdをすべて並べてmaxをとる
print(max(math.gcd(L[i-1],R[i+1]) for i in range(1,N+1)))

Fixed submission:
#3.7.3 -> import math
from fractions import gcd

# [0,--list--,0]
N = int(input())
A = [0]+list(map(int,input().split()))+[0]
L = [0]*(N+2)
R = [0]*(N+2)
#0,A[1]->L[i-1],A[i]->L[N-1],A[N]
for i in range(1,N+1):
    L[i] =gcd(L[i-1],A[i])
#0,A[N]->R[i+1],A[i]->R[2],A[1]
for i in range(N,0,-1):
    R[i] = gcd(R[i+1],A[i])
#A[i]を含めないL,Rのgcdをすべて並べてmaxをとる
print(max(gcd(L[i-1],R[i+1]) for i in range(1,N+1)))

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

N = int(input())
A = list(map(int,input().split()))
max = 0
L = []
R = []
for i in range(N):
    L = A[:i]
    R = A[i:]
    if i > 0 :
        L.pop()
    while 2>len(L) or 2>len(R):
        L.append(0)
        R.append(0)
    x = reduce(math.gcd,L)
    y = reduce(math.gcd,R)
    gcdmax = math.gcd(x,y)
    if max < gcdmax:
        max = gcdmax
print(max)


Fixed submission:
#3.7.3 -> import math
from fractions import gcd

# [0,--list--,0]
N = int(input())
A = [0]+list(map(int,input().split()))+[0]
L = [0]*(N+2)
R = [0]*(N+2)
#0,A[1]->L[i-1],A[i]->L[N-1],A[N]
for i in range(1,N+1):
    L[i] =gcd(L[i-1],A[i])
#0,A[N]->R[i+1],A[i]->R[2],A[1]
for i in range(N,0,-1):
    R[i] = gcd(R[i+1],A[i])
#A[i]を含めないL,Rのgcdをすべて並べてmaxをとる
print(max(gcd(L[i-1],R[i+1]) for i in range(1,N+1)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = str(input())
if s.count(“R”)>s.count(“B”):
  print(“Yes”)
else:
  print(“No”)


Fixed submission:
n = int(input())
s = str(input())
if s.count("R")>s.count("B"):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
s = input()
mins = 1000
for i in renge(len(s)-2):
  mins = min(mins,abs(753-((int(s[i])+int(s[i+1])+int(s[i+2])))
print(mins)

Fixed submission:
s = str(input())
mins = 1000
for i in range(len(s)-2):
    mins = min(mins,abs(753-(int(s[i:i+3]))))
print(mins)
Buggy python submission (verdict: Runtime Error):
n,m,x,y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
if x<y-1 and max(x)<min(y)-1:
    print("No War")
else:
    print("War")


Fixed submission:
n,m,x,y = map(int,input().split())
xx = list(map(int,input().split()))
yy = list(map(int,input().split()))
if x<y and max(xx)<min(yy) and x<min(yy) and max(xx)<y:
    print("No War")
else:
    print("War")
Buggy python submission (verdict: Runtime Error):
n =int(input())
for i in range(16):
    if (n%(i*7))%4==0:
        print("Yes")
        exit()
print("No")


Fixed submission:
n =int(input())
for i in range(16):
    for j in range(26):
        if i*7+j*4==n:
            print("Yes")
            exit()
print("No")
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
s=[]
for _ in range(h):
  s.append(str(input()))
for i in range(h):
  for j in range(w):
    flag=False
    if s[i][j]!="#":
      continue
    for k in [-1,1]:
      if 0<=i+k<h:
        if s[i+k][j]=="#":
          flag=True
      if 0<=j+k<h:
        if s[i][j+k]=="#":
          flag=True
    if not flag:
      print("No")
      exit()
print("Yes")

Fixed submission:
h,w = map(int,input().split())
s=[]
for _ in range(h):
  s.append(str(input()))
for i in range(h):
  for j in range(w):
    flag=False
    if s[i][j]!="#":
      continue
    for k in [-1,1]:
      if 0<=i+k<h:
        if s[i+k][j]=="#":
          flag=True
      if 0<=j+k<w:
        if s[i][j+k]=="#":
          flag=True
    if not flag:
      print("No")
      exit()
print("Yes")

Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
s=[]
for _ in range(h):
  s.append(str(input()))
for i in range(h):
  for j in range(w):
    flag=False
    if s[i][j]!="#":
      break
    for k in [-1,1]:
      if 0<=i+k<h:
        if s[i+k][j]=="#":
          flag=True
      if 0<=j+k<h:
        if s[i][j+k]=="#":
          flag=True
    if not flag:
      print("No")
      exit()
print("Yes")

Fixed submission:
h,w = map(int,input().split())
s=[]
for _ in range(h):
  s.append(str(input()))
for i in range(h):
  for j in range(w):
    flag=False
    if s[i][j]!="#":
      continue
    for k in [-1,1]:
      if 0<=i+k<h:
        if s[i+k][j]=="#":
          flag=True
      if 0<=j+k<w:
        if s[i][j+k]=="#":
          flag=True
    if not flag:
      print("No")
      exit()
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k = map(int,input().split())
for i in range(a,b+1):
    if (i<a+k) or (b-k<i):
        print(i)


Fixed submission:
a,b,k = map(int,input().split())
x=[]
for i in range(k):
    if a<=a+i<=b:
        x.append(a+i)
        x.append(b-i)
x = sorted(list(set(x)))
for i in x:
    print(i)
Buggy python submission (verdict: Runtime Error):
r = input()
g = input()
print(2*g-r)


Fixed submission:
r = int(input())
g = int(input())
print(2*g-r)
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
dd=[0]*(max(d)+1)
tt=[0]*(max(t)+1)
for i in range(n):
    dd[d[i]]+=1
for i in range(m):
    tt[t[i]]+=1
for i in range(m):
    if tt[t[i]]>dd[t[i]]:
        print("NO")
        exit()
print("YES")

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
d.sort()
t.sort()
i=0
j=0
while i<m and j<n:
    if t[i]==d[j]:
        i+=1
        j+=1
    elif t[i]<d[j]:
        print("NO")
        exit()
    else:
        j+=1
print("YES")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
for i in range(m):
    if d.count(t[i])>0:
        d.remove(t[i])
    else:
        print("NO")
        exit()
print("YES")

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
d.sort()
t.sort()
i=0
j=0
while i<m and j<n:
    if t[i]==d[j]:
        i+=1
        j+=1
    elif t[i]<d[j]:
        print("NO")
        exit()
    else:
        j+=1
print("YES")
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(n):
    a1,b1=map(int,input().split())
    a.append(a1)
    b.append(b1)
for i in range(m):
    c1,d1=map(int,input().split())
    c.append(c1)
    d.append(d1)
for i in range(n):
    min_len = 100000000
    for j in range(m):
        len = abs(c[j]-a[i])+abs(d[j]-b[i])
        if len < min_len:
            min_len=len
            cnt = j+1
    print(cnt)

Fixed submission:
n,m = map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(n):
    a1,b1=map(int,input().split())
    a.append(a1)
    b.append(b1)
for i in range(m):
    c1,d1=map(int,input().split())
    c.append(c1)
    d.append(d1)
for i in range(n):
    min_len = 1000000000
    cnt = None
    for j in range(m):
        len = abs(c[j]-a[i])+abs(d[j]-b[i])
        if len < min_len:
            min_len=len
            cnt = j+1
    print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1
for i in range(1,n+1):
    ans *= i
print(ans%(10**9+7))

Fixed submission:
import math
n = int(input())
ans = math.factorial(n)
print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

print((a-1) * (b-1))

Fixed submission:
a, b = (int(i) for i in input().split())

print((a-1) * (b-1))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]

b = []
for i in range(len(a)):
    b.append(a[i] - (i+1))

while True:
    p_num = []
    n_num = []
    z_num = []
    for i in range(len(b)):
        if b[i] > 0:
            p_num.append(b[i])
        elif b[i] < 0:
            n_num.append(b[i])
        else:
            z_num.append(b[i])

    if len(p_num) > len(n_num) + len(z_num):
        for i in range(len(b)):
            b[i] = b[i] - 1
    elif len(n_num) > len(p_num) + len(z_num):
        for i in range(len(b)):
            b[i] = b[i] + 1
    else:
        break

ans = 0
for i in range(len(b)):
    ans += abs(b[i])

print(ans)


Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

b = []
for i in range(len(a)):
    b.append(a[i] - (i+1))

p_num = []
n_num = []
z_num = []

for i in range(len(b)):
    if b[i] > 0:
        p_num.append(b[i])
    elif b[i] < 0:
        n_num.append(b[i])
    else:
        z_num.append(b[i])

p_num.sort()
n_num.sort()
n_num.reverse()

if len(p_num) > len(n_num) + len(z_num):
    count_n = len(n_num) + len(z_num)
    count_p = len(p_num)
    index = -1
    while  count_p > count_n:
        count_p -= 1
        count_n += 1
        index += 1
    for i in range(len(b)):
        b[i] = b[i] - p_num[index]

elif len(n_num) > len(p_num) + len(z_num):
    count_n = len(n_num)
    count_p = len(p_num) + len(z_num)
    index = -1
    while  count_n > count_p:
        count_n -= 1
        count_p += 1
        index += 1
    for i in range(len(b)):
        b[i] = b[i] - n_num[index]

ans = 0
for i in range(len(b)):
    ans += abs(b[i])

print(ans)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

if a > 8 or b > 8:
    print(':(')
else:
    print('Yay!')


Fixed submission:
a,b = (int(i) for i in input().split())

if a > 8 or b > 8:
    print(':(')
else:
    print('Yay!')
Buggy python submission (verdict: Runtime Error):
N=int(input())
s=input()

count=0
i=0
j=N-1

while i<j:
    if s[i]=="E":
        i+=1
        continue
    if s[j]=="W":
        j-=1
        continue
    sub_i=i
    sub_j=j
    j_i=0
    j_j=0
    while s[sub_i]=="W":
        sub_i+=1
        j_i+=1
    while s[sub_j]=="E":
        sub_j-=1
        j_j+=1
    if j_i<j_j:
        i=sub_i
        count+=1
    else:
        j=sub_j
        count+=1
    
print(count)


Fixed submission:
a,b=(int(i) for i in input().split())

c=[]
c.append(a+b)
c.append(a-b)
c.append(a*b)
c.sort()

print(c[-1])

Buggy python submission (verdict: Runtime Error):
N=int(input())
s=input()

count=0
i=0
j=N-1

while i<=j:
    if s[i]=="E":
        i+=1
        continue
    if s[j]=="W":
        j-=1
        continue
    sub_i=i+1
    sub_j=j-1
    j_i=0
    j_j=0
    while s[sub_i]=="E":
        sub_i+=1
        j_i+=1
    while s[sub_j]=="W":
        sub_j-=1
        j_j+=1
    if j_i>j_j:
        i=sub_i
        count+=1
    else:
        j=sub_j
        count+=1
    


Fixed submission:
a,b=(int(i) for i in input().split())

c=[]
c.append(a+b)
c.append(a-b)
c.append(a*b)
c.sort()

print(c[-1])
Buggy python submission (verdict: Runtime Error):
a,b,x=(int(i) for i in input().split()))

if a>x:
    print('NO')
elif a+b<x:
    print('NO')
else:
    print('YES')

Fixed submission:
a,b,x=(int(i) for i in input().split())

if a>x:
    print('NO')
elif a+b<x:
    print('NO')
else:
    print('YES')
Buggy python submission (verdict: Runtime Error):
if x < a:
    print(0)
else:
    print(10)

Fixed submission:
x, a = input().split()
if x < a:
    print(0)
else:
    print(10)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))

import fractions
from functools import reduce
from copy import copy

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

gcds=[]
for i in range(N):
    A_=copy(A)
    A_=pop(i)
    gcds.append(gcd(*A_))

print(max(gcds))


Fixed submission:
A,B,T=map(int,input().split())
print(T//A*B)

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

import fraction
from functools import reduce
from copy import copy

def gcd(*numbers):
    return reduce(fraction.gcd, numbers)

gcds=[]
for i in range(N):
    A_=copy(A)
    A_=pop(i)
    gcds.append(gcd(*A_))

print(max(gcds))


Fixed submission:
A,B,T=map(int,input().split())
print(T//A*B)

Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
T=int(input())
print(T//A*B)

Fixed submission:
A,B,T=map(int,input().split())
print(T//A*B)

Buggy python submission (verdict: Runtime Error):
A=int(input())
B=int(input())
T=int(input())
print(T/A*B)

Fixed submission:
A,B,T=map(int,input().split())
print(T//A*B)
Buggy python submission (verdict: Time Limit Exceeded):
time = 0
people = int(input())
capacity = []
for i in range(5):
    capacity.append(int(input()))
city = [0]*6
city[0] = people

while city[5] < people:
    time += 1
    for i in range(5):
        t = min(capacity[4-i],city[4-i])
        city[4-i] -= t
        city[5-i] += t

print(time)

Fixed submission:
import math
time = 5
people = int(input())
capacity = []
for i in range(5):
    capacity.append(int(input()))

time += math.ceil(people/min(capacity)) - 1
print(time)
Buggy python submission (verdict: Runtime Error):
def calc(n, p):
    count = 0
    for i in range(1, n-1):
        if p[i-1] < p[i] and p[i] < p[i+1]:
            count += 1
            continue
        if p[i-1] > p[i] and p[i] > p[i+1]:
            count += 1
            continue

    return count
print(calc(input(), list(input().split())))

Fixed submission:
def calc(n, p):
    count = 0
    for i in range(1, n-1):
        if p[i-1] < p[i] and p[i] < p[i+1]:
            count += 1
            continue
        if p[i-1] > p[i] and p[i] > p[i+1]:
            count += 1
            continue
    return count
print(calc(int(input()), [int(a) for a in input().split()]))
Buggy python submission (verdict: Runtime Error):

n = int(input())

li = []
for i in range(n):
    li.append(list(input().split()))


for money in li:
    if money[1] == 'JPN':
        continue
    else:
        money[0] = int(money[0]) * 380000.0

sum_money = sum([int(i[0]) for i in li])

print(sum_money)

Fixed submission:
n = int(input())
 
li = []
for i in range(n):
    li.append(list(input().split()))
 
 
for money in li:
    if money[1] == 'JPY':
        continue
    else:
        money[0] = float(money[0]) * 380000.0
 
sum_money = sum([float(i[0]) for i in li])
  
print(sum_money)

Buggy python submission (verdict: Runtime Error):

n = int(input())

li = []
for i in range(n):
    li.append(list(map(float, input().split())))


for money in li:
    if money[1] == 'JPN':
        continue
    else:
        money[0] *= 380000.0

sum_money = sum([i[0] for i in li])


Fixed submission:
n = int(input())
 
li = []
for i in range(n):
    li.append(list(input().split()))
 
 
for money in li:
    if money[1] == 'JPY':
        continue
    else:
        money[0] = float(money[0]) * 380000.0
 
sum_money = sum([float(i[0]) for i in li])
  
print(sum_money)
Buggy python submission (verdict: Runtime Error):
import sys

argvs = sys.argv

if len(argvs) < 2:
    sys.exit(1)

try:
    a = int(argvs[1])
    b = int(argvs[2])
except TypeError:
    sys.exit(1)

if b % a == 0:
    print(a+b)
else:
    print(b-a)


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

if b % a == 0:
    print(a+b)
else:
    print(b-a)
Buggy python submission (verdict: Runtime Error):
N = int(input())
dlist = list(map(int, input().split()))

dlist.sort()
print(dlist[N/2]-dlist[N/2-1])

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

dlist.sort()
N = int(N/2)
print(dlist[N]-dlist[N-1])
Buggy python submission (verdict: Runtime Error):
import math

A, B, C, D = map(int, input().split())

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

allnum =  B -A +1
if A%C==0:
    Csta = A
else:    
    Csta = A + (C-A%C)
if B%C==0:
    Cowa = B
else:    
    Cowa = B -B%C

if A%D==0:
    Dsta = A
else:    
    Dsta = A + (D-A%D)
if B%D==0:
    Dowa = B
else:    
    Dowa = B -B%D     

E = lcm(C, D)
if A%E==0:
    Esta = A
else:    
    Esta = A + (E-A%E)
if B%E==0:
    Eowa = B
else:    
    Eowa = B -B%E     

if A>Csta or B<Csta:
    Cnum = 0
else:
    Cnum = (Cowa-Csta+C)/C

if A>Dsta or B<Dsta:
    Dnum = 0
else:
    Dnum = (Dowa-Dsta+D)/D

if A>Esta or B<Esta:
    Enum = 0
else:
    Enum = (Eowa-Esta+E)/E


num = allnum - Cnum - Dnum + Enum
print(int(num))


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

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

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

allnum =  B -A +1
E = lcm(C, D)

Cnum = (B//C) - ((A-1)//C)
Dnum = (B//D) - ((A-1)//D)
Enum = (B//E) - ((A-1)//E)

num = allnum - Cnum - Dnum + Enum
print(int(num))
Buggy python submission (verdict: Runtime Error):

W, H, x, y = map(int, input().split())
if x=W:
    if H-y < y:
        y = H-y
    print(y*W, "0")    
elif y=H:
    if W-x < x:
        x = W-x
    print(x*H, "0")
    
else:
    if W-x < x:
        x = W-x
    if H-y < y:
        y = H-y

    if x*H > y*W: 
        print(y*W, "0")
    elif x*H < y*W:
        print(x*H, "0")
    else:
        print(x*H, "1")

Fixed submission:


W, H, x, y = map(float, input().split())

if x/W == 0.5 and y/H == 0.5:   
	print(W*H/2,"1")
else:
	print(W*H/2,"0")
Buggy python submission (verdict: Runtime Error):

N = int(input())
countA = 0
countB = 0
countC = 0
kcount = 0

for i in range(N):
    K = input()
    kcount += K.count("AB")
    K = list(K)
    if K[0] == "B" and K[-1] == "A":
        countC += 1 
    if K[-1] == "A":
        countA += 1
    if K[0] == "B"
        countB += 1
if countC>=1 and (countB-countC)==0 and (countA-countC)==0:
    print(kcount+countC-1)
elif countC >=1 and (countB-countC)==0 and (countA-countC)>=1:
    print(kcount+countC)
elif countC >=1 and (countB-countC)>=1 and (countA-countC)==0:
    print(kcount+countC)
elif countB > countA:
    print(kcount+countA)
else:
    print(kcount+countB)

Fixed submission:

N = int(input())
countA = 0
countB = 0
countC = 0
kcount = 0

for i in range(N):
    K = input()
    kcount += K.count("AB")
    K = list(K)
    if K[0] == "B" and K[-1] == "A":
        countC += 1 
    if K[-1] == "A":
        countA += 1
    if K[0] == "B":
        countB += 1
if countC>=1 and (countB-countC)==0 and (countA-countC)==0:
    print(kcount+countC-1)
elif countC >=1 and (countB-countC)==0 and (countA-countC)>=1:
    print(kcount+countC)
elif countC >=1 and (countB-countC)>=1 and (countA-countC)==0:
    print(kcount+countC)
elif countB > countA:
    print(kcount+countA)
else:
    print(kcount+countB)
Buggy python submission (verdict: Runtime Error):
b = input()
 
if  "A"==b
    print("T")
elif "C"==b
    print("G")
elif "T"==b
    print("A")
else:
    print("C")

Fixed submission:
b = input()
 
if  b=="A":
    print("T")
elif b=="C":
    print("G")
elif b=="T":
    print("A")
else:
    print("C")

Buggy python submission (verdict: Runtime Error):
b = input()

if b == "A"
    print("T")
elif b == "C"
    print("G")
elif b == "T"
    print("A")
else:
    print("C")
    

Fixed submission:
b = input()
 
if  b=="A":
    print("T")
elif b=="C":
    print("G")
elif b=="T":
    print("A")
else:
    print("C")