Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N, M = map(int, input().split())
friend_info = [list(map(int, input().split())) for _ in range(M)]

relation_dict = {}
for person1, person2 in friend_info:
    add_flag = False
    for k, v in relation_dict.items():
        if((person1 in v) or (person2 in v)):
            relation_dict[k].add(person1)
            relation_dict[k].add(person2)
            add_flag = True
            break
    if(add_flag == False):
        new_key = str(len(relation_dict)+1)
        relation_dict[new_key] = {person1, person2}

max_group = max([len(relation) for relation in relation_dict.values()])

print(max_group)


Fixed submission:
D, T, S = map(int, input().split())
if S * T >= D:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N, M = map(int, input().split())
friend_info = [list(map(int, input().split())) for _ in range(M)]

relation_dict = {}
for person1, person2 in friend_info:
    add_flag = False
    for k, v in relation_dict.items():
        if((person1 in v) or (person2 in v)):
            relation_dict[k].add(person1)
            relation_dict[k].add(person2)
            add_flag = True
            break
    if(add_flag == False):
        new_key = str(len(relation_dict)+1)
        relation_dict[new_key] = {person1, person2}

max_group = max([len(relation) for relation in relation_dict.values()])
print(max_group)

Fixed submission:
D, T, S = map(int, input().split())
if S * T >= D:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
long_str = input()
short_str = input()
short_list = list(short_str)
 
long_len = len(long_str)
short_len = len(short_str)
iter_num = long_len - short_len + 1
 
max_count = 0
for i in range(iter_num):
  tmp = 0
  obj_list = list(long_str[i:(short_len+i)])
  for s, o in zip(short_list, obj_list):
    tmp += int(s == o)
  max_count = max(max_count, tmp)

print(short_len - max_count)

Fixed submission:
D, T, S = map(int, input().split())
if S * T >= D:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
import numpy as np

list_len = int(input())
A_list = list(map(int, input().split()))

comb = np.array(list(combinations(A_list, 2)))
comb_mul = np.apply_along_axis(lambda x: x[0]*x[1], 1, comb)
total_sum = sum(comb_mul)
mod_result = total_sum % (10**9+7)

print(mod_result)

Fixed submission:
N = int(input()) #入力する整数
A = list(map(int,input().split())) #入力する数列A
SUMA = sum(A) #数列の和
MOD = 10**9 + 7 # mod
C = [0] * (N-1) #累積和数列
for i in range(N-1): #\sum_{j = i+1}^{N}を求めて数列に代入する
  SUMA -= A[i]
  C[i] = SUMA
ans = 0 #求める答え
for i in range(N-1):
  ans += A[i]*C[i]
  ans %= MOD #その都度modで割った余りにする
print(ans) #答えを出力する

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

list_len = int(input())
A_list = list(map(int, input().split()))

comb = list(combinations(A_list, 2))
comb_mul = list(map(lambda row: row[0]*row[1], comb))
total_sum = sum(comb_mul)
mod_result = total_sum % (10**9+7)

print(mod_result)

Fixed submission:
N = int(input()) #入力する整数
A = list(map(int,input().split())) #入力する数列A
SUMA = sum(A) #数列の和
MOD = 10**9 + 7 # mod
C = [0] * (N-1) #累積和数列
for i in range(N-1): #\sum_{j = i+1}^{N}を求めて数列に代入する
  SUMA -= A[i]
  C[i] = SUMA
ans = 0 #求める答え
for i in range(N-1):
  ans += A[i]*C[i]
  ans %= MOD #その都度modで割った余りにする
print(ans) #答えを出力する
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N, M = map(int, input().split())
friend_info = [list(map(int, input().split())) for _ in range(M)]

relation_dict = {}
for person1, person2 in friend_info:
    add_flag = False
    for k, v in relation_dict.items():
        if((person1 in v) or (person2 in v)):
            relation_dict[k].add(person1)
            relation_dict[k].add(person2)
            add_flag = True
            break
    if(add_flag == False):
        new_key = str(len(relation_dict)+1)
        relation_dict[new_key] = {person1, person2}

max_group = max([len(relation) for relation in relation_dict.values()])

print(max_group)


Fixed submission:
def find(target):
    if parent[target] < 0:
        return target
    else:
        parent[target] = find(parent[target])
        return parent[target]

def is_same(x, y):
    return find(x) == find(y)

def union(x, y):
    root_x = find(x)
    root_y = find(y)
    if root_x == root_y:
        return
    if parent[root_x] > parent[root_y]:
        root_x, root_y = root_y, root_x
    parent[root_x] += parent[root_y]
    parent[root_y] = root_x

# 今回これ使わないけど、どこに誰がいるのかはこれでわかる
def members(n, x):
    root = find(x)
    return [i for i in range(n) if find(i) == root]

def get_size(x):
    return -parent[find(x)]

def get_root():
    return [i for i, root in enumerate(parent) if root < 0]
n, m = map(int, input().split())
parent = [-1 for _ in range(n)]
for _ in range(m):
    a, b = map(lambda x: int(x) - 1, input().split())
    union(a, b)
ans = 0
for i in range(n):
    ans = max(ans, get_size(i))
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
c=0
for i in range(len(s)):
  if s[i]!=t[i]:
    c+=1
print(c)    

Fixed submission:
a=int(input())
print(a+a**2+a**3)
Buggy python submission (verdict: Runtime Error):
import numpy as np

n = int(input())
L = [int(i) for i in input().split()]
LL = [0 for i in range(pow(10,5)+1)]
LLL = np.ones(pow(10,5)+1, dtype = "uint64")
 
for i in range(n):
  LL[L[i]] += 1
  
out = 1
for i in range(len(LL)-1):
  LLL[i+1] = pow(i+1, LL[i+1])

out = int(int(np.prod(LLL)) % 998244353)
if L[0] != 0 or L.count(0) != 1:
  out = 0
print(out)

Fixed submission:
n = int(input())
L = [int(i) for i in input().split()]
LL = [0 for i in range(pow(10,5)+1)]
 
for i in range(n):
  LL[L[i]] += 1
  
MOD = 998244353
out = 1
maximum = max(L)
for i in range(maximum):
  out = (out * pow(LL[i], LL[i+1], MOD)) % MOD
 
if L[0] != 0 or LL[0] != 1:
  out = 0

for i in range(maximum):
  if L[i+1] == 0:
    out = 0
  
print(out)

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

n = int(input())
L = [int(i) for i in input().split()]
LL = [0 for i in range(pow(10,5)+1)]
LLL = np.ones(pow(10,5)+1, dtype = "uint64")
 
for i in range(n):
  LL[L[i]] += 1
  
out = 1
for i in range(len(LL)-1):
  LLL[i+1] = pow(i+1, LL[i+1])

out = int(np.prod(LLL))
if L[0] != 0 or LL[0] != 1:
  out = 0
print(out % 998244353)

Fixed submission:
n = int(input())
L = [int(i) for i in input().split()]
LL = [0 for i in range(pow(10,5)+1)]
 
for i in range(n):
  LL[L[i]] += 1
  
MOD = 998244353
out = 1
maximum = max(L)
for i in range(maximum):
  out = (out * pow(LL[i], LL[i+1], MOD)) % MOD
 
if L[0] != 0 or LL[0] != 1:
  out = 0

for i in range(maximum):
  if L[i+1] == 0:
    out = 0
  
print(out)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

print(max(o, a-2*b))

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

print(max(0, a-2*b))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L = [int(i) for i in input().split()]
out = 0

for i in range(n):
  temp = 0
  for j in range(i,n-1):
    if L[j] >= L[j+1]:
      temp += 1
    else:
      break
  if temp > out:
    out = temp
print(out)

Fixed submission:
import numpy as np

n = int(input())
L = np.array([int(i) for i in input().split()])
LL = np.roll(L, -1)
LL[-1] = pow(10,9)+1
LL = L >= LL

tindex = -1
out = 0
for i in range(n):
  if LL[i] == False:
    if (i-tindex) > out:
      out = i-tindex-1
    tindex = i
print(out)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
L = []

for i in range(n):
  a, b = map(int, input().split())
  for j in range(b):
    L.append(a)

L.sort()
print(L[k-1])

Fixed submission:
n, k = map(int, input().split())
L = [0]*(pow(10,5)+1)

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

s = 0
for i in range(pow(10,5)+1):
  s += L[i]
  if s >= k:
    print(i)
    break
Buggy python submission (verdict: Runtime Error):
s, t, u = map(str, input().split())

print(s.upper[0]+t.upper[0]+u.upper[0])

Fixed submission:
s, t, u = map(str, input().split())

print(s.upper()[0]+t.upper()[0]+u.upper()[0])
Buggy python submission (verdict: Runtime Error):
import math
def pcount(n, r):
    return math.factorial(n) // (math.factorial(r)* math.factorial(n - r))

n, a, b = map(int, input().split())
L = [int(i) for i in input().split()]
L.sort(reverse=True)

T = L[:a]
print(sum(T)/a)

s = 0
Tmin = min(T)
countTminT = T.count(Tmin)
countTminL = L.count(Tmin)

if a == 1 and countTminL == 1:
  s = 1
elif countTminT == a:
  for i in range(a,b+1):
    s += pcount(countTminL, i)
else:
  s += pcount(countTminL, countTminT)

print(s)

Fixed submission:
import math
def pcount(n, r):
    return math.factorial(n) // (math.factorial(r)* math.factorial(n - r))

n, a, b = map(int, input().split())
L = [int(i) for i in input().split()]
L.sort(reverse=True)

T = L[:a]
print(sum(T)/a)

s = 0
Tmin = min(T)
countTminT = T.count(Tmin)
countTminL = L.count(Tmin)

if a == 1 and countTminL == 1:
  s = 1
elif countTminT == a:
  for i in range(a,b+1):
    if countTminL+1 == i:
      break
    s += pcount(countTminL, i)
else:
  s += pcount(countTminL, countTminT)

print(s)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

if a == b:
  print("H")
else:
  print("D")

Fixed submission:
a, b = map(str, input().split())
 
if a == b:
  print("H")
else:
  print("D")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

s = 1

for i in range(n):
  s = s * (i+1)
print(s%1000000007)

Fixed submission:
n = int(input())
 
s = 1
 
for i in range(n):
  s = (s * (i+1)) % 1000000007
print(s%1000000007)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

L = factorization(math.factorial(n))

out = 1
for i in range(len(L)):
  out = out * (L[i][1] + 1)
out = out % (pow(10,9)+7)
print(out)


Fixed submission:
import math
n = int(input())
outlist = [0 for i in range(n+1)]

def isprime(n):
  for i in range(2, int(math.sqrt(n)+1)):
    if n%i == 0:
      return (0)
      break
  return (1)
    
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr 

for i in range(2,n+1):
  L = factorization(i)
  for j in range(len(L)):
    if isprime(L[j][0]) == 1:
      outlist[L[j][0]] += L[j][1]

out = 1
for i in range(len(outlist)):
  out = out * (outlist[i]+1)
print(out % (pow(10,9)+7))

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

L = factorization(math.factorial(n))

out = 1
for i in range(len(L)):
  out = out * (L[i][1] + 1)
print(out)


Fixed submission:
import math
n = int(input())
outlist = [0 for i in range(n+1)]

def isprime(n):
  for i in range(2, int(math.sqrt(n)+1)):
    if n%i == 0:
      return (0)
      break
  return (1)
    
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr 

for i in range(2,n+1):
  L = factorization(i)
  for j in range(len(L)):
    if isprime(L[j][0]) == 1:
      outlist[L[j][0]] += L[j][1]

out = 1
for i in range(len(outlist)):
  out = out * (outlist[i]+1)
print(out % (pow(10,9)+7))
Buggy python submission (verdict: Runtime Error):
a o b = map(str, input().split())

if o == "+":
  print(int(a) + int(b))
else:
  print(int(a) - int(b))

Fixed submission:
a, o, b = map(str, input().split())
 
if o == "+":
  print(int(a) + int(b))
else:
  print(int(a) - int(b))
Buggy python submission (verdict: Runtime Error):
n = int(input())
L = [int(i) for i in input().split()]
L.sort()

def out_detect(n,L):
  flag = 0
  if n%2 == 0:
    for i in range(n):
      if L[i] != -(-(i+1)//2)*2-1:
        flag = 1
        break
  else:
    if L[0] != 0:
      flag = 1
      return (flag)
    for i in range(1,n):
      if L[i] != (-(-i//2)*2):
        flag = 1
        break
  return (flag)

if out_detect(n,L) == 1:
  print(0)
else:
  if n%2 == 0:
    out = pow(2,n//2)
  else:
    out = pow(2,(n-1)//2)
print(out%(pow(10,9)+7))

Fixed submission:
n = int(input())
L = [int(i) for i in input().split()]
L.sort()

def out_detect(n,L):
  flag = 0
  if n%2 == 0:
    for i in range(n):
      if L[i] != -(-(i+1)//2)*2-1:
        flag = 1
        break
  else:
    if L[0] != 0:
      flag = 1
      return (flag)
    for i in range(1,n):
      if L[i] != (-(-i//2)*2):
        flag = 1
        break
  return (flag)

if out_detect(n,L) == 1:
  print(0)
else:
  if n%2 == 0:
    out = pow(2,n//2)
  else:
    out = pow(2,(n-1)//2)
  print(out%(pow(10,9)+7))
Buggy python submission (verdict: Runtime Error):
a,b,c = map(input().split())
out = a[0] + b[0] + c[0]
print(out)

Fixed submission:
a,b,c = map(str, input().split())
out = a[0] + b[0] + c[0]
print(out)
Buggy python submission (verdict: Runtime Error):
5
3 10
48 17
31 199
231 23
3 2

Fixed submission:
n = int(input())
L = []
for i in range(n):
	L.append([int(i) for i in input().split()])

x = L[0][0]
y = L[0][1]

for i in range(n-1):
  n = max(-(-x//L[i+1][0]), -(-y//L[i+1][1]))
  x = n*L[i+1][0]
  y = n*L[i+1][1]

print(x+y)
Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
Li = [input() for i in range(N)]

s = ""
for i in range(N):
  temp = min(Li)
  Li.remove(temp)
  s += temp
print(s)

Fixed submission:
a, b, c = map(str, input().split())
s = a+b+c

if s.count("5") == 2 and s.count("7") == 1:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
L = [input() for i in range(N)]

s = ""
for i in range(N):
  temp = min(L)
  L.remove(temp)
  s += temp
print(s)

Fixed submission:
a, b, c = map(str, input().split())
s = a+b+c

if s.count("5") == 2 and s.count("7") == 1:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
 v = input()
 if v % 9 == 0
     print('Yes')
 else:
     print('No')

Fixed submission:
s=int(input())
if s%9==0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

print(min(n % k, n % abs(n - k)))

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

if n > k:
    print(min(n % k, abs(n % k - k)))
elif n == k:
    print(0)
elif n < k:
    print(min(n, k - n))
Buggy python submission (verdict: Time Limit Exceeded):
def cmb(n, r, p):
    if r < 0 or n < r:
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

n, a, b = map(int, input().split())

p = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

for i in range(2, n + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ma = cmb(n, a, p)
mb = cmb(n, b, p)

print((pow(2, n, p) - 1 - ma - mb) % p)

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

p = 10 ** 9 + 7
inv = [0] * (b + 1)
inv[1] = 1

for k in range(2, b + 1):
	inv[k] = pow(k, p - 2, p)

com = 1
for i in range(1, a + 1):
	com = (com * (n + 1 - i)) % p * inv[i]

coma = com

for j in range(a + 1, b + 1):
	com = (com * (n + 1 - j)) % p * inv[j]

comb = com

print((pow(2, n, p) - 1 - coma - comb) % p)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
ls = list(map(int, input().split()))

ans = 0

for i in range(n - k + 1):
    exv = 0
    for j in range(k):
        exv += (ls[i + j] + 1) / 2
    
    if exv > ans:
        ans = exv

print(ans)

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

exv = 0

for j in range(k):
    exv += (ls[j] + 1) / 2

ans = exv

for i in range(k, n):
    exv += (ls[i] + 1) / 2
    exv -= (ls[i - k] + 1) / 2
    
    if exv > ans:
        ans = exv

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

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

def lcm_ls(num):
    return reduce(lcm, num, 1)


n = int(input())
ls = list(map(int, input().split()))

m = lcm_ls(ls)

ans = 0

for i in range(n):
    ans += m // ls[i]

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

Fixed submission:
import fractions
from functools import reduce

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_ls(num):
    return reduce(lcm, num, 1)


n = int(input())
ls = list(map(int, input().split()))

m = lcm_ls(ls)

ans = 0

for i in range(n):
    ans += m // ls[i]

print(ans % (10 ** 9 + 7))
Buggy python submission (verdict: Runtime Error):
ls_ac = [0] * n
ls_ng = [0] * n
ac = 0
ng = 0


for i in range(m):
    p = int(ls[i][0])
    if ls[i][1] == "AC":
        if ls_ac[p - 1] == 0:
            ac += 1
            ng += ls_ng[p - 1]
            ls_ac[p - 1] = 1
    elif ls[i][1] == "WA":
        if ls_ac[p - 1] == 0:
            ls_ng[p - 1] += 1

print(ac, ng)

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

ls_ac = [0] * n
ls_ng = [0] * n
ac = 0
ng = 0


for i in range(m):
    p = int(ls[i][0])
    if ls[i][1] == "AC":
        if ls_ac[p - 1] == 0:
            ac += 1
            ng += ls_ng[p - 1]
            ls_ac[p - 1] = 1
    elif ls[i][1] == "WA":
        if ls_ac[p - 1] == 0:
            ls_ng[p - 1] += 1

print(ac, ng)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls_a = list(map(int, input().split()))

s = 0
S = 0

for i in range(n):
    s = S
    S += ls_a[i]
    if S > sum(ls_a)/2:
        break

print(int(min(abs(sum(ls_a)/2 - s)*2, abs(sum(ls_a)/2 - S)*2)))

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

s = 0
S = 0
half = sum(ls_a)/2

for i in range(n):
    s = S
    S += ls_a[i]
    if S > half:
        break

print(int(min(abs(half - s)*2, abs(half - S)*2)))
Buggy python submission (verdict: Runtime Error):
if n % 2 != 0:
    print("No")
else:
    s_1 = s[:int(n/2)]
    s_2 = s[int(n/2):]
    if s_1 == s_2:
        print("Yes")
    else:
        print("No")

Fixed submission:
n = int(input())
s = input()

if n % 2 != 0:
    print("No")
else:
    s_1 = s[:int(n/2)]
    s_2 = s[int(n/2):]
    if (s_1 == s_2):
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
for j in range(len(s)):
    if j % 2 == 0 and s[j] == "L":
        print("No")
        break
    elif j % 2 == 1 and s[j] == "R":
        print("No")
        break
    elif j == len(s) -1:
        print("Yes")

Fixed submission:
s = [i for i in input()]

for j in range(len(s)):
    if (j % 2 == 0) and (s[j] == "L"):
        print("No")
        break
    elif (j % 2 == 1) and (s[j] == "R"):
        print("No")
        break
    elif j == len(s) - 1:
        print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())
ls_a = [int(input()) for _ in range(q)]

ls_p = [k] * n

for i in range(n):
    num = 0
    num = ls_a.count(i+1)
    ls_p[i] += (num - q)

for j in range(n):
    if ls_p[j] > 0:
        print("Yes")
    elif ls_p[j] <= 0:
        print("No")

Fixed submission:
n, k, q = map(int, input().split())
ls_a = [int(input()) for _ in range(q)]

ls_p = [k] * n
ls_c = [0] * n

for i in range(q):
    ls_c[ls_a[i] - 1] += 1

for j in range(n):
    ls_p[j] += ls_c[j] - q

for l in range(n):
    if ls_p[l] > 0:
        print("Yes")
    elif ls_p[l] <= 0:
        print("No")
Buggy python submission (verdict: Runtime Error):
if n < 10:
    print(n)
elif n < 100:
    print(9)
elif n < 1000:
    print(9 + (n-99))
elif n < 10000:
    print(9 + 900)
elif n < 100000:
    print(9 + 900 + (n-9999))
elif n == 100000:
    print(9 + 900 + 90000)

Fixed submission:
n = int(input())

if n < 10:
    print(n)
elif n < 100:
    print(9)
elif n < 1000:
    print(n-90)
elif n < 10000:
    print(909)
elif n < 100000:
    print(n-9090)
elif n == 100000:
    print(90909)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls_a = [int(input()) for _ in range(n)]

print(max(ls_a[1:]))
for i in range(1, n - 1):
	print(max(max(ls_a[:i]), max(ls_a[i+1:])))
print(max(ls_a[:n]))

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

ls_as = sorted(ls_a, reverse=True)
fst = ls_as[0]
snd = ls_as[1]

for i in range(n):
	if ls_a[i] != fst:
		print(fst)
	elif ls_a[i] == fst:
		print(snd)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ls = [int(input()) for _ in range(m)]

dp = [0] * (n + 1)
dp[0] = 1

if ls[0] == 1:
	dp[1] = 0
	del ls[0]
else:
	dp[1] = 1

ls.append(0)

for i in range(2, n + 1):
	if i == ls[0]:
		dp[i] == 0
		del ls[0]
	else:
		dp[i] = dp[i - 1] + dp[i - 2]
		
print(dp[n] % 1000000007)

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

dp = [0] * (n + 1)
dp[0] = 1

ls.append(0)

if ls[0] == 1:
	dp[1] = 0
	del ls[0]
else:
	dp[1] = 1

for i in range(2, n + 1):
	if i == ls[0]:
		dp[i] == 0
		del ls[0]
	else:
		dp[i] = dp[i - 1] + dp[i - 2]

print(dp[n] % 1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
ls = [[int(_) for _ in input().split()] for _ in range(q)]

flag = [0] * (n - 1)

for i in range(n - 1):
	if s[i:i+2] == 'AC':
		flag[i] = 1
	
for j in range(q):
	flgp = flag[ls[j][0] - 1:ls[j][1] - 1]
	print(sum(flgp))

Fixed submission:
n, q = map(int, input().split())
s = input()
ls = [[int(_) for _ in input().split()] for _ in range(q)]

csm = [0]
cnt = 0

for i in range(n - 1):
	if s[i:i+2] == 'AC':
		cnt += 1
	csm.append(cnt)
	
for j in range(q):
	print(csm[ls[j][1] - 1] - csm[ls[j][0] - 1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
ls = [[int(_) for _ in input().split()] for _ in range(q)]

flag = [0] * (n - 1)

for i in range(n - 1):
	if s[i:i+2] == 'AC':
		flag[i] = 1
	
for j in range(q):
	flgp = flag[ls[j][0] - 1:ls[j][1] - 1]
	print(sum(flgp))

Fixed submission:
n, q = map(int, input().split())
s = input()
ls = [[int(_) for _ in input().split()] for _ in range(q)]

csm = [0]
cnt = 0

for i in range(n - 1):
	if s[i:i+2] == 'AC':
		cnt += 1
	csm.append(cnt)
	
for j in range(q):
	print(csm[ls[j][1] - 1] - csm[ls[j][0] - 1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
ls = [[int(_) for _ in input().split()] for _ in range(q)]

for i in range(q):
	sp = s[ls[i][0] - 1:ls[i][1]]
	print(sp.count('AC'))

Fixed submission:
n, q = map(int, input().split())
s = input()
ls = [[int(_) for _ in input().split()] for _ in range(q)]

csm = [0]
cnt = 0

for i in range(n - 1):
	if s[i:i+2] == 'AC':
		cnt += 1
	csm.append(cnt)
	
for j in range(q):
	print(csm[ls[j][1] - 1] - csm[ls[j][0] - 1])