Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
_,*a=map(int,open(0).read().split())
a=[i for i in a if a.count(i)==1]
a.sort()
b=0
while a:
    b+=1
    a=[i for i in a[1:] if i%a[0]!=0]
print(b)

Fixed submission:
N  = int(input())
c = list(map(int,input().split()))

c.sort()
a = c[N-1]
list_c = [0]*(a+1)
for i in c:
  mal = 2
  b = i
  while i<=a:
    list_c[i]+=1
    i = b*mal
    mal+=1
count = 0
for i in c:
  if list_c[i]==1:
    count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
c=list(map(int, input().split()))
c.sort()

count = 0
while count<len(c):
  d = c[count]
  if d in c[count+1:len(c)]:
    s = count
    while d in c:
      c.pop(s)
    continue
  f = 1
  while f<len(c):
    if f == count:
      f+=1
      continue
    if c[f]%c[count]==0:
      c.pop(f)
      continue
    f+=1
  count+=1
print(len(c))


Fixed submission:
N  = int(input())
c = list(map(int,input().split()))

c.sort()
a = c[N-1]
list_c = [0]*(a+1)
for i in c:
  mal = 2
  b = i
  while i<=a:
    list_c[i]+=1
    i = b*mal
    mal+=1
count = 0
for i in c:
  if list_c[i]==1:
    count+=1
print(count)

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

count = 0
while count<len(c):
  for i,b in enumerate(c):
    if i == count:
      continue
      
    print(i,b)
    if b%c[count]==0:
      c.pop(i)
      print(c)
  count+=1

print(c)



    

Fixed submission:
N  = int(input())
c = list(map(int,input().split()))

c.sort()
a = c[N-1]
list_c = [0]*(a+1)
for i in c:
  mal = 2
  b = i
  while i<=a:
    list_c[i]+=1
    i = b*mal
    mal+=1
count = 0
for i in c:
  if list_c[i]==1:
    count+=1
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
c=list(map(int, input().split()))

@jit
def search(N,c):
  count = 0
  for i in range(N):
    b = []
    m = copy.copy(c)
    a = c[i]
    m.pop(i)
    m.sort()
    for j in range(N-1):
      if m[j]>c[i]:
        count+=1
        break
      elif c[i]%m[j]==0:
        break
      elif j == N-2:
        count+=1
      elif c[i]%m[j]!=0:
        continue
      
  return count

print(search(N,c))
      
      
      
     
  
  

Fixed submission:
N  = int(input())
c = list(map(int,input().split()))

c.sort()
a = c[N-1]
list_c = [0]*(a+1)
for i in c:
  mal = 2
  b = i
  while i<=a:
    list_c[i]+=1
    i = b*mal
    mal+=1
count = 0
for i in c:
  if list_c[i]==1:
    count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = input()
if len(list(a)) <=N:
  print(a)
else:
  print(a[0:N]+'...')

Fixed submission:
N = (int(input())%100)%10
if N in [2,4,5,7,9]:
  print('hon')
elif N in [0,1,6,8]:
  print('pon')
else:
  print('bon')
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
a = list(map(int,input().split()))
list_a = []
list_b =[]
list_a.append(1)
count_a = 1
count_b = 0
for i in range(1,K+1):
  if i == 1:
    k = i
  if a[k-1] in list_b:
    break
  elif a[k-1] in list_a:
    list_b.append(a[k-1])
    count_b+=1
  if a[k-1] not in list_a:
    list_a.append(a[k-1])
    count_a+=1
  k = a[k-1]
#print(list_a,list_b,count_a,count_b)
if count_b != 0:
  num_k = K-(count_a-count_b)
  num_k = num_k%count_b
  if 1 in list_b and list_b[0]!=1:
    #list_b.remove(1)
    list_b.insert(0,1)
  print(list_b[num_k])
elif count_b ==0:
  print(list_a[count_a-1])

Fixed submission:
a = list(input())
b = list(input())
flag = True
for i,j in enumerate(a):
  if j !=b[i]:
    print('No')
    flag = False
    break
if flag == True:
  print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
goods = []
count = 0
for i in range(N):
  good = str(input())
  if good not in goods:
    goods.append(good)
    count +=1
    
print(count)

Fixed submission:
N = int(input())
goods = {}
count = 0
for i in range(N):
  good = input()
  goods[good] =1
    
    
print(len(goods))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
goods = []
for i in range(N):
  good = str(input())
  if good not in goods:
    goods.append(good)
    
print(len(goods))

Fixed submission:
N = int(input())
goods = {}
count = 0
for i in range(N):
  good = input()
  goods[good] =1
    
    
print(len(goods))
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,(input().split())))
list_a = [0]*2*100001
for i in a:
  list_a[i] += 1
for i in range(1,N+1):
  print(list_a[i])

Fixed submission:
N = int(input())
print(round(N*2*3.1415,2))
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,(input().split())))
list_a = [0]*2*100000
for i in a:
  list_a[i] += 1
for i in range(1,N+1):
  print(list_a[i])

Fixed submission:
N = int(input())
a = list(map(int,(input().split())))
list_a = [0]*2*100001
for i in a:
  list_a[i] += 1
for i in range(1,N+1):
  print(list_a[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,(input().split())))
for i in range(1,N+1):
  if i not in a:
    print(0)
  else:
    print(a.count(i))

Fixed submission:
N = int(input())
a = list(map(int,(input().split())))
list_a = [0]*2*100001
for i in a:
  list_a[i] += 1
for i in range(1,N+1):
  print(list_a[i])
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce


def gcd_list(numbers):
    return reduce(math.gcd, numbers)
K = int(input())
count = 0 
a = [0,0,0]
for i in range(1,K+1):
  a[0] = i
  for j in range(1,K+1):
    a[1] = j
    for k in range(1,K+1):
      a[2] = k
      count += gcd_list(a)


print(count)

Fixed submission:
from math import gcd
k=int(input())
cnt=0
for i in range(1,k+1):
  for p in range(1,k+1):
    for q in range(1,k+1):
      gcd1=gcd(i,p)
      
      cnt+=gcd(gcd1,q)
 
      
print(cnt)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = [0]*N
b = [None]*N
for i in range(M):
  s,c = map(int,input().split())
  if b[s-1] == c:
    continue
  else:
    a[s-1] +=1
    b[s-1] =c
    
count = 0
for i in range(N):
  if a[i]>=2:
    count=-1
  elif b[0]==0 and N>1:
    count =-1
  elif b[i]==0:
    if i is None:
      if N==1:
        b[i] =0
      else:
        b[i]=1
  elif i>0:
    if b[i] is None:
      b[i]=0
b.reverse()
if count == 0:
  for i in range(N):
    count+=b[i]*10**i
print(count)
    

Fixed submission:
N,M = map(int,input().split())
a = [0]*N
b = [None]*N
for i in range(M):
  s,c = map(int,input().split())
  if b[s-1] == c:
    continue
  else:
    a[s-1] +=1
    b[s-1] =c
    
count = 0
for i in range(N):
  if a[i]>=2:
    count=-1
  elif b[0]==0 and N>1:
    count =-1
  elif i==0:
    if b[i] is None:
      if N==1:
        b[i] =0
      else:
        b[i]=1
  elif i>0:
    if b[i] is None:
      b[i]=0
b.reverse()
if count == 0:
  for i in range(N):
    count+=b[i]*10**i
print(count)

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = [0]*N
b = [None]*N
for i in range(M):
  s,c = map(int,input().split())
  if b[s-1] == c:
    continue
  else:
    a[s-1] +=1
    b[s-1] =c
    
count = 0
for i in range(N):
  if a[i]>=2:
    count=-1
  elif b[0]==0 and N>1:
    count =-1
  elif i==0:
    if i is None:
      if N==1:
        b[i] =0
      else:
        b[i]=1
  elif i>0:
    if b[i] is None:
      b[i]=0
b.reverse()
if count == 0:
  for i in range(N):
    count+=b[i]*10**i
print(count)

Fixed submission:
N,M = map(int,input().split())
a = [0]*N
b = [None]*N
for i in range(M):
  s,c = map(int,input().split())
  if b[s-1] == c:
    continue
  else:
    a[s-1] +=1
    b[s-1] =c
    
count = 0
for i in range(N):
  if a[i]>=2:
    count=-1
  elif b[0]==0 and N>1:
    count =-1
  elif i==0:
    if b[i] is None:
      if N==1:
        b[i] =0
      else:
        b[i]=1
  elif i>0:
    if b[i] is None:
      b[i]=0
b.reverse()
if count == 0:
  for i in range(N):
    count+=b[i]*10**i
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,N = map(int,input().split())
for i in range(N):
  if A>0:
    A-=1
  else:
    if B>0:
      B-=1
print(A,B)

Fixed submission:
A,B,N = map(int,input().split())
if A>=0:
  if N<=A:
    print(A-N,B)
  else:
    N = N-A
    if N<=B:
      print(0,B-N)
    else:
      print(0,0)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))
a_list = []
for i in range(1,200001):
  a_list.append(i)
count=0
for i in a:
  if i==a_list[0]:
    count+=1
    a_list.pop(0)
    
if count==0:
  print(-1)
else:
  print(N-count)

Fixed submission:
from collections import deque
N = int(input())
a = list(map(int,input().split()))
d = deque()
for i in range(1,200001):
  d.append(i)
count=0
for i in a:
  if i==d[0]:
    count+=1
    d.popleft()
    
if count==0:
  print(-1)
else:
  print(N-count)
Buggy python submission (verdict: Runtime Error):
import bisect

n = int(input())
l = sorted(list(map(int, input().split())))

ans = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        ans += bisect.bisect_left(l, l[i]+l[j]) - (j+1)
        #print(l,i,j,bisect.bisect_left(l, l[i]+l[j]))
print(ans)

Fixed submission:
N = int(input())
a = list(input())
count = 1
for i in range(N):
  if i>0:
    if a[i-1]==a[i]:
      pass
    elif a[i-1]!=a[i]:
      count+=1
      
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
for i in range(K):
  A[0] = int(A[0]/2)
  A.sort(reverse=True)

print(sum(A))

Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
import heapq
a = list(map(lambda x: x*(-1), A))  # 各要素を-1倍

heapq.heapify(a)
for i in range(K):
  num = heapq.heappop(a)*(-1)
  heapq.heappush(a, -1*(int(num/2)))
  #print(num,a)
  if num == 0:
    break
print(-sum(a))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = []
c = []
for i in range(N):
    b = list(input())
    a+=b
for i in range(M):
  b = list(input())
  c+=b
#print(c,a)
f = False
for i in range(N*N):
  if f == True:
    break
  if N*N-i<M*M:
    break
  count=0
  flag = True
  #print(i,c[0],a[i])
  if c[0] == a[i]:
    if N-(i%N)<M:
      continue
    num = i
    for j in range(M):
      for k in range(M):
        #print(c[count],a[num])
        if c[count] == a[num]:
          
          num+=1
          count+=1
        elif c[count]!=a[num]:
          flag =False
          break
      num+=N-M
      if flag == False:
        #print(i)
        break  
      if j == M-1:
        f = True
            
  else:
    continue
if f == False:
  print('No')
else:
  print('Yes')
           
    
    

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

if M == N:
  print('Draw')
elif (M>N and N!=1) or M==1:
  print('Alice')
else:
  print('Bob')
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
MOD=998244353
S=[]
for _ in range(K):
    L,R=map(int,input().split())
    S.append((L,R))
dp=[0]*(N+1)
dp[1]=1
for i in range(2,N+1):
    for j in range(K):
        L,R=S[j][0],S[j][1]
        if L>=i:
            continue
        l=max(0,i-R)
        r=min(i-1,i-L)
        dp[i]+=sum(dp[l:r+1])
        dp[i]%=MOD
print(dp[N]%MOD)

Fixed submission:
N,K=map(int,input().split())
MOD=998244353
S=[]
for _ in range(K):
    L,R=map(int,input().split())
    S.append((L,R))
S.sort()
dp=[0]*(N+1)
dp[1]=1
ans=[0]*(K+1)
for i in range(2,N+1):
    for j in range(K):
        L,R=S[j][0],S[j][1]
        if L>=i:
            break
        l=max(0,i-R)
        r=min(i-1,i-L)
        ans[j]+=dp[r]-dp[l-1]
    dp[i]+=sum(ans)
    dp[i]%=MOD
print(dp[N]%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
MOD=998244353
S=[0]*(N+1)
for _ in range(K):
    L,R=map(int,input().split())
    for i in range(L,R+1):
        S[i]=1
dp=[0]*(N+1)
dp[1]=1
for i in range(2,N+1):
    for j in range(i):
        if S[j]==1:
            dp[i]+=dp[i-j]
            dp[i]%=MOD
print(dp[N]%MOD)

Fixed submission:
N,K=map(int,input().split())
MOD=998244353
S=[]
for _ in range(K):
    L,R=map(int,input().split())
    S.append((L,R))
S.sort()
dp=[0]*(N+1)
dp[1]=1
ans=[0]*(K+1)
for i in range(2,N+1):
    for j in range(K):
        L,R=S[j][0],S[j][1]
        if L>=i:
            break
        l=max(0,i-R)
        r=min(i-1,i-L)
        ans[j]+=dp[r]-dp[l-1]
    dp[i]+=sum(ans)
    dp[i]%=MOD
print(dp[N]%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
MOD=998244353
S=[0]*(N+1)
for _ in range(K):
    L,R=map(int,input().split())
    for i in range(L,R+1):
        S[i]=1
dp=[0]*(N+1)
dp[1]=1
for i in range(2,N+1):
    for j in range(i):
        if S[j]==1:
            dp[i]+=dp[i-j]
            dp[j]%=MOD
print(dp[N]%MOD)

Fixed submission:
N,K=map(int,input().split())
MOD=998244353
S=[]
for _ in range(K):
    L,R=map(int,input().split())
    S.append((L,R))
S.sort()
dp=[0]*(N+1)
dp[1]=1
ans=[0]*(K+1)
for i in range(2,N+1):
    for j in range(K):
        L,R=S[j][0],S[j][1]
        if L>=i:
            break
        l=max(0,i-R)
        r=min(i-1,i-L)
        ans[j]+=dp[r]-dp[l-1]
    dp[i]+=sum(ans)
    dp[i]%=MOD
print(dp[N]%MOD)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
ans=0
line=[A[0]]
for i in range(1,N):
    ans+=line.pop(0)
    line.append(A[i])
    line.append(A[i])
print(ans)

Fixed submission:
import heapq
N=int(input())
A=list(map(int,input().split()))
A.sort(reverse=True)
ans=0
line=[]
heapq.heappush(line,-A[0])
for i in range(1,N):
    ans-=heapq.heappop(line)
    heapq.heappush(line,-A[i])
    heapq.heappush(line,-A[i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ans=1
mod=10**18
A.sort()
if A[0]==0:
    print(0)
else:
    for i in A:
        ans*=i
        if ans>mod:
            ans=-1
    print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=1
mod=10**18
for i in A:
    if i==0:
        ans=0
        break
    elif i==1:
        continue
    elif ans!=-1:
        ans=ans*i
        if ans>mod:
            ans=-1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
ans=1
mod=10**18
for i in A:
    ans=ans*i
if ans>mod:
    ans=-1
print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=1
mod=10**18
for i in A:
    if i==0:
        ans=0
        break
    elif i==1:
        continue
    elif ans!=-1:
        ans=ans*i
        if ans>mod:
            ans=-1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,X,Y=map(int,input().split())
ans=[]
for i in range(1,N):
    for j in range(i+1,N+1):
        a=j-i
        a=min(a,abs(j-Y)+abs(i-X)+1)
        ans.append(a)
for i in range(1,N):
    Ans=ans.count(i)
    print(Ans)

Fixed submission:
N,X,Y=map(int,input().split())
ans=[]
count=[0]*(N-1)
for i in range(1,N):
    for j in range(i+1,N+1):
        a=j-i
        a=min(a,abs(j-Y)+abs(i-X)+1)
        count[a-1]+=1
for i in range(0,N-1):
    print(count[i])

Buggy python submission (verdict: Time Limit Exceeded):
N,X,Y=map(int,input().split())
ans=[]
for i in range(1,N):
    for j in range(i+1,N+1):
        if i<=X and j<=X:
            a=j-i
            ans.append(a)
        elif Y<=i and Y<=j:
            a=j-i
            ans.append(a)
        else:
            a=j-i
            a=min(a,abs(j-Y)+abs(i-X)+1)
            ans.append(a)
for i in range(1,N):
    Ans=ans.count(i)
    print(Ans)

Fixed submission:
N,X,Y=map(int,input().split())
ans=[]
count=[0]*(N-1)
for i in range(1,N):
    for j in range(i+1,N+1):
        a=j-i
        a=min(a,abs(j-Y)+abs(i-X)+1)
        count[a-1]+=1
for i in range(0,N-1):
    print(count[i])
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N=int(input())
a=[]
A=list(map(int,input().split()))
c=collections.Counter(A)
d=c.most_common()
ans=0
for i in range(len(d)):
    ans+=d[i][1]*(d[i][1]-1)//2
for i in range(N):
    for j in range(len(d)):
        if A[i]==d[j][0]:
            Ans=ans-(d[j][1]-1)
            break
    print(Ans)

Fixed submission:
import collections
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)
ans=0
for i in c:
    ans+=c[i]*(c[i]-1)//2
for i in range(N):
    a=A[i]
    Ans=ans-c[a]+1
    print(Ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N=int(input())
a=[]
A=list(map(int,input().split()))
c=collections.Counter(A)
d=c.most_common()
Ans=[]
for i in range(N):
    ans=0
    if i>0:
        for l in range(i):
            if A[i]==A[l]:
                ans=Ans[l]
                break
    if ans==0:
        for j in range(len(d)):
            if d[j][0]==A[i]:
                ans+=(d[j][1]-1)*(d[j][1]-2)//2
            else:
                ans+=d[j][1]*(d[j][1]-1)//2
    Ans.append(ans)
for i in range(N):
    print(Ans[i])

Fixed submission:
import collections
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)
ans=0
for i in c:
    ans+=c[i]*(c[i]-1)//2
for i in range(N):
    a=A[i]
    Ans=ans-c[a]+1
    print(Ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N=int(input())
a=[]
A=list(map(int,input().split()))
a=A
c=collections.Counter(a)
d=c.most_common()
for i in range(N):
    ans=0
    for j in range(len(d)):
        if d[j][0]==A[i]:
            ans+=(d[j][1]-1)*(d[j][1]-2)//2
        else:
            ans+=d[j][1]*(d[j][1]-1)//2
    print(ans)

Fixed submission:
import collections
N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)
ans=0
for i in c:
    ans+=c[i]*(c[i]-1)//2
for i in range(N):
    a=A[i]
    Ans=ans-c[a]+1
    print(Ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = 10**9 + 7

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

def pow(a, n, p):
    bi = str(format(n, 'b'))
    res = 1
    for i in range(len(bi)):
        res = (res * res) % p
        if bi[i] == '1':
            res = (res * a) % p
    return res

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, 10**6 + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

if n == 1:
    print(0)
elif n == 2:
    print(2)
else:
    ans = 0
    for i in range(2, n + 1):
        tryvalue = ((pow(2, i, p) - 2)*cmb(n, i, p)*pow(8, n-i, p))
        ans = (ans + tryvalue) % p
    print(ans)


Fixed submission:
n = int(input())
p = 10**9 + 7

def cmb(n, r, p):
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

def pow(a, n, p):
    bi = str(format(n, 'b'))
    res = 1
    for i in range(len(bi)):
        res = (res * res) % p
        if bi[i] == '1':
            res = (res * a) % p
    return res

fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, 10**6 + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

if n == 1:
    print(0)
elif n == 2:
    print(2)
else:
    ans = 0
    powered_2 = pow(2, 1, p)
    for i in range(2, n + 1):
        powered_2 = powered_2 * 2 % p
        tryvalue = ((powered_2 - 2)*cmb(n, i, p)*pow(8, n-i, p))
        ans = (ans + tryvalue) % p
    print(ans)
Buggy python submission (verdict: Runtime Error):
n, x, t = map(int, input().split())
print((n // x + 1) * T)

Fixed submission:
import math

n, x, t = map(int, input().split())
print(math.ceil(n / x) * t)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
l = list(map(int, input().split()))

l_counter = Counter(l)
l_set = sorted(list(l_counter.keys()))

length = len(l_set)
ans = 0
if n < 3:
    print(0)
else:
    for i in range(length - 2):
        for j in range(i + 1, length - 1):
            for k in range(j + 1, length):
                if l_set[k] < l_set[i] + l_set[j]:
                    ans += l_counter[l_set[i]] * l_counter[l_set[j]] * l_counter[l_set[k]]

    print(ans)


Fixed submission:
s = input()
if s.count('R') == 0:
    print(0)
elif s.count('R') == 1:
    print(1)
elif s.count('R') == 2:
    if s[1] == 'R':
        print(2)
    else:
        print(1)
else:
    print(3)
Buggy python submission (verdict: Runtime Error):
x, k, d = map(int, input().split())

pm = x // abs(x)
left = k - (abs(x) // d)

if abs(x) // d > k:
    print(abs(x) - k*d)
else:
    ans_abs = abs(x) % d
    if left % 2 == 0:
        print(ans_abs)
    else:
        print(d - ans_abs)


Fixed submission:
x, k, d = map(int, input().split())

left = k - (abs(x) // d)

if abs(x) // d > k:
    print(abs(x) - k*d)
else:
    ans_abs = abs(x) % d
    if left % 2 == 0:
        print(ans_abs)
    else:
        print(d - ans_abs)
Buggy python submission (verdict: Runtime Error):
from collections import deque

def main():
    n, m = map(int, input().split())
    ans_list = [0]*(n+1)

    class Node:
        def __init__(self, x):
            self.val = x
            self.adj = []

    nodelist = [Node(0)]
    for i in range(1, n+1):
        nodelist.append(Node(i))

    for i in range(m):
        a, b = map(int, input().split())
        nodelist[a].adj.append(b)
        nodelist[b].adj.append(a)

    q = deque()
    q.append(nodelist[1])

    while len(q) > 0:
        node = q.popleft()

        if node is not None:
            for i in node.adj:
                if ans_list[i] == 0:
                    ans_list[i] = node.val
                    q.append(nodelist[i])

    print('Yes')
    for j in range(2, n + 1):
        print(ans_list[j])

if __name__ = '__main__':
    main()          


Fixed submission:
from collections import deque

n, m = map(int, input().split())
ans_list = [0]*(n+1)

class Node:
    def __init__(self, x):
        self.val = x
        self.adj = []

nodelist = [Node(0)]
for i in range(1, n+1):
  nodelist.append(Node(i))

for i in range(m):
    a, b = map(int, input().split())
    nodelist[a].adj.append(b)
    nodelist[b].adj.append(a)

q = deque()
q.append(nodelist[1])

while len(q) > 0:
    node = q.popleft()

    if node is not None:
        for i in node.adj:
            if ans_list[i] == 0:
                ans_list[i] = node.val
                q.append(nodelist[i])

print('Yes')
for j in range(2, n + 1):
    print(ans_list[j])
Buggy python submission (verdict: Time Limit Exceeded):
import math
 
sum = 0
k = int(input())
for a in range(1, k + 1):
  for b in range(1, k + 1):
    for c in range(1, k + 1):
      ab = math.gcd(a, b)
      sum += math.gcd(ab, c)
print(sum)    

Fixed submission:
import math

k = int(input())
list = [0]*201
for b in range(1, k + 1):
    for c in range(1, k + 1):
        list[math.gcd(b, c)] += 1
list_2 = [0]*201
for i in range(k):
    for a in range(1, k + 1):
        list_2[i + 1] += math.gcd(i + 1, a)*list[i + 1]
print(sum(list_2))
Buggy python submission (verdict: Runtime Error):
k = int(input())
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]

for i in range(k):
    if a[i] % 10 != 0:
        a.append(10*a[i] + a[i] % 10 - 1)
    a.append(10*a[i] + a[i] % 10)
    if a[i] % 10 != 9:
        a.append(10*a[i] + a[i] % 10 + 1)

print(a[k - 1])


Fixed submission:
x, y, z = map(int, input().split())
x_swap_1 = y
y_swap_1 = x
x = x_swap_1
y = y_swap_1
x_swap_2 = z
z_swap_2 = x
x = x_swap_2
z = z_swap_2
print(str(x) + ' ' + str(y) + ' ' + str(z))
Buggy python submission (verdict: Runtime Error):
k = int(input())
a[i] = [1, 2, 3, 4, 5, 6, 7, 8, 9]

for i in range(k):
    if a[i] % 10 != 0:
        a.append(10*a[i] + a[i] % 10 - 1)
    a.append(10*a[i] + a[i] % 10)
    if a[i] % 10 != 9:
        a.append(10*a[i] + a[i] % 10 + 1)

print(a[k - 1])


Fixed submission:
k = int(input())
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]

for i in range(k):
    if a[i] % 10 != 0:
        a.append(10*a[i] + a[i] % 10 - 1)
    a.append(10*a[i] + a[i] % 10)
    if a[i] % 10 != 9:
        a.append(10*a[i] + a[i] % 10 + 1)

print(a[k - 1])