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

Fixed submission:
a=int(input())
b=int(input())
x=[1,2,3]
x.remove(a)
x.remove(b)
print(x[0])

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
x=[1,2,3]
x=x.remove(a)
x=x.remove(b)
print(x[0])

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
x=[1,2,3]
x=x.remove(a)
x=x.remove(b)
print(x)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
x=[1,2,3]
print(x.remove(a,b))
Problem p02879 (python)

Fixed submission:
a,b=(int(x) for x in input().split())
if a>9 or b>9:
    print(-1)
else:
    print(a*b)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a>9 or b>9:
    print(-1)
print(a*b)
Problem p02897 (python)

Fixed submission:
a=int(input())
if a%2==0:
    print(a/2/a)
else:
    print((a//2+1)/a)

Buggy submission (verdict: Runtime Error):
a=int(input())
if a%2==0:
    print(a/2/a)
else:
    print((a//2+1)a)
Problem p02951 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a-b>=c:
    print(0)
else:
    print(c-(a-b))

Buggy submission (verdict: Runtime Error):
a,b,cmap(int,input().split())
if a-b>=c:
    print(0)
else:
    print(c-a+b)

Buggy submission (verdict: Runtime Error):
a,b,cmap(int,input().split())
if a-b>=c:
    print(0)
else:
    print(c-a-b)
Problem p03041 (python)

Fixed submission:
a,b=map(int,input().split())
s=input()
print(s[:b-1]+s[b-1].lower()+s[b:])

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=input()
print(s[:k-1]+s[k-1].lower()+s[k:])

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=input()
print(s[:k-1]+s[k-1].lower+s[k:])
Problem p03242 (python)

Fixed submission:
n=input()
result=''
for i in n:
    if i=='1':
        result+='9'
    else:
        result+='1'
print(result)

Buggy submission (verdict: Runtime Error):
n=input()
result=''
for i in n:
    if i==1:
        result+=9
    else:
        result+=1
print(result)

Buggy submission (verdict: Runtime Error):
n=input()
result=''
for i in n:
    if i==1:
        result+=9
    else:
        result+=1
    print(result)

Buggy submission (verdict: Runtime Error):
n=input()
result=''
for i in n:
    if i=='1':
        result+=9
    else:
        result+=1
    print(result)

Buggy submission (verdict: Runtime Error):
n=input()
result=''
for i in n:
    if i=='1':
        result.append('9')
    else:
        result.append('1')
    print(result)
Problem p03307 (python)

Fixed submission:
n=int(input())
if n%2 !=0:
    print(2*n)
else:
    print(n)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n% !=0:
    print(2*n)
else:
    print(n)
Problem p02623 (python)

Fixed submission:
import numpy as np
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n, m, k = geta(int)
    a = np.array([0] + list(geta(int)))
    b = np.array([0] + list(geta(int)))

    ca = np.cumsum(a)
    cb = np.cumsum(b)

    ans = 0
    for i, ai in enumerate(ca):
        if k < ai:
            break

        j = np.searchsorted(cb, k-ai, side="right") - 1

        if ans < i + j:
            ans = i + j

    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n, m, k = geta(int)
    ca = np.array([0] + list(geta(int))).cumsum()
    cb = np.array([0] + list(geta(int))).cumsum()

    ans = 0
    for i in range(n+1):
        if ca[i] > k:
            break
        j = np.searchsorted(cb, k-ca[i], side="right") - 1
        if ans < i + j:
            ans = i + j

    print(ans)


if __name__ == "__main__":
    main()
Problem p02624 (python)

Fixed submission:
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n = gete(int)

    ans = 0
    for i in range(1, n+1):
        m = n//i
        ans += i * m * (m+1) // 2

    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n = gete(int)

    ans = 0
    for i in range(1, n+1):
        m = n//i
        ans += i * m * (m+1) // 2

    print(ans)


if __name__ == "__main__":
    main()
Problem p02685 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**5)
# from collections import defaultdict

geta = lambda fn: list(map(fn, input().split()))


def egcd(a: int, b: int):
    """
    A solution of ax+by=gcd(a,b). Returns
    (gcd(a,b), (x, y)).
    """
    if a == 0:
        return b, 0, 1
    else:
        g, x, y = egcd(b % a, a)
        return g, y - (b // a) * x, x


def modinv(a: int, m: int):
    """
    Returns a^{-1} modulo m.
    """
    g, x, y = egcd(a, m)
    if g > 1:
        raise Exception('{}^(-1) mod {} does not exist.'.format(a, m))
    else:
        return x % m


def modpow(a: int, n: int, m: int):
    """
    Returns a^n mod m. (-inf < n < inf)
    """
    if a in [-1, 0, 1]:
        if a == -1:
            return 1 if n & 1 == 0 else m - 1
        else:
            return a

    x, k = (a % m, n) if n >= 0 else (modinv(a, m), -n)

    ret = 1
    while k > 0:
        if k & 1 == 1:
            ret = ret * x % m
        x *= x
        k = k >> 1

    return ret


mod = 998244353

N, M, K = geta(int)

if M == 1:
    print(0 if K < N - 1 else 1)
    exit()

a = M * modpow(M - 1, N - 1, mod) % mod
ans, k = a, 1
mi = modinv(M - 1, mod)

for k in range(1, K + 1):
    a = a * (N - k) * mi * modinv(k, mod) % mod
    ans = (ans + a) % mod

print(ans)

Buggy submission (verdict: Runtime Error):
# import sys
# sys.setrecursionlimit
# from collections import defaultdict

geta = lambda fn: list(map(fn, input().split()))


def egcd(a: int, b: int):
    """
    A solution of ax+by=gcd(a,b). Returns
    (gcd(a,b), (x, y)).
    """
    if a == 0:
        return b, 0, 1
    else:
        g, x, y = egcd(b % a, a)
        return g, y - (b // a) * x, x


def modinv(a: int, m: int):
    """
    Returns a^{-1} modulo m.
    """
    g, x, y = egcd(a, m)
    if g > 1:
        raise Exception('{}^(-1) mod {} does not exist.'.format(a, m))
    else:
        return x % m


def modpow(a: int, n: int, m: int):
    """
    Returns a^n mod m. (-inf < n < inf)
    """
    if a in [-1, 0, 1]:
        if a == -1:
            return 1 if n & 1 == 0 else m - 1
        else:
            return a

    x, k = (a % m, n) if n >= 0 else (modinv(a, m), -n)

    ret = 1
    while k > 0:
        if k & 1 == 1:
            ret = ret * x % m
        x *= x
        k = k >> 1

    return ret


mod = 998244353

N, M, K = geta(int)

a = M * modpow(M - 1, N - 1, mod) % mod
ans, k = a, 1
mi = modinv(M - 1, mod)

for k in range(1, K + 1):
    a = a * (N - k) * mi * modinv(k, mod) % mod
    ans = (ans + a) % mod

print(ans)
Problem p02695 (python)

Fixed submission:
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
L = []
for _ in range(Q):
    L.append(tuple(map(int, input().split())))

ans = 0
_N = N
if N < M:
    _N = M

for A in combinations_with_replacement(range(1, M + 1), _N):
    tmp = 0
    for a, b, c, d in L:
        if a <= _N and b <= _N and A[b - 1] - A[a - 1] == c:
            tmp += d

    if tmp > ans:
        ans = tmp

print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
L = []
for _ in range(Q):
    L.append(tuple(map(int, input().split())))

ans = 0
for A in combinations_with_replacement(range(1, M + 1), min(N, M)):
    tmp = 0
    for a, b, c, d in L:
        if A[b - 1] - A[a - 1] == c:
            tmp += d

    if tmp > ans:
        ans = tmp

print(ans)
Problem p02754 (python)

Fixed submission:
class Solution:
    def solve(self, N: int, A: int, B: int) -> int:

        return (N // (A+B)) * A + min(N % (A+B), A)


if __name__ == '__main__':

    # standard input
    N, A, B = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(N, A, B))

Buggy submission (verdict: Runtime Error):
import unittest
from solution import Solution


class TestSolution(unittest.TestCase):

    def test_001(self):
        # class under test
        solution = Solution()

        # actual
        N, A, B = 6, 2, 4

        actual = solution.solve(N, A, B)

        # expect
        expect = 2

        # assert
        self.assertEqual(actual, expect)

    def test_002(self):
        # class under test
        solution = Solution()

        # actual
        N, A, B = 10**18, 5, 5

        actual = solution.solve(N, A, B)

        # expect
        expect = 5 * 10**17

        # assert
        self.assertEqual(actual, expect)


if __name__ == '__main__':
    unittest.main()
Problem p02831 (python)

Fixed submission:
import fractions


class Solution:
    def solve(self, a: int, b: int) -> int:

        return a * b // fractions.gcd(a, b)


if __name__ == '__main__':

    # standard input
    a, b = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(a, b))

Buggy submission (verdict: Runtime Error):

class Solution:
    def solve(self, a: int, b: int) -> int:

        return a * b // math.gcd(a, b)


if __name__ == '__main__':

    # standard input
    a, b = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(a, b))

Buggy submission (verdict: Runtime Error):
import math


class Solution:
    def solve(self, a: int, b: int) -> int:

        return a * b // math.gcd(a, b)


if __name__ == '__main__':

    # standard input
    a, b = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(a, b))
Problem p02862 (python)

Fixed submission:
class Solution:
    def solve(self, x: int, y: int) -> int:

        if (2*x - y) % 3 != 0 or (-x + 2*y) % 3 != 0:
            return 0

        m = (2*x - y) // 3
        n = (-x + 2*y) // 3

        if m < 0 or n < 0:
            return 0

        # calculate {m+n}C{n}
        def egcd(a, b):
            if a == 0:
                return b, 0, 1
            else:
                g, y, x = egcd(b % a, a)
                return g, x - (b // a) * y, y

        def modinv(a, m):
            g, x, y = egcd(a, m)
            if g != 1:
                raise Exception('modular inverse does not exist')
            else:
                return x % m

        def convination(n: int, r: int, mod: int = 10**9+7) -> int:
            r = min(r, n-r)
            res = 1
            for i in range(r):
                res = res * (n-i) * modinv(i+1, mod) % mod
            return res

        return convination(n+m, m)


if __name__ == '__main__':

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

    # solve
    solution = Solution()
    print(solution.solve(x, y))

Buggy submission (verdict: Runtime Error):
class Solution:
    def solve(self, x: int, y: int) -> int:

        if (2*x - y) % 3 != 0 or (-x + 2*y) % 3 != 0:
            return 0

        m = (2*x - y) // 3
        n = (-x + 2*y) // 3

        # calculate {m+n}C{n}

        mod = 10**9 + 7

        # power
        def fastPow(x: int, n: int) -> int:
            ans = 1
            while n > 0:
                if n & 1 == 1:
                    ans = ans * x % mod
                x = x * x % mod
                n >>= 1

            return ans

        # factorial and its inverse
        fact = [1]
        inv = [1]
        for i in range(1, m+n+1):
            fact.append(0)
            inv.append(0)
            fact[i] = fact[i-1] * i % mod
            inv[i] = fastPow(fact[i], mod - 2) % mod

        return fact[n+m] * inv[n] % mod * inv[m] % mod


if __name__ == '__main__':

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

    # solve
    solution = Solution()
    print(solution.solve(x, y))
Problem p02879 (python)

Fixed submission:
class Solution:
    def solve(self, a: int, b: int) -> int:

        if 1 <= a <= 9 and 1 <= b <= 9:
            return a*b
        else:
            return -1


if __name__ == '__main__':

    # standard input
    a, b = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(a, b))

Buggy submission (verdict: Runtime Error):
from typing import List


class Solution:
    def solve(self, a: int, b: int) -> int:

        if 1 <= a <= 9 and 1 <= b <= 9:
            return a*b
        else:
            return -1


if __name__ == '__main__':

    # standard input
    a, b = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(a, b))
Problem p02881 (python)

Fixed submission:
import math


class Solution:
    def solve(self, n: int) -> int:

        maxDivisor = int(math.sqrt(n) + 0.5)

        for i in range(1, maxDivisor + 1):
            if n % i == 0:
                p = i

        q = n // p

        return p+q-2


if __name__ == '__main__':

    # standard input
    n = int(input())

    # solve
    solution = Solution()
    print(solution.solve(n))

Buggy submission (verdict: Runtime Error):

class Solution:
    def solve(self, n: int) -> int:

        maxDivisor = int(math.sqrt(n) + 0.5)

        for i in range(1, maxDivisor + 1):
            if n % i == 0:
                p = i

        q = n // p

        return p+q-2


if __name__ == '__main__':

    # standard input
    n = int(input())

    # solve
    solution = Solution()
    print(solution.solve(n))
Problem p02933 (python)

Fixed submission:
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    a = gete(int)
    s = gete()

    if a < 3200:
        print('red')
    else:
        print(s)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    a = gete(int)
    s = gete()

    if s < 3200:
        print(a)
    else:
        print('red')


if __name__ == "__main__":
    main()
Problem p03253 (python)

Fixed submission:
import math


class Solution:

    def solve(self, N: int, M: int) -> int:

        mod = 10**9+7
        INT_MAX = 10**9

        # calculate {m+n}C{n}

        def egcd(a, b):
            if a == 0:
                return b, 0, 1
            else:
                g, y, x = egcd(b % a, a)
                return g, x - (b // a) * y, y

        def modinv(a, m):
            g, x, y = egcd(a, m)
            if g != 1:
                raise Exception('modular inverse does not exist')
            else:
                return x % m

        def combination(n: int, r: int, mod: int = 10**9+7) -> int:
            r = min(r, n-r)
            res = 1
            for i in range(r):
                res = res * (n-i) * modinv(i+1, mod) % mod
            return res

        # solve

        m = M
        answer = 1
        factors = {}
        for i in range(2, int(math.sqrt(M))+1):
            factor = 0
            while m % i == 0:
                m //= i
                factor += 1

            if factor > 0:
                answer *= combination(N + factor - 1, N - 1, mod=mod)
                answer %= mod

        if m > 1:
            answer *= N
            answer %= mod

        return answer


if __name__ == '__main__':

    # standard input
    N, M = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(N, M))

Buggy submission (verdict: Runtime Error):
class Solution:

    def solve(self, N: int, M: int) -> int:

        mod = 10**9+7
        INT_MAX = 10**9

        # calculate {m+n}C{n}

        def egcd(a, b):
            if a == 0:
                return b, 0, 1
            else:
                g, y, x = egcd(b % a, a)
                return g, x - (b // a) * y, y

        def modinv(a, m):
            g, x, y = egcd(a, m)
            if g != 1:
                raise Exception('modular inverse does not exist')
            else:
                return x % m

        def combination(n: int, r: int, mod: int = 10**9+7) -> int:
            r = min(r, n-r)
            res = 1
            for i in range(r):
                res = res * (n-i) * modinv(i+1, mod) % mod
            return res

        # prime list

        isPrime = [True] * (INT_MAX + 1)
        isPrime[0], isPrime[1] = False, False
        primes = []

        for i in range(2, len(isPrime)):
            if isPrime[i] == True:
                primes.append(i)
                for j in range(2 * i, len(isPrime), i):
                    isPrime[j] = False

        # solve

        m = M
        answer = 1
        factors = {}
        while m > 1:
            for p in primes:
                factors[p] = 0

                while m % p == 0:
                    m //= p
                    factors[p] += 1

                if factors[p] > 0:
                    answer *= combination(N + factors[p] - 1, N - 1, mod=mod)
                    answer %= mod

        return answer


if __name__ == '__main__':

    # standard input
    N, M = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(N, M))
Problem p03326 (python)

Fixed submission:
class Solution:

    def solve(self, N: int, M: int, cakes) -> int:

        sign = []
        for i in [1, -1]:
            for j in [1, -1]:
                for k in [1, -1]:
                    sign.append((i, j, k))

        def sumprod(c, s):
            ret = 0
            for i in range(len(c)):
                ret += c[i] * s[i]
            return ret

        candidates = []
        for s in sign:
            cakes = sorted(cakes, key=lambda c: sumprod(c, s))

            xyz = [0, 0, 0]
            for i in range(M):
                for j in range(3):
                    xyz[j] += cakes[i][j]

            candidates.append(
                sum([abs(xyz_) for xyz_ in xyz])
            )

        return max(candidates)


if __name__ == '__main__':

    # standard input
    N, M = map(int, input().split())
    cakes = []
    for i in range(N):
        cakes.append(tuple(map(int, input().split())))

    # solve
    solution = Solution()
    print(solution.solve(N, M, cakes))

Buggy submission (verdict: Runtime Error):
from typing import List


class Solution:

    def solve(self, N: int, M: int, cakes) -> int:

        sign = []
        for i in [1, -1]:
            for j in [1, -1]:
                for k in [1, -1]:
                    sign.append((i, j, k))

        def sumprod(c, s):
            ret = 0
            for i in range(len(c)):
                ret += c[i] * s[i]
            return ret

        candidates = []
        for s in sign:
            cakes = sorted(cakes, key=lambda c: sumprod(c, s))

            xyz = [0, 0, 0]
            for i in range(M):
                for j in range(3):
                    xyz[j] += cakes[i][j]

            candidates.append(
                sum([abs(xyz_) for xyz_ in xyz])
            )

        return max(candidates)


if __name__ == '__main__':

    # standard input
    N, M = map(int, input().split())
    cakes = []
    for i in range(N):
        cakes.append(tuple(map(int, input().split())))

    # solve
    solution = Solution()
    print(solution.solve(N, M, cakes))
Problem p02594 (python)

Fixed submission:
n = int(input())
if n >= 30:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
if X>=30:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = int(input()).
if n>=30:
  print("Yes")
else:
  print("No")
Problem p02595 (python)

Fixed submission:
N, D = map(int,input().split())
ans = 0
i = 1
while i <= N:
  i += 1
  X, Y = map(int,input().split())
  
  if X * X + Y * Y <= D * D:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
D=int(input())
ans = 0
i=1
while i<=N:
  i+=1
  X=int(input())
  Y=int(input())
  if X * X + Y * Y <= D * D:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
D=int(input())
ans = 0
for i in range(1,N):
  X=int(input())
  Y=int(input())
  if X * X + Y * Y <= D * D:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
read N, D as int
ans = 0
for i = 1, ..., N:
	read X, Y as int
	if X * X + Y * Y <= D * D:
		ans += 1
 write ans

Buggy submission (verdict: Runtime Error):
n=int(input())
b=int(input())
count=1
i=1
while i<=n:
  p = int(input())
  q = int(input())  
  r = abs(complex(p,q))
  a=int(r)
  i+=1
if a==b:
  count+=1
print(count)
Problem p02729 (python)

Fixed submission:

n,m = map(int,input().split())
import math

print(n*(n-1)//2 + m*(m-1)//2)

Buggy submission (verdict: Runtime Error):

n,m = map(int,input().split())
import math
def c(n,k):
    return math.factorial(n)//math.factorial(k)//math.factorial(n-k)

print(c(n,2) + c(m,2))
Problem p02754 (python)

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

shou = n // (a+b)
amari = n % (a+b)

if amari >= a:
    print(shou * a + a)

else: print(shou * a + amari)

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

shou = n // (a+b)
amari = n % (a+b)

ans = shou*a+a if amari >= a　else shou*a+amari

print(ans)

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

shou = n // (a+b)
amari = n % (a+b)

ans = shou * a + a if amari >= a　else shou*a+amari

print(ans)

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

shou = n // (a+b)
amari = n % (a+b)

ans = shou * a + a if amari >= a　else ans = shou*a+amari

print(ans)

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

shou = n // (a+b)
amari = n % (a+b)

print(shou * a + a) if amari >= a　else print(shou*a+amari)

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

shou = n // (a+b)
amari = n % (a+b)

print(shou * a + a) if amari >= a

print(shou * a + amari) if amari < a