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

Fixed submission:
def main():
    l, r, d = list(map(int, input().split()))
    ans = 0
    for i in range(l, r + 1):
        if i % d == 0:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
def main():
    def f(n):
        if n == 0:
            return 0
        if d[n] != 0:
            return d[n]
        d[n] = f(n % sum(list(map(int, bin(n)[2:])))) + 1
    def rev(i):
        if X[i] == '0':
            print(d[b % (c + 1)] + 1 if (b := (m + (1 << (n - i - 1)))) != 0 else 0)
        else:
            print(d[b % (c - 1)] + 1 if (b := (m - (1 << (n - i - 1)))) != 0 else 0)

    n = int(input())
    X = list(input())
    d = defaultdict(int)
    d[0] = 0
    printl = lambda x, y: print(d[x % y] + 1 if x != 0 else 0)
    for i in range(1, n):
        f(i)
    c = sum(list(map(int, X)))
    m = int(''.join(X), 2)
    for i in range(n):
        rev(i)

if __name__ == '__main__':
    main()
Problem p02609 (python)

Fixed submission:
def main():
    def f(n):
        if n == 0: return 0
        return f(n % bin(n).count('1')) + 1
    n = int(input())
    X = list(input())
    c = sum(list(map(int, X)))
    m = int(''.join(X), 2)
    mp, mm = m % (c + 1), m % (c - 1) if c - 1 != 0 else 0
    jp, jm = 1, 1
    ans = [0] * n
    for i in range(n - 1, -1, -1):
        if X[i] == '0':
            mod = c + 1
            ans[i] = f((mp + jp) % mod) + 1
        else:
            ans[i] = f((mm - jm + mod) % mod) + 1 if (mod := c - 1) != 0 else 0
        jp, jm = (jp << 1) % (c + 1), (jm << 1) % (c - 1) if c - 1 != 0 else 0
    [print(a) for a in ans]
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
def main():
    def f(n):
        if n == 0:
            return 0
        if d[n] != 0:
            return d[n]
        d[n] = f(n % sum(list(map(int, bin(n)[2:])))) + 1
    def rev(i):
        if X[i] == '0':
            print(d[b % (c + 1)] + 1 if (b := (m + (1 << (n - i - 1)))) != 0 else 0)
        else:
            print(d[b % (c - 1)] + 1 if (b := (m - (1 << (n - i - 1)))) != 0 else 0)

    n = int(input())
    X = list(input())
    d = defaultdict(int)
    d[0] = 0
    for i in range(1, n):
        f(i)
    c = sum(list(map(int, X)))
    m = int(''.join(X), 2)
    for i in range(n):
        rev(i)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
def main():
    def f(n):
        if n == 0:
            return 0
        if d[n] != 0:
            return d[n]
        d[n] = f(n % sum(list(map(int, bin(n)[2:])))) + 1
    def rev(i):
        if X[i] == '0':
            print(d[b % (c + 1)] + 1 if (b := (m + (1 << (n - i - 1)))) != 0 else 0)
        else:
            print(d[b % (c - 1)] + 1 if (b := (m - (1 << (n - i - 1)))) != 0 else 0)

    n = int(input())
    X = list(input())
    d = defaultdict(int)
    d[0] = 0
    printl = lambda x, y: print(d[x % y] + 1 if x != 0 else 0)
    for i in range(1, n):
        f(i)
    c = sum(list(map(int, X)))
    m = int(''.join(X), 2)
    for i in range(n):
        rev(i)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
def main():
    def f(n):
        if n == 0:
            return 0
        if d[n] != 0:
            return d[n]
        d[n] = f(n % sum(list(map(int, bin(n)[2:])))) + 1


    n = int(input())
    X = list(input())
    rev = lambda x: '1' if x == '0' else '0'
    d = defaultdict(int)
    d[0] = 0
    for i in range(1, n):
        f(i)
    X[0] = rev(X[0])
    print(d[int(''.join(X), 2) % sum(list(map(int, X)))] + 1)
    for i in range(n - 1):
        X[i] = rev(X[i])
        X[i + 1] = rev(X[i + 1])
        print(d[int(''.join(X), 2) % sum(list(map(int, X)))] + 1)




if __name__ == '__main__':
    main()
Problem p02756 (python)

Fixed submission:
from collections import deque
S = deque(list(input()))
q = int(input())
r = False
for _ in range(q):
    t = input().split()
    if len(t) == 1:
        r = not r
    else:
        t[1] = int(t[1]) - 1
        if (not t[1] and not r) or (t[1] and r):
            S.appendleft(t[2])
        else:
            S.append(t[2])
if r:
    S = list(S)
    print(''.join(S[::-1]))
else:
    print(''.join(S))

Buggy submission (verdict: Runtime Error):
from collections import deque
S = deque(list(input()))
q = int(input())
r = False
for _ in range(q):
    t = input().split()
    if len(t) == 1:
        r = not r
    else:
        t[1] = int(t[1]) - 1
        if (not t[1] and not r) or (t[1] and r):
            S.appendleft(t[2])
        else:
            S.append(t[2])
if r:
    print(''.join(S[::-1]))
else:
    print(''.join(S))
Problem p02818 (python)

Fixed submission:
a, b, k = list(map(int, input().split()))
a_ans = a - min(a, k)
if a_ans == 0:
    b_ans = b - min(b, k - a)
else:
    b_ans = b
print('{} {}'.format(a_ans, b_ans))

Buggy submission (verdict: Runtime Error):
a, b, k = list(map(int, input().split()))
a_ans = a - min(a, k)
if a_ans == 0:
    b_ans = b - min(b, k - a)
print('{} {}'.format(a_ans, b_ans))
Problem p02952 (python)

Fixed submission:
n = int(input())
ans = 0
for i in range(1, n + 1):
    if i < 10:
        ans += 1
    elif 100 <= i < 1000:
        ans += 1
    elif 10000 <= i < 100000:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
for i in range(1, 6, 2):
    if n < 10 ** (i - 1):
        break
    if 10 ** (i - 1) < n < 10 ** i:
        ans += n - int('9' * (i - 1))
    else:
        ans += 9 * 10 ** (i - 1)
print(ans)
Problem p02972 (python)

Fixed submission:
def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * n
    ans = []
    for i, a in enumerate(A[::-1]):
        i = n - i
        b = sum(B[i - 1::i])
        if b % 2 != a:
            ans.append(str(i))
            B[i - 1] = 1
    print(len(ans))
    print(' '.join(ans))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * n
    ans = []
    for i, a in enumerate(A[::-1]):
        i = n - i
        b = sum(B[i - 1::i])
        if b % 2 != a:
            ans.append(str(i))
            B[i] = 1
    print(len(ans))
    print(' '.join(ans))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    A = list(map(int, input().split()))
    B = [0] * n
    ans = []
    for i, a in enumerate(A[::-1]):
        i = n - i
        b = sum(B[i::i])
        if b % 2 != a:
            ans.append(str(i))
            B[i] = 1
    print(len(ans))
    print(' '.join(ans))

if __name__ == '__main__':
    main()
Problem p02995 (python)

Fixed submission:
import fractions
a, b, c, d = list(map(int, input().split()))
ans = []
for n in [a - 1, b]:
    mc = n // c
    md = n // d
    cd = c * d // fractions.gcd(c, d)
    mcd = n // cd
    ans.append(n - mc - md + mcd)
print(int(ans[1] - ans[0]))

Buggy submission (verdict: Runtime Error):
import math
a, b, c, d = list(map(int, input().split()))
ans = []
for n in [a - 1, b]:
    mc = n // c
    md = n // d
    cd = c * d // math.gcd(c, d)
    mcd = n // cd
    ans.append(n - mc - md + mcd)
print(int(ans[1] - ans[0]))
Problem p03000 (python)

Fixed submission:
n, x = list(map(int, input().split()))
l = list(map(int, input().split()))
ans = 1
d = 0
for i in range(n):
    d += l[i]
    if d > x:
        break
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, x = list(map(int, input().split()))
l = list(map(int, input().split()))
ans = 1
d = 0
for i in range(n + 1):
    d += l[i]
    if d > x:
        break
    ans += 1
print(ans)
Problem p03112 (python)

Fixed submission:
def main():
    from bisect import bisect_left
    import sys
    input = sys.stdin.buffer.readline
    def dist(x, s, t):
        if s < x and t < x:
            return x - min(s, t)
        elif s > x and t > x:
            return max(s, t) - x
        else:
            if (ds := abs(x - s)) <= (dt := abs(x - t)):
                return 2 * ds + dt
            else:
                return ds + 2 * dt
    def near(A, x):
        if (i := bisect_left(A, x)) == 0:
            return [A[0], ]
        elif 0 < i < len(A):
            return [A[i - 1], A[i]]
        else:
            return [A[-1], ]
    a, b, q = map(int, input().split())
    S = [int(input()) for _ in range(a)]
    T = [int(input()) for _ in range(b)]
    for _ in range(q):
        x = int(input())
        ans = 100000000000
        for s in near(S, x):
            for t in near(T, x):
                ans = min(ans, dist(x, s, t))
        print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    from bisect import bisect_left
    import sys
    input = sys.stdin.buffer.readline
    def dist(x, s, t):
        if s < x and t < x:
            return x - min(s, t)
        elif s > x and t > x:
            return max(s, t) - x
        else:
            if (ds := abs(x - s)) <= (dt := abs(x - t)):
                return 2 * ds + dt
            else:
                return ds + 2 * dt
    def near(A, x):
        if (i := bisect_left(A, x)) == 0:
            return [A[0], ]
        elif 0 < i < a:
            return [A[i - 1], A[i]]
        else:
            return [A[-1], ]
    a, b, q = map(int, input().split())
    S = [int(input()) for _ in range(a)]
    T = [int(input()) for _ in range(b)]
    for _ in range(q):
        x = int(input())
        ans = 100000000000
        for s in near(S, x):
            for t in near(T, x):
                ans = min(ans, dist(x, s, t))
        print(ans)

if __name__ == '__main__':
    main()
Problem p03162 (python)

Fixed submission:
n = int(input())
H = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * 3 for _ in range(n)]
dp[0] = H[0]
for i in range(1, n):
    dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + H[i][0]
    dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + H[i][1]
    dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + H[i][2]
print(max(dp[n - 1]))

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
H = np.array([list(map(int, input().split())) for _ in range(n)], dtype = np.int)
dp = np.zeros((n, 3), dtype = np.int)
dp[0] = H[0]
def except_ind(num):
    ind = np.ones((3, ), dtype = bool)
    ind[num] = False
    return ind
for i in range(1, n):
    for j in range(3):
        dp[i][j] = np.max(dp[i - 1][except_ind(j)]) + H[i][j]
print(np.max(dp[n - 1]))
Problem p03240 (python)

Fixed submission:
from itertools import product
def main():
    n = int(input())
    A = []
    for _ in range(n):
        A.append(list(map(int, input().split())))
    for a in A:
        if a[2] > 0:
            t = a
            break
    for x, y in product(range(0, 101), repeat = 2):
        H = t[2] + abs(t[0] - x) + abs(t[1] - y)
        for a in A:
            if a[2] == 0 and H > abs(a[0] - x) + abs(a[1] - y):
                break
            elif a[2] != 0 and a[2] != H - abs(a[0] - x) - abs(a[1] - y):
                break
        else:
            ansx, ansy = x, y
            break
    H = t[2] + abs(t[0] - ansx) + abs(t[1] - ansy)
    print('{} {} {}'.format(ansx, ansy, H))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from itertools import product
def main():
    n = int(input())
    A = []
    for _ in range(n):
        A.append(list(map(int, input().split())))
    for a in A:
        if a[2] != 0:
            t = a
            break
    for x, y in product(range(0, 101), repeat = 2):
        H = t[2] + abs(t[0] - x) + abs(t[1] - y)
        for a in A:
            if a[2] == 0 and H < abs(a[0] - x) + abs(a[1] - y):
                break
            elif a[2] == 0:
                continue
            elif a[2] != 0 and a[2] == H - abs(a[0] - x) - abs(a[1] - y):
                continue
            elif a[2] != H - abs(a[0] - x) - abs(a[1] - y):
                break
        else:
            ansx, ansy = x, y
            break
    H = t[2] + abs(t[0] - ansx) + abs(t[1] - ansy)
    print('{} {} {}'.format(ansx, ansy, H))



if __name__ == '__main__':
    main()
Problem p03280 (python)

Fixed submission:
a, b = list(map(int, input().split()))
print((a - 1) * (b - 1))

Buggy submission (verdict: Runtime Error):
def main():
    a, b = map(int, inptut().split())
    print((a - 1) * (b - 1))

if __name__ == '__main__':
    main()
Problem p03476 (python)

Fixed submission:
def main():
    import math
    def generate_primes(num):
        if num == 1: return []
        primes = list(range(2, num + 1))
        i, p = 0, 1
        while p <= math.sqrt(num):
            if primes[i] != 0:
                p = primes[i]
                primes = [prime if (prime % p != 0 or prime == p) else 0 for prime in primes]
            i += 1
        return set([p for p in primes if p != 0])

    primes = generate_primes(100000)
    ans = [0] * 50001
    for j in range(1, 50001):
        i = 2 * j - 1
        if i in primes and (i + 1) // 2 in primes:
            ans[j] = ans[j - 1] + 1
        else:
            ans[j] = ans[j - 1]
    q = int(input())
    for _ in range(q):
        l, r = list(map(lambda x: (int(x) + 1) // 2, input().split()))
        print(ans[r] - ans[l - 1])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import math
    def generate_primes(num):
        if num == 1: return []
        primes = list(range(2, num + 1))
        i, p = 0, 1
        while p <= math.sqrt(num):
            if primes[i] != 0:
                p = primes[i]
                primes = [prime if (prime % p != 0 or prime == p) else 0 for prime in primes]
            i += 1
        return set([p for p in primes if p != 0])

    primes = generate_primes(100000)
    ans = [0] * 50000
    for j in range(1, 50000):
        i = 2 * j - 1
        if i in primes and (i + 1) / 2 in primes:
            ans[j] = ans[j - 1] + 1
        else:
            ans[j] = ans[j - 1]
    q = int(input())
    for _ in range(q):
        l, r = list(map(lambda x: (int(x) + 1) // 2, input().split()))
        print(ans[r] - ans[l - 1])


if __name__ == '__main__':
    main()
Problem p03486 (python)

Fixed submission:
s = list(input())
t = list(input())
s_uni = sorted([ord(i) for i in s])
t_uni = sorted([ord(i) for i in t], reverse = True)
for i in range(min(len(s), len(t))):
    if s_uni[i] < t_uni[i]:
        print('Yes')
        exit()
    elif s_uni[i] == t_uni[i]:
        continue
    else:
        print('No')
        exit()
if len(s) < len(t):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())
s_uni = sorted([ord(i) for i in s])
t_uni = sorted([ord(i) for i in t], reverse = True)
for i in range(len(s)):
    if s_uni[i] < t_uni[i]:
        print('Yes')
        exit()
    elif s_uni[i] == t_uni[i]:
        continue
    else:
        print('No')
        exit()
if len(s) < len(t):
    print('Yes')
else:
    print('No')
Problem p03547 (python)

Fixed submission:
x, y = input().split()
if x < y:
    print('<')
elif x == y:
    print('=')
else:
    print('>')

Buggy submission (verdict: Runtime Error):
x, y = list(input())
if x < y:
    print('<')
elif x == y:
    print('=')
else:
    print('>')
Problem p03638 (python)

Fixed submission:
def main():
    def flatten_list(l):
        for el in l:
            if isinstance(el, list):
                yield from flatten_list(el)
            else:
                yield el
    H, W = list(map(int, input().split()))
    n = int(input())
    A = list(map(int, input().split()))
    ans = []
    for i, a in enumerate(A):
        ans .append([str(i + 1)] * a)
    ans = list(flatten_list(ans))
    ans = [ans[i:i + W] if i // W % 2 == 0 else ans[i + W - 1:i - 1:-1] for i in range(0, len(ans), W)]
    [print(' '.join(a)) for a in ans]

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    def flatten_list(l):
        for el in l:
            if isinstance(el, list):
                yield from flatten_list(el)
            else:
                yield el
    H, W = list(map(int, input().split()))
    n = int(input())
    A = list(map(int, input().split()))
    ans = []
    for i, a in enumerate(A):
        ans .append([str(i + 1)] * a)
    ans = list(flatten_list(ans))
    ans = [ans[i:i + W] if i // W % 2 == 0 else ans[i + W - 1:i - 1:-1] for i in range(0, len(ans), W)]
    [print(' '.join(a)) for a in ans]



if __name__ == '__main__':
    main()
Problem p03693 (python)

Fixed submission:
n = input().split()
n = int(''.join(n))
if n % 4 == 0:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
n = list(input())
n = int(''.join(n))
if n % 4 == 0:
    print('YES')
else:
    print('NO')
Problem p03992 (python)

Fixed submission:
def main():
    s = input()
    print(s[:4] + ' ' + s[4:])

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    S = list(input())
    k = int(input())
    ans = []
    for s in S:
        if k == 0:
            break
        if s != 'a' and ord(s) >= 123 - k:
            ans.append('a')
            k -= 123 - ord(s)
        else:
            ans.append(s)
    if k > 0:
        ans[-1] = chr(ord(ans[-1]) + k)
    print(''.join(ans))



if __name__ == '__main__':
    main()
Problem p03994 (python)

Fixed submission:
def main():
    S = list(input())
    k = int(input())
    ans = []
    for s in S:
        if s != 'a' and ord(s) >= 123 - k:
            ans.append('a')
            k -= 123 - ord(s)
        else:
            ans.append(s)
    if k > 0:
        ans[-1] = chr((ord(ans[-1]) + k - 97) % 26 + 97)
    print(''.join(ans))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    S = list(input())
    k = int(input())
    ans = []
    for s in S:
        if k == 0:
            break
        if s != 'a' and ord(s) >= 123 - k:
            ans.append('a')
            k -= 123 - ord(s)
        else:
            ans.append(s)
    if k > 0:
        ans[-1] = chr(ord(ans[-1]) + k)
    print(''.join(ans))



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    S = list(input())
    k = int(input())
    ans = []
    for s in S:
        if k == 0:
            break
        if ord(s) >= 123 - k:
            ans.append('a')
            k -= 123 - ord(s)
        else:
            ans.append(s)
    if k > 0:
        ans[-1] = chr(ord(ans[-1]) + k)
    print(''.join(ans))



if __name__ == '__main__':
    main()
Problem p03997 (python)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())
print((a + b) * h // 2)

Buggy submission (verdict: Runtime Error):
a, b, h = list(map(int, input().split()))
print((a + b) * h // 2)
Problem p04015 (python)

Fixed submission:
def main():
    n, a = list(map(int, input().split()))
    X = list(map(lambda x: int(x) - a, input().split()))
    b = max(max([x for x in X]) + a, a)
    dp = [[0] * (2 * b * n + 1) for  _ in range(n + 1)]
    dp[0][b * n] = 1
    for i in range(1, n + 1):
        for j in range(2 * b * n + 1):
            if 0 <= j - X[i - 1] < 2 * b * n:
                dp[i][j] = dp[i - 1][j] + dp[i - 1][j - X[i - 1]]
            else:
                dp[i][j] = dp[i - 1][j]
    print(dp[n][b * n] - 1)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n, a = list(map(int, input().split()))
    X = list(map(lambda x: int(x) - a, input().split()))
    m = sum([x for x in X if x < 0])
    p = sum([x for x in X if x > 0])
    if p == m == 0:
        print(pow(2, n) - 1)
        exit()
    dp = [[0] * (p - m + 1) for  _ in range(n + 1)]
    dp[0][1 - m] = 1
    for i in range(1, n + 1):
        for j in range(p - m + 1):
            if 0 <= j - X[i - 1] < p - m + 1:
                dp[i][j] = dp[i - 1][j] + dp[i - 1][j - X[i - 1]]
            else:
                dp[i][j] = dp[i - 1][j]
    print(dp[n][1 - m] - 1)

if __name__ == '__main__':
    main()
Problem p02760 (python)

Fixed submission:
A=[[int(i) for i in input().split()] for _ in range(3)]
N=int(input())
for _ in range(N):
    b=int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j]==b:
                A[i][j]=-1
flag=False
for h in range(3):
    cnt=0
    for w in range(3):
        if A[h][w]==-1:
            cnt+=1
    if cnt==3:
        flag=True
for w in range(3):
    cnt=0
    for h in range(3):
        if A[h][w]==-1:
            cnt+=1
    if cnt==3:
        flag=True
cnt=0
for d in range(3):
    if A[d][d]==-1:
        cnt+=1
if cnt==3:
    flag=True
cnt=0
for d in range(3):
    if A[d][2-d]==-1:
        cnt+=1
if cnt==3:
    flag=True
print('Yes' if flag else 'No')

Buggy submission (verdict: Runtime Error):
A=[[int(i) for i in input().split()] for _ in range(3)]
N=int(input())
for _ in range(N):
    b=int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j]==b:
                A[i][j]=-1
flag=False
for h in range(3):
    cnt=0
    for w in range(3):
        if A[h][w]==-1:
            cnt+=1
    if cnt==3:
        flag=True
for w in range(3):
    cnt=0
    for h in range(3):
        if A[h][w]==-1:
            cnt+=1
    if cnt==3:
        flag=True
cnt=0
if A[d][d]==-1:
    cnt+=1
if cnt==3:
    flag=True
cnt=0
if A[d][-d]==-1:
    cnt+=1
if cnt==3:
    flag=True
print('Yes' if flag else 'No')
Problem p03141 (python)

Fixed submission:
print(-sum([v[k%2]*(k%2*2-1)for k,v in enumerate(sorted([[int(j) for j in input().split()] for i in range(int(input()))],key=lambda x:-x[0]-x[1]))]))

Buggy submission (verdict: Runtime Error):
#include"bits/stdc++.h"

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7

int N;
vector<ll> A, B;
vector<pair<ll, ll>> diff;

//���C���֐�
int main()
{
	cin >> N;
	A.resize(N);
	B.resize(N);
	diff.resize(N);
	REP(i, N)cin >> A[i] >> B[i];
	REP(i, N)diff[i] = make_pair(A[i] + B[i], i);
	sort(diff.begin(), diff.end());
	reverse(diff.begin(), diff.end());

	ll tak = 0, ao = 0;
	REP(i, N)
	{
		auto p = diff[i];
		if(i % 2 == 0)tak += A[p.second];
		else ao += B[p.second];
	}
	cout << tak - ao << endl;
	//cerr << tak << " " << ao << endl;

	cin >> N;
	return 0;
}
Problem p03262 (python)

Fixed submission:
from fractions import gcd
N , X = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
y = [abs(x[i]-X) for i in range(N)]
res = y[0]
for i in range(1,N):
    res = gcd(res,y[i])
print(res)

Buggy submission (verdict: Runtime Error):
from math import gcd
N , X = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
y = [abs(x[i]-X) for i in range(N)]
res = y[0]
for i in range(1,N):
    res = gcd(res,y[i])
print(res)