Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
tax = [int(n) for n in input().split()]

max_8tax = (tax[0]+1) / .08
min_8tax = int((tax[0]) / .08)
max_10tax = int((tax[1]+1) / .1) - 1
min_10tax = int((tax[1]) / .1)

r = -1

#print(max_8tax, min_8tax)
#print(max_10tax, min_10tax)

for i in range(min_10tax, max_10tax):
    if min_8tax <= i and i <= max_8tax:
        r = i
        break

print(r)

Fixed submission:
s = input()

if s == 'AAA' or s == 'BBB':
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
info = [int(n) for n in input().split()]

group = info[1] + info[2]

a = info // group
b = info % group
if b > info[1]:
    b = info[1]


result = a * info[1] + b
print(result)

Fixed submission:
info = [int(n) for n in input().split()]

group = info[1] + info[2]

a = info[0] // group
b = info[0] % group
if b > info[1]:
    b = info[1]


result = a * info[1] + b
print(result)
Buggy python submission (verdict: Runtime Error):
tax = [int(n) for n in input().split()]

max_8tax = (tax[0]+1) / .08
min_8tax = (tax[0]) / .08)
max_10tax = int((tax[1]+1) / .1) - 1
min_10tax = int((tax[1]) / .1)

r = -1

for i in range(min_10tax, max_10tax):
    if min_8tax <= i and i < max_8tax:
        r = i
        break

print(r)

Fixed submission:
tax = [int(n) for n in input().split()]

max_8tax = (tax[0]+1) / .08
min_8tax = tax[0] / .08
max_10tax = int((tax[1]+1) / .1) - 1
min_10tax = int(tax[1] / .1)

r = -1

for i in range(min_10tax, max_10tax):
    if min_8tax <= i and i < max_8tax:
        r = i
        break

print(r)
Buggy python submission (verdict: Time Limit Exceeded):
def cc(c):
    if c<2:return 0
    return int(c*(c-1)/2)

n=int(input())
a=[int(A) for A in input().split()]

cnt=0
for elem in set(a):
    cnt+=cc(a.count(elem))

for k in a:
    print(cnt-(a.count(k)-1))


Fixed submission:
from collections import Counter
n=int(input())
a=[int(A) for A in input().split()]

cnt=Counter(a)
s=sum([c*(c-1)//2 for c in cnt.values()])

for k in a:
    print(s-(cnt[k]-1))

Buggy python submission (verdict: Time Limit Exceeded):
def cc(c):
    if c<2: return 0
    return int(c*(c-1)/2)

n=int(input())
a=[int(A) for A in input().split()]

acnt=dict()
for elem in set(a):
    acnt[elem] = a.count(elem)

memo = [-1]*2000010
for ak in a:
    if memo[ak] != -1:
        print(memo[ak])
        continue

    cnt=0
    for k,kcnt in acnt.items():
        if ak==k:
            cnt+= cc(kcnt-1)
        else:
            cnt+=cc(kcnt)
    memo[ak]=cnt

    print(cnt)




Fixed submission:
from collections import Counter
n=int(input())
a=[int(A) for A in input().split()]

cnt=Counter(a)
s=sum([c*(c-1)//2 for c in cnt.values()])

for k in a:
    print(s-(cnt[k]-1))

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

def cc(c):
    if c<2: return 0
    return int(c*(c-1)/2)

n=int(input())
a=[int(A) for A in input().split()]

ball_cnt = dict(Counter(a))
for k in range(n):
    cnt=0
    for key, value in ball_cnt.items():
        if a[k]==key:
            cnt+=cc(value-1)
        else:
            cnt+=cc(value)
    print(cnt)

Fixed submission:
from collections import Counter
n=int(input())
a=[int(A) for A in input().split()]

cnt=Counter(a)
s=sum([c*(c-1)//2 for c in cnt.values()])

for k in a:
    print(s-(cnt[k]-1))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
a=[int(A) for A in input().split()]
for k in range(1, n+1):
    ball = a[0:k-1] + a[k:]
    cnt=0
    for s in set(ball):
        bc = ball.count(s)
        if bc<2:
            continue
        cnt+= bc*(bc-1)/2
    print(int(cnt))


Fixed submission:
from collections import Counter
n=int(input())
a=[int(A) for A in input().split()]

cnt=Counter(a)
s=sum([c*(c-1)//2 for c in cnt.values()])

for k in a:
    print(s-(cnt[k]-1))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
a=[int(A) for A in input().split()]
for k in range(1, n+1):
    ball = a[0:k-1] + a[k:]
    cnt=0
    for cc in Counter(ball).values():
        if cc <2:
            continue
        cnt += cc*(cc-1)/2
    print(int(cnt))


Fixed submission:
from collections import Counter
n=int(input())
a=[int(A) for A in input().split()]

cnt=Counter(a)
s=sum([c*(c-1)//2 for c in cnt.values()])

for k in a:
    print(s-(cnt[k]-1))
Buggy python submission (verdict: Time Limit Exceeded):
h,w=map(int, input().split())
cnt = 0
if h==1 or w == 1:
    print(1)
    exit(0)
    
for i in range(1, w+1):
    cnt += h//2 + (i%2 if h%2!=0 else 0)

print(cnt)

Fixed submission:
h, w = map(int, input().split())
hdiv = h // 2
hmod = h % 2
if h==1 or w==1:
    print(1)
elif hmod == 0:
    print(hdiv * w)
else:
    print(hdiv * w + w // 2 + w % 2)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,m=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
tickets=list()
for i in range(m):
    tickets.append(list(map(int,input().split())))

price_min=float("INF")
for ticket in tickets:
    price = A[ticket[0]-1] + B[ticket[1]-1] - ticket[2]
    price_min = price if price_min>price else price_min

# 割引券を使わない場合
for _a in A:
    for _b in B:
        price=_a + _b
        price_min=price if price_min > price else price_min
        if price <_a:
            break
print(price_min)

Fixed submission:
a,b,m=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
tickets=list()
for i in range(m):
    tickets.append(list(map(int,input().split())))

price_min=float("INF")
for ticket in tickets:
    price = A[ticket[0]-1] + B[ticket[1]-1] - ticket[2]
    price_min = price if price_min>price else price_min

# 割引券を使わない場合
no_ticket=min(A)+min(B)
if price_min > no_ticket: price_min=no_ticket
print(price_min)
Buggy python submission (verdict: Runtime Error):
import sys

r = int(sys.argv[1])

print(r*r, end="")


Fixed submission:
r = int(input())

print(r*r)

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

r = int(sys.argv[1])

print(r*r)


Fixed submission:
r = int(input())

print(r*r)

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

r = int(sys.argv[1])

print(r*r)


Fixed submission:
r = int(input())

print(r*r)
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())

if h != 1 and w != 1:
    if h*w % 2 == 1:
        print(str(int(h*w/2) + 1))
    else:
        print(str(int(h*w/2)))
elif:
    print(str(1))


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

if h != 1 and w != 1:
    if h*w % 2 == 1:
        print(str(int(h*w/2) + 1))
    else:
        print(str(int(h*w/2)))
else:
    print(str(1))
Buggy python submission (verdict: Time Limit Exceeded):
N,A,B = map(int, input().split())
L = []
b = 0
ans = 0
cnt = 0

while True:
  if A == 0: break

  L.append(A)
  b += A
  cnt += A
  if cnt > N:
    ans = b - (cnt - N)
    break

  L.append(B)
  cnt += B
  if cnt > N:
    ans = b
    break

print(ans)

Fixed submission:
N,A,B = map(int, input().split())
L = []
b = 0
ans = 0

if A == 0:
  ans = 0
elif N < A:
  ans = N
elif N < A+B:
  ans = A
else:
  x = N // (A+B)
  y = N % (A+B)
  ans = A * x + min(y, A)

print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
ans = ""

if int(S[0]) > 1:
  ans = S[0]
elif K>=100:
  for i in range(len(S)):
    if int(S[i]) > 1:
      ans = S[i]
      break
    elif i==S-1:
      ans = 1
else:
  for i in range(len(S)):
    if int(S[i]) > 1:
      if i+1 <= K:
        ans = S[i]
        break
      else:
        ans = 1
        break
    elif i==S-1:
      ans = 1
print(ans)

Fixed submission:
S = input()
K = int(input())
ans = 1

for i in range(len(S)):
  if int(S[i]) == 1:
    continue
  else:
    if i+1 <= K:
      ans = S[i]
      break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

l = []
for x in range(N):
    x = input()
    l.append(x)
    

lst = sorted(list(set(l)))
n_list = []


for x in lst:
    n = l.count(x)
    n_list.append(n)

max_n = max(n_list)
l_max = [i for i, x in enumerate(n_list) if x == max_n]

for x in l_max:
    print(lst[x]) 

Fixed submission:
import collections

N = int(input())

l = []
for x in range(N):
    x = input()
    l.append(x)

l_dict = collections.Counter(l)

max_n = max(l_dict.values())

l_max = sorted([x[0] for x in l_dict.items() if x[1] == max_n])

for a in l_max:
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

l = []
for x in range(N):
    x = input()
    l.append(x)
    
l_sorted=sorted(l)

lst = sorted(set(l))
n_list = []

for x in lst:
    n = l_sorted.count(x)
    n_list.append(n)

max_n = max(n_list)
l_max = [i for i, x in enumerate(n_list) if x == max_n]

for x in l_max:
    print(lst[x])

Fixed submission:
import collections

N = int(input())

l = []
for x in range(N):
    x = input()
    l.append(x)

l_dict = collections.Counter(l)

max_n = max(l_dict.values())

l_max = sorted([x[0] for x in l_dict.items() if x[1] == max_n])

for a in l_max:
    print(a)
Buggy python submission (verdict: Runtime Error):
raw_input = input()

l = raw_input.split()
A = int(l[0])
B = int(l[1])

answers = [1,2,3]

answers.remove(A)
answers.remove(B)


for ans in answers:
    print(ans)

Fixed submission:
raw_input1 = input()
raw_input2 = input()

A = int(raw_input1)
B = int(raw_input2)

answers = [1,2,3]

answers.remove(A)
answers.remove(B)


for ans in answers:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

N = int(input())
balls = input()
balls = balls.split()
balls = list(map(int, balls))

count = defaultdict(int)
for i in balls:
  count[i] += 1

def cmb(M):
  return M*(M-1)//2

sum = defaultdict(int)
for i in count:
  for j in count:
    if i==j:
      sum[i] += cmb(count[j]-1)
    else:
      sum[i] += cmb(count[j])
      
for i in balls:
  print(sum[i])

  
    

Fixed submission:
from collections import defaultdict

N = int(input())
balls = input()
balls = balls.split()
balls = list(map(int, balls))

count = defaultdict(int)
for i in balls:
  count[i] += 1

def cmb(M):
  return M*(M-1)//2

sum = 0
for i in count:
   sum += cmb(count[i])
#sum = defaultdict(int)
#for i in count:
#  for j in count:
#    if i==j:
#      sum[i] += cmb(count[j]-1)
#    else:
#      sum[i] += cmb(count[j])
#      
for i in balls:
  print(sum - (count[i]-1))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(4100000)

line = input().split()
nPerson = int(line[0])
nFriend = int(line[1])
nBlock  = int(line[2])

friends = [[] for i in range(nFriend)]
for i in range(nFriend):
  line = input().split()
  friends[i] =[int(line[0]), int(line[1]) ]

blocks = [[] for i in range(nBlock)]
for i in range(nBlock):
  line = input().split()
  blocks[i] = [int(line[0]), int(line[1]) ]
  
connected = [[] for i in range(nPerson+1)]
  
for i in friends:
  if i[1] not in connected[i[0]]:
    connected[i[0]].append(i[1])
  if i[0] not in connected[i[1]]:
    connected[i[1]].append(i[0])

blocked = [[] for i in range(nPerson+1)]
for i in blocks:
  if i[1] not in blocked[i[0]]:
    blocked[i[0]].append(i[1])
  if i[0] not in blocked[i[1]]:
    blocked[i[1]].append(i[0])
  
for i in range(len(connected)):
  connected[i] = set(connected[i])
for i in range(len(blocked)):
  blocked[i] = set(blocked[i])
  
nCand = [0]*(nPerson+1)

def findCand(target,curPer):
  if visited[curPer] == True :
    return
  visited[curPer] = True
  if curPer not in connected[target] and curPer not in blocked[target]:
    nCand[target] += 1
  for i in connected[curPer]:
    findCand(target,i)

for i in range(1,nPerson+1):
  visited = [False]*(nPerson+1)
  visited[i] = True
  for j in connected[i]:
    findCand(i,j)

res = ""
for i in range(1,nPerson+1):
  res += str(nCand[i]) + " "
  
print(res)
  

Fixed submission:
N = int(input())
print( N//2 + N%2)
Buggy python submission (verdict: Runtime Error):
line = input().split()
N, M = int(line[0]), int(line[1]) 

if M == 0:
  return 10**N

conds = []
for i in range(M):
  line = input().split()
  conds.append((int(line[0]),int(line[1])))
 
NUM = [-1] * N
 
isOK = True
for curCon in conds:
  s = curCon[0]
  dig = curCon[1]
  
  if NUM[s-1] == -1:
    NUM[s-1] = dig
  elif NUM[s-1] > dig:
    NUM[s-1] = dig
 
if N > 1:
  if NUM[0] == -1 or NUM[0] == 0:
    isOK = False
 
if isOK != True:
  print(-1)
else:
  for i in range(N):
    if NUM[i] == -1:
      NUM[i] = 0
  numChar = ""
  for iNum in NUM:
    numChar += str(iNum)
  print(int(numChar))

Fixed submission:
line = input().split()
N, M = int(line[0]), int(line[1]) 

if M == 0:
  if N == 1:
    print(0)
  else:
    print(10**(N-1))
  quit()

conds = []
for i in range(M):
  line = input().split()
  conds.append((int(line[0]),int(line[1])))
 
NUM = [-1] * N
 
isOK = True
for curCon in conds:
  s = curCon[0]
  dig = curCon[1]
  
  if NUM[s-1] == -1:
    NUM[s-1] = dig
  elif NUM[s-1] != dig:
    isOK = False
 
if N > 1:
  if NUM[0] == 0:
    isOK = False
 
if isOK != True:
  print(-1)
  quit()
else:
  if NUM[0] == -1:
    NUM[0]=1
    
  for i in range(N):
    if NUM[i] == -1:
      NUM[i] = 0
  numChar = ""
  for iNum in NUM:
    numChar += str(iNum)
  print(int(numChar))
Buggy python submission (verdict: Runtime Error):
import itertools
from collections import defaultdict as dict
d = dict(int)

N = int(input())
S = [int(_) for _ in input()]
s = list(itertools.combinations(S, 3))

for j in range(len(s)):

    # カウントアップ
    d[s[j]] += 1

print(len(d))

Fixed submission:
X = int(input())
if X < 100:
    print(0)
    exit()

w = X // 100
ans = w * 105
if X <= ans:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
S = int(input())
if S == "Sunny":
  ans = "Cloudy"
elif S == "Cloudy":
  ans = "Rainy"
else:
  ans = "Sunny"
print(ans)

Fixed submission:
S = input()
if S == "Sunny":
  ans = "Cloudy"
elif S == "Cloudy":
  ans = "Rainy"
else:
  ans = "Sunny"
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
ans = ["Yes"] * N
ok = Q - K
for i in range(1, N + 1):
  sumA = A.count(i)
  if sumA <= ok:
    ans[i - 1] = "No"

for ANS in ans:
  print(ANS)

Fixed submission:
from collections import Counter
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
C = Counter(A)
ans = ["No"] * N
ok = Q - K
if ok < 0:
  ans = ["Yes"] * N
  for ANS in ans:
    print(ANS)
  exit()

c = [key - 1 for key,val in C.items() if val > ok]
for i in c:
  ans[i] = "Yes"
for ANS in ans:
  print(ANS)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
n = [int(_) for _ in range(1, N)]
print(sum(n))

Fixed submission:
N = int(input())
n = N - 1
ans = (n + 1) * n
ans //= 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = [int(_) for _ in input().split()]
BC = [[int(_) for _ in input().split()] for _ in range(M)]
ABC = []
for x, y in BC:
    A.extend([y] * x)

A.sort(reverse = True)
print(sum(A[:N]))

Fixed submission:
N, M = map(int, input().split())
A = [int(_) for _ in input().split()]
BC = [[int(_) for _ in input().split()] for _ in range(M)]
# Cの大きい順にソート
BC.sort(key = lambda x: x[1], reverse = True)
ABC = []
for x, y in BC:
    A.extend([y] * x)
    # 2N個以上あっても選ばれないので、そこで打ち切り
    if len(A) > N * 2:
        break

A.sort(reverse = True)
print(sum(A[:N]))
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N, Q = map(int,input().split())
s = [_ for _ in input()]
td = [[_ for _ in input().split()] for _ in range(Q)]
GOL = [1 for _ in range(N)]

listS = defaultdict(list)
for i, word in enumerate(s):
    listS[word[0]].append(i)

for t, d in td:
    dictS = listS.get(t)
    if dictS == None:
        continue
    for idx in dictS:
        if (idx == 0 and d == "L") or (idx == N - 1 and d == "R"):
            pass
        else:
            if d == "L":
                GOL[idx - 1] += GOL[idx]
            else:
                GOL[idx + 1] += GOL[idx]

        GOL[idx] = 0

print(sum(GOL))

Fixed submission:

A,B,C = map(int,input().split())

if A == B == C:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = [ _ for _ in input()]
lr = [[int(_) for _ in input().split()] for _ in range(Q)]
A = [i for i, _ in enumerate(S, 1) if _ == "A"]
C = [i for i, _ in enumerate(S, 1) if _ == "C"]
AC = [_ for _ in A if _ + 1 in C]
for l,r in lr:
    ans = [_ for _ in AC if l <= _ and _ + 1 <= r]

    print(len(ans))

Fixed submission:
N, Q = map(int, input().split())
S = [ _ for _ in input()]
lr = [[int(_) for _ in input().split()] for _ in range(Q)]
ans = [0] * (N + 1)

for i, data in enumerate(S, 1):
    if data == "A":
        if i >= N:
            break

        if S[i] == "C":
            ans[i] = ans[i - 1] + 1
            continue

    ans[i] = ans[i - 1]

for l, r in lr:
    print(ans[r - 1] - ans[l - 1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
lr = [[int(_) for _ in input().split()] for _ in range(Q)]

for l,r in lr:
    Smoji = S[l - 1 :r]
    ans = Smoji.count("AC")

    print(ans)

Fixed submission:
N, Q = map(int, input().split())
S = [ _ for _ in input()]
lr = [[int(_) for _ in input().split()] for _ in range(Q)]
ans = [0] * (N + 1)

for i, data in enumerate(S, 1):
    if data == "A":
        if i >= N:
            break

        if S[i] == "C":
            ans[i] = ans[i - 1] + 1
            continue

    ans[i] = ans[i - 1]

for l, r in lr:
    print(ans[r - 1] - ans[l - 1])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
X = [int(x) for x in input().split()]
X.sort(reverse=True)
valX = [X[x] - X[x + 1] for x in range(M - 1)]

if N >= M:
    print(0)
    exit()

if N == 1:
    print(max(X) - min(X))
    exit()

for i in range(1,N):
    valX[valX.index(max(valX))] = 0

print(sum(valX))

Fixed submission:
N, M = map(int,input().split())
X = [int(x) for x in input().split()]
X.sort(reverse=True)
valX = [X[x] - X[x + 1] for x in range(M - 1)]
valX.sort(reverse=True)

if N >= M:
    print(0)
    exit()

if N == 1:
    print(max(X) - min(X))
    exit()

for i in range(N - 1):
    valX[i] = 0

print(sum(valX))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
X = [int(x) for x in input().split()]
X.sort(reverse=True)
valX = [X[x] - X[x + 1] for x in range(M - 1)]

if N >= M:
    print(0)
    exit()

if N == 1:
    print(max(X) - min(X))
    exit()

for i in range(1,N):
    valX[valX.index(max(valX))] = 0

print(sum(valX))

Fixed submission:
N, M = map(int,input().split())
X = [int(x) for x in input().split()]
X.sort(reverse=True)
valX = [X[x] - X[x + 1] for x in range(M - 1)]
valX.sort(reverse=True)

if N >= M:
    print(0)
    exit()

if N == 1:
    print(max(X) - min(X))
    exit()

for i in range(N - 1):
    valX[i] = 0

print(sum(valX))
Buggy python submission (verdict: Runtime Error):
# 最長共通部分　LCS ***未完成***
strA = input()
strB = input()
### 一致したら左上+1、そうでない場合は上か左のMAX
# / | 0 | A | B | C | B | A |
# 0 | 0 | 0 | 0 | 0 | 0 | 0 |
# B | 0 | 0 | 1 | 1 | 1 | 1 |
# B | 0 | 0 | 1 | 1 | 2 | 2 |
# A | 0 | 0 | 1 | 1 | 2 | 3 |
dp = [[0] * (len(strA) + 1) for _ in range(len(strB) + 1)]

for i, A in enumerate(strA, 1):
    for j, B in enumerate(strB, 1):
        if A == B:
            dp[j][i] = dp[j - 1][i - 1] + 1
        else:
            dp[j][i] = max(dp[j - 1][i], dp[j][i - 1])
ans = ""
cnt = 1
lstAns = dp[-1]
x, y = len(strB), len(strA)
while x > 0 and y > 0:
    if dp[x][y] == dp[x - 1][y]:
        x -= 1
    elif dp[x][y] == dp[x][y - 1]:
        y -= 1
    else:
        ans = strA[x] + ans
        x -= 1
        y -= 1
print(ans)

Fixed submission:
# 最長共通部分　LCS ***未完成***
strA = input()
strB = input()
### 一致したら左上+1、そうでない場合は上か左のMAX
# / | 0 | A | B | C | B | A |
# 0 | 0 | 0 | 0 | 0 | 0 | 0 |
# B | 0 | 0 | 1 | 1 | 1 | 1 |
# B | 0 | 0 | 1 | 1 | 2 | 2 |
# A | 0 | 0 | 1 | 1 | 2 | 3 |
dp = [[0] * (len(strA) + 1) for _ in range(len(strB) + 1)]

for i, A in enumerate(strA, 1):
    for j, B in enumerate(strB, 1):
        if A == B:
            dp[j][i] = dp[j - 1][i - 1] + 1
        else:
            dp[j][i] = max(dp[j - 1][i], dp[j][i - 1])
ans = ""
cnt = 1
lstAns = dp[-1]
x, y = len(strA), len(strB)
while x > 0 and y > 0:
    if dp[y][x] == dp[y - 1][x]:
        y -= 1
    elif dp[y][x] == dp[y][x - 1]:
        x -= 1
    else:
        x -= 1
        y -= 1
        ans = strA[x] + ans

print(ans)

Buggy python submission (verdict: Runtime Error):
# 最長共通部分　LCS
strA = input()
strB = input()
### 一致したら左上+1、そうでない場合は上か左のMAX
# / | 0 | A | B | C | B | A |
# 0 | 0 | 0 | 0 | 0 | 0 | 0 |
# B | 0 | 0 | 1 | 1 | 1 | 1 |
# B | 0 | 0 | 1 | 1 | 2 | 2 |
# A | 0 | 0 | 1 | 1 | 2 | 3 |
dp = [[0] * (len(strA) + 1) for _ in range(len(strB) + 1)]

for i, A in enumerate(strA, 1):
    for j, B in enumerate(strB, 1):
        if A == B:
            dp[j][i] = dp[j - 1][i - 1] + 1
        else:
            dp[j][i] = max(dp[j - 1][i], dp[j][i - 1])
ans = ""
cnt = 1
lstAns = dp[-1]
for DP in lstAns:
    if cnt == DP:
        cnt += 1
        ans += strB[cnt - 1]
print(ans)

Fixed submission:
# 最長共通部分　LCS ***未完成***
strA = input()
strB = input()
### 一致したら左上+1、そうでない場合は上か左のMAX
# / | 0 | A | B | C | B | A |
# 0 | 0 | 0 | 0 | 0 | 0 | 0 |
# B | 0 | 0 | 1 | 1 | 1 | 1 |
# B | 0 | 0 | 1 | 1 | 2 | 2 |
# A | 0 | 0 | 1 | 1 | 2 | 3 |
dp = [[0] * (len(strA) + 1) for _ in range(len(strB) + 1)]

for i, A in enumerate(strA, 1):
    for j, B in enumerate(strB, 1):
        if A == B:
            dp[j][i] = dp[j - 1][i - 1] + 1
        else:
            dp[j][i] = max(dp[j - 1][i], dp[j][i - 1])
ans = ""
cnt = 1
lstAns = dp[-1]
x, y = len(strA), len(strB)
while x > 0 and y > 0:
    if dp[y][x] == dp[y - 1][x]:
        y -= 1
    elif dp[y][x] == dp[y][x - 1]:
        x -= 1
    else:
        x -= 1
        y -= 1
        ans = strA[x] + ans

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int,input().split())
A = [list(map(int,input().split())) for z in range(M)]
a = sorted(A)

MAP = [[0] for b in range(N + 1)]

for i in range(M):
    x, y = A[i]
    MAP[x].append(y)
    MAP[x].sort()

for j in range(M):
    ans = str(A[j][0]).zfill(6)
    ans += str(MAP[A[j][0]].index(A[j][1])).zfill(6)

    print(ans)

Fixed submission:
N, M = [int(_) for _ in input().split()]
PY = [[int(_) for _ in input().split()] + [_] for _ in range(M)]
# 2番目のKeyでソート
PY.sort(key = lambda x : x[1])
# 順番カウント用
cnt = [0] * (N + 1)
ans = [""] * M

for p, y, i in PY:
    # 何番目かカウント
    cnt[p] += 1
    # 答え
    ans[i] = str(p).zfill(6) + str(cnt[p]).zfill(6)

print("\n".join(ans))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict as dict
d = dict(int)

N, M = map(int,input().split())
A = [list(map(int,input().split())) for z in range(M)]
a = sorted(A)
b = [[0, 0] for z in range(M + 1)]
for i in range(1, M + 1):
    x, y = a[i - 1]
    if b[i - 1][0] != x:
        cnt = 1

    b[i] = [x, str(x).zfill(6) + str(cnt).zfill(6)]
    cnt += 1

for j in range(M):
    print(b[a.index(A[j]) + 1][1])



Fixed submission:
N, M = [int(_) for _ in input().split()]
PY = [[int(_) for _ in input().split()] + [_] for _ in range(M)]
# 2番目のKeyでソート
PY.sort(key = lambda x : x[1])
# 順番カウント用
cnt = [0] * (N + 1)
ans = [""] * M

for p, y, i in PY:
    # 何番目かカウント
    cnt[p] += 1
    # 答え
    ans[i] = str(p).zfill(6) + str(cnt[p]).zfill(6)

print("\n".join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
S = [str(i) for i in input()]
T = [str(i) for i in input()]
ans = "Yes"

for j in range(len(S)):
    IDXs = [i for i, x in enumerate(S) if x == S[j]]
    IDXt = [i for i, x in enumerate(T) if x == T[j]]

    if IDXs != IDXt:
        ans = "No"
        break

print(ans)

Fixed submission:
S = [str(i) for i in input()]
T = [str(i) for i in input()]
ans = "Yes"

for j in range(len(S)):
    if S[j] == 0:
        continue

    IDXs = [i for i, x in enumerate(S) if x == S[j]]
    IDXt = [i for i, x in enumerate(T) if x == T[j]]

    if IDXs != IDXt:
        ans = "No"
        break

    for k in range(len(IDXs)):
        S[IDXs[k]] = 0
        T[IDXs[k]] = 0

print(ans)