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

Fixed submission:
h,w=map(int,input().split())
L=[list(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        if L[i][j]=='#':
            if L[i][max(j-1,0)]!='#' and L[i][min(j+1,w-1)]!='#' and L[max(i-1,0)][j]!='#' and L[min(i+1,h-1)][j]!='#':
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
L=[list(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        if L[i][j]=='#':
            if L[i][max(i-1,0)]!='#' and L[i][min(i+1,w-1)]!='#' and L[max(i-1,0)][j]!='#' and L[min(i+1,h-1)][j]!='#':
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
L=[list(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        if L[i][j]=='#':
            if L[i][max(i-1,0)]!='#' and L[i][min(i+1,w-1)]!='#' and L[max(i-1,0)][j]!='#' and L[min(i+1,h-1)][i]!='#':
                print('No')
                exit()
print('Yes')
Problem p03721 (python)

Fixed submission:
n,k=map(int,input().split())
A=[]
for i in range(n):
    a=list(map(int,input().split()))
    A.append(a)
S=sorted(A,key=lambda x:x[0])
i=0

while i<n:
    a=S[i][1]
    if k<=a:
        print(S[i][0])
        exit()
    else:
        k-=S[i][1]
        i+=1

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=[]
for i in range(n):
    a=list(map(int,input().split()))
    A.append(a)
S=sorted(A,key=lambda,x:x[0])
i=0
while k>0:
    k-=A[i][1]
    i+=1
print(A[i][0])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=[]
for i in range(n):
    a=list(map(int,input().split()))
    A.append(a)
S=sorted(A,key=lambda,x:x[0])
i=0
while k>0:
    k-=a[i][1]
    i+=1
print(a[i][0])
Problem p03796 (python)

Fixed submission:
n=int(input())
r=1
for i in range(1,n+1):
    r=r*i%(10**9+7)
print(r)

Buggy submission (verdict: Runtime Error):
def t(n):
    if n==1:
        return 1
    return n*t(n-1)
print(t(int(input()))%(10**9+7))

Buggy submission (verdict: Runtime Error):
def t(n):
    if n==1:
        return 1
    return n*t(n-1)
print(t(int(input())))
Problem p03828 (python)

Fixed submission:
from collections import Counter

def prime_factrization(n):
    a=[]
    for i in range(2,int(n**0.5)+1):
        while n%i==0:
            n//=i
            a.append(i)
    if a==[]:
        a.append(n)
    else:
        if n!=1:
            a.append(n)
    return a
    
n=int(input())
if n==1:
    print(1%1000000007)
else:
    L=[]
    for i in range(2,n+1):
        L+=prime_factrization(i)
    LC=Counter(L)
    r=1
    for v in LC.values():
        r*=(v+1)
    print(r%1000000007)

Buggy submission (verdict: Runtime Error):
def prime_factrization(n):
    a=[]
    for i in range(2,int(n**0.5)+1):
        while n%i==0:
            n//=i
            a.append(i)
    if a==[]:
        a.append(n)
    else:
        if n!=1:
            a.append(n)
    return a
    
n=int(input())
if n==1:
    print(1%(10**9+7))
else:
    L=[]
    for i in range(2,n+1):
        L+=prime_factrization(i)
    LC=Counter(L)
    r=1
    for v in LC.values():
        r*=(v+1)
    print(r%(10**9+7))
Problem p03836 (python)

Fixed submission:
sx,sy,tx,ty=map(int,input().split())
dx,dy=tx-sx,ty-sy
print('U'*dy+'R'*dx+'D'*dy+'L'*dx+'L'+'U'*(dy+1)+'R'*(dx+1)+'D'+'R'+'D'*(dy+1)+'L'*(dx+1)+'U')

Buggy submission (verdict: Runtime Error):
sx,sy=map(int,input().split())
tx,ty=map(int,input().split())
dx,dy=tx-sx,ty-sy
print('U'*dy+'R'*dx+'D'*dy+'L'*dx+'L'+'U'*(dy+1)+'R'*(dx+1)+'D'+'R'+'D'*(dy+1)+'L'*(dx+1)+'U')
Problem p03846 (python)

Fixed submission:
n=int(input())
A=sorted((map(int,input().split())))
G=sorted([2*(i+1) for i in range(n//2)]*2+[0])
K=sorted([(2*i+1) for i in range(n//2)]*2)
if n%2:
	if A!=G:
		print(0)
		exit()
else:
	if A!=K:
		print(0)
		exit()
print(2**(n//2)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n=int(input())
A=sorted((map(int,input().split())))
G=sorted([2*(i+1) for i in range(n//2)]*2+[0])
K=sorted([(2*i+1) for i in range(n//2)]*2)
if n%2:
	if A!=G:
		print(0)
		exit()
else:
	if A!=K:
		print(0)
		exit()
print(2**(n//2)%(10**9+7)
Problem p02600 (python)

Fixed submission:

M = int(input())

if(M>=400 and M<600):
    print("8")
elif(M>=600 and M<800):
    print("7")
elif(M>=800 and M<1000):
    print("6")
elif(M>=1000 and M<1200):
    print("5")
elif(M>=1200 and M<1400):
    print("4")
elif(M>=1400 and M<1600):
    print("3")
elif(M>=1600 and M<1800):
    print("2")
elif(M>=1800 and M<2000):
    print("1")

Buggy submission (verdict: Runtime Error):
n, k = (int(x) for x in input().split())
a = input().split()

for i in range(1,n-k+1):
    if(int(a[i-1]) >= int(a[k+i-1])):
        print("No")
    else:
        print("Yes")
Problem p02612 (python)

Fixed submission:
n = int(input())
if(n%1000==0):
    print(0)
else:
    x = n//1000
    print((x+1)*1000-n)

Buggy submission (verdict: Runtime Error):
n = input()
x = n//1000
print(n-x*1000)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
N = int(input())
arr = []
temp = N
n = 0
if N == 1:
    print(0)
else:
    for i in range(2, int(-(-N**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt=cnt+1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])

    for i in range(len(arr)):
        a = 0
        b = arr[i]
        while a < b[1]:
            a = a+a+1
            n = n+1
    print(n)
Problem p02642 (python)

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

a.sort()
if a[0] == 1:
    if len(a) == 1 or a[1] != 1:
        print(1)
    else:
        print(0)
else:
    a_max = a[-1]
    seive = [True for _ in range(a_max + 1)]
    a += [-1]
    ret = 0
    add = 1
    for i in range(n):
        if a[i] != a[i+1]:
            if seive[a[i]]:
                ret += add
                j = 2 * a[i]
                while j <= a_max:
                    seive[j] = False
                    j += a[i]
            add = 1
        else:
            add = 0
    print(ret)

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

a.sort()
if a[0] == 1:
    if a[1] != 1:
        print(1)
    else:
        print(0)
else:
    cnt = 1
    b = []
    for i in range(n-1):
        if a[i] != a[i+1]:
            b.append([a[i], cnt])
            cnt = 1
        else:
            cnt += 1
    b.append([a[n-1], cnt])

    ret = 0
    d_lst = []
    for c in b:
        num, cnt = c
        for d in d_lst:
            if num % d == 0:
                break
        else:
            if cnt == 1:
                ret += 1
            d_lst.append(num)

    print(ret)
Problem p02690 (python)

Fixed submission:
#!/usr/bin/env python

def main():
    x = int(input())
    for i in range(1000):
        for j in range(0, i+1):
            y = i ** 5 - j ** 5
            z = i ** 5 + j ** 5
            if x == y:
                a = i
                b = j
                break
            elif x == z:
                a = i
                b = -j
                break
    print(a, b)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

def main():
    x = int(input())
    for i in range(100):
        for j in range(0, i+1):
            y = i ** 5 - j ** 5
            z = i ** 5 + j ** 5
            if x == y:
                a = i
                b = j
                break
            elif x == z:
                a = i
                b = -j
                break
    print(a, b)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

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

    fact = factorization(x)
    fact = [[1]] + fact
    chk = 1
    for q in fact:
        p = q[0]
        a = p
        b = 0
        y = p ** 5
        while y <= x:
            y = a ** 5 - b ** 5
            if x == y:
                ret_a, ret_b = a, b
                chk = 0
                break
            a += 1
            b += 1
        if chk == 0:
            break

        a = p
        b = 0
        while a >= b:
            z = a ** 5 + b ** 5
            if x == z:
                ret_a, ret_b = a, -b
                chk = 0
                break
            a -= 1
            b += 1
        if chk == 0:
            break

    print(ret_a, ret_b)

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

Fixed submission:
#!/usr/bin/env python

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a_sort = sorted(a)

    ball_dict = {}
    count = 1
    for i in range(1, n):
        if a_sort[i] == a_sort[i - 1]:
            count += 1
        else:
            ball_dict.setdefault(a_sort[i - 1], count)
            count = 1
    ball_dict.setdefault(a_sort[n - 1], count)

    ans = 0
    for v in ball_dict.values():
        ans += v * (v - 1) // 2

    ans_dict = {}
    for v in ball_dict.values():
        if v not in ans_dict:
            ans_dict.setdefault(v, ans - (v - 1))

    for i in range(n):
        print(ans_dict[ball_dict[a[i]]])

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a_sort = sorted(a)

    ball_dict = {}
    count = 1
    for i in range(1, n):
        if a_sort[i] == a_sort[i - 1]:
            count += 1
        else:
            ball_dict.setdefault(a_sort[i - 1], count)
            count = 1
    ball_dict.setdefault(a_sort[n - 1], count)

    ans = 0
    for v in ball_dict.values():
        ans += v * (v - 1) // 2

    ans_dict = {}
    for v in ball_dict.values():
        if v not in ans_dict.values():
            ans_dict.setdefault(v, ans - (v - 1))

    for i in range(n):
        print(ans_dict[ball_dict[a[i]]])

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a_sort = sorted(a)

    ball_dict = {a[0]:1}
    for i in range(1, n):
        if a_sort[i] == a_sort[i - 1]:
            ball_dict[a_sort[i]] += 1
        else:
            ball_dict.setdefault(a_sort[i], 1)

    for i in range(n):
        new_dict = ball_dict.copy()
        new_dict[a[i]] -= 1
        ans = 0
        for v in new_dict.values():
            ans += v * (v - 1) // 2
        print(ans)

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

Fixed submission:
#!/usr/bin/env python

def main():
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    ret = 0
    magni = 1
    for j in range(60):
        bin_cnt = [0, 0]
        for i in range(n):
            a[i], b = divmod(a[i], 2)
            bin_cnt[b] += 1
        x, y = bin_cnt
        ret += x * y * magni % mod
        magni = magni * 2 % mod

    ret %= mod

    print(ret)


if __name__ == '__main__':
    main()

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

n = int(input())
a = np.array(list(map(int, input().split())))

def xor_(x, y):
    p, q = tuple(sorted([x, y]))
    p = np.array(list(bin(p)))
    q = np.array(list(bin(q)))

    i = -1
    r = str()
    while p[i] != 'b':
        if p[i] == q[i]:
            r = '0' + r
        else:
            r = '1' + r
        i -= 1

    while q[i] != 'b':
        r = q[i] + r
        i -= 1
    
    r = '0b' + r

    return(int(r, 0))

sum = 0
for i in range(n-1):
    for j in range(i+1, n):
        sum += xor_(a[i], a[j])
        sum = sum % (10**9 + 7)

print(sum)
Problem p02882 (python)

Fixed submission:
import math
a,b,V = map(int, input().split())

if V == a*a*b:
    print(0)
else:    
    if V >= a * a * b / 2:
        theta = math.atan( a**3 / (2 * (a**2 * b - V)) )

    else:
        theta = math.atan(2 * V / (a * b**2))

    print(90 - theta * 180 / math.pi)

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

if V >= a * a * b / 2:
    theta = math.atan( a**3 / (2 * (a**2 * b - V)) )

else:
    theta = math.atan(2 * V / (a * b**2))

print(90 - theta * 180 / math.pi)
Problem p02885 (python)

Fixed submission:
A,B = map(int, input().split())
C = A - B * 2
if C<0:
  print(0)  
else:
  print(C)

Buggy submission (verdict: Runtime Error):
A,B = map(int, input().sprit())
C = A - B * 2
if C<0:
  print(0)  
else:
  print(C)

Buggy submission (verdict: Runtime Error):
A,B = map(int, input().sprit())
C = A - B * 2
if C<0:
  print(0)  
else:
  print(C)
Problem p02886 (python)

Fixed submission:
N = int(input())
d = list(map(int,input().split()))
sum = 0
for i in range(N):
  for j in range(i+1,N):
    sum += d[i] * d[j]
    
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
d = list(map(int(input().split())))
sum = 0
for i in range(N):
  for j in range(i+1,N):
    sum += d[i] * d[j]
    
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
d = list(map(int(input().sprit())))
sum = 0
for i in range(N):
  for j in range(i+1,N):
    sum += d[i] * d[j]
    
print(sum)
Problem p02898 (python)

Fixed submission:
NK = list(map(int,input().split()))
h_list = list(map(int,input().split()))

counter = 0

for i in range(NK[0]):
    if h_list[i] >= NK[1]:
        counter += 1

print(counter)

Buggy submission (verdict: Runtime Error):
N = int(input())
K = int(input())

counter = 0
for i in range(N):
    h = int(input())
    if h >= K:
        counter += 1

print(counter)

Buggy submission (verdict: Runtime Error):
N = int(input())
K = int(input())

counter = 0
for i in range(N):
    h = int(input())
    if h >= K:
        counter += 1

print(counter)
Problem p03796 (python)

Fixed submission:
N = int(input())
power = 1
for i in range(N):
  power = power*(i+1) % (10**9+7)
  
print(power)

Buggy submission (verdict: Runtime Error):
N = int(input())

N = int(input())
power = 1
for i in range(N):
  power = power*(i+1) % (10**9+7)
  
print(power)

Buggy submission (verdict: Runtime Error):
N = int(input())

N = int(input())
power = 1
for i in range(N):
  power = power*(i+1)
  if power > 10**9+7:
    power = power % (10**9+7)
  
print(power)

Buggy submission (verdict: Runtime Error):
N = int(input())

N = int(input())
power = 1
for i in range(N):
  power = power*(i+1)%(10**9+7)
  
print(power)
Problem p02802 (python)

Fixed submission:
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000001
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
n,m = arrIN()

d = defaultdict(list)

for i in range(m):
    a,b = input().split()
    d[int(a)].append(b)
ca = pe = 0
for i in range(1,n+1):
    if "AC" in d[i]:
        ca+=1
        pe+=d[i].index("AC")
print(ca,pe)

Buggy submission (verdict: Runtime Error):
from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000001
MOD = 10**9+7
spf = [i for i in range(MAXN)]
spf[0]=spf[1] = -1
def sieve():
    for i in range(2,MAXN,2):
        spf[i] = 2
    for i in range(3,int(MAXN**0.5)+1):
        if spf[i]==i:
            for j in range(i*i,MAXN,i):
                if spf[j]==j:
                    spf[j]=i
def fib(n,m):
    if n == 0:
        return [0, 1]
    else:
        a, b = fib(n // 2)
        c = ((a%m) * ((b%m) * 2 - (a%m)))%m
        d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m
        if n % 2 == 0:
            return [c, d]
        else:
            return [d, c + d]

def charIN(x= ' '):
    return(sys.stdin.readline().strip().split(x))

def arrIN(x = ' '):
    return list(map(int,sys.stdin.readline().strip().split(x)))

def ncr(n,r):
    num=den=1
    for i in range(r):
        num = (num*(n-i))%MOD
        den = (den*(i+1))%MOD

    return (num*(pow(den,MOD-2,MOD)))%MOD

def flush():
    return sys.stdout.flush()

'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''
n,m = arrIN()

d = defaultdict(list)

for i in range(m):
    a,b = input().split()
    d[int(a)].append(b)
ca = pe = 0
for i in range(1,n+1):
    if "AC" in d[i]:
        ca+=1
        pe+=d[i].index("AC")
print(ca,de)
Problem p03501 (python)

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

print(a*n if a*n < b else b)

Buggy submission (verdict: Runtime Error):
n = input()
digitSum = 0
for digit in n:
    digitSum += int(digit)

print("Yes" if int(n) % digitSum == 0 else "No")
Problem p02585 (python)

Fixed submission:
from itertools import accumulate 
#acumulate [a[0], a[0]+a[1], a[0]+...]
 
n, k = map(int, input().split())
p = [int(x) - 1 for x in input().split()]
c = list(map(int, input().split()))
ans = -(10 ** 18)
 
for i in range(n):
    pos = i
    scores = []
    while True:
        pos = p[pos]
        scores.append(c[pos])
        if pos == i:
            break
    m = len(scores)
    s = list(accumulate(scores))
    for j in range(min(m, k)):
        x = (k - j - 1) // m
        ans = max(ans, s[j], s[j] + s[-1] * x)
 
print(ans)

Buggy submission (verdict: Runtime Error):
p = [int(x) - 1 for x in input().split()]
c = list(map(int, input().split()))
ans = -(10 ** 18)
 
for i in range(n):
    pos = i
    scores = []
    while True:
        pos = p[pos]
        scores.append(c[pos])
        if pos == i:
            break
    m = len(scores)
    s = list(accumulate(scores))
    for j in range(min(m, k)):
        x = (k - j - 1) // m
        ans = max(ans, s[j], s[j] + s[-1] * x)
 
print(ans)
Problem p02717 (python)

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

d = c
c = b 
b = a
a = d
 
print(a,b,c)

Buggy submission (verdict: Runtime Error):
n,k = map(int, input().split())
print(abs(n-k) % k)

# if n % k == 0:
#   print(0)
#   exit()

# min = 10**18

# while True:
#   n = abs(n-k)
#   if min > n:
#     min = n
#   else:
#     break

# print(min)

Buggy submission (verdict: Runtime Error):
a = input().int()
b = input().int()
c = input().int()

d = c
c = b 
b = d
d = a

print(a)
print(b)
print(c)
Problem p02720 (python)

Fixed submission:
import queue

k = int(input())
q = queue.Queue()
for i in range(1,10):
  q.put(i)

n = 0
while True:
  val = q.get()
  n += 1
  if n == k:
    print(val)
    break

  if val % 10 != 0:
    q.put(10 * val + (val % 10) - 1)
  q.put(10 * val + (val % 10))
  if val % 10 != 9:
    q.put(10 * val + (val % 10) + 1)

Buggy submission (verdict: Runtime Error):
mport queue

k = int(input())
q = queue.Queue()
for i in range(1,9):
  q.put(i)

n = 0
while True:
  val = q.get()
  if val % 10 != 0:
    q.put(10 * val + (val % 10) - 1)
  q.put(10 * val + (val % 10))
  if val % 10 != 9:
    q.put(10 * val + (val % 10) + 1)
  
  n += 1
  if n == k:
    print(val)
    break
Problem p02609 (python)

Fixed submission:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    x = input()
    k = int(x,2)
    c = x.count('1')
    kp = k%(c+1)
    if c > 1:
        kn = k%(c-1)
    
    for i in range(n):
        cnt = 1
        if x[i] == '1':
            if c == 1:
                print(0)
                continue
            mod = c-1
            tmp = (kn - pow(2,n-i-1,mod))%mod
            while 1:
                if tmp == 0:
                    break
                tmp = tmp%format(tmp, 'b').count('1')
                cnt+=1
        else:
            mod = c+1
            tmp = (kp + pow(2,n-i-1,mod))%mod
            while 1:
                if tmp == 0:
                    break
                tmp = tmp%format(tmp, 'b').count('1')
                cnt+=1
        print(cnt)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    x = input()
    k = int(x,2)
    c = x.count('1')
    kp = k%(c+1)
    if c > 1:
        kn = k%(c-1)
    
    for i in range(n):
        cnt = 1
        if x[i] == '1':
            if c == 1:
                print(0)
                continue
            mod = c-1
            tmp = (kn - pow(2,n-i-1,mod))%mod
            while 1:
                if tmp == 0:
                    print(cnt)
                    break
                tmp = tmp%format(tmp, 'b').count('1')
                cnt+=1
        else:
            mod = c+1
            tmp = (kn + pow(2,n-i-1,mod))%mod
            while 1:
                if tmp == 0:
                    print(cnt)
                    break
                tmp = tmp%format(tmp, 'b').count('1')
                cnt+=1
            


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

Fixed submission:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    a = int(input())
    ans = 0
    for i in range(3):
        ans += a**(i+1)
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    a = int(input())
    for i in range(3):
        ans += a**(i+1)
    print(ans)


if __name__ == '__main__':
    main()