Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import deque

N=int(input())
a=[0]*(N-1)
b=[0]*(N-1)
c=[0]*(N-1)
L=[ [] for _ in range(N)]
for i in range(N-1):
  a[i],b[i],c[i]= map(int,input().split())
  L[a[i]-1].append((b[i]-1,c[i]))
  L[b[i]-1].append((a[i]-1,c[i]))
Q,K= map(int,input().split())
         
#Lの中のitemの0は接続先、1は距離

d=[ -1 for i in range(N)]

def BFS(x):
  v=deque([x])
  d[x]=0
  
  while len(v)>0:
    s=v.popleft() #sはint
    for item in L[s]:
      if d[item[0]]==-1:
        d[item[0]]=d[s]+item[1]
        v.append(item[0])
BFS(K-1)

x=[0]*Q
y=[0]*Q
for j in range(Q):
  x[i],y[i] = map(int,input().split())
  print(d[x[i]-1]+d[y[i]-1])

Fixed submission:
from collections import deque

N=int(input())
a=[0]*(N-1)
b=[0]*(N-1)
c=[0]*(N-1)
L=[ [] for _ in range(N)]
for i in range(N-1):
  a[i],b[i],c[i]= map(int,input().split())
  L[a[i]-1].append((b[i]-1,c[i]))
  L[b[i]-1].append((a[i]-1,c[i]))
Q,K= map(int,input().split())
         
#Lの中のitemの0は接続先、1は距離

d=[ -1 for i in range(N)]

def BFS(x):
  v=deque([x])
  d[x]=0
  
  while len(v)>0:
    s=v.popleft() #sはint
    for item in L[s]:
      if d[item[0]]==-1:
        d[item[0]]=d[s]+item[1]
        v.append(item[0])
BFS(K-1)

x=[0]*Q
y=[0]*Q
for i in range(Q):
  x[i],y[i] = map(int,input().split())
  print(d[x[i]-1]+d[y[i]-1])

Buggy python submission (verdict: Runtime Error):
from collections import deque

N=int(input())
a=[0]*(N-1)
b=[0]*(N-1)
c=[0]*(N-1)
L=[ [] for _ in range(N)]
for i in range(N-1):
  a[i],b[i],c[i]= map(int,input().split())
  L[a[i]-1].append((b[i]-1,c[i]))
  L[b[i]-1].append((a[i]-1,c[i]))
Q,K= map(int,input().split())
         
#Lの中のitemの0は接続先、1は距離

d=[ -1 for i in range(N)]

def BFS(x):
  v=deque([x])
  d[x]=0
  
  while len(v)>0:
    s=v.popleft() #sはint
    for item in L[s]:
      if d[item[0]]==-1:
        d[item[0]]=d[s]+item[1]
        v.append(item[0])
BFS(K-1)

x=[0]*N
y=[0]*N
for i in range(Q):
  x[i],y[i] = map(int,input().split())
  print(d[x[i]-1]+d[y[i]-1])

Fixed submission:
from collections import deque

N=int(input())
a=[0]*(N-1)
b=[0]*(N-1)
c=[0]*(N-1)
L=[ [] for _ in range(N)]
for i in range(N-1):
  a[i],b[i],c[i]= map(int,input().split())
  L[a[i]-1].append((b[i]-1,c[i]))
  L[b[i]-1].append((a[i]-1,c[i]))
Q,K= map(int,input().split())
         
#Lの中のitemの0は接続先、1は距離

d=[ -1 for i in range(N)]

def BFS(x):
  v=deque([x])
  d[x]=0
  
  while len(v)>0:
    s=v.popleft() #sはint
    for item in L[s]:
      if d[item[0]]==-1:
        d[item[0]]=d[s]+item[1]
        v.append(item[0])
BFS(K-1)

x=[0]*Q
y=[0]*Q
for i in range(Q):
  x[i],y[i] = map(int,input().split())
  print(d[x[i]-1]+d[y[i]-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
a=[0]*M
b=[0]*M
c=[] #最初の候補地

for i in range(M):
  a[i],b[i]=map(int,input().split())
  if a[i]==1:
    if b[i] not in c:
      c.append(b[i])
    
for j in range(M):
  if a[j]!=1:
    if a[j] in c:
      if b[j]==N:
        print("POSSIBLE")
        break
else:
  print("IMPOSSIBLE")

Fixed submission:
N,M = map(int,input().split())
a=[0]*M
b=[0]*M
c=set() #最初の候補地

for i in range(M):
  a[i],b[i]=map(int,input().split())
  if a[i]==1:
    if b[i] not in c:
      c.add(b[i])
    
for j in range(M):
  if a[j]!=1:
    if a[j] in c:
      if b[j]==N:
        print("POSSIBLE")
        break
else:
  print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
a=[0]*M
b=[0]*M
c=[] #最初の候補地

for i in range(M):
  a[i],b[i]=map(int,input().split())
  if a[i]==1:
    c.append(b[i])
    
for j in range(M):
  if a[j] in c:
    if b[j]==N:
      print("POSSIBLE")
      break
else:
  print("IMPOSSIBLE")

Fixed submission:
N,M = map(int,input().split())
a=[0]*M
b=[0]*M
c=set() #最初の候補地

for i in range(M):
  a[i],b[i]=map(int,input().split())
  if a[i]==1:
    if b[i] not in c:
      c.add(b[i])
    
for j in range(M):
  if a[j]!=1:
    if a[j] in c:
      if b[j]==N:
        print("POSSIBLE")
        break
else:
  print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
N=int(input())
a=[0]*N
for i in range(N):
    a[i]=int(input().split())

b=[0]*N
b[0]=a[0]
for i in range(1,N):
    b[i]=b[i-1]+a[i]

x=[0]*N
y=[0]*N
z=[0]*N
for j in range(N):
    x[j]=b[j]
    y[j]=b[-1]-b[j]
    z[j]=abs(x[j]-y[j])

print(min(z[:-1]))

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

b=[0]*N
b[0]=a[0]
for i in range(1,N):
    b[i]=b[i-1]+a[i]

x=[0]*N
y=[0]*N
z=[0]*N
for j in range(N):
    x[j]=b[j]
    y[j]=b[-1]-b[j]
    z[j]=abs(x[j]-y[j])

print(min(z[:-1]))
Buggy python submission (verdict: Runtime Error):
N=int(input())
s=[0]*N
for i in range(N):
  s[i] = int(input())
s.sort()
s_sum=sum(s)

if s_sum%10 !=0:
  ans = s_sum
else:
  for num in s:
    if (s_sum-num)%10 !=0:
      maxi_1 = s_sum-num
      #print(num,maxi_1)
      break
    else:
      maxi_1=0
  tmp=0
  for num in s:
    tmp += num
    if (s_sum-tmp)%10 !=0:
      maxi_2= s_sum-tmp
      #print(num,maxi_2)
      break
    else:
      maxi_2=0
    ans=max(maxi_1,maxi_2)
print(ans)

Fixed submission:
N=int(input())
s=[0]*N
for i in range(N):
  s[i] = int(input())
s.sort()
s_sum=sum(s)

if s_sum%10 !=0:
  ans = s_sum
else:
  for num in s:
    if (s_sum-num)%10 !=0:
      maxi_1 = s_sum-num
      #print(num,maxi_1)
      break
    else:
      maxi_1=0
  tmp=0
  for num in s:
    tmp += num
    if (s_sum-tmp)%10 !=0:
      maxi_2= s_sum-tmp
      #print(num,maxi_2)
      break
    else:
      maxi_2=0
  ans=max(maxi_1,maxi_2)
print(ans)
Buggy python submission (verdict: Runtime Error):
N,N=map(int,input().split())
a=[0]*M
b=[0]*M
r=[0]*M
for i in range(M):
  A[i],B[i]=map(int,input().split())
  r[A[i]-1] +=1
  r[B[i]-1] +=1
  
for item in r:
  print(item)

Fixed submission:
N,M=map(int,input().split())
a=[0]*M
b=[0]*M
r=[0]*N
for i in range(M):
  a[i],b[i]=map(int,input().split())
  #print(a[i]-1,b[i]-1)
  r[a[i]-1] +=1
  r[b[i]-1] +=1
  
for item in r:
  print(item)
Buggy python submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)

print(sum(N//3:2N//3))

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)

#print(a)
print(sum( a[1:2*N:2] ))
Buggy python submission (verdict: Time Limit Exceeded):
import copy
X=int(input())
ava={0}
ava2={0}

for i in range(1,10**9):
  ava=copy.deepcopy(ava2)
  #print(i,ava,ava2)
  if X not in ava:
    for item in ava: 
      ava2.add(item+i)
      ava2.add(item-i)
  else:
    print(i-1)
    break

Fixed submission:
X=int(input())

for i in range(10**9):
  if (i*(i+1))//2>=X:
    print(i)
    break
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
O = M//2
if N>=O:
  print(N)
elpe:
  P = (N+O)//2
  print(P)

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

if N>=O:
  print(O)
else:
  P = (N+O)//2
  print(P)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[0]*N
B=[0]*N
for i in range(N):
  A[i],B[i] = map(int,input().split())
  
cnt=0
for i in range(N-1,-1,-1):
  s=A[i]%B[i]
  if s!=0:
    b= B[i]-s
    for j in range(0,i+1):
      A[j] += b
    cnt += b
  #print(i,A,cnt)

print(cnt)

Fixed submission:
N=int(input())
A=[0]*N
B=[0]*N
for i in range(N):
  A[i],B[i] = map(int,input().split())
  
cnt=0
for i in range(N-1,-1,-1):
  A[i] += cnt
  s=A[i]%B[i]
  if s!=0:
    cnt +=B[i]-s
  #print(i,A,cnt)

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[0]*N
B=[0]*N
for i in range(N):
  A[i],B[i] = map(int,input().split())
  
cnt=0
for i in range(N-1,-1,-1):
  s=A[i]%B[i]
  if s!=0:
    b= B[i]-s
    for j in range(0,i+1):
      A[j] += b
    cnt += b
  #print(i,A,cnt)

print(cnt)

Fixed submission:
N=int(input())
A=[0]*N
B=[0]*N
for i in range(N):
  A[i],B[i] = map(int,input().split())
  
cnt=0
for i in range(N-1,-1,-1):
  A[i] += cnt
  s=A[i]%B[i]
  if s!=0:
    cnt +=B[i]-s
  #print(i,A,cnt)

print(cnt)
Buggy python submission (verdict: Runtime Error):
S=input()

for i in range(10000):
  if S[-6:]=="dreamer" or S[-6:]=="eraser":
    S=S[:-6]
  elif S[-5:]=="dream" or S[-5:]=="erase":
    S=S[:-5]
  else:
    pass
  if S=[]:
    print("YES")
    break
else:
  print("NO")

Fixed submission:
S=input()

for i in range(100000):
  if S[-7:]=="dreamer":
    S=S[:-7]
  elif S[-6:]=="eraser":
    S=S[:-6]
  elif S[-5:]=="dream" or S[-5:]=="erase":
    S=S[:-5]
  else:
    pass
  if S=="":
    print("YES")
    break
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
N=int(input())

for i in range(1,N):
  if i*(i+1)//2 >= N:
    k=i
    break
    
c = int(k*(k+1)//2 - N)

for j in range(1,k+1):
  if j!=c:
    print(j)

Fixed submission:
N=int(input())
k=1

for i in range(1,N+1):
  if i*(i+1)//2 >= N:
    k=i
    break
    
c = int(k*(k+1)//2 - N)

for j in range(1,k+1):
  if j!=c:
    print(j)

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

for i in range(1,N):
  if i*(i+1)//2 >= N:
    i=k
    break
    
c = int(k*(k+1)//2 - N)

for j in range(1,k+1):
  if j!=c:
    print(j)

Fixed submission:
N=int(input())
k=1

for i in range(1,N+1):
  if i*(i+1)//2 >= N:
    k=i
    break
    
c = int(k*(k+1)//2 - N)

for j in range(1,k+1):
  if j!=c:
    print(j)

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

for i in range(1,N):
  if i*(i+1)//2 >= N:
    break
    
c = int(i*(i+1)//2 - N)

for j in range(1,i+1):
  if j!=c:
    print(j)

Fixed submission:
N=int(input())
k=1

for i in range(1,N+1):
  if i*(i+1)//2 >= N:
    k=i
    break
    
c = int(k*(k+1)//2 - N)

for j in range(1,k+1):
  if j!=c:
    print(j)

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

for i in range(1,N):
  if i*(i+1)//2 >= N:
    break
    
c = i*(i+1)//2 - N

for j in range(1,i+1):
  if j!=c:
    print(j)

Fixed submission:
N=int(input())
k=1

for i in range(1,N+1):
  if i*(i+1)//2 >= N:
    k=i
    break
    
c = int(k*(k+1)//2 - N)

for j in range(1,k+1):
  if j!=c:
    print(j)

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

for i in range(1,N):
  if i*(i+1)//2 >= N:
    break
    
c = i*(i+1)//2 - N

for j in range(1,i+1):
  if j!=c:
    print(j)

Fixed submission:
N=int(input())
k=1

for i in range(1,N+1):
  if i*(i+1)//2 >= N:
    k=i
    break
    
c = int(k*(k+1)//2 - N)

for j in range(1,k+1):
  if j!=c:
    print(j)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())

if (a+b+C)-max(a,b,c)==max(a,b,c):
  print("Yes")
else:
  print("No")

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

if (a+b+c)-max(a,b,c)==max(a,b,c):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
s=input()

ans="No"
for i in range(len(s)):
  if s[i]=="C":
    for j in range(i+1,len(s)):
      if s[j]="F":
        print("Yes")
        exit()
else:
  print(ans)

Fixed submission:
s=input()

ans="No"
for i in range(len(s)):
  if s[i]=="C":
    for j in range(i+1,len(s)):
      if s[j]=="F":
        print("Yes")
        exit()
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())

print(len(set(a,b,c)))

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

print(len({a,b,c}))

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

print(len(set(a,b,c))

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

print(len({a,b,c}))
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
S=input()
pas=0
kai=0

for num in S:
  if num=="a":
    if pas<A+B:
      pas +=1
      print("Yes")
    else:
      print("No")
  elif num=="b":
    if pas<A+B and :
      pas +=1


Fixed submission:
N,A,B= map(int,input().split())
S=input()
sanka=0
kaigai=0

for i in range(N):
  if S[i]=="a":
    if sanka< A+B:
      print("Yes")
      sanka += 1
    else:
      print("No")
  elif S[i]=="b":
    if sanka < A+B and kaigai <B:
      print("Yes")
      sanka += 1
      kaigai += 1
    else:
      print("No")    
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
S=input()

ans="NO"
n=0
w=0
e=0
s=0

for str in S:
  if str=="N":
    n +=1
  elif str=="E":
    e +=1
  elif str=="S":
    s +=1
  else:
    w +=1

if (n>0 and s>0) or (n==0 and s==0):
  tate=True
if (e>0 and w>0) or (e==0 and w==0):
  yoko=True
  
if tate and yoko:
  ans="Yes"
  
print(ans)

Fixed submission:
S=input()

ans="No"
n=0
w=0
e=0
s=0
tate=0
yoko=0

for str in S:
  if str=="N":
    n +=1
  elif str=="E":
    e +=1
  elif str=="S":
    s +=1
  else:
    w +=1

if (n>0 and s>0) or (n==0 and s==0):
  tate=True
if (e>0 and w>0) or (e==0 and w==0):
  yoko=True
  
if tate and yoko:
  ans="Yes"
  
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(lambda x: int(x), input().split())
INF=10**12
dp=[INF]*n
for _ in range(m):
    dp[int(input())-1]=0
dp[0]=1 if dp[0]==INF else 0
dp[1]=dp[0]+1 if dp[1]==INF else 0
for i in range(2, n):
    if dp[i]==0:
        continue
    dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
print(dp[n-1])

Fixed submission:
n,m=map(lambda x: int(x), input().split())
INF=10**12
dp=[INF]*n
for _ in range(m):
    dp[int(input())-1]=0
dp[0]=1 if dp[0]==INF else 0
if n>1:
    dp[1]=dp[0]+1 if dp[1]==INF else 0
if n>2:
    for i in range(2, n):
        if dp[i]==0:
            continue
        dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(lambda x: int(x), input().split()))
ans=0
for i in range(2,100000):
    tmp = a.count(i-1)+a.count(i)+a.count(i+1)
    if ans < tmp:
        ans=tmp
print(ans)

Fixed submission:
n=int(input())
a=list(map(lambda x: int(x), input().split()))
dic={}
for i in a:
    dic[i]=dic.get(i,0)+1
tmp=dic.get(0,0)+dic.get(1,0)
ans=0
for i in range(2,100000):
    tmp+=dic.get(i,0)
    if tmp>ans:
        ans=tmp
    tmp-=dic.get(i-2,0)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=0
while True:
    n=int(n/2)
    a+=1
    if n==1:
        break
print(2**a)

Fixed submission:
n=int(input())
a=0
while True:
    if n==1:
        break
    n=int(n/2)
    a+=1
print(2**a)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n, m = map(lambda x: int(x), input().split())
a = [0] * m
b = [0] * m
c = [0] * m
for i in range(m):
    a[i], b[i], c[i] = map(lambda x: int(x), input().split())

dist = [[-1 for i in range(n+1)] for j in range(n+1)]
for i in range(1, n+1):
    dist[i][i] = 0
    hist = [i]
    while True:
        hist_tmp = []
        for h in hist:
            for j in range(m):
                if a[j] == h and (dist[i][b[j]] == -1 or dist[i][b[j]] > dist[i][a[j]] + c[j]):
                    dist[i][b[j]] = dist[i][a[j]] + c[j]
                    hist_tmp.append(b[j])
                elif b[j] == h and (dist[i][a[j]] == -1 or dist[i][a[j]] > dist[i][b[j]] + c[j]):
                    dist[i][a[j]] = dist[i][b[j]] + c[j]
                    hist_tmp.append(a[j])
        if hist_tmp == []:
            break
        else:
            hist = copy.copy(hist_tmp)

count = 0
for i in range(m):
    if dist[a[i]][b[i]] < c[i]:
        count += 1
print(count)

Fixed submission:
n, m = map(lambda x: int(x), input().split())
a = [0] * m
b = [0] * m
c = [0] * m
for i in range(m):
    a[i], b[i], c[i] = map(lambda x: int(x), input().split())

inf = 100 * 1000
dist = [[inf for i in range(n+1)] for j in range(n+1)]
for i in range(1, n+1):
    dist[i][i] = 0
for i in range(m):
    dist[a[i]][b[i]] = c[i]
    dist[b[i]][a[i]] = c[i]

for k in range(1, n+1):
    for i in range(1, n+1):
        for j in range(1, n+1):
            dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])

count = 0
for i in range(m):
    if dist[a[i]][b[i]] < c[i]:
        count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())

if n == 1:
    print(0)
else:
    lis = [i for i in range(n+1)]
    for i in range(2, int(n**0.5) + 1):
        if lis[i] == i:
            lis[i] = i
            for j in range(i**2, n+1, i):
                if lis[j] == j:
                    lis[j] = i
#print(lis)
def bunkai(m):
    ans = []
    for i in range(m):
        ans.append(lis[m])
        m = m//lis[m]
        if m == 1:
            break
    return ans

ans = 1

for i in range(2,n):
    tmp = 1
    yaku = collections.Counter(bunkai(i))
    for i in yaku:
        tmp = tmp * (yaku[i] +1)
    ans += tmp

print(ans)




Fixed submission:
from collections import Counter

n = int(input())

if n == 1:
    print(0)
else:
    lis = [i for i in range(n+1)]
    for i in range(2, int(n**0.5) + 1):
        if lis[i] == i:
            lis[i] = i
            for j in range(i**2, n+1, i):
                if lis[j] == j:
                    lis[j] = i
#print(lis)
def bunkai(m):
    ans = []
    now = lis[m]
    cnt = 1
    for i in range(m):
        m = m//lis[m]
        if now == lis[m]:
            cnt += 1
        else:
            ans.append(cnt)
            cnt = 1
            now = lis[m]
        
        if m == 1:
            break
    return ans

ans = 1
for i in range(2,n):
    tmp = 1
    yaku = bunkai(i)
    for i in yaku:
        tmp *= (i +1)
    ans += tmp

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections

n = int(input())

if n == 1:
    print(0)
else:
    lis = [0 for i in range(n+1)]
    for i in range(2, n+1):
        if lis[i] == 0:
            lis[i] = i
            for j in range(i**2, n+1, i):
                if lis[j] == 0:
                    lis[j] = i

def bunkai(m):
    ans = []
    for i in range(m):
        ans.append(lis[m])
        m = m//lis[m]
        if m == 1:
            break
    return ans

ans = 1

for i in range(2,n):
    tmp = 1
    yaku = collections.Counter(bunkai(i))
    for i in yaku:
        tmp = tmp * (yaku[i] +1)
    ans += tmp

print(ans)




Fixed submission:
from collections import Counter

n = int(input())

if n == 1:
    print(0)
else:
    lis = [i for i in range(n+1)]
    for i in range(2, int(n**0.5) + 1):
        if lis[i] == i:
            lis[i] = i
            for j in range(i**2, n+1, i):
                if lis[j] == j:
                    lis[j] = i
#print(lis)
def bunkai(m):
    ans = []
    now = lis[m]
    cnt = 1
    for i in range(m):
        m = m//lis[m]
        if now == lis[m]:
            cnt += 1
        else:
            ans.append(cnt)
            cnt = 1
            now = lis[m]
        
        if m == 1:
            break
    return ans

ans = 1
for i in range(2,n):
    tmp = 1
    yaku = bunkai(i)
    for i in yaku:
        tmp *= (i +1)
    ans += tmp

print(ans)
Buggy python submission (verdict: Runtime Error):
import scipy.special.comb
S = int(input)
ans = 0
for i in range(3, S+1, 3):
  ans += scipy.special.comb(S-2*(i//3)-1, i//3-1, exact=True)
print(ans)

Fixed submission:
from scipy.special import comb
S = int(input())
ans = 0
mod = 10**9+7
for i in range(3, S+1, 3):
  ans = (ans +comb(S-2*(i//3)-1, i//3-1, exact=True)) % mod 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())

powlis = [pow(10, i, K) for i in range(K)]
for i in range(K-1):
    powlis[i+1] = (powlis[i] + powlis[i+1]) % K

lis = [(7 *powlis[i])%K  for i in range(K) ]

try:
    print(lis.index(0) + 1)
except:
    print(-1)

Fixed submission:
K = int(input())

powlis = [7*pow(10, i, K) for i in range(K)]
for i in range(K-1):
    powlis[i+1] = (powlis[i] + powlis[i+1]) % K
powlis[0] %= K


try:
    print(powlis.index(0) + 1)
except:
    print(-1)

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

powlis = [pow(10, i, K) for i in range(K)]
for i in range(K-1):
    powlis[i+1] = (powlis[i] + powlis[i+1]) % K
    
print(lis[0:10])
if 0 in lis:
    print(lis.index(0)+1)
else:
    print(-1)

Fixed submission:
K = int(input())

powlis = [7*pow(10, i, K) for i in range(K)]
for i in range(K-1):
    powlis[i+1] = (powlis[i] + powlis[i+1]) % K
powlis[0] %= K


try:
    print(powlis.index(0) + 1)
except:
    print(-1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
h = list(map(int,input().split()))

dp = [-1 for i in range(N)]

dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(N-2):
    dp[i+2] = max(dp[i+1] + abs(h[i+1]-h[i+2]), dp[i] + abs(h[i] - h[i+2])
print(dp[N-1])

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

a=[0]*N
a[1] = abs(h[0]-h[1])

for i in range(2,N):
    a[i]=min(a[i-2]+abs(h[i-2]-h[i]),a[i-1]+abs(h[i-1]-h[i]))

print(a[N-1])
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split)
if a <= c <= b:
    print("Yes")
else:
    print("No")


Fixed submission:
a, b, c = map(int, input().split())
if a <= c <= b:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split());f=lambda t,x:set([i for i in range(1500)if int(i*t)==x]);print(min(f(.08,a)&f(.1,b)))

Fixed submission:
a,b=map(int,input().split())
for i in range(1500):
  if int(i*.08)==a and int(i*.1)==b:
    print(i);exit()
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
cnt = 0
for A in range(1,N+1):
    for B in range(1,N//A+1):
        C = N-A*B
        if C>0:
            cnt += 1
print(cnt)

Fixed submission:
N = int(input())
cnt = 0
for A in range(1,N+1):
    for B in range(1,N//A+1):
        C = N-A*B
        if C>0:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = 10**7+1
P = [1 for _ in range(n)]
P[0]=0
P[1]=0
for i in range(2,int(n**0.5)+1):
    for j in range(i*i,n,i):
        P[j] = 0
Q = []
for i in range(2,n):
    if P[i]==1:
        Q.append(i)
def f(x):
    if x==1:
        return 1
    if P[x]==1:
        return 2
    C = {}
    for q in Q:
        if x%q==0:
            cnt = 0
            while x%q==0:
                x = x//q
                cnt += 1
            C[q] = cnt
        if x==1:break
        if P[x]==1:
            C[x]=1
            break
    num = 1
    for q in C:
        num *= C[q]+1
    return num
N = int(input())
cnt = 0
for i in range(1,N+1):
    cnt += i*f(i)
print(cnt)

Fixed submission:
N = int(input())
ans = 0
for i in range(1,N+1):
    for j in range(i,N+1,i):
        ans += j
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
p = 10**7+10
K = int(p**0.5)
P = [1 for _ in range(K)]
P[0]=0
P[1]=0
for i in range(2,int(K**0.5)+1):
    for j in range(i*i,K,i):
        P[j]=0
Q = []
for i in range(2,K):
    if P[i]==1:
        Q.append(i)
def f(x):
    if x==1:
        return 1
    C = {}
    for q in Q:
        k = 0
        while x%q==0:
            x = x//q
            k += 1
        if k>0:
            C[q]=k
        if x==1:break
    if x>1:
        C[x] = 1
    res = 1
    for y in C:
        res = res*(C[y]+1)
    return res
N = int(input())
tot = 0
for i in range(1,N+1):
    tot += i*f(i)
print(tot)

Fixed submission:
N = int(input())
ans = 0
for i in range(1,N+1):
    for j in range(i,N+1,i):
        ans += j
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
C = {}
for i in range(N):
    a = A[i]
    if a not in C:
        C[a] = 0
    C[a] += 1
A = []
for a in C:
    if C[a]==1:
        A.append(a)
if len(A)==0:
    print(0)
else:
    A = sorted(A)
    amax = A[-1]
    P = [0 for _ in range(amax+1)]
    for i in range(N):
        P[A[i]] = 1
    for i in range(N):
        a = A[i]
        for j in range(a*2,amax+1,a):
            P[j] = 0
    print(sum(P))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
N = len(A)
amax = A[-1]
P = [0 for _ in range(amax+1)]
for i in range(N):
    P[A[i]] = 1
for i in range(N):
    a = A[i]
    for j in range(a*2,amax+1,a):
        P[j] = 0
C = {}
for i in range(N):
    a = A[i]
    if a not in C:
        C[a] = 0
    C[a] += 1
for i in range(N):
    a = A[i]
    if P[a]==1 and C[a]>1:
        P[a] = 0
print(sum(P))