Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#coding: utf-8
from collections import defaultdict
import sys

H, W, M = (int(x) for x in input().split())

NH = [[0, i] for i in range(H)]
NW = [[0, i] for i in range(W)]

B = []
for i in range(M):
    h, w = (int(x)-1 for x in input().split())
    B.append((h, w))
    NH[h][0] += 1
    NW[w][0] += 1

NH.sort(reverse=True)
NW.sort(reverse=True)
maxH = NH[0][0]
maxW = NW[0][0]

for i in range(H):
    countH, idxH = NH[i] 
    if countH != maxH:
        break

    for j in range(W):
        countW, idxW = NW[j] 
        if countW!= maxW:
            break

        if (idxH, idxW) not in B:
            print(maxH + maxW)
            sys.exit(0)

print(maxH + maxW - 1)



Fixed submission:
#coding: utf-8
from collections import defaultdict
import sys

H, W, M = (int(x) for x in input().split())

NH = [[0, i] for i in range(H)]
NW = [[0, i] for i in range(W)]

B = defaultdict(int) 
for i in range(M):
    h, w = (int(x)-1 for x in input().split())
    B[(h, w)] = 0
    NH[h][0] += 1
    NW[w][0] += 1

NH.sort(reverse=True)
NW.sort(reverse=True)
maxH = NH[0][0]
maxW = NW[0][0]

for i in range(H):
    countH, idxH = NH[i] 
    if countH != maxH:
        break

    for j in range(W):
        countW, idxW = NW[j] 
        if countW!= maxW:
            break

        if (idxH, idxW) not in B:
            print(maxH + maxW)
            sys.exit(0)

print(maxH + maxW - 1)
Buggy python submission (verdict: Runtime Error):
coding: utf-8

import bisect
import math

N, M = (int(v) for v in input().split())

seen = {}
WA = {}

acs = 0
was = 0

for i in range(M):
    q, tmp = input().split()
    if tmp == "AC":
        if q not in seen:
            acs += 1
            if q not in WA:
                WA[q] = 0
            was += WA[q]
            seen[q] = 1
    else:
        if q not in WA:
            WA[q] = 1
        else:
            WA[q] += 1

print (acs, was)



Fixed submission:
#coding: utf-8

import bisect
import math

N, M = (int(v) for v in input().split())

seen = {}
WA = {}

acs = 0
was = 0

for i in range(M):
    q, tmp = input().split()
    if tmp == "AC":
        if q not in seen:
            acs += 1
            if q not in WA:
                WA[q] = 0
            was += WA[q]
            seen[q] = 1
    else:
        if q not in WA:
            WA[q] = 1
        else:
            WA[q] += 1

print (acs, was)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/python3
#coding: utf-8

S = input()
ret = 0

# 山を下る
i = 0
while S[i] == ">":
    i += 1
    ret += i

# 山を登って降りる
n_up = 0
n_down = 0
while i < len(S):
    n_up = 0
    n_down = 0
    while i < len(S) and S[i] == "<":
        n_up += 1
        i += 1
        if i >= len(S):
            break
    while i < len(S) and S[i] == ">":
        n_down += 1
        i += 1
        if i >= len(S):
            break
    if n_up < n_down:
        n_up, n_down = n_down, n_up

    ret += ((n_up+1) * n_up) // 2
    ret += (n_down * (n_down-1)) // 2
    
print(ret)

Fixed submission:
#!/usr/bin/python3
#coding: utf-8

S = input()
ret = 0

# 山を下る
i = 0
while i < len(S) and S[i] == ">":
    i += 1
    ret += i

# 山を登って降りる
n_up = 0
n_down = 0
while i < len(S):
    n_up = 0
    n_down = 0
    while i < len(S) and S[i] == "<":
        n_up += 1
        i += 1
        if i >= len(S):
            break
    while i < len(S) and S[i] == ">":
        n_down += 1
        i += 1
        if i >= len(S):
            break
    if n_up < n_down:
        n_up, n_down = n_down, n_up

    ret += ((n_up+1) * n_up) // 2
    ret += (n_down * (n_down-1)) // 2
    
print(ret)
Buggy python submission (verdict: Runtime Error):
#include <math.h>

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<double> V(N);
  for (size_t i = 0; i < N; i++) {
    cin >> V[i];
  }

  while (V.size() != 1) {
    sort(V.rbegin(), V.rend());
    int a = V.back();
    V.pop_back();
    int b = V.back();
    V.pop_back();
    V.push_back((double)(a + b) / (double)2.0);
  }

  printf("%lf\n", V[0]);

  return 0;
}


Fixed submission:
#coding: utf-8

N = int(input())
V = [int(v) for v in input().split()]

for i in range(N-1):
    V.sort()
    V.append((V[0]+V[1])/2)
    V = V[2:]

print (V[0])

Buggy python submission (verdict: Runtime Error):
#include <math.h>

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<double> V(N);
  for (size_t i = 0; i < N; i++) {
    cin >> V[i];
  }

  while (V.size() != 1) {
    sort(V.rbegin(), V.rend());
    int a = V.back();
    V.pop_back();
    int b = V.back();
    V.pop_back();
    V.push_back((double)(a + b) / (double)2.0);
  }

  printf("%lf\n", V[0]);

  return 0;
}


Fixed submission:
#coding: utf-8

N = int(input())
V = [int(v) for v in input().split()]

for i in range(N-1):
    V.sort()
    V.append((V[0]+V[1])/2)
    V = V[2:]

print (V[0])

Buggy python submission (verdict: Runtime Error):
#include <math.h>

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<long double> V(N);
  for (size_t i = 0; i < N; i++) {
    cin >> V[i];
  }

  while (V.size() != 1) {
    sort(V.rbegin(), V.rend());
    int a = V.back();
    V.pop_back();
    int b = V.back();
    V.pop_back();
    V.push_back((long double)(a + b) / (long double)2.0);
  }

  printf("%lf\n", V[0]);

  return 0;
}


Fixed submission:
#coding: utf-8

N = int(input())
V = [int(v) for v in input().split()]

for i in range(N-1):
    V.sort()
    V.append((V[0]+V[1])/2)
    V = V[2:]

print (V[0])
Buggy python submission (verdict: Runtime Error):
n=int(input())%1000
print(n is 0 0 else 1000-n)


Fixed submission:
n=int(input())%1000
print(0 if n==0 else 1000-n)
Buggy python submission (verdict: Runtime Error):
print(int(input()) * int(input()))

Fixed submission:
a, b = map(int, input().split())
print(a * b)
Buggy python submission (verdict: Runtime Error):
a = {0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
print(a[int(input())])

Fixed submission:
a = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(a[int(input())])
Buggy python submission (verdict: Runtime Error):
S=input()
ans = 111111111
for i in range(2,9):
    temp = abs(753 - (100 * int(S[i - 2]) + 10 * int(S[i - 1]) + int(S[i])))
    ans = min(ans, temp)
print(ans)

Fixed submission:
S=input()
ans = 111111111
for i in range(2,len(S)):
    temp = abs(753 - (100 * int(S[i - 2]) + 10 * int(S[i - 1]) + int(S[i])))
    ans = min(ans, temp)
print(ans)

Buggy python submission (verdict: Runtime Error):
S=input()
ans = 111111111;
for i in range(2,10):
    temp = abs(753 - (100 * int(S[i - 2]) + 10 * int(S[i - 1]) + int(S[i])))
    ans = min(ans, temp)
print(ans)

Fixed submission:
S=input()
ans = 111111111
for i in range(2,len(S)):
    temp = abs(753 - (100 * int(S[i - 2]) + 10 * int(S[i - 1]) + int(S[i])))
    ans = min(ans, temp)
print(ans)
Buggy python submission (verdict: Runtime Error):
a=input()
b=input()

if a > b:
    printf("GREATER")
elif a < b:
    print("LESS")
else:
    print("EQUAL")

Fixed submission:
a=int(input())
b=int(input())

if a > b:
    print("GREATER")
elif a < b:
    print("LESS")
else:
    print("EQUAL")
Buggy python submission (verdict: Runtime Error):
print(int(input())*int(input()))

Fixed submission:
A, B = list(map(int, input().split()))
print(A*B)
Buggy python submission (verdict: Time Limit Exceeded):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
X = int(input())
soin = factorization(X)
small = soin[0][0]

for i in range(10**9):
    if i**5-(i-small)**5==X:
        print(i,i-small)
        break

Fixed submission:
X = int(input())

flag = False
for a in range(-118,120):
    for b in range(-119,119):
        if a**5-b**5==X:
            print(a,b)
            flag = True
            break
    if flag:
        break
Buggy python submission (verdict: Runtime Error):
S, W = int(input())

if S < W:
    print("unsafe")
else:
    print("safe")

Fixed submission:
S, W = map(int, input().split())

if S <= W:
    print("unsafe")
else:
    print("safe")
Buggy python submission (verdict: Runtime Error):
import collections

N = int(input())
S = []

for i in range(N):
    S.append(input())

c = collections.counter(S)

print(len(c))


Fixed submission:
import collections

N = int(input())
S = []

for i in range(N):
    S.append(input())

c = collections.Counter(S)

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

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

c = collections.Counter(A)

for i in range(1,N+1):
    print(A.count(i))

Fixed submission:
import collections

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

c = collections.Counter(A)

for i in range(1,N+1):
    print(c[i])
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

K = int(input())
S = 0

for i in range(1,K+1):
    if i==1:
        S+=K*K
        continue
    for j in range(1,K+1):
        if j==1:
            S+=K
            continue
        for k in range(1,K+1):
            if k==1:
                S+=1
            else:
                S += gcd(i,j,k)

print(S)


Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

K = int(input())
S = 0

for i in range(1,K+1):
    for j in range(i+1,K+1):
        for k in range(j+1,K+1):
            S += gcd(i,j,k)*6

for i in range(1,K+1):
    for j in range(i+1,K+1):
        S+= gcd(i,j)*6

for i in range(1,K+1):
    S+=i

print(S)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

K = int(input())
S = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            S += gcd(i,j,k)

print(S)


Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

K = int(input())
S = 0

for i in range(1,K+1):
    for j in range(i+1,K+1):
        for k in range(j+1,K+1):
            S += gcd(i,j,k)*6

for i in range(1,K+1):
    for j in range(i+1,K+1):
        S+= gcd(i,j)*6

for i in range(1,K+1):
    S+=i

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

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

c = collections.Counter(A)
#print(c)

csum = 0
for i in c.values():
    if i == 1:
        csum += 0
    else:
        csum += combinations_count(i, 2)

#print(csum)

#print(A)
for i in A:
    #print(c[i], i)
    if c[i] == 1:
        print(csum)
    elif c[i] == 2:
        print(csum-1)
    else:
        print(csum - combinations_count(c[i], 2) + combinations_count(c[i]-1, 2))


Fixed submission:
import collections
import math

def combinations_count2(n):
    return n*(n-1) // 2

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

c = collections.Counter(A)
#print(c)

d = {}
csum = 0
for i,j in c.items():
    if j == 1:
        d[i] = 0
        csum += 0
    else:
        d[i] =  combinations_count2(j)
        csum += d[i]

#print(c)
#print(d)
#print(csum)

#print(A)
for i in A:
    #print(c[i], i)
    if c[i] == 1:
        print(csum)
    elif c[i] == 2:
        print(csum-1)
    else:
        print(csum - combinations_count2(c[i]) + combinations_count2(c[i]-1))
Buggy python submission (verdict: Time Limit Exceeded):
def pow(x, n, mod):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = ans*x % mod
    x = x*x % mod
    n = n >> 1
  return ans

def kaijou_k(n, k, mod):
    a = 1
    for i in range(k, n+1):
        a *= i % mod
    return a

def main():
    n, a, b = map(int, input().split())
    mod = 10**9 +7
    allsum = pow(2, n, mod)-1
    abunbo = kaijou_k(n, n-a+1, mod)
    abunsi = kaijou_k(a, 1, mod)
    asum = abunbo * pow(abunsi, mod-2, mod) % mod
    bbunbo = kaijou_k(n, n-b+1, mod)
    bbunsi = kaijou_k(b, 1, mod)
    bsum = bbunbo * pow(bbunsi, mod-2, mod) % mod
    ans = allsum - asum - bsum
    print(ans)
    
if __name__ == '__main__':
    main()

Fixed submission:
def pow(x, n, mod):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = ans*x % mod
    x = x*x % mod
    n = n >> 1
  return ans

def kaijou_k(n, k, mod):
    a = 1
    for i in range(k, n+1):
        a *= i
        a %= mod
    return a %mod

def main():
    n, a, b = map(int, input().split())
    mod = 10**9 +7
    allsum = pow(2, n, mod)-1
    abunbo = kaijou_k(n, n-a+1, mod)
    abunsi = kaijou_k(a, 1, mod)
    asum = abunbo * pow(abunsi, mod-2, mod) % mod
    bbunbo = kaijou_k(n, n-b+1, mod)
    bbunsi = kaijou_k(b, 1, mod)
    bsum = bbunbo * pow(bbunsi, mod-2, mod) % mod
    ans = (allsum - asum - bsum) % mod
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = input().split()

flag = 0
for i in range(len(A)):
    for j in range(i+1,len(A)):
        if(A[i]==A[j]):
            flag = 1

if(flag == 0):
    print("YES")
else:
    print("NO")


Fixed submission:
N = int(input())
A = input().split()

if(len(A)) == len(set(A)):
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int,input().split())
p = list(map(int,input().split()))

#print(sum(p[1:4]))
maxid = 0
for i in range(N - (K-1)):
    if(sum(p[maxid:(maxid+K)]) < sum(p[i:(i+K)])):
        maxid = i

maxsum = 0
for i in range(K):
    maxsum += ((p[maxid+i]*(p[maxid+i]+1))/2)/p[maxid+i]

print(maxsum)



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

S = 0
maxsum = 0
for i in range(K):
    S += (p[i]+1)/2

for i in range(K,N):
    if(maxsum < S):
        maxsum = S
    S = S + (p[i]+1)/2 - (p[i-K]+1)/2

if(maxsum < S):
    maxsum = S

print(maxsum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))

count = 1
for i in range(1,N):
    for j in range(i):
        if(P[i]>P[j]):
            break
        elif(i == j + 1):
            count+=1

print(count)



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

Pmin = float("inf")
count = 0
for i in P:
    if i < Pmin:
        Pmin = i
        count += 1

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

count = 0
for i in range(1,N+1):
    li = i//10**(len(str(i))-1) 
    ri = i%10
    for j in range(i,N+1):
        lj = j//10**(len(str(j))-1)
        rj = j%10
        if li == rj and lj == ri:
            if i == j:
                count += 1
            else:
                count += 2

print(count)

Fixed submission:
N = int(input())
c = [[0]*9 for _ in range(9)]
count = 0
for i in range(1,N+1):
    li = i//10**(len(str(i))-1) 
    ri = i%10
    if ri == 0:
        continue
    c[li-1][ri-1] += 1

for i in range(9):
    for j in range(9):
        count += c[i][j]*c[j][i]

print(count)
Buggy python submission (verdict: Runtime Error):
#Atcoderではmathではなく，fractionsを使用．
#a/2が全て同じ数の2の倍数を素因数に持つ必要がある．

import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def waru2(n):
    count = 0
    while True:
        if n % 2 == 0:
            n //= 2
            count += 1
        else:
            break
    return count

N, M = map(int, input().split())
a = list(map(int, input().split()))

half_a = []
waru = []

for i in a:
    half_a.append(i//2)
    waru.append(waru2(i))

if max(waru) == min(waru):
    half_lcm = lcm_list(half_a)
    print(-(-(M//half_lcm)//2))
else:
    print(0)

Fixed submission:
#Atcoderではmathではなく，fractionsを使用するため．基本fractions
#a/2が全て同じ数の2の倍数を素因数に持つ必要がある．

import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def waru2(n):
    count = 0
    while True:
        if n % 2 == 0:
            n //= 2
            count += 1
        else:
            break
    return count

N, M = map(int, input().split())
a = list(map(int, input().split()))

half_a = []
waru = []

for i in a:
    half_a.append(i//2)
    waru.append(waru2(i))

if max(waru) == min(waru):
    half_lcm = lcm_list(half_a)
    print(-(-(M//half_lcm)//2))
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N, M = map(int, input().split())
a = list(map(int, input().split()))
half_a = []

for i in a:
    half_a.append(i//2)

half_lcm = lcm_list(half_a)

count = 0
print(-(-(M//half_lcm)//2))


Fixed submission:
#Atcoderではmathではなく，fractionsを使用するため．基本fractions
#a/2が全て同じ数の2の倍数を素因数に持つ必要がある．

import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def waru2(n):
    count = 0
    while True:
        if n % 2 == 0:
            n //= 2
            count += 1
        else:
            break
    return count

N, M = map(int, input().split())
a = list(map(int, input().split()))

half_a = []
waru = []

for i in a:
    half_a.append(i//2)
    waru.append(waru2(i))

if max(waru) == min(waru):
    half_lcm = lcm_list(half_a)
    print(-(-(M//half_lcm)//2))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())

MON = 6
ANS =6-A-B
print(ANS)

Fixed submission:
A = int(input())
B = int(input())

MON = 6
ANS = 6-A-B
print(ANS)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
c = 0
if (N % 2) == 0:
    for i in range(N,2,-2):
        for j in range(1,10):
            if i % 5**j == 0:
                c += 1
            else:
                break
    print(c)
else:
    print(0)

Fixed submission:
N = int(input())
count = 0
mul = 10

if (N % 2) == 0:
    while True:
        count += N // mul
        mul *= 5
        if mul > N: break
    print(count)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
#1:初期化
N = int(input())
a = []
r_append = a.append()
for i in range(N):
    r_append(list(map(int,input().split())))
dp = [[0]*3 for _ in range (N+1)]
#print(dp, sep="\n")
#print(a, sep="\n")

#2:初期値(元からゼロなので記述無し)

#3:dp実行部(貰うDP)
for i in range(1,N+1):
    for j in range(3):
        for k in range(3):
            if(j == k):
                continue
            dp[i][j] = max(dp[i][j], dp[i-1][k]+a[i-1][j]) #dpは[1]からだが，aは[0]からに注意

#4:出力
dpmax = 0
for i in range(3):
    dpmax= max(dp[N][i], dpmax)
#print(*dp, sep="\n")
print(dpmax)


Fixed submission:
#1:初期化
N = int(input())
a = []
for i in range(N):
    a.append(list(map(int,input().split())))
dp = [[0]*3 for _ in range (N+1)]
#print(dp, sep="\n")
#print(a, sep="\n")

#2:初期値(元からゼロなので記述無し)

#3:dp実行部(貰うDP)
for i in range(1,N+1):
    for j in range(3):
        for k in range(3):
            if(j == k):
                continue
            dp[i][j] = max(dp[i][j], dp[i-1][k]+a[i-1][j]) #dpは[1]からだが，aは[0]からに注意

#4:出力
dpmax = 0
for i in range(3):
    dpmax= max(dp[N][i], dpmax)
#print(*dp, sep="\n")
print(dpmax)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    #1:初期化
    s = input()
    t = input()
    limit = 7
    dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]

    #2:初期値(いらない)

    #3:dp実行部(貰うDP)or(配るDP)
    for i in range(len(s)):
        for j in range(len(t)):
            if s[i]==t[j]:
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]+1)
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j])
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1])

    #4:出力
    #print(*dp,sep="\n")
    res = ""
    s_len = len(s)
    t_len = len(t)
    while s_len > 0 and t_len > 0:
        if dp[s_len][t_len] == dp[s_len-1][t_len]:
            s_len -= 1
        elif dp[s_len][t_len] == dp[s_len][t_len-1]:
            t_len -= 1
        else:
            res = s[s_len-1] + res
            s_len -= 1
            t_len -= 1
    print(res)
        

if __name__ == '__main__':
    main()

Fixed submission:
"""memo
    いつものように，numpyを使いたくなかったので他人のコードを参考にした．
    enumerateは「https://note.nkmk.me/python-enumerate-start/」を参考．
"""

def main2():
    #1:初期化
    s = input()
    t = input()
    v = [0] * (len(t) + 1)
    dp = [v]
    #print(v)
    #print(dp)

    #2:初期値(いらない)

    #3:dp実行部(貰うDP)
    for str1 in s:
        v = v.copy()
        #print(i, str1, u, v)
        dp.append(v)
        #print("in",*dp,sep="\n")
        ll, ul = 0, 0
        for j, str2 in enumerate(t, 1):
            uu = v[j]
            if str1 == str2:
                v[j] = ll = ul + 1
            else:
                if ll > uu:
                    v[j] = ll
                else:
                    ll = uu
            ul = uu
        #print("out",*dp,sep="\n")
            
    # #4:出力
    #print(*dp,sep="\n")
    res = ""
    s_len = len(s)
    t_len = len(t)
    while s_len > 0 and t_len > 0:
        if dp[s_len][t_len] == dp[s_len-1][t_len]:
            s_len -= 1
        elif dp[s_len][t_len] == dp[s_len][t_len-1]:
            t_len -= 1
        else:
            res = s[s_len-1] + res
            s_len -= 1
            t_len -= 1
    print(res)

if __name__ == '__main__':
    main2()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

H,W,M = map(int, input().split())

count_H = [0 for _ in range(H)]
count_W = [0 for _ in range(W)]
bomb = set()

for _ in range(M):
  h,w = map(int, input().split())
  bomb.add((h-1,w-1))
  count_H[h-1] += 1
  count_W[w-1] += 1

def argmax(L):
  indeices = []
  maximum = 0
  for i in range(len(L)):
    if L[i]>maximum:
      indices = [i]
      maximum = L[i]
    elif L[i]==maximum:
      indices.append(i)
  return indices, maximum

indices_H, max_H = argmax(count_H)
indices_W, max_W = argmax(count_W)

answer = max_H + max_W - 1
flg = -1
for h in indices_H:
  for w in indices_W:
    if (h,w) not in bomb:
      answer = max_H + max_W
      flg = 0
      break
  if flg == 0:
    break

print(answer)

Fixed submission:
# -*- coding: utf-8 -*-

H,W,M = map(int, input().split())

count_H = [0 for _ in range(H)]
count_W = [0 for _ in range(W)]
bomb = set()

for _ in range(M):
  h,w = map(int, input().split())
  bomb.add((h-1,w-1))
  count_H[h-1] += 1
  count_W[w-1] += 1

def argmax(L):
  indices = []
  maximum = -1
  for i in range(len(L)):
    if L[i] > maximum:
      indices = [i]
      maximum = L[i]
    elif L[i] == maximum:
      indices.append(i)
  return indices,maximum

indices_H,max_H = argmax(count_H)
indices_W,max_W = argmax(count_W)

answer = max_H + max_W - 1
flg = -1
for h in indices_H:
  for w in indices_W:
    if (h,w) not in bomb:
      answer = max_H + max_W
      flg = 0
      break
  if flg == 0:
    break

print(answer)