Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [input() for _ in range(N)]

D = [[0 for j in range(40)] for i in range(60)]

for a in A:
    #まずは分子の整数Bと分母の指数kに分けていく
    B=0;k=0
    for j in range(len(a)):
        if a[j]!='.':
            B=B*10
            B=B+int(a[j])
        if a[j]=='.':
            k=len(a)-j-1
    
    #次にBに2と5がいくつ含まれるかを求める
    t=0;f=0
    b=B
    while b%2==0:
        t+=1
        b=b//2
    b=B
    while b%5==0:
        f+=1
        b=b//5
    
    #D[t-k][f-k]をインクリメントする
    #…と言いたいところだがマイナスになりうるので+10したものを入れる
    
    D[t-k+10][f-k+10]+=1
    

Ans=0
for i in range(len(D)):
    for j in range(len(D[i])):
        for k in range(len(D)):
            for l in range(len(D[k])):
                #(hoge*2^i*5^j)*(fuga*2^k*5^l)がOKならAnsに足し入れる
                if i+k-20>=0 and j+l-20>=0 and not(i==k and j==l):
                    Ans = Ans+D[i][j]*D[k][l]

#D[i][j]*D[k][l]とD[i][l]*D[i][j]で同じものを２回かけているので2で割っておく
Ans = Ans//2

#違うA_iでも同じt-k,f-kを持つことはある
#ので、それを処理する
for i in range(len(D)):
    for j in range(len(D[i])):
        if i-10>=0 and j-10>=0:
            Ans = Ans + D[i][j]*(D[i][j]-1)//2

print(Ans)        

Fixed submission:
N = int(input())
A = [input() for _ in range(N)]

D = [[0 for j in range(40)] for i in range(60)]

for a in A:
    #まずは分子の整数Bと分母の指数kに分けていく
    B=0;k=0
    for j in range(len(a)):
        if a[j]!='.':
            B=B*10
            B=B+int(a[j])
        if a[j]=='.':
            k=len(a)-j-1
    
    #次にBに2と5がいくつ含まれるかを求める
    t=0;f=0
    b=B
    while b%2==0:
        t+=1
        b=b//2
    b=B
    while b%5==0:
        f+=1
        b=b//5
    
    #D[t-k][f-k]をインクリメントする
    #…と言いたいところだがマイナスになりうるので+10したものを入れる
    
    D[t-k+10][f-k+10]+=1
    

Ans=0
for i in range(len(D)):
    for j in range(len(D[i])):
        for k in range(len(D)):
            for l in range(len(D[k])):
                #(hoge*2^i*5^j)*(fuga*2^k*5^l)がOKならAnsに足し入れる
                if i+k-20>=0 and j+l-20>=0 and not(i==k and j==l):
                    Ans = Ans+D[i][j]*D[k][l]

#D[i][j]*D[k][l]とD[i][l]*D[i][j]で同じものを２回かけているので2で割っておく
Ans = Ans//2

#違うA_iでも同じt-k,f-kを持つことはある
#ので、それを処理する
for i in range(len(D)):
    for j in range(len(D[i])):
        if i-10>=0 and j-10>=0:
            Ans = Ans + D[i][j]*(D[i][j]-1)//2

print(Ans)
Buggy python submission (verdict: Runtime Error):
def solve():
  N = int(input())
  lines = [input().split() for i in range(N)]
  for d,e in lines:
    if d==e:
      count += 1
      if count>=3:
        print("Yes")
        return
    else:
      count = 0
  print("No")
  return

solve()

Fixed submission:
def solve():
  N = int(input())
  lines = [input().split() for i in range(N)]
  count = 0
  for d,e in lines:
    if d==e:
      count += 1
      if count>=3:
        print("Yes")
        return
    else:
      count = 0
  print("No")
  return

solve()
Buggy python submission (verdict: Runtime Error):
X,N = map(int,input().split(" "))
p = list(map(int,input().split(" ")))
for k in range(200):
  temp = X-k
  if temp not in p:
    print(temp)
    break
  semp = X+k
  if semp not in p:
    print(semp)
    break

Fixed submission:
X,N = map(int,input().split(" "))
if N==0:
  print(X)
else:
  p = list(map(int,input().split(" ")))
  for k in range(200):
    temp = X-k
    if temp not in p:
      print(temp)
      break
    semp = X+k
    if semp not in p:
      print(semp)
      break
Buggy python submission (verdict: Runtime Error):
A,V,B,W,T = map(int,input().split(" "))
kyori = abs(A-B)
dif = V-W
if dif>0:
  if kyori/dif<=T:
    print("OK")
  else:
    print("NO")
else:
  print("NO")

Fixed submission:
A,V = map(int,input().split(" "))
B,W = map(int,input().split(" "))
T, = map(int,input().split(" "))
kyori = abs(A-B)
dif = V-W
if dif>0:
  if kyori/dif<=T:
    print("YES")
  else:
    print("NO")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(len(a)) :
	if a[i] == 0:
		print(0)
		exit(1)
for i in range(len(a)) :
	ans *= a[i]
	if ans > 1e18 :
		print(-1)
		exit(1)
print(ans)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
ans = 1
zero = 0
over = 0
for i in range(len(a)) :
	if a[i] == 0 :
		zero = 1
for i in range(len(a)) :
	if over : break
	ans *= a[i]
	if ans > 1e18 :
		over = 1
if zero : print(0)
elif over : print(-1)
else : print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
 
cnt = 0
for r in range(1, n):
    a = r * (n - r)
    for i in range(a, 0, -r):
        if i < n:
            cnt += i // r
            break
 
print(cnt)

Fixed submission:
n = int(input())
print(sum((n - 1) // i for i in range(1, n)))

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

cnt = 0
for r in range(1, n):
    a = r * (n - r)
    for i in range(a, 0, -r):
        if i < n:
            cnt += i // r
            break

print(cnt)

Fixed submission:
n = int(input())
print(sum((n - 1) // i for i in range(1, n)))
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()
d = len(S) - len(T)
print(len(T) - max(sum(t == s for t, s in zip(T, S[i : i + d + 1])) for i in range(d)))

Fixed submission:
S = input()
T = input()
d = len(S) - len(T)
print(len(T) - max(sum(t == s for t, s in zip(T, S[i : i + len(T) + 1])) for i in range(d + 1)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
money = 1000
stock = 0
(*a,) = map(int, input().split())

for i in range(n - 1):
    if a[i] < a[i + 1]:
        stock += money // a[i]
        money = money % a[i]
    elif a[i] > a[i + 1]:
        money += stock * a[i]
        stock = 0
    else:
        pass
money += stock * a[-1]
print(money)

Fixed submission:
x = int(input())
if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
else:
    print(1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

input = sys.stdin.readline

n, k = map(int, input().split())
a = list(map(int, input().split()))

tmp1 = 1
tmp2 = 1
for i in range(k):
    tmp1 *= a[i]

for i in range(k, n):
    tmp2 = (tmp1 // a[i - k]) * a[i]
    print(["No", "Yes"][tmp1 < tmp2])
    tmp1 = tmp2

Fixed submission:
import sys

input = sys.stdin.readline

import sys

input = sys.stdin.readline

n, k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(k, n):
    print(["No", "Yes"][a[i - k] < a[i]])

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

input = sys.stdin.readline

n, k = map(int, input().split())
a = list(map(int, input().split()))

tmp1 = 1
tmp2 = 1
for i in range(k):
    tmp1 *= a[i]

for i in range(k, n):
    tmp2 = (tmp1 // a[i - k]) * a[i]
    print(["No", "Yes"][tmp1 < tmp2])
    tmp1 = tmp2

Fixed submission:
import sys

input = sys.stdin.readline

import sys

input = sys.stdin.readline

n, k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(k, n):
    print(["No", "Yes"][a[i - k] < a[i]])
Buggy python submission (verdict: Runtime Error):
count = 0
a = input()
b = input()

for i in len(a):
    if a[i]!=b[i]:
        count += 1

print(count)

Fixed submission:
count = 0
a = input()
b = input()

for i in range(len(a)):
    if a[i]!=b[i]:
        count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate

n, m, k = map(int, input().split())
(*a,) = accumulate(map(int, input().split()))
(*b,) = accumulate(map(int, input().split()))
a = (0,) + tuple(i for i in a if i <= k)
b = (0,) + tuple(i for i in b if i <= k)
ans = 0
for i in range(len(a)):
    tmp = k - a[i]
    for j in range(len(b) - 1, -1, -1):
        if b[j] <= tmp:
            ans = max(ans, i + j)
            break
print(ans)

Fixed submission:
from itertools import accumulate
from bisect import bisect

n, m, k = map(int, input().split())
(*a,) = accumulate(map(int, input().split()))
(*b,) = accumulate(map(int, input().split()))
a = (0,) + tuple(i for i in a if i <= k)
b = tuple(i for i in b if i <= k)
print(max(i + bisect(b, k - a[i]) for i in range(len(a))))

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate

n, m, k = map(int, input().split())
(*a,) = accumulate(map(int, input().split()))
(*b,) = accumulate(map(int, input().split()))
a = (0,) + tuple(i for i in a if i <= k)
b = (0,) + tuple(i for i in b if i <= k)
ans = set()
for i in range(len(a)):
    tmp = k - a[i]
    for j in range(len(b) - 1, -1, -1):
        if b[j] <= tmp:
            ans.add(i + j)
            break
print(max(ans))

Fixed submission:
from itertools import accumulate
from bisect import bisect

n, m, k = map(int, input().split())
(*a,) = accumulate(map(int, input().split()))
(*b,) = accumulate(map(int, input().split()))
a = (0,) + tuple(i for i in a if i <= k)
b = tuple(i for i in b if i <= k)
print(max(i + bisect(b, k - a[i]) for i in range(len(a))))

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate

n, m, k = map(int, input().split())
(*a,) = accumulate(map(int, input().split()))
(*b,) = accumulate(map(int, input().split()))
a = (0,) + tuple(i for i in a if i <= k)
b = (0,) + tuple(i for i in b if i <= k)
ans = set()
for i in range(len(a)):
    tmp = k - a[i]
    for j in range(len(b) - 1, -1, -1):
        if b[j] <= tmp:
            ans.add(i + j)
            break
print(max(ans))


Fixed submission:
from itertools import accumulate
from bisect import bisect

n, m, k = map(int, input().split())
(*a,) = accumulate(map(int, input().split()))
(*b,) = accumulate(map(int, input().split()))
a = (0,) + tuple(i for i in a if i <= k)
b = tuple(i for i in b if i <= k)
print(max(i + bisect(b, k - a[i]) for i in range(len(a))))
Buggy python submission (verdict: Time Limit Exceeded):
ans = 1
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    ans *= a[i]

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

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

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

Buggy python submission (verdict: Runtime Error):
ans = 1
n = input()
a = list(map(int, input().split()))

for i in range(n):
    ans *= a[i]

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

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

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

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

for i in a:
    ans *= i

if ans > 1000000000000000000:
    print(-1)
else:
    print(ans)

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

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

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

for i in a:
    ans *= i

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

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

if 0 in a:
    print(0)
else:
    for i in a:
        ans *= i
        if ans > 10 ** 18:
            print(-1)
            break
    else:
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
from itertools import product
from functools import reduce

l1 = [i for i in range(1, int(input()) + 1)]
print(sum(reduce(gcd, l) for l in product(l1, repeat=3)))


Fixed submission:
from math import gcd
from itertools import product
from functools import reduce

l1 = [i for i in range(1, int(input()) + 1)]
print(sum(reduce(gcd, l) for l in product(l1, repeat=3)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = tuple(map(int, input().split()))
pos = 0
j = 1

while True:
    for i, data in enumerate(a[pos:]):
        if data == j:
            pos += i + 1
            j += 1
            break
    else:
        print((-1, n - j + 1)[j != 1])
        break


Fixed submission:
n = int(input())
j = 1

for i in map(int, input().split()):
    if i == j:
        j += 1

print((-1, n - j + 1)[j != 1])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
from bisect import bisect_left

n = int(input())
l = sorted(map(int, input().split()))
ld = deque(l)
cnt = 0
for a in range(n - 2):
    l_a = ld.popleft()
    for b in range(a + 1, n - 1):
        cnt += bisect_left(l[b + 1 :], l_a + l[b])
print(cnt)

Fixed submission:
from collections import deque
from bisect import bisect_left

n = int(input())
l = sorted(map(int, input().split()))
ld = deque(l)
cnt = 0
for a in range(n - 2):
    l_a = ld.popleft()
    for b in range(a + 1, n - 1):
        cnt += bisect_left(l, l_a + l[b]) - b - 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

input()
l = sorted(map(int, input().split()))
print(sum(a + b > c for a, b, c in combinations(l, 3)))


Fixed submission:
from collections import deque
from bisect import bisect_left

n = int(input())
l = sorted(map(int, input().split()))
ld = deque(l)
cnt = 0
for a in range(n - 2):
    l_a = ld.popleft()
    for b in range(a + 1, n - 1):
        cnt += bisect_left(l, l_a + l[b]) - b - 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left

n = int(input())
l = sorted(map(int, input().split()))
cnt = 0
for a in range(n - 2):
    for b in range(a + 1, n - 1):
        cnt += bisect_left(l[b + 1 :], l[a] + l[b])
print(cnt)

Fixed submission:
from collections import deque
from bisect import bisect_left

n = int(input())
l = sorted(map(int, input().split()))
ld = deque(l)
cnt = 0
for a in range(n - 2):
    l_a = ld.popleft()
    for b in range(a + 1, n - 1):
        cnt += bisect_left(l, l_a + l[b]) - b - 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = sorted(map(int, input().split()))
cnt = 0
for a in range(n - 2):
    for b in range(a + 1, n - 1):
        for c in range(b + 1, n):
            if l[a] + l[b] > l[c]:
                cnt += 1
            else:
                break
print(cnt)

Fixed submission:
from collections import deque
from bisect import bisect_left

n = int(input())
l = sorted(map(int, input().split()))
ld = deque(l)
cnt = 0
for a in range(n - 2):
    l_a = ld.popleft()
    for b in range(a + 1, n - 1):
        cnt += bisect_left(l, l_a + l[b]) - b - 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = sorted(map(int, input().split()))
cnt = 0
for a in range(n - 2):
    for b in range(a + 1, n - 1):
        for c in range(b + 1, n):
            if l[a] + l[b] > l[c]:
                cnt += 1
            else:
                break
print(cnt)

Fixed submission:
from collections import deque
from bisect import bisect_left

n = int(input())
l = sorted(map(int, input().split()))
ld = deque(l)
cnt = 0
for a in range(n - 2):
    l_a = ld.popleft()
    for b in range(a + 1, n - 1):
        cnt += bisect_left(l, l_a + l[b]) - b - 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

for i in range(1, n):
    print(a.index(i) + 1, end=" ")

print(a.index(n) + 1)

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

for i in range(n):
    newa[a[i] - 1] = i + 1

print(*newa, sep=" ")
Buggy python submission (verdict: Time Limit Exceeded):
input()
(*a,) = map(int, input().split())
ma = max(a)

最小公倍数 = ma
while not all(最小公倍数 % i == 0 for i in set(a)):
    最小公倍数 += ma
ans = 最小公倍数 / sum(最小公倍数 // i for i in a)
print([ans, int(ans)][ans % 1 == 0])

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

ただの倍数 = 1
for i in set(a):
    ただの倍数 *= i
ans = ただの倍数 / sum(ただの倍数 // i for i in a)
print([ans, int(ans)][ans % 1 == 0])

Buggy python submission (verdict: Time Limit Exceeded):
input()
(*a,) = map(int, input().split())
ma = max(a)

最小公倍数 = ma
while True:
    if all(最小公倍数 % i == 0 for i in a):
        break
    最小公倍数 += ma
ans = 最小公倍数 / sum(最小公倍数 // i for i in a)
print([ans, int(ans)][ans % 1 == 0])

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

ただの倍数 = 1
for i in set(a):
    ただの倍数 *= i
ans = ただの倍数 / sum(ただの倍数 // i for i in a)
print([ans, int(ans)][ans % 1 == 0])
Buggy python submission (verdict: Runtime Error):
from itertools import combinations

l, r = map(lambda s: int(s) % 2019, input().split())
print(min((i * j) % 2019 for i, j in combinations(range(l, r + 1), 2)))

Fixed submission:
from itertools import combinations

n = 2019
l, r = map(int, input().split())
if l // n < r // n:
    print(0)
else:
    print(min((i * j) % n for i, j in combinations(range(l % n, r % n + 1), 2)))

Buggy python submission (verdict: Runtime Error):
from itertools import combinations

l, r = map(lambda s: int(s) % 2019, input().split())
print(
    (min((i * j) % 2019 for i, j in combinations(range(l, r + 1), 2)), 0)[
        r < l or l == 0
    ]
)

Fixed submission:
from itertools import combinations

n = 2019
l, r = map(int, input().split())
if l // n < r // n:
    print(0)
else:
    print(min((i * j) % n for i, j in combinations(range(l % n, r % n + 1), 2)))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
l, r = map(int, input().split())

ans = set(range(l, r + 1))
for _ in range(m - 1):
    l, r = map(int, input().split())
    ans &= set(range(l, r + 1))

print(len(ans))

Fixed submission:
n, m = map(int, input().split())
l, r = map(int, input().split())

for _ in range(m - 1):
    a, b = map(int, input().split())
    l = max(l, a)
    r = min(r, b)

print(max(0, r - l + 1))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate

n = int(input())
s = input()
t01 = s.replace("E", "0")
t01 = t01.replace("W", "1")
t10 = str(sum((1 - int(t01[n - i - 1])) * 10 ** i for i in range(n))).zfill(n)
l1 = [int(a) for a in t01]
l2 = [int(a) for a in t10]
left = [0] + list(accumulate(l1))[:-1]
right = list(accumulate(l2[::-1]))[-2::-1] + [0]
print(min(w + e for (w, e) in zip(left, right)))

Fixed submission:
from itertools import accumulate

n = int(input())
s = input()

t01 = ""
t10 = ""

for x in s:
    if x == "E":
        t01 += "0"
        t10 += "1"
    else:
        t01 += "1"
        t10 += "0"

l1 = [int(a) for a in t01]
l2 = [int(a) for a in t10]
left = [0] + list(accumulate(l1))[:-1]
right = list(accumulate(l2[::-1]))[-2::-1] + [0]
print(min(w + e for (w, e) in zip(left, right)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))
y = sorted(x)
for i in x:
    print((y[n // 2 - 1], y[n // 2])[i in y[: n // 2]])

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
y = sorted(x)
a = y[n // 2 - 1]
b = y[n // 2]
for i in x:
    print((a, b)[i <= a])
Buggy python submission (verdict: Runtime Error):
if b - a <= 0:
    print("delicious")
elif b - a <= x:
    print("safe")
else:
    print("dangerous")

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

if b - a <= 0:
    print("delicious")
elif b - a <= x:
    print("safe")
else:
    print("dangerous")
Buggy python submission (verdict: Time Limit Exceeded):
na = 1
a = []
b = []
n = int(input())

for i in range(n):
    a.append(int(input()))

for _ in range(n):
    if a[na - 1] in b:
        print(-1)
        break
    else:
        b.append(a[na - 1])
        if a[na - 1] == 2:
            print(len(b))
            break
        na = a[na - 1]

Fixed submission:
na = 0
a = []
b = []
n = int(input())

for i in range(n):
    a.append(int(input()))

for i in range(n):
    b.append(a[na])
    if a[na] == 2:
        print(i + 1)
        break
    na = a[na] - 1
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from itertools import product

n = int(input())
s = np.array([int(input()) for _ in range(n)])

ans = 0
for i in product((0, 1), repeat=n):
    x = sum(np.array(i) * s)
    if x % 10 != 0:
        ans = max(ans, x)
print(ans)

Fixed submission:
s = [int(input()) for _ in range(int(input()))]

if sum(s) % 10 != 0:
    print(sum(s))
else:
    s.sort()
    for i, x in enumerate(s):
        if x % 10 != 0:
            print(sum(s) - x)
            break
    else:
        print(0)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from itertools import product

n = int(input())
s = np.array([int(input()) for _ in range(n)])

ans = set([0])
for i in product((0, 1), repeat=n):
    x = sum(np.array(i) * s)
    if x % 10 != 0:
        ans.add(x)
print(max(ans))

Fixed submission:
s = [int(input()) for _ in range(int(input()))]

if sum(s) % 10 != 0:
    print(sum(s))
else:
    s.sort()
    for i, x in enumerate(s):
        if x % 10 != 0:
            print(sum(s) - x)
            break
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

flg = False
for i in range(n - m + 1):
    for j in range(n - m + 1):
        if a[i][j : j + m] == b[0]:
            for k in range(i + 1, i + m):
                if a[k][j : j + m] != b[k]:
                    break
            else:
                print("Yes")
                flg = True
                break
    if flg:
        break
else:
    print("No")

Fixed submission:
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

d = n - m + 1
flg = False
for i in range(d):
    for j in range(d):
        if a[i][j : j + m] == b[0]:
            for k in range(1, m):
                if a[i + k][j : j + m] != b[k]:
                    break
            else:
                print("Yes")
                flg = True
                break
    if flg:
        break
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
let [a, op, b] = require("fs").readFileSync("/dev/stdin", "utf8").split(" ");
[a, b] = [a, b].map(Number);
console.log(op == "+" ? a + b : a - b);

Fixed submission:
a, op, b = input().split()
a, b = int(a), int(b)
print(a + b if op == "+" else a - b)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
A = list(map(int,input().split()))

ans = 0
p = list(itertools.combinations(A,2))
for i in range(len(p)):
    ans += p[i][0]*p[i][1]

print(ans % (10**9+7))

Fixed submission:
mod = 10**9+7
N = int(input())
A = list(map(int, input().split()))

#累積和のリストを作成
S = [0]*(N+1)
ans = 0
for i in range(N):
    S[i+1] = A[i] + S[i]%mod

#累積和って感じですね
for i in range(N):
    sum = S[N] - S[i + 1]
    if sum < 0:
        sum += mod
    ans += A[i] * sum

print(ans % mod)

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

mod = 10**9 + 7
ans = 0
for i in range(N):
    for j in range(i,N):
        if i != j:
            ans += A[i]*A[j]

print(ans%mod)

Fixed submission:
mod = 10**9+7
N = int(input())
A = list(map(int, input().split()))

#累積和のリストを作成
S = [0]*(N+1)
ans = 0
for i in range(N):
    S[i+1] = A[i] + S[i]%mod

#累積和って感じですね
for i in range(N):
    sum = S[N] - S[i + 1]
    if sum < 0:
        sum += mod
    ans += A[i] * sum

print(ans % mod)