Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    S=list(input())
    K=int(input())
    S=S*K

    cnt=0
    gr=groupby(S)
    for key,group in gr:
        if len(list(group))>=2:
            cnt+=1
    print(cnt)

resolve()

Fixed submission:
from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    S = list(input())
    K = int(input())
    l = []
    cnt = 0
    if len(S)==1:
        print(K//2)
    else:
        gr = groupby(S)
        for key, group in gr:
            l.append(list(group))
        if len(l)==1:
            print(len(S)*K//2)
        else:
            for i in range(len(l)):
                cnt += len(l[i]) // 2
                
            if l[0][0] == l[-1][0]:
                dev = len(l[0]) // 2 + len(l[-1]) // 2 - (len(l[-1]) + len(l[0])) // 2
            else:
                dev = 0
            print(cnt * K - dev * (K - 1))


resolve()
Buggy python submission (verdict: Time Limit Exceeded):
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N,K,Q=map(int,input().split())
    A=[int(input()) for i in range(Q)]

    process=[K]*N
    for i in range(Q):
        for j in range(N):
            if A[i]-1!=j:
                process[j]-=1
    for i in process:
        if i<=0:
            print('No')
        else:
            print('Yes')


resolve()

Fixed submission:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N,K,Q=map(int,input().split())
    A=[int(input()) for i in range(Q)]

    S=[0]*N
    for i in A:
        S[i-1]+=1

    for i in S:
        if K-(Q-i)<=0:
            print('No')
        else:
            print('Yes')


resolve()
Buggy python submission (verdict: Time Limit Exceeded):
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():

    N=int(input())
    H=list(map(int,input().split()))

    maxcnt=0
    for i in range(N):
        cnt=0


        j=i
        for j in range(i,N-1):
            if H[j] >= H[j + 1]:
                cnt+=1
            else:
                break

        maxcnt=max(maxcnt,cnt)
    print(maxcnt)



resolve()

Fixed submission:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():

    N=int(input())
    H=list(map(int,input().split()))

    d=[1]*N


    for j in range(1,N):
        if H[j-1] >= H[j]:
            d[j]+=d[j-1]
        else:
            continue

    print(max(d)-1)



resolve()

Buggy python submission (verdict: Time Limit Exceeded):
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():

    N=int(input())
    H=list(map(int,input().split()))

    maxcnt=0
    for i in range(N):
        cnt=0

        j=i
        while j<=N-2:
            if H[j] >= H[j + 1]:
                cnt+=1
                j+=1
            else:
                break

        maxcnt=max(maxcnt,cnt)
    print(maxcnt)



resolve()

Fixed submission:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():

    N=int(input())
    H=list(map(int,input().split()))

    d=[1]*N


    for j in range(1,N):
        if H[j-1] >= H[j]:
            d[j]+=d[j-1]
        else:
            continue

    print(max(d)-1)



resolve()
Buggy python submission (verdict: Time Limit Exceeded):
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
from collections import Counter
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    N=int(input())
    S=[str(input()) for i in range(N)]


    cnt=0
    for i in range(N):
        for j in range(i+1,N):
            if Counter(S[i])==Counter(S[j]):
                cnt+=1

    print(cnt)

resolve()

Fixed submission:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
from collections import Counter
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    N=int(input())
    S=[''.join(sorted(input())) for i in range(N)]
    C=Counter(S)
    print(sum(i*(i-1)//2 for i in C.values()))






resolve()

Buggy python submission (verdict: Time Limit Exceeded):
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    N=int(input())
    S=[sorted(list(input())) for i in range(N)]

    cnt=0
    for i in range(N):
        for j in range(i+1,N):
            if S[i]==S[j]:
                cnt+=1

    print(cnt)

resolve()

Fixed submission:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
from collections import Counter
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    N=int(input())
    S=[''.join(sorted(input())) for i in range(N)]
    C=Counter(S)
    print(sum(i*(i-1)//2 for i in C.values()))






resolve()
Buggy python submission (verdict: Time Limit Exceeded):
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():

    N=int(input())
    H=list(map(int,input().split()))
    def main():
        if N == 1:
            return 'Yes'
        for i in range(N-1):
            if i==N-2:
                return 'Yes'
            if H[i]<=min(H[i+1:])+1:
                continue
            else:
                return 'No'
    print(main())


resolve()

Fixed submission:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():

    N=int(input())
    H=list(map(int,input().split()))
    def main():
        if N == 1:
            return 'Yes'
        maxval=0
        for i in range(N):
            if maxval-2>=H[i]:
                return 'No'
            else:
                maxval=max(maxval,H[i])
        return 'Yes'
    print(main())


resolve()
Buggy python submission (verdict: Runtime Error):
    S = int(input())
    # S == 10 ** 9 * i + mod
    i, mod = divmod(S, 10 ** 9)
    # 求めたいのは、10 ** 9 * i - modなるiとmodの組
    # mod == 0のときはそのまま
    if mod == 0:
        print(0, 0, 10 ** 9, mod, 1, i)
    # そうでないときはiをインクリしてmodの項を負にしてしまえばいい
    else:
        print(0, 0, 10 ** 9, 10 ** 9 * (i + 1) - S, 1, i + 1)

Fixed submission:
def resolve():
    S=int(input())
    i,mod=divmod(S,10**9)
    if mod==0:
        print(0,0,10**9,mod,1,i)
    else:
        print(0,0,10**9,10**9*(i+1)-S,1,i+1)

resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N=int(input())
    A=[int(input()) for i in range(N)]
    temp=[0]*N

    for i in range(N):
        if A[i]<max(A):
            temp[i]=max(A)
        elif A.count(max(A))!=1:
            temp[i]=max(A)
        else:
            temp[i]=max(A[:i]+A[i+1:])
    for i in temp:
        print(i)



resolve()

Fixed submission:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
#from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    N=int(input())
    A=[int(input()) for i in range(N)]
    B=sorted(A,reverse=True)

    for i in range(N):
        if A[i]<B[0]:
            print(B[0])
        else:
            print(B[1])



resolve()

Buggy python submission (verdict: Time Limit Exceeded):
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    N=int(input())
    A=[int(input()) for i in range(N)]
    temp=[0]*N

    for i in range(N):
        if A[i]<max(A):
            temp[i]=max(A)
        elif A.count(max(A))!=1:
            temp[i]=max(A)
        else:
            temp[i]=max(A[:i]+A[i+1:])
    for i in temp:
        print(i)



resolve()

Fixed submission:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
#from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    N=int(input())
    A=[int(input()) for i in range(N)]
    B=sorted(A,reverse=True)

    for i in range(N):
        if A[i]<B[0]:
            print(B[0])
        else:
            print(B[1])



resolve()
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    A=[0]+list(map(int,input().split()))
    ans=[0]*(N+1)
    s=[0]*(N+1)

    for i in reversed(range(1,N+1)):
        cnt=0
        for j in range(i+i,N+1,i):
            cnt^=s[j]
        if (A[i]==1 and cnt!=1) or (A[i]==0 and cnt!=0): s[i]=1
    
    print(sum(s))
    for i in range(1,N + 1):
        if s[i]==1:
            print(s.index(i))






    

resolve()

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    A=[0]+list(map(int,input().split()))
    ans=[0]*(N+1)
    s=[0]*(N+1)

    for i in reversed(range(1,N+1)):
        cnt=0
        for j in range(i+i,N+1,i):
            cnt^=s[j]
        if (A[i]==1 and cnt!=1) or (A[i]==0 and cnt!=0): s[i]=1
    
    print(sum(s))
    for i in range(1,N + 1):
        if s[i]==1:
            print(i)






    

resolve()
Buggy python submission (verdict: Time Limit Exceeded):
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import unittest
from io import StringIO
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    n = int(input())
    seq = [int(input()) for _ in range(n)]

    # リストseqからLISの長さを出す

    import bisect
    
    def main():
        cnt=0
        while len(seq)>0:

            LIS = [seq[0]]
            for i in range(len(seq)):
                if seq[i] > LIS[-1]:
                    LIS.append(seq[i])
                else:
                    LIS[bisect.bisect_left(LIS, seq[i])] = seq[i]
            cnt+=1
            
            for i in LIS:
                seq.remove(i)
        return cnt
    print(main())
    




resolve()

Fixed submission:
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import unittest
from io import StringIO
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    n = int(input())
    seq = [int(input()) for _ in range(n)][::-1]

    """
    Longest Increasing/Decreasing Subsuquence (LIS, LDS)
    Verified:
        https://atcoder.jp/contests/abc134/tasks/abc134_e
        https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/all/DPL_1_D
    """


    def longest_subsequence(A: "Array[int]", equals: bool, increasing: bool) -> int:
        """
        Compute the length of LIS or LDS.
        
        Args:
            A ("Array[int]"): a list or tuple to compute.
            equals (bool): permit adjacent numbers in subsequence to equal.
            increasing (bool): compute an increasing subsequence or decreasing one.
        Returns: (int) the length of a subsequence.
        """
        from bisect import bisect_left, bisect_right

        bs = bisect_right if equals else bisect_left
        compare = (lambda x, y: x >= y) if equals else (lambda x, y: x > y)
        if not increasing:
            A = A[::-1]

        dp = [A[0]]  # dp := length of LIS (dp table itself is not LIS)
        for i in A[1:]:
            if compare(i, dp[-1]):
                dp.append(i)
            else:
                dp[bs(dp, i)] = i
        return len(dp)
    
    print(longest_subsequence(seq,True,True))

    
    




resolve()
Buggy python submission (verdict: Time Limit Exceeded):
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    L,R=map(int,input().split())
    minmod=10**10
    for i in range(L,R):
        for j in range(i+1,R+1):
            minmod=min(minmod,(i*j)%2019)
    print(minmod)

resolve()

Fixed submission:
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product

def resolve():
    L,R=map(int,input().split())
    if R-L<2018:
        print(min([(i*j)%2019 for i in range(L,R) \
                   for j in range(i+1, R+1)]))
    else:
        print(0)

resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    n,k=map(int,input().split())
    val=(n-1)*(n-2)//2
    if k>val:
        print(-1)
    else:
        edge=[(1,i) for i in range(2,n+1)]
        rem=val-k
        a,b=2,3
        cnt=0
        while True:
            if b<=n:
                if edge[-1]!=(a,b):
                    edge.append((a,b))
                    cnt+=1
                    if cnt==rem:
                        break
                b+=1
            else:
                a+=1
                b=a+1
                edge.append((a,b))
                cnt+=1
                if cnt==rem: break
        
        print(len(edge))
        for i in edge:
            print(*i)
        #print()



    
resolve()

Fixed submission:
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():

    n, k = map(int, input().split())
    val = (n-1)*(n-2)//2
    if k > val:
        print(-1)
    else:
        rem = val-k
        print(n-1+rem)
        for i in range(2,n+1):
            print(1,i)
        a, b = 2, 3
        cnt = 0
        for i in range(rem):
            print(a,b)
            if b < n:
                b+=1
            else:
                a += 1
                b = a+1



resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    H,W=map(int,input().split())
    grid=[[_ for _ in input()] for _ in range(H)]
    ans=0
    for h in range(H):
        for w in range(W):
            if grid[h][w]=='.':
                cnt=1
                i=1
                while True:
                    if h+i<H and grid[h+i][w]=='.':
                        cnt+=1
                        i+=1
                    else:
                        break
                i=1
                while True:
                    if w+i<W and grid[h][w+i]=='.':
                        cnt+=1
                        i+=1
                    else:
                        break
                i=1
                while True:
                    if h-i>=0 and grid[h-i][w]=='.':
                        cnt+=1
                        i+=1
                    else:
                        break
                i=1
                while True:
                    if w-i >=0 and grid[h][w-i]=='.':
                        cnt+=1
                        i+=1
                    else:
                        break
                ans=max(ans,cnt)
    print(ans)



resolve()

Fixed submission:
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    H, W = map(int, input().split())
    grid = [[_ for _ in input()] for _ in range(H)]

    l = [[0] * W for _ in range(H)]
    r = [[0] * W for _ in range(H)]
    u = [[0] * W for _ in range(H)]
    d = [[0] * W for _ in range(H)]

    for h in range(H):
        cur = 0
        for w in range(W):
            if grid[h][w] == '#':
                cur = 0
            else:
                cur += 1
            l[h][w] = cur

    for h in range(H):
        cur = 0
        for w in reversed(range(W)):
            if grid[h][w] == '#':
                cur = 0
            else:
                cur += 1
            r[h][w] = cur

    for w in range(W):
        cur = 0
        for h in range(H):
            if grid[h][w] == '#':
                cur = 0
            else:
                cur += 1
            u[h][w] = cur

    for w in range(W):
        cur = 0
        for h in reversed(range(H)):
            if grid[h][w] == '#':
                cur = 0
            else:
                cur += 1
            d[h][w] = cur

    ans = 0
    for h in range(H):
        for w in range(W):
            ans = max(ans, r[h][w] + l[h][w] + u[h][w] + d[h][w] - 3)
    print(ans)


resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    N, M = map(int, input().split())
    d = Counter(list(map(int, input().split())))

    for i in range(M):
        b, c = map(int, input().split())
        d[c] += b

    d = dict(sorted(d.items(), reverse=True))

    def main():
        cnt = 0
        ans = 0

        for k, v in d.items():
            if cnt + v < N:
                ans += v * k
                cnt += v
            else:
                ans += (N - cnt) * k
                return ans

    print(main())



resolve()

Fixed submission:
A,B=map(int,input().split())
if A<=5:
    print(0)
elif 6<=A<=12:
    print(B//2)
else:
    print(B)
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N,M=map(int,input().split())
    l, r = map(int, input().split())
    s = {i for i in range(l, r + 1)}
    for i in range(1,M):
        l,r=map(int,input().split())
        s=s&{i for i in range(l,r+1)}

    print(len(s))


resolve()

Fixed submission:
# input = sys.stdin.readline

def resolve():
    N,M=map(int,input().split())
    l, r = map(int, input().split())
    for i in range(1,M):
        ll,rr=map(int,input().split())
        l=max(l,ll)
        r=min(r,rr)

    print(r-l+1 if r-l+1>=0 else 0)


resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    N,M=map(int,input().split())
    l, r = map(int, input().split())
    s = {i for i in range(l, r + 1)}
    for i in range(1,M):
        l,r=map(int,input().split())
        s=s&{i for i in range(l,r+1)}

    print(len(s))


resolve()

Fixed submission:
# input = sys.stdin.readline

def resolve():
    N,M=map(int,input().split())
    l, r = map(int, input().split())
    for i in range(1,M):
        ll,rr=map(int,input().split())
        l=max(l,ll)
        r=min(r,rr)

    print(r-l+1 if r-l+1>=0 else 0)


resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    N, M = map(int, input().split())
    d = Counter(list(map(int, input().split())))

    for i in range(M):
        b, c = map(int, input().split())
        d[c] += b

    d = dict(sorted(d.items(), reverse=True))

    def main():
        cnt = 0
        ans = 0

        for k, v in d.items():
            if cnt + v < N:
                ans += v * k
                cnt += v
            else:
                ans += (N - cnt) * k
                return ans

    print(main())



resolve()

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

for _ in range(M):
  B, C = map(int, input().split())
  A[C] += B

A = sorted(A.items(), key=lambda x:x[0], reverse=True)

ans = 0
for key, count in A:
  if N > count:
    ans += key * count
    N -= count
  else:
    ans += key * N
    break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import heapq
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N,M=map(int,input().split())
    A=sorted(list(map(int,input().split())))
    B, C = [0] * M, [0] * M
    for i in range(M):
        B[i], C[i] = map(int, input().split())



    L=[]
    for i in range(M):
        for _ in range(B[i]):
            L.append(C[i])
    L.sort()
    ans=list(heapq.merge(A,L))
    print(sum(ans[len(ans)-N:]))




resolve()

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

for _ in range(M):
  B, C = map(int, input().split())
  A[C] += B

A = sorted(A.items(), key=lambda x:x[0], reverse=True)

ans = 0
for key, count in A:
  if N > count:
    ans += key * count
    N -= count
  else:
    ans += key * N
    break

print(ans)