Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
X = list(map(int,input().split()))
res = 10**10
for i in range(N-K+1):
    if X[i]*X[i+K-1] >= 0:
        res = min(res,max(abs(X[i+K-1],X[i])))
    else:
        res = min(res,abs(X[i])*2+X[i+K-1],X[i+K-1]*2+abs(X[i]))
print(res)

Fixed submission:
n,k = map(int,input().split())
X = list(map(int,input().split()))
S = []
for i in range(n-k+1):
	if X[i]*X[i+k-1] < 0:
		S.append(X[i+k-1]-X[i]+min(abs(X[i+k-1]),abs(X[i])))
	else:
		S.append(max(abs(X[i+k-1]),abs(X[i])))
print(min(S))
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
A = [int(i)%m for i in input().split()]  
S = [0]*n
S[0] = A[0]
for i in range(n):
	S[i] = (S[i-1]+A[i])%m
D = dict()
for s in S:
	if s in D:D[s] += 1
	else:D[s] = 1
res = D[0]
for v in D.values():
	res += v*(v-1)//2
print(res)

Fixed submission:
from collections import Counter
n,m = map(int,input().split())
A = list(map(int,input().split()))
B = [0]
for a in A:
    B.append((B[-1]+a)%m)
D = Counter(B)
res = 0
for v in D.values():
    res += v*(v-1)//2
print(res)

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
A = [int(i)%m for i in input().split()]  
S = [0]*n
S[0] = A[0]
for i in range(n):
	S[i] = (S[i-1]+A[i])%m
D = dict()
for s in S:
	if s in D:D[s] += 1
	else:D[s] = 1
res = D[0]
for v in D.values():
	res += v*(v-1)//2
print(res)

Fixed submission:
from collections import Counter
n,m = map(int,input().split())
A = list(map(int,input().split()))
B = [0]
for a in A:
    B.append((B[-1]+a)%m)
D = Counter(B)
res = 0
for v in D.values():
    res += v*(v-1)//2
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

ans = []
for i in range(n-1):
    w = s[:i].count('W')
    e = s[i+1:].count('E')
    ans.append(w+e)

ans.append(s[:n].count('W'))

print(min(ans))

Fixed submission:
n = int(input())
S = input()

e = S.count('E')
w = 0
ans = e
for s in S:
    if s == 'E':
        e -= 1
    else:
        w += 1
    ans = min(ans,e+w)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
k = int(input())
A = set(S[0])
for i in range(len(S)):
	for j in range(len(S)-i+1):
		A.add(S[j:j+i+1])
A = list(A)
A.sort()
print(A[k])

Fixed submission:
S = input()
k = int(input())
A = set()
for l in range(k+1):
	for i in range(len(S)-l):
			A.add(S[i:i+l+1])
A = sorted(list(A))
print(A[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
from itertools import combinations

n = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)

def comb(n,r):
    return factorial(n)//(factorial(n-r) * factorial(r))

res = []
for i in A[1:]:
    res.append([comb(A[0],i),A[0],i])

res.sort(reverse=True)

print(res[0][1],res[0][2])

Fixed submission:
n = int(input())
A = sorted(list(map(int,input().split())),reverse=True)
k = 10**10
for i in range(1,n):
    k = min(k,abs(A[0]/2 -A[i]))
    if k == abs(A[0]/2 -A[i]):
        ans = [A[0],A[i]]
print(ans[0],ans[1])

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
from itertools import combinations

n = int(input())
A = tuple(map(int,input().split())) 

def comb(n,r):
    return factorial(n)//(factorial(n-r) * factorial(r))

res = []
for a,b in combinations(A,2):
    if a < b:
        a,b = b,a
    res.append([comb(a,b),a,b])

res.sort(reverse=True)
print(res[0][1],res[0][2])



Fixed submission:
n = int(input())
A = sorted(list(map(int,input().split())),reverse=True)
k = 10**10
for i in range(1,n):
    k = min(k,abs(A[0]/2 -A[i]))
    if k == abs(A[0]/2 -A[i]):
        ans = [A[0],A[i]]
print(ans[0],ans[1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

h,w,d = map(int,input().split())
A = [list(map(int,input().split())) for i in range(h)]
q = int(input())
for i in range(q):
    l,r = map(int,input().split())
    res = 0
    for s in range(h):
        for t in range(w):
            if A[s][t] == l:
                y1 = s
                x1 = t
    while l != r:
        l += d
        for hh in range(h):
            for ww in range(w):
                if A[hh][ww] == l:
                    y2 = hh
                    x2 = ww
        res += abs(x2-x1)+abs(y2-y1)
        y1 = y2
        x1 = x2
    print(res)
        

Fixed submission:
H,W,D = map(int,input().split())
A = [list(map(int,input().split())) for i in range(H)]
d = [[0,0,0] for _ in range(H*W+2)]
for h in range(H):
    for w in range(W):
        d[A[h][w]+1] = [h+1,w+1,0]
d = d[2:]
for i in range(H*W):
    if i < D:
        continue
    d[i][2] = d[i-D][2]+abs(d[i][0]-d[i-D][0])+abs(d[i][1]-d[i-D][1])
q = int(input())
for i in range(q):
    l,r = map(int,input().split())
    print(d[r-1][2]-d[l-1][2])
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse=True)
A_card = []
B_card = []
for i in range(n):
        if i%2 == 0:
                A_card.append(A[i])
        else:
                B_card.append(A[i])
print(sum(A_card) - sum(B_card))

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

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = sorted(list(map(int,input().split())))
A_card = []
B_card = []
for i in range(n):
        if i%2 == 0:
                A_card.append(A[i])
        else:
                B_card.append(A[i])
print(sum(A_card) - sum(B_card))

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

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
A = sorted(A)
Alice_card = []
Bob_card = []
for i in range(n):
        if i%2 == 0:
                Alice_card.append(A[i])
        else:
                Bob_card.append(A[i])
Alice_total = sum(Alice_card)
Bob_total = sum(Bob_card)
print(abs(Alice_total - Bob_total))

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

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
Alice_card = []
Bob_card = []
for i in range(n):
        if i%2 == 0:
                Alice_card.append(A[i])
        else:
                Bob_card.append(A[i])
Alice_total = sum(Alice_card)
Bob_total = sum(Bob_card)
print(abs(Alice_total - Bob_total))

Fixed submission:
n = int(input()) % 500
a = int(input())
if a >= n:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                count += 1 
print(count)

Fixed submission:
x = int(input()) 
a = int(input())
b = int(input())
print((x-a)%b)
Buggy python submission (verdict: Runtime Error):
n = int(input())
D = [input() for i in range(n)]
print(len(set(D)))

Fixed submission:
print(input().replace('2017','2018'))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
CSF = [list(map(int,input().split())) for i in range(n-1)]

for i in range(n-1):
	time = CSF[i][1]+CSF[i][0]
	for j in range(i+1,n-1):
		while (time-CSF[j][1])%CSF[j][2] != 0 or time-CSF[j][1]<0:
			time += 1
		time += CSF[j][0]
	print(time)
print(0)

Fixed submission:
from math import ceil

n = int(input())
CSF = [list(map(int,input().split())) for i in range(n-1)]

for i in range(n-1):
	time = CSF[i][1]+CSF[i][0]
	for j in range(i+1,n-1):
		if (time-CSF[j][1])%CSF[j][2] != 0 or time-CSF[j][1]<0:
			time = max(CSF[j][1],CSF[j][2]*(ceil(time/CSF[j][2])))
		time += CSF[j][0]
	print(time)
print(0)
Buggy python submission (verdict: Runtime Error):
n,a,b =  map(int,input().split())
ans = 0
for i in range(n+1):
        good_num = 0
        for j in str(i) :
                good_num += int(j)
        if a <= good_num <= b:
                ans += i
print(ans)

Fixed submission:
a,b,c,d = map(int,input().split())
if a+b > c+d:
    print('Left')
elif a+b == c+d:
    print('Balanced')
else:
    print('Right')
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))

c = 0
while all (a%2==0 for a in A):
    A = list(a//2 for a in A)
    c += 1
print(c)

Fixed submission:
print(input().count('1'))
Buggy python submission (verdict: Runtime Error):
s = input()
if s == "KIHBR" or s == "AKIHBR" or s == "KIHABR" or s == "KIHBAR" or s == "KIHBRA" or s == "AKIHABR" or s == "AKIHBAR"or s == "AKIHBRA"or s == "KIHABAR"or s == "KIHABRA"or s == "KIHBARA"or s == "AKIHABAR"or s == "AKIHABRA"or s == "AKIHBARA"or s == "KIHABARA"or s == "AKIHABARA":
    print("YWS")
else:
    print("NO)

Fixed submission:
s = input()
if s == "KIHBR" or s == "AKIHBR" or s == "KIHABR" or s == "KIHBAR" or s == "KIHBRA" or s == "AKIHABR" or s == "AKIHBAR"or s == "AKIHBRA"or s == "KIHABAR"or s == "KIHABRA"or s == "KIHBARA"or s == "AKIHABAR"or s == "AKIHABRA"or s == "AKIHBARA"or s == "KIHABARA"or s == "AKIHABARA":
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
for a in range(1,3501):
    for b in range(1,3501):
        if 4*a*b-n*a-n*b == 0:
            continue
        if 1 <= n*a*b//(4*a*b-n*(a+b)) <= 3500 and (n*a*b)%(4*a*b-n*a-n*b) == 0:
            print(a,b,n*a*b//(4*a*b-n*(a+b)))
            exit()

Fixed submission:
n = int(input())
for a in range(1,3501):
    for b in range(1,3501):
        if 4*a*b-n*a-n*b == 0:
            continue
        if 1 <= n*a*b//(4*a*b-n*(a+b)) <= 3500 and (n*a*b)%(4*a*b-n*a-n*b) == 0:
            print(a,b,n*a*b//(4*a*b-n*(a+b)))
            exit()
Buggy python submission (verdict: Runtime Error):
A,B,C,D,E,F = map(int,input().split())

W = set()
for i in range(0,F+1,100*A):
    for j in range(0,F+1-i,100*B):
        W.add(i+j)
        
S = set()
for i in range(0,F+1,C):
    for j in range(0,F+1-i,D):
        S.add(i+j)

rate = 0
for w in W:
    for s in S:
        if 0 < w+s <= F and s/(w+s) <= E/(E+100):
            if s/(w+s) > rate:
                rate= s/(w+s)
                res1,res2 = w+s,s
                
print(res1,res2)

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

W = set()
for i in range(0,F+1,100*A):
    for j in range(0,F+1-i,100*B):
        W.add(i+j)
        
S = set()
for i in range(0,F+1,C):
    for j in range(0,F+1-i,D):
        S.add(i+j)

rate = 0
for w in W:
    for s in S:
        if 0 < w+s <= F and s/(w+s) <= E/(E+100):
            if s/(w+s) >= rate:
                rate= s/(w+s)
                res1,res2 = w+s,s
                
print(res1,res2)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().spilt())
print((n-1)*(m-1))

Fixed submission:
n,m = map(int,input().split())
print((n-1)*(m-1))
Buggy python submission (verdict: Runtime Error):
n = int(input())
A =list(map(int,input().split()))
num4 = 0
num2 = 0
num1 = 0
for a in A:
    if a%4 == 0:
        nu+= 1
    elif a%2 == 0:
        num2 += 1
    else:
        num1 += 1

if num2 == 0:
    if num4 >= num1-1:
        print("Yes")
    else:
        print("No")
else:
    if num4 >= num1:
        print("Yes")
    else:
        print("No") 

Fixed submission:
n = int(input())
A =list(map(int,input().split()))
num4 = 0
num2 = 0
num1 = 0
for a in A:
    if a%4 == 0:
        num4 += 1
    elif a%2 == 0:
        num2 += 1
    else:
        num1 += 1

if num2 == 0:
    if num4 >= num1-1:
        print("Yes")
    else:
        print("No")
else:
    if num4 >= num1:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())

s = [0]*n
g = [0]*n

for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        s[b] = 1
    if b == n:
        g[a] = 1
for i in range(n):
    if s[i] and g[i]:
    print("POSSIBLE")
    exit()

print("IMPOSSIBLE")

Fixed submission:
n,m = map(int,input().split())
route = [0]*(n+10)
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        route[b] += 1
    if b == n:
        route[a] += 1
if 2 in route:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
First = []
Second = []
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        First.append(b)
    if b == n:
        Second.append(a)
for i in range(1,n+1):
    if i in First and i in Second:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")


Fixed submission:
n,m = map(int,input().split())
route = [0]*(n+10)
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        route[b] += 1
    if b == n:
        route[a] += 1
if 2 in route:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
First = []
Second = []
for i in range(m):
    ab = [int(j) for j in input().split()]
    if ab[0] == 1:
        First.append(ab)
    if ab[1] == n:
        Second.append(ab)
if any (i[1]==j[0] for i in First for j in Second):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Fixed submission:
n,m = map(int,input().split())
route = [0]*(n+10)
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        route[b] += 1
    if b == n:
        route[a] += 1
if 2 in route:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
int main(){
    int n, k;
    cin >> n >> k;
    int l[100];
    rep(i, n) cin >> l[i];
    sort(l, l + n, greater<int>());
    int res = 0;
    rep(i, k) res += l[i];
    cout << res << endl;
}

Fixed submission:
n,k = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x)
ans = 0
for i in range(k):
    ans += x[-i-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
3
a
aa
b

Fixed submission:
n = int(input())
S = [list(input()) for i in range(n)]
X = "qwertyuiopasdfghjklzxcvbnm"
ans = []
for i in range(26):
	res = []
	for s in S:
		res.append(s.count(X[i]))
	for j in range(min(res)):
		ans.append(X[i])
ans.sort()
print("".join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
p = 1
for i in range(1,int(input())+1):
    p *= i
print(p%(10**9+7))

Fixed submission:
p = 1
for i in range(1,int(input())+1):
    p *= i
    p %= 10**9+7
print(p)
Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int,input().split())
c = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z==s:
                c += 1
print(c)

Fixed submission:
k,s = map(int,input().split())
c = 0
for x in range(k+1):
    for y in range(k+1):
        if 0<=s-x-y<=k:
                c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
input()
t = list(map(int,input().split()))
m = int(input())
for i in range(m):
    p,x = map(int,input().split())
    print(sum(t)-t[p-1]+x)

Fixed submission:
a,x,b = input().split()
if x == '+':
    print(int(a)+int(b))
else:
    print(int(a)-int(b))
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x = map(int,input().split())
c = 0
for i in range(a,b+1):
    if i%x == 0:
        c += 1
print(c)

Fixed submission:
a,b,x = map(int,input().split())
if a%x != 0:
    print(b//x-a//x)
else:
    print(b//x-a//x+1)
Buggy python submission (verdict: Time Limit Exceeded):
n,v = map(int,input().split())
X = list(map(int,input().split()))

ans = [[0,0]] 

for i in range(n):
    ans2 = []
    for x in ans:
        ans2.append([x[0]+X[i],x[1]+1])
        ans2.append([x[0],x[1]])
    ans = ans2

cnt = 0
for a in ans:
    if a[1] == 0:
        continue
    elif a[0]/a[1] == v:
        cnt += 1

print(cnt)


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

X = [int(i)-a for i in input().split()]
dp = [[0]*(100*n+1) for i in range(n+1)]
dp[0][50*n] = 1

for i in range(n):
    for j in range(50,100*n+1-50):
        dp[i+1][j] = dp[i][j]+dp[i][j-X[i]]

print(dp[n][50*n]-1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(-100,101):
    c = 0
    for a in A:
        c += abs((i-a)**2)
    ans.append(c)

print(min(c))

Fixed submission:
n = int(input())
print(n*(n+1)//2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(-100,101):
    c = 0
    for a in A:
        c += (i-a)**2
    ans.append(c)

print(min(min))

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
ave1 = sum(A)//n
ave2 = ave1+1
ans1 = 0
ans2 = 0
for a in A:
    ans1 += (a-ave1)**2
    ans2 += (a-ave2)**2
print(min(ans1,ans2))

Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(-100,101):
    c = 0
    for a in A:
        c += (i-a)**2
    ans.append(c)

print(min(c))

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
ave1 = sum(A)//n
ave2 = ave1+1
ans1 = 0
ans2 = 0
for a in A:
    ans1 += (a-ave1)**2
    ans2 += (a-ave2)**2
print(min(ans1,ans2))
Buggy python submission (verdict: Runtime Error):
a,b = map(int(input().split()))
if a <= 0 <= b:
    print('Zero')
elif b < 0 and b%2 == a%2:
    print('Negative')
else:
    print("Positive")

Fixed submission:
a,b = map(int,input().split())
if a <= 0 <= b:
        print("Zero")

elif b < 0 and (b-a)%2 == 0:
        print("Negative")
else:
        print("Positive")
Buggy python submission (verdict: Runtime Error):
a = input()
ans = 0
if a >= 105:
    ans+=1
if a >= 135:
    ans+=1
if a >= 165:
    ans+=1
if a >= 189:
    ans+=1
if a >= 195:
    ans+=1
print(ans)

Fixed submission:
a = int(input())
ans = 0
if a >= 105:
    ans+=1
if a >= 135:
    ans+=1
if a >= 165:
    ans+=1
if a >= 189:
    ans+=1
if a >= 195:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
def get_ints():
    return map(int, input().split())

n, m = get_ints()
penalty = 0
oks = 0
ac = []
for i in range(n):
    ac.append(False)
for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if ac[p]:
        continue
    if s == 'AC':
        ac[p] = True
        oks += 1
    else:
        penalty += 1

print(f'{oks} {penalty}')


Fixed submission:
def get_ints():
    return map(int, input().split())

n, m = get_ints()
penalty = 0
oks = 0
ac = []
penalty = []
for i in range(n):
    ac.append(False)
    penalty.append(0)
for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if ac[p]:
        continue
    if s == 'AC':
        ac[p] = True
        oks += 1
    else:
        penalty[p] += 1

ans = 0
for i in range(n):
    if ac[i]:
        ans += penalty[i]

print(str(oks) + ' ' + str(ans))
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def get_ints():
    return list(map(int, input().split()))

[n, m] = get_ints()
a = get_ints()

l = reduce(lambda n, m: n * m // math.gcd(n, m), map(lambda x: x // 2, a))
t = m // l
print(t // 2 if t % 2 == 0 else t // 2 + 1)


Fixed submission:
from fractions import gcd
from functools import reduce

def get_ints():
    return list(map(int, input().split()))

[n, m] = get_ints()
a = get_ints()

def small_lcm(x, y):
    if x is None or y is None:
        return None
    ans = x * y // gcd(x, y)
    return ans if ans <= m else None

def count_div2(a):
    ans = 0
    while a % 2 == 0:
        ans += 1
        a //= 2
    return ans

cds = list(map(count_div2, a))
for v in cds:
    if v != cds[0]:
        print(0)
        exit(0)

l = reduce(small_lcm, map(lambda x: x // 2, a))
if l is None:
    print(0)
    exit(0)
t = m // l
print(t // 2 if t % 2 == 0 else t // 2 + 1)
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = 2 * n - 1

if x == 1 or x == l:
    print('No')
    exit(0)

ans = list(map(lambda k: (k - n + x) % l + 1, range(l)))
ans[n - 3], ans[n + 1] = ans[n + 1], ans[n - 3]
print('Yes')
print(' '.join(map(str, ans)))


Fixed submission:
n, x = map(int, input().split())
l = 2 * n - 1

if x == 1 or x == l:
    print('No')
    exit(0)

if n == 2:
    print('Yes\n1\n2\n3')
    exit(0)

ans = list(map(lambda k: (k - n + x) % l + 1, range(l)))
ans[n - 3], ans[n + 1] = ans[n + 1], ans[n - 3]
print('Yes')
for v in ans:
    print(v)
Buggy python submission (verdict: Runtime Error):

n , k = map(int,input().strip().split())
if k == 2:
    n = bin(n)[2:]
    print(len(n))
elif k==8:
    n = oct(n)[2:]
    print(len(n))
elif k == 3:
    n = np.base_repr(n, base=3)
    print(len(n))
elif k == 4:
    n = np.base_repr(n, base=4)
    print(len(n))
elif k == 5:
    n = np.base_repr(n, base=5)
    print(len(n))
elif k == 6:
    n = np.base_repr(n, base=6)
    print(len(n))
elif k == 7:
    n = np.base_repr(n, base=7)
    print(len(n))
elif k == 9:
    n = np.base_repr(n, base=9)
    print(len(n))

else:
    print(len(n))

Fixed submission:
import numpy as np
n , k = map(int,input().strip().split())
n = np.base_repr(n, base=k)
print(len(n))

Buggy python submission (verdict: Runtime Error):
import numpy as np
n , k = map(int,input().strip().split())
if k == 2:
    n = bin(n)[2:]
    print(len(n))
elif k==8:
    n = oct(n)[2:]
    print(len(n))
elif k == 3:
    n = np.base_repr(n, base=3)
    print(len(n))
elif k == 4:
    n = np.base_repr(n, base=4)
    print(len(n))
elif k == 5:
    n = np.base_repr(n, base=5)
    print(len(n))
elif k == 6:
    n = np.base_repr(n, base=6)
    print(len(n))
elif k == 7:
    n = np.base_repr(n, base=7)
    print(len(n))
elif k == 9:
    n = np.base_repr(n, base=9)
    print(len(n))

else:
    print(len(n))

Fixed submission:
import numpy as np
n , k = map(int,input().strip().split())
n = np.base_repr(n, base=k)
print(len(n))

Buggy python submission (verdict: Runtime Error):
import numpy as np
n , k = map(int,input().strip().split())
if k == 2:
    n = bin(n)[2:]
    print(len(n))
elif k==8:
    n = oct(n)[2:]
    print(len(n))
elif k == 3:
    n = np.base_repr(n, base=3)
    print(len(n))
elif k == 10:
    print(len(n))

Fixed submission:
import numpy as np
n , k = map(int,input().strip().split())
n = np.base_repr(n, base=k)
print(len(n))
Buggy python submission (verdict: Runtime Error):
from math import gcd
MOD = 10**9 + 7
H, W, T = map(int, input().split())
ga, gb = gcd(H, T), gcd(W, T)
H //= ga
W //= gb
ans = (pow(2, H, MOD) + pow(2, W, MOD) - 1 + pow(2, gcd(H, W)) - 2) % MOD
print(pow(ans, ga*gb, MOD))


Fixed submission:
from fractions import gcd
MOD = 10**9 + 7
H, W, T = map(int, input().split())
ga, gb = gcd(H, T), gcd(W, T)
H //= ga
W //= gb
ans = (pow(2, H, MOD) + pow(2, W, MOD) - 1 + pow(2, gcd(H, W)) - 2) % MOD
print(pow(ans, ga*gb, MOD))

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
MOD = 10**9 + 7
H, W, T = map(int, input().split())
ga, gb = gcd(H, T), gcd(W, T)
H //= ga
W //= gb
ans = (pow(2, H, MOD) + pow(2, W, MOD) - 1 + pow(2, gcd(H, W)) - 2) % MOD
print(pow(ans, ga*gb, MOD))


Fixed submission:
from fractions import gcd
MOD = 10**9 + 7
H, W, T = map(int, input().split())
ga, gb = gcd(H, T), gcd(W, T)
H //= ga
W //= gb
ans = (pow(2, H, MOD) + pow(2, W, MOD) - 1 + pow(2, gcd(H, W)) - 2) % MOD
print(pow(ans, ga*gb, MOD))

Buggy python submission (verdict: Runtime Error):
from math import gcd
MOD = 10**9 + 7
H, W, T = map(int, input().split())
ga, gb = gcd(H, T), gcd(W, T)
H //= ga
W //= gb
ans = pow(2, H, MOD) + pow(2, W, MOD) - 1 + pow(2, gcd(H, W)) - 2
print(pow(ans, ga*gb, MOD))


Fixed submission:
from fractions import gcd
MOD = 10**9 + 7
H, W, T = map(int, input().split())
ga, gb = gcd(H, T), gcd(W, T)
H //= ga
W //= gb
ans = (pow(2, H, MOD) + pow(2, W, MOD) - 1 + pow(2, gcd(H, W)) - 2) % MOD
print(pow(ans, ga*gb, MOD))