Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = len(S)
C = [0 for i in range(2019)]
C[0] = 1
now = 0
for i in range(N):
    now += int(S[-i-1])*(10**i)
    now %= 2019
    C[now] += 1
ans = 0
for i in range(2019):
    ans += C[i]*(C[i]-1)//2
print(ans)



Fixed submission:
S = input()
N = len(S)
C = [0 for i in range(2019)]
C[0] = 1
now = 0
tenfactor = 1

for i in range(N):
    s = int(S[-i-1])
    now = (now + s*tenfactor)%2019
    tenfactor = tenfactor*10%2019
    C[now] += 1
ans = 0
for i in range(2019):
    ans += C[i]*(C[i]-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = len(S)
C = [0 for i in range(2019)]
C[0] = 1
now = 0
for i in range(N):
    now += int(S[-i-1])*(10**i)
    C[now%2019] += 1
ans = 0
for i in range(2019):
    ans += C[i]*(C[i]-1)//2
print(ans)




Fixed submission:
S = input()
N = len(S)
C = [0 for i in range(2019)]
C[0] = 1
now = 0
tenfactor = 1

for i in range(N):
    s = int(S[-i-1])
    now = (now + s*tenfactor)%2019
    tenfactor = tenfactor*10%2019
    C[now] += 1
ans = 0
for i in range(2019):
    ans += C[i]*(C[i]-1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
x = [0,0,0]
for i in range(n):
    x[ord(s[i])%3] += 1
 
ans = x[0]*x[1]*x[2]

for i in range(n):
    for j in range(i+1,n):
        if 2*j-i >= n:
            continue
        k = 2*j-i
        if s[i] != s[j]:
            if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                ans -= 1
 
print(ans)

Fixed submission:
n = int(input())
s = input()
r = 0
b = 0
g = 0
for i in range(n):
    if s[i] == 'R':
        r += 1
    elif s[i] == 'B':
        b += 1
    else:
        g += 1

ans = r*g*b

for i in range(n):
    for j in range(i+1,n):
        if 2*j-i >= n:
            continue
        k = 2*j-i
        if s[i] != s[j]:
            if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                ans -= 1

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

Fixed submission:
k,n = map(int,input().split())
a = list(map(int,input().split()))
ans = a[0] + k - a[-1]
for i in range(n-1):
  ans = max(ans, a[i+1]-a[i])
print(k-ans)
Buggy python submission (verdict: Runtime Error):
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort()
q.sort()
r.sort()

ans = 0

cnt = 0

while x+y-cnt > 0:
    if x > 0:
        p1 = p[-1]
    else:
        p1 = 0
    if y > 0:
        p2 = q[-1]
    else:
        p2 = 0
    p3 = r[-1]
    eat = max(p1,p2,p3)
    ans += eat
    if x > 0 and p[-1] == eat:
        x -= 1
        p.pop()
    elif y > 0 and q[-1] == eat:
        y -= 1
        q.pop()
    else:
        cnt += 1
        r.pop()
print(ans)


Fixed submission:
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort()
q.sort()
r.sort()

ans = 0

cnt = 0

while x+y-cnt > 0:
    if x > 0:
        p1 = p[-1]
    else:
        p1 = 0
    if y > 0:
        p2 = q[-1]
    else:
        p2 = 0
    if cnt < c:
        p3 = r[-1]
    else:
        p3 = 0
    eat = max(p1,p2,p3)
    ans += eat
    if x > 0 and p[-1] == eat:
        x -= 1
        p.pop()
    elif y > 0 and q[-1] == eat:
        y -= 1
        q.pop()
    else:
        cnt += 1
        r.pop()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())

for i in range(Q):
    command = input().split()
    if command[0] == '1':
        S = S[::-1]
    else:
        if command[1] == '1':
            S = command[2] + S
        else:
            S = S + command[2]
print(S)


Fixed submission:
S = input()
Q = int(input())

front = ''
back = ''

T_count = 0

for i in range(Q):
    command = input().split()
    if command[0] == '1':
        T_count = (T_count+1)%2
    else:
        if (int(command[1]) + T_count)%2 == 1:
            front += command[2]
        else:
            back += command[2]

if T_count == 0:
    print(front[::-1]+S+back)
else:
    print(back[::-1]+S[::-1]+front)
Buggy python submission (verdict: Runtime Error):
def modinv(a,m):
    return pow(a,m-2,m)


n,k = map(int,input().split())
P = 10**9+7

if n-1 <= k:

    ans = 1
    for i in range(1,n):
        ans = ans*(N+1-i)*modinv(i,P)%P

else:
    ans = 0
    nCl = 1
    n1Cl = 1
    for l in range(1,k+1):
        nCl = nCl*(n+1-l)*modinv(l,P)%P
        n1Cl = n1Cl*(n-l)*modinv(l,P)%P
        ans = (ans+nCl*n1Cl)%P

print((ans+1)%P)



Fixed submission:
def modinv(a,m):
    return pow(a,m-2,m)


n,k = map(int,input().split())
P = 10**9+7



if n-1 <= k:
    N = n + min(n-1,k)
    ans = 1
    for i in range(1,n):
        ans = ans*(N+1-i)*modinv(i,P)%P

else:
    ans = 1
    nCl = 1
    n1Cl = 1
    for l in range(1,k+1):
        nCl = nCl*(n+1-l)*modinv(l,P)%P
        n1Cl = n1Cl*(n-l)*modinv(l,P)%P
        ans = (ans+nCl*n1Cl)%P

print(ans)

Buggy python submission (verdict: Runtime Error):
def modinv(a,m):
    return pow(a,m-2,m)


n,k = map(int,input().split())
P = 10**9+7

if n-1 <= k:

    ans = 1
    for i in range(1,n):
        ans = ans*(N+1-i)*modinv(i,P)%P

else:
    ans = 0
    nCl = 1
    n1Cl = 1
    for l in range(1,k+1):
        nCl = nCl*(n+1-l)*modinv(l,P)%P
        n1Cl = n1Cl*(n-l)*modinv(l,P)%P
        ans = (ans+nCl*n1Cl)%P

print((ans+1)%P)



Fixed submission:
def modinv(a,m):
    return pow(a,m-2,m)


n,k = map(int,input().split())
P = 10**9+7



if n-1 <= k:
    N = n + min(n-1,k)
    ans = 1
    for i in range(1,n):
        ans = ans*(N+1-i)*modinv(i,P)%P

else:
    ans = 1
    nCl = 1
    n1Cl = 1
    for l in range(1,k+1):
        nCl = nCl*(n+1-l)*modinv(l,P)%P
        n1Cl = n1Cl*(n-l)*modinv(l,P)%P
        ans = (ans+nCl*n1Cl)%P

print(ans)
Buggy python submission (verdict: Runtime Error):
#a,bの最大公約数
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

#a,bの最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

#べき乗関数powを使った逆元の計算(modinvよりもPythonでは高速、PyPyだと遅い)
def modinv2(a,m):
    return pow(a,m-2,m)


N = int(input())
A = list(map(int,input().split()))
P = 10**9+7

A.sort()

inv = modinv2(A[0],P)
g = A[0]
invlist = []
seki = A[0]%P

for i in range(1,N):
    inv = (inv+modinv2(A[i],P))%P
    seki = seki*A[i]%P

g = gcd(A[0],A[1])
l = A[0]//g*A[1]
cc = modinv2(g,P)
for i in range(2,N):
    g = gcd(l,A[i])
    l = l//g*A[i]
    cc = cc*modinv2(g,P)%P

ans = (inv*seki%P)*cc%P

print(ans)


Fixed submission:
#a,bの最大公約数
def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

#a,bの最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

#べき乗関数powを使った逆元の計算(modinvよりもPythonでは高速、PyPyだと遅い)
def modinv2(a,m):
    return pow(a,m-2,m)


N = int(input())
A = list(map(int,input().split()))
P = 10**9+7

if N == 1:
    ans = 1

else:

    A.sort()

    inv = modinv2(A[0],P)
    g = A[0]
    invlist = []
    seki = A[0]%P

    for i in range(1,N):
        inv = (inv+modinv2(A[i],P))%P
        seki = seki*A[i]%P

    g = gcd(A[0],A[1])
    l = A[0]//g*A[1]
    cc = modinv2(g,P)
    for i in range(2,N):
        g = gcd(l,A[i])
        l = l//g*A[i]
        cc = cc*modinv2(g,P)%P

    ans = (inv*seki%P)*cc%P

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = list(input())

ans = 0
check = []
for i in range(N):
    if i <= K-1:
        if T[i] == 'r':
            ans += P
        elif T[i] == 's':
            ans += R
        else:
            ans += S
    else:
        if T[i] != T[i-K]:
            if T[i] == 'r':
                ans += P
            elif T[i] == 's':
                ans += R
            else:
                ans += S
#        elif len(check) != 0:
#           a = bisect.bisect_left(check,i-K)
        elif T[i] == T[i-K] and i-K in check:
            if T[i] == 'r':
                ans += P
            elif T[i] == 's':
                ans += R   
            else:
                ans += S
        else:
            check.append(i)

print(ans)




Fixed submission:
N,K = map(int,input().split())
R,S,P = map(int,input().split())
T = list(input())

ans = 0
check = {i:0 for i in range(N)}
for i in range(N):
    if i <= K-1:
        if T[i] == 'r':
            ans += P
        elif T[i] == 's':
            ans += R
        else:
            ans += S
    else:
        if T[i] != T[i-K]:
            if T[i] == 'r':
                ans += P
            elif T[i] == 's':
                ans += R
            else:
                ans += S
        elif T[i] == T[i-K] and check[i-K] == 1:
            if T[i] == 'r':
                ans += P
            elif T[i] == 's':
                ans += R   
            else:
                ans += S
        else:
            check[i] = 1

print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
if S == 'SUN':
    print(7)
elif S = 'MON':
    print(6)
elif S = 'TUE':
    print(5)
elif S = 'WED':
    print(4)
elif S = 'THU':
    print(3)
elif S = 'FRI':
    print(2)
else:
    print(1)


Fixed submission:
S = input()
if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
else:
    print(1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

# 01ナップサック問題
N,W = map(int,readline().split())
AB = [tuple(map(int,readline().split())) for i in range(N)]
AB.sort(key=lambda x: x[0])
dp = [0]*(W+1)

for (w,v) in AB:
    dpnew = dp[::]
    for j in range(W):
        dpnew[min(j+w,W)] = max(dp[min(j+w,W)],dp[j] + v)
    dp = dpnew

print(dp[W])


Fixed submission:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

# 01ナップサック問題
N,W = map(int,readline().split())
AB = [list(map(int,readline().split())) for i in range(N)]
AB.sort(key=lambda x: (x[0],x[1]))
dp = [0]*(W+1)

for (w,v) in AB:
    dpnew = dp[::]
    for j in range(W):
        dpnew[min(j+w,W)] = max(dp[min(j+w,W)],dp[j] + v)
    dp = dpnew

print(max(dp))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

# 01ナップサック問題
N,W = map(int,readline().split())
AB = [tuple(map(int,readline().split())) for i in range(N)]
AB.sort(key=lambda x: x[0])
dp = [0]*(W+1)

for (w,v) in AB:
    dpnew = dp[::]
    for j in range(W):
        dpnew[min(j+w,W)] = max(dp[min(j+w,W)],dp[j] + v)
    dp = dpnew

print(max(dp))


Fixed submission:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

# 01ナップサック問題
N,W = map(int,readline().split())
AB = [list(map(int,readline().split())) for i in range(N)]
AB.sort(key=lambda x: (x[0],x[1]))
dp = [0]*(W+1)

for (w,v) in AB:
    dpnew = dp[::]
    for j in range(W):
        dpnew[min(j+w,W)] = max(dp[min(j+w,W)],dp[j] + v)
    dp = dpnew

print(max(dp))
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/dsu>
//using namespace atcoder;

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001000;

int main() {
    int a,b; cin >> a >> b;
    if (a >= 10 || b >= 10) cout << -1 << endl;
    else cout << a*b << endl;
    return 0;
}

Fixed submission:
A,B=map(int,input().split())
if 1<=A<=9 and 1<=B<=9:
    print(A*B)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
import math

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

if a*a*b < 2*x:
    print(90-math.degrees(math.atan(a**3/(2*(a*a*b-x)))))
else:
    print(90-math.degrees(math.atan(2*x/(a*b*b))))



Fixed submission:
import math
a,b,x=map(int,input().split())
if a*a*b<=2*x:
    c=(b-x/(a**2))*2/a
    ans=math.degrees(math.atan(c))
else:
    c=a*b*b/(2*x)
    ans=math.degrees(math.atan(c))
print(ans)

Buggy python submission (verdict: Runtime Error):
import math

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

if a*a*b <= 2*x:
    print(90-math.degrees(math.atan(a**3/(2*(a*a*b-x)))))
else:
    print(90-math.degrees(math.atan(2*x/(a*b*b))))



Fixed submission:
import math
a,b,x=map(int,input().split())
if a*a*b<=2*x:
    c=(b-x/(a**2))*2/a
    ans=math.degrees(math.atan(c))
else:
    c=a*b*b/(2*x)
    ans=math.degrees(math.atan(c))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
A.sort()
F.sort(reverse=True)

ng = -1
ok = 10**18
while ok - ng > 1:
    mid = (ok + ng) // 2
    c = 0
    for i in range(N):
        c += max(0,A[i]-mid//F[i])
    if c <= K:
        ok = mid
    else:
        ng = mid
print(ok)


Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
A.sort()
F.sort(reverse=True)

ng = -1
ok = 10**18
while ok - ng > 1:
    mid = (ok + ng) // 2
    c = 0
    for i in range(N):
        c += max(0,A[i]-mid//F[i])
    if c <= K:
        ok = mid
    else:
        ng = mid
print(ok)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=list(map(int,input().split()))
L.sort()
ans=0
for n in range(1,N):
  b=L[n]
  for k in range(n):
    a=L[k]
    left=n+1
    right=N
    while left<right:
      mid=(left+right)//2
      if L[mid-1]<a+b<=L[mid]:
        ans+=(mid-n-1)
        break
      elif a+b<L[mid]:
        right=mid
      else:
        left=mid+1
    ans+=(left-n-1)
print(ans)

Fixed submission:
import bisect
N=int(input())
L=list(map(int,input().split()))
L.sort()
ans=0
for n in range(1,N):
  b=L[n]
  for k in range(n):
    a=L[k]
    index=bisect.bisect_left(L,a+b)
    ans+=(index-n-1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=list(map(int,input().split()))
L.sort(reverse=True)
ans=0
for n in range(N-2):
  for k in range(n+1,N-1):
    if L[n]<L[k]*2:
      for l in range(k+1,N):
        if L[n]<L[k]+L[l]:
          ans+=1
        else:
          break
print(ans)

Fixed submission:
import bisect
N=int(input())
L=list(map(int,input().split()))
L.sort()
ans=0
for n in range(1,N):
  b=L[n]
  for k in range(n):
    a=L[k]
    index=bisect.bisect_left(L,a+b)
    ans+=(index-n-1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=list(map(int,input().split()))
L.sort(reverse=True)
ans=0
for n in range(N-2):
  for k in range(n+1,N-1):
    if L[n]<L[k]*2:
      for l in range(k+1,N):
        if L[n]<L[k]+L[l]:
          ans+=1
        else:
          break
print(ans)

Fixed submission:
import bisect
N=int(input())
L=list(map(int,input().split()))
L.sort()
ans=0
for n in range(1,N):
  b=L[n]
  for k in range(n):
    a=L[k]
    index=bisect.bisect_left(L,a+b)
    ans+=(index-n-1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=list(map(int,input().split()))
L.sort()
ans=0
for n in range(2,N):
  for k in range(1,n):
    for l in range(k):
      if L[n]<L[k]+L[l]:
        ans+=1
print(ans)

Fixed submission:
import bisect
N=int(input())
L=list(map(int,input().split()))
L.sort()
ans=0
for n in range(1,N):
  b=L[n]
  for k in range(n):
    a=L[k]
    index=bisect.bisect_left(L,a+b)
    ans+=(index-n-1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M,L = map(int,input().split())
INF = 10**18
d = [[INF for j in range(N)] for i in range(N)]

# 入力
for _ in range(M):
    A,B,C = map(int,input().split())
    if L < C:
        continue
    d[A-1][B-1] = C
    d[B-1][A-1] = C

# 初期化
for i in range(N):
    d[i][i] = 0

# ワーシャルフロイド1回目
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

for i in range(N):
    for j in range(N):
        if d[i][j] <= L:
            d[i][j] = 1
        else:
            d[i][j] = INF

# 初期化
for i in range(N):
    d[i][i] = 0

# ワーシャルフロイド2回目
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

Q = int(input())

for _ in range(Q):
    s,t = map(int,input().split())
    if d[s-1][t-1] == INF:
        print(-1)
    else:
        print(d[s-1][t-1]-1)



Fixed submission:
N,M,L = map(int,input().split())
INF = 10**18
d = [[INF for j in range(N)] for i in range(N)]

# 入力
for _ in range(M):
    A,B,C = map(int,input().split())
    if L < C:
        continue
    d[A-1][B-1] = C
    d[B-1][A-1] = C

# 初期化
for i in range(N):
    d[i][i] = 0

# ワーシャルフロイド1回目
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

for i in range(N):
    for j in range(N):
        if d[i][j] <= L:
            d[i][j] = 1
        else:
            d[i][j] = INF

# 初期化
for i in range(N):
    d[i][i] = 0

# ワーシャルフロイド2回目
for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

Q = int(input())

for _ in range(Q):
    s,t = map(int,input().split())
    if d[s-1][t-1] == INF:
        print(-1)
    else:
        print(d[s-1][t-1]-1)
Buggy python submission (verdict: Runtime Error):
N=int(input())
 
li=list(map(int,input().split()))
 
ans=sorted(range(N), key=lambda a: li[a])
 
for n in range(N):
  ans[n]+=1
      
print(*ans)

Fixed submission:
N=int(input())

if N%2==0:
  print(1/2)

else:
  print((N+1)/(2*N))

Buggy python submission (verdict: Runtime Error):
N=int(input())
 
li=list(map(int,input().split()))
 
ans=sorted(range(N), key=lambda k: li[k])
 
for n in range(N):
  ans[n]+=1
      
print(*ans)

Fixed submission:
N=int(input())

if N%2==0:
  print(1/2)

else:
  print((N+1)/(2*N))

Buggy python submission (verdict: Runtime Error):
N=int(input())

if N%2==0:
  print(1/2)

else:
  print((n+1)/(2*n))

Fixed submission:
N=int(input())

if N%2==0:
  print(1/2)

else:
  print((N+1)/(2*N))
Buggy python submission (verdict: Time Limit Exceeded):
import copy

N=int(input())

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

ans=copy.copy(li)

for n in range(N):
  ans.pop(li[n]-1)
  ans.insert(li[n]-1,n+1)

print(*ans)

Fixed submission:
import copy

N=int(input())

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

ans=copy.copy(li)

ans=sorted(range(N), key=lambda k: li[k])

for n in range(N):
  ans[n]+=1
      
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import copy

N=int(input())

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

ans=copy.copy(li)

for n in range(N):
  ans.pop(li[n]-1)
  ans.insert(li[n]-1,n+1)

print(*ans)

Fixed submission:
import copy

N=int(input())

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

ans=copy.copy(li)

ans=sorted(range(N), key=lambda k: li[k])

for n in range(N):
  ans[n]+=1
      
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import copy

N=int(input())

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

ans=copy.copy(li)

for n in range(N):
  x=li[n]
  ans.pop(x-1)
  ans.insert(x-1,n+1)

print(*ans)

Fixed submission:
import copy

N=int(input())

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

ans=copy.copy(li)

ans=sorted(range(N), key=lambda k: li[k])

for n in range(N):
  ans[n]+=1
      
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import copy

N=int(input())

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

ans=copy.deepcopy(li)

for n in range(N):
  x=li[n]
  ans.pop(x-1)
  ans.insert(x-1,n+1)

print(*ans)

Fixed submission:
import copy

N=int(input())

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

ans=copy.copy(li)

ans=sorted(range(N), key=lambda k: li[k])

for n in range(N):
  ans[n]+=1
      
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import copy

N=int(input())

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

ans=copy.deepcopy(li)

for n in range(N):
  x=li[n]
  ans.pop(x-1)
  ans.insert(x-1,n+1)

print(*ans)

Fixed submission:
import copy

N=int(input())

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

ans=copy.copy(li)

ans=sorted(range(N), key=lambda k: li[k])

for n in range(N):
  ans[n]+=1
      
print(*ans)
Buggy python submission (verdict: Runtime Error):
S=input()
if S=='Sunny':
    print('Cloudy')
elif:
    print('Rainy')
else:
    print('Sunny')


Fixed submission:
S=input()
if S=='Sunny':
    print('Cloudy')
elif S=='Cloudy':
    print('Rainy')
else:
    print('Sunny')
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = list(map(int,input().split()))

A.sort()
for i in range(M):
    A[-1] = A[-1]//2
    A.sort()

print(sum(A))


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

A.sort()
while M != 0:
    x = bisect.bisect_left(A,A[-1]/2)
    if N-x <= M:
        M -= N-x
        for i in range(x,N):
            A[i] = A[i]/2
        A.sort()
    else:
        for i in range(N-M,N):
            A[i] = A[i]/2
        M = 0
        A.sort()

print(sum(map(int,A)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
ans = 0
for i in range(1,N):
    c = 0
    cc = 0
    for j in range(N-i):
        if S[j] == S[i+j]:
            cc += 1
        else:
            c = max(cc,c)
            cc = 0
    c = max(cc,c)
    c = min(i,c)
    ans = max(ans,c)
print(ans)


Fixed submission:
N = int(input())
S = input()
ans = 0
for i in range(1,N):
    c = 0
    cc = 0
    for j in range(N-i):
        if S[j] == S[i+j]:
            cc += 1
        else:
            c = max(cc,c)
            cc = 0
    c = max(cc,c)
    c = min(i,c)
    ans = max(ans,c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
ans = 0
for i in range(N):
    for j in range(i,N):
        s = S[i:j+1]
        if S[j+1:].find(s) != -1:
            ans = max(ans,len(s))
print(ans)

Fixed submission:
N = int(input())
S = input()
ans = 0
for i in range(1,N):
    c = 0
    cc = 0
    for j in range(N-i):
        if S[j] == S[i+j]:
            cc += 1
        else:
            c = max(cc,c)
            cc = 0
    c = max(cc,c)
    c = min(i,c)
    ans = max(ans,c)
print(ans)