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

Fixed submission:
import sys
L, A, B, M = map(int, input().split())
mod = M
sys.setrecursionlimit(pow(10, 8))

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, (y-1)//2)**2 * x % mod
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
def modinv(a):
    b, u, v = mod, 1, 0
    while b:
        t = a//b
        a, u = a-t*b, u-t*v
        a, b, u, v = b, a, v, u
    u %= mod
    return u
def div(a, b):
    return a * modinv(b) % mod

def G(n, i):
    if n == 1:
        return 1
    tn = n//2
    return (G(tn, i) * (1 + power(10, tn*i)) %mod + (n%2)*power(10, (n-1)*i)) % mod

def G2(n, i):
    if n ==0 :
        return 0
    if n == 1:
        return power(10, i) % mod
    tn = n//2
    X = G2(tn, i)
    I = power(10, tn*i)
    Y = (X*(I+1)%mod + mul(mul(tn, I), (G(tn+1, i)-1))%mod) %mod
    Y = Y + mul(n%2, mul(n, power(10, n*i)))
    return Y%mod


def f(a, b, n, i):
    if n == 0:
        return 0
    r = power(10, i)
    P = power(r,n)
    #aa = mul(a, div(P-1, r-1))
    aa = mul(a, G(n, i))
    bb2 = mul(b, div(r-n*P + (n-1)*P*r, mul(1-r, 1-r)))
    bb = mul(b, G2(n-1, i))
    #print(n-1, i, div(r-n*P + (n-1)*P*r, mul(1-r, 1-r)), G2(n-1, i))
    #print(bb, bb2)
    return (aa - bb) % mod

sl = A + (L-1) * B
t = 10
k = 0
ts = 0
ks = []
mk = 18
for i in range(mk):
    k = max(min((t-1),sl)-(A-B), 0) // B - ts
    #print(t, min(t, sl) - (A-B), -(-((min(t, sl) - (A-B))//B)))
    #k = -(-(min(t, sl) - (A-B)) // B) - 1 - ts
    ts += k
    ks.append(k)
    t *= 10
ti = 0
ti2 = 0
b = B
R = 0
for i in range(mk):
    i = mk - i
    n = ks[i-1]
    a = sl - ti2*b
    if n:
        R = (R + (f(a, b, n, i))*power(10, ti)) % mod
#        print(a, f(a,b,r,n))
#    print(a, b, r, n, R, ti)

    ti += i*n
    ti2 += n
print(R)
#$print(ks)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
def sc(s):
    b = None
    nc = 0
    kk = [0]*len(s)
    for i, c in enumerate(s):
        if c == ".":
            if c == b:
                nc += 1
            else:
                si = i
        else:
            if b == ".":
                for j in range(si, i):
                    kk[j] = i - si
            nc = 0
        b = c
    return kk
d = []
d2 = []
d3 = []
for h in range(H):
    s = input().strip() + "#"
    d.append(s)
    d2.append(sc(s))

for i in range(W):
    s = ""
    for j in range(H):
        s += d[j][i]
    s += "#"
    d3.append(sc(s))
r = 0
for i in range(H):
    for j in range(W):
        r = max(r, d2[i][j] + d3[j][i]-1)
print(r)
Problem p03034 (python)

Fixed submission:
N, = map(int, input().split())
xs = list(map(int, input().split()))
r = 0
for k in range(1, N):
    a = (N-1) % k
    b = a - k
    n = (N-1-a)//k
    if a <= k:
        a += k
    if a <= k:
        a += k

    for _ in range((N-1-a)//k):
        b = a - k
        n = (N-1-a)//k
        if a <= b:
            a += k
            continue
        if a%(a-b) == 0:
            if a <= (a-b)*n:
                a += k
                continue
    if a <= b or a >= N-1:
        continue
    s1 = a
    s2 = n * (a-b)
    t = xs[s1]
    ps = [(s1,t)]
    for i in range(n):
        s1 += a-b
        t += xs[s2]
        t = max(t,0)
        t += xs[s1]
        ps.append((s2,xs[s2]))
        ps.append((s1,xs[s1]))
        s2 -= a-b
    #print(ps, t)
    r = max(r, t)

print(r)

Buggy submission (verdict: Runtime Error):
N, = map(int, input().split())
xs = list(map(int, input().split()))
r = 0
for k in range(1, N):
    a = (N-1) % k
    if a <= k:
        a += k
    if a <= k:
        a += k

    for _ in range((N-1-a)//k):
        b = a - k
        n = (N-1-a)//k
        if a <= b:
            a += k
            continue
        if a%(a-b) == 0:
            if a <= (a-b)*n:
                a += k
                continue
    if a <= b or a >= N-1:
        continue
    s1 = a
    s2 = n * (a-b)
    t = xs[s1]
    ps = [(s1,t)]
    for i in range(n):
        s1 += a-b
        t += xs[s2]
        t = max(t,0)
        t += xs[s1]
        ps.append((s2,xs[s2]))
        ps.append((s1,xs[s1]))
        s2 -= a-b
    #print(ps, t)
    r = max(r, t)

print(r)
Problem p03232 (python)

Fixed submission:

import sys
from itertools import accumulate
mod = pow(10, 9) + 7
N, = [int(i) for i in input().split(' ')]
As = [int(i) for i in input().split(' ')]
sys.setrecursionlimit(pow(10, 8))

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, (y-1)//2)**2 * x % mod

NNN = 10**5
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

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

def fractional(N):
    if N == 0:
        return 1
    else:
        return mul(N, fractional(N-1))

T = g1[N]
fracs = list(accumulate([0] + [mul(T, inverse[(i+1)]) for i in range(N)]))


result = 0
for i in range(N):
    i = i+1
    x = mul(As[i-1], fracs[N-i+1] + (fracs[i] - fracs[1]))
    result = (result + x) % mod 
print(result)

Buggy submission (verdict: Runtime Error):

import sys
from itertools import accumulate
N, = [int(i) for i in input().split(' ')]
As = [int(i) for i in input().split(' ')]
mod = pow(10, 9) + 7
sys.setrecursionlimit(100000)

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y//2)**2 % mod
    else            : return power(x, (y-1)//2)**2 * x % mod

def div(a, b):
    return mul(a, power(b, mod-2))

def fractional(N):
    if N == 0:
        return 1
    else:
        return mul(N, fractional(N-1))

T = fractional(N)
fracs = list(accumulate([0] + [div(T, (i+1)) for i in range(N)]))


result = 0
for i in range(N):
    i = i+1
    x = mul(As[i-1], fracs[N-i+1] + (fracs[i] - fracs[1]))
    result = (result + x) % mod 
print(result)
Problem p03253 (python)

Fixed submission:
N, M = [int(i) for i in input().split(' ')]
mod = pow(10, 9) + 7
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

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

NNN = (10**5) * 2
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

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

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    c = 0
    while n % i == 0:
      n /= i
      c+=1
    if c!=0:
        table.append(c)
    i += 1
  if n > 1:
    table.append(1)
  return table

xxs = prime_decomposition(M)

result = 1
for xx in xxs:
    result = mul(result, cmb(xx+N-1,xx,mod))
print(result)

Buggy submission (verdict: Runtime Error):
N, M = [int(i) for i in input().split(' ')]
mod = pow(10, 9) + 7
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

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

NNN = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

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

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    c = 0
    while n % i == 0:
      n /= i
      c+=1
    if c!=0:
        table.append(c)
    i += 1
  if n > 1:
    table.append(1)
  return table

xxs = prime_decomposition(M)

result = 1
for xx in xxs:
    result = mul(result, cmb(xx+N-1,xx,mod))
print(result)
Problem p03326 (python)

Fixed submission:
N, M = map(int, input().split())
xs = [[] for _ in range(8)]
for j in range(N):
    a, b, c = map(int, input().split())
    for i in range(2**3):
        t = []
        for k in range(3):
            t.append(1-2*((i>>k)%2))
        xs[i].append(a*t[0] +b*t[1]+c*t[2])
print(max(sum(sorted(xs[i])[-M:]) for i in range(2**3))*(M!=0))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
xs = [[] for _ in range(N)]
for j in range(N):
    a, b, c = map(int, input().split())
    for i in range(2**3):
        t = []
        for k in range(3):
            t.append(1-2*((i>>k)%2))
        xs[i].append(a*t[0] +b*t[1]+c*t[2])
print(max(sum(sorted(xs[i])[-M:]) for i in range(2**3)))
Problem p03345 (python)

Fixed submission:
a, b, _, k = [int(x) for x in input().strip().split(" ")]

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

Buggy submission (verdict: Runtime Error):
a, b, _, k = [int(i) for x in input().strip().split(" ")]

if k % 2 == 0:
    print(a-b)
else:
    print(b-a)
Problem p02624 (python)

Fixed submission:
n = int(input())
ans = 0
for i in range(1,n+1):
    a = n//i
    ans += i*(a*(a+1)//2)
print(ans)

Buggy submission (verdict: Runtime Error):
import sympy
a = 0
n = int(input())
for i in range(1,n+1):
    a += i*(sympy.divisor_count(i))
print(a)
Problem p02627 (python)

Fixed submission:
a = input()
if str.upper(a) == a:
    print("A")
else:
    print("a")

Buggy submission (verdict: Runtime Error):
n = int(input())
c = 0
n1 = 0
n1 += n
for i in range(1,12):
    a = n1 - 26**(i)
    c += 1
    if a <= 0:
        break
    n1 = n1 - 26**(i)
a = ""
for i in range(c):
    if n // 26**(c-i-1) >= 26:
        alpha = 26
        n = n - 26**(c-i)
    else:
        alpha = n // 26**(c-i-1)
        n = n % 26**(c-i-1)
    a += chr(96 + alpha)
print(a)
Problem p02659 (python)

Fixed submission:
a,b = input().split()
a1 = int(a)
b1 = int(b[0] + b[2] + b[3])
print(a1*b1//100)

Buggy submission (verdict: Runtime Error):
a,b = input().split()
a1 = int(a)
b1 = int(b*100)
print((a1*b1)//100)
Problem p02753 (python)

Fixed submission:
a = input().count("A")
if a == 3:
  print("No")
elif a == 0:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
a = list(input().count("A"))
if a == 3:
  print("No")
elif a == 0:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
a = list(input().count("A"))
if a = 3:
  print("No")
elif a = 0:
  print("No")
else:
  print("Yes")
Problem p02754 (python)

Fixed submission:
n,a,b = map(int,input().split())
ans = a*(n//(a+b)) + min(n%(a+b),a)
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
ans = a*(n//(a+b)) + min(N%(a+b),a)
print(ans)
Problem p02785 (python)

Fixed submission:
n,k = map(int,input().split())
li = list(map(int,input().split()))
lenght = len(li)
li.sort(reverse=True)
if lenght <= k:
    del li[0:lenght]
else:
    del li[0:k]
print(sum(li))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
li = list(map(int,input().split()))
li.sort(reverse=True)
for i in range(k):
    li.remove(li[0])
print(sum(li))
Problem p02831 (python)

Fixed submission:
import fractions
a,b = map(int,input().split())
print(a*b//(fractions.gcd(a,b)))

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
print(a*b//(math.gcd(a,b)))

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
print((a*b)//math.gcd(a,b))

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())
print(a * b / (math.gcd(a,b)))

Buggy submission (verdict: Runtime Error):
from math import gcd
a,b = map(int,input().split())
print(a * b / (gcd(a,b)))

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
from math import gcd
print(a * b / (gcd(a,b)))
Problem p02915 (python)

Fixed submission:
print((int(input()))**3)

Buggy submission (verdict: Runtime Error):
print((int.input())**3)
Problem p03127 (python)

Fixed submission:
import fractions
n = int(input())
li = list(map(int,input().split()))
gcd1 = 0
gcd1 = fractions.gcd(li[0],li[1])
for i in range(2,n):
    gcd1 = fractions.gcd(gcd1,li[i])
print(gcd1)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
li = list(map(int,input().split()))
gcd1 = 0
gcd1 = math.gcd(li[0],li[1])
for i in range(2,n):
    gcd1 = math.gcd(gcd1,li[i])
print(gcd1)
Problem p03803 (python)

Fixed submission:
li = [2,3,4,5,6,7,8,9,10,11,12,13,1]
a,b = map(int,input().split())
if li.index(a) == li.index(b):
    print("Draw")
elif li.index(a) > li.index(b):
    print("Alice")
else:
    print("Bob")

Buggy submission (verdict: Runtime Error):
li = [2,3,4,5,6,7,8,9,10,11,12,1]
a,b = map(int,input().split())
if li.index(a) == li.index(b):
    print("Draw")
elif li.index(a) > li.index(b):
    print("Alice")
else:
    print("Bob")

Buggy submission (verdict: Runtime Error):
li = [2,3,4,5,6,7,8,9,10,11,12,1]
a,b = map(int,input().split())
if li.index(a) == li.index(b):
    print("Draw")
if li.index(a) > li.index(b):
    print("Alice")
else:
    print("Bob")
Problem p02695 (python)

Fixed submission:
N,M,Q=map(int,input().split())
S=[0]*Q;t=0;d=0;A=[0]*10
for i in range(Q):
  a,b,c,d=map(int,input().split())
  S[i]=[a,b,c,d]
#print(S)
for i1 in range(1,M+1):
  for i2 in range(i1,M+1):
    for i3 in range(i2,M+1):
      for i4 in range(i3,M+1):
        for i5 in range(i4,M+1):
          for i6 in range(i5,M+1):
            for i7 in range(i6,M+1):
              for i8 in range(i7,M+1):
                for i9 in range(i8,M+1):
                  for i10 in range(i9,M+1):
                    d=0
                    A=[i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
                    for i in range(Q):
                      if A[S[i][1]-1]-A[S[i][0]-1]==S[i][2]:
                        d=d+S[i][3]
                    t=max(t,d)
                    
print(t)

Buggy submission (verdict: Runtime Error):
N,M,Q=map(int,input().split())
S=[0]*Q;t=0;d=0;A=[0]*10
for i in range(Q):
  a,b,c,d=map(int,input().split())
  S[i]=[a,b,c,d]
#print(S)
for i1 in range(M):
  for i2 in range(M):
    for i3 in range(M):
      for i4 in range(M):
        for i5 in range(M):
          for i6 in range(M):
            for i7 in range(M):
              for i8 in range(M):
                for i9 in range(M):
                  for i10 in range(M):
                    A=[i1,i2,i3,i4,i5,i6,i7,i8,i9,i10]
                    for i in range(Q):
                      if A[S[i][1]]-A[S[i][0]]==S[i][2]:
                        d=d+S[i][3]
                    t=max(t,d)
                    d=0
print(t)
Problem p03775 (python)

Fixed submission:
def d(n):
  return len(str(n))

N=int(input())
if N==1:
  print(1)
else:
  i=0
  #print(int(N**0.5))
  while N%(int(N**0.5)-i)!=0:
    i=i+1
  print(max(d(int(N**0.5)-i),d(N//(int(N**0.5)-i))))

Buggy submission (verdict: Runtime Error):
def d(n):
  return len(str(n))

N=int(input())
i=1
#print(int(N**0.5))
while N%(int(N**0.5)-i)!=0:
  i=i+1
print(max(d(int(N**0.5)-i),d(N//(int(N**0.5)-i))))
Problem p02933 (python)

Fixed submission:
# -*- coding utf-8 -*-
MOD = 10 ** 9 + 7

a = int(input())
b = input()

if a >= 3200:
    print(b)
else:
    print('red')

Buggy submission (verdict: Runtime Error):
# -*- coding utf-8 -*-
MOD = 10 ** 9 + 7

a = int(input())
b = input()

if a >= 3200:
    print(s)
else:
    print('red')
Problem p02831 (python)

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


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

# a,bの最小公倍数


def lcm(a, b):
    return a * b // gcd(a, b)


print(lcm(A, B))

Buggy submission (verdict: Runtime Error):
import math

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


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


print(lcm(A, B))
Problem p02916 (python)

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

ans = 0

for i in range(len(A)-1):
    if A[i] + 1 == A[i+1]:
        ans += C[A[i]-1]

print(ans+sum(B))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = sum(B)

for i in range(len(A)-1):
    if A[i] + 1 == A[i+1]:
        if N % 2 == 1 or N == 2:
            ans += C[i-1]
        else:
            ans += C[i+1]

print(ans)
Problem p02951 (python)

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

A -= B
C -= A

if C < 0:
    print(0)
else:
    print(C)

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

for i in range(N):
    if i != N-1:
        if H[i] > H[i+1]:
            H[i] -= 1
    if i == N:
        if H[i] < H[i-1]:
            H[i-1] -= 1

for i in range(N):
    if i < N-1:
        if H[i] > H[i+1]:
            print("No")
            exit()
    if i == N:
        if H[i-1] > H[i]:
            print("No")
            exit()
print("Yes")
Problem p03135 (python)

Fixed submission:
T, X = map(int,input().split())

print(T / X)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = list(map(int, input().split()))

y = []
for i in range(m):
    y+= [x[i+1] - x[i]]
    
y.sort()

print(sum(y[:max(m-n, 0)]))
Problem p03631 (python)

Fixed submission:
N = input()

print("Yes" if N[0] == N[2] else "No")

Buggy submission (verdict: Runtime Error):
import math


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


N = int(input())
ans = 0
for i in range(N):
    T = int(input())

    if i == 0:
        ans = T

    else:
        ans = lcm(ans, T)

print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd


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


N = int(input())
ans = 0
for i in range(N):
    T = int(input())

    if i == 0:
        ans = T

    else:
        ans = lcm(ans, T)

print(ans)
Problem p03767 (python)

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

a.sort(reverse=True)
ans = 0
count = 0
for i in range(1, N*3+1, 2):
    if count == N:
        break
    else:
        ans += a[i]
        count += 1

print(ans)

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

a.sort(reverse=True)
ans = 0

A = []
n = N * 3
for i in range(1, n+1, 2):
    A.append(a[i])

for i in range(N):
    ans += A[i]
print(ans)

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

def quicksort(seq):
    if len(seq) < 1:
        return seq
    pivot = seq[0]
    left = []
    right = []
    for x in range(1, len(seq)):
        if seq[x] <= pivot:
            left.append(seq[x])
        else:
            right.append(seq[x])
    left = quicksort(left)
    right = quicksort(right)
    foo = [pivot]
    return left + foo + right

a = quicksort(a)

for i in range(N):
    ans += a[-2]
    a = a[1:-2]
print(ans)
Problem p02990 (python)

Fixed submission:
a = list(map(int,input().split()))
N = a[0]
K = a[1]

i = 2
x = (N-K+1)
y = 1
z = (x*y)%(10**9+7)
print(z)

while K >= i:
    if (N-K+1) >= i:
        x = (N-K+2-i)*x//i
        y = (K-i+1)*y//(i-1)
        z = (x*y)%(10**9+7)
        print(z)
    else:
        print(0)
    i = i + 1

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
N = a[0]
K = a[1]

i = 2
x = (N-K+1)
y = 1
z = (x*y)%(10**9+7)
print(z)

while (N-K+1) >= i and K >= i:
    x = (N-K+2-i)*x/i
    y = (K-i+1)*y/(i-1)
    z = (x*y)%(10**9+7)
    print(int(z))
    i = i + 1
Problem p02793 (python)

Fixed submission:
MOD = 1000000007

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

def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x%y)

N = int(input())
A = list(map(int, input().split()))

l = 1
for i in A:
    l = lcm(l, i)

l %= MOD

ans = 0
for i in A:
    ans += l*pow(i, MOD-2, MOD)
    ans %= MOD

print(ans)

Buggy submission (verdict: Runtime Error):
import math
MOD = 1000000007

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

N = input()
A = list(map(int, input().split()))

l = 1
for i in A:
    l = lcm(l, i)

l %= MOD

ans = 0
for i in A:
    ans += l*pow(i, MOD-2, MOD)
    ans %= MOD

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = input()

A = list(map(int, input().split()))

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

l = 1
for i in A:
    l = lcm(l, i)

ans = 0
for i in A:
    ans += l // i

print(ans%1000000007)
Problem p03107 (python)

Fixed submission:
S = list(raw_input())

i = 0
cnt = 0
while len(S) > 0:
    if i+1 == len(S):
        break
    if S[i] != S[i+1]:
        del S[i]
        del S[i]
        if i <= 0:
            i = -1
        else:
            i -= 2
        cnt += 2
    i += 1

print cnt

Buggy submission (verdict: Runtime Error):
S = list(raw_input())

i = 0
cnt = 0
while len(S) > 0:
    if i+1 == len(S):
        break
    if S[i] != S[i+1]:
        del S[i]
        del S[i]
        i -= 2
        cnt += 2
    i += 1

print cnt
Problem p03137 (python)

Fixed submission:
N,M = map(int,raw_input().split())

X = map(int,raw_input().split())

X.sort()
gap = []
for i in range(M-1):
    i = M-i-1
    gap.append(abs(X[i]-X[i-1]))

gap.sort()
gap.reverse()

gapsum = 0
counter = 0
if len(gap) > 0:
    while N-counter-1 > 0 and counter < len(gap):
        gapsum += gap[counter]
        counter += 1

print abs(X[0]-X[-1])-gapsum

Buggy submission (verdict: Runtime Error):
N,M = map(int,raw_input().split())

X = map(int,raw_input().split())

X.sort()
gap = []
for i in range(M-1):
    i = M-i-1
    gap.append(abs(X[i]-X[i-1]))

gap.sort()
gap.reverse()

gapsum = 0
counter = 0
if len(gap) > 0:
    while N-counter-1 > 0:
        gapsum += gap[counter]
        counter += 1


print abs(X[0]-X[-1])-gapsum

Buggy submission (verdict: Runtime Error):
N,M = map(int,raw_input().split())

X = map(int,raw_input().split())

X.sort()
gap = []
for i in range(M-1):
    i = M-i-1
    gap.append(X[i]-X[i-1])

gap.sort()
gap.reverse()

gapsum = 0
counter = 0
if len(gap) > 0:
    while N-counter-1 > 0:
        gapsum += gap[counter]
        counter += 1


print abs(X[0]-X[-1])-gapsum