Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
lis = []
for _ in range(N):
  a, b = map(int, input().split())
  for l in range(b):
    lis.append(a)
lis.sort()
total = 0
for i in range(M):
  total = total + lis[i]
print(total)  

Fixed submission:
N, M = map(int, input().split())
lis = []
for _ in range(N):
  a, b = map(int, input().split())
  lis.append((a, b))
def eval(data):
  return data[0]
lis.sort(key=eval)
total = 0
num = 0
mark = 0
for i in range(N):
  num = num + lis[i][1]
  total = total + lis[i][0]*lis[i][1]
  if num > M:
    mark = i
    total = total - lis[i][0]*lis[i][1]
    num = num - lis[i][1]
    break
total = total + (M - num)*lis[mark][0]
print(total)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
lis = []
for _ in range(N):
  a, b = map(int, input().split)
  for l in range(b):
    lis.append(a)
lis.sort()
total = 0
for i in range(M):
  total = total + lis[i]
print(total)  

Fixed submission:
N, M = map(int, input().split())
lis = []
for _ in range(N):
  a, b = map(int, input().split())
  lis.append((a, b))
def eval(data):
  return data[0]
lis.sort(key=eval)
total = 0
num = 0
mark = 0
for i in range(N):
  num = num + lis[i][1]
  total = total + lis[i][0]*lis[i][1]
  if num > M:
    mark = i
    total = total - lis[i][0]*lis[i][1]
    num = num - lis[i][1]
    break
total = total + (M - num)*lis[mark][0]
print(total)
Buggy python submission (verdict: Runtime Error):
def calc0toN(a):
  bina = int(bin(a)[2:]) 
  if a % 2 == 0:
    if a % 4 == 0:
      return bina
    else:
      return 1 ^ bina
  else:
    if (a + 1) % 4 == 0:
      return 0
    else:
      return 1
A, B = map(int, input().split())
print(int("0b" + str(calc0toN(A - 1) ^ calc0toN(B)), 2))

Fixed submission:
def calc0toN(a):
  if a % 2 == 0:
    if a % 4 == 0:
      return a
    else:
      return 1 ^ a
  else:
    if (a + 1) % 4 == 0:
      return 0
    else:
      return 1
A, B = map(int, input().split())
print(calc0toN(A - 1) ^ calc0toN(B))

Buggy python submission (verdict: Runtime Error):
def calc0toN(a):
  bina = int(bin(a)[2:]) 
  if a % 2 == 0:
    if a % 4 == 0:
      return bina
    else:
      return 1 | bina
  else:
    if (a + 1) % 4 == 0:
      return 0
    else:
      return 1
A, B = map(int, input().split())
print(int("0b" + str(calc0toN(A - 1) | calc0toN(B)), 2))

Fixed submission:
def calc0toN(a):
  if a % 2 == 0:
    if a % 4 == 0:
      return a
    else:
      return 1 ^ a
  else:
    if (a + 1) % 4 == 0:
      return 0
    else:
      return 1
A, B = map(int, input().split())
print(calc0toN(A - 1) ^ calc0toN(B))
Buggy python submission (verdict: Runtime Error):
Y, M, D = map(int, input().split(/))
boo = False
if Y < 2019:
  boo = True
else:
  if Y == 2019 and M <= 4:
    boo = True
if boo:
  print("Heisei")
else:
  print("TBD")

Fixed submission:
Y, M, D = map(int, input().split("/"))
boo = False
if Y < 2019:
  boo = True
else:
  if Y == 2019 and M <= 4:
    boo = True
if boo:
  print("Heisei")
else:
  print("TBD")
Buggy python submission (verdict: Runtime Error):
N = int(input())
total = 0
for _ in range(N):
  x, u = input().split()
  i = int(x)
  if u == "JPY":
    tptal += i
  else:
    total += i*380000
print(total)    

Fixed submission:
N = int(input())
total = 0
for _ in range(N):
  x, u = input().split()
  i = float(x)
  if u == "JPY":
    total += i
  else:
    total += i*380000
print(total)

Buggy python submission (verdict: Runtime Error):
N = int(input())
total = 0
for _ in range(N):
  x, u = input().split()
  i = int(x)
  if u == "JPY":
    tptal += i
  else:
    total += i*380000.0
print(total)    

Fixed submission:
N = int(input())
total = 0
for _ in range(N):
  x, u = input().split()
  i = float(x)
  if u == "JPY":
    total += i
  else:
    total += i*380000
print(total)
Buggy python submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
inf = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
    if min(a, b, c) > 0:
      return abs(a - A) + abs(b - B) + abs(c - C) 
    else:
      return inf
  else:  
  ret0 = dfs(cur + 1, a, b, c) 
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))

Fixed submission:
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
inf = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
    if min(a, b, c) > 0:
      return abs(a - A) + abs(b - B) + abs(c - C) - 30 
    else:
      return inf
  else:  
    ret0 = dfs(cur + 1, a, b, c) 
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))

Buggy python submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
if cur == N:
  return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))


Fixed submission:
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
inf = 10 ** 9

def dfs(cur, a, b, c):
  if cur == N:
    if min(a, b, c) > 0:
      return abs(a - A) + abs(b - B) + abs(c - C) - 30 
    else:
      return inf
  else:  
    ret0 = dfs(cur + 1, a, b, c) 
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
print(dfs(0, 0, 0, 0))
Buggy python submission (verdict: Runtime Error):
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
　　x = int(input())
　　b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
　　res = INF
　　for S in [s[b - 1], s[b]]:
　　　　for T in [t[d - 1], t[d]]:
　　　　　　d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
　　　　　　res = min(res, d1, d2)
print(res)

Fixed submission:
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
for q in range(Q):
  x = int(input())
  b, d = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
  res = INF
  for S in [s[b - 1], s[b]]:
    for T in [t[d - 1], t[d]]:
      d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
      res = min(res, d1, d2)
  print(res)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
lis = [int(x) for x in input().split()]
lis.sort()
if N >= M:
  print(0)
else:
  lis2 = []
  for i in range(M - 1):
    lis2.append(lis[i + 1] - lis[i])
  lis2.sort(reverse = True)
  k = 0
  for i in range(N - 1, M - 1)

Fixed submission:
N, M = map(int, input().split())
lis = [int(x) for x in input().split()]
lis.sort()
if N >= M:
  print(0)
else:
  lis2 = []
  for i in range(M - 1):
    lis2.append(lis[i + 1] - lis[i])
  lis2.sort(reverse = True)
  k = 0
  for i in range(N - 1, M - 1):
    k += lis2[i]
  print(k)
Buggy python submission (verdict: Runtime Error):
S = input()
if S=="AAA" or S="BBB":
  print("No")
else:
  print("Yes")

Fixed submission:
S = input()
if S=="AAA" or S=="BBB":
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
ST = input().split()
s += ST[0]
s += ST[1]

Fixed submission:
ST = input().split()
s = ""
s += ST[1]
s += ST[0]
print(s)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
H = list(map(int, input().split()))
c = 0
for h in H:
  if h>=K:
    c += 1
primt(c)

Fixed submission:
N, K = map(int, input().split())
H = list(map(int, input().split()))
c = 0
for h in H:
  if h>=K:
    c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = []
c=0
f = True
for i in range(N):
  A.append(list(map(int, input().split())))
idx = [0 for i in range(N)]

a = 0

cc = 0

ccc = 0

btlf = [False for i in range(N)]#その周回ですでにバトルしたかどうかのフラグです
m = (N*(N-1))//2
n = 100000
for i in range(min(m,n)):#周回
  btlf = [False for i in range(N)]#リセット
  ccc = 0
  for j in range(N):
    #print(idx)
    if idx[j] != N-1:
      a = A[j][idx[j]]
      if a>j:
        if A[a-1][idx[a-1]]-1==j and btlf[a-1] == False and btlf[j] == False:
          idx[a-1]+=1
          btlf[a-1] = True
          idx[j]+=1
          btlf[j] = True
          cc+=1
          ccc+=1
  if cc == m:#idx == [N-1 for i in range(N)]:
    print(i+1)
    f = False
    break
  if ccc == 0:#対戦が一度もなければ打ち切ります
    break
if f:
  print(-1)

Fixed submission:
S = input()
T = input()
c = 0
if S[0]==T[0]:
  c += 1
if S[1]==T[1]:
  c += 1
if S[2]==T[2]:
  c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = map(int, input().split())
s = 0
for i in range(N):
  s += 1/i
print(1/s)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
s = 0
for i in range(N):
  s += 1/A[i]
print(1/s)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = map(int, input().split())
c = 0.0
for i in range(N):
  c += (1 / A[i])
print(1/c)
  

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
s = 0
for i in range(N):
  s += 1/A[i]
print(1/s)
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N = 100000:
  print(90909)
elif N >= 10000:
  print(909 + N - 9999)
elif N >= 1000:
  print(909)
elif N >= 100:
  print(9 + N - 99)
elif N >= 10:
  print(9)
else:
  print(N)

Fixed submission:
N = int(input())

if N == 100000:
  print(90909)
elif N >= 10000:
  print(909 + N - 9999)
elif N >= 1000:
  print(909)
elif N >= 100:
  print(9 + N - 99)
elif N >= 10:
  print(9)
else:
  print(N)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = map(int,input().split())

for i in range(N-1):
  if H(N-i-1) < H(N-i-2):
    H(N-i-2) -= 1
    
f = 0
for i in range(N-1):
  if H(N-i-1) < H(N-i-2):
    f = 1
    
if f == 0:
  print("No")
else:
  print("Yes")

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

for i in range(N-1):
  if H[N-i-1] < H[N-i-2]:
    H[N-i-2] -= 1
    
f = 0
for i in range(N-1):
  if H[N-i-1] < H[N-i-2]:
    f = 1
    
if f == 0:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
N = int(input())
H = map(int,input().split())

for i in range(N-1):
  if H(N-i-1) < H(N-i-2):
    H(N-i-2) -= 1
    
f = 0
for i in range(N-1):
  if H(N-i-1) < H(N-i-2):
    f = 1
    
if f = 0:
  print("No")
else:
  print("Yes")

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

for i in range(N-1):
  if H[N-i-1] < H[N-i-2]:
    H[N-i-2] -= 1
    
f = 0
for i in range(N-1):
  if H[N-i-1] < H[N-i-2]:
    f = 1
    
if f == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = list(map(int, input().split()))
err = 0
for i in range(N):
  if p[i]!=i:
    err+=0
if err == 0:
  print("YES")
elif err == 2:
  print("YES")
else:
  print("NO")

Fixed submission:
a, b = map(int, input().split())
if (a+b)%2 == 1:
  print("IMPOSSIBLE")
else:
  print((a+b)//2)

Buggy python submission (verdict: Runtime Error):
N = int(input())
p = list(map(int, input().split()))
err = 0
for i in range(N):
  if p[i]!=i:
    err+=0
if err == 0:
  print("YES")
elif err == 2:
  print("YES")
else:
  print("NO")

Fixed submission:
a, b = map(int, input().split())
if (a+b)%2 == 1:
  print("IMPOSSIBLE")
else:
  print((a+b)//2)
Buggy python submission (verdict: Runtime Error):
N = input(int())
p = list(map(int, input().split()))
err = 0
for i in range(N):
  if p[i]!=i:
    err+=0
if err == 0:
  print("YES")
elif err == 2:
  print("YES")
else:
  print("NO")

Fixed submission:
N = int(input())
p = list(map(int, input().split()))
err = 0
for i in range(N):
  if p[i] != i+1:
    err += 1
if err == 0:
  print("YES")
elif err == 2:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

kill = 0

if A[0] >= B[0]:
  kill += B[0]
  B[0] = 0
else:
  kill += A[0]
  B[0] -= A[0]

for i in range(N):
  if A[i+1] <= B[i]:
    kill += A[i+1]
  else:
    A[i+1] -= B[i]
    kill += B[i]
    if A[i+1] >= B[i+1]:
      kill += B[i+1]
      B[i+1] = 0
    else:
      kill += A[i+1]
      B[i+1] -= A[i+1]

print(kill)

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

kill = 0

if A[0] >= B[0]:
  kill += B[0]
  B[0] = 0
else:
  kill += A[0]
  B[0] -= A[0]

for i in range(N-1):
  if A[i+1] <= B[i]:
    kill += A[i+1]
  else:
    A[i+1] -= B[i]
    kill += B[i]
    if A[i+1] >= B[i+1]:
      kill += B[i+1]
      B[i+1] = 0
    else:
      kill += A[i+1]
      B[i+1] -= A[i+1]

if A[N] <= B[N-1]:
  kill += A[N]
else:
  kill += B[N-1]

print(kill)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

kill = 0

if A[0] >= B[0]:
  kill += B[0]
  B[0] = 0
else:
  kill += A[0]
  B[0] -= A[0]

for i in range(N):
  if A[i+1] <= B[i]:
    kill += A[i+1]
  else:
    A[i+1] -= B[i]
    kill += B[i]
    if A[i+1] >= B[i+1]:
      kill += B[i+1]
      B[i+1] = 0
    else:
      kill += A[i+1]
      B[i+1] -= A[i+1]

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

kill = 0

if A[0] >= B[0]:
  kill += B[0]
  B[0] = 0
else:
  kill += A[0]
  B[0] -= A[0]

for i in range(N-1):
  if A[i+1] <= B[i]:
    kill += A[i+1]
  else:
    A[i+1] -= B[i]
    kill += B[i]
    if A[i+1] >= B[i+1]:
      kill += B[i+1]
      B[i+1] = 0
    else:
      kill += A[i+1]
      B[i+1] -= A[i+1]

if A[N] <= B[N-1]:
  kill += A[N]
else:
  kill += B[N-1]

print(kill)
Buggy python submission (verdict: Runtime Error):
N, D = map(int, input().split())
print(int(N//(2*D+1.001) + 1))

Fixed submission:
r = int(input())
print(3*r*r)
Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())
if R-L >= 2020:
  print(0)
else:
  m = 2020
  for i in range(L, R):
    for j in range(i+1,R+1):
      m = min(m, (i*j)%2019)
print(m)

Fixed submission:
L, R = map(int, input().split())
if R-L >= 2020:
  print(0)
else:
  m = 2020
  for i in range(L, R):
    for j in range(i+1,R+1):
      m = min(m, (i*j)%2019)
  print(m)

Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())
if R-L >= 4050:
  print(1)
else:
  m = 2020
  for i in range(L, R):
    for j in range(i+1,R+1):
      m = min(m, (i*j)%2019)
print(m)

Fixed submission:
L, R = map(int, input().split())
if R-L >= 2020:
  print(0)
else:
  m = 2020
  for i in range(L, R):
    for j in range(i+1,R+1):
      m = min(m, (i*j)%2019)
  print(m)
Buggy python submission (verdict: Runtime Error):
N = int(input())
W = list(map(int, input().split()))
W = sorted(W)
m = 100000
for i in range(len(W)):
  m = min(m, abs(W[:i]-W[i:]))
print(m)

Fixed submission:
N = int(input())
W = list(map(int, input().split()))
m = 100000
for i in range(len(W)):
  m = min(m, abs(sum(W[:i])-sum(W[i:])))
print(m)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
l = 1
r = N
for i in range(M):
  L, R = map(int, input().split())
  if L > l:
    l = L
  if r > R:
    r = R
if l > r:
  print(0)
else:
  print(r-l+1)

Fixed submission:
A, B = map(int, input().split())
if A >= 13:
  print(B)
elif A <= 5:
  print(0)
else:
  print(B//2)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
l = 1
r = N
for i in range(M):
  L, R = map(int, input().split())
  if L < l:
    l = L
  if r < R:
    r = R
if l > r:
  print(0)
else:
  print(r-l+1)

Fixed submission:
A, B = map(int, input().split())
if A >= 13:
  print(B)
elif A <= 5:
  print(0)
else:
  print(B//2)
Buggy python submission (verdict: Runtime Error):
r, D, x2000 = map(int, input().split())
for i in range(10):
  x = r*x - D
  print(x)

Fixed submission:
r, D, x2000 = map(int, input().split())
x = x2000
for i in range(10):
  x = r*x - D
  print(x)
Buggy python submission (verdict: Runtime Error):
import math
N, K = map(int, input().split())

S = 0

for i in range(N):
  S += ((1/N)*(2**((-1)*max(0, math.ceil(math.log2((K-1)/(i+1)))))))

print(S)

Fixed submission:
import math
N, K = map(int, input().split())

S = 0

for i in range(N):
  S += ((1/N)*(2**((-1)*max(0, math.ceil(math.log2((K-0.1)/(i+1)))))))

print(S)

Buggy python submission (verdict: Runtime Error):
import math
N, K = map(int, input().split())

S = 0

for i in range(N):
  S += (1/N)*max(math.floor(math.log2((K-1)/N)),1)

print(S)

Fixed submission:
import math
N, K = map(int, input().split())

S = 0

for i in range(N):
  S += ((1/N)*(2**((-1)*max(0, math.ceil(math.log2((K-0.1)/(i+1)))))))

print(S)

Buggy python submission (verdict: Runtime Error):
import math
N, K = map(int, input().split())

S = 0

for i in range(N):
  S += (1/N)*math.floor(math.log2((K-1)/N))

print(S)

Fixed submission:
import math
N, K = map(int, input().split())

S = 0

for i in range(N):
  S += ((1/N)*(2**((-1)*max(0, math.ceil(math.log2((K-0.1)/(i+1)))))))

print(S)
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
print(max(2*A-1, 2*B-1, A+B)

Fixed submission:
A, B = map(int, input().split())
print(int(max(2*A-1, 2*B-1, A+B)))
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
AClst = []
c = 0

for i in range(N-1):
  if S[i:i+2]=="AC":
    c += 1
  AClst.append(c)
AClst.append(c)

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

Fixed submission:
B = input()

if B == "A":
  print("T")
elif B == "T":
  print("A")
elif B == "G":
  print("C")
else:
  print("G")
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
AClst = []
c = 0

for i in range(N-1):
  if S[i:i+2]=="AC":
    c += 1
  AClst.append(c)
AClst.append(c)

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

Fixed submission:
N, Q = map(int, input().split())
S = input()
AClst = [0]
c = 0

for i in range(N-1):
  if S[i:i+2]=="AC":
    c += 1
  AClst.append(c)

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

Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
AClst = []
count = 0

for i in range(N-1):
  if S[i:i+2]=="AC":
    c += 1
  AClst.append(c)
AClst.append(c)

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

Fixed submission:
N, Q = map(int, input().split())
S = input()
AClst = [0]
c = 0

for i in range(N-1):
  if S[i:i+2]=="AC":
    c += 1
  AClst.append(c)

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

Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
AClst = [] #ACのAを抜き出すリスト

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

for q in range(Q):
  l, r = map(int, input().split())
  print(AClst[l:r].count(1))

Fixed submission:
N, Q = map(int, input().split())
S = input()
AClst = [0]
c = 0

for i in range(N-1):
  if S[i:i+2]=="AC":
    c += 1
  AClst.append(c)

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

Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
AClst = [] #ACのAを抜き出すリスト

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

for q in range(Q):
  l, r = map(int, input().split())
  print(AClst[l:r].count(1))

Fixed submission:
N, Q = map(int, input().split())
S = input()
AClst = [0]
c = 0

for i in range(N-1):
  if S[i:i+2]=="AC":
    c += 1
  AClst.append(c)

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

Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
AClst = [] #ACのAを抜き出すリスト

for i in range(len(s)-1):
  if S[i,i+2]=="A":
    AClst.append(1)
  else:
    AClst.append(0)

for i in range(N):
  l, r = map(int, input().split())
  print(AClst[l:r].count(1))

Fixed submission:
N, Q = map(int, input().split())
S = input()
AClst = [0]
c = 0

for i in range(N-1):
  if S[i:i+2]=="AC":
    c += 1
  AClst.append(c)

for q in range(Q):
  l, r = map(int, input().split())
  print(AClst[r-1]-AClst[l-1])
Buggy python submission (verdict: Runtime Error):
A, B, K = map(int, input().split())
S = []
for i in range(100):
  if A%i==0 and B%i==0:
    S.append(i)
print(S[K-1])

Fixed submission:
A, B, K = map(int, input().split())
S = []
for i in range(100):
  if A%(i+1)==0 and B%(i+1)==0:
    S.append(i+1)
print(S[len(S)-K])
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = 0
for i in range(N):
  x, u = input().split()
  if u == "JPY":
    s += int(x)
  else:
    s += int(x) * 380000
print(s)

Fixed submission:
N = int(input())
s = 0
for i in range(N):
  x, u = input().split()
  if u == "JPY":
    s += float(x)
  else:
    s += float(x) * 380000.0
print(s)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
C = [0 for i in range(N)]
for i in range(N):
  if i == 0:
    C[i] == 0
  elif i == 1:
    c[i] == abs(H[i-1]-H[i])
  else:
    c[i] == min(abs(H[i-1]-H[i]), abs(H[i-2]-H[i]))
print(c[i])

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
C = [0 for i in range(N)]
for i in range(N):
  if i == 0:
    C[i] = 0
  elif i == 1:
    C[i] = abs(H[i-1]-H[i])
  else:
    C[i] = min(C[i-1] + abs(H[i-1]-H[i]), C[i-2] + abs(H[i-2]-H[i]))
print(C[N-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
t = 999 #平均気温とAとの最短の差
p = 0 #その差を記録したポイント
for i in range(H):
  if t > abs(A - T - H[i]*0.006):
    t = abs(A - T - H[i]*0.006)
    p = i+1
print(p)

Fixed submission:
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
t = 999 #平均気温とAとの最短の差
p = 0 #その差を記録したポイント
for i in range(len(H)):
  if t > abs(A - T + H[i]*0.006):
    t = abs(A - T + H[i]*0.006)
    p = i+1
print(p)
Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split())
A = []
for i in range(N):
  c, t = map(int, input().split())
  if t <= T:
    A.append(c)
if len(A)==0:
  print("TLE")
else:
  print(min(A))

Fixed submission:
N = int(input())
if N == 1:
  print("Hello World")
else:
  A = int(input())
  B = int(input())
  print(A+B)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
x = list(map(int, input().split()))
m = 10000000000000
for i in range(N-K+1):
  X = x[i:i+K]
  if X[0]*X[K-1] <= 0: # 区間に0を含む時
    m = min(m, 2*abs(X[0])+X[K-1], abs(X[0])+2*X[K-1])
  elif X[0]>0:
    m = min(m, X[K-1])
  else:
    m = min(m, abs(X[0]))
print(m)

Fixed submission:
N, K = map(int, input().split())
x = list(map(int, input().split()))
m = 10000000000000
for i in range(N-K+1):
  x1 = x[i]
  xk = x[i+K-1]
  if x1*xk <= 0: # 区間に0を含む時
    m = min(m, 2*abs(x1)+xk, abs(x1)+2*xk)
  elif x1>0:
    m = min(m, xk)
  else:
    m = min(m, abs(x1))
print(m)
Buggy python submission (verdict: Runtime Error):
A, B  map(int, input().split())
print((A-1)*(B-1))

Fixed submission:
A, B = map(int, input().split())
print((A-1)*(B-1))