Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    from itertools import accumulate

    N = int(input())  # len(A)
    A = list(map(int, input().split()))
    zenbu=sum(A)
    B = [0] + A
    B = list(accumulate(B))
    C = [zenbu]*N
    import numpy as np
    B=np.array(B[1:])
    C=np.array(C)
    D=C-B
    ans=10**18
    for i in range(1, N+1):
        ans = min(abs(B[i]-D[i]),ans)
    print(ans)
resolve()

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

def resolve():
    from itertools import accumulate

    N = int(input())  # len(A)
    A = list(map(int, input().split()))
    zenbu=sum(A)
    B = [0] + A
    B = list(accumulate(B))  # 累積和を格納したリスト作成


    ans=10**18
    for i in range(1, N):
        ans = min(abs(B[i]-(zenbu-B[i])),ans)
    print(ans)

resolve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    ans=10**18
    for i in range(1,n):
        x=abs(sum(l[:i])-sum(l[i:]))
        ans=min(x,ans)
    print(ans)
resolve()

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

def resolve():
    from itertools import accumulate

    N = int(input())  # len(A)
    A = list(map(int, input().split()))
    zenbu=sum(A)
    B = [0] + A
    B = list(accumulate(B))  # 累積和を格納したリスト作成


    ans=10**18
    for i in range(1, N):
        ans = min(abs(B[i]-(zenbu-B[i])),ans)
    print(ans)

resolve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    lans=[]
    for i in range(1,n):
        lans.append(abs(sum(l[:i])-sum(l[i:])))
    print(min(lans))
resolve()

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

def resolve():
    from itertools import accumulate

    N = int(input())  # len(A)
    A = list(map(int, input().split()))
    zenbu=sum(A)
    B = [0] + A
    B = list(accumulate(B))  # 累積和を格納したリスト作成


    ans=10**18
    for i in range(1, N):
        ans = min(abs(B[i]-(zenbu-B[i])),ans)
    print(ans)

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

def resolve():
    import numpy as np
    n=int(input())
    l=[list(map(int,input().split())) for i in range(n)]
    import itertools
    ans=0
    p=list(itertools.permutations(l))
    for x in p:
        z = list(x)
        for y in range(n-1):
            a=np.array(z[y])
            b=np.array(z[y+1])
            ans+=np.linalg.norm(a-b)
    print(ans/len(list(p)))
resolve()

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

def resolve():
    n=int(input())
    l=[list(map(int,input().split())) for i in range(n)]
    import itertools
    ans=0
    p=list(itertools.permutations(l))
    for x in p:
        z = list(x)
        for y in range(n-1):
            ans+=((z[y][0]-z[y+1][0])**2+(z[y][1]-z[y+1][1])**2)**0.5
    print(ans/len(list(p)))
resolve()

Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import numpy as np
    n=int(input())
    l=[list(map(int,input().split()))]
    lkyori=[]
    for i in range(n):
        for j in range(i+1,n+1):
            a=np.array(l[i])
            b=np.array(l[j])
            lkyori.append(np.linalg.norm(a-b)/n)
    import itertools
    answer=0
    print(list(itertools.permutations(lkyori,2)))

resolve()

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

def resolve():
    n=int(input())
    l=[list(map(int,input().split())) for i in range(n)]
    import itertools
    ans=0
    p=list(itertools.permutations(l))
    for x in p:
        z = list(x)
        for y in range(n-1):
            ans+=((z[y][0]-z[y+1][0])**2+(z[y][1]-z[y+1][1])**2)**0.5
    print(ans/len(list(p)))
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    n,k,q=map(int, input().split())
    l=[int(input()) for i in range(q)]
    a=[k-q for i in range(n)]
    for i in l:
        a[i-1]+=1
    for i in range(n):
        if a[i]<=0:
            print('No')
        else:
            print('Yes')
resolve()

Fixed submission:
s=input()
if s=='Sunny':
    print('Cloudy')
elif s=='Cloudy':
    print('Rainy')
else:
    print('Sunny')
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n,k,q=map(int, input().split())
    a=k-q
    l=[int(input()) for i in range(q)]
    for i in range(1,n+1):
        if a+l.count(i)>0:
            print('Yes')
        else:
            print('No')
resolve()

Fixed submission:
def resolve():
    n,k,q=map(int, input().split())
    l=[int(input()) for i in range(q)]
    a=[k-q for i in range(n)]
    for i in l:
        a[i-1]+=1
    for i in range(n):
        if a[i]<=0:
            print('No')
        else:
            print('Yes')
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n,k,q=map(int, input().split())
    l=[int(input()) for i in range(q)]
    for i in range(1,n+1):
        if k-(q-l.count(i))<=0:
            print('No')
        else:
            print('Yes')
resolve()

Fixed submission:
def resolve():
    n,k,q=map(int, input().split())
    l=[int(input()) for i in range(q)]
    a=[k-q for i in range(n)]
    for i in l:
        a[i-1]+=1
    for i in range(n):
        if a[i]<=0:
            print('No')
        else:
            print('Yes')
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n,k,q=map(int, input().split())
    l=[int(input()) for i in range(q)]
    for i in range(1,n+1):
        if k-(q-l.count(i))<=0:
            print('No')
        else:
            print('Yes')
resolve()

Fixed submission:
def resolve():
    n,k,q=map(int, input().split())
    l=[int(input()) for i in range(q)]
    a=[k-q for i in range(n)]
    for i in l:
        a[i-1]+=1
    for i in range(n):
        if a[i]<=0:
            print('No')
        else:
            print('Yes')
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    hl=list(map(int,input().split()))
    cntmax=0
    #スタート位置
    for i in range(n):
        #右に移動
        cnt = 0
        for j in range(i,n-1):
            if hl[j] >= hl[j+1]:
                cnt+=1
                if cnt==n-1-i:
                    cntmax=max(cnt,cntmax)
            else:
                cntmax=max(cnt,cntmax)
                break
    print(cntmax)
resolve()

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

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    cnt=0
    cntmax=0
    for i in range(n-1):
        if l[i]>=l[i+1]:
            cnt+=1
            cntmax=max(cnt,cntmax)
        else:
            cntmax=max(cnt,cntmax)
            cnt=0
    print(cntmax)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().strip()

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 sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    s=[sorted(list(input())) for i in range(n)]
    s.sort()
    ans=0
    cnt=1
    for i in range(n-1):
        if s[i]==s[i+1]:
                cnt+=1
                if i ==n-2:
                    ans+=cnt*(cnt-1)//2
        else:
            if cnt>=2:
                ans += cnt * (cnt - 1) // 2
                cnt=1
    print(ans)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=[int(input()) for i in range(n)]
    if len(set(l))==1:
        for i in range(n):
            print(max(l))
    else:
        biggest = max(l)
        lsort=sorted(l)
        niban=lsort[-2]
        for j in range(n):
            if l[j]!=biggest:
                print(biggest)
            else:
                print(niban)
resolve()

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

def resolve():
    n=int(input())
    l=[int(input()) for i in range(n)]
    biggest = max(l)
    lsort=sorted(l)
    niban=lsort[-2]
    for j in range(n):
        if l[j]!=biggest:
            print(biggest)
        else:
            print(niban)
resolve()
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    import numpy as np
    n,d=map(int, input().split())
    l=[list(map(int,input().split())) for i in range(n)]
    cnt=0
    for j in range(n-1):
        for k in range(j+1,n):
            a=np.array(l[j])-np.array(l[k])
            if (np.linalg.norm(a))%1==0:
                cnt+=1
    print(cnt)
resolve()

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

def resolve():
    import numpy as np
    n,d=map(int, input().split())
    l=[list(map(int,input().split())) for i in range(n)]
    cnt=0
    for j in range(n-1):
        for k in range(j+1,n):
            a=np.array(l[j])-np.array(l[k])
            if (np.linalg.norm(a))%1==0:
                cnt+=1
    print(cnt)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    n=int(input())
    l=list(map(int, input().split()))
    ans='YES'
    l.sort()
    for i in range(n-1):
        if l[i]==l[i+1]:
            ans='NO'
    print(ans)

resolve()

Fixed submission:
def resolve():
    s=input()
    num=0
    for i in range(len(s)):
        for j in range(len(s)+1):
            s1=s[i:j]
            if 'B' not in s1 and 'D' not in s1 and 'E' not in s1 and 'F' not in s1\
                    and 'H' not in s1 and 'I' not in s1 and 'J' not in s1 and 'K' not in s1 and 'L' not in s1 and\
                    'M' not in s1 and 'N' not in s1 and 'O' not in s1 and 'P' not in s1 and 'Q' not in s1 and\
                    'R' not in s1 and 'S' not in s1 and 'U' not in s1 and 'V' not in s1 and 'W' not in s1 and\
                    'X' not in s1 and 'Y' not in s1 and 'Z' not in s1 and len(s1)>=num:
                num=len(s1)
    print(num)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    cnt=0
    n,m,c=map(int, input().split())
    b_list=list(map(int, input().split()))
    for i in range(n):
        a_list=list(map(int, input().split()))
        for x in range(m):
            siki=0
            siki+=a_list[i]*b_list[i]
            if siki>-c:
                cnt+=1
    print(cnt)
resolve()

Fixed submission:
def resolve():
    cnt = 0
    n, m, c = map(int, input().split())
    b_list = list(map(int, input().split()))
    for i in range(n):
        a_list = list(map(int, input().split()))
        siki = 0
        for x in range(m):
            siki += (a_list[x] * b_list[x])
        if siki+c > 0:
                cnt += 1
    print(cnt)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    s=int(input())
    l=[s]
    for i in range(10**6):
        if l[i]%2==0:
            if l[i]//2 in l:
                print(i+2)
                break
            else:
                l.append(l[i]//2)
        else:
            if 3*l[i]+1 in l:
                print(i+2)
                break
            else:
                l.append(3 * l[i] + 1)
resolve()


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

def resolve():
    a,b,c=map(int, input().split())
    print(a*b//2)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    a,b,c=map(int, input().split())
    cnt=0
    if a+b>=c-1:
        print(b+c)
    else:
        print(a+b+1+)
resolve()

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

def resolve():
    a,b,c=map(int, input().split())
    cnt=0
    if a+b>=c-1:
        print(b+c)
    else:
        print(a+b+1+b)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b,c=map(int, input().split())
    cnt=0
    if a+b>=c-1:
        print(b+c)
    else:
        while c>=1:
            c-=1
            if b>0:
                b-=1
                cnt+=2
            elif b==0 and a>0:
                a-=1
                cnt+=1
            elif b==0 and a==0:
                cnt+=1
                break
        if b>0:
            cnt+=b
        print(cnt)
resolve()

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

def resolve():
    a,b,c=map(int, input().split())
    cnt=0
    if a+b>=c-1:
        print(b+c)
    else:
        print(a+b+1+b)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    s=list(input())
    cnt=0
    while True:
        flag=True
        for i in range(len(s)-1):
            if s[i]=='B' and s[i+1]=='W':
                cnt+=1
                s[i],s[i+1]='W','B'
                flag=False
        if flag:
            break
    print(cnt)
resolve()

Fixed submission:


def resolve():
    s=list(input())
    ans=[]
    cnt=0
    for i in s:
        if i=='B':
            cnt+=1
        else:
            ans.append(cnt)
    print(sum(ans))
resolve()

Buggy python submission (verdict: Time Limit Exceeded):

def resolve():
    s=input()
    cnt=0
    while s.count('BW')>=1:
        s=list(s)
        for i in range(len(s)-1):
            if s[i]=='B' and s[i+1]=='W':
                cnt+=1
                s[i],s[i+1]='W','B'
        s=''.join(s)
    print(cnt)

resolve()

Fixed submission:


def resolve():
    s=list(input())
    ans=[]
    cnt=0
    for i in s:
        if i=='B':
            cnt+=1
        else:
            ans.append(cnt)
    print(sum(ans))
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    a,b,k=map(int, input().split())
    turn=0
    for i in range(k):
        if turn==0:
            if a%2!=0:
                a-=1
            b+=a//2
            a=a//2
            turn=1
        else:
            if b%2!=0:
                b-=1
            a+=b//2
            b=b//2
            turn=0
    print(a,b)
resolve()

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

def resolve():
    s=input()
    if len(s)==2:
        print(s)
    else:
        print(s[2]+s[1]+s[0])
resolve()
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,x=map(int, input().split())
    l=list(map(int,input().split()))
    if n==1:
        print(l[0]-x)
    else:
        l.append(x)
        l.sort()
        S=[]
        for i in range(n):
            S.append(l[i+1]-l[i])
        from functools import reduce
        from math import gcd
        print(reduce(gcd,S))
resolve()


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

def resolve():
    n,x=map(int, input().split())
    l=list(map(int,input().split()))
    ll=[]
    for i in l:
        ll.append(abs(x-i))
    from functools import reduce
    from fractions import gcd
    print(reduce(gcd,ll))
resolve()

Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,x=map(int, input().split())
    l=list(map(int,input().split()))
    if n==1:
        print(l[0]-x)
    else:
        l.append(x)
        l.sort()
        S=[]
        for i in range(n-1):
            S.append(l[i+1]-l[i])
        from functools import reduce
        from math import gcd
        print(reduce(gcd,S))
resolve()

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

def resolve():
    n,x=map(int, input().split())
    l=list(map(int,input().split()))
    ll=[]
    for i in l:
        ll.append(abs(x-i))
    from functools import reduce
    from fractions import gcd
    print(reduce(gcd,ll))
resolve()
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        s=input()
        k=int(input())
        if int(s[0])!=1:
            return s[0]
        else:
            cnt=0
            for i in s:
                if int(i)==1:
                    cnt+=1
                    if cnt>=k:
                        return 1
                else:
                    if cnt>=k:
                        return 1
                    else:
                        return i
    print(main())
resolve()

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

def resolve():
    a,b=map(int, input().split())
    print(a*b-a-b+1)
resolve()
Buggy python submission (verdict: Runtime Error):

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

def resolve():
    import functools
    n=int(input())
    print(n * 2 // functools.gcd(n, 2))
resolve()


Fixed submission:

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

def resolve():
    import fractions
    n=int(input())
    print(n * 2 // fractions.gcd(n, 2))
resolve()

Buggy python submission (verdict: Runtime Error):

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

def resolve():
    import functools
    n=int(input())
    n * 2 // functools.gcd(n, 2)

resolve()

Fixed submission:

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

def resolve():
    import fractions
    n=int(input())
    print(n * 2 // fractions.gcd(n, 2))
resolve()

Buggy python submission (verdict: Runtime Error):

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

def resolve():
    n=int(input())
    import math
    def lcm(x, y):
        return (x * y) // math.gcd(x, y)
    print(lcm(2,n))
resolve()

Fixed submission:

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

def resolve():
    import fractions
    n=int(input())
    print(n * 2 // fractions.gcd(n, 2))
resolve()
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int, input().split())
    l=list(map(int,input().split()))
    cnt=0
    if n<=k:
        print(1)
    else:

        while True:
            n-=k
            n+=1
            cnt+=1
            if n<=k:
                cnt+=1
                print(cnt)
                break
reso

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

def resolve():
    n,k=map(int, input().split())
    l=list(map(int,input().split()))
    cnt=0
    if n<=k:
        print(1)
    else:

        while True:
            n-=k
            n+=1
            cnt+=1
            if n<=k:
                cnt+=1
                print(cnt)
                break
resolve()
Buggy python submission (verdict: Runtime Error):
def input(): return sys.stdin.readline().strip()

def resolve():
    x=int(input())
    l=[]
    for i in range(1,33):
        for j in range(1,11):
            if i**j>=x:
                l.append(i**(j-1))
                break
    print(max(l))
resolve()

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

def resolve():
    x=int(input())
    l=[]
    for i in range(1,33):
        for j in range(2,11):
            y=i**j
            if y<x:
                l.append(y)
            elif y==x:
                l.append(y)
                break
            else:
                break
    print(max(l))
resolve()
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,x=map(int, input().split())
    l=[int(input()) for i in range(n)]
    print((x-sum(l))//min(l)+n)
resolve()

Fixed submission:
def resolve():
    s=input()
    print(700+100*s.count('o'))
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    def main():

        n=int(input())
        d=list(map(int,input().split()))
        m=int(input())
        t=list(map(int,input().split()))
        from collections import Counter
        dd=Counter(d)
        tt=Counter(t)
        ddkey=list(dd.keys())
        ddvalue=list(dd.values())
        for x,y in tt.items():
            flag=True
            if x in ddkey and ddvalue[ddkey.index(x)]>=y:
                continue
            else:
                return 'NO'
        return 'YES'
    print(main())
resolve()

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

def resolve():
    def main():

        n=int(input())
        d=list(map(int,input().split()))
        m=int(input())
        t=list(map(int,input().split()))
        from collections import Counter
        dd=Counter(d)
        tt=Counter(t)
        for key,value in tt.items():
            if dd[key]<value:
                return 'NO'
        return 'YES'
    print(main())
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():

        n=int(input())
        d=list(map(int,input().split()))
        m=int(input())
        t=list(map(int,input().split()))
        from collections import Counter
        dd=Counter(d)
        tt=Counter(t)
        ddl=list(dd.keys())
        for x,y in tt.items():
            flag=True
            for j,k in dd.items():
                if x==j :
                    if y<=k:
                        flag=False
                        break
                    else:
                        return 'NO'
            if flag:
                return 'NO'
        return 'YES'
    print(main())
resolve()

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

def resolve():
    def main():

        n=int(input())
        d=list(map(int,input().split()))
        m=int(input())
        t=list(map(int,input().split()))
        from collections import Counter
        dd=Counter(d)
        tt=Counter(t)
        for key,value in tt.items():
            if dd[key]<value:
                return 'NO'
        return 'YES'
    print(main())
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    dl=list(map(int,input().split()))
    m=int(input())
    tl=list(map(int,input().split()))
    ans='YES'
    for i in tl:
        if i not in dl:
            ans='NO'
            break
        if i in dl:
            dl.remove(i)
    print(ans)
resolve()

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

def resolve():
    def main():

        n=int(input())
        d=list(map(int,input().split()))
        m=int(input())
        t=list(map(int,input().split()))
        from collections import Counter
        dd=Counter(d)
        tt=Counter(t)
        for key,value in tt.items():
            if dd[key]<value:
                return 'NO'
        return 'YES'
    print(main())
resolve()
Buggy python submission (verdict: Runtime Error):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    S=[]
    for i in range(n):
        S.append(int(input()))
    from functools import reduce
    from math import gcd

    def lcm(A, B):
        return A * B // gcd(A, B)


    print(reduce(lcm, S))
resolve()

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

def resolve():
    n=int(input())
    S=[]
    for i in range(n):
        S.append(int(input()))
    from functools import reduce
    from fractions import gcd

    def lcm(A, B):
        return A * B // gcd(A, B)


    print(reduce(lcm, S))
resolve()