Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
hlist = list(map(int, input().split()))

dp = [10**9]*(n+1)
dp[1] = 0

for i in range(2, n+1):
    for j in range(1, k+1):
        if i-j>0:
            dp[i] = min(dp[i], dp[i-j] + abs(hlist[i-1-j] - hlist[i-1]))
        else:
            break

print(dp[n])

Fixed submission:
n, k = map(int, input().split())
heights = list(map(int, input().split()))
heights = [0] + heights
dp = [10**10]*(n+1)
dp[1] = 0

for i in range(1, n+1):
    for step in range(1, k+1):
        if (i + step) <= n:
            dp[i+step] = min(dp[i+step], abs(heights[i+step] - heights[i]) + dp[i])
print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
hlist = list(map(int, input().split()))

# dp[i] stores the minimum cost to reach step i (starting from step 1) i: 1->N
dp = [10**9]*(n+1)
dp[1] = 0

## TLE : backward fill
# for i in range(2, n+1):
#     for ss in range(1, k+1): # ss: step size
#         if i-ss >= 1:
#             dp[i] = min(dp[i], dp[i-ss] + abs(hlist[i-1] - hlist[i - ss - 1]))

## Forward fill
for i in range(n+1):
    for ss in range(i+1, i+k+1):
        if ss<=n:
            dp[ss] = min(dp[ss], dp[i] + abs(hlist[i-1] - hlist[ss - 1]))

print(dp[n])

Fixed submission:
n, k = map(int, input().split())
heights = list(map(int, input().split()))
heights = [0] + heights
dp = [10**10]*(n+1)
dp[1] = 0

for i in range(1, n+1):
    for step in range(1, k+1):
        if (i + step) <= n:
            dp[i+step] = min(dp[i+step], abs(heights[i+step] - heights[i]) + dp[i])
print(dp[n])

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

import math
# dp[i] stores the minimum cost to reach step i (starting from step 1) i: 1->N
dp = [math.inf]*(n+1)
dp[1] = 0

for i in range(2, n+1):
    for ss in range(1, k+1): # ss: step size
        if i-ss >= 1:
            dp[i] = min(dp[i], dp[i-ss] + abs(hlist[i-1] - hlist[i - ss - 1]))

print(dp[n])

Fixed submission:
n, k = map(int, input().split())
heights = list(map(int, input().split()))
heights = [0] + heights
dp = [10**10]*(n+1)
dp[1] = 0

for i in range(1, n+1):
    for step in range(1, k+1):
        if (i + step) <= n:
            dp[i+step] = min(dp[i+step], abs(heights[i+step] - heights[i]) + dp[i])
print(dp[n])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
hlist = list(map(int, input().split()))

# dp[i] stores the minimum cost to reach step i (starting from step 1) i: 1->N
dp = [10**9]*(n+1)
dp[1] = 0

for i in range(2, n+1):
    for ss in range(1, k+1): # ss: step size
        if i-ss >= 1:
            dp[i] = min(dp[i], dp[i-ss] + abs(hlist[i-1] - hlist[i - ss - 1]))

print(dp[n])

Fixed submission:
n, k = map(int, input().split())
heights = list(map(int, input().split()))
heights = [0] + heights
dp = [10**10]*(n+1)
dp[1] = 0

for i in range(1, n+1):
    for step in range(1, k+1):
        if (i + step) <= n:
            dp[i+step] = min(dp[i+step], abs(heights[i+step] - heights[i]) + dp[i])
print(dp[n])
Buggy python submission (verdict: Time Limit Exceeded):
nums = []
nums = input().split()
N = int(nums[0])
Y = int(nums[1])
Right = 0
for c in range(N+1) :
    for b in range(N + 1):
        for a in range(N + 1):
            if( Y == 10000 * a + 5000 * b + 1000 *c ):
                if (N == (a + b + c)):
                    Right = 1
                    break
                else:
                    continue
        else:
            continue
        break
    else:
        continue
    break
if( Right == 0 ):
    print("-1 -1 -1")
else :
    print(a,b,c)

Fixed submission:
nums = []
nums = input().split()
N = int(nums[0])
Y = int(nums[1])
Right = 0
for a in range(N+1) :
    for b in range(N + 1 - a):
        c = N - a - b
        if( Y == 10000 * a + 5000 * b + 1000 *c ):
            if (N == (a + b + c)):
                Right = 1
                break
            else:
                continue
    else:
        continue
    break
if( Right == 0 ):
    print("-1 -1 -1")
else :
    print(a,b,c)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d = map(int, input().split())
cnt = []
if a == c and b == d:
    print(max(a*c, b*d))
    exit()
else:
    for i in range(a, b+1):
        for j in range(c, d+1):
            cnt.append(i*j)
            
C = sorted(cnt)
print(max(C[0],C[-1]))


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

if a == c and b == d:
    print(max(a*c, b*d))
    exit()
else:
    print(max(a*c, a*d,b*c,b*d))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d =map(int, input().split())
cnt = a*c

if a == c and b == d:
    print(max(a*c, b*d))
    exit()
else:
    for i in range(a, b+1):
        for j in range(c, d+1):
            cnt = max(cnt,i*j)
            
print(cnt)   

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

if a == c and b == d:
    print(max(a*c, b*d))
    exit()
else:
    print(max(a*c, a*d,b*c,b*d))

Buggy python submission (verdict: Time Limit Exceeded):
a, b, c, d =map(int, input().split())
cnt = []

if a == c and b == d:
    print(max(a*c, b*d))
    exit()
else:
    for i in range(a, b+1):
        for j in range(c, d+1):
            cnt.append(i*j)
        
print(max(cnt))

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

if a == c and b == d:
    print(max(a*c, b*d))
    exit()
else:
    print(max(a*c, a*d,b*c,b*d))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
l = []

for i in range(n):
    if i == 0:
        l.append(a[0])
    else:
        if max(l) <= a[i]:
            l.append(a[i])
        else:
            l.append(max(l))
            
print(sum(l) - sum(a))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
l = [a[0]]

for i in range(n-1):
    if l[i] >= a[i+1]:
        l.append(l[i])
    else:
        l.append(a[i+1])

print(sum(l) -sum(a))
Buggy python submission (verdict: Runtime Error):
import math
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
 
if w >= v:
    print('No')
else:
    for i in range(1,t+1):
        if abs(a-b) <= (w-v)*i:
            print('Yes')
            break

Fixed submission:
s = input()
print(s[:3])

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

 
if w >= v:
    print('No')
else:
    for i in range(1,t+1):
        a_place = a + v*i
        b_place = b + w*i
        if a_place - b_place = 0:
            print('Yes')
            break

Fixed submission:
s = input()
print(s[:3])
Buggy python submission (verdict: Runtime Error):
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())

if w >= v:
    print('NO')
else:
    kyori = abs(a-b)
    time = kyori - (v-w)
    if t >= kyori/time:
        print('YES')
    else:
        print('NO')

Fixed submission:
a, v = map(int,input().split())
b, w = map(int,input().split())
t = int(input())
 
 
if (abs(a-b) <= (v- w)*t):
    print('YES')
else:
    print('NO')

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

if w >= v:
    print('No')
else:
    kyori = abs(a-b)
    time = kyori - (v-w)
    if t >= kyori/time:
        print('YES')
    else:
        print('No')

Fixed submission:
a, v = map(int,input().split())
b, w = map(int,input().split())
t = int(input())
 
 
if (abs(a-b) <= (v- w)*t):
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
 
 
if w >= v:
    print('No')
else:
    for i in range(1,t+1):
        a_place = a + v*i
        b_place = b + w*i
        if a_place - b_place = 0:
            print('Yes')
            break

Fixed submission:
a, v = map(int,input().split())
b, w = map(int,input().split())
t = int(input())
 
 
if (abs(a-b) <= (v- w)*t):
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
f = 1


for i in range(n):
    if 0 in a:
        f = 0
        break
    else:
        f *= a[i]
    
if f <= 10**18:
    print(f)
else:
    print(-1)
        

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

print(a *b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
f = 1


for i in range(n):
    if 0 in a:
        f = 0
    else:
        f *= a[i]
    
if f <= 10**18:
    print(f)
else:
    print(-1)

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

if 0 in a:
    print(0)
else:
    for i in a:
        ans *= i
        
        if ans > 10**18:
            print(-1)
            exit()
            
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
f = 1
 

for i in a:
    f *= i

if f <= 10**18:
    print(f)
else:
    print(-1)

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

if 0 in a:
    print(0)
else:
    for i in a:
        ans *= i
        
        if ans > 10**18:
            print(-1)
            exit()
            
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
f = 1

for i in a:
    f *= i
  


if f > 10**18:
    print(-1)
else:
    print(f)

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

if 0 in a:
    print(0)
else:
    for i in a:
        ans *= i
        
        if ans > 10**18:
            print(-1)
            exit()
            
    print(ans)
Buggy python submission (verdict: Runtime Error):
T = input()

times = len(T)

list = []

for i in range(times):
    if i == len(T):
        if T[i] == 'P' or T[i] == 'D':
            list.append(T[i])
        else:
            list.append('D')
    
    else:
        if T[i] == '?':
            list.append('D')
        else:
            if T[i+1] == '?' or T[i+1] == 'D':
                list.append('P')
            else:
                list.append('D')

print(''.join(list))

Fixed submission:
t = input()
print(t.replace("?", "D"))
Buggy python submission (verdict: Time Limit Exceeded):
tkhp, tkat, aohp, aoat = map(int, input().split())

while True:
    aohp -= tkat
    tkhp -= aoat
    if aohp == 0:
        print('Yes')
        break
    elif tkhp == 0:
        print('No')
        break
    

Fixed submission:
thhp, that, aohp, aoat = map(int, input().split())

while True:
    aohp -= that
    if aohp <= 0:
        print('Yes')
        break
        
    thhp -= aoat
    if thhp <= 0:
        print('No')
        break
Buggy python submission (verdict: Runtime Error):

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

num1 = n // (a + b) * a
num2 = n % (a + b)

if num2 < a:
    print(num1 + num2)
else:
    print(num1)

Fixed submission:
S= input()

if 'A' in S and 'B' in S:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a = []
for i in range(3):
    a1, a2, a3 = map(int, input().split())
    a.append(a1)
    a.append(a2)
    a.append(a3)

l = [0]*9
n = int(input())

for i in range(n):
    b = int(input())
    for k in range(9):
        if a[k] == b:
            l[k] += 1
 
if l[0] == 1 and l[1] == 1 and l[2] == 1:
    print('Yes')
elif l[3] == 1 and l[4] == 1 and l[5] == 1:
    print('Yes')
elif l[6] == 1 and l[7] == 1 and l[8] == 1:
    print('Yes')
elif l[0] == 1 and l[3] == 1 and l[6] == 1:
    print('Yes')
elif l[1] == 1 and l[4] == 1 and l[7] == 1:
    print('Yes')
elif l[2] == 1 and l[5] == 1 and l[8] == 1:
    print('Yes')
elif l[0] == 1 and l[4] == 1 and l[8] == 1:
    print('Yes')
elif l[2] == 1 and l[4] == 1 and l[6] == 1:
    print('Yes')
else:
    print('No')

Fixed submission:
import math

n = int(input())

print(math.ceil(n / 2))
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
cnt = 0

for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if l == s-i-j:
                cnt += 1
            
print(cnt)

Fixed submission:
k, s = map(int, input().split())
cnt = 0

for i in range(k+1):
    for j in range(k+1):
        l = s-i-j
        if 0 <= l <= k:
            cnt += 1
            
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
cnt = 0

for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i + j+ l == s:
                cnt += 1
                
print(cnt)

Fixed submission:
k, s = map(int, input().split())
cnt = 0

for i in range(k+1):
    for j in range(k+1):
        l = s-i-j
        if 0 <= l <= k:
            cnt += 1
            
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))

r=[0]*n
for ii in range(n):
  r0=0
  for jj in range(n):
    if ii!=jj:
      r0=r0^a[jj]
  r[ii]=r0
"""
for ii in range(n):
  print(bin(a[ii]),bin(r[ii]))
"""
print(*r)

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

r1=0
for jj in range(n):
  r1=r1^a[jj]

r=[0]*n
for ii in range(n):
  r[ii]=r1^a[ii]
"""
for ii in range(n):
  print(bin(a[ii]),bin(r[ii]))
"""
print(*r)
Buggy python submission (verdict: Time Limit Exceeded):
"""
くじ引きを N 回行い、i 回目には種類が文字列 Si

で表される景品を手に入れました。

何種類の景品を手に入れましたか？
"""
n=int(input())
a=[]
for ii in range(n):
	s=input()
	if s in a:
	    pass
	else:
	    a.append(s)
#print(a)
print(len(a))

Fixed submission:
n=int(input())
a=[]
for ii in range(n):
	s=input()
	a.append(s)

#print(a)
#print(len(a))
print(len(list(set(a))))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[0]*n
a[:]=map(int,input().split())
for ii in range(n):
    print(a.count(ii+1))

Fixed submission:
n=int(input())
a=[0]*(n-1)
a[:]=map(int,input().split())
b=[0]*(n)
"""print(a)
print(b)"""
for ii in range(n-1):
    b[a[ii]-1]+=1
for ii in range(n):
    print(b[ii])
Buggy python submission (verdict: Time Limit Exceeded):
"""
青木君は任意の整数 x

に対し、以下の操作を行うことができます。

操作: x
を x と K

の差の絶対値で置き換える。

整数 N
の初期値が与えられます。この整数に上記の操作を 0 回以上好きな回数行った時にとりうる N

の最小値を求めてください。
制約
"""
n,k=map(int,input().split())
"""if n>k:
    x=n-k
else:
    x=n
"""
x=n
r=min(x,abs(x-k))
for ii in range(max(k,x)):
    x=min(x,abs(x-k))
#    print(r,x,abs(x-k))
    if r==min(x,abs(x-k)):
        break
    else:
        r=min(x,abs(x-k))

print(r)

Fixed submission:
"""
青木君は任意の整数 x

に対し、以下の操作を行うことができます。

操作: x
を x と K

の差の絶対値で置き換える。

整数 N
の初期値が与えられます。この整数に上記の操作を 0 回以上好きな回数行った時にとりうる N

の最小値を求めてください。
制約
"""
n,k=map(int,input().split())
x=n
if k==x:
    r=0
elif k>x:
    r=min(x,(k-x))
else:
    if (x-k)>=k:
        r=min(k-(x-k)%k,(x-k)%k)
    else:
        r=min(k-k%(x-k),k%(x-k))
print(r)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[""]*n
for ii in range(n):
  s[ii]=input()
ss=list(set(s))
ss.sort()
c=[0]*len(ss)
for ii in range(n):
  c[ss.index(s[ii])]+=1
#print(c)
mx=max(c)
for ii in range(len(ss)):
  if c[ii]==mx:
    print(ss[ii])
  


Fixed submission:
n=int(input())
ss=set()
d=dict()
for ii in range(n):
  s=input()
  if s in ss:
    d[s]+=1
  else:
    ss.add(s)
    d[s]=1
ss=list(ss)
ss.sort()
mx=max(d.values())
for ii in ss:
  if d[ii]==mx:
    print(ii)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[""]*n
for ii in range(n):
  s[ii]=input()
ss=list(set(s))
#print(ss)
#print(s)
r=[]
for ii in range(len(ss)):
  l=[1 if x==ss[ii] else 0 for x in s]
  r.append([n-sum(l),ss[ii]])
r.sort()
#pint(r)
for ii in range(len(ss)):
  if r[ii][0]==r[0][0]:
    print(r[ii][1])
  else:
    exit()

Fixed submission:
n=int(input())
ss=set()
d=dict()
for ii in range(n):
  s=input()
  if s in ss:
    d[s]+=1
  else:
    ss.add(s)
    d[s]=1
ss=list(ss)
ss.sort()
mx=max(d.values())
for ii in ss:
  if d[ii]==mx:
    print(ii)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[0]*n
def int1(x):
  return int(x)-1
a[:]=map(int1,input().split())
#print(a)
import numpy as np
l=np.argsort(a)
#print(l)
del a[0:l[0]]
r=0
for ii in range(n):
  if ii in a:
    del a[0:a.index(ii)]
    r+=1
    #print(a,r)
  else:
    #print(a)
    if r==0:
      print(-1)
    else:
      print(n-r)
    exit()
print(n-r)

Fixed submission:
n=int(input())
a=[0]*n
def int1(x):
  return int(x)-1
a[:]=map(int1,input().split())

r=0
#j0=0
#import numpy as np
ii=0
for jj in range(n):
  if a[jj]==ii:
    r+=1
    ii+=1
if r==0:
  print(-1)
  exit()

print(n-r)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[0]*n
def int1(x):
  return int(x)-1
a[:]=map(int1,input().split())
#print(a)
r=0
for ii in range(n):
  if ii in a:
    del a[0:a.index(ii)]
    r+=1
    #print(a,r)
  else:
    #print(a)
    if r==0:
      print(-1)
    else:
      print(n-r)
    exit()
print(n-r)

Fixed submission:
n=int(input())
a=[0]*n
def int1(x):
  return int(x)-1
a[:]=map(int1,input().split())

r=0
#j0=0
#import numpy as np
ii=0
for jj in range(n):
  if a[jj]==ii:
    r+=1
    ii+=1
if r==0:
  print(-1)
  exit()

print(n-r)
Buggy python submission (verdict: Time Limit Exceeded):
n=10**100
n5=10
n20=50
s=list(input())
ls=len(s)

sisr=[]
for ss in s:
  if ss=="R":
    sisr.append(True)
  else:
    sisr.append(False)

r=[-1]*ls
for ii in range(ls):
  iii=ii
  for jj in range(n5):
    if sisr[iii]:
      iii+=1
    else:
      iii-=1
  r[ii]=iii
    
import copy
r2=copy.copy(r)
for kk in range(n20):
  r4=[-1]*ls
  for ii in range(ls):
    iii=ii
    for jj in range(n5):
      iii=r2[iii]
    r4[ii]=iii
  r2=copy.copy(r4)
    
r3=[0]*ls
for ii in range(ls):
  r3[r2[ii]]+=1
#print(*r)
#print(*r2)
print(*r3)

Fixed submission:
s=list(input())
ls=len(s)
r=[0]*ls
c=0
for ii in range(ls-1):
  if s[ii]=="R" and s[ii+1]=="R":
    c+=1
  elif s[ii]=="R" and s[ii+1]=="L":
    c+=1
    r[ii]+=c//2+c%2
    r[ii+1]+=c//2
    c=0
  elif s[ii]=="L" and s[ii+1]=="L":
    pass
  elif s[ii]=="L" and s[ii+1]=="R":
    pass
  #print(c)
#print(*r)
c=0  
for jj in range(ls-1):
  ii=ls-1-jj
  if s[ii-1]=="R" and s[ii]=="R":
    pass
  elif s[ii-1]=="R" and s[ii]=="L":
    c+=1
    r[ii-1]+=c//2
    r[ii]+=c//2+c%2
    c=0
  elif s[ii-1]=="L" and s[ii]=="L":
    c+=1
  elif s[ii-1]=="L" and s[ii]=="R":
    pass
  #print(ii,c)
print(*r)

Buggy python submission (verdict: Time Limit Exceeded):
n=10^100
s=list(input())
ls=len(s)
ds=n//ls
rs=n%ls

sisr=[]
for ss in s:
  if ss=="R":
    sisr.append(True)
  else:
    sisr.append(False)

r=[-1]*ls
for ii in range(ls):
  iii=ii
  for jj in range(ls):
    if sisr[iii]:
      iii+=1
    else:
      iii-=1
  r[ii]=iii
      
r2=[-1]*ls
for ii in range(ls):
  iii=ii
  for jj in range(ds):
    iii=r[iii]
  r2[ii]=iii

r3=[-1]*ls
for ii in range(ls):
  iii=r2[ii]
  for jj in range(rs):
    if sisr[iii]:
      iii+=1
    else:
      iii-=1
  r3[ii]=iii
      
"""
print(ds,rs)
print(sisr)
print(r)
print(r2)
print(r3)
"""
rs=[]
for ii in range(ls):
  rs.append(str(r3.count(ii)))
print(*rs)

Fixed submission:
s=list(input())
ls=len(s)
r=[0]*ls
c=0
for ii in range(ls-1):
  if s[ii]=="R" and s[ii+1]=="R":
    c+=1
  elif s[ii]=="R" and s[ii+1]=="L":
    c+=1
    r[ii]+=c//2+c%2
    r[ii+1]+=c//2
    c=0
  elif s[ii]=="L" and s[ii+1]=="L":
    pass
  elif s[ii]=="L" and s[ii+1]=="R":
    pass
  #print(c)
#print(*r)
c=0  
for jj in range(ls-1):
  ii=ls-1-jj
  if s[ii-1]=="R" and s[ii]=="R":
    pass
  elif s[ii-1]=="R" and s[ii]=="L":
    c+=1
    r[ii-1]+=c//2
    r[ii]+=c//2+c%2
    c=0
  elif s[ii-1]=="L" and s[ii]=="L":
    c+=1
  elif s[ii-1]=="L" and s[ii]=="R":
    pass
  #print(ii,c)
print(*r)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[[]*3 for ii in range(n)]
for ii in range(n):
  s=input().split()
  a[ii][0]=s[0]
  a[ii][1]=-int(s[1])
  a[ii][2]=ii
a.sort()
for ii in range(n):
  print(a[ii][2]+1)

Fixed submission:
n=int(input())
a=[[""]*3 for ii in range(n)]
for ii in range(n):
  s=input().split()
  #print(s)
  a[ii][0]=s[0]
  a[ii][1]=100-int(s[1])
  a[ii][2]=ii
a.sort()
for ii in range(n):
  print(a[ii][2]+1)
Buggy python submission (verdict: Runtime Error):
def get_binaly_arr(num,digit):
    return list(bin(num)[2:].zfill(digit))

def get_droped_mat(mat,binaly_arr,direction):
    if direction == "H":# 行をdrop!
        return [mat[i] for i in range(len(mat)) if binaly_arr[i] != "0" ]
    elif direction == "W": # 列をdrop!
        return [[arr[i] for i in range(len(arr)) if binaly_arr[i] != "0" ] for arr in mat]
    else :
        print("INVALID DIRECTION!")

def count_black(mat):
    return sum([sum([1 for item in arr if item == "#"]) for arr in mat])

    
if __name__ == "__main__":
    H,W,K = list(map(int,input().split()))
    c = []
    for i in range(0,H):
        c.append(list(input()))
    H_pattern_num = 2 ** H
    W_pattern_num = 2 ** W
    count = 0
    ite_num = 0
    for i in range(0,H_pattern_num):
        for j in range(0,W_pattern_num):
            # バイナリ配列を生成
            H_binaly_arr = get_binaly_arr(i,H)
            W_binaly_arr = get_binaly_arr(j,W)
            mat_temp = c.copy()
            mat_temp = get_droped_mat(c,H_binaly_arr,direction="H")
            mat_temp = get_droped_mat(mat_temp,W_binaly_arr,direction="W")
            if K == count_black(mat_temp):
                count += 1
    print(count)

Fixed submission:
N = int(input())
sub = (N%1000)
print(0 if sub == 0 else (1000-sub))
Buggy python submission (verdict: Runtime Error):
H,W,K = list(map(int,input().split()))
c = []
for i in range(H):
    c.append(list(input()))
ans = 0
H_pattern,W_pattern = 2**H,2**W
for i in range(0,H_pattern):
    for j in range(0,W_pattern):
        H_active,W_active=list(bin(H_pattern,i)[2:].zfill(H)),list(bin(W_pattern,j).zfill(H))
        count = 0
        for k,arr in enumerate(c):
            for l,item in enumerate(arr):
                if H_active[k] == "1" and W_active[l] == "1" and item == "#":
                    count += 1
        if count == K:
            ans += 1
print(ans)




Fixed submission:
H,W,K = list(map(int,input().split()))
c = []
for i in range(H):
    c.append(list(input()))
ans = 0
H_pattern,W_pattern = 2**H,2**W
for i in range(0,H_pattern):
    for j in range(0,W_pattern):
        H_active_arr,W_active_arr=list(bin((H_pattern-1)&i)[2:].zfill(H)),list(bin((W_pattern-1)&j)[2:].zfill(W))
        count = 0
        for k,arr in enumerate(c):
            for l,item in enumerate(arr):
                if H_active_arr[k] == "1" and W_active_arr[l] == "1" and item == "#":
                    count += 1
        if count == K:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
def get_sum_arr(arr):
    sum_arr = [0]
    N = len(arr)
    for i in range(1,N+1):
        sum_arr.append(sum_arr[i-1] + arr[i-1])
    return sum_arr

def get_max_b(left_time,j,B_sum_arr):
    # [0,1,2,3,4,5]
    while B_sum_arr[j] >= left_time and j > 0:
        j -= 1
    return j
def get_max_book_num(A,B,K):
    A_sum_arr,B_sum_arr = get_sum_arr(A),get_sum_arr(B)
    count,i,j = 0,0,len(B_sum_arr)-1
    for i in range(0,len(A_sum_arr)):
        if K < A_sum_arr[i]:
            break
        else:
            left_time = K - A_sum_arr[i]
            j = get_max_b(left_time,j,B_sum_arr)
        count = max(count,(i+j))
    return count

if __name__ == "__main__":
    N,M,K = list(map(int,input().split()))
    A = list(map(int,input().split()))
     # [0,1,2,3,4,5]
    B = list(map(int,input().split()))
     # [0,1,2,3,4,5]
    print(get_max_book_num(A,B,K))
    


Fixed submission:
a = int(input())
print(a+a**2+a**3)
Buggy python submission (verdict: Runtime Error):
if __name__=="__main__":
    X,N = list(map(int,input().split(" ")))
    p = list(map(int,input().split(" ")))
    for i in range(X+1):
        for j in [-1,1]:
            a = X + i*j
            if not (a in p):
                print(a)
                exit()

Fixed submission:
if __name__=="__main__":
    X,N = list(map(int,input().split()))
    p = list(map(int,input().split()))
    for i in range(X+1):
        for j in [-1,1]:
            a = X + i*j
            if not (a in p):
                print(a)
                exit(0)