Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N,X = map(int,input().split())
positions_from_X = [abs(int(x)-X) for x in input().split()]

min_distance = min(positions_from_X)

n = min_distance

for d in sorted([i for i in range(1,n+1) if n%i==0], reverse=True):
    flg = d
    for p in positions_from_X:
        if p%d !=0:
            flg=0
            break
    if flg:
        break

print(flg)

Fixed submission:
N,X = map(int,input().split())
positions_from_X = [abs(int(x)-X) for x in input().split()]

n = min(positions_from_X)

if N==1:
    flg = n
else:
    for d in sorted([i for i in range(1,n+1) if n%i==0], reverse=True):
        flg = d
        for p in positions_from_X:
            if p%d !=0:
                flg=0
                break
        if flg:
            break

print(flg)
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = 0
for i in range(1,N,2):
	t = 0
    for j in range(1,N,2):
		if not N%n:
			t+=1
    if t==8:
		s+=1

print(s)



Fixed submission:
N = int(input())
s = 0
for i in range(1,N+1,2):
  t = 0
  for j in range(1,i+1,2):
    if not i%j:
      t+=1
  if t==8:
    s+=1

print(s)
Buggy python submission (verdict: Runtime Error):
R = int(input())
r = 'AGC'
if R<2800:
    r[1]='R'
if R<1200:
    r[1]='B'
print(r)

Fixed submission:
R = int(input())
r = 'AGC'
if R<2800: r='ARC'
if R<1200: r='ABC'
print(r)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

if set(S)!=set(T):
    ans = 'No'

for i in range(len(S)):
    if ans:
        break
    U = S[i:]+S[:i]
    if U==T:
        ans = 'Yes'

if not ans:
    ans = 'No'

print(ans)

Fixed submission:
S = input()
T = input()

ans = ''

if set(S)!=set(T):
    ans = 'No'

for i in range(len(S)):
    if ans:
        break
    U = S[i:]+S[:i]
    if U==T:
        ans = 'Yes'

if not ans:
    ans = 'No'

print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

if set(S)!=set(T):
    ans = 'No'

for i in len(S):
    if ans:
        break
    U = S[i:]+S[:i]
    if U==T:
        ans = 'Yes'

if not ans:
    ans = 'No'

print(ans)

Fixed submission:
S = input()
T = input()

ans = ''

if set(S)!=set(T):
    ans = 'No'

for i in range(len(S)):
    if ans:
        break
    U = S[i:]+S[:i]
    if U==T:
        ans = 'Yes'

if not ans:
    ans = 'No'

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

idx = As.index(i)
left = idx
right = n - idx - 1

n_l = (left + k - 1) // (k - 1)
n_r = (right + k - 1) // (k - 1)

print(n_l + n_r)

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

idx = As.index(min(As))
left = idx

n_l = (left + k - 2) // (k - 1)

right = n - ((n_l) * (k-1)) - 1

n_r = (right + k - 2) // (k - 1)

print(n_l + n_r)
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define length(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, length(a))cin >> a[i]
#define ccin(i, j, a) rep(i, length(a))rep(j, length(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define sqrtl sqrt
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-9;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
int main(){
    ld n;
    cin >> n;
    cout << fixed;
    cout << (n/3)*(n/3)*(n/3) << endl;
    return 0;
}

Fixed submission:
n = int(input())
print((n/3)**3)

Buggy python submission (verdict: Runtime Error):
n = map(int,input().split())
print(n*n*n/27)

Fixed submission:
n = int(input())
print((n/3)**3)
Buggy python submission (verdict: Runtime Error):
入力 = input
出力 = print
ぜろ = 0
いち = 1
曲の数 = 入力()
整数化 = int
浮動小数点化 = float
曲の数 = 整数化(曲の数)
曲名 = [ぜろ]
時間 = [ぜろ]
曲名.remove(ぜろ)
時間.remove(ぜろ)
範囲 = range
for 制御変数 in 範囲(ぜろ,曲の数):
    入力された値 = 入力()
    曲名.append(入力された値)
    入力された値 = 入力()
    時間.append(入力された値)
    時間[制御変数] = 整数化(浮動小数点化(時間[制御変数]))
寝た時の曲名 = 入力()
まだわからん = ぜろ
寝たタイミング = まだわからん
for 制御変数 in 範囲(ぜろ,曲の数):
    if(曲名[制御変数] == 寝た時の曲名):
        寝たタイミング = 制御変数
        break
寝ていたときに流れていた曲の時間 = まだわからん
for 制御変数 in 範囲(寝たタイミング + いち,曲の数):
    寝ていたときに流れていた曲の時間 += 時間[制御変数]
出力(寝ていたときに流れていた曲の時間)

Fixed submission:
入力 = input
出力 = print
ぜろ = 0
いち = 1
曲の数 = 入力()
整数化 = int
浮動小数点化 = float
曲の数 = 整数化(曲の数)
曲名 = [ぜろ]
時間 = [ぜろ]
曲名.remove(ぜろ)
時間.remove(ぜろ)
範囲 = range
for 制御変数 in 範囲(ぜろ,曲の数):
    入力された値 = 入力().split()
    曲名.append(入力された値[ぜろ])
    時間.append(入力された値[いち])
    時間[制御変数] = 整数化(浮動小数点化(時間[制御変数]))
寝た時の曲名 = 入力()
まだわからん = ぜろ
寝たタイミング = まだわからん
for 制御変数 in 範囲(ぜろ,曲の数):
    if(曲名[制御変数] == 寝た時の曲名):
        寝たタイミング = 制御変数
        break
寝ていたときに流れていた曲の時間 = まだわからん
for 制御変数 in 範囲(寝たタイミング + いち,曲の数):
    寝ていたときに流れていた曲の時間 += 時間[制御変数]
出力(寝ていたときに流れていた曲の時間)
Buggy python submission (verdict: Runtime Error):
n = input()
first = n // 100
second = (n % 100) // 10
third = (n % 10)

if (first == 7 or second == 7 or third == 7):
  print('YES')
else:
  print('No')

Fixed submission:
n = int(input())
first = n // 100
second = (n % 100) // 10
third = (n % 10)

if (first == 7 or second == 7 or third == 7):
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
n = input()
first = n // 100
second = (n % 100) // 10
third = (n % 10)

if (first == 7 || second == 7 || third == 7):
  print('YES')
else:
  print('No')

Fixed submission:
n = int(input())
first = n // 100
second = (n % 100) // 10
third = (n % 10)

if (first == 7 or second == 7 or third == 7):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n = input()
i = 1
result = 0
while (i <= n):
  if (i % 3 != 0 and i % 5 != 0):
    result += i
  i += 1
print(result)

Fixed submission:
n = int(input())
i = 1
result = 0
while (i <= n):
  if (i % 3 != 0 and i % 5 != 0):
    result += i
  i += 1
print(result)

Buggy python submission (verdict: Runtime Error):
n = input()
i = 1
result = 0
while (i <= n):
  if (i % 3 == 0 || i % 5 == 0):
    result += i
print(result)

Fixed submission:
n = int(input())
i = 1
result = 0
while (i <= n):
  if (i % 3 != 0 and i % 5 != 0):
    result += i
  i += 1
print(result)
Buggy python submission (verdict: Runtime Error):
def resolve():
  s = input()
  if s == 'Sunny':
    print('Cloudy')
  elif s == 'Cloudy':
    print(Rainy)
  else:
    print('Sunny')

  return

if __name__ == "__main__":
  resolve()


Fixed submission:
import sys

def resolve():
  s = input()
  if s == 'Sunny':
      print('Cloudy')
  elif s == 'Cloudy':
      print('Rainy')
  else:
      print('Sunny')

if __name__ == "__main__":
    resolve()
Buggy python submission (verdict: Runtime Error):
from scipy.misc import comb

def f2(n, k):
    return comb(n+k-1, k-1)

def f(n, k):
    if n < k:
        return 0
    if n == 0 and k == 0:
        return 1
    if k < 1:
        return 0

    return f2(n-k, k)


if __name__ == "__main__":
    N, K = map(int, input().split())

    blue = K
    red = N - K

    for i in range(1, K+1):
        blue = f(K, i)
        red = f2(N-K-(i-1), i+1)
        ans = blue * red
        print(int(ans % 1000000007))



Fixed submission:
from scipy.misc import comb

def f2(n, k):
    return comb(n+k-1, k-1, exact=True)

def f(n, k):
    if n < k:
        return 0
    if n == 0 and k == 0:
        return 1
    if k < 1:
        return 0

    return f2(n-k, k)


if __name__ == "__main__":
    N, K = map(int, input().split())

    blue = K
    red = N - K

    for i in range(1, K+1):
        blue = f(K, i)
        red = f2(N-K-(i-1), i+1)
        ans = blue * red
        print(int(ans % 1000000007))

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

def f2(n, k):
    return comb(n+k-1, k-1)

def f(n, k):
    if n < k:
        return 0
    if n == 0 and k == 0:
        return 1
    if k < 1:
        return 0

    return f2(n-k, k)


if __name__ == "__main__":
    N, K = map(int, input().split())

    blue = K
    red = N - K

    for i in range(1, K+1):
        blue = f(K, i)
        red = f2(N-K-(i-1), i+1)
        ans = blue * red
        print(int(ans % 1000000007))



Fixed submission:
from scipy.misc import comb

def f2(n, k):
    return comb(n+k-1, k-1, exact=True)

def f(n, k):
    if n < k:
        return 0
    if n == 0 and k == 0:
        return 1
    if k < 1:
        return 0

    return f2(n-k, k)


if __name__ == "__main__":
    N, K = map(int, input().split())

    blue = K
    red = N - K

    for i in range(1, K+1):
        blue = f(K, i)
        red = f2(N-K-(i-1), i+1)
        ans = blue * red
        print(int(ans % 1000000007))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

keys = [True] * N

l1 = 1
r1 = N

for i in range(M):
    l, r = map(int, input().split())
    if (l1 < l):
        l1 = l
    if (r < r1):
        r1 = r
    newKeys = [False] * N
    for j in range(l1 - 1, r1):
        newKeys[j] = True
    keys = np.logical_and(keys, newKeys)

print(np.sum(keys == True))


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

keys = [True] * N

l1 = 1
r1 = N

for i in range(M):
    l, r = map(int, input().split())
    if (l1 < l):
        l1 = l
    if (r < r1):
        r1 = r

if (r1 - l1 + 1 > 0):
    print(r1 - l1 + 1)
else:
    print(0)

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

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

keys = [True] * N

for i in range(M):
    l, r = map(int, input().split())
    newKeys = [False] * N
    for j in range(l - 1, r):
        newKeys[j] = True
    keys = np.logical_and(keys, newKeys)

print(np.sum(keys == True))


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

keys = [True] * N

l1 = 1
r1 = N

for i in range(M):
    l, r = map(int, input().split())
    if (l1 < l):
        l1 = l
    if (r < r1):
        r1 = r

if (r1 - l1 + 1 > 0):
    print(r1 - l1 + 1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import fractions
from functools import reduce

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

max = 1

for comb in itertools.combinations(a, n-1):
    ret = reduce(fractions.gcd, comb)
    if ret > max:
        max = ret

print(max)


Fixed submission:
import itertools
import fractions
from functools import reduce

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

L = [0] * n
R = [0] * n

for i in range(len(a)):
    if i == 0:
        L[i] = a[i]
        R[n - 1] = a[n - 1]
    else:
        L[i] = fractions.gcd(L[i - 1], a[i])
        R[n - 1 - i] = fractions.gcd(R[n - i], a[n - 1 - i])

val = 1

for i in range(len(a)):
    ret = 0
    if i == 0:
        ret = R[i + 1]
    elif i == n - 1:
        ret = L[i - 1]
    else:
        ret = fractions.gcd(L[i - 1], R[i + 1])

    if ret > val:
       val = ret
        
print(val)

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

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

def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a

def ngcd(nums):
    d = 0
    for num in nums:
        d = gcd(d, num)
    return d

max = 1

for comb in itertools.combinations(a, n-1):
    ret = ngcd(comb)
    if ret > max:
        max = ret

print(max)


Fixed submission:
import itertools
import fractions
from functools import reduce

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

L = [0] * n
R = [0] * n

for i in range(len(a)):
    if i == 0:
        L[i] = a[i]
        R[n - 1] = a[n - 1]
    else:
        L[i] = fractions.gcd(L[i - 1], a[i])
        R[n - 1 - i] = fractions.gcd(R[n - i], a[n - 1 - i])

val = 1

for i in range(len(a)):
    ret = 0
    if i == 0:
        ret = R[i + 1]
    elif i == n - 1:
        ret = L[i - 1]
    else:
        ret = fractions.gcd(L[i - 1], R[i + 1])

    if ret > val:
       val = ret
        
print(val)
Buggy python submission (verdict: Time Limit Exceeded):
# ABC 120 C

import re

S = input()

base = len(S)

l = len(S)

while True:
    tmp = l
    S = re.sub('01', '', S)
    if l != len(S):
        l = len(S)

    S = re.sub('10', '', S)
    if l != len(S):
        l = len(S)

    if tmp == l:
        break

print(base - len(S))


Fixed submission:
# ABC 120 C

import re

S = input()

l0 = 0
l1 = 0

for i in range(len(S)):
    if S[i] == '0':
        l0 += 1
    elif S[i] == '1':
        l1 += 1

print(min(l0, l1) * 2)
Buggy python submission (verdict: Runtime Error):
# ABC 119 D

import bisect

def resolve():
    A, B, Q = map(int, input().split())
    s = [int(input()) for _ in range(A)]
    t = [int(input()) for _ in range(B)]

    for _ in range(Q):
        i = int(input())
        s1 = -1 if bisect.bisect_left(s, i) == 0 else s[bisect.bisect_left(s, i)-1]
        s2 = -1 if bisect.bisect_right(s, i) >= A else s[bisect.bisect_right(s, i)]
        t1 = -1 if bisect.bisect_left(t, i) == 0 else t[bisect.bisect_left(t, i)-1]
        t2 = -1 if bisect.bisect_left(t, i) >= A else t[bisect.bisect_right(t, i)]
        tmp = []

        if s1 != -1 and t1 != -1:
            tmp.append(max(i-s1, i-t1))
        if s2 != -1 and t2 != -1:
            tmp.append(max(s2-i, t2-i))
        if s1 != -1 and t2 != -1:
            tmp.append(min(i-s1, t2-i) + t2-s1)
        if t1 != -1 and s2 != -1:
            tmp.append(min(i-t1, s2-i) + s2-t1)

        print(min(tmp))


if __name__ == "__main__":
    resolve()


Fixed submission:
# ABC 119 D

import bisect

def resolve():
    A, B, Q = map(int, input().split())
    s = [int(input()) for _ in range(A)]
    t = [int(input()) for _ in range(B)]

    for _ in range(Q):
        i = int(input())
        s1 = -1 if bisect.bisect_left(s, i) == 0 else s[bisect.bisect_left(s, i)-1]
        s2 = -1 if bisect.bisect_right(s, i) >= A else s[bisect.bisect_right(s, i)]
        t1 = -1 if bisect.bisect_left(t, i) == 0 else t[bisect.bisect_left(t, i)-1]
        t2 = -1 if bisect.bisect_left(t, i) >= B else t[bisect.bisect_right(t, i)]
        tmp = []

        if s1 != -1 and t1 != -1:
            tmp.append(max(i-s1, i-t1))
        if s2 != -1 and t2 != -1:
            tmp.append(max(s2-i, t2-i))
        if s1 != -1 and t2 != -1:
            tmp.append(min(i-s1, t2-i) + t2-s1)
        if t1 != -1 and s2 != -1:
            tmp.append(min(i-t1, s2-i) + s2-t1)

        print(min(tmp))


if __name__ == "__main__":
    resolve()
Buggy python submission (verdict: Runtime Error):
# ABC 116 C

N = int(input())

h = list(map(int, input().split()))

def chomp0(arr):
    while len(arr) != 0 and arr[0] == 0:
        del arr[0]

    while len(arr) != 0 and arr[-1] == 0:
        del arr[-1]

    return arr

def solve(arr):
    if len(arr) == 0:
        return 0

    arr = chomp0(arr)

    ans = 0

    num0 = arr.count(0)
    if num0 != 0:
        for _ in range(num0):
            idx = arr.index(0)
            ans += solve(arr[:idx])
            arr = arr[idx+1:]

    minVal = min(arr)
    ans += minVal
    for i in range(len(arr)):
        arr[i] -= minVal

    if arr.count(0) != len(arr):
        ans += solve(arr)

    return ans

print(solve(h))


Fixed submission:
# ABC 116 C

N = int(input())

h = list(map(int, input().split()))

def chomp0(arr):
    while len(arr) != 0 and arr[0] == 0:
        del arr[0]

    while len(arr) != 0 and arr[-1] == 0:
        del arr[-1]

    return arr

def solve(arr):
    arr = chomp0(arr)

    if len(arr) == 0:
        return 0

    ans = 0

    num0 = arr.count(0)
    if num0 != 0:
        for _ in range(num0):
            idx = arr.index(0)
            ans += solve(arr[:idx])
            arr = arr[idx+1:]

    minVal = min(arr)
    ans += minVal
    for i in range(len(arr)):
        arr[i] -= minVal

    if arr.count(0) != len(arr):
        ans += solve(arr)

    return ans

print(solve(h))

Buggy python submission (verdict: Runtime Error):
# ABC 116 C

N = int(input())

h = list(map(int, input().split()))

def chomp0(arr):
    while len(arr) != 0 and arr[0] == 0:
        del arr[0]

    while len(arr) != 0 and arr[-1] == 0:
        del arr[-1]

    return arr

def solve(arr):
    ans = 0

    num0 = arr.count(0)
    if num0 != 0:
        for _ in range(num0):
            idx = arr.index(0)
            ans += solve(arr[:idx])
            arr = arr[idx+1:]

    minVal = min(arr)
    ans += minVal
    for i in range(len(arr)):
        arr[i] -= minVal

    arr = chomp0(arr)

    if arr.count(0) != len(arr):
        ans += solve(arr)

    return ans

print(solve(h))


Fixed submission:
# ABC 116 C

N = int(input())

h = list(map(int, input().split()))

def chomp0(arr):
    while len(arr) != 0 and arr[0] == 0:
        del arr[0]

    while len(arr) != 0 and arr[-1] == 0:
        del arr[-1]

    return arr

def solve(arr):
    arr = chomp0(arr)

    if len(arr) == 0:
        return 0

    ans = 0

    num0 = arr.count(0)
    if num0 != 0:
        for _ in range(num0):
            idx = arr.index(0)
            ans += solve(arr[:idx])
            arr = arr[idx+1:]

    minVal = min(arr)
    ans += minVal
    for i in range(len(arr)):
        arr[i] -= minVal

    if arr.count(0) != len(arr):
        ans += solve(arr)

    return ans

print(solve(h))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())

A = np.zeros([N, 3], dtype='int32')

for i in range(N):
    a, b, c = map(int, input().split())
    A[i] = [a, b, c]

dp = np.zeros([N+1, 3], dtype='int32')

for i in range(N):
    for j in range(3):     # i   日目の選択
        for k in range(3): # i+1 日目の選択
            if j == k:
                continue
            if dp[i+1][k] < dp[i][j] + A[i][k]:
                dp[i+1][k] = dp[i][j] + A[i][k]

print(dp[-1].max())


Fixed submission:
import numpy as np

N = int(input())

A = np.zeros([N, 3], dtype='int32')

for i in range(N):
    a, b, c = map(int, input().split())
    A[i] = [a, b, c]

dp = np.zeros([N+1, 3], dtype='int32')

for i in range(N):
    dp[i+1][0] = A[i][0] + max(dp[i][1], dp[i][2])
    dp[i+1][1] = A[i][1] + max(dp[i][0], dp[i][2])
    dp[i+1][2] = A[i][2] + max(dp[i][0], dp[i][1])

print(dp[-1].max())
Buggy python submission (verdict: Time Limit Exceeded):
# ABC 115 C

N, K = map(int, input().split())

h = [int(input()) for _ in range(N)]

h.sort()

ans = 1.0e+9

for i in range(N-K+1):
    ans = min(ans, max(h[i:i+K]) - min(h[i:i+K]))

print(ans)


Fixed submission:
# ABC 115 C

N, K = map(int, input().split())

h = [int(input()) for _ in range(N)]

h.sort()

ans = 1.0e+9

for i in range(N-K+1):
    ans = min(ans, h[i+K-1] - h[i])

print(ans)
Buggy python submission (verdict: Runtime Error):
from a import resolve

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """12"""
        output = """Yes"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """101"""
        output = """No"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """999999999"""
        output = """Yes"""
        self.assertIO(input, output)

if __name__ == "__main__":
    unittest.main()


Fixed submission:
import sys

def resolve():
  n = int(input())
  s = str(n)
  sum = 0
  for c in s:
    sum += int(c)
  if n % sum == 0:
    print("Yes")
  else:
    print("No")
  return

if __name__ == "__main__":
  resolve()
Buggy python submission (verdict: Runtime Error):
from a import resolve

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 2
2 0
0 0
-1 0
1 0"""
        output = """2
1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 4
10 10
-10 -10
3 3
1 2
2 3
3 5
3 5"""
        output = """3
1
2"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """5 5
-100000000 -100000000
-100000000 100000000
100000000 -100000000
100000000 100000000
0 0
0 0
100000000 100000000
100000000 -100000000
-100000000 100000000
-100000000 -100000000"""
        output = """5
4
3
2
1"""
        self.assertIO(input, output)

if __name__ == "__main__":
    unittest.main()


Fixed submission:
import math

INF = 1001001001

def resolve():
  n, m = map(int, input().split())
  s = []
  c = []

  for i in range(n):
    a, b = map(int, input().split())
    s.append([a, b])

  for i in range(m):
    a, b = map(int, input().split())
    c.append([a, b])

  for a in s:
    ans = 0
    dist = INF
    for i in range(m):
      if abs(a[0] - c[i][0]) + abs(a[1] - c[i][1]) < dist:
        dist = abs(a[0] - c[i][0]) + abs(a[1] - c[i][1])
        ans = i+1
    print(ans)
  return

if __name__ == "__main__":
  resolve()
Buggy python submission (verdict: Runtime Error):
# ABC 054 B

import sys

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

A = [input() for i in range(N)]
B = [input() for i in range(M)]

ret = [[] for i in range(M)]

for i in range(len(B)):
    for j in range(len(A)):
        f = -1
        while True:
            f = A[j].find(B[i], f+1)
            if f == -1:
                break

            ret[i].append((j, f))

flag = False

# ret = [[(1, 1)],
#        [(1, 1), (2, 1)]]

if M == 1 and len(ret[0] > 0):
    print('True')
    sys.exit(0)

for i in range(len(ret[0])):
    start = ret[0][i] # (x, y)

    for j in range(M-1):
        if not (start[0]+1, start[1]) in ret[j+1]:
            break
        if j == M-2:
            print('Yes')
            sys.exit(0)

print('No')


Fixed submission:
import sys

def resolve():
    N, M = map(int, input().split())
    A = []
    for i in range(N):
        A.append(input())
    B = []
    for i in range(M):
        B.append(input())

    for i in range(N - M + 1):
        for j in range(N - M + 1):
            for k in range(M):
                if B[k] != A[i+k][j:j+M]:
                    break
                if k == M-1:
                    print('Yes')
                    return

    print('No')

if __name__ == "__main__":
    resolve()