Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = []
for i in range(n):
    tmp = int(input())
    s.append(tmp)
sorted(s)
max_s = sum(s)
 
if max_s % 10 != 0:
    print(max_s)
else:
    for j in range(n):
        if s[j] % 10 != 0:
            print(max_s - s[j])
            break
        elif j == n-1:
            assert False


Fixed submission:
n = int(input())
s = []
for i in range(n):
    tmp = int(input())
    s.append(tmp)
s.sort()
max_s = sum(s)
 
if max_s % 10 != 0:
    print(max_s)
else:
    for j in range(n):
        if s[j] % 10 != 0:
            print(max_s - s[j])
            break
        elif j == n-1:
            print(0)

Buggy python submission (verdict: Runtime Error):
```
n = int(input())
s = []
for i in range(n):
    tmp = int(input())
    s.append(tmp)
sorted(s)
max_s = sum(s)
 
if max_s % 10 != 0:
    print(max_s)
else:
    for j in range(n):
        if s[j] % 10 != 0:
            print(max_s - s[j])
            break
        elif j == n-1:
            assert "a"
            print(0)

Fixed submission:
n = int(input())
s = []
for i in range(n):
    tmp = int(input())
    s.append(tmp)
s.sort()
max_s = sum(s)
 
if max_s % 10 != 0:
    print(max_s)
else:
    for j in range(n):
        if s[j] % 10 != 0:
            print(max_s - s[j])
            break
        elif j == n-1:
            print(0)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
from math import ceil

H, W, K = map(int, input().split())
A = [input() for _ in range(H)]

# 2回目以降の移動において、すべての部屋は開いていると考えてよい
si, sj = next(
    (i, j)
    for i in range(H)
    for j in range(W)
    if A[i][j] == 'S'
)
q = deque()
q.append((si, sj, 0))
T = {(si, sj)}
while q:
    i, j, d = q.popleft()
    if d < K:
        for x, y in (
                (u, v)
                for u, v in ((i + 1, j), (i, j + 1), (i - 1, j), (i, j - 1))
                if 0 <= u < H and 0 <= v < W and
                A[u][v] == '.' and (u, v) not in T
        ):
            q.append((x, y, d + 1))
            T.add((x, y))
ans = 1 + ceil(
    min(
        min(i, j, H - 1 - i, W - 1 - j)
        for i, j in T
    ) / K
)

print(ans)


Fixed submission:
from collections import deque
from math import ceil

H, W, K = map(int, input().split())
A = [input() for _ in range(H)]

# 2回目以降の移動において、すべての部屋は開いていると考えてよい
si, sj = next(
    (i, j)
    for i in range(H)
    for j in range(W)
    if A[i][j] == 'S'
)
q = deque()
q.append((si, sj, 0))
T = {(si, sj)}
while q:
    i, j, d = q.popleft()
    if d < K:
        for x, y in (
                (u, v)
                for u, v in ((i + 1, j), (i, j + 1), (i - 1, j), (i, j - 1))
                if 0 <= u < H and 0 <= v < W and
                A[u][v] == '.' and (u, v) not in T
        ):
            q.append((x, y, d + 1))
            T.add((x, y))
ans = 1 + ceil(
    min(
        min(i, j, H - 1 - i, W - 1 - j)
        for i, j in T
    ) / K
)

print(ans)
Buggy python submission (verdict: Runtime Error):
# 入力
N, M = map(int, input().split())
A, B = zip(*(map(int, input().split()) for _ in range(M)))

# 隣接リスト表現のグラフに変換
E = [[] for _ in range(N + 1)]
for a, b in zip(A, B):
    E[a].append(b)
    E[b].append(a)

# 訪れたことがあるかどうかのフラグ
v = [i == 1 for i in range(N + 1)]


# 訪れたことのない頂点を深さ優先探索する
def dfs(i, p):
    for j in E[i]:
        if not v[j]:
            v[j] = True
            p.append(j)
            return dfs(j, p)
    else:
        return p


# Hamiltonish Path を求める
p = list(reversed(dfs(1, []))) + [1] + dfs(1, [])

# 出力
ans = '{}\n{}'.format(len(p), ' '.join(map(str, p)))
print(ans)


Fixed submission:
import sys
sys.setrecursionlimit(2*10**5)

# 入力
N, M = map(int, input().split())
A, B = zip(*(map(int, input().split()) for _ in range(M)))

# 隣接リスト表現のグラフに変換
E = [[] for _ in range(N + 1)]
for a, b in zip(A, B):
    E[a].append(b)
    E[b].append(a)

# 訪れたことがあるかどうかのフラグ
v = [i == 1 for i in range(N + 1)]


# 訪れたことのない頂点を深さ優先探索する
def dfs(i, p):
    for j in E[i]:
        if not v[j]:
            v[j] = True
            p.append(j)
            return dfs(j, p)
    else:
        return p


# Hamiltonish Path を求める
p = list(reversed(dfs(1, []))) + [1] + dfs(1, [])

# 出力
ans = '{}\n{}'.format(len(p), ' '.join(map(str, p)))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from functools import lru_cache

sys.setrecursionlimit(2*10**5)

# 入力
N = int(input())
s = input()
xs = [
    1 if c == 'o' else
    -1
    for c in s
]


# 動物1と動物2の種別を決め打ちで割り当てて、矛盾がないかを検証する
@lru_cache(maxsize=None)
def f(l, r, i):
    return (
        l if i == 0 else
        r if i == 1 else
        f(l, r, i - 2) * f(l, r, i - 1) * xs[(i - 1) % N]
    )


def g(l, r):
    return ''.join(
        'S' if f(l, r, i) == 1 else
        'W'
        for i in range(N)
    )


ans = (
    g(1, 1) if f(1, 1, N) == 1 and f(1, 1, N + 1) == 1 else
    g(1, -1) if f(1, -1, N) == 1 and f(1, -1, N + 1) == -1 else
    g(-1, 1) if f(-1, 1, N) == -1 and f(-1, 1, N + 1) == 1 else
    g(-1, -1) if f(-1, -1, N) == -1 and f(-1, -1, N + 1) == -1 else
    '-1'
)

# 出力
print(ans)


Fixed submission:
# 入力
N = int(input())
s = input()
xs = [
    1 if c == 'o' else
    -1
    for c in s
]

# 動物1と動物2の種別を決め打ちで割り当てて、矛盾がないかを検証する
dp = {
    l: {
        r: [0 for _ in range(N + 2)]
        for r in (1, -1)
    }
    for l in (1, -1)
}
for l in (1, -1):
    for r in (1, -1):
        dp[l][r][0] = l
        dp[l][r][1] = r
        for i in range(2, N + 2):
            dp[l][r][i] = dp[l][r][i - 2] * dp[l][r][i - 1] * xs[(i - 1) % N]


def f(l, r):
    return ''.join(
        'S' if dp[l][r][i] == 1 else
        'W'
        for i in range(N)
    )


ans = next(
    (
        f(l, r)
        for l in (1, -1)
        for r in (1, -1)
        if dp[l][r][N] == l and dp[l][r][N + 1] == r
    ),
    '-1'
)

# 出力
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from functools import lru_cache

sys.setrecursionlimit(2*10**5)

# 入力
N, Ma, Mb = map(int, input().split())
a, b, c = (
    zip(*(map(int, input().split()) for _ in range(N))) if N else
    ((), ())
)


# タイプAがxグラム, タイプBがyグラムの物質の最小生成コストを動的計画法により求める
@lru_cache(maxsize=None)
def f(i, x, y):
    return (
        10**18 if (i < 0 and not (x == y == 0)) or x < 0 or y < 0 else
        0 if x == 0 and y == 0 else
        min(
            f(i - 1, x - a[i - 1], y - b[i - 1]) + c[i - 1],
            f(i - 1, x, y)
        )
    )


# タイプAとタイプBの物質の比率がMa:Mbとなるような物質の最小コストを求める
opt = min(
    f(N, x, Mb * (x // Ma))
    for x in range(Ma, sum(a) + 1)
    if x % Ma == 0
)
ans = (
    opt if opt < 10**18 else
    -1
)

# 出力
print(ans)


Fixed submission:
import sys
from functools import lru_cache

sys.setrecursionlimit(2*10**5)

# 入力
N, Ma, Mb = map(int, input().split())
a, b, c = (
    zip(*(map(int, input().split()) for _ in range(N))) if N else
    ((), ())
)


# タイプAがxグラム, タイプBがyグラムの物質の最小生成コストを動的計画法により求める
@lru_cache(maxsize=None)
def f(i, x, y):
    return (
        10**18 if (i < 0 and not (x == y == 0)) or x < 0 or y < 0 else
        0 if x == 0 and y == 0 else
        min(
            f(i - 1, x - a[i - 1], y - b[i - 1]) + c[i - 1],
            f(i - 1, x, y)
        )
    )


# タイプAとタイプBの物質の比率がMa:Mbとなるような物質の最小コストを求める
A = sum(a)
B = sum(b)
opt = min(
    f(N, x, Mb * (x // Ma))
    for x in range(Ma, A + 1)
    if x % Ma == 0 and Mb * (x // Ma) <= B
)
ans = (
    opt if opt < 10**18 else
    -1
)

# 出力
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from functools import lru_cache

sys.setrecursionlimit(2*10**5)

# 入力
N, Ma, Mb = map(int, input().split())
a, b, c = (
    zip(*(map(int, input().split()) for _ in range(N))) if N else
    ((), ())
)


# タイプAがxグラム, タイプBがyグラムの物質の最小生成コストを動的計画法により求める
@lru_cache(maxsize=None)
def f(i, x, y):
    return (
        10**18 if (i < 0 and not (x == y == 0)) or x < 0 or y < 0 else
        0 if x == 0 and y == 0 else
        min(
            f(i - 1, x - a[i - 1], y - b[i - 1]) + c[i - 1],
            f(i - 1, x, y)
        )
    )


# タイプAとタイプBの物質の比率がMa:Mbとなるような物質の最小コストを求める
opt = min(
    f(N, x, Mb * (x // Ma))
    for x in range(Ma, sum(a) + 1)
    if x % Ma == 0
)
ans = (
    opt if opt < 10**18 else
    -1
)

# 出力
print(ans)


Fixed submission:
import sys
from functools import lru_cache

sys.setrecursionlimit(2*10**5)

# 入力
N, Ma, Mb = map(int, input().split())
a, b, c = (
    zip(*(map(int, input().split()) for _ in range(N))) if N else
    ((), ())
)


# タイプAがxグラム, タイプBがyグラムの物質の最小生成コストを動的計画法により求める
@lru_cache(maxsize=None)
def f(i, x, y):
    return (
        10**18 if (i < 0 and not (x == y == 0)) or x < 0 or y < 0 else
        0 if x == 0 and y == 0 else
        min(
            f(i - 1, x - a[i - 1], y - b[i - 1]) + c[i - 1],
            f(i - 1, x, y)
        )
    )


# タイプAとタイプBの物質の比率がMa:Mbとなるような物質の最小コストを求める
A = sum(a)
B = sum(b)
opt = min(
    f(N, x, Mb * (x // Ma))
    for x in range(Ma, A + 1)
    if x % Ma == 0 and Mb * (x // Ma) <= B
)
ans = (
    opt if opt < 10**18 else
    -1
)

# 出力
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())

ans = len({a, b, c})
print(ans)


Fixed submission:
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())

ans = len({a, b, c})
print(ans)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())

ans = len({a, b, c})
print(ans)


Fixed submission:
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())

ans = len({a, b, c})
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache

# 入力
N, x = map(int, input().split())
a = list(map(int, input().split()))

# a_i, a_{i + 1}, ..., a_j の最小値
@lru_cache(maxsize=None)
def f(i, j):
    return (
        a[i] if i == j else
        min(f(i, (j - 1) % N), a[j])
    )

# 変色回数を0からN-1まで決め打ちして解を求める
ans = min(
    sum(f(i, (i + k) % N) for i in range(N)) + k * x
    for k in range(N)
)

# 出力
print(ans)


Fixed submission:
# 入力
N, x = map(int, input().split())
a = list(map(int, input().split()))

dp = [[0 for _ in range(N)] for i in range(N)]
for i in range(N):
    dp[i][i] = a[i]
    for k in range(1, N):
        j = (i + k) % N
        dp[i][j] = min(dp[i][(j - 1) % N], a[j])

# 変色回数を0からN-1まで決め打ちして解を求める
ans = min(
    sum(dp[i][(i + k) % N] for i in range(N)) + k * x
    for k in range(N)
)

# 出力
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import lru_cache

# 入力
N, x = map(int, input().split())
a = list(map(int, input().split()))

# a_i, a_{i + 1}, ..., a_j の最小値
@lru_cache(maxsize=None)
def f(i, j):
    return (
        a[i] if i == j else
        min(f(i, (j - 1) % N), a[j])
    )

# 変色回数を0からN-1まで決め打ちして解を求める
ans = min(
    sum(f(i, (i + k) % N) for i in range(N)) + k * x
    for k in range(N)
)

# 出力
print(ans)


Fixed submission:
# 入力
N, x = map(int, input().split())
a = list(map(int, input().split()))

dp = [[0 for _ in range(N)] for i in range(N)]
for i in range(N):
    dp[i][i] = a[i]
    for k in range(1, N):
        j = (i + k) % N
        dp[i][j] = min(dp[i][(j - 1) % N], a[j])

# 変色回数を0からN-1まで決め打ちして解を求める
ans = min(
    sum(dp[i][(i + k) % N] for i in range(N)) + k * x
    for k in range(N)
)

# 出力
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = list(map(int,input().split("" )))
S = set(L)
X = []

if len(S) < 3:
  print(0)
else:
  for i in S:
    L.count(i) > 1:
      X.append(L.count(i))
  ans = len(S)*len(S-1)*len(S-2)
  for i in X:
    ans *= i
  print(ans)

Fixed submission:
n = int(input())
l = list(map(int,input().split(" ")))
ans = 0

for i in range(n):
  for j in range(n):
    for k in range(n):
      if l[i] < l[j] & l[j] < l[k]:
        if l[i] != l[j] != l[k]:
          if l[i] + l[j] + l[k] > max(l[i],l[j],l[k])*2:
            ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
t = 7

for i in range(k):
  if t % k == 0:
    print(i+1)
    break
  t = t * 10 + 7
else:
	print(-1)

Fixed submission:
k=int(input())
n=7%k
for i in range(1,k+1):
  if n == 0:
    print(i)
    exit()
  n=(n*10+7) % k
print(-1)
Buggy python submission (verdict: Runtime Error):
print([8,7,6,5,4,3,2,1][(input()-400) // 200 ])

Fixed submission:
print([8,7,6,5,4,3,2,1][(int(input())-400) // 200 ])
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
ls=list(map(int,input().split()))
ls.sort()

#定数倍のやつに＋１する
A=[0]*(max(ls)+1)
for i in range(len(ls)):
  a=1
  while ls[i]*a<=max(ls):
    b=ls[i]*a
    if A[b]<=1:
      A[b]+=1
    a+=1
    
ans=0     
for i in range(len(ls)):
  if A[ls[i]]==1:
    ans+=1
print(ans)

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

#定数倍のやつに＋１する
M=max(ls)
A=[0]*(M+1)
for i in range(N):
  a=M//ls[i]
  for j in range(1,a+1):
    if A[j*ls[i]]<=2:
      A[j*ls[i]]+=1
    
ans=0     
for i in range(len(ls)):
  if A[ls[i]]==1:
    ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
ls=list(map(int,input().split()))
ls.sort()

#定数倍のやつに＋１する
A=[0]*(max(ls)+1)
for i in range(len(ls)):
  a=1
  while ls[i]*a<=max(ls):
    b=ls[i]*a
    if A[b]<=1:
      A[b]+=1
    a+=1
    
ans=0     
for i in range(len(ls)):
  if A[ls[i]]==1:
    ans+=1
print(ans)

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

#定数倍のやつに＋１する
M=max(ls)
A=[0]*(M+1)
for i in range(N):
  a=M//ls[i]
  for j in range(1,a+1):
    if A[j*ls[i]]<=2:
      A[j*ls[i]]+=1
    
ans=0     
for i in range(len(ls)):
  if A[ls[i]]==1:
    ans+=1
print(ans)

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

#重複したやつ除く
ls_A.sort()
ls=[]
for i in range(N):
  if i==0:
    if ls_A[0]!=ls_A[1]:
      ls.append(ls_A[0])
  elif i==N-1:
    if ls_A[N-1]!=ls_A[N-2]:
      ls.append(ls_A[N-1]) 
  else:
    if ls_A[i]!=ls_A[i-1] and ls_A[i]!=ls_A[i+1]:
      ls.append(ls_A[i])       

#定数倍のやつに＋１する
if not ls:
  print(0)
else:
  A=[0]*(max(ls)+1)
  for i in range(len(ls)):
    a=1
    while ls[i]*a<=max(ls):
      A[ls[i]*a]+=1
      a+=1
  ans=0    
  for i in range(len(ls)):
    if A[ls[i]]==1:
      ans+=1
  print(ans)

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

#定数倍のやつに＋１する
M=max(ls)
A=[0]*(M+1)
for i in range(N):
  a=M//ls[i]
  for j in range(1,a+1):
    if A[j*ls[i]]<=2:
      A[j*ls[i]]+=1
    
ans=0     
for i in range(len(ls)):
  if A[ls[i]]==1:
    ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
ls_A=list(map(int,input().split()))
ls_A.sort()
ls=[]
for i in range(N):
  if i==0:
    if ls_A[0]!=ls_A[1]:
      ls.append(ls_A[0])
  if i==N-1:
    if ls_A[N-1]!=ls_A[N-2]:
      ls.append(ls_A[N-1]) 
  else:
    if ls_A[i]!=ls_A[i-1] and ls_A[i]!=ls_A[i+1]:
      ls.append(ls_A[i])       
    
ans=0
for i in range(len(ls)):
  for j in range(i):
    if ls[i]%ls[j]==0:
      break
    else:
      continue
  else:
    ans+=1
print(ans)

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

#定数倍のやつに＋１する
M=max(ls)
A=[0]*(M+1)
for i in range(N):
  a=M//ls[i]
  for j in range(1,a+1):
    if A[j*ls[i]]<=2:
      A[j*ls[i]]+=1
    
ans=0     
for i in range(len(ls)):
  if A[ls[i]]==1:
    ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,S=map(int,input().split())
ls=list(map(int,input().split()))
MOD=998244353
dp=[[1]+[0]*S for i in range(N+1)]
for i in range(N):
  for j in range(S+1):    
      dp[i+1][j]=dp[i][j]*2%MOD
      if ls[i]<=j:
        dp[i+1][j]=(dp[i+1][j]+dp[i][j-ls[i]])%MOD
print(dp[N][S])

Fixed submission:
N,S=map(int,input().split())
ls=list(map(int,input().split()))
MOD=998244353
dp=[[1]+[0]*S for i in range(N+1)]
for i in range(N):
  for j in range(S+1):    
      dp[i+1][j]=dp[i][j]*2%MOD
      if ls[i]<=j:
        dp[i+1][j]=(dp[i+1][j]+dp[i][j-ls[i]])%MOD
print(dp[N][S])

Buggy python submission (verdict: Time Limit Exceeded):
N,S=map(int,input().split())
ls=list(map(int,input().split()))
MOD=998244353
dp=[[1]+[0]*S for i in range(N+1)]
for i in range(N):
  for j in range(S+1):
    if ls[i]>j:
      dp[i+1][j]=dp[i][j]*2%MOD
    else:
      dp[i+1][j]=(dp[i][j]*2+dp[i][j-ls[i]])%MOD
print(dp[N][S])

Fixed submission:
N,S=map(int,input().split())
ls=list(map(int,input().split()))
MOD=998244353
dp=[[1]+[0]*S for i in range(N+1)]
for i in range(N):
  for j in range(S+1):    
      dp[i+1][j]=dp[i][j]*2%MOD
      if ls[i]<=j:
        dp[i+1][j]=(dp[i+1][j]+dp[i][j-ls[i]])%MOD
print(dp[N][S])

Buggy python submission (verdict: Time Limit Exceeded):
N,S=map(int,input().split())
ls=list(map(int,input().split()))
MOD=998244353
dp=[[1]+[0]*(S) for i in range(N+1)]
for i in range(N):
  for j in range(S+1):
    if ls[i]>j:
      dp[i+1][j]=dp[i][j]*2
      dp[i+1][j]%=MOD
    else:
      dp[i+1][j]=dp[i][j]*2+dp[i][j-ls[i]]
      dp[i+1][j]%=MOD
print(dp[N][S]) 

Fixed submission:
N,S=map(int,input().split())
ls=list(map(int,input().split()))
MOD=998244353
dp=[[1]+[0]*S for i in range(N+1)]
for i in range(N):
  for j in range(S+1):    
      dp[i+1][j]=dp[i][j]*2%MOD
      if ls[i]<=j:
        dp[i+1][j]=(dp[i+1][j]+dp[i][j-ls[i]])%MOD
print(dp[N][S])
Buggy python submission (verdict: Runtime Error):
K = int(input())
S = input()
if len(S)<=K:
  input(S)
else:
  input(S[:K] + "...")

Fixed submission:
K = int(input())
S = input()
if len(S)<=K:
  print(S)
else:
  print(S[:K] + "...")
Buggy python submission (verdict: Runtime Error):
X=int(input())
A=0
for a in range(X):
  if (a+1)**5-a**5 <= X <= (a+1)**5+a**5:
    A = a
    break

for b in range(-A,A+1):
  if (A+1)**5-b**5 == X:
    B=b
    break   
    
print(A+1,B)

Fixed submission:
X=int(input())
I=J=0
for i in range(-300,300):
  for j in range(-300,300):
    if i**5-j**5==X:
      I=i
      J=j
      break
print(I,J)

Buggy python submission (verdict: Runtime Error):
X=int(input())
A=0
for a in range(X):
  if (a+1)**5-a**5 <= X <= (a+1)**5+a**5:
    A = a
    break

for b in range(-A,A+1):
  if (A+1)**5-b**5 == X:
    B=b
    break   
    
print(A+1,B)

Fixed submission:
X=int(input())
I=J=0
for i in range(-300,300):
  for j in range(-300,300):
    if i**5-j**5==X:
      I=i
      J=j
      break
print(I,J)

Buggy python submission (verdict: Runtime Error):
B=0
for b in range((a+1)**5-a**5,(a+1)**+a**5+1):
  if (a+1)**5-b**5 == X:
    B=b
    break

print(A+1, B)

Fixed submission:
X=int(input())
I=J=0
for i in range(-300,300):
  for j in range(-300,300):
    if i**5-j**5==X:
      I=i
      J=j
      break
print(I,J)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
List = list(map(int,input().split()))

ListK = [i+1+List[i] for i in range(N)]
ListL = [i+1-List[i] for i in range(N)]

from collections import Counter 
ans = 0
for i in range(N):
  ans += (Counter(ListK)[i])*(Counter(ListL)[i])

print(ans)  

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

ListK = [i+1+List[i] for i in range(N)]
ListL = [i+1-List[i] for i in range(N)]

from collections import Counter 
ans = 0

NewlistK = Counter(ListK)
NewlistL = Counter(ListL)

for i in range(N):
  ans += (NewlistK[i])*(NewlistL[i])

print(ans)

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

ListL = [i+1+List[i] for i in range(N)]
ListR = [i+1-List[i] for i in range(N)]

ans = 0
for i in range(2*10**5):
  ans += ListL.count(i)*ListR.count(i)

print(ans)  

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

ListK = [i+1+List[i] for i in range(N)]
ListL = [i+1-List[i] for i in range(N)]

from collections import Counter 
ans = 0

NewlistK = Counter(ListK)
NewlistL = Counter(ListL)

for i in range(N):
  ans += (NewlistK[i])*(NewlistL[i])

print(ans)
Buggy python submission (verdict: Runtime Error):
N,M,Q = map(int,input().split())
ls_rq = [list(map(int, input().split())) for i in range(Q)]

#深さ優先探索により各数列を生成する
As=[]
from queue import LifoQueue as lq
S=lq()
S.put([])
while not S.empty():
  a=S.get()
  if len(a)==N:
    As.append(a)
  else:
    if len(a)==0:
      b=1
    else:
      b=a[-1]
    for  i in range(b,M+1):
      S.put(a+[i])

#各数列のスコアを求める
ls_score=[]
for ls in As:
  score=0
  for j in range(Q):
    if ls[ls_rq[j][1]-1]-ls[ls_rq[j][0]-1]==ls_rq[j][2]:
      score+=ls_rq[j][3]
  ls_score.append(score)    
  score=0

#スコアの最大値を求める  
ans=max(ls_score)  
print(ans)  


Fixed submission:
N=int(input())
A, B=map(int,input().split())
C=A//N
if A==C*N:
  print("OK")
elif A<=(C+1)*N<=B:
  print("OK")
else:
  print("NG")
Buggy python submission (verdict: Time Limit Exceeded):
N,M,Q = map(int,input().split())
ls_rq = [list(map(int, input().split())) for i in range(Q)]

#深さ優先探索により各数列を生成する
As=[]
from queue import LifoQueue as lq
S=lq()
S.put([])
while not S.empty():
  a=S.get()
  if len(a)==N:
    As.append(a)
  else:
    if len(a)==0:
      b=1
    else:
      b=a[-1]
    for  i in range(b,M+1):
      S.put(a+[i])

#各数列のスコアを求める
ls_score=[]
for ls in As:
  score=0
  for j in range(Q):
    if ls[ls_rq[j][1]-1]-ls[ls_rq[j][0]-1]==ls_rq[j][2]:
      score+=ls_rq[j][3]
  ls_score.append(score)    
  score=0

#スコアの最大値を求める  
ans=max(ls_score+[0])  
print(ans)  


Fixed submission:
N,M,Q = map(int,input().split())
ls_rq = [list(map(int, input().split())) for i in range(Q)]

#深さ優先探索により各数列を生成する
As=[]
from queue import LifoQueue as lq
S=lq()
S.put([])
while not S.empty():
  a=S.get()
  if len(a)==N:
    As.append(a)
  else:
    if len(a)==0:
      b=1
    else:
      b=a[-1]
    for  i in range(b,M+1):
      S.put(a+[i])

#各数列のスコアを求める
ls_score=[]
for ls in As:
  score=0
  for j in range(Q):
    if ls[ls_rq[j][1]-1]-ls[ls_rq[j][0]-1]==ls_rq[j][2]:
      score+=ls_rq[j][3]
  ls_score.append(score)    
  score=0

#スコアの最大値を求める  
ans=max(ls_score+[0])  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M,Q = map(int,input().split())
ls_rq = [list(map(int, input().split())) for i in range(Q)]

#深さ優先探索により各数列を生成する
As=[]
from queue import LifoQueue as lq
S=lq()
S.put([])
while not S.empty():
  a=S.get()
  if len(a)==N:
    As.append(a)
  else:
    if len(a)==0:
      b=1
    else:
      b=a[-1]
    for  i in range(b,M+1):
      S.put(a+[i])

#各数列のスコアを求める
ls_score=[]
for ls in As:
  score=0
  for j in range(Q):
    if ls[ls_rq[j][1]-1]-ls[ls_rq[j][0]-1]==ls_rq[j][2]:
      score+=ls_rq[j][3]
  ls_score.append(score)    
  score=0

#スコアの最大値を求める  
ans=max(ls_score)  
print(ans)  

Fixed submission:
N,M,Q = map(int,input().split())
ls_rq = [list(map(int, input().split())) for i in range(Q)]

#深さ優先探索により各数列を生成する
As=[]
from queue import LifoQueue as lq
S=lq()
S.put([])
while not S.empty():
  a=S.get()
  if len(a)==N:
    As.append(a)
  else:
    if len(a)==0:
      b=1
    else:
      b=a[-1]
    for  i in range(b,M+1):
      S.put(a+[i])

#各数列のスコアを求める
ls_score=[]
for ls in As:
  score=0
  for j in range(Q):
    if ls[ls_rq[j][1]-1]-ls[ls_rq[j][0]-1]==ls_rq[j][2]:
      score+=ls_rq[j][3]
  ls_score.append(score)    
  score=0

#スコアの最大値を求める  
ans=max(ls_score+[0])  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int,input().split())
List = [int(A*i/B)-A*int(i/B) for i in range(N+1)]
print(max(List))

Fixed submission:
A, B, N = map(int,input().split())
C = min([N,B-1])
ans = int(A*C/B)
print(ans)
Buggy python submission (verdict: Runtime Error):
S, W = map(int,input().split())
print("safe"if S>W"unsafe"else)


Fixed submission:
S, W = map(int,input().split())
print("safe"if S>W else"unsafe")

Buggy python submission (verdict: Runtime Error):
S, W = map(int,input().split())
if S>W:
  print("safe"if S>W"unsafe"else)


Fixed submission:
S, W = map(int,input().split())
print("safe"if S>W else"unsafe")

Buggy python submission (verdict: Runtime Error):
S, W = map(int,input().split())
if S>W:
  print("safe")
else S<=W:
  print("unsafe")

Fixed submission:
S, W = map(int,input().split())
print("safe"if S>W else"unsafe")
Buggy python submission (verdict: Time Limit Exceeded):
Row = int(input())
List = list(input() for i in range(Row))
List.sort()
a=Row-1
while a>0:
 if List[a] == List[a-1]:
  List.remove(List[a])
  a-=1
 else:a-=1
else:print(len(List)) 

Fixed submission:
Row = int(input())
List = list(input() for i in range(Row))
print(len(set(List)))