Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
import collections
d = collections.Counter()
MOD = int(1e9 + 7)

max_i = 0
for a in map(int, input().split()):
  inv_bin = bin(a)[2:][::-1]
  for i, b in enumerate(inv_bin):
    if (b == '1'):
      d[i] += 1
  max_i = max(i, max_i)

ans = 0
for k, v in d.items():
  ans += (N - v) * v * (2 ** k) 
  ans %= MOD
print(ans)


Fixed submission:
N = int(input())
import collections
d = collections.Counter()
MOD = int(1e9 + 7)

max_i = 0
for a in map(int, input().split()):
  inv_bin = bin(a)[2:][::-1]
  for i, b in enumerate(inv_bin):
    if (b == '1'):
      d[i] += 1
  max_i = max(i, max_i)

ans = 0
for k, v in d.items():
  ans += (N - v) * v * (2 ** k) 
  ans %= MOD
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())



stock = []
ans = 0
for i in range(n):
  str = collections.Counter(input().strip())
  ans += stock.count(str)
  stock.append(str)

print(ans)


Fixed submission:
import collections
n = int(input())



stock = collections.Counter()
ans = 0


for i in range(n):
  str = tuple(sorted(collections.Counter(input().strip()).items()))
  ans += stock[str]
  stock[str] += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
# 1 <= N <= 10 ** 5
# 0 <= M <= N − 1
# 1 <= a <= N - 1
import sys
sys.setrecursionlimit(100000)
N, M = map(int, input().split())

memo = {1: 1, 0: 1}
def fibo(n):
  if n in memo:
    return memo[n]
  else:
    num = fibo(n - 1) + fibo(n - 2)
    memo[n] = num
    return num


stairs = [False for _ in range(N + 1)]
pattern = 1
prev = 0
for _ in range(M):
  a = int(input())
  sub = a - prev - 1
  if sub == -1:
    print(0)
    break
  pattern *= fibo(sub)
  prev = a + 1
else:
  sub = N - prev
  pattern *= fibo(sub)

  print(pattern % 1000000007)


Fixed submission:
# 1 <= N <= 10 ** 5
# 0 <= M <= N − 1
# 1 <= a <= N - 1
N, M = map(int, input().split())

memo = {1: 1, 0: 1}
for i in range(2, int(10**5) + 1):
  memo[i] = memo[i-1] + memo[i-2]


stairs = [False for _ in range(N + 1)]
pattern = 1
prev = 0
for _ in range(M):
  a = int(input())
  sub = a - prev - 1
  if sub == -1:
    print(0)
    break
  pattern *= memo[sub]
  prev = a + 1
else:
  sub = N - prev
  pattern *= memo[sub]
  print(pattern % 1000000007)

Buggy python submission (verdict: Runtime Error):
# 1 <= N <= 10 ** 5
# 0 <= M <= N − 1
# 1 <= a <= N - 1
import sys
sys.setrecursionlimit(10000)
N, M = map(int, input().split())

memo = {1: 1, 0: 1}
def fibo(n):
  if n in memo:
    return memo[n]
  else:
    num = fibo(n - 1) + fibo(n - 2)
    memo[n] = num
    return num


stairs = [False for _ in range(N + 1)]
pattern = 1
prev = 0
for _ in range(M):
  a = int(input())
  sub = a - prev - 1
  if sub == -1:
    print(0)
    break
  pattern *= fibo(sub)
  prev = a + 1
else:
  sub = N - prev
  pattern *= fibo(sub)

  print(pattern % 1000000007)


Fixed submission:
# 1 <= N <= 10 ** 5
# 0 <= M <= N − 1
# 1 <= a <= N - 1
N, M = map(int, input().split())

memo = {1: 1, 0: 1}
for i in range(2, int(10**5) + 1):
  memo[i] = memo[i-1] + memo[i-2]


stairs = [False for _ in range(N + 1)]
pattern = 1
prev = 0
for _ in range(M):
  a = int(input())
  sub = a - prev - 1
  if sub == -1:
    print(0)
    break
  pattern *= memo[sub]
  prev = a + 1
else:
  sub = N - prev
  pattern *= memo[sub]
  print(pattern % 1000000007)

Buggy python submission (verdict: Runtime Error):
# 1 <= N <= 10 ** 5
# 0 <= M <= N − 1
# 1 <= a <= N - 1
N, M = map(int, input().split())

memo = {1: 1, 0: 1}
def fibo(n):
  if n in memo:
    return memo[n]
  else:
    num = fibo(n - 1) + fibo(n - 2)
    memo[n] = num
    return num


stairs = [False for _ in range(N + 1)]
pattern = 1
prev = 0
for _ in range(M):
  a = int(input())
  sub = a - prev - 1
  if sub == -1:
    print(0)
    break
  pattern *= fibo(sub)
  prev = a + 1
else:
  sub = N - prev
  pattern *= fibo(sub)

  print(pattern % 1000000007)



Fixed submission:
# 1 <= N <= 10 ** 5
# 0 <= M <= N − 1
# 1 <= a <= N - 1
N, M = map(int, input().split())

memo = {1: 1, 0: 1}
for i in range(2, int(10**5) + 1):
  memo[i] = memo[i-1] + memo[i-2]


stairs = [False for _ in range(N + 1)]
pattern = 1
prev = 0
for _ in range(M):
  a = int(input())
  sub = a - prev - 1
  if sub == -1:
    print(0)
    break
  pattern *= memo[sub]
  prev = a + 1
else:
  sub = N - prev
  pattern *= memo[sub]
  print(pattern % 1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
target_str = "AC"

N, Q = map(int, input().split()) 
S = input().strip()

target_list = [0 for i in range(N)]

for i in range(N - 1):
  if S[i: i + 2] == target_str:
    target_list[i] = 1

for i in range(Q):
  l, r = map(int, input().split()) 
  print(sum(target_list[l - 1: r - 1]))

Fixed submission:
target_str = "AC"

N, Q = map(int, input().split()) 
S = input().strip()

cumsum_list = [0 for i in range(N)]

cnt = 0
for i in range(N - 1):
  if S[i: i + 2] == target_str:
    cnt += 1
  cumsum_list[i] = cnt
cumsum_list.insert(0, 0)
cumsum_list.insert(0, 0)


for i in range(Q):
  l, r = map(int, input().split()) 
  print(cumsum_list[r] - cumsum_list[l])

Buggy python submission (verdict: Time Limit Exceeded):
target_str = "AC"

N, Q = map(int, input().split()) 
S = input().strip()

for i in range(Q):
  l, r = map(int, input().split()) 
  print(S[l - 1: r].count(target_str))

Fixed submission:
target_str = "AC"

N, Q = map(int, input().split()) 
S = input().strip()

cumsum_list = [0 for i in range(N)]

cnt = 0
for i in range(N - 1):
  if S[i: i + 2] == target_str:
    cnt += 1
  cumsum_list[i] = cnt
cumsum_list.insert(0, 0)
cumsum_list.insert(0, 0)


for i in range(Q):
  l, r = map(int, input().split()) 
  print(cumsum_list[r] - cumsum_list[l])
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
B = list(map(int, input().split()))


for i, b in enumerate(B, start=1):
  if b > i:
    print(-1)
    exit()


bnn = collections.defaultdict(
  lambda: collections.defaultdict(dict)
)
def inv_sousa(B, N, now=tuple()):
  if N == 0:
    yield now
  else:
    if now in bnn[B][N] or max(B) > N:
      return
    bnn[B][N][now] = False

    for i in set(B):
      idx = i - 1
      if B[idx] == i:
        yield from inv_sousa(B[:idx] + B[i:], N - 1, now=now + (B[idx],))


for x in inv_sousa(tuple(B), N):
  if x:
    for i in x[::-1]:
      print(i)
    break
else:
  print(-1)

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


inv_output = list()
for i in range(N, 0, -1):
  for j in range(i, 0, -1):
    if B[j - 1] == j:
      inv_output.append(B.pop(j - 1))
      break
  else:
    print(-1)
    break
else:
  for i in inv_output[::-1]:
    print(i)

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


for i, b in enumerate(B, start=1):
  if b > i:
    print(-1)
    exit()


bnn = collections.defaultdict(
  lambda: collections.defaultdict(dict)
)
def inv_sousa(B, N, now=tuple()):
  if N == 0:
    yield now
  elif now not in bnn[B][N]:
    for i in range(1, N + 1):
      idx = i - 1
      if B[idx] <= i:
        yield from inv_sousa(B[:idx] + B[i:], N - 1, now=now + (B[idx],))
    bnn[B][N][now] = False


for x in inv_sousa(tuple(B), N):
  if x:
    for i in x[::-1]:
      print(i)
    break
else:
  print(-1)

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


inv_output = list()
for i in range(N, 0, -1):
  for j in range(i, 0, -1):
    if B[j - 1] == j:
      inv_output.append(B.pop(j - 1))
      break
  else:
    print(-1)
    break
else:
  for i in inv_output[::-1]:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
islands = {i + 1: {i + 1} for i in range(N)}
ab_list = [map(int, input().split()) for i in range(M)]

ans = list()
k2k = dict()
start = N*(N - 1) / 2


def recursive_dict(x):
  if not x in k2k: return x
  prev = k2k[x]
  while True:
    if prev in k2k:
      prev = k2k[prev]
    else:
      k2k[x] = prev
      return prev


for a, b in ab_list[::-1]:
  a, b = recursive_dict(a), recursive_dict(b)
  if a == b:
    ans.append(0)
    continue
  ans.append(len(islands[a]) * len(islands[b]))
  islands[a] |= islands[b]
  k2k[b] = a

cumsum = 0
for i in ans[::-1]:
  cumsum += i
  print(cumsum)


Fixed submission:
N, M = map(int, input().split())
islands = {i + 1: 1 for i in range(N)}
ab_list = [map(int, input().split()) for i in range(M)]

ans = list()
k2k = dict()
start = N*(N - 1) / 2


def recursive_dict(x):
  if not x in k2k: return x
  prev = k2k[x]
  while True:
    if prev in k2k:
      prev = k2k[prev]
    else:
      k2k[x] = prev
      return prev

for a, b in ab_list[::-1]:
  a, b = recursive_dict(a), recursive_dict(b)
  if a == b:
    ans.append(0)
    continue
  ans.append(islands[a] * islands[b])
  islands[a] += islands[b]
  k2k[b] = a

cumsum = 0
for i in ans[::-1]:
  cumsum += i
  print(cumsum)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
islands = {i + 1: {i + 1} for i in range(N)}
ab_list = [map(int, input().split()) for i in range(M)]

ans = list()
k2k = dict()
start = N*(N - 1) / 2


def recursive_dict(x):
  if not x in k2k: return x
  prev = k2k[x]
  while True:
    if prev in k2k:
      prev = k2k[prev]
    else:
      k2k[x] = prev
      return prev


for a, b in ab_list[::-1]:
  a, b = recursive_dict(a), recursive_dict(b)
  if a == b:
    ans.append(0)
    continue
  ans.append(len(islands[a]) * len(islands[b]))
  islands[a] |= islands[b]
  k2k[b] = a

cumsum = 0
for i in ans[::-1]:
  cumsum += i
  print(cumsum)


Fixed submission:
N, M = map(int, input().split())
islands = {i + 1: 1 for i in range(N)}
ab_list = [map(int, input().split()) for i in range(M)]

ans = list()
k2k = dict()
start = N*(N - 1) / 2


def recursive_dict(x):
  if not x in k2k: return x
  prev = k2k[x]
  while True:
    if prev in k2k:
      prev = k2k[prev]
    else:
      k2k[x] = prev
      return prev

for a, b in ab_list[::-1]:
  a, b = recursive_dict(a), recursive_dict(b)
  if a == b:
    ans.append(0)
    continue
  ans.append(islands[a] * islands[b])
  islands[a] += islands[b]
  k2k[b] = a

cumsum = 0
for i in ans[::-1]:
  cumsum += i
  print(cumsum)
Buggy python submission (verdict: Runtime Error):
print(
  "Yay!"
  if all(lambda x: x <= 8,      
         map(int, input().split())
        )
  else ":("
)

Fixed submission:
print(
  "Yay!"
  if all(map(
    lambda x: x <= 8,      
    map(int, input().split())
  ))
  else ":("
)
Buggy python submission (verdict: Runtime Error):
N,X,T=list(map(int,input().split()))

result=N//X*T

if N%X!=0:
    result+=T

print(result)N,X,T=list(map(int,input().split()))

result=N//X*T

if N%X!=0:
    result+=T

print(result)

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

result=N//X*T

if N%X!=0:
    result+=T

print(result)
Buggy python submission (verdict: Runtime Error):
import numpy as np

X,N=list(map(int,input().split()))
Pn=list(map(int,input().split()))


possible=[]

for i in range(1,101):
    if i not in Pn:
        possible.append(i)

idx = np.abs(np.asarray(possible) - X).argmin()

print(possible[idx])

Fixed submission:
import numpy as np

X,N=list(map(int,input().split()))
Pn=list(map(int,input().split()))


possible=[]

for i in range(min(Pn)-1,max(Pn)+2) if N!=0 else [X]:
    if i not in Pn:
        possible.append(i)

idx = np.abs(np.asarray(possible) - X).argmin()

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

if 0 in A:
    print(0)
else:
    result=1
    for a in A:
        result=result*a
    if result>10**18:
        result=-1
    print(result)

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

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

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
 
A=list(map(int,input().split()))
 
result=1
for a in A:
    result=result*a
if result>10**18:
    result=-1
print(result)

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

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

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

N=int(input())

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

result=reduce(mul,A)

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



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

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

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

N=int(input())

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

result=reduce(mul,A)

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



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

if 0 in A:
    print(0)
else:
    result=1
    for a in A:
        result=result*a
        if result>10**18:
            result=-1
            break
    print(result)
Buggy python submission (verdict: Runtime Error):
import itertools
import numpy as np
N,M,X=map(int,input().split())

CA=[list(map(int, input().split())) for i in range(int(N))]
CA_low_cost=float('inf')
for i in range(N):
    CA_comb=list(itertools.combinations(CA,N-i))
    for comb in CA_comb:
        comb_ls=np.array(comb)
        comb_sum=np.sum(comb_ls,axis=0)
        if list(filter(lambda x:x<X ,comb_sum[1:]))==[]:
            if CA_low_cost>comb_sum[0]:
                CA_low_cost=comb_sum[0]
if CA_low_cost==float('inf'):
    print(-1)
else:
    print(CA_low_cost)

Fixed submission:
import itertools
import numpy as np
N,M,X=map(int,input().split())

CA=[list(map(int, input().split())) for i in range(int(N))]
CA_low_cost=float('inf')
for i in range(N):
    CA_comb=list(itertools.combinations(CA,N-i))
    for comb in CA_comb:
        comb_ls=np.array(comb)
        comb_sum=np.sum(comb_ls,axis=0)
        if list(filter(lambda x:x<X ,comb_sum[1:]))==[]:
            if CA_low_cost>comb_sum[0]:
                CA_low_cost=comb_sum[0]
if CA_low_cost==float('inf'):
    print(-1)
else:
    print(CA_low_cost)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
dl=[]
dr=[]

for i in range(Q):
    line = list(map(int, input().split()))
    dl.append(line[0])
    dr.append(line[1])

s=[]
for i in range(N+1):
    s.append(S[:i].count('AC'))

ans=[]
for l, r in zip(dl, dr):
    ans.append(s[r]-s[l])

for i in range(Q):
    print(ans[i])

Fixed submission:
##初期値設定##
N, Q = map(int, input().split())
S = input()
dl=[]
dr=[]
for i in range(Q):
    line = list(map(int, input().split()))
    dl.append(line[0])
    dr.append(line[1])

##ACの個数配列計算##
a=[]
for i in range(N-1):
    tmp_S = S[i:i+2]
    if tmp_S == "AC":
        a.append(1)
    else:
        a.append(0)

##累積和計算##
s = [0]
for i in range(len(a)):
    s.append(s[i]+a[i])

##解答算出##
ans=[]
for l, r in zip(dl, dr):
    ans.append(s[r-1]-s[l-1])

for i in range(Q):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())

counts = []
for i in range(N):
    count = 0
    for j in range(i):
        if S[j] != "E":
            count += 1
    for j in range(i+1, N):
        if S[j] != "W":
            count += 1
    counts.append(count)

print(min(counts))

Fixed submission:
N = int(input())
S = list(input())

sum_W = [0]
for i in range(1, N):
    if S[i-1] == "W":
        sum_W.append(sum_W[i-1]+1)
    else:
        sum_W.append(sum_W[i-1])

sum_E = [S[1:].count("E")]
for i in range(0, N-1):
    if S[i+1] == "E":
        sum_E.append(sum_E[i]-1)
    else:
        sum_E.append(sum_E[i])

counts = []
for i in range(N):
    count = 0
    counts.append(sum_W[i]+sum_E[i])

print(min(counts))
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def lcm(a, b):
    g = gcd(a,b)
    return a / g * b

N = int(input())
T = [int(input()) for i in range(N)]
ans = 1
for i in range(len(T)):
    ans = lcm(ans, T[i])

print(int(ans))

Fixed submission:
import math
from functools import reduce

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

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

N = int(input())
T = [int(input()) for i in range(N)]

print(lcm_list(T))

Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def lcm(a, b):
    g = gcd(a,b)
    return a * b / g

N = int(input())
T = [int(input()) for i in range(N)]
ans = 1
for i in range(len(T)):
    ans = lcm(ans, T[i])

print(int(ans))

Fixed submission:
import math
from functools import reduce

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

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

N = int(input())
T = [int(input()) for i in range(N)]

print(lcm_list(T))

Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

def lcm(a, b):
    g = gcd(a,b)
    return a * b / g

N = int(input())
T = [int(input()) for i in range(N)]
ans = T[0]
for i in range(1, len(T)):
    ans = lcm(ans, T[i])

print(int(ans))


Fixed submission:
import math
from functools import reduce

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

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

N = int(input())
T = [int(input()) for i in range(N)]

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

power = 1
for i in range(1,n+1):
    power *= i

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


Fixed submission:
n = int(input())

power = 1
for i in range(1,n+1):
    power *= i
    power = power%(10**9+7)
    
print(power)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int,input().split())

count=0
for X in range(k+1):
    for Y in range(k+1):
        for Z in range(k+1):
            if X + Y + Z == s:
                count+=1

print(count)

Fixed submission:
k, s = map(int,input().split())

count=0
for X in range(k+1):
    for Y in range(k+1):
        Z = s - X - Y
        if k>=Z>=0:
            count+=1

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

sum=0
for i in range(n-1) :
  for j in range(n-i-1) :
    sum += a[i]*a[j+i+1]
    sum = sum%1000000007

print(sum)

Fixed submission:
d,t,s = map(int, input().split())

if s*t < d :
  print("No")
else :
  print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
r_wa = list()
for i in range(n+1) :
  r_wa.append(sum(a[:i+1]))

for i in range(n-1) :
  ans += a[i]*(r_wa[n]-r_wa[i])
  ans = ans%1000000007
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
r_wa = [a[0]]
for i in range(n) :
  if i>0 :
    r_wa.append(r_wa[i-1]+a[i])

for i in range(n-1) :
  ans += a[i]*(r_wa[n-1]-r_wa[i])
  ans = ans%1000000007
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
r_wa = list()
for i in range(n+1) :
  r_wa.append(sum(a[:i+1]))

for i in range(n-1) :
  ans += a[i]*(r_wa[n]-r_wa[i])
  ans = ans%1000000007
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
r_wa = [a[0]]
for i in range(n) :
  if i>0 :
    r_wa.append(r_wa[i-1]+a[i])

for i in range(n-1) :
  ans += a[i]*(r_wa[n-1]-r_wa[i])
  ans = ans%1000000007
print(ans)

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

sum=0
for i in range(n-1) :
  for j in range(n-i-1) :
    sum += a[i]*a[j+i+1]
    sum = sum%1000000007

print(sum)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
r_wa = [a[0]]
for i in range(n) :
  if i>0 :
    r_wa.append(r_wa[i-1]+a[i])

for i in range(n-1) :
  ans += a[i]*(r_wa[n-1]-r_wa[i])
  ans = ans%1000000007
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

addans=0

for i in range(1,n) :
  if a[i-1]+1 == a[i] :
    addans += c[a[i-2]]
    print(addans)
print(sum(b)+addans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

addans=0

for i in range(n-1) :
  if a[i]+1 == a[i+1] :
    addans += c[a[i]-1]
print(sum(b)+addans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())

li=[list(map(int,input().split())) for i in range(n)]
lj=[list(map(int,input().split())) for i in range(m)]

for i in range(n):
    li_distance=[abs(lj[j][0]-li[i][0])+abs(lj[j][1]-li[i][1]) for j in range(m)]
    print(li_distance.index(min(li_distance)+1))
    

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

li=[list(map(int,input().split())) for i in range(n)]
lj=[list(map(int,input().split())) for i in range(m)]

for i in range(n):
    li_distance=[abs(lj[j][0]-li[i][0])+abs(lj[j][1]-li[i][1]) for j in range(m)]
    print(li_distance.index(min(li_distance))+1)
Buggy python submission (verdict: Runtime Error):
a=input()
print(int(a+a**2+a**3))


Fixed submission:
a=input()
a=int(a)
print(int(a+a**2+a**3))

Buggy python submission (verdict: Runtime Error):
a=input()
print(a+a**2+a**3)

Fixed submission:
a=input()
a=int(a)
print(int(a+a**2+a**3))
Buggy python submission (verdict: Runtime Error):
a=int(input())
a=a.split(" ")
c=0
for i in a:
    c+=1
    if i==0:
        break
print(c)

Fixed submission:
a=input()
a=a.split(" ")
c=0
for i in a:
    c+=1
    if i==str(0):
        break
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B,N=map(int,input().split())
han=0
kot=0
i=0
if B-1>=N:
    print(math.floor(A*N/B)-A*math.floor(N/B))
    i=1
else:
    for a in range(B-1,N,5*B):
        if han<(math.floor(A*a/B)-A*math.floor(a/B)):
            han=(math.floor(A*a/B)-A*math.floor(a/B))
            kot=a

if i==0:
    print(han)

Fixed submission:
import math
A,B,N=map(int,input().split())
han=0
kot=0
i=0
if B==1:
    print(0)
    exit()
if B-1>=N:
    print(math.floor(A*N/B)-A*math.floor(N/B))
    i=1
else:
    for a in range(B-1,N,B):
        if han<(math.floor(A*a/B)-A*math.floor(a/B)):
            han=(math.floor(A*a/B)-A*math.floor(a/B))
            kot=a

if i==0:
    print(han)

Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B,N=map(int,input().split())
han=0
kot=0
i=0
if B-1>=N:
    print(math.floor(A*N/B)-A*math.floor(N/B))
    i=1
else:
    for a in range(B-1,N,2*B):
        if han<(math.floor(A*a/B)-A*math.floor(a/B)):
            han=(math.floor(A*a/B)-A*math.floor(a/B))
            kot=a

if i==0:
    print(han)

Fixed submission:
import math
A,B,N=map(int,input().split())
han=0
kot=0
i=0
if B==1:
    print(0)
    exit()
if B-1>=N:
    print(math.floor(A*N/B)-A*math.floor(N/B))
    i=1
else:
    for a in range(B-1,N,B):
        if han<(math.floor(A*a/B)-A*math.floor(a/B)):
            han=(math.floor(A*a/B)-A*math.floor(a/B))
            kot=a

if i==0:
    print(han)

Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B,N=map(int,input().split())
han=0
kot=0
i=0
if B-1>=N:
    print(math.floor(A*N/B)-A*math.floor(N/B))
    i=1
else:
    for a in range(B-1,N,B):
        if han<(math.floor(A*a/B)-A*math.floor(a/B)):
            han=(math.floor(A*a/B)-A*math.floor(a/B))
            kot=a

if i==0:
    print(han)

Fixed submission:
import math
A,B,N=map(int,input().split())
han=0
kot=0
i=0
if B==1:
    print(0)
    exit()
if B-1>=N:
    print(math.floor(A*N/B)-A*math.floor(N/B))
    i=1
else:
    for a in range(B-1,N,B):
        if han<(math.floor(A*a/B)-A*math.floor(a/B)):
            han=(math.floor(A*a/B)-A*math.floor(a/B))
            kot=a

if i==0:
    print(han)