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

Fixed submission:
N,M = list(map(int,input().split()))
S = list(map(int,input().split()))
S = [0] + S
T = list(map(int,input().split()))
T = [0] + T
dp = [[0] * (N+1)  for _ in range(M+1)]
DP = [[0] * (N+1)  for _ in range(M+1)]
dp[0][0] = 1
for n in range(N+1):
    DP[0][n] = 1
for m in range(M+1):
    DP[m][0] = 1
# s = 0
# for i in range(N+1):
#     for j in range(M+1):
#         if S[i] == T[j]:
#             for i2 in range(i):
#                 for j2 in range(j):
#                     dp[i][j] += dp[i2][j2]
#             s += dp[i][j]
# print(s)
for n in range(1,N+1):
    for m in range(1,M+1):
        if S[n] == T[m]:
            dp[m][n] = DP[m-1][n-1]
        DP[m][n] = (DP[m-1][n] + DP[m][n-1] + dp[m][n] - DP[m-1][n-1]) % (10**9+7)
print(DP[M][N])

Buggy submission (verdict: Runtime Error):
import sys
N,M = list(map(int,sys.stdin.readline().split()))
S = list(map(int,sys.stdin.readline()split()))
S = [0] + S
T = list(map(int,sys.stdin.readline()split()))
T = [0] + T
DP = [[0] * (N+1)  for _ in range(M+1)]
for n in range(N+1):
    DP[0][n] = 1
for m in range(M+1):
    DP[m][0] = 1
# s = 0
# for i in range(N+1):
#     for j in range(M+1):
#         if S[i] == T[j]:
#             for i2 in range(i):
#                 for j2 in range(j):
#                     dp[i][j] += dp[i2][j2]
#             s += dp[i][j]
# print(s)
mod = 10**9 + 7
for n in range(1,N+1):
    for m in range(1,M+1):
        num = DP[m-1][n-1] if S[n] == T[m] else 0
        DP[m][n] = (DP[m-1][n] + DP[m][n-1] + num - DP[m-1][n-1]) % mod
print(DP[M][N])
Problem p03013 (python)

Fixed submission:
#coding:utf-8
#dp[i]:i段目に登るまでの組み合わせ総数
#dp[i] = dp[i-1] + dp[i-2] if dp[i] != B[i] else 0
N,M = list(map(int,input().split()))
B = [True] * N

for _ in range(M):
    B[int(input())-1] = False
dp = [0] * N
if B[0]:
    dp[0] = 1
if N >= 2 and B[1]:
    dp[1] = dp[0] + 1 
mod = 10**9 + 7
for i in range(2,N):
    if B[i] :
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[-1])

Buggy submission (verdict: Runtime Error):
#coding:utf-8
#dp[i]:i段目に登るまでの組み合わせ総数
#dp[i] = dp[i-1] + dp[i-2] if dp[i] != B[i] else 0
N,M = list(map(int,input().split()))
B = [True] * N
try:
    for _ in range(M):
        B[int(input())-1] = False
except:
    print(0)
    import sys
    sys.exit(1)
dp = [0] * N
if B[0]:
    dp[0] = 1
dp[1] = dp[0] + 1 if B[1] else 0
mod = 10**9 + 7
for i in range(2,N):
    if B[i] :
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[-1])

Buggy submission (verdict: Runtime Error):
#coding:utf-8
#dp[i]:i段目に登るまでの組み合わせ総数
#dp[i] = dp[i-1] + dp[i-2] if dp[i] != B[i] else 0
N,M = list(map(int,input().split()))
B = [True] * N
for _ in range(M):
    B[int(input())-1] = False
dp = [0] * N
dp[0] = 1 if B[0] else 0
dp[1] = dp[0] + 1 if B[1] else 0
mod = 10**9 + 7
for i in range(2,N):
    if B[i] :
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[-1])

Buggy submission (verdict: Runtime Error):
#coding:utf-8
#dp[i]:i段目に登るまでの組み合わせ総数
#dp[i] = dp[i-1] + dp[i-2] if dp[i] != B[i] else 0
N,M = list(map(int,input().split()))
B = [True] * N
for _ in range(M):
    B[int(input())-1] = False
dp = [0] * N
dp[0] = 1 if B[0] else 0
dp[1] = dp[0] + 1 if B[1] else 0
mod = 10**9 + 7
for i in range(2,N):
    if B[i] :
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
print(dp[-1])
Problem p03104 (python)

Fixed submission:
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from math import gcd, ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    A,B = LMIIS()
    if A & 1:
        if B & 1:
            #A, (A+1 A+2).....(B-1,B)
            print(A^(B-A)//2%2)
        else:
            #A, (A+1 A+2).....(B-2,B-1),B
            print(A^((B-A-1)//2%2)^B)
    else:
        if B & 1:
            #(A, A+1).....(B-1,B)
            print((B-A+1)//2%2)
        else:
            #(A, A+1).....(B-2,B-1),B
            print((B-A)//2%2^B)



    

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#coding:utf-8
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True

def main():
    A,B = LMIIS()
    #001 - 010 - 011 - 100 - 101 - 110 -> 111 diff 101
    #000 - 001 - 010 - 011 - 100 - 101 -> 001 diff 101
    # 0 0 1
    # 0 1 1
    # 1 0 0 
    # 1 1 0

    # 00
    # 01 
    # 10
    # 11

    Abin = []
    Bbin = []

    diff = abs(A-B)
    Atmp = A
    while Atmp:
        Abin.append(Atmp % 2)
        Atmp //= 2

    Btmp = B
    while Btmp:
        Bbin.append(Btmp % 2)
        Btmp //= 2
    
    Abin += [0] * (len(Bbin) - len(Abin))
    Bbin += [0] * (len(Abin) - len(Bbin))
    
        
    
    
    #print(Abin,Bbin)

    ans = [0] * len(Abin)
    ans[0] = Abin[0]
    tmp = A
    j = 1

    # 0桁目
    if diff % 2 == 1:
        ans[0] = 1
    if diff // 2 % 2 == 1:
        ans[0] ^= 1   

    # 2**i桁目
    for i in range(1,len(Abin)):
        # 周期：2**(i+1)
        for _ in range(diff % 2**(i+1) - j + 1):
            tmp ^= A+j
            j += 1
        ans[i] = tmp // 2 ** i % 2
    
    v = 0
    for i in range(len(ans)-1,-1,-1):
        v *= 2
        v += ans[i]
    print(v)

    # print('gutyoku')
    # r = A
    # for i in range(A+1,B+1):
    #     r ^= i
    # print(r)
    







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

Fixed submission:
#coding:utf-8
N  = int(input())
A = list(map(int,input().split()))
def c(A,B):
    for a,b in zip(A,B):
        if a != b:
            return False
    return True
while True:
    A.sort()
    prev = A[:]
    
    s = A[0]
    for i in range(N):
        if A[i] % s == 0:
            A[i] = s
        else:
            A[i] = A[i] % s
    A.sort()
    #print("A  :",A)
    #print("pre:",prev)
    if  c(prev,A) : break
#print("A  :",A)
#print("pre:",prev)
print(A[0])

Buggy submission (verdict: Runtime Error):
#coding:utf-8
N  = int(input())
A = list(map(int,input().split()))
def c(A,B):
    for a,b in zip(A,B):
        if a != b:
            return False
    return True
while True:
    A.sort()
    prev = A[:]
    
    s = A[0]
    for i in range(N):
        if A[i] % s == 0:
            A[i] = s
        else:
            A[i] = A[i] % s
    A.sort()
    #print("A  :",A)
    #print("pre:",prev)
    if  c(prev,A) : break
#print("A  :",A)
#print("pre:",prev)
print(A[0])
#coding:utf-8
N  = int(input())
A = list(map(int,input().split()))
def c(A,B):
    for a,b in zip(A,B):
        if a != b:
            return False
    return True
while True:
    A.sort()
    prev = A[:]
    
    s = A[0]
    for i in range(N):
        if A[i] % s == 0:
            A[i] = s
        else:
            A[i] = A[i] % s
    A.sort()

    if  prev==A : break

print(A[0])
Problem p03286 (python)

Fixed submission:
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7


    N = II()
    if N == 0:
        print(0)
        return
    ans_stack = deque()
    determined = 0
    for i in range(100):
        if (N - determined) % 2 ** (i+1) != 0:
            ans_stack.append(1)
            determined += (-2) ** i
        else:
            ans_stack.append(0)
        if determined == N:
            break
    ans_str = ''
    while len(ans_stack) > 0:
        item = ans_stack.pop()
        ans_str += str(item)
    print(ans_str)
    '''
    1 -2 4 -8 16 -32 64 -128
    '''
            
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    from math import log2, ceil
    N = II()
    if N == 0:
        print(0)
        return
    ans_stack = deque()
    determined = 0
    for i in range(100):
        if (N - determined) % 2 ** (i+1) != 0:
            ans_stack.append(1)
            determined += (-2) ** i
        else:
            ans_stack.append(0)
        if determined == N:
            break
    ans_str = ''
    while len(ans_stack) > 0:
        item = ans_stack.pop()
        ans_str += str(item)
    print(ans_str)
    '''
    1 -2 4 -8 16 -32 64 -128
    '''
            
if __name__ == '__main__':
    main()
Problem p03724 (python)

Fixed submission:
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7
    N,M = map(int,input().split())
    count_list = [0]*(N+1)
    for _ in range(M):
        a,b = map(int,input().split())
        count_list[a] += 1
        count_list[b] += 1
    for c in count_list:
        if c% 2 == 1:
            print('NO')
            return
    print('YES')
    return

    

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
わからん
Problem p02546 (python)

Fixed submission:
S=list(input())
if S[len(S)-1]=="s":
  S.append("es")
else:
  S.append("s")
s="".join(S)
print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
import math
ans = 0
for a in range(1, n):
  ans += math.floor((n - 1) / a)
print(ans)
Problem p02552 (python)

Fixed submission:
x=int(input())
if x==0:
  print("1")
else:
  print("0")

Buggy submission (verdict: Runtime Error):
d,t,s=map(int,input().split())
if s*t >= d:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = int(input())
#最後に切った場所がiであるようなパターンの数をdp[i]とする
dp=[0]*(s+1)
dp[0]=1
if s<3:
  print("0")
for i in range(3,s+1):
  dp[i]=dp[i-1]+dp[i-3]
  dp.append(dp[i])
  score=dp[s]%(10**9+7)
print(score)
Problem p02570 (python)

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

if D/S > T:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
d,t,s=int(input())
if S*t >= d:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S=input()
T=input()
tlen = len(T)


for i in range(tlen, 1):
    for k in range(0, tlen+1-i):
        Tinclude = T[k:i]
        print(tlen-i)
        break
Problem p02571 (python)

Fixed submission:
S = input()
T = input()
 
Nmax = len(T)
for i in range(len(S)-len(T)+1):
    diff = 0
    for j in range(len(T)):
        if(S[i+j] != T[j]):
            diff += 1
 
    Nmax = min(diff, Nmax)
 
print(Nmax)

Buggy submission (verdict: Runtime Error):
S=input()
T=input()

for i in range(0,len(S)-len(T)+1):
  score=0
  for j in range(0,len(T)):
    if(S[i] != T[i+j]):
      score += 1
  score = min(score, len(T))
print(score)
Problem p02577 (python)

Fixed submission:
N=int(input())
n= str(N)
total=0
for i in range(len(n)):
  k = n[i]
  k = int(k)
  total += k
  
if total%9==0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
Ls = list(map(int,input().split()))
score=0
for i in range(0,N-2):
  a = Ls[i]
  for j in range(i+1, N-1):
      b = Ls[j]
      for k in range(j+1, N):
        c = Ls[k]
        if ((a+b>c)&(a+c>b)&(b+c>a)&(a!=b)&(a!=c)&(b!=c)):
          score+=1
          L_list=[i,j,k]
          print(L_list)
print(score)
Problem p02546 (python)

Fixed submission:
s = input()

if s[len(s)-1] == 's':
    print(s+'es')
else:
    print(s+'s')

Buggy submission (verdict: Runtime Error):
s = input()

if s[len(s)] == 's':
    print(s+'es')
else:
    print(s+'s')
Problem p02570 (python)

Fixed submission:
d,t,s = map(int, input().split())

if d/t<=s:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
ruijimax = 0

for first in range(len(S)-len(T)):
    ruiji = 0
    for i in range(len(T)):
        if S[first+i] == T[i]:
            ruiji += 1
    if ruijimax <= ruiji:
        ruijimax = ruiji

print(len(T)-ruijimax)
Problem p02792 (python)

Fixed submission:
n = int(input())
c = [[0] * 10 for _ in range(10)]
ans = 0
for i in range(1, n + 1):
    l = int(str(i)[0])
    r = i % 10
    c[l][r] += 1
for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
n = int(input())
a = list(map(int, input().split()))
l = a[0]
for i in range(1, n): l = l // fractions.gcd(l, a[i]) * a[i]
print(sum([l // a[i] for i in range(n)]) % 1000000007)
Problem p02915 (python)

Fixed submission:
print(int(input())**3)

Buggy submission (verdict: Runtime Error):
print(int(input()**3))
Problem p03634 (python)

Fixed submission:
from collections import deque
n = int(input())
G = [deque([]) for _ in range(n)]
for i in range(n - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append([b, c])
    G[b].append([a, c])
dist = [-1] * n

def dfs(v):
    cnt = 0
    stack = [[v, 0]]
    while stack:
        x = stack[-1]
        if len(G[x[0]]) > 0:
            w = G[x[0]].popleft()
            if dist[w[0]] == -1:
                dist[w[0]] = w[1] + dist[x[0]]
                stack.append(w)
        else: stack.pop()

q, k = map(int, input().split())
k -= 1
dist[k] = 0
dfs(k)
for i in range(q):
    x, y = map(int, input().split())
    print(dist[x - 1] + dist[y - 1])
#print(dist)

Buggy submission (verdict: Runtime Error):
n = int(input())
G = [[] for _ in range(n)] 
for i in range(n - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    G[a].append([b, c])
    G[b].append([a, c])

vis = [False] * n
d = [-1] * n
def dfs(k, depth):
    vis[k] = True
    d[k] = depth
    for i in G[k]: # i: [to, cost]
        if not vis[i[0]]: dfs(i[0], depth + i[1])

q, k = map(int, input().split())
dfs(k - 1, 0)

for i in range(q):
    x, y = map(int, input().split())
    print(d[x - 1] + d[y - 1])
Problem p02596 (python)

Fixed submission:
# AFTER CONTEST


def solve(n):
    if n % 7 == 0:
        n //= 7

    if n % 2 == 0 or n % 5 == 0:
        return -1

    # Since R(k) = 1...1 = (10^k - 1) / 9, we have
    #   n | R(k)
    #   <=> 10^k = 1 ∈ Z_9n
    n9 = n * 9
    d = 10 % n9
    for i in range(n9):
        if d == 1:
            return i + 1
        d = (10 * d) % n9
    raise RuntimeError()


def main(istr, ostr):
    (k,) = list(map(int, istr.readline().strip().split()))
    result = solve(k)
    print(result, file=ostr)


if __name__ == "__main__":
    import sys

    main(sys.stdin, sys.stdout)

Buggy submission (verdict: Runtime Error):
# AFTER CONTEST

def solve(k):
    if k % 7 == 0:
        k //= 7

    if k % 2 == 0 or k % 5 == 0:
        return -1

    # Min i s.t. k | R(i)
    # by pigeonhole, there exists such i <= k
    r = 1
    for i in range(1, k + 1):
        if r == 0:
            return i
        r = (1 + 10 * r) % k
    raise RuntimeError()


def main(istr, ostr):
    k, = list(map(int, istr.readline().strip().split()))
    result = solve(k)
    print(result, file=ostr)


if __name__ == "__main__":
    import sys

    main(sys.stdin, sys.stdout)
Problem p03137 (python)

Fixed submission:
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()

difX = []
for i in range(len(X)-1):
    difX.append(X[i+1]-X[i])
difX.sort(reverse=True)

if M > N:

    difX = difX[N-1:]

    total = 0
    for x in difX:
        total+= x

    print(total)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()

difX = []
for i in range(len(X)-1):
    difX.append(X[i+1]-X[i])


for i in range(N-1):
    difX.pop(difX.index(max(difX)))

total = 0
for x in difX:
    total+= x

print(total)
Problem p02570 (python)

Fixed submission:
d, t, s = map(int, input().split())

if t * s >= d:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
d=input()
t=input()
s=input()

    
    if (s*t >= d):
        print ('Yes')
    
    else:
        print ('No')

Buggy submission (verdict: Runtime Error):
d=int(input())
t=int(input())
s=int(input())


if (s*t) >= d :
    print ('Yes')
    
else:
    print ('No')
Problem p02676 (python)

Fixed submission:
num=int(input()) #ask integer for limitation
s=input() #ask string
if len(s) > num:    #check if the length s exceeded num
    print(s[:num] + "...")  #print s with the limit "num"
else:   #if the string not exceeded num
    print(s)

Buggy submission (verdict: Runtime Error):
#input an interget
K=int(input())
#input an string
S=str(input())
#get the length of the string
x=int(len(str1))
#get the difference in length between k and s
i=x-k

#make a second string for the appending
S2="..."

#if statement about how the string will function
#if the string is the same length as k then print it
if i==0:
    print(S)
#if not, delete the last character of the string
else:
    while i>0:
        S=S[i]
        i+=1
#and then join the two strings together
    newstr="".join((S,S2))
    print(newstr)

Buggy submission (verdict: Runtime Error):

while True:
     k = input()
     if 1 <= int(k) <= 100:
         break;
     print ('Error Invalid Input for K')


while True:
     s = input().lower()
     if 1 <= len(s) <= 100:
         break;
     print ('Error Invalid Input for s')


if len(s) > k:
    print(s[:k] + "...")
else:
    print(s)

Buggy submission (verdict: Runtime Error):
def convert(S): 
  
    
    str1 = ""  # initialization of string to "" 
    return(str1.join(S))    # using join function join the list s by  
                            # separating words by str1


K = int(input())    # take K from user
readtext= str(input())  # take the input string 

S = list(readtext)   #split the string into charactrers and put them to list
list1=[]  #list 1 

for i in range (0 , K): # for looop to append the charachters to the new list
   
    list1.append(S[i]) # appending the charachters to the list
if len(S) > K:  # condition when number of charachters is big than K
    b = "..."
    list1.append(b) # append the 3 dots 

print(convert(list1)) # convert the list of characters back to the string format
Problem p02693 (python)

Fixed submission:
from sys import stdin, stdout
import math
import bisect
import queue

k = int(stdin.readline().strip())
a, b = map(int, stdin.readline().strip().split())

flag = 0

for i in range(a, b + 1):
    if i % k == 0:
        flag = 1
        break

stdout.writelines('OK\n' if flag == 1 else 'NG\n')

Buggy submission (verdict: Runtime Error):
K = int(input())
A = int(input())
B = int(input())
i = A
while A <= i <= B :
    if str(K) in str(i) :
        print("OK")
        break
    i = i + 1
else :
    print("NG")
Problem p02707 (python)

Fixed submission:
# In peace, in love, in war, everything is the same

import math

deg = [0] * 200005
n=int(input())
ar = list(map(int, input().split()))

for i in range(n-1):
    deg[ar[i]] = deg[ar[i]] + 1

for i in range(1, n+1, 1):
    print(deg[i])

Buggy submission (verdict: Runtime Error):
# In peace, in love, in war, everything is the same

import math

deg = [0] * 100005
n=int(input())
ar = list(map(int, input().split()))

for i in range(n-1):
    deg[ar[i]] = deg[ar[i]] + 1

for i in range(1, n+1, 1):
    print(deg[i])
Problem p02754 (python)

Fixed submission:
def count_balls(n, a, b):
    if(a==0): return 0
    if(n<a): return n
    end = n % (a+b)
    if(end > a):
        return a*(n//(a+b))+a
    else:
        return a*(n//(a+b))+end
n,a,b=map(int, input().strip().split())
print(count_balls(n,a,b))

Buggy submission (verdict: Runtime Error):
n=input()
i=0
a=input()
b=input()
c=0
while True:
    for j in range(a):
        if i >= n:break
        i+=1
        c+=1
    for j in range(b):
        i+=1
    if i > n:break
print(c)

Buggy submission (verdict: Runtime Error):
s = input()
s = s.split(" ")
n = int(s[0])
b = int(s[1])
a = int(s[2])

num = (n //(a+b))*b +(n%(a+b))%a
print(num)
Problem p02762 (python)

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

fa = [x for x in range (n + 1)]
siz = [1 for i in range (n + 1)]
dep = [0 for i in range (n + 1)]
e = [1 for i in range (n + 1)]

def find (x) :
    if (fa[x] == x) :
        return x
    fa[x] = find (fa[x])
    return fa[x]

def uni (x, y) :
    u, v = find (x), find (y)
    if (dep[u] >= dep[v]) :
        fa[v] = u
        if (u != v) :
            siz[u] += siz[v]
        if (dep[u] == dep[v]) :
            dep[u] += 1
    else :
        fa[u] = v
        if (u != v) :
            siz[v] += siz[u]

for i in range (m) :
    a, b = list (map (int, input ().split ()))
    uni (a, b)
    e[a] += 1
    e[b] += 1

for i in range (1, n + 1) :
    siz[i] = siz[find (i)]

for i in range (k) :
    c, d = list (map (int, input ().split ()))
    if (find (c) == find (d)) :
        siz[c] -= 1
        siz[d] -= 1

siz = [siz[i] - e[i] for i in range (1, n + 1)]

print (' '.join (list (map (str, siz))))

Buggy submission (verdict: Runtime Error):
def find (x) : 
    fa[x] = x if fa[x] == x else find (fa[x])
    return fa[x]

def union (x, y) :
    fa[find (x)] = find (y)
    
N, M, K = list (map (int, input().split()))

fa = [x for x in range (N + 1)]
ans = [-1 for i in range (N + 1)]
siz = [0 for i in range (N + 1)]

for i in range (M) :
    a, b = list (map (int, input().split()))
    union (a, b)
    ans[a] -= 1
    ans[b] -= 1
    
for i in range (1, N + 1) :
    siz[find(i)] += 1

for i in range (1, N + 1) :
    ans[i] += siz[find (i)]

for i in range (K) :
    c, d = list (map (int, input().split()))
    if (find (c) == find (d)) :
        ans[c] -= 1
        ans[d] -= 1

print (' '.join (list (map(str , ans[1 : N + 1]))))

Buggy submission (verdict: Runtime Error):
fa = [x for x in range (100002)]
ans = [-1 for i in range (100002)]
siz = [0 for i in range (100002)]
rank = [0 for i in range (100002)]


def find (x) : # find the highest ancestor of x
    fa[x] = x if fa[x] == x else find (fa[x])
    return fa[x]

def union (x, y) :
    fa[find (x)] = find (y)
    

N, M, K = list (map (int, input().split()))

for i in range (M) :
    a, b = list (map (int, input().split()))
    union (a, b)
    ans[a] -= 1
    ans[b] -= 1
    
# TODO : .... build ans[]
for i in range (1, N + 1) :
    siz[find(i)] += 1

for i in range (1, N + 1) :
    ans[i] += siz[find (i)]

# TODO : eliminate blockships
for i in range (K) :
    c, d = list (map (int, input().split()))
    if (find (c) == find (d)) :
        ans[c] -= 1
        ans[d] -= 1

print (' '.join (list (map(str , ans[1 : N + 1]))))
Problem p02766 (python)

Fixed submission:
import math

n, k = map(int, input().split())
print(math.floor(math.log(n, k) + 1))

Buggy submission (verdict: Runtime Error):
import math
number = int(input())
base = int(input())
converted=0
reminder=0
i=0
counter=0
while number!=0:
    reminder=number%base
    number=number//base
    converted=converted+reminder*10**i
    i+=1


#To convert integer into string
y=str(converted)
print(len(y))