Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
q = int(input())
f = False #さかさま
for i in range(q):
    x = list(input().split())
    if x[0]=='1':
        f = not f
    else:
        if f:
            if x[1]=='1': s = s+[x[2]]
            else: s = [x[2]]+s
        else:
            if x[1]=='1': s = [x[2]]+s
            else: s = s+[x[2]]
if f: s.reverse()
print(''.join(s))

Fixed submission:
s = list(input())
q = int(input())
a = []
f = False #さかさま
for i in range(q):
    x = list(input().split())
    if x[0]=='1':
        f = not f
    else:
        if f:
            if x[1]=='1': s.append(x[2])
            else: a.append(x[2])
        else:
            if x[1]=='1': a.append(x[2])
            else: s.append(x[2])
a.reverse()
s = a+s
if f:s.reverse()
print(''.join(s))

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
q = int(input())
for i in range(q):
    x = list(input().split())
    if x[0]=='1':
        s.reverse()
    else:
        if x[1]=='1': s = [x[2]]+s
        else: s = s+[x[2]]
print(''.join(s))

Fixed submission:
s = list(input())
q = int(input())
a = []
f = False #さかさま
for i in range(q):
    x = list(input().split())
    if x[0]=='1':
        f = not f
    else:
        if f:
            if x[1]=='1': s.append(x[2])
            else: a.append(x[2])
        else:
            if x[1]=='1': a.append(x[2])
            else: s.append(x[2])
a.reverse()
s = a+s
if f:s.reverse()
print(''.join(s))
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9+7
n,a,b = map(int, input().split())
ans = 0
c = 1
x = n
if a!=n and b!=n: ans+=c
for i in range(1,(n+2)//2):
    c = c*x//(n+1-x)
    x-=1
    ans += c*2
    if i==a or n-i==a:
        ans -= c
    if i==b or n-i==b:
        ans -= c
    if i==n/2:
        ans -= c

print(ans%mod)

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

mod = 10**9+7
ans = pow(2,n,mod)-1

nca = 1
ncb = 1

for i in range(b):
    ncb = ncb*(n-i)%mod
    ncb *= pow(i+1,mod-2,mod)
    if i+1==a:
        nca = ncb

ans -= nca+ncb
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9+7
n,a,b = map(int, input().split())
ans = 0
c = 1
x = n
y = 1
if a!=n and b!=n: ans+=c
for i in range(1,(n+2)//2):
    c = c*x//y
    x-=1
    y+=1
    ans += c*2
    if i==a or n-i==a:
        ans -= c
    if i==b or n-i==b:
        ans -= c
    if i==n/2:
        ans -= c

print(ans%mod)

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

mod = 10**9+7
ans = pow(2,n,mod)-1

nca = 1
ncb = 1

for i in range(b):
    ncb = ncb*(n-i)%mod
    ncb *= pow(i+1,mod-2,mod)
    if i+1==a:
        nca = ncb

ans -= nca+ncb
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9+7
n,a,b = map(int, input().split())
ans = 0
c = 1
x = n
y = 1
if a!=n and b!=n: ans+=c
for i in range(1,(n+2)//2):
    c = c*x//y
    x-=1
    y+=1
    ans += c*2
    if i==a or n-i==a:
        ans -= c
    if i==b or n-i==b:
        ans -= c
    if i==n/2:
        ans -= c
    ans %= mod

print(ans)

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

mod = 10**9+7
ans = pow(2,n,mod)-1

nca = 1
ncb = 1

for i in range(b):
    ncb = ncb*(n-i)%mod
    ncb *= pow(i+1,mod-2,mod)
    if i+1==a:
        nca = ncb

ans -= nca+ncb
print(ans%mod)

Buggy python submission (verdict: Time Limit Exceeded):
import math
def c(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
mod = 10**9+7
n,a,b = map(int, input().split())
ans = 2**n-1
ans -= c(n,a)+c(n,b)
print(ans%mod)

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

mod = 10**9+7
ans = pow(2,n,mod)-1

nca = 1
ncb = 1

for i in range(b):
    ncb = ncb*(n-i)%mod
    ncb *= pow(i+1,mod-2,mod)
    if i+1==a:
        nca = ncb

ans -= nca+ncb
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
n = list(input())
n = [int(i) for i in n]
n.reverse()
l = len(n)
ans = 0
for i in range(l):
    if (n[i]==5 and n[i+1]>=5) or n[i]>5:
        if i!=l-1:
            n[i+1] += 1
        else:
            ans += 1
        ans += 10-n[i]
    else:
        ans += n[i]
print(ans)

Fixed submission:
n = list(input())
n = [int(i) for i in n]
n.reverse()
l = len(n)
ans = 0
for i in range(l-1):
    if (n[i]==5 and n[i+1]>=5) or n[i]>5:
        n[i+1] += 1
        ans += 10-n[i]
    else:
        ans += n[i]
ans += 11-n[-1] if n[-1]>5 else n[-1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
p = list(map(int, input().split()))
m = max(p)
s = [0]*(m+1)
for i in range(m+1):
    s[i] += s[i-1]+i
ans = 0
for i in range(n-k+1):
    buf = 0
    for j in range(k):
        buf += s[p[i+j]]/p[i+j]
    if ans<buf: ans=buf
print(ans)

Fixed submission:
n,k = map(int, input().split())
p = list(map(int, input().split()))
m = max(p)
h = [0]*(m+1)
h[1] = 1
for i in range(1,m):
    h[i+1] = h[i]+0.5
ans = sum = 0
for i in range(n):
    if i>=k:
        sum = sum-h[p[i-k]]+h[p[i]]
        if ans<sum: ans=sum
    else:
        sum += h[p[i]]
        if i==k-1: ans=sum
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
h,n = map(int,input().split())

ab = []
ma = 0
for i in range(n):
    a,b = map(int,input().split())
    ab.append([a,b])
    ma = max(ma,a)

dp = [10**10]*(h+ma+1)
dp[0] = 0

for i in range(1,h+ma+1):
    dp[i] = min([dp[max(i-a,0)]+b for a,b in ab])

print(min(dp[h:]))

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

ab = [list(map(int,input().split())) for i in range(n)]
ma = max(a for a,b in ab)


dp = [10**10]*(h+ma+1)
dp[0] = 0

for i in range(1,h+ma+1):
    dp[i] = min(dp[i-a]+b for a,b in ab)

print(min(dp[h:]))

Buggy python submission (verdict: Time Limit Exceeded):
h,n = map(int,input().split())

ab = []
ma = 0
for i in range(n):
    a,b = map(int,input().split())
    ab.append([a,b])
    ma = max(ma,a)

dp = [float('inf')]*(h+ma+1)
dp[0] = 0

for i in range(1,h+ma+1):
    dp[i] = min([dp[max(i-a,0)]+b for a,b in ab])

print(min(dp[h:]))

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

ab = [list(map(int,input().split())) for i in range(n)]
ma = max(a for a,b in ab)


dp = [10**10]*(h+ma+1)
dp[0] = 0

for i in range(1,h+ma+1):
    dp[i] = min(dp[i-a]+b for a,b in ab)

print(min(dp[h:]))

Buggy python submission (verdict: Time Limit Exceeded):
h,n = map(int,input().split())
dp = [[10**10]*(h+1) for i in range(n+1)]
dp[0][0] = 0

for i in range(1,n+1):
    a,b = map(int,input().split())
    for j in range(h+1):
        if j-a<0:
            dp[i][j] = min(b,dp[i-1][j])
        else:
            dp[i][j] = min(dp[i][j-a]+b,dp[i-1][j])

print(dp[n][h]) 

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

ab = [list(map(int,input().split())) for i in range(n)]
ma = max(a for a,b in ab)


dp = [10**10]*(h+ma+1)
dp[0] = 0

for i in range(1,h+ma+1):
    dp[i] = min(dp[i-a]+b for a,b in ab)

print(min(dp[h:]))

Buggy python submission (verdict: Time Limit Exceeded):
h,n = map(int,input().split())
dp = [[float('inf')]*(h+1) for i in range(n+1)]
dp[0][0] = 0

for i in range(1,n+1):
    a,b = map(int,input().split())
    for j in range(h+1):
        if j-a<0:
            dp[i][j] = min(dp[i][j],b,dp[i-1][j])
        else:
            dp[i][j] = min(dp[i][j-a]+b,dp[i-1][j])

print(dp[n][h]) 

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

ab = [list(map(int,input().split())) for i in range(n)]
ma = max(a for a,b in ab)


dp = [10**10]*(h+ma+1)
dp[0] = 0

for i in range(1,h+ma+1):
    dp[i] = min(dp[i-a]+b for a,b in ab)

print(min(dp[h:]))
Buggy python submission (verdict: Runtime Error):
h,w,k = map(int,input().split())
s = [input() for i in range(h)]
ans = [[0]*w for i in range(h)]
c = 1
not_cherry = [] #イチゴがない列
ok = False
for i in range(h):
    if '#' in s[i]:
        cherry = 0
        for j in range(w):
            if s[i][j]=='#':
                if cherry==0:
                    ans[i][j] = c
                else:
                    c += 1
                    ans [i][j] = c
                cherry += 1
            else:
                ans [i][j] = c
        c += 1
        ok = False
    else:
        if ok:
            not_cherry[-1] += 1
        else:
            not_cherry.append(1)
        ok = True

i = 0
ind = 0
while i<h:
    if 0 in ans[i]:
        c = not_cherry[ind]
        for l in range(c):
            for j in range(w):
                if i+l<h-1:ans[i+l][j] = ans[i+c][j]
                else:ans[i][j] = ans[i-1][j]
        i+=c
        ind += 1
    else:
        i+=1

for i in ans:
    print(*i)
            




Fixed submission:
h,w,k = map(int,input().split())
s = [input() for i in range(h)]
ans = [[0]*w for i in range(h)]
c = 1
not_cherry = [] #イチゴがない列
ok = False
for i in range(h):
    if '#' in s[i]:
        cherry = 0
        for j in range(w):
            if s[i][j]=='#':
                if cherry==0:
                    ans[i][j] = c
                else:
                    c += 1
                    ans [i][j] = c
                cherry += 1
            else:
                ans[i][j] = c
        c += 1
        ok = False
    else:
        if ok:
            not_cherry[-1] += 1
        else:
            not_cherry.append(1)
        ok = True

i = 0
ind = 0
while i<h:
    if 0 in ans[i]:
        c = not_cherry[ind]
        for l in range(c):
            for j in range(w):
                if i+l<h-1 and i+c<h-1:ans[i+l][j] = ans[i+c][j]
                else:ans[i+l][j] = ans[i+l-1][j]
        i+=c
        ind += 1
    else:
        i+=1

for i in ans:
    print(*i)
Buggy python submission (verdict: Time Limit Exceeded):
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


x,y = map(int,input().split())

mod = 10**9+7

division = (x+y)//3

if (x+y)%3!=0:
    print(0)
    exit()


mod = 10**9+7

#combを求める前処理 O(log division)
g1 = [1, 1] #元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, division + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( pow(i,mod-2,mod) )
    g2.append( (g2[-1] * inverse[-1]) % mod )

r = min(x,y)-division
ans = cmb(division,r,mod)

print(ans)

Fixed submission:
x,y = map(int,input().split())

mod = 10**9+7

division = (x+y)//3

if [x%3,y%3] in [[1,1],[2,2]]:
    print(0)
    exit()

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )



r = min(x,y)-division
ans = cmb(division,r,mod)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


x,y = map(int,input().split())

mod = 10**9+7

division = (x+y)//3

if (x+y)%3!=0:
    print(0)
    exit()


mod = 10**9+7

#combを求める前処理 O(log division)
g1 = [1, 1] #元テーブル
g2 = [1, 1] #逆元テーブル

for i in range( 2, division + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    g2.append( pow(g1[-1],mod-2,mod) )

r = min(x,y)-division
ans = cmb(division,r,mod)

print(ans)

Fixed submission:
x,y = map(int,input().split())

mod = 10**9+7

division = (x+y)//3

if [x%3,y%3] in [[1,1],[2,2]]:
    print(0)
    exit()

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )



r = min(x,y)-division
ans = cmb(division,r,mod)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = sorted(list(map(int,input().split())))
ans = 0
import bisect
for i in range(n):
    for j in range(i+1,n):
        a1 = abs(l[i]-l[j])
        a2 = l[i]+l[j]
        x1 = bisect.bisect_right(l,a1)
        x2 = bisect.bisect_left(l,a2)
        buf = 0
        if x1<=i<=x2:buf+=1
        if x1<=j<=x2:buf+=1
        ans += max(0,x2-x1-buf)
print(ans//3)


Fixed submission:
n = int(input())
l = sorted(list(map(int,input().split())))
ans = 0
import bisect
for i in range(n):
    for j in range(i+1,n):
        a = l[i]+l[j]
        x = bisect.bisect_left(l,a)
        if x>j:
            ans += max(0,x-j-1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = sorted(list(map(int,input().split())))
ans = 0
import bisect
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if abs(l[i]-l[j])<l[k]<l[i]+l[j]:
                ans += 1
print(ans)


Fixed submission:
n = int(input())
l = sorted(list(map(int,input().split())))
ans = 0
import bisect
for i in range(n):
    for j in range(i+1,n):
        a = l[i]+l[j]
        x = bisect.bisect_left(l,a)
        if x>j:
            ans += max(0,x-j-1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int,input().split()))
ans = cnt = 0
for i in range(1,n):
    flag = cnt = 0
    for j in range(i,n):
        if h[j-1]>=h[j] and flag==0:
            cnt+=1
        else:
            flag = 1
    ans = max(ans,cnt)
print(ans)


Fixed submission:
n = int(input())
h = list(map(int,input().split()))
dif = [0]*(n-1)
ans = cnt = 0
for i in range(n-1):
    dif[i] =  h[i]-h[i+1]
for i in dif:
    if i>=0:
        cnt+=1
    else:
        ans = max(ans,cnt)
        cnt=0
print(max(ans,cnt))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)
n,q = map(int,input().split())
g = [[] for i in range(n)]
c = [0]*n
reach = [False]*n
for i in range(n-1):
    a,b = map(lambda x: int(x)-1,input().split())
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p,x = map(int,input().split())
    c[p-1] += x

def dfs(v):
    reach[v] = True
    for i in g[v]:
        if not reach[i]:
            c[i] += c[v]
            dfs(i)

reach[0] = True
dfs(0)
print(*c)


Fixed submission:
n,q = map(int,input().split())
g = [[] for i in range(n)]
c = [0]*n
reach = [False]*n
for i in range(n-1):
    a,b = map(lambda x: int(x)-1,input().split())
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p,x = map(int,input().split())
    c[p-1] += x

reach[0] = True
q = [0]
while q:
    cur = q.pop()
    reach[cur] = True
    for i in g[cur]:
        if not reach[i]:
            c[i] += c[cur]
            q.append(i)
print(*c)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)
n,q = map(int,input().split())
g = [[] for i in range(n)]
c = [0]*n
reach = [False]*n
for i in range(n-1):
    a,b = map(lambda x: int(x)-1,input().split())
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p,x = map(int,input().split())
    c[p-1] += x

def dfs(v):
    reach[v] = True
    for i in g[v]:
        if not reach[i]:
            c[i] += c[v]
            dfs(i)

reach[0] = True
dfs(0)
print(*c)

Fixed submission:
n,q = map(int,input().split())
g = [[] for i in range(n)]
c = [0]*n
reach = [False]*n
for i in range(n-1):
    a,b = map(lambda x: int(x)-1,input().split())
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p,x = map(int,input().split())
    c[p-1] += x

reach[0] = True
q = [0]
while q:
    cur = q.pop()
    reach[cur] = True
    for i in g[cur]:
        if not reach[i]:
            c[i] += c[cur]
            q.append(i)
print(*c)

Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
g = [[] for i in range(n)]
c = [0]*n
for i in range(n-1):
    a,b = map(lambda x: int(x)-1,input().split())
    g[a].append(b)

def dfs(v,x):
    c[v] += x
    for i in g[v]:
        dfs(i,x)

for i in range(q):
    p,x = map(int,input().split())
    dfs(p-1,x)

print(*c)

Fixed submission:
n,q = map(int,input().split())
g = [[] for i in range(n)]
c = [0]*n
reach = [False]*n
for i in range(n-1):
    a,b = map(lambda x: int(x)-1,input().split())
    g[a].append(b)
    g[b].append(a)

for i in range(q):
    p,x = map(int,input().split())
    c[p-1] += x

reach[0] = True
q = [0]
while q:
    cur = q.pop()
    reach[cur] = True
    for i in g[cur]:
        if not reach[i]:
            c[i] += c[cur]
            q.append(i)
print(*c)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = len(s)

mod = 10**9+7
dp = [[0]*13 for i in range(n+1)]
dp[0][0] = 1

for i in range(n):
    flag = 1 if s[i]=='?' else 0 #?だったら1
    if flag==1:
        for a in range(10):#i+1桁目の数字(0-9)
            for j in range(13): #あまり(0-12)
                dp[i+1][(j*10+a)%13] += dp[i][j]#i桁目の余りの10倍とi桁目を足して余りをだす
    else:
        for j in range(13):
            a = int(s[i])
            dp[i+1][(j*10+a)%13] += dp[i][j]
            
print(dp[n][5]%mod)

Fixed submission:
s = list(input())
n = len(s)

mod = 10**9+7
dp = [[0]*13 for i in range(n+1)]
dp[0][0] = 1

for i in range(n):
    flag = 1 if s[i]=='?' else 0 #?だったら1
    if flag==1:
        for a in range(10):#i+1桁目の数字(0-9)
            for j in range(13): #あまり(0-12)
                dp[i+1][(j*10+a)%13] += dp[i][j] #i桁目の余りの10倍とi桁目を足して余りをだす
    else:
        for j in range(13):
            a = int(s[i])
            dp[i+1][(j*10+a)%13] += dp[i][j]
    for j in range(13):
        dp[i+1][j]%=10**9+7
        
print(dp[n][5])

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = len(s)
dp = [[0]*13 for i in range(n+1)]
dp[0][0] = 1
for i in range(n):
    flag = 1 if s[i]=='?' else 0 #?だったら1
    if flag==1:
        for a in range(10):#i+1桁目の数字(0-9)
            for j in range(13): #あまり(0-12)
                dp[i+1][(j*10+a)%13] += dp[i][j] #i桁目の余りの10倍とi桁目を足して余りをだす
    else:
        for j in range(13):
            a = int(s[i])
            dp[i+1][(j*10+a)%13] += dp[i][j]
    for j in range(13):
        dp[i+1][j]%=10**9+7
print(dp[n][5])

Fixed submission:
s = list(input())
n = len(s)

mod = 10**9+7
dp = [[0]*13 for i in range(n+1)]
dp[0][0] = 1

for i in range(n):
    flag = 1 if s[i]=='?' else 0 #?だったら1
    if flag==1:
        for a in range(10):#i+1桁目の数字(0-9)
            for j in range(13): #あまり(0-12)
                dp[i+1][(j*10+a)%13] += dp[i][j] #i桁目の余りの10倍とi桁目を足して余りをだす
    else:
        for j in range(13):
            a = int(s[i])
            dp[i+1][(j*10+a)%13] += dp[i][j]
    for j in range(13):
        dp[i+1][j]%=10**9+7
        
print(dp[n][5])

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = len(s)
dp = [[0]*13 for i in range(n+1)]
dp[0][0] = 1
for i in range(n):
    flag = 1 if s[i]=='?' else 0
    for a in range(10):#i+1桁目の数字(0-9)
        if flag==1 or s[i]==str(a):
            for j in range(13): #あまり(0-12)
                dp[i+1][(j*10+a)%13] += dp[i][j] #i桁目の余りの10倍とi桁目を足して余りをだす
    for j in range(13):
        dp[i+1][j]%=10**9+7
print(dp[n][5])

Fixed submission:
s = list(input())
n = len(s)

mod = 10**9+7
dp = [[0]*13 for i in range(n+1)]
dp[0][0] = 1

for i in range(n):
    flag = 1 if s[i]=='?' else 0 #?だったら1
    if flag==1:
        for a in range(10):#i+1桁目の数字(0-9)
            for j in range(13): #あまり(0-12)
                dp[i+1][(j*10+a)%13] += dp[i][j] #i桁目の余りの10倍とi桁目を足して余りをだす
    else:
        for j in range(13):
            a = int(s[i])
            dp[i+1][(j*10+a)%13] += dp[i][j]
    for j in range(13):
        dp[i+1][j]%=10**9+7
        
print(dp[n][5])
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
a -= 1
from math import gcd
g = c*d//gcd(c,d)
cc = b//c-a//c
dc = b//d-a//d 
gc = b//g-a//b
print(b-a-cc-dc+gc)

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
e = c*d//fractions.gcd(c,d)
cnt = b-a+1
c_cnt = b//c-(a-1)//c
d_cnt = b//d-(a-1)//d
e_cnt = b//e-(a-1)//e
print(cnt-c_cnt-d_cnt+e_cnt)

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
e = c*d//math.gcd(c,d)
n = b-a+1
nc = (n+a%c)//c
nd = (n+a%d)//d
ne = (n+a%e)//e
print(n-(nc+nd-ne))

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
e = c*d//fractions.gcd(c,d)
cnt = b-a+1
c_cnt = b//c-(a-1)//c
d_cnt = b//d-(a-1)//d
e_cnt = b//e-(a-1)//e
print(cnt-c_cnt-d_cnt+e_cnt)
Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
l = list(map(int,input().split()))
cur = ans = 0
while cur<=x and ans<=n:
    ans += 1
    cur += l[ans-1]
print(ans)


Fixed submission:
n,x = map(int,input().split())
l = list(map(int,input().split()))
cur = ans = 0
for i in range(n):
    cur += l[i]
    if cur<=x:
        ans += 1
print(ans+1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
xy = sorted([tuple(map(int,input().split())) for i in range(n)])
dif = []
for i in range(n-1):
    dif.append(tuple([xy[i+1][0]-xy[i][0],xy[i+1][1]-xy[i][1]]))
from collections import Counter
c = Counter(dif)
print(n-c[list(c)[0]])

Fixed submission:
n = int(input())
xy = sorted([tuple(map(int,input().split())) for i in range(n)])
if n==1:
    print(1)
    exit()
dif = []
for i in range(n):
    for j in range(i+1,n):
        dif.append(tuple([xy[j][0]-xy[i][0],xy[j][1]-xy[i][1]]))
from collections import Counter
c = Counter(dif)
print(n-max(c.values()))
Buggy python submission (verdict: Time Limit Exceeded):
h,w = map(int,input().split())
x = []
for i in range(h):
    x.append(input())

l = [[0]*w for i in range(h)]
r = [[0]*w for i in range(h)]
u = [[0]*w for i in range(h)]
d = [[0]*w for i in range(h)]

for i in range(h):
    c = 0
    for j in range(w):
        if x[i][j] == '.':
            l[i][j] = c
            c += 1
        else: c=0


for i in range(h):
    c = 0
    for j in range(w):
        if x[i][w-1-j] == '.':
            r[i][w-1-j] = c
            c += 1
        else: c=0

for i in range(w):
    c = 0
    for j in range(h):
        if x[j][i] == '.':
            u[j][i] = c
            c += 1
        else: c=0

for i in range(w):
    c = 0
    for j in range(h):
        if x[h-1-j][i] == '.':
            d[h-1-j][i] = c
            c += 1
        else: c=0

ans = 0
for i in range(h):
    for j in range(w):
        c = l[i][j]+r[i][j]+u[i][j]+d[i][j]
        if x[i][j]=='.':c+=1
        ans = max(ans,c)

print(ans)

Fixed submission:
h,w = map(int,input().split())
x = []
for i in range(h):
    x.append(input())

l = [[0]*w for i in range(h)]
r = [[0]*w for i in range(h)]
u = [[0]*w for i in range(h)]
d = [[0]*w for i in range(h)]

for i in range(h):
    c = 0
    for j in range(w):
        if x[i][j] == '.':
            l[i][j] = c
            c += 1
        else: c=0


for i in range(h):
    c = 0
    for j in range(w):
        if x[i][w-1-j] == '.':
            r[i][w-1-j] = c
            c += 1
        else: c=0

for i in range(w):
    c = 0
    for j in range(h):
        if x[j][i] == '.':
            u[j][i] = c
            c += 1
        else: c=0

for i in range(w):
    c = 0
    for j in range(h):
        if x[h-1-j][i] == '.':
            d[h-1-j][i] = c
            c += 1
        else: c=0

ans = 0
for i in range(h):
    for j in range(w):
        c = l[i][j]+r[i][j]+u[i][j]+d[i][j]
        if x[i][j]=='.':c+=1
        ans = max(ans,c)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

n = int(input())
ans = 0
i = 1
x = n
while i<n:
    if (n-i)%i==0:
        x = (n-i)//i
        if x<=i:break
        ans += x
    i += 1
print(ans)

Fixed submission:
n = int(input())
ans = 0
i = 1
x = n
while i<n**0.5:
    if (n-i)%i==0:
        x = (n-i)//i
        if x<=i:break
        ans += x
    i += 1
print(ans)