Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
visited = [0]
visited_flg = [0 for _ in range(N)]
visited_flg[0] = 1
now_city = 0

next_city = A[0]
# visited.append(A[0])

# if K <= N:
#     p = 0
#     for _ in range(K):
#         p = A[p]
#     print(p + 1)
#     exit()


while True:
    next_city = A[now_city] 
    if visited_flg[next_city]:
        break
    
    now_city = next_city
    visited.append(now_city)
    visited_flg[now_city] = 1
    

loop_start = next_city
loop_city =  visited[visited.index(loop_start):]
k =  (K- len(visited)) % len(loop_city)
print(loop_city[k]+1)

Fixed submission:
N, K = map(int,input().split())
A = [int(i)-1 for i in input().split()]

visited = [0]
visited_flg = [0 for _ in range(N)]
visited_flg[0] = 1
now_city = 0

next_city = A[0]
# visited.append(A[0])

if K <= N:
    p = 0
    for _ in range(K):
        p = A[p]
    print(p + 1)
    exit()


while True:
    next_city = A[now_city] 
    if visited_flg[next_city]:
        break
    
    now_city = next_city
    visited.append(now_city)
    visited_flg[now_city] = 1
    

loop_start = next_city
loop_city =  visited[visited.index(loop_start):]
k =  (K- len(visited)) % len(loop_city)
print(loop_city[k]+1)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
def gcd(x, y):
    if x>y:
        if y==0:
            return x
        return gcd(y,x%y)
    else:
        if x==0:
            return y
        return gcd(x,y%_)
if (n%m==0):
    print(0)
else:
    print(gcd(n,m)) 

Fixed submission:
x,y=map(int,input().split())

if x>=y:
    x=x%y
a=y-x
b=x

print(min(a,b))

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
import math
print(math.gcd(n,m))

Fixed submission:
x,y=map(int,input().split())

if x>=y:
    x=x%y
a=y-x
b=x

print(min(a,b))
Buggy python submission (verdict: Time Limit Exceeded):
h,n=map(int,input().split())
M=[list(map(int,input().split())) for _ in range(n)]
res=[0]
f=0
for j in range(1,h+1):
    
    i=0
    if 0>=j-M[i][0]:
        ind=0
    else:
        ind=j-M[i][0]
    ff=res[ind]+M[i][1]
    
    for i in range(1,n):
        if 0>=j-M[i][0]:
            ind=0
        else:
            ind=j-M[i][0]
        kari=res[ind]+M[i][1]
        
        ff=min(ff,kari)
    res.append(ff)
print(res[-1])


Fixed submission:
h,n=map(int,input().split())
M=[list(map(int,input().split())) for _ in range(n)]
res=[0]
f=0
for j in range(1,h+1):
    
    i=0
    if 0>=j-M[i][0]:
        ind=0
    else:
        ind=j-M[i][0]
    ff=res[ind]+M[i][1]
    
    for i in range(1,n):
        if 0>=j-M[i][0]:
            ind=0
        else:
            ind=j-M[i][0]
        kari=res[ind]+M[i][1]
        
        ff=min(ff,kari)
    res.append(ff)
print(res[-1])

Buggy python submission (verdict: Time Limit Exceeded):
h,n=map(int,input().split())
M=[list(map(int,input().split())) for _ in range(n)]
res=[0]
f=0
for j in range(1,h+1):
    ff=[]
    for i in range(n):

        if 0>=j-M[i][0]:
            ind=0
        else:
            ind=j-M[i][0]
        kari=res[ind]+M[i][1]
        
        ff.append(kari)
    res.append(min(ff))
print(res[-1])

Fixed submission:
h,n=map(int,input().split())
M=[list(map(int,input().split())) for _ in range(n)]
res=[0]
f=0
for j in range(1,h+1):
    
    i=0
    if 0>=j-M[i][0]:
        ind=0
    else:
        ind=j-M[i][0]
    ff=res[ind]+M[i][1]
    
    for i in range(1,n):
        if 0>=j-M[i][0]:
            ind=0
        else:
            ind=j-M[i][0]
        kari=res[ind]+M[i][1]
        
        ff=min(ff,kari)
    res.append(ff)
print(res[-1])
Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
nn=str(n)
# c=int(math.log10(n)//1)+1

a=list(range(1,n+1))

b=[[[] for _ in range(10)] for __ in range(10)]
for i in range(1,10):
    for j in range(1,10):
        box=[]
        for h in a:
            if str(h)[0]==str(i) and str(h)[-1]==str(j):
                box.append(h)
        b[i][j]=box

# b=[[[] for _ in range(10)] for __ in range(9)]

ans=0
for i in range(1,10):
    for j in range(1,10):
        ans+=len(b[i][j])*len(b[j][i])
print(ans)

Fixed submission:
import math
n=int(input())
nn=str(n)
# c=int(math.log10(n)//1)+1

a=list(range(1,n+1))


# b=[[[] for _ in range(10)] for __ in range(10)]
b=[[[0] for _ in range(10)] for __ in range(10)]


# for i in range(1,10):
#     for j in range(1,10):
#         box=0
#         for h in a:
#             if str(h)[0]==str(i) and str(h)[-1]==str(j):
# #                 box.append(h)
#                 box+=1
#         b[i][j]=box
        
        
        
for h in a:
    x=int(str(h)[0])
#     print(x)
    y=int(str(h)[-1])
    b[x][y][0]+=1



# b=[[[] for _ in range(10)] for __ in range(9)]

ans=0
for i in range(1,10):
    for j in range(1,10):
        ans+=(b[i][j][0])*(b[j][i][0])
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
TF=[0]*n
p=[0]*n
for _ in range(m):
    i,s =map(str,input().split())
    i=int(i)-1
    if (s=="WA") and (TF[i]==1):
        pass
    elif (s=="WA") and (TF[i]==0):
        p[i]+=1
    elif (s=="AC") and (TF[i]==0):
        TF[i]=1
    elif (s=="AC") and (TF[i]==1):
        pass
for i in range(m):
    if TF[i]==0:
        p[i]=0
ac=sum(TF)
pe=sum(p)
print(ac,pe)

Fixed submission:
n,m=map(int,input().split())
TF=[0]*n
p=[0]*n
for _ in range(m):
    i,s =map(str,input().split())
    i=int(i)-1
    if (s=="WA") and (TF[i]==1):
        pass
    elif (s=="WA") and (TF[i]==0):
        p[i]+=1
    elif (s=="AC") and (TF[i]==0):
        TF[i]=1
    elif (s=="AC") and (TF[i]==1):
        pass
for i in range(n):
    if TF[i]==0:
        p[i]=0
ac=sum(TF)
pe=sum(p)
print(ac,pe)
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
m=math.sqrt(n)
m=math.floor(m)
li=[]
for i in range(1,m):
    a=i+n/i
    li.append(a)
li=[li[i] for i in range(m-1) if li[i].is_integer()]
print(int(min(li))-2)

Fixed submission:
import math
n=int(input())
m=math.sqrt(n)
m=math.floor(m)+1
li=[]
for i in range(1,m):
    a=i+n/i
    li.append(a)
li=[li[i] for i in range(m-1) if li[i].is_integer()]
print(int(min(li))-2)
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
a=list(map(int,input().split()))
eat=0
if a[0]>x:
    eat+=(a[0]-x)
    a[0]=x
for i in range(1,n-1):
    if a[i-1]+a[i]>x:
        f=(a[i-1]+a[i]-x)
        eat+=f
        a[i]=a[i-f]
print(eat)

Fixed submission:
n,x = map(int,input().split())
a=list(map(int,input().split()))
ans=0
if a[0]>x:
    ans+=a[0]-x
    a[0]=x
for i in range(len(a)-1):
    if a[i]+a[i+1]>x:  
        b=a[i+1]-x+a[i]
        a[i+1]=x-a[i]
        ans+=b
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
from bisect import bisect_left
from collections import deque
#======================================================#
def main():
    N = II()
    cc = list(IS())
    cc_rev = cc[::-1]
    cnt = 0
    indexs = []
    for i, c in enumerate(cc):
        if c == 'W':
            indexs.append(i)
    indexs = deque(indexs)
    if cc.count('W') == 0:
        print(0)
        return 0
    for i, c in enumerate(cc_rev):
        if c == 'R':
            idx = indexs.popleft()
            if i >= idx:
                cc[idx] = 'R'
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
from bisect import bisect_left
from collections import deque
#======================================================#
def main():
    n = II()
    cc = list(IS())
    cc_rev = cc[::-1]
    cnt = 0
    indexs = []
    for i, c in enumerate(cc):
        if c == 'W':
            indexs.append(i)
    indexs = deque(indexs)
    if cc.count('W') == 0:
        print(0)
        return 0
    # print(indexs)
    for i, c in enumerate(cc_rev):
        if c == 'R':
            if indexs:
                idx = indexs.popleft()
                if idx < (n-i-1):
                    cc[idx] = 'R'
                    cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
def get_primes(n=10**3):
    is_prime = [True]*(n+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, n+1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def prime_factor(n):
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
#======================================================#
def main():
    n = II()
    aa = MII()
    aa.sort()
    lst = []
    ans = []
    while aa:
        x = aa[0]
        lst = []
        flag=False
        for a in aa[1:]:
            if a%x!=0:
                lst.append(a)
            else:
                if a==x:
                    flag=True
        if not flag:
            ans.append(x)
        aa = lst
        # print(ans)
    print(len(ans))


if __name__ == '__main__':
    main()

Fixed submission:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    aa = MII()
    aa.sort()
    maxa = aa[-1]
    dp = [False]*(maxa+1)
    for a in aa:
        dp[a] = True
    dup = set()
    for a in aa:
        if a in dup:
            dp[a] = False
            continue
        else:
            dup.add(a)
        if dp[a]:
            for j in range(a*2,maxa+1,a):
                dp[j] = False
    print(sum(1 for d in dp if d))



if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    aa = MII()
    t = 1
    for a in aa:
        t *= a
    if t > 10**18:
        print(-1)
    else:
        print(t)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    aa = MII()
    t = 1
    if 0 in aa:
        print(0)
        return None
    for a in aa:
        t *= a
        if t > 10**18:
            print(-1)
            return None
    print(t)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
MD2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
MD3 = lambda d1,d2,d3: [MD2(d2,d3) for _ in range(d1)]
## math
DIVC = lambda x,y: -(-x//y)
DIVF = lambda x,y: x//y

def main():
    s = IS()
    n = len(s)
    cnt = 0
    for i in reversed(range(3,n)):
        if int(s[i-1])%2==0:
            if int(s[i])%2==0: pass
        for j in reversed(range(0,i-3)):
            if int(s[j:i+1])%2019 == 0:
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
MD2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
MD3 = lambda d1,d2,d3: [MD2(d2,d3) for _ in range(d1)]
## math
DIVC = lambda x,y: -(-x//y)
DIVF = lambda x,y: x//y

def main():
    s = list(map(int, IS()))
    n = len(s)
    p = 2019
    cnt = 0
    d = [0]*p
    d[0] = 1 # 0(mod p)はそれ単体で割り切れるため+1しておく
    ss = 0
    x = 1
    for si in s[::-1]:
        ss += x*si
        ss %= p
        d[ss] += 1
        x = (10*x)%p # %p無しだとTLE
    cnt = 0
    for di in d:
        cnt += di*(di-1)//2 # calc combination(n_C_2)
    print(cnt)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
MD2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
MD3 = lambda d1,d2,d3: [MD2(d2,d3) for _ in range(d1)]
## math
DIVC = lambda x,y: -(-x//y)
DIVF = lambda x,y: x//y

def main():
    s = IS()
    n = len(s)
    cnt = 0
    for i in reversed(range(3,n)):
        if int(s[i-1])%2 == 0:
            if int(s[i])%2 == 0: pass
            else: continue
        for j in reversed(range(0,i-3)):
            if int(s[j:i+1])%2019 == 0:
                cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
MD2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
MD3 = lambda d1,d2,d3: [MD2(d2,d3) for _ in range(d1)]
## math
DIVC = lambda x,y: -(-x//y)
DIVF = lambda x,y: x//y

def main():
    s = list(map(int, IS()))
    n = len(s)
    p = 2019
    cnt = 0
    d = [0]*p
    d[0] = 1 # 0(mod p)はそれ単体で割り切れるため+1しておく
    ss = 0
    x = 1
    for si in s[::-1]:
        ss += x*si
        ss %= p
        d[ss] += 1
        x = (10*x)%p # %p無しだとTLE
    cnt = 0
    for di in d:
        cnt += di*(di-1)//2 # calc combination(n_C_2)
    print(cnt)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    X, Y, A, B, C = input_nums()
    P = input_nums()
    Q = input_nums()
    R = input_nums()
    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort(reverse=True)
    res = []
    res += P[:X]
    res += Q[:Y]
    res.sort(reverse=True)
    index = 0
    maxindex = len(R)-1
    for i in range(len(res)):
        if res[i] < R[index] and index <= maxindex:
            res[i] = R[index]
            index += 1
    print(sum(res))
if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    X, Y, A, B, C = input_nums()
    P = input_nums()
    Q = input_nums()
    R = input_nums()
    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort()

    P = sorted(P[:X])
    Q = sorted(Q[:Y])
    res = []
    res = P + Q + R
    res.sort(reverse=True)
    print(sum(res[:X+Y]))
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    X, Y, A, B, C = input_nums()
    P = input_nums()
    Q = input_nums()
    R = input_nums()
    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort(reverse=True)
    res = []
    res += P[:X]
    res += Q[:Y]
    res.sort(reverse=True)
    index = 0
    for i in range(len(res)):
        if res[i] < R[index]:
            res[i] = R[index]
            index += 1
    print(sum(res))
if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    X, Y, A, B, C = input_nums()
    P = input_nums()
    Q = input_nums()
    R = input_nums()
    P.sort(reverse=True)
    Q.sort(reverse=True)
    R.sort()

    P = sorted(P[:X])
    Q = sorted(Q[:Y])
    res = []
    res = P + Q + R
    res.sort(reverse=True)
    print(sum(res[:X+Y]))
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

s = input()
n = int(input())
for i in range(n):
    q = input()
    if len(q) == 1:
        s = s[::-1]
    else:
        _, f, c = q.split()
        if f == '1':
            s = c + s
        else:
            s = s + c
print(s)

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

s = input()
n = int(input())
front = ''
end = ''
front_flag = True # Trueの場合frontがfront Falseの場合endがfront
for i in range(n):
    q = input()
    if len(q) == 1:
        front_flag = not front_flag
    else:
        _, f, c = q.split()
        if f == '1':
            if front_flag:
                front += c
            else:
                end += c
        else:
            if not front_flag:
                front += c
            else:
                end += c

if front_flag:
    s = front[::-1] + s + end
else:
    s = end[::-1] + s[::-1] + front

print(s)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

MOD = 10**9+7
def modcmb(n, r, mod):
    x = 1
    y = n
    for i in range(2,r+1):
        x *= i
        x %= mod
        y *= n-i+1
        y %= mod
    return y * pow(x, mod-2, mod) % mod

n, a, b = [int(x) for x in stdin.readline().rstrip().split()]

DIV = 10**9+7

all_n = '1'* n
nishin = int(all_n, 2)

_a = modcmb(n, a, MOD)
_b = modcmb(n, b, MOD)

print((nishin - (_a + _b))%DIV)

Fixed submission:
from sys import stdin

MOD = 10**9+7
def modcmb(n, r, mod):
    x = 1
    y = n
    for i in range(2,r+1):
        x *= i
        x %= mod
        y *= n-i+1
        y %= mod
    return y * pow(x, mod-2, mod) % mod

n, a, b = [int(x) for x in stdin.readline().rstrip().split()]

DIV = 10**9+7

_n = pow(2, n, MOD)
_a = modcmb(n, a, MOD)
_b = modcmb(n, b, MOD)
ans = _n - _a - _b - 1
print(ans % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

if __name__ == '__main__':
    N = int(stdin.readline().rstrip())
    d = {}
    for i in range(N):
        poll = stdin.readline().rstrip()
        if not poll in d:
            d[poll] = 1
        else:
            d[poll] += 1
    max_k_list = [kv[0] for kv in d.items() if kv[1] == max(d.values())]
    for key in sorted(max_k_list):
        print(key)

Fixed submission:
from sys import stdin

if __name__ == '__main__':
    N = int(stdin.readline().rstrip())
    d = {}
    for i in range(N):
        poll = stdin.readline().rstrip()
        if not poll in d:
            d[poll] = 1
        else:
            d[poll] += 1
    maxv = max(d.values())
    max_k_list = [kv[0] for kv in d.items() if kv[1] == maxv]
    for key in sorted(max_k_list):
        print(key)
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

if __name__ == '__main__':
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
    P = [int(x) for x in stdin.readline().rstrip().split()]
    E = [((p*(p+1))/2)/p  for p in P]
    maxe = 0
    for i in range(N-K+1):
        val = sum(E[i:i+K])
        if maxe < val:
            maxe = val
    print(maxe)

Fixed submission:
from sys import stdin

if __name__ == '__main__':
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
    P = [int(x) for x in stdin.readline().rstrip().split()]
    E = [((p*(p+1))/2)/p  for p in P]
    maxe = sum(E[0:0+K])
    frontval = maxe
    for i in range(1, N-K+1):
        val = frontval - E[i-1] + E[i+K-1]
        frontval = val
        if maxe < val:
            maxe = val
    print(maxe)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
import numpy as np
#======================================================#
MOD=10**9+7
def main():
    n = II()
    aa = np.array(MII())
    ans = 0
    for i in range(60):
        cnt1 = int(sum(aa&1))
        ans += cnt1*(n-cnt1)*(2**i)
        aa >>= 1
    print(ans%MOD)



if __name__ == '__main__':
    main()

Fixed submission:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
import numpy as np
#======================================================#
MOD=10**9+7
def main():
    n = II()
    aa = np.array(MII())
    ans = 0
    for i in range(60):
        cnt1 = int((aa&1).sum())
        ans += cnt1*(n-cnt1)*(2**i)
        aa >>= 1
    print(ans%MOD)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    S = input()
    res = S[0]
    for i in range(1, N):
        if res[-1] != S[i]:
            res += S[i]
    print(len(res))

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    S = input()
    res = S[0]
    for i in range(1, N):
        if res[-1] != S[i]:
            res += S[i]
    print(len(res))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
import itertools as it

def main():
    N = int(input())
    L = input_nums()
    count = 0
    for v in it.combinations(L, 3):
        a, b, c = v
        if a < b + c and b < c + a and c < a + b:
            count += 1
    print(count)


if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
from bisect import bisect_left

def main():
    N = int(input())
    L = sorted(input_nums())
    count = 0
    for i in range(N-2):
        a = L[i]
        for j in range(i+1, N-1):
            count += bisect_left(L, a+L[j]) - j - 1
    print(count)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
import itertools as it

def main():
    N = int(input())
    L = input_nums()
    count = 0
    for v in it.combinations(L, 3):
        a, b, c = v
        if a < b + c and b < c + a and c < a + b:
            count += 1
    print(count)


if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
from bisect import bisect_left

def main():
    N = int(input())
    L = sorted(input_nums())
    count = 0
    for i in range(N-2):
        a = L[i]
        for j in range(i+1, N-1):
            count += bisect_left(L, a+L[j]) - j - 1
    print(count)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

if __name__ == '__main__':
    N = int(stdin.readline().rstrip())
    n = [x for x in range(1,N)]
    print(sum(n))

Fixed submission:
from sys import stdin

if __name__ == '__main__':
    N = int(stdin.readline().rstrip())
    print( ((N-1) * N) // 2)