Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
AtCoder, s, Contest = map(str, input().split()) 
x = s[0]
print(f'A{x}C')

Fixed submission:
AtCoder, s, Contest = map(str, input().split()) 
print('A' + s[0] + 'C')

Buggy python submission (verdict: Runtime Error):
AtCoder, s, Contest = map(str, input().split()) 
print(f'A{s[0]}C')AtCoder, s, Contest = map(str, input().split()) 
x = s[0]
print(f'A{s}C')

Fixed submission:
AtCoder, s, Contest = map(str, input().split()) 
print('A' + s[0] + 'C')

Buggy python submission (verdict: Runtime Error):
AtCoder, s, Contest = map(str, input().split()) 
print(f'A{s[0]}C')

Fixed submission:
AtCoder, s, Contest = map(str, input().split()) 
print('A' + s[0] + 'C')

Buggy python submission (verdict: Runtime Error):
AtCoder, s, Contest = map(str, input().split()) 
print(f'A{s[0]}C')

Fixed submission:
AtCoder, s, Contest = map(str, input().split()) 
print('A' + s[0] + 'C')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
count = 0
l.sort(reverse=True)
for i in range(n-2):
  for j in range(i+1,n-1):
    tmp = [k for k, x in enumerate(l[(j+1):]) if x > l[i]-l[j]]
    if len(tmp) != 0:
      count += tmp[-1]+1
print(count)

Fixed submission:
from bisect import bisect_left
 
n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    count+=bisect_left(l,l[j]+l[i])-j-1
print(count)

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

Fixed submission:
from bisect import bisect_left
 
n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    count+=bisect_left(l,l[j]+l[i])-j-1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))
count = 0
l.sort(reverse=True)
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if l[i]<l[j]+l[k] and l[j]<l[k]+l[i] and l[k]<l[i]+l[j]:
        count += 1
      else:
        break
print(count)

Fixed submission:
from bisect import bisect_left
 
n = int(input())
l = list(map(int,input().split()))
l.sort()
count = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    count+=bisect_left(l,l[j]+l[i])-j-1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n=int(input())
a = [list(map(int, input().split())) for _ in range(n)]
a=sum(a,[])
a_sort=copy.copy(a)
a_sort.sort()
a_last,a_last2=a_sort[-1],a_sort[-2]
if a_last==a_last2:
  for i in range(n):
    print(a_last)
else:
  for i in range(n):
    if a[i]!=a_last:
      print(a_last)
    else:
      print(a_last2)

Fixed submission:
n=int(input())
a = [int(input()) for _ in range(n)]
a_max=max(a)
a_max2=sorted(a)[-2]
if a_max!=a_max2:
  for i in range(n):
    if a[i]!=a_max:
      print(a_max)
    else:
      print(a_max2)
else:
  for i in range(n):
    print(a_max)
Buggy python submission (verdict: Runtime Error):
N=int(input())
W=list(map(int,input().split()))
sum_W=sum(W)
half_W=sum_W/2
tmp=sum_W
for i in range(N):
  tmp-=W[i]
  if tmp<half_W:
    print(min(abs(sum_W-2*tmp),abs(sum_W-2*tmp+W[i])))
    break
  elif tmp=half_W:
    print(0)
    break

Fixed submission:
N=int(input())
W=list(map(int,input().split()))
sum_W=sum(W)
half_W=sum_W/2
a=sum_W
b=0
for i in range(N):
  a-=W[i]
  b+=W[i]
  if a<=half_W:
    print(min(abs(a-b),abs(a-b+2*W[i])))
    break
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,M=list(map(int,input().split()))
ans=np.ones(N,int)
for i in range(M):
  L,R=list(map(int,input().split()))
  x=np.zeros(N,int)
  x[L-1:R]=1
  ans*=x
print(sum(ans))

Fixed submission:
N,M=list(map(int,input().split()))
L=[0]*M
R=[0]*M
for i in range(M):
  L[i],R[i]=map(int,input().split())
a=max(L)
b=min(R)
if b>=a:
  print(b-a+1)
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n,q=map(int,input().split())
s=str(input())
lr=[list(map(int, input().split())) for _ in range(q)]
for i in range(q):
  x=s[lr[i][0]-1:lr[i][1]]
  print(x.count('AC'))

Fixed submission:
n,q=map(int,input().split())
s=str(input())
lr=[list(map(int, input().split())) for _ in range(q)]
l=[0]*n
count=0
for i in range(1,n):
  if s[i-1]=='A' and s[i]=='C':
    count+=1
  l[i]=count
for i in range(q):
  print(l[lr[i][1]-1]-l[lr[i][0]-1])
Buggy python submission (verdict: Runtime Error):
# Author : prayushd
# Language : Python

import re
import os
import sys
from math import ceil, inf
from fractions import gcd
from queue import Queue
from collections import defaultdict, Counter, deque
from bisect import bisect, insort, bisect_left, bisect_right

mod = int(1e9)+7
input = sys.stdin.readline

'''
Check for special cases (n=1)
One wrong submission = 10 mins penalty!
do smth instead of nothing and stay organized
'''

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	ans = [inf]*n
	for i in range(n-1):
		ans[i] = min(ans[i], arr[i])
		ans[i+1] = min(ans[i+1], arr[i])
	# print(ans)
	print(sum(ans))


if __name__ == '__main__':
	main()

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
ans = [999999999]*n
for i in range(n-1):
	ans[i] = min(ans[i], arr[i])
	ans[i+1] = min(ans[i+1], arr[i])
print(sum(ans))

Buggy python submission (verdict: Runtime Error):
# Author : prayushd
# Language : Python

import re
import os
import sys
from math import ceil
from fractions import gcd
from queue import Queue
from collections import defaultdict, Counter, deque
from bisect import bisect, insort, bisect_left, bisect_right

mod = int(1e9)+7
input = sys.stdin.readline

'''
Check for special cases (n=1)
One wrong submission = 10 mins penalty!
do smth instead of nothing and stay organized
'''

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	ans = [inf]*n
	for i in range(n-1):
		ans[i] = min(ans[i], arr[i])
		ans[i+1] = min(ans[i+1], arr[i])
	print(sum(ans))


if __name__ == '__main__':
	main()

Fixed submission:
n = int(input())
arr = list(map(int, input().split()))
ans = [999999999]*n
for i in range(n-1):
	ans[i] = min(ans[i], arr[i])
	ans[i+1] = min(ans[i+1], arr[i])
print(sum(ans))
Buggy python submission (verdict: Runtime Error):
n, m = input().split(" ")
# n, m = 100, 5

gacha = 1900 * m
state = 100 * (n-m)

res = (gacha + state) * 2**m

print(res)


Fixed submission:
n, m = map(int, input().split(" "))
# n, m = 100, 5

gacha = 1900 * m
state = 100 * (n-m)

res = (gacha + state) * 2**m

print(res)
Buggy python submission (verdict: Runtime Error):
from math import factorial

N,M = map(int,input().split())

def foo(N,M):
	if N == M+1 or N+1 == M:
		tm = factorial(min(N,M))
		return(tm*max(N,M)+tm)

	elif N==M:
		return(2*factorial(N)*2)

	else:
		return(0)

print(foo(N,M)/(10**9+7))

Fixed submission:
from math import factorial

N,M = map(int,input().split())

def foo(N,M):
	if N == M+1 or N+1 == M:
		tm = factorial(min(N,M))
		return(tm*max(N,M)*tm)

	elif N==M:
		return((factorial(N)**2)*2)

	else:
		return(0)

print(foo(N,M)%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial

N,M = map(int,input().split())

if N == M+1 or N+1 == M:
	print(factorial(N)*factorial(M))

elif N==M:
	print(2*factorial(N)*factorial(M))
	
else:
	print(0)

Fixed submission:
from math import factorial

N,M = map(int,input().split())

def foo(N,M):
	if N == M+1 or N+1 == M:
		tm = factorial(min(N,M))
		return(tm*max(N,M)*tm)

	elif N==M:
		return((factorial(N)**2)*2)

	else:
		return(0)

print(foo(N,M)%(10**9+7))
Buggy python submission (verdict: Runtime Error):
N = int(input())

l = [0 for i in range(N)]
ad = [[] for i in range(N)]
de1 = [0 for i in range(N)]

for i in range(N-1):
	a,b = map(int,input().split())
	l[a-1] += 1
	l[b-1] += 1
	ad[a-1].append(b-1)
	ad[b-1].append(a-1)

for i in range(N):
	if l[i] == 1:
		de1[ad[i][0]] += 1

for i in range(N):
	if de1[i] >= 2:
		print("First")
		break
else:
	print("Second")







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

l = [0 for i in range(N)]

for i in range(M):
	a,b = map(int,input().split())
	l[a-1] += 1
	l[b-1] += 1

for i in l:
	if i%2 == 1:
		print("NO")
		break
else:
	print("YES")
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split(" ")))


l = [[] for i in range(N)]
c = 0

s = 0
t = a[0]

for i in a[1:]:
	if t > i:
		l[s].append((c))
		s = c+1
	c += 1
	t = i
else:
	l[s].append((c))

c = 0

s = 0
t = a[0]

for i in a[1:]:
	if t < i:
		l[s].append((c))
		s = c+1
	c += 1
	t = i
else:
	l[s].append((c))

l[0] = max(l[0])
for i in range(1,N):
	if i!=N-1:
		l[i+1].append(-1)
		l[i] = max(l[i-1],max(l[i]),max(l[i+1]))
	else:
		l[i] = max(l[i-1],max(l[i]))


now = 0
res = 0

while now<N-1:
	now = l[now]	
	res+=1

print(res)

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


l = [[] for i in range(N)]
c = 0

s = 0
t = a[0]

for i in a[1:]:
	if t > i:
		l[s].append((c))
		s = c+1
	c += 1
	t = i
else:
	l[s].append((c))

c = 0

s = 0
t = a[0]

for i in a[1:]:
	if t < i:
		l[s].append((c))
		s = c+1
	c += 1
	t = i
else:
	l[s].append((c))

l[0] = max(l[0])
for i in range(1,N):
	l[i].append(-1)
for i in range(1,N):
	
	if i!=N-1:
		l[i+1].append(-1)
		l[i] = max(l[i-1],max(l[i]),max(l[i+1]))
	else:
		l[i] = max(l[i-1],max(l[i]))


now = 0
res = 0

while now<N-1:
	now = l[now]	
	res+=1
if N==1:
	print(1)
	exit()
print(res)
Buggy python submission (verdict: Runtime Error):
N, L, T = list(map(int, input().split(" ")))

# N,L,T = 3,10,6
# a = [1,2,3]
# b = [2,1,1]

a = []
b = []
for i in range(N):
    an, ve = map(int, input().split(" "))
    a.append(an)
    b.append(ve)

crash = 0

for i in range(1, N):
    if b[0] != b[i]:
        if b[0] == 1:
            crash += (T - ((a[i] - a[0]) / 2)) // (L / 2) + 1
        else:
            crash += (T - (L - (a[i] - a[0])) / 2) // (L / 2) + 1

for i in range(N):
    if b[i] == 1:
        a[i] += T
    else:
        a[i] -= T
    a[i] %= L


if b[0] == 1:
    where = int(crash) % N
else:
    where = int(-crash) % N

nowplace = a[where]
a.sort()

if b[0] == 1:
	if crash % 2 == 1:
		where0 = min([i for i in range(N) if a[i] == nowplace])
	else:
		where0 = max([i for i in range(N) if a[i] == nowplace])		
else:
	if crash % 2 == 1:
		where0 = max([i for i in range(N) if a[i] == nowplace])
	else:
		where0 = min([i for i in range(N) if a[i] == nowplace])

where0 = (where0 - crash) % N

res = a[where0:] + a[:where0]
res = map(str, res)

for i in res:
    print(i)


Fixed submission:
N, L, T = list(map(int, input().split(" ")))

# N,L,T = 3,10,6
# a = [1,2,3]
# b = [2,1,1]

a = []
b = []
for i in range(N):
    an, ve = map(int, input().split(" "))
    a.append(an)
    b.append(ve)

crash = 0

for i in range(1, N):
    if b[0] != b[i]:
        if b[0] == 1:
            crash += (T - ((a[i] - a[0]) / 2)) // (L / 2) + 1
        else:
            crash += (T - (L - (a[i] - a[0])) / 2) // (L / 2) + 1

for i in range(N):
    if b[i] == 1:
        a[i] += T
    else:
        a[i] -= T
    a[i] %= L


if b[0] == 1:
    where = int(crash) % N
else:
    where = int(-crash) % N

nowplace = a[0]

a.sort()

if b[0] == 1:
	where0 = max([i for i in range(N) if a[i] == nowplace])
else:
	where0 = min([i for i in range(N) if a[i] == nowplace])

where0 = (where0 - where) % N

res = a[where0:] + a[:where0]
res = map(str, res)

for i in res:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
input()
a=[]
for i in input().split():
	a.append(int(i))

maxp = 0
b=[]
for i in range(len(a)):
	for j in range(len(a))[i+1:]:
		d=a[j]-a[i]
		if d>maxp:
			maxp=d
		b.append(d)
c=0
for i in b:
	if i==maxp:
		c+=1

print(c)

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

maxp = 0
minp = 10000000000000
maxval=0
c=0
for i in range(len(a)):
	if a[i]<minp:
		minp=a[i]
	val=a[i]-minp
	if val>maxval:
		maxval=val
		c=1
	elif val==maxval:
		c+=1

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
input()
a=[]
for i in input().split():
	a.append(int(i))

maxp = 0
for i in range(len(a)):
	for j in range(len(a))[i+1:]:
		if a[j]-a[i]>maxp:
			maxp=a[j]-a[i]

c=0
for i in range(len(a)):
	for j in range(len(a))[i+1:]:
		if a[j]-a[i]==maxp:
			c+=1
print(c)

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

maxp = 0
minp = 10000000000000
maxval=0
c=0
for i in range(len(a)):
	if a[i]<minp:
		minp=a[i]
	val=a[i]-minp
	if val>maxval:
		maxval=val
		c=1
	elif val==maxval:
		c+=1

print(c)
Buggy python submission (verdict: Runtime Error):
##################################################################

if __name__ == "__main__":
    Input = [input() for i in range(2)]
    # = list(map(int,Input[0].split()))
    S = str(Input[0])
    K = int(Input[1])

    n = len(S)
    ren = 1
    bef = S[0]
    cont = []
    for s in range(1,n):
        if bef == S[s]:
            ren += 1
            bef = S[s]
            if s == n-1:
                cont.append(ren)                
        else:
            cont.append(ren)
            ren = 1
            bef = S[s]

    ans = (sum([c//2 for c in cont]))*K
    if S[0] == S[-1]:
        if cont[0]%2==1 and cont[-1]%2==1:
            ans += K-1
    print(ans)


Fixed submission:
##################################################################

if __name__ == "__main__":
    Input = [input() for i in range(2)]
    # = list(map(int,Input[0].split()))
    S = str(Input[0])
    K = int(Input[1])

    n = len(S)
    ren = 1
    bef = S[0]
    cont = []
    if n == 1:
        cont = [1]
    for s in range(1,n):
        if bef == S[s]:
            ren += 1
            bef = S[s]
            if s == n-1:
                cont.append(ren)                
        else:
            cont.append(ren)
            ren = 1
            bef = S[s]

    ans = (sum([c//2 for c in cont]))*K
    if n ==1:
        ans += K//2
    elif S[0] == S[-1]:
        if len(cont)>1 and cont[0]%2==1 and cont[-1]%2==1:
            ans += K-1
        elif len(cont) ==1:
            ans = (n*K)//2
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np

    
##################################################################

if __name__ == "__main__":
    Input1 = [input() for i in range(2)]
    N = int(Input1[0])
    A = list(map(int,Input1[1].split()))

    B = []
    for i in range(N):
        temp = A.index(i+1)
        B.append(temp+1)
    print(' '.join(map(str,B)))
    


Fixed submission:
#import numpy as np

    
##################################################################

if __name__ == "__main__":
    Input1 = [input() for i in range(2)]
    N = int(Input1[0])
    A = list(map(int,Input1[1].split()))

    B = [0]*N
    for i in range(N):
        temp = A[i]
        B[temp-1] = i+1
    print(' '.join(map(str,B)))
Buggy python submission (verdict: Runtime Error):
#import numpy as np
#from math import gcd

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

    
##################################################################

if __name__ == "__main__":
    Input1 = [input() for i in range(1)]
    #N = int(Input1[0])
    A,B = list(map(int,Input1[0].split()))
    if B > A:
        temp = A
        A = B
        B = temp

    ans = 1
    if B == 1:
        print(ans)
    else:
        for i in range(len(fact)):
            f = fact[i][0]
            if A % f == 0:
                ans += 1
        print(ans)
    
    #print(' '.join(map(str,B)))
    


Fixed submission:
#import numpy as np
#from math import gcd

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

    
##################################################################

if __name__ == "__main__":
    Input1 = [input() for i in range(1)]
    #N = int(Input1[0])
    A,B = list(map(int,Input1[0].split()))
    if B > A:
        temp = A
        A = B
        B = temp

    ans = 1
    if B == 1:
        print(ans)
    else:
        fact = factorization(B)
        for i in range(len(fact)):
            f = fact[i][0]
            if A % f == 0:
                ans += 1
        print(ans)
    
    #print(' '.join(map(str,B)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))

for i in range(1,n+1):
  print(a.index(i)+1,end=' ')

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = [0] * n
for i,j in enumerate(a):
  b[j-1] = i+1
print(' '.join(map(str,b)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [''.join(sorted(input())) for i in range(n)]
cnt = 0
for i in range(len(s)-1):
  for j in range(i+1, len(s)):
    if s[i] == s[j]:
      cnt += 1
print(cnt)

Fixed submission:
import collections
n=int(input())
s=[''.join(sorted(input())) for i in range(n)]
s_cnt=collections.Counter(s)
ans=sum(i*(i-1)//2 for i in s_cnt.values())
print(ans)
Buggy python submission (verdict: Runtime Error):
A,P=map(int,input().split())
print(((A*3)//2 + b//2) + (((A**3)%2 + b%2)//2))

Fixed submission:
A,P=map(int,input().split())
print(((A*3)//2 + P//2) + (((A*3)%2 + P%2)//2))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
  cnt=0
  tmp=0
  while i*tmp < k:
    tmp*=2
    cnt+=1
  ans+=(1/3)*((1/2)**cnt)
  
print(ans)

Fixed submission:
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
  cnt=0
  tmp=1
  while i*tmp < k:
    tmp*=2
    cnt+=1
  ans+=(1/n)*((1/2)**cnt)
  
print(ans)
Buggy python submission (verdict: Runtime Error):
H,W=int(input())
h,w=int(input())
print(H*W-(W*h)+((H*w)-(h*w)))

Fixed submission:
H,W=map(int,input().split())
h,w=map(int,input().split())
print(H*W-((W*h)+((H*w)-(h*w))))
Buggy python submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
ans=[]
for i in range(1,A):
  if A%i==0 and B%i==0:
    ans.append(i)

if len(ans)==0:
  print(1)
else:
  print(ans[-K])

Fixed submission:
A,B,K=list(map(int,input().split()))
ans=[]
c=min(A,B)
for i in range(1,c+1):
  if A%i==0 and B%i==0:
    ans.append(i)

print(ans[-K])
Buggy python submission (verdict: Runtime Error):
a,b,c=int(input())
print(max(a,b,c)-min(a,b,c))

Fixed submission:
a,b,c=map(int,input().split())
print(max(a,b,c)-min(a,b,c))
Buggy python submission (verdict: Runtime Error):
s='0131212112121'
print("Yes" if s[x]==s[y] else "No")

Fixed submission:
s='0131212112121'
x,y=map(int,input().split())
print("Yes" if s[x]==s[y] else "No")
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
ans=0
for i in range(k+1):
  for j in range(k+1):
    for z in range(k+1):
      if i+j+z==s:
        ans+=1
print(ans)

Fixed submission:
k,s=map(int,input().split())
ans=0
for i in range(k+1):
  for j in range(k+1):
    if 0<=s-i-j<=k:
      ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
c = True
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] != 'U' && s[i] != 'D' && s[i] != 'L':
            c = False
    if i % 2 == 1:
        if s[i] != 'U' && s[i] != 'D' && s[i] != 'R':
            c = False

if c:
    print('Yes')
else:
    print('No')
    

Fixed submission:
s = input()
c = True
for i in range(len(s)):
    if i % 2 == 1:
        if s[i] != 'U' and s[i] != 'D' and s[i] != 'L':
            c = False
    if i % 2 == 0:
        if s[i] != 'U' and s[i] != 'D' and s[i] != 'R':
            c = False

if c:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())


if n % 2 == 0:
    print(int(n / 2 * (n - 1)))
else:
    print(int((n - 1) / 2 * n))

Fixed submission:
import math

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

print(math.ceil((b - 1) / (a - 1)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

if n == 1:
    print(0)
else:
    print(sum(range(1, n)))

Fixed submission:
n = int(input())

print(n * (n - 1) // 2)
Buggy python submission (verdict: Runtime Error):
n, i = map(int, input().split())

print(n - i + 1)　

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

print(n - i + 1)
Buggy python submission (verdict: Runtime Error):
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools
    import fractions
    import functools

    n = int(input())
    as_ = list(map(int, input().split()))
        
    # gcd = functools.reduce(math.gcd, as_)
    gcm = as_[0]
    for i in range(1, n):
        gcm = gcm * as_[i] // math.gcd(gcm, as_[i])
        # print(gcm)
    # print(gcm - 1)
    gcm_1 = gcm - 1
    print(functools.reduce(lambda x, y: x + gcm_1 % y, as_, 0))

if __name__ == '__main__':
    main()

Fixed submission:
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools
    import fractions
    import functools

    n = int(input())
    as_ = list(map(int, input().split()))
        
    # gcd = functools.reduce(math.gcd, as_)
    gcm = as_[0]
    for i in range(1, n):
        gcm = gcm * as_[i] // fractions.gcd(gcm, as_[i])
        # print(gcm)
    # print(gcm - 1)
    gcm_1 = gcm - 1
    print(functools.reduce(lambda x, y: x + gcm_1 % y, as_, 0))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    s = input()
    k = int(input())

    chars = sorted(set(s))

    num_substr = 0
    for char in chars:
        substrs = set()
        for i in range(len(s)):
            if s[i] == char:
                for j in range(i, len(s)):
                    substrs.add(s[i:j + 1])
        
        if num_substr + len(substrs) < k:
            num_substr += len(substrs)
            # len_substr -= 1
            continue
        else:
            print(sorted(list(substrs))[k - num_substr - 1])
            break




if __name__ == '__main__':
    main()

Fixed submission:
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    s = input()
    k = int(input())

    substrs = set()
    for i in range(1, 5 + 1):
        for j in range(len(s) - i + 1):
            substrs.add(s[j:j + i])
    # print(substrs)
    print(sorted(list(substrs))[k - 1])


if __name__ == '__main__':
    main()