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

Fixed submission:
def K1(n):
    ans = 0
    d = len(str(n))
    ans += int(str(n)[0])
    ans += 9 * (d-1)
    return ans


def K2(n):
    d = len(str(n))
    ans = 9**2*(d-2)*(d-1)//2
    ans += (int(str(n)[0]) - 1) * 9 * (d-1)
    ans += K1(int(str(n)[1:]))
    return ans


def K3(n):
    d = len(str(n))
    ans = 0
    for i in range(2,d-1):
        ans += i*(i-1)//2
    ans *= 9**3
    ans += (int(str(n)[0]) - 1) * 9**2 * (d-1)*(d-2) // 2
    ans += K2(int(str(n)[1:]))
    return ans


def main():
    N = int(input())
    K = int(input())

    if K == 1:
        print(K1(N))

    if K == 2:
        if N < 10:
            print(0)
            exit()
        print(K2(N))

    if K == 3:
        if N < 100:
            print(0)
            exit()
        print(K3(N))



if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
MOD = 10**9+7
fac = [1, 1]

def prepare(n, mod):
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)


def modcmb(n, r, mod):
    if n < 0 or r < 0 or r > n:
        return 0

    return fac[n] * pow(fac[r], mod-2, mod) * pow(fac[n-r], mod-2, mod) % mod


def f(r, c):
    return modcmb(r+c, r, MOD)


def g(x, y):
    return ((y+2) * modcmb(x+y+2, x, MOD) - (x+1)) * pow(x+1, MOD-2, MOD)


def main():
    prepare(2*10**6+10, MOD)
    r1,c1,r2,c2 = map(int, input().split())

    ans = g(r2, c2) - g(r1-1, c2) - g(r2, c1-1) + g(r1-1, c1-1)
    ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def K1(n):
    ans = 0
    d = len(str(n))
    ans += int(str(n)[0])
    ans += 9 * (d-1)
    return ans


def K2(n):
    d = len(str(n))
    ans = 9**2*(d-2)*(d-1)//2
    ans += (int(str(n)[0]) - 1) * 9 * (d-1)
    ans += K1(int(str(n)[1:]))
    return ans


def K3(n):
    d = len(str(n))
    ans = 0
    for i in range(2,d-1):
        ans += i*(i-1)//2
    ans *= 9**3
    ans += (int(str(n)[0]) - 1) * 9**2 * (d-1)*(d-2) // 2
    ans += K2(int(str(n)[1:]))
    return ans


def main():
    N = int(input())
    K = int(input())

    if K == 1:
        print(K1(N))

    if K == 2:
        print(K2(N))

    if K == 3:
        print(K3(N))



if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def K1(n):
    ans = 0
    d = len(str(n))
    ans += int(str(n)[0])
    ans += 9 * (d-1)
    return ans


def K2(n):
    d = len(str(n))
    ans = 9**2*(d-2)*(d-1)//2
    ans += (int(str(n)[0]) - 1) * 9 * (d-1)
    ans += K1(int(str(n)[1:]))
    return ans


def K3(n):
    d = len(str(n))
    ans = 9**3*(d-2)*(d-3)//2
    ans += (int(str(n)[0]) - 1) * 9 * (d-1)
    ans += K2(int(str(n)[1:]))
    return ans


def main():
    N = int(input())
    K = int(input())

    if K == 1:
        print(K1(N))

    if K == 2:
        print(K2(N))

    if K == 3:
        print(K3(N))



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

Fixed submission:
from functools import reduce
from fractions import gcd

MOD = 10**9+7

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

def main():
    N = int(input())
    a = [int(i) for i in input().split()]

    lcm = reduce(lcm_base, a, 1)
    
    ans = 0
    for i in a:
        ans += lcm // i

    print(ans % MOD)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from collections import Counter, defaultdict
from math import sqrt

MOD = 10**9+7
p_list = defaultdict(int)

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


def main():
    N = int(input())
    a = [int(i) for i in input().split()]

    for i in a:
        l = Counter(prime_decomposition(i))
        for k, v in l.items():
            p_list[k] = max(p_list[k], v)
    
    lcm = 1
    for k, v in p_list.items():
        lcm *= k**v

    ans = 0
    for i in a:
        ans += lcm // i

    print(int(ans) % MOD)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from functools import reduce
from fractions import gcd
import numpy as np

MOD = 10**9+7

def main():
    N = int(input())
    a = [int(i) for i in input().split()]
    A = np.array(a)

    lcm = np.lcm.reduce(A)
    B = lcm // A

    print(np.sum(B) % MOD)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
input = sys.stdin.readline

from functools import reduce
from fractions import gcd
import numpy as np

MOD = 10**9+7

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


def main():
    N = int(input())
    a = [int(i) for i in input().split()]
    A = np.array(a)

    lcm = reduce(lcm_base, a, 1)
    B = lcm // A

    print(np.sum(B) % MOD)


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

Fixed submission:
from math import sqrt

def main():
    N = int(input())

    ans = 10**12+1
    for i in range(1, int(sqrt(N))+1):
        if N % i == 0:
            tmp = i + (N // i) - 2
            ans = min(ans, tmp)
        
    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from math import sqrt, inf

def main():
    N = int(input())

    ans = inf
    for i in range(1, int(sqrt(N))+1):
        if N % i == 0:
            tmp = i + (N // i) - 2
            ans = min(ans, tmp)
        
    print(ans)


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

Fixed submission:
import re

def main(s):
    #文字列sに同じ文字がn個以上連続している部分文字列を見つける
    n = 2
    # カンマを取ると n 個ちょうどになる
    reg = re.compile("(.)\\1{%d,}" %(n-1))
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]


if __name__ == "__main__":
    s = input()
    K = int(input())

    # 1文字の場合
    if len(s) == 1:
        print(K // 2)
        exit()

    t = list(main(s))

    # 全ての文字が同じ場合
    if len(t) == 1 and len(t[0]) == len(s):
        print((len(s) * K) // 2)
        exit()

    # 先頭と末尾が同じ場合
    ans1 = 0
    if len(s) >= 3 and s[0] == s[-1]:
        if len(t) >= 2 and t[0][0] == s[0] and t[-1][0] == s[-1]:
            ans1 = len(t[0]) // 2 + len(t[-1]) // 2 - ((len(t[0]) + len(t[-1])) // 2)
            ans1 *= K-1
        
        elif len(t) >= 1 and t[0][0] != s[0]:
            ans1 = len(t[-1]) // 2 - ((1 + len(t[-1])) // 2)
            ans1 *= K-1
        
        elif len(t) >= 1 and t[-1][0] != s[-1]:
            ans1 = len(t[0]) // 2 - ((len(t[0] + 1)) // 2)
            ans1 *= K-1
        
        else:
            ans1 = -1 * (K-1)

    # 先頭と末尾が異なる場合
    ans2 = 0
    for i in t:
        ans2 += len(i) // 2
    ans2 *= K

    ans = -ans1 + ans2
    print(ans)

Buggy submission (verdict: Runtime Error):
import re

def main(s):
    #文字列sに同じ文字がn個以上連続している部分文字列を見つける
    n = 2
    # カンマを取ると n 個ちょうどになる
    reg = re.compile("(.)\\1{%d,}" %(n-1))
    while True:
        m = reg.search(s)
        if not m:
            break
        yield m.group(0)
        s = s[m.end():]


if __name__ == "__main__":
    s = input()
    K = int(input())

    # 1文字の場合
    if len(s) == 1:
        print(K // 2)
        exit()

    t = list(main(s))

    # 全ての文字が同じ場合
    if len(t) == 1 and len(t[0]) == len(s):
        print((len(s) * K) // 2)
        exit()

    # 先頭と末尾が同じ場合
    ans1 = 0
    if len(s) >= 3 and s[0] == s[-1]:
        if len(t) >= 2 and t[0][0] == s[0] and t[-1][0] == s[-1]:
            ans1 = len(t[0]) // 2 + len(t[-1]) // 2 - ((len(t[0]) + len(t[-1])) // 2)
            ans *= K-1
        
        elif len(t) >= 1 and t[0][0] != s[0]:
            ans1 = len(t[-1]) // 2 - ((1 + len(t[-1])) // 2)
            ans1 *= K-1
        
        elif len(t) >= 1 and t[0][0] != s[0]:
            ans1 = len(t[0]) // 2 - ((len(t[0] + 1)) // 2)
            ans1 *= K-1
        
        else:
            ans1 = -1 * (K-1)

    # 先頭と末尾が異なる場合
    ans2 = 0
    for i in t:
        ans2 += len(i) // 2
    ans2 *= K

    ans = -ans1 + ans2
    print(ans)
Problem p02912 (python)

Fixed submission:
from heapq import heappush, heappop

N,M = map(int, input().split())
hq = []
a = [int(i) for i in input().split()]
for i in range(N):
    heappush(hq, -a[i])

for i in range(M):
    tmp = -heappop(hq) // 2
    heappush(hq, -tmp)

print(-sum(hq))

Buggy submission (verdict: Runtime Error):
from heapq import heappush, heappop

N,M = map(int, input().split())
a = [int(i) for i in input().split()]

hq = heapq.heapify(a)

for i in range(N):
    heappush(hq, -a[i])

for i in range(M):
    tmp = -heappop(hq) // 2
    heappush(hq, -tmp)

print(-sum(hq))
Problem p02984 (python)

Fixed submission:
import sys
input = sys.stdin.readline

N = int(input())
a = [int(i) for i in input().split()]

s = sum(a)
x = [None]*N
x[0] = s - 2 * (sum(a[1::2]))

for i in range(1,N):
    x[i] = 2 * a[i-1] - x[i-1]

print(*x)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

input = sys.stdin.readline
N = int(input())
B = [int(i)*2 for i in input().split()]

#a = [[0]*N for i in range(N)]
A = np.identity(N)
for i in range(N-1):
    #A[i][i] += 1
    A[i][i+1] += 1

A[-1][0] += 1
#A[-1][-1] += 1
#A = np.array(a)
b = np.array(B)

x = np.linalg.solve(A, b)

for i in x:
  print(int(i), end=" ")

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
B = [int(i)*2 for i in input().split()]

#a = [[0]*N for i in range(N)]
A = np.identity(N)
for i in range(N-1):
    #A[i][i] += 1
    A[i][i+1] += 1

A[-1][0] += 1
#A[-1][-1] += 1
#A = np.array(a)
b = np.array(B)

x = np.linalg.solve(A, b)

print(*x.astype(int))

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

input = sys.stdin.readline
N = int(input())
B = [int(i)*2 for i in input().split()]

#a = [[0]*N for i in range(N)]
A = np.identity(N)
for i in range(N-1):
    #A[i][i] += 1
    A[i][i+1] += 1

A[-1][0] += 1
#A[-1][-1] += 1
#A = np.array(a)
b = np.array(B)

x = np.linalg.solve(A, b)

print(*x.astype(int))

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

input = sys.stdin.readline
N = int(input())
B = [int(i)*2 for i in input().split()]

a = [[0]*N for i in range(N)]

for i in range(N-1):
    a[i][i] += 1
    a[i][i+1] += 1

a[-1][0] += 1
a[-1][-1] += 1

A = np.array(a)
b = np.array(B)

x = np.linalg.solve(A, b)

print(*x.astype(int))
Problem p02987 (python)

Fixed submission:
from collections import Counter

s = input()

t = Counter(s)

a = []
for i,j in t.items():
    a.append(j)

if len(a) == 2:
    if a[0] == a[1]:
        print("Yes")
        exit()

print("No")

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

N,K = map(int, input().split())
MOD = 10**9+7
A = N - K + 1

nCr = {}
def cmb(n, r):
    if n < r:
        return 0
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n,r) in nCr:
        return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

for i in range(K):
    print(cmb(K-1, i) * cmb(A, i+1) % MOD)
Problem p02990 (python)

Fixed submission:
#import sys
#sys.setrecursionlimit(100000)

N,K = map(int, input().split())
MOD = 10**9+7
A = N - K + 1

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

for i in range(K):
    if N - K - i >= 0:
        print(cmb(K-1, i) * cmb(A, i+1) % MOD)
    else:
        print(0)

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
MOD = 10**9+7
A = N - K + 1

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

print(N-K+1)
for i in range(1,K):
    ans = cmb(K-1, i)
    ans %= MOD
    ans *= cmb(A, i+1)
    ans %= MOD
    print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
MOD = 10**9+7
A = N - K + 1

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

print(N-K+1)
for i in range(1,K):
    ans = cmb(K-1, i) % MOD
    ans *= cmb(A, i+1) % MOD

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
MOD = 10**9+7
A = N - K + 1

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

print(N-K+1)
for i in range(1,K):
    print(cmb(K-1, i) * cmb(A, i+1) % MOD)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)

N,K = map(int, input().split())
MOD = 10**9+7
A = N - K + 1

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

print(N-K+1)
for i in range(1,K):
    print(cmb(K-1, i) * cmb(A, i+1) % MOD)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

N,K = map(int, input().split())
MOD = 10**9+7
A = N - K + 1

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

print(N-K+1)
for i in range(1,K):
    print(cmb(K-1, i) * cmb(A, i+1) % MOD)
Problem p03038 (python)

Fixed submission:
N,M = map(int, input().split())
a = [int(i) for i in input().split()]
c = [[int(i) for i in input().split()] for j in range(M)]

a.sort()
c2=sorted(c,key=lambda x:(-int(x[1])))

d = []
for i in range(M):
    for j in range(c2[i][0]):
        d.append(c2[i][1])
        if len(d) == N:
            break
    else:
        continue
    break

i = 0
while a[i] < d[i]:
    a[i] = d[i]
    i += 1
    if i == N or i == len(d):
        break

print(sum(a))

Buggy submission (verdict: Runtime Error):
N,M=map(int, input().split())
a=[int(i) for i in input().split()]
a.sort()
'''
for i in range(M):
    B,C=map(int, input().split())
    for j in range(B):
        if a[j]<C:
            a[j]=C   
    a.sort()

print(sum(a))
'''
for i in range(M):
    B,C=map(int, input().split())
    j=0
    while j<B:
        if a[j]>C:
            break
        a[j]=C
        j+=1
    a.sort()
    print(a)

print(sum(a))
Problem p02629 (python)

Fixed submission:
import string

N = int(input())
alphabet = list(string.ascii_lowercase)
num2alphabet = {i + 1: a for i, a in enumerate(alphabet)}
num2alphabet[0] = "z"
ans = ""

while N > 0:
    num = N % 26
    ans += num2alphabet[num]
    if N <= 26:
        break

    if num == 0:
        N -= 1

    N = N // 26

print(''.join(list(reversed(ans))))

Buggy submission (verdict: Runtime Error):
N = int(input())
alphabet = [chr(ord('a') + i) for i in range(26)]
num2alphabet = {i + 1: a for i, a in enumerate(alphabet)}

ans = ""

while N > 0:
    num = N % 26
    ans += num2alphabet[num]
    N = N // 26

print(''.join(list(reversed(ans))))

Buggy submission (verdict: Runtime Error):
import string

N = int(input())
alphabet = [chr(ord('a') + i) for i in range(26)]
num2alphabet = {i + 1: a for i, a in enumerate(alphabet)}

ans = ""

while N > 0:
    num = N % 26
    ans += num2alphabet[num]
    N = N // 26

print(''.join(list(reversed(ans))))

Buggy submission (verdict: Runtime Error):
import string

N = int(input())
alphabet = list(string.ascii_lowercase)
num2alphabet = {i + 1: a for i, a in enumerate(alphabet)}

ans = ""

while N > 0:
    num = N % 26
    ans += num2alphabet[num]
    N = N // 26

print(''.join(list(reversed(ans))))
Problem p02659 (python)

Fixed submission:
A, B = input().split()
A = int(A)
B = int(B.replace(".", ""))

print(A * B // 100)

Buggy submission (verdict: Runtime Error):
A, B = input().split()
A = int(A // 100)
B = int(float(B) * 100)
AB = A * B
print(AB)
Problem p02682 (python)

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

if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(A - (K - (A + B)))

Buggy submission (verdict: Runtime Error):
def solve(A, B, C, K):
    num = K

    if K <= A:
        return 1 * A

    num -= A
    ans = 1 * A

    if num <= B:
        return ans

    num -= B

    if num < 0:
        return ans

    return ans - num


A, B, C, K = map(int, input().split())
print(solve1(A, B, C, K))
Problem p03053 (python)

Fixed submission:
from collections import deque
H, W = map(int, input().split())

area = [input() for _ in range(H)]

distance = [ [float('inf') for _ in range(W)] for _ in range(H)]
to_search = deque()

for i in range(H):
    for j in range(W):
        if area[i][j] == "#":
            to_search.appendleft((i, j, 0))
            distance[i][j] = 0

didj = [[1, 0], [0, 1], [-1, 0], [0, -1]]
ans = 0

while len(to_search) > 0:
    nowi, nowj, nowd = to_search.pop()
    for di, dj in didj:
        nexti = nowi + di
        nextj = nowj + dj
        if 0 <= nexti < H and 0 <= nextj < W:
            if distance[nexti][nextj] > nowd + 1:
                to_search.appendleft((nexti, nextj, nowd + 1))
                distance[nexti][nextj] = nowd + 1
                ans = max(ans, nowd + 1)

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
H, W = map(int, input().split())

area = [input() for _ in range(H)]

distance = [ [float('inf') for _ in range(W)] for _ in range(H)]
to_search = deque()

for i in range(H):
    for j in range(W):
        if area[i][j] == "#":
            to_search.appendleft((i, j, 0))
            distance[i][j] = 0

didj = [[1, 0], [0. 1], [-1, 0], [0, -1]]
ans = 0

while len(to_search) > 0:
    nowi, nowj, nowd = to_search.pop()
    for di, dj in didj:
        nexti = nowi + di
        nextj = nowj + dj
        if 0 <= nexti <= H and 0 <= nextj <= W:
            if distance[nexti][nextj] > nowd + 1:
                to_search.appendleft((nexti, nextj, nowd + 1))
                distance[nexti][nextj] = nowd + 1
                ans = max(ans, nowd + 1)

print(ans)
Problem p03221 (python)

Fixed submission:
import sys


class City:
    def __init__(self, ind, pref, time):
        self.ind = ind
        self.pref = pref
        self.time = time
        self.sort_res = None

    def get_id(self):
        str1 = "0" * (6 - len(str(self.pref))) + str(self.pref)
        str2 = "0" * (6 - len(str(self.sort_res))) + str(self.sort_res)
        return str1 + str2
    def __str__(self):
    	return str(self.ind)
if __name__ == '__main__':
    nm = list(sys.stdin.readline().split(" "))
    N = int(nm[0])
    M = int(nm[1])
    prefs = [[] for x in range(N)]
    cities = []
    for i in range(M):
        info = sys.stdin.readline().rstrip().split(" ")
        newcity = City(i, int(info[0]), int(info[1]))
        prefs[int(info[0])-1].append(newcity)
    for i in range(N):
        prefs[i].sort(key=lambda x: x.time)
        for j in range(len(prefs[i])):
            prefs[i][j].sort_res = j + 1
    for i in prefs:
        for j in i:
            cities.append(j)
    cities.sort(key=lambda y: y.ind)
    for i in cities:
        print(i.get_id())

Buggy submission (verdict: Runtime Error):
import sys
class City:
  def __init__(self, index, pref, time):
    self.index = index
    self.pref = pref
    self.time = time
    self.sort_res = None
  def get_id(self):
    str1 = "0"*(6-len(str(self.pref)))+str(self.pref)
    str2 = "0"*(6-len(str(self.sort_res)))+str(self.sort_res)
    return str1 + str2
if __name__ == '__main__':
  nm = list(sys.stdin,readline().split(" "))
  N = int(nm[0])
  M = int(nm[1])
  prefs = [[]] * N
  cities = []
  for i in range(M):
    info = list(sys.stdin,readline().split(" "))
    newcity = City(i,int(info[0]),int(info[1]))
    prefs[int(info[0])].append(newcity)
  for i in range(N):
    prefs[i].sort(key = lambda x: x.time)
  	for j in range(len(prefs[i])):
      prefs[i][j].sort_res = j+1
  for i in prefs:
    for j in i:
      cities.append(i)
  cities.sort(key = lambda x:x.index)
  for i in cities:
    print(i.get_id())
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())

if S > W:
    print('safe')
else:
    print('unsafe')

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A = N
S = []
for i in range(N):
    S += [input()]
for j in range (1, N):
    for k in range(j):
        if S[k] == S[j]:
            A -= 1
            break
print(A)
Problem p02701 (python)

Fixed submission:
N = int(input())
S = [input() for _ in range(N)]
print(len(set(S)))

Buggy submission (verdict: Runtime Error):
3
apple
orange
apple
Problem p02711 (python)

Fixed submission:
import math
N = int(input())
if N%10 == 7:
  print("Yes")
elif (N-N%10)%100 == 70:
  print("Yes")
elif N-N%100 == 700:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = input()
X = 0
for i in range(3):
    if A [i] == 7:
        X += 1
if X == 0:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
if N%10 == 7:
  print(Yes)
elif (N-N%10)%100 == 70:
  print(Yes)
elif N/100 == 7:
  print(Yes)
else:
  print(No)
Problem p02766 (python)

Fixed submission:
import math
N,K = map(int,input().split())

for i in range(int(math.log2(N)+1)):
    if N >= pow(K,i) and N < pow(K,i+1):
        print(i+1)
        exit()

Buggy submission (verdict: Runtime Error):
import math
N,K = map(int,input().split())

for i in range(int(math.log2(N)+1)):
    if N >= pow(K,i) and N < pow(K,i+1):
        print(i+1)
        exit()
Problem p02777 (python)

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

if u == s:
  print((a-1),b)
else:
  print(a,(b-1))

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

if u == s:
  print((a-1),b)
else:
  print(a,(b-1))
Problem p03104 (python)

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

def calc(x): #[0, x]
    if x == 0: return 0
    res = 0
    x += 1
    for i in range(64):
        length = 2**i
        cycle = 2**(i+1)
        num = (x // cycle) * length
        if (x % cycle) > length: num += x % cycle - length
        if num%2: res += 2**i
    return res
'''
def calc2(x):
    res = 0
    for i in range(x+1): res ^= i
    return res

for i in range(100):
    a, b = calc(i), calc2(i)
    assert a == b ,f'i={i}, a={a}, b={b}'
'''

ans = calc(B) ^ calc(A-1)
print(ans)

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

def calc(x): #[0, x]
    if x == 0: return 0
    res = 0
    x += 1
    for i in range(64):
        length = 2**i
        cycle = 2**(i+1)
        num = (x // cycle) * length
        if (x % cycle) > length: num += x % cycle - length
        if num%2: res += 2**i
    return res

def calc2(x):
    res = 0
    for i in range(x+1): res ^= i
    return res

for i in range(100):
    a, b = calc(i), calc2(i)
    assert a == b ,f'i={i}, a={a}, b={b}'

ans = calc(B) ^ calc(A-1)
print(ans)