Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,w = map(int,input().split())
dpv = [10 ** 20 for i in range(10**5+1)]
dpv[0] = 0
for i in range(n):
  weight,value = map(int,input().split())
  for j in range(10**5-value,-1,-1):
    dpv[j+value] = min(dpv[j+value],dpv[j]+weight)
for i in range(10**5,-1,-1):
  if dpv[i] <= w:
    print(i)
    exit()

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

lis = [list(map(int,input().split())) for i in range(n)]
lis.sort(key = lambda x:x[1])

dp = {0:0}

for weight ,value in lis:
    gone = dp.copy()
    for key in dp:
        gone[key+value] = min(dp[key] + weight, dp.get(key+value, float("inf")))
    dp = gone
for key in sorted(dp.keys(), reverse = True):
    if dp[key] <= w:
        print(key)
        exit()

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

lis = [list(map(int,input().split())) for i in range(n)]
lis.sort(key = lambda x:x[1])

dp = {0:0}

for weight ,value in lis:
    gone = dp.copy()
    for key in dp:
        gone[key+value] = min(dp[key] + weight, dp.get(key+v, float("inf")))
    dp = gone
for key in sorted(dp.keys(), reverse = True):
    if dp[key] <= w:
        print(key)
        exit()

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

lis = [list(map(int,input().split())) for i in range(n)]
lis.sort(key = lambda x:x[1])

dp = {0:0}

for weight ,value in lis:
    gone = dp.copy()
    for key in dp:
        gone[key+value] = min(dp[key] + weight, dp.get(key+value, float("inf")))
    dp = gone
for key in sorted(dp.keys(), reverse = True):
    if dp[key] <= w:
        print(key)
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
import math
n= int(input())
lis= list(map(int,input().split()))
lis.sort(reverse=True)
ans=0
while lis:
  a =lis.pop(0)
  num = 2**math.ceil(math.log(a,2))-a
  if num==0:num=a
  if num in lis:
    lis.remove(num)
    ans +=1
print(ans)


Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
c=Counter(a)
ans=0
for i in a:
  if c[i]==0:
    continue
  pt=2**len(format(i,'b'))
  c[i]-=1
  if c[pt-i]>=1:
    ans+=1
    c[pt-i]-=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(Christmas + " Eve" * (25-n))

Fixed submission:
n = int(input())
print("Christmas" + " Eve" * (25-n))
Buggy python submission (verdict: Runtime Error):
def to3(x,n):
  if (int(x/n)):
    return to3(int(x/n),n) + str(x%n)
  return str(x%n)
ch = ["3","5","7"]
ans = 0
for i in range(3 ** len(str(num))+1):
  s = to3(i,3)
  for u in range(len(str(num))-len(s)+2):
    if u > 0:
      s = "0" + s
    k1 = 0
    k2 = 0
    k3 = 0
    ss = ""
    for j in range(len(s)):
      if s[j] == "0":k1 = 1
      elif s[j] == "1":k2 = 1
      else: k3 = 1
      ss += ch[int(s[j])]
    if k1 and k2 and k3 and int(ss) <= num:ans += 1
print(ans)

Fixed submission:
num = int(input())
def to3(x,n):
  if (int(x/n)):
    return to3(int(x/n),n) + str(x%n)
  return str(x%n)
ch = ["3","5","7"]
ans = 0
for i in range(3 ** len(str(num))+1):
  s = to3(i,3)
  for u in range(len(str(num))-len(s)+2):
    if u > 0:
      s = "0" + s
    k1 = 0
    k2 = 0
    k3 = 0
    ss = ""
    for j in range(len(s)):
      if s[j] == "0":k1 = 1
      elif s[j] == "1":k2 = 1
      else: k3 = 1
      ss += ch[int(s[j])]
    if k1 and k2 and k3 and int(ss) <= num:ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
def to3(x,n):
  if (int(x/n)):
    return to3(int(x/n),n) + str(x%n)
  return str(x%n)
c = ["3","5","7"]
ch = ["0","3","5","7"]
ans = 0
for i in range(4 ** len(str(num))):
  s = to3(i,4)
  ss = ""
  for j in range(len(s)):
    ss += ch[int(s[j])]
  key = 1
  k1 = 0
  k2 = 0
  k3 = 0
  for k in range(len(ss)):
    if ss[k] == "0":
      key = 0
      break
    elif ss[k] == "3":
      k1 = 1
    elif ss[k] == "5":
      k2 = 1
    else:
      k3 = 1
  if key == 1 and k1 and k2 and k3 and int(ss) <= num:ans += 1
print(ans)

Fixed submission:
num = int(input())
def to3(x,n):
  if (int(x/n)):
    return to3(int(x/n),n) + str(x%n)
  return str(x%n)
ch = ["3","5","7"]
ans = 0
for i in range(3 ** len(str(num))+1):
  s = to3(i,3)
  for u in range(len(str(num))-len(s)+2):
    if u > 0:
      s = "0" + s
    k1 = 0
    k2 = 0
    k3 = 0
    ss = ""
    for j in range(len(s)):
      if s[j] == "0":k1 = 1
      elif s[j] == "1":k2 = 1
      else: k3 = 1
      ss += ch[int(s[j])]
    if k1 and k2 and k3 and int(ss) <= num:ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n= int(input())
lis = list(map(int,input().split())
cou = 0
num = sum(lis)/n
for i in range(n):
  lis[i] -= num
  cou = min(cou,abs(lis[i]))
for i in range(n):
  if cou == lis[i]:
    print(i)
    exit()

Fixed submission:
n = int(input())
lis = list(map(int,input().split()))
li = []
num = sum(lis)/n
for i in range(n):li.append(abs(lis[i]-num))
print(li.index(min(li)))
Buggy python submission (verdict: Runtime Error):
n,m =map(int,input().split())
lis = [list(map(int,input().split())) for i in range(m)]
for i in range(n):
    lis[i].append(i)
lis.sort()
cnt = 1
ans = []
ans.append([lis[0][-1],format(lis[0][0]).zfill(6)+format(1).zfill(6)])
for i in range(m-1):
    if lis[i][0] == lis[i+1][0]:
        cnt += 1
        ans.append([lis[i+1][-1],format(lis[i+1][0]).zfill(6)+format(cnt).zfill(6)])
    else:
        cnt = 1
        ans.append([lis[i+1][-1],format(lis[i+1][0]).zfill(6)+format(cnt).zfill(6)])
ans.sort(key = lambda x:x[0])
for i,x in ans:
    print(x)

Fixed submission:
from operator import itemgetter
n,m = map(int,input().split())
lis = []
ans = [0 for i in range(m)]
num = [0 for i in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  lis.append([i,a,b])
lis.sort(key=itemgetter(2))
for i in range(m):
  num[lis[i][1]-1] += 1
  cou = max(0,5-(lis[i][1] // 10))
  co = max(0,5-(num[lis[i][1]-1] // 10))
  ans[lis[i][0]] = format(lis[i][1],'06d') + format(num[lis[i][1]-1],'06d')
for i in range(m):print(ans[i])
Buggy python submission (verdict: Runtime Error):
n = int(input())
num = 1
while num * (num + 1) <= 2 * n:
  num += 1
now = n
for i in range(num,0,-1):
  if now >= i:
    print(i)
    now -= i

Fixed submission:
s = str(input())
if len(s) == 2:
  print(s)
else:
  print(s[2] + s[1] + s[0])
Buggy python submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
for i in range(n):
  b += a//2
  a = a//2
  a += b//2
  b = b//2
print(a,b)

Fixed submission:
a,b,k = map(int,input().split())
cnt = 0
while cnt < k:
  b += a//2
  a = a//2
  cnt += 1
  if cnt < k:
    a += b//2
    b = b//2
    cnt += 1
print(a,b)
Buggy python submission (verdict: Runtime Error):
n = int(input())
lis = [list(map(int,input().split())) for i in range(n)]
li = []
for nu,nuu,nuuu in lis:
  if nuuu != 0:li.append([nu,nuu,nuuu])
for i in range(101):
  for j in range(101):
    s = set()
    for h in range(len(li)):
      num = abs(li[h][0]-i)+abs(li[h][1]-j)
      if num + li[h][2] < 0:
        s.add(num + li[h][2] + 1)
      s.add(num + li[h][2])
    if len(s) == 1:
      for num in s:
        print(i,j,num)

Fixed submission:
n = int(input())
if n == 1:
  print("Hello World")
  exit()
else:
  a = int(input())
  b = int(input())
  print(a + b)
Buggy python submission (verdict: Runtime Error):
n = int(input())
lis = []
for i in range(n):
  a = list(map(int,input().split()))
  if a[2] != 0:lis.append(a)
if len(lis) == 1:
  print(lis[0][0],lis[0][1],lis[0][2])
  exit()
for x in range(101):
  for y in range(101):
    co = abs(x -lis[0][0])+abs(y -lis[0][1])+lis[0][2]
    for j in range(1,n):
      if lis[j][2] != 0 and co != abs(x -lis[j][0])+abs(y -lis[j][1])+lis[j][2]:
        break
      if j == n-1:
        print(x,y,co)
        exit()

Fixed submission:
n = int(input())
lis = []
for i in range(n):
  a = list(map(int,input().split()))
  if a[2] != 0:lis.append(a)
if len(lis) == 1:
  print(lis[0][0],lis[0][1],lis[0][2])
  exit()
for x in range(101):
  for y in range(101):
    co = abs(x -lis[0][0])+abs(y -lis[0][1])+lis[0][2]
    for j in range(1,len(lis)):
      if co != abs(x -lis[j][0])+abs(y -lis[j][1])+lis[j][2]:
        break
      if j == len(lis)-1:
        print(x,y,co)
        exit()

Buggy python submission (verdict: Runtime Error):
n = int(input())
lis = [list(map(int,input().split())) for i in range(n)]
ans = []
for x in range(101):
  for y in range(101):
    co = abs(x -lis[0][0])+abs(y -lis[0][1])+lis[0][2]
    for j in range(n):
      if co != abs(x -lis[j][0])+abs(y -lis[j][1])+lis[j][2]:
        break
      if j == n-1:
        ans.append([x,y,co])
print(ans[0][0],ans[0][1],ans[0][2])

Fixed submission:
n = int(input())
lis = []
for i in range(n):
  a = list(map(int,input().split()))
  if a[2] != 0:lis.append(a)
if len(lis) == 1:
  print(lis[0][0],lis[0][1],lis[0][2])
  exit()
for x in range(101):
  for y in range(101):
    co = abs(x -lis[0][0])+abs(y -lis[0][1])+lis[0][2]
    for j in range(1,len(lis)):
      if co != abs(x -lis[j][0])+abs(y -lis[j][1])+lis[j][2]:
        break
      if j == len(lis)-1:
        print(x,y,co)
        exit()
Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
cou = 0
lis = list(map(int,input().split()))
for i in range(n):
  if i != n-1:
    if x >= lis[i]:
      x -= lis[i]:
        cou += 1
  else:
    if x == lis[i]:
      cou += 1
print(cou)

Fixed submission:
n,x = map(int,input().split())
cou = 0
lis = list(map(int,input().split()))
lis.sort()
for i in range(n):
  if i != n-1:
    if x >= lis[i]:
      x -= lis[i]
      cou += 1
  else:
    if x == lis[i]:
      cou += 1
print(cou)
Buggy python submission (verdict: Runtime Error):
import collections

n,m = map(int,input().split())
s = list(str(input()))
key = collection.deque()
lis = [[] for i in range(n)]
li = [{"A":0,"B":0} for i in range(n)]

for i in range(m):
  a,b = map(int,input().split())
  lis[a-1].append(b-1)
  lis[b-1].append(a-1)
  li[a-1][s[b-1]] += 1
  li[b-1][s[a-1]] += 1
  
ans = [0 for i in range(n)]

for i in range(n):
  if li[i]["A"] == 0 or li[i]["B"] == 0:
    key.append(i)
    ans[i] = 1
    
while len(key) > 0:
  num = key.popleft()
  for nu in lis[num]:
    li[nu][s[num]] -= 1
    if li[nu]["A"] == 0 or li[nu]["B"] == 0:
      if ans[nu] == 0:
        key.append(nu)
        ans[nu] = 1

if sum(ans) == n:print("No")
else:print("Yes")

Fixed submission:
import collections

n,m = map(int,input().split())
s = list(str(input()))
key = collections.deque()
lis = [[] for i in range(n)]
li = [{"A":0,"B":0} for i in range(n)]

for i in range(m):
  a,b = map(int,input().split())
  lis[a-1].append(b-1)
  lis[b-1].append(a-1)
  li[a-1][s[b-1]] += 1
  li[b-1][s[a-1]] += 1
  
ans = [0 for i in range(n)]

for i in range(n):
  if li[i]["A"] == 0 or li[i]["B"] == 0:
    key.append(i)
    ans[i] = 1
    
while len(key) > 0:
  num = key.popleft()
  for nu in lis[num]:
    li[nu][s[num]] -= 1
    if li[nu]["A"] == 0 or li[nu]["B"] == 0:
      if ans[nu] == 0:
        key.append(nu)
        ans[nu] = 1

if sum(ans) == n:print("No")
else:print("Yes")

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

n,m = map(int,input().split())
s = list(str(input()))
key = collection.deque()
lis = [[] for i in range(n)]
li = [{"A":0,"B":0} for i in range(n)]

for i in range(m):
  a,b = map(int,input().split())
  lis[a-1].append(b-1)
  lis[b-1].append(a-1)
  li[a-1][s[b-1]] += 1
  li[b-1][s[a-1]] += 1
  
ans = [0 for i in range(n)]

for i in range(n):
  if li[i]["A"] == 0 or li[i]["B"] == 0:
    key.append(i)
    ans[i] = 1
    
while len(key) > 0:
  num = key.popleft()
  for nu in lis[num]:
    li[j][s[num]] -= 1
    if li[j]["A"] == 0 or li[j]["B"] == 0:
      if ans[j] == 0:
        key.append(j)
        ans[j] = 1

if sum(ans) == n:print("No")
else:print("Yes")

Fixed submission:
import collections

n,m = map(int,input().split())
s = list(str(input()))
key = collections.deque()
lis = [[] for i in range(n)]
li = [{"A":0,"B":0} for i in range(n)]

for i in range(m):
  a,b = map(int,input().split())
  lis[a-1].append(b-1)
  lis[b-1].append(a-1)
  li[a-1][s[b-1]] += 1
  li[b-1][s[a-1]] += 1
  
ans = [0 for i in range(n)]

for i in range(n):
  if li[i]["A"] == 0 or li[i]["B"] == 0:
    key.append(i)
    ans[i] = 1
    
while len(key) > 0:
  num = key.popleft()
  for nu in lis[num]:
    li[nu][s[num]] -= 1
    if li[nu]["A"] == 0 or li[nu]["B"] == 0:
      if ans[nu] == 0:
        key.append(nu)
        ans[nu] = 1

if sum(ans) == n:print("No")
else:print("Yes")
Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
lis = []
for i in range(h):
  lis.append(list(map(int,input().split())))
cou = 0
ans = []
for i in range(h):
  for j in range(w):
    if lis[i][j] % 2 == 1:
      if j != w-1:
        ans.append([str(i+1),str(j+1),str(i+1),str(j+2)])
        lis[i][j]-=1
        lis[i][j+1]+= 1
        cou += 1
      else:
        if i != h-1:
          ans.append([i+1,j+1,i+2,j+1])
          lis[i][j]-=1
          lis[i+1][j]+= 1
          cou += 1
print(cou)
for i in range(len(ans)):
  print(" ".join(ans[i]))

Fixed submission:
h,w = map(int,input().split())
lis = []
for i in range(h):
  lis.append(list(map(int,input().split())))
cou = 0
ans = []
for i in range(h):
  for j in range(w):
    if lis[i][j] % 2 == 1:
      if j != w-1:
        ans.append([str(i+1),str(j+1),str(i+1),str(j+2)])
        lis[i][j]-=1
        lis[i][j+1]+= 1
        cou += 1
      else:
        if i != h-1:
          ans.append([str(i+1),str(j+1),str(i+2),str(j+1)])
          lis[i][j]-=1
          lis[i+1][j]+= 1
          cou += 1
print(cou)
for i in range(len(ans)):
  print(" ".join(ans[i]))

Buggy python submission (verdict: Runtime Error):
h,w = map(int,input().split())
lis = []
for i in range(h):
  lis.append(list(map(int,input().split())))
cou = 0
ans = []
for i in range(h):
  for j in range(w):
    if lis[i][j] % 2 == 1:
      if j != w-1:
        ans.append([str(i+1),str(j+1),str(i+1),str(j+2)])
        lis[i][j]-=1
        lis[i][j+1]+= 1
        cou += 1
      else:
        ans.append([i+1,j+1,i+2,j+1])
        lis[i][j]-=1
        lis[i+1][j]+= 1
        cou += 1
print(cou)
for i in range(len(ans)):
  print(" ".join(ans[i]))

Fixed submission:
h,w = map(int,input().split())
lis = []
for i in range(h):
  lis.append(list(map(int,input().split())))
cou = 0
ans = []
for i in range(h):
  for j in range(w):
    if lis[i][j] % 2 == 1:
      if j != w-1:
        ans.append([str(i+1),str(j+1),str(i+1),str(j+2)])
        lis[i][j]-=1
        lis[i][j+1]+= 1
        cou += 1
      else:
        if i != h-1:
          ans.append([str(i+1),str(j+1),str(i+2),str(j+1)])
          lis[i][j]-=1
          lis[i+1][j]+= 1
          cou += 1
print(cou)
for i in range(len(ans)):
  print(" ".join(ans[i]))
Buggy python submission (verdict: Runtime Error):
n = list(str(input()))
k = int(input())
for i in range(n):
  if n[i] != "1":
    print(n[i])
    exit()
print("1")

Fixed submission:
n = list(str(input()))
k = int(input())
for i in range(min(k,len(n))):
  if n[i] != "1":
    print(n[i])
    exit()
print("1")
Buggy python submission (verdict: Time Limit Exceeded):
n,m,q = map(int,input().split())
lis = [list(map(int,input().split())) for i in range(m)]
li = [list(map(int,input().split())) for i in range(q)]
ans = [[0] * n for i in range(n)]
for a,b in lis:
  ans[a-1][b-1] += 1
for a,b in li:
  cou = 0
  for i in range(a-1,b):
    cou += sum(ans[i][i:b])
  print(cou)

Fixed submission:
n,m,q = map(int,input().split())
lis = [[0 for i in range(n+1)] for j in range(n+1)]
for i in range(m):
    l,r = map(int,input().split())
    lis[l][r] += 1
for i in range(1,n+1):
    for j in range(1,n+1):
        lis[i][j] += lis[i-1][j] + lis[i][j-1] - lis[i-1][j-1]
for i in range(q):
    p,q = map(int,input().split())
    print(lis[q][q] - lis[q][p-1] - lis[p-1][q] + lis[p-1][p-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,g = map(int,input().split())
lis = []
mon = []
for i in range(n):
  a,b = map(int,input().split())
  lis.append([a,b])
score = {(0,0)}
for i in range(n):
  gone = set()
  for nu,cou in score:
    for j in range(lis[i][0]+1):
      if j != lis[i][0]:
        gone.add((nu+(i+1) * 100 * j,cou + j))
      else:
        gone.add((nu+(i+1) * 100 * j + lis[i][1],cou + j))
  score = gone
ans = 10 ** 12
for nu,num in score:
  if nu >= g:
    ans = min(ans,num)
print(ans)


Fixed submission:
import math
n,g = map(int,input().split())
lis = []
sum = []
for i in range(n):
  a,b = map(int,input().split())
  lis.append([a,b])
  sum.append((i+1)*100*a+b)
def ans(x,y):
  if y <= 0:return 10 ** 12
  nu = min(math.ceil(x/(100 * y)),lis[y-1][0])
  num = 100 * y * nu
  if nu == lis[y-1][0]:num += lis[y-1][1]
  if num >= x:cou = nu
  else:cou = nu +ans(x-num,y-1)
  return min(cou,ans(x,y-1))

print(ans(g,n))
Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

string s,t;
int i;

int main(){
    cin >> s;
    cin >> t;

    s = s + s;
    if(s.find(t) != s.npos){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    return 0;
}

Fixed submission:
s = str(input())
t = str(input())
for i in range(len(s)):
  if s == t:
    print("Yes")
    exit()
  nu = t[-1]
  t = nu+t[:-1]
print("No")

Buggy python submission (verdict: Runtime Error):
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

string s,t;
int si;
int i;

int main(){
    cin >> s >> t;

    s = s + s;
    if(s.find(t) != s.npos){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    return 0;
}

Fixed submission:
s = str(input())
t = str(input())
for i in range(len(s)):
  if s == t:
    print("Yes")
    exit()
  nu = t[-1]
  t = nu+t[:-1]
print("No")
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
lis = list(map(int,input().split()))
now = 1
for num in lis:
    now = (now * num)//math.gcd(now,num)
now -= 1
ans = sum([now%lis[i] for i in range(n)])
print(ans)

Fixed submission:
import fractions
n = int(input())
lis = list(map(int,input().split()))
cou = 1
for i in range(n):
  cou = (cou * lis[i])//fractions.gcd(cou, lis[i])
cou -= 1
print(sum([cou % lis[i] for i in range(n)]))
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
lis = list(map(int,input().split()))
for i in range(n):lis[-(i+1)] += i
lis.sort()
cou = 0
co = 0
num = lis[math.ceil(n/2)]
nu = lis[math.floor(n/2)]
for i in range(n):
  cou += abs(lis[i]-num)
  co += abs(lis[i]-nu)
print(min(cou,co))

Fixed submission:
import math
n = int(input())
lis = list(map(int,input().split()))
if n == 1:
  print("0")
  exit()
for i in range(n):lis[-(i+1)] += i
lis.sort()
cou = 0
co = 0
num = lis[math.ceil(n/2)]
nu = lis[math.floor(n/2)]
for i in range(n):
  cou += abs(lis[i]-num)
  co += abs(lis[i]-nu)
print(min(cou,co))
Buggy python submission (verdict: Time Limit Exceeded):
lis = [1]
cou = 1
n = int(input())
while 6 ** cou <= n:
  lis.append(6**cou)
  cou += 1
cou = 1
while 9 ** cou <= n:
  lis.append(9**cou)
  cou += 1
lis.sort(reverse = True)

now = {0}

for i in range(n):
  gone = set()
  for num in now:
    for k in range(len(lis)):
      gone.add(num + lis[k])
  if n in gone:
    print(i+1)
    exit()
  now = gone

Fixed submission:
n = int(input())

lis = [1, 6, 36, 216, 1296, 7776, 46656,
     9, 81, 729, 6561, 59049]
m = len(lis)

dp = [float('inf') for _ in range(n+1)]
dp[0] = 0

for j in range(1,n+1):
    temp = []
    for i in range(m):
        if j < lis[i]:
            continue
        else:
            temp.append(dp[j-lis[i]]+1)
    dp[j] = min(temp)

print(dp[n])

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

lis = [1, 6, 36, 216, 1296, 7776, 46656,
     9, 81, 729, 6561, 59049]
m = len(c)

dp = [float('inf') for _ in range(n+1)]
dp[0] = 0

for j in range(1,n+1):
    temp = []
    for i in range(m):
        if j < lis[i]:
            continue
        else:
            temp.append(dp[j-lis[i]]+1)
    dp[j] = min(temp)

print(dp[n])


Fixed submission:
n = int(input())

lis = [1, 6, 36, 216, 1296, 7776, 46656,
     9, 81, 729, 6561, 59049]
m = len(lis)

dp = [float('inf') for _ in range(n+1)]
dp[0] = 0

for j in range(1,n+1):
    temp = []
    for i in range(m):
        if j < lis[i]:
            continue
        else:
            temp.append(dp[j-lis[i]]+1)
    dp[j] = min(temp)

print(dp[n])

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

lis = [1, 6, 36, 216, 1296, 7776, 46656,
     9, 81, 729, 6561, 59049]
m = len(c)

dp = [float('inf') for _ in range(n+1)]
dp[0] = 0

for j in range(1,n+1):
    temp = []
    for i in range(m):
        if j < c[i]:
            continue
        else:
            temp.append(dp[j-lis[i]]+1)
    dp[j] = min(temp)

print(dp[n])


Fixed submission:
n = int(input())

lis = [1, 6, 36, 216, 1296, 7776, 46656,
     9, 81, 729, 6561, 59049]
m = len(lis)

dp = [float('inf') for _ in range(n+1)]
dp[0] = 0

for j in range(1,n+1):
    temp = []
    for i in range(m):
        if j < lis[i]:
            continue
        else:
            temp.append(dp[j-lis[i]]+1)
    dp[j] = min(temp)

print(dp[n])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
cou = n
lis = []
for i in range(n):
    if i == 0:
        lis.append(s[i+1:n].count("E"))
    else:
        lis.append(s[0:i].count("W")+s[i+1:n].count("E"))
print(min(lis))

Fixed submission:
n = int(input())
lis = [0]
s = str(input())
cou = 0
co  = 0
for i in range(n-1):
    if s[i] == "W":cou += 1
    lis.append(cou)
for k in range(1,n):
    if s[n-(k)] == "E":co += 1
    lis[n-(k+1)] += co
print(min(lis))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = []
lis = []
for i in range(n):
	a = int(input())
	lis.append(a)
	li.append(a)
co = 0
cou = 0
for i in range(n-1):
	if lis.index(n-(i+1)) > lis.index(n-i):
		lis.remove(n-(i+1))
		lis.insert(0,n-(i+1))
		co += 1

for k in range(n-1):
	if li.index(k+2) < li.index(k+1):
		li.remove(k+2)
		li.append(k+2)
		cou += 1
print(min(co,cou))

Fixed submission:
n = int(input())
lis = [int(input()) for i in range(n)]
li = [-1 for i in range(n)]
for i in range(n):
    li[lis[i]-1] = i
cnt = 0
ans = n-1
for i in range(n-1):
    if li[i] < li[i+1]:
        cnt += 1
    else:
        ans = min(ans,n-1-cnt)
        cnt = 0
ans = min(ans,n-1-cnt)
print(ans)