Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
flag = True
for i in range(Q):
  string = input().split()
  if string[0] == '1':
    flag = not flag
  elif flag ^ (string[1] == '1'):
      S = S + string[2]
  else:
      S = string[2] + S
if not flag:
  S = S[::-1]
print(S)

Fixed submission:
from collections import deque
S = deque()
tmp = input()
for i in range(len(tmp)):
  S.append(tmp[i])
Q = int(input())
flag = True
for i in range(Q):
  string = input().split()
  if string[0] == '1':
    flag = not flag
  elif flag ^ (string[1] == '1'):
      S.append(string[2])
  else:
      S.appendleft(string[2])
if not flag:
  S.reverse()
for s in S:
  print(s, end='')

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
flag = True
for i in range(Q):
  string = input().split()
  if string[0] == '1':
    flag = not flag
  elif flag ^ (string[1] == '1'):
      S = S + string[2]
  else:
      S = string[2] + S
if not flag:
  S = S[::-1]
print(S)

Fixed submission:
from collections import deque
S = deque()
tmp = input()
for i in range(len(tmp)):
  S.append(tmp[i])
Q = int(input())
flag = True
for i in range(Q):
  string = input().split()
  if string[0] == '1':
    flag = not flag
  elif flag ^ (string[1] == '1'):
      S.append(string[2])
  else:
      S.appendleft(string[2])
if not flag:
  S.reverse()
for s in S:
  print(s, end='')

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
for i in range(Q):
  string = input().split()
  if string[0] == '1':
    S = S[::-1]
  elif string[1] == '1':
      S = string[2] + S
  else:
      S = S + string[2]
print(S)

Fixed submission:
from collections import deque
S = deque()
tmp = input()
for i in range(len(tmp)):
  S.append(tmp[i])
Q = int(input())
flag = True
for i in range(Q):
  string = input().split()
  if string[0] == '1':
    flag = not flag
  elif flag ^ (string[1] == '1'):
      S.append(string[2])
  else:
      S.appendleft(string[2])
if not flag:
  S.reverse()
for s in S:
  print(s, end='')

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
for i in range(Q):
  string = input().split()
  if string[0] == '1':
    S = S[::-1]
  elif string[1] == '1':
      S = string[2] + S
  else:
      S = S + string[2]
print(S)

Fixed submission:
from collections import deque
S = deque()
tmp = input()
for i in range(len(tmp)):
  S.append(tmp[i])
Q = int(input())
flag = True
for i in range(Q):
  string = input().split()
  if string[0] == '1':
    flag = not flag
  elif flag ^ (string[1] == '1'):
      S.append(string[2])
  else:
      S.appendleft(string[2])
if not flag:
  S.reverse()
for s in S:
  print(s, end='')
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
root = [[] for _ in range(N + 10)]
counter = [0 for _ in range(N + 10)]
for _ in range(N - 1):
  a, b = map(int, input().split())
  root[a].append(b)
  root[b].append(a)
for _ in range(Q):
  p, x = map(int, input().split())
  counter[p] += x
queue = [1]
while queue:
  vertex = queue.pop(0)
  for v in root[vertex]:
    counter[v] += counter[vertex]
    queue.append(v)
    root[v].remove(vertex)
for i in range(1, N):
  print('{} '.format(counter[i]), end='')
print(counter[N])

Fixed submission:
N, Q = map(int, input().split())
root = [[] for _ in range(N + 10)]
counter = [0 for _ in range(N + 10)]
for _ in range(N - 1):
  a, b = map(int, input().split())
  root[a].append(b)
  root[b].append(a)
for _ in range(Q):
  p, x = map(int, input().split())
  counter[p] += x
from collections import deque
d = deque([1])
while d:
  vertex = d.pop()
  for v in root[vertex]:
    counter[v] += counter[vertex]
    d.append(v)
    root[v].remove(vertex)
for i in range(1, N):
  print('{} '.format(counter[i]), end='')
print(counter[N])
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
  s = input()
  t = input()
  ans = 0
  alp = [[] for _ in range(27)]
  length_s = len(s)
  for i in range(length_s):
    char = ord(s[i]) - ord('a')
    alp[char].append(i + 1)
  length_t = len(t)
  import bisect
  for i in range(length_t):
    char = ord(t[i]) - ord('a')
    if alp[char]:
      if ans % length_s >= max(alp[char]):
        ans = (ans // length_s + 1) * length_s
      index = bisect.bisect_right(alp[char], ans % length_s)
      ans += alp[char][index] - ans % length_s
    else:
      return -1
  return ans
print(solve())

Fixed submission:
def solve():
  s = input()
  t = input()
  ans = 0
  alp = [[] for _ in range(27)]
  length_s = len(s)
  for i in range(length_s):
    char = ord(s[i]) - ord('a')
    alp[char].append(i + 1)
  length_t = len(t)
  import bisect
  for i in range(length_t):
    char = ord(t[i]) - ord('a')
    if alp[char]:
      if ans % length_s >= alp[char][-1]:
        ans = (ans // length_s + 1) * length_s
      index = bisect.bisect_right(alp[char], ans % length_s)
      ans += alp[char][index] - ans % length_s
    else:
      return -1
  return ans
print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
  s = input()
  t = input()
  ans = 0
  alp = [[] for _ in range(27)]
  length_s = len(s)
  for i in range(length_s):
    char = ord(s[i]) - ord('a')
    alp[char].append(i + 1)
  length_t = len(t)
  import bisect
  for i in range(length_t):
    char = ord(t[i]) - ord('a')
    if alp[char]:
      if ans % length_s >= max(alp[char]):
        ans = (ans // length_s + 1) * length_s
      index = bisect.bisect_right(alp[char], ans % length_s)
      ans += alp[char][index] - ans % length_s
    else:
      return -1
  return ans
print(solve())

Fixed submission:
def solve():
  s = input()
  t = input()
  ans = 0
  alp = [[] for _ in range(27)]
  length_s = len(s)
  for i in range(length_s):
    char = ord(s[i]) - ord('a')
    alp[char].append(i + 1)
  length_t = len(t)
  import bisect
  for i in range(length_t):
    char = ord(t[i]) - ord('a')
    if alp[char]:
      if ans % length_s >= alp[char][-1]:
        ans = (ans // length_s + 1) * length_s
      index = bisect.bisect_right(alp[char], ans % length_s)
      ans += alp[char][index] - ans % length_s
    else:
      return -1
  return ans
print(solve())
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
AB = [[] for _ in range(M + 10)]
ans = 0
for _ in range(N):
  a, b = map(int, input().split())
  if a > m:
    continue
  AB[a].append(b)
import heapq
reward = []
heapq.heapify(reward)
for i in range(1, M + 1):
  for item in AB[i]:
    heapq.heappush(reward, -item)
  if reward:
    ans -= heapq.heappop(reward)
print(ans)

Fixed submission:
N, M = map(int, input().split())
AB = [[] for _ in range(M + 10)]
ans = 0
for _ in range(N):
  a, b = map(int, input().split())
  if a > M:
    continue
  AB[a].append(b)
import heapq
reward = []
heapq.heapify(reward)
for i in range(1, M + 1):
  for item in AB[i]:
    heapq.heappush(reward, -item)
  if reward:
    ans -= heapq.heappop(reward)
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split(' '))
AB = [[] for _ in range(M + 10)]
ans = 0
for _ in range(N):
  a, b = map(int, input().split())
  AB[a].append(b)
import heapq
reward = []
heapq.heapify(reward)
for i in range(1, M + 1):
  for item in AB[i]:
    heapq.heappush(reward, -item)
  if reward:
    ans -= heapq.heappop(reward)
print(ans)

Fixed submission:
N, M = map(int, input().split())
AB = [[] for _ in range(M + 10)]
ans = 0
for _ in range(N):
  a, b = map(int, input().split())
  if a > M:
    continue
  AB[a].append(b)
import heapq
reward = []
heapq.heapify(reward)
for i in range(1, M + 1):
  for item in AB[i]:
    heapq.heappush(reward, -item)
  if reward:
    ans -= heapq.heappop(reward)
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split(' '))
AB = [[] for _ in range(N + 10)]
ans = 0
for _ in range(N):
  a, b = map(int, input().split())
  AB[a].append(b)
import heapq
reward = []
heapq.heapify(reward)
for i in range(1, M + 1):
  for item in AB[i]:
    heapq.heappush(reward, -item)
  if reward:
    ans -= heapq.heappop(reward)
print(ans)

Fixed submission:
N, M = map(int, input().split())
AB = [[] for _ in range(M + 10)]
ans = 0
for _ in range(N):
  a, b = map(int, input().split())
  if a > M:
    continue
  AB[a].append(b)
import heapq
reward = []
heapq.heapify(reward)
for i in range(1, M + 1):
  for item in AB[i]:
    heapq.heappush(reward, -item)
  if reward:
    ans -= heapq.heappop(reward)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
class Edge:
  def __init__(self, starting_point, arrival_point, cost):
    self.starting_point = starting_point
    self.arrival_point = arrival_point
    self.cost = cost

def solve():
  N, M, P = map(int, input().split())
  edges = []
  dist = [float('inf') for _ in range(N + 10)]
  dist[1] = 0
  ans = 0
  for i in range(M):
    a, b, c = map(int, input().split())
    e = Edge(a, b, -c + P)
    edges.append(e)
  for i in range(2 * N):
    for e in edges:
      if dist[e.arrival_point] > e.cost + dist[e.starting_point]:
        dist[e.arrival_point] = e.cost + dist[e.starting_point]
        if e.arrival_point == N and i == 2 * N - 1:
          return -1
  return max((-1) * dist[N], 0)
print(solve())

Fixed submission:
class Edge:
  def __init__(self, starting_point, arrival_point, cost):
    self.starting_point = starting_point
    self.arrival_point = arrival_point
    self.cost = cost

def solve():
  N, M, P = map(int, input().split())
  edges = []
  INF = float('inf')
  dist = [INF for _ in range(N + 10)]
  dist[1] = 0
  for i in range(M):
    a, b, c = map(int, input().split())
    e = Edge(a, b, -c + P)
    edges.append(e)
  for i in range(2 * N):
    for e in edges:
      if dist[e.arrival_point] > e.cost + dist[e.starting_point]:
        dist[e.arrival_point] = e.cost + dist[e.starting_point]
        if i == N - 1:
          dist[e.arrival_point] = -INF
  if dist[N] != -INF:
    return max(-dist[N], 0)
  else:
    return -1
print(solve())
Buggy python submission (verdict: Runtime Error):
import math
MOD = 10**9 + 7
comb = lambda n, r: math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N, K = map(int, input().split(' '))
red = N - K
for i in range(K):
  res = comb(red + 1, i + 1) * comb(K - 1, i)
  res %= MOD
  print(res)

Fixed submission:
import math
def comb(n, r):
  if n - r < 0:
    return 0
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
MOD = 10**9 + 7
N, K = map(int, input().split(' '))
red = N - K
for i in range(K):
  res = comb(red + 1, i + 1) * comb(K - 1, i)
  res %= MOD
  print(res)
Buggy python submission (verdict: Runtime Error):
import math
def lcm(x, y):
  return (x * y) // math.gcd(x, y)
A, B, C, D = map(int, input().split(' '))
res = 0
can_dived_c = B // C - (A - 1) // C
can_dived_d = B // D - (A - 1) // D
can_dived_both = B // lcm(C, D) - (A - 1) // lcm(C, D)
res = B - (A - 1) - can_dived_c - can_dived_d + can_dived_both
print(res)

Fixed submission:
def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
def lcm(x, y):
  return (x * y) // gcd(x, y)
A, B, C, D = map(int, input().split(' '))
can_dived_c = B // C - (A - 1) // C
can_dived_d = B // D - (A - 1) // D
can_dived_both = B // lcm(C, D) - (A - 1) // lcm(C, D)
res = B - (A - 1) - can_dived_c - can_dived_d + can_dived_both
print(res)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split(' '))
count = (N - 1) * (N - 2) // 2
is_connect = [[False for _ in range(N)] for _ in range(N)]
if K > count:
  print(-1)
else:
  for i in range(1, N):
    is_connect[0][i] = True
  i = 2
  j = 1
  for _ in range(count - K):
    is_connect[j][i] = True
    i += 1
    if i == N - 1:
      j += 1
      i = j + 1
  for i in range(N):
    for j in range(N):
      if i != j and is_connect[i][j]:
        print('{0} {1}'.format(i + 1, j + 1))

Fixed submission:
N, K = map(int, input().split(' '))
count = (N - 1) * (N - 2) // 2
is_connect = [[False for _ in range(N)] for _ in range(N)]
if K > count:
  print(-1)
else:
  for i in range(1, N):
    is_connect[0][i] = True
  i = 2
  j = 1
  for _ in range(count - K):
    is_connect[j][i] = True
    if i == N - 1:
      j += 1
      i = j + 1
    else:
      i += 1
  print(N - 1 + count - K)
  for i in range(N):
    for j in range(N):
      if i != j and is_connect[i][j]:
        print('{0} {1}'.format(i + 1, j + 1))
Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
h = list(map(int, input().split(' ')))
h.append(math.inf)
h.append(math.inf)
dp = [math.inf for _ in range(N + 100)]
dp[0] = 0
for i in range(N-1):
  dp[i+1] = min(dp[i] + abs(h[i+1] - h[i]), dp[i+1])
  dp[i+2] = min(dp[i] + abs(h[i+2] - h[i]), dp[i+2])
print(dp[N-1])

Fixed submission:
f_inf = float('inf')
N = int(input())
h = list(map(int, input().split(' ')))
h.append(f_inf)
h.append(f_inf)
dp = [f_inf for _ in range(N + 100)]
dp[0] = 0
for i in range(N-1):
  dp[i+1] = min(dp[i] + abs(h[i+1] - h[i]), dp[i+1])
  dp[i+2] = min(dp[i] + abs(h[i+2] - h[i]), dp[i+2])
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
f_inf = float('inf')
N, K = map(int, input().split(' '))
h = list(map(int, input().split(' ')))
h.append(f_inf)
h.append(f_inf)
dp = [f_inf for _ in range(N + 100)]
dp[0] = 0
for i in range(N - 1):
  for j in range(1, K + 1):
    if i + j > N - 1:
      break
    dp[i+j] = min(dp[i] + abs(h[i+j] - h[i]), dp[i+j])
print(dp[N-1])

Fixed submission:
f_inf = float('inf')
N, K = map(int, input().split(' '))
h = list(map(int, input().split(' ')))
h.append(f_inf)
h.append(f_inf)
dp = [f_inf for _ in range(N + 100)]
dp[0] = 0
for i in range(N - 1):
  for j in range(1, K + 1):
    if i + j > N - 1:
      break
    dp[i+j] = min(dp[i] + abs(h[i+j] - h[i]), dp[i+j])
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
p = [0]
p += list(map(float, input().split(' ')))
dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
dp[1][0], dp[1][1] = 1- p[1], p[1]
for i in range(2, N + 1):
  for j in range(i + 1):
      dp[i][j] = dp[i-1][j-1]  * p[i]
      dp[i][j] += dp[i-1][j] * (1 - p[i])
res = 0
for i in range(N // 2 + 1, N + 1):
  res += dp[N][i]
print(res)

Fixed submission:
N = int(input())
p = [0]
p += list(map(float, input().split(' ')))
dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
dp[1][0], dp[1][1] = 1- p[1], p[1]
for i in range(2, N + 1):
  for j in range(i + 1):
      dp[i][j] = dp[i-1][j-1]  * p[i]
      dp[i][j] += dp[i-1][j] * (1 - p[i])
res = 0
for i in range(N // 2 + 1, N + 1):
  res += dp[N][i]
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
import itertools

def calc(a,b,c):
    x=gcd(a,b)
    y=gcd(x,c)
    return y

n=int(input())

A=list(itertools.product(range(1,n+1), repeat=3))

D={}
for i in A:
    mat=tuple(sorted(i))
    if mat in D:
        D[mat]+=1
    else:
        D[mat]=1

ans=0
for a,b,c in D:
    ans+=calc(a,b,c)*D[(a,b,c)]
print(ans)


Fixed submission:
from math import gcd
import itertools

def calc(a,b,c):
    x=gcd(a,b)
    y=gcd(x,c)
    return y

n=int(input())
A=list(itertools.combinations_with_replacement(range(1,n+1), 3))

ans=0
for a,b,c in A:
    if a==b==c:
        ans+=calc(a,b,c)
    elif a!=b and a!=c and b!=c:
        ans+=calc(a,b,c)*6
    else:
        ans+=calc(a,b,c)*3
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=list(map(int,input().split()))

D={}
for i in A:
      if i not in D:
            D[i]=1
      else:
            D[i]+=1


for i in range(n):
      D[A[i]]-=1
      ans=0
      for j in D.values():
            ans+=j*(j-1)//2
      print(ans)
      D[A[i]]+=1
      

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

D={}
for i in A:
      if i not in D:
            D[i]=1
      else:
            D[i]+=1
S=0
DD=D.copy()
for i in DD:
      bu=DD[i]
      DD[i]=bu*(bu-1)//2
      S+=DD[i]

for i in range(n):
      print(S-(D[A[i]]-1))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
P=list(map(int,input().split()))
R=[0]*(n-k+1)
ma=0
for i in range(n-k+1):
    R[i]=sum(P[i:i+k])
    ma=max(ma,R[i])
print((ma+k)/2)

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

S=[0]*(n+1)
S[1]=P[0]
for i in range(2,n+1):
        S[i]=S[i-1]+P[i-1]
ma=0
for i in range(k,n+1):
       s=S[i]-S[i-k]
       if ma<s:
              ma=s
print((ma+k)/2)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
P=list(map(int,input().split()))
R=[0]*(n-k+1)
for i in range(n-k+1):
    R[i]=sum(P[i:i+k])
print((max(R)+k)/2)

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

S=[0]*(n+1)
S[1]=P[0]
for i in range(2,n+1):
        S[i]=S[i-1]+P[i-1]
ma=0
for i in range(k,n+1):
       s=S[i]-S[i-k]
       if ma<s:
              ma=s
print((ma+k)/2)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
P=list(map(int,input().split()))
dp=[0]*(n+1)
for i in range(n+1):
    dp[i+1]+=dp[i]+P[i]
ans=0
for i in range(n-k+1):
    ans=max(ans,dp[i+k]-dp[i])
print((ans+k)/2)
    

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

S=[0]*(n+1)
S[1]=P[0]
for i in range(2,n+1):
        S[i]=S[i-1]+P[i-1]
ma=0
for i in range(k,n+1):
       s=S[i]-S[i-k]
       if ma<s:
              ma=s
print((ma+k)/2)

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

ma=0
for i in range(n-k+1):
       s=sum(P[i:i+k])
       if ma<s:
              ma=s
print((ma+k)/2)
       

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

S=[0]*(n+1)
S[1]=P[0]
for i in range(2,n+1):
        S[i]=S[i-1]+P[i-1]
ma=0
for i in range(k,n+1):
       s=S[i]-S[i-k]
       if ma<s:
              ma=s
print((ma+k)/2)
Buggy python submission (verdict: Runtime Error):
def keta1(n):
    s = str(n)
    return (len(s) - 1) * 9 + int(s[0])
 
def keta2(n):
    if n < 10:
      return 0
    s = str(n)
    cnt = [0] * 101
    for i in range(2, 101):
        cnt[i] = 9 * 9 * (i - 1)
    res = 0
    for i in range(len(s)):
        res += cnt[i]
    res += (int(s[0]) - 1) * keta1(10 ** (len(s) - 1) - 1) + keta1(int(s[1:]))
    return res
 
def keta3(n):
    s = str(n)
    cnt = [0] * 101
    for i in range(3, 101):
        cnt[i] = 9 * 9 * 9 * (i - 1) * (i - 2) // 2
    res = 0
    for i in range(len(s)):
        res += cnt[i]
    res += (int(s[0]) - 1) * keta2(10 ** (len(s) - 1) - 1) + keta2(int(s[1:]))
    return res
 
if K == 1:
    print(keta1(N))
elif K == 2:
    print(keta2(N))
elif K == 3:
    print(keta3(N))
        

Fixed submission:
N = int(input())
K = int(input())
 
def keta1(n):
    s = str(n)
    return (len(s) - 1) * 9 + int(s[0])
 
def keta2(n):
    if n < 10:
      return 0
    s = str(n)
    cnt = [0] * 101
    for i in range(2, 101):
        cnt[i] = 9 * 9 * (i - 1)
    res = 0
    for i in range(len(s)):
        res += cnt[i]
    res += (int(s[0]) - 1) * keta1(10 ** (len(s) - 1) - 1) + keta1(int(s[1:]))
    return res
 
def keta3(n):
    s = str(n)
    cnt = [0] * 101
    for i in range(3, 101):
        cnt[i] = 9 * 9 * 9 * (i - 1) * (i - 2) // 2
    res = 0
    for i in range(len(s)):
        res += cnt[i]
    res += (int(s[0]) - 1) * keta2(10 ** (len(s) - 1) - 1) + keta2(int(s[1:]))
    return res
 
if K == 1:
    print(keta1(N))
elif K == 2:
    print(keta2(N))
elif K == 3:
    print(keta3(N))
Buggy python submission (verdict: Runtime Error):
h, n = map(int, input().split())
a = []
b = []
for _ in range(n):
    ai, bi = map(int, input().split())
    a.append(ai)
    b.append(bi)
 
dp = [float("inf")] * (2 * 10000 + 1)
dp[0] = 0
for i in range(h):
    for j in range(n):
        if (i + a[j]) > 2 * 10000:
            dp[2 * 10000] = min(dp[2 * 10000], dp[i] + b[j])
            continue
        dp[i + a[j]] = min(dp[i + a[j]], dp[i] + b[j])
 
ans = float('inf')
for j in range(h, 2 * 10000 + 1):
    ans = min(ans, dp[j])
print(ans)

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

if h%a:
       print(h//a+1)
else:
       print(h//a)
Buggy python submission (verdict: Runtime Error):
h=int(input())

a=1
b=1
ans=0s
for i in range(1,h+1):
       if i==b:
              ans+=b
              b=b*2
              
print(ans)

Fixed submission:
h=int(input())

a=1
b=0
ans=0
for i in range(1,41):
       if h<a:
              break
       ans+=a
       a=a*2
       b+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
 
ans=0
for i in range(1,n+1):
       if i%10==0:
              continue
       for j in range(1,n+1):
              if str(i)[0]==str(j)[-1] and str(i)[-1]==str(j)[0]:
                     ans+=1
print(ans)

Fixed submission:
n=int(input())
ans=0
dic={}
for i in range(1,n+1):
    s=str(i)
    d=(s[0],s[-1])
    if d not in dic.keys():
        dic[d] = 1
    else:
        dic[d] += 1
 
for a in dic.keys():
    b = (a[1],a[0])
    if b in dic.keys():
        ans += dic[a]*dic[(a[1],a[0])]
 
print(ans)
Buggy python submission (verdict: Runtime Error):
c=input()
S='abcdefghijklmnopqrstuvwxyz"
for i in range(26):
  if c==S[i]:
    print(S[i+1])

Fixed submission:
c=input()
L=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

for i in range(len(L)):
    if c==L[i]:
        print(L[i+1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n % 2 == 1:
	print(0)
	exit()
 
# 5の倍数で割り切れる回数
result = 0
i = 1
while True:
	result += inp_n // ((5 ** i) * 2)
	i += 1
	if inp_n < ((5 ** i) * 2): break
 
# 結果出力
print(result)


Fixed submission:
N = int(input())
 
if N % 2 > 0 or N < 10:
  print(0)
  exit()
else:
  #S = str(N)[::-1]
  ans = 0
  N = N // 10
  for i in range(50):
    ans += N
    N = N // 5
    
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=[]
B=[]
for i in range(n):
   a=int(input())
   A.append(a)
   d=[]
   for j in range(a):
      x,y=map(int,input().split())
      d.append((x,y))
   B.append(d)
c=0
for i in range(2**n):
   L=[0]*n
   for j in range(n):
      if i>>j&1
         L[j]=1
   if 1 in L:
      flag=True
      for k in range(n):
         if L[k]==1:
            for m in range(A[k]):
               if L[B[k][m][0]-1]!=B[k][m][1]:
                  flag=False
                  break
      if flag:
         c=max(sum(L),c)
print(c)

Fixed submission:
n = int(input())
l = []
for i in range(n):
    a = int(input())
    l.append([tuple(map(int, input().split())) for _ in range(a)])
 
cnt = 0
for i in range(1 << n):
    Flag = True
    for j in range(n):
        if (i >> j) & 1:
            for x, y in l[j]:
                if i >> (x-1) & 1 != y:
                    Flag = False
                    break
    if Flag:
        cnt = max(cnt, sum(map(int, bin(i)[2:])))
 
print(cnt)