Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

res = len(T)
for i in range(len(S)) :
    for j in range(i,len(S)) :
        if (S[i:j] in T) and (i>=T.index(S[i:j])) :
            diff = len(T) - len(S[i:j])
        if res>=diff :
            res = diff

print(res)

Fixed submission:
D,T,S = map(int,input().split())
if (D/S <= T) :
    print("Yes")
else :
    print("No")

Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

min = 100000
for i in range(len(S)) :
    for j in range(len(S),i-1,-1) :
        if (S[i:j] in T) :
            if (min > len(T) - len(S[i:j])) and (i >= T.index(S[i:j]) and j<=len(T)-T.index(S[i:j]) ) :
                min = len(T) - len(S[i:j])

print(min)

Fixed submission:
D,T,S = map(int,input().split())
if (D/S <= T) :
    print("Yes")
else :
    print("No")
Buggy python submission (verdict: Runtime Error):
n, x, m = map(int, input().split())
count=x
now=x
flag=-1
sled=[now]
for i in range(1,n):
     now=(now*now)%m
     if now==0:
         flag=0
         break
     if now==1:
         flag==1
         nokori=n-i
         break
     if now in sled:
         start=sled.index(now)
         nokori=n-i
         flag=2
         break
     
     else:
         sled.append(now)
     count+=now
     #print(i,now,count)
sled=sled[start:]
if flag==1:
    count+=nokori
if flag==2:
    #print(count)
    roopnum=int(nokori/len(sled))
    amari=nokori%len(sled)
    
    one_roop=sum(sled)
    count+=one_roop*roopnum
    #print(count)
    for i in range(amari):
        count+=sled[i]
print(count)

Fixed submission:
n, x, m = map(int, input().split())
count=x
now=x
flag=-1
sled=[now]
for i in range(1,n):
     now=(now*now)%m
     if now==0:
         flag=0
         break
     if now in sled:
         start=sled.index(now)
         nokori=n-i
         flag=2
         break
     
     else:
         sled.append(now)
     count+=now
     #print(i,now,count)

if flag==2:
    #print(count)
    sled=sled[start:]
    roopnum=int(nokori/len(sled))
    amari=nokori%len(sled)
    
    one_roop=sum(sled)
    count+=one_roop*roopnum
    #print(count)
    for i in range(amari):
        count+=sled[i]
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
A = list(map(int, input().split()))

scored_list=[]
score=A[k-1]
for i in range(k-1):
    score*=A[k-i-2]
scored_list.append(score)
for i in range(n-k):
    score/=A[i]
    score*=A[k+i]
    scored_list.append(score)
for i in range(len(scored_list)-1):
    if scored_list[i]<scored_list[i+1]:
        print("Yes")
    else:
        print("No")

Fixed submission:
n, k = map(int, input().split())
A = list(map(int, input().split()))

for i in range(n-k):
    if A[i]<A[k+i]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
x = int(input())
A = list(map(int, input().split()))

kabu=0
money=1000
x=x-1
for i in range(len(A)):
    if A[x-i]>A[x-i-1]:
        lastday=x-i
        break
    
for i in range(lastday):
    if A[i]<A[i+1]:#翌日の方が高い⇒購入
        buy=money//A[i]
        money-=A[i]*buy
        kabu+=buy
    elif A[i]>A[i+1]:#前日の方が低い⇒売却
        money+=A[i]*kabu
        kabu=0

money+=A[lastday]*kabu
print(money)
        

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

kabu=0
money=1000
x=x-1
lastday=0
for i in range(len(A)):
    if A[x-i]>A[x-i-1]:
        lastday=x-i
        break
    
for i in range(lastday):
    if A[i]<A[i+1]:
        buy=money//A[i]
        money-=A[i]*buy
        kabu+=buy
    elif A[i]>A[i+1]:
        money+=A[i]*kabu
        kabu=0

money+=A[lastday]*kabu
print(money)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, k = map(int, input().split())
    A = [int(a) for a in input().split()]

    score = 1
    for i in range(k):
        score *= A[i]

    for i in range(n - k):
        tmp = ((score // A[i]) * A[k + i])

        if tmp > score:
            print("Yes")
        else:
            print("No")

        score = tmp

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n, k = map(int, input().split())
    A = [int(a) for a in input().split()]
        
    for i in range(n - k):
        if A[i + k] > A[i]:
            print("Yes")
        else:
            print("No")

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, k = map(int, input().split())
    A = [int(a) for a in input().split()]

    score = 1
    for i in range(k):
        score *= A[i]

    for i in range(n - k):
        tmp = (score // A[i]) * A[k + i]

        if tmp > score:
            print("Yes")
        else:
            print("No")

        score = tmp

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n, k = map(int, input().split())
    A = [int(a) for a in input().split()]
        
    for i in range(n - k):
        if A[i + k] > A[i]:
            print("Yes")
        else:
            print("No")

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, k = map(int, input().split())
    A = [int(a) for a in input().split()]

    score = 1
    for i in range(k):
        score *= A[i]

    for i in range(n - k):
        tmp = (score // A[i]) * A[k + i]

        if tmp > score:
            print("Yes")
        else:
            print("No")

        score = tmp

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n, k = map(int, input().split())
    A = [int(a) for a in input().split()]
        
    for i in range(n - k):
        if A[i + k] > A[i]:
            print("Yes")
        else:
            print("No")

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n, k = map(int, input().split())
    A = [int(a) for a in input().split()]

    score = 0
    is_high = True
    for i in range(k - 1, n):
        tmp = 1
        for j in range(k):
            tmp *= A[i - j]

        if i >= k:
            if tmp > score:
                print("Yes")
            else:
                print("No")

        score = tmp

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n, k = map(int, input().split())
    A = [int(a) for a in input().split()]
        
    for i in range(n - k):
        if A[i + k] > A[i]:
            print("Yes")
        else:
            print("No")

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N, M, K = map(int, input().split())
    A = deque([int(a) for a in input().split()])
    B = deque([int(b) for b in input().split()])
    Bsum = sum(B)
    ans = Asum = 0
    idx_b = len(B) - 1

    A.appendleft(0)

    for i in range(len(A)):
        Asum += A[i]

        for j in range(idx_b + 1):
            if Asum + Bsum > K:
                if idx_b >= 0:
                    Bsum -= B[idx_b]
                    idx_b -= 1
                else:
                    break
            else:
                break

        if Asum + Bsum <= K:
            ans = max(ans, i + (idx_b + 1))

    print(ans)
 
if __name__ == "__main__":
    main()

Fixed submission:
def main3():
    N, M, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    B = [int(b) for b in input().split()]
    Bsum = sum(B)
    ans = Asum = 0
    idx_b = len(B) - 1

    for i in range(N + 1):
        if i == 0:
            if Asum + Bsum <= K:
                ans = max(ans, i + idx_b + 1)

            else:
                while Asum + Bsum > K:
                    if idx_b >= 0:
                        Bsum -= B[idx_b]
                        idx_b -= 1
                    else:
                        break
                    
                if Asum + Bsum <= K:
                    ans = max(ans, i + idx_b + 1)

        else:
            Asum += A[i - 1]

            while Asum + Bsum > K:
                if idx_b >= 0:
                    Bsum -= B[idx_b]
                    idx_b -= 1
                else:
                    break
            if Asum + Bsum <= K:
                ans = max(ans, i + idx_b + 1)

    print(ans)

if __name__ == "__main__":
    main3()
Buggy python submission (verdict: Time Limit Exceeded):
import time
def main():
    N = int(input())
    A = input()
    ans = 1
    inf = 10**18
    t = time.time()

    for a in A.split():
        ans *= int(a)

    if ans > inf:
        print(-1)
    else:
        print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
import time
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    ans = 1
    inf = 10**18
    t = time.time()

    if 0 in A:
        print(0)
        exit()

    for i in range(len(A)):
        ans *= A[i]
        if ans > inf :
            print(-1)
            exit()

    print(ans)
    
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    ans = 1
    inf = 10**18

    for i in range(len(A)):
        ans *= A[i]

    if ans > inf:
        print(-1)
    else:
        print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
import time
def main():
    N = int(input())
    A = [int(a) for a in input().split()]
    ans = 1
    inf = 10**18
    t = time.time()

    if 0 in A:
        print(0)
        exit()

    for i in range(len(A)):
        ans *= A[i]
        if ans > inf :
            print(-1)
            exit()

    print(ans)
    
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def main():
    K = int(input())
    s = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                s += gcd(i, j, k)
    print(s)
if __name__ == "__main__":
    main()

Fixed submission:
import math
from functools import reduce
def main():
    K = int(input())
    s = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                s += math.gcd(math.gcd(i, j), k)
    print(s)
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
def main():
    N = int(input())
    A = [ a for a in input().split()]
    pair = defaultdict(int)
    for i in range(N):
        pair[A[i]] += 1

    for i in range(N):
        pair[A[i]] -= 1
        comb = 0
        for k, v in pair.items():
            if v >= 2:
                comb += v*(v-1)//2
        print(comb)
        pair[A[i]] += 1

if __name__ == "__main__":
    main()

Fixed submission:
from collections import defaultdict
def main():
    N = int(input())
    A = [ a for a in input().split()]
    pair = defaultdict(int)
    for i in range(N):
        pair[A[i]] += 1

    total = 0
    for k, v in pair.items():
        total += v*(v-1)//2

    for i in range(len(A)):
        v = pair[A[i]]
        ans = total - (v*(v-1)//2) + (v-1)*(v-2)//2
        print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
def main():
    S = input()
    Q = int(input())
    ans = deque(S)

    for q in range(Q):
        T, *arg = input().split()
        T = int(T)

        if T == 1:
            ans.reverse()
        else:
            if int(arg[0]) == 1:
                ans.appendleft(arg[1])
            else:
                ans.append(arg[1])

    print("".join(ans))
if __name__ == "__main__":
    main()

Fixed submission:
from collections import deque
def main():
    S = input()
    Q = int(input())
    ans = deque(S)
    switch = 1
    count = 0

    for q in range(Q):
        T, *arg = input().split()
        T = int(T)

        if T == 1:
            count += 1
            if switch == 1:
                switch = 2
            elif switch == 2:
                switch = 1
        else:
            if switch == 1:
                if int(arg[0]) == 1:
                    ans.appendleft(arg[1])
                else:
                    ans.append(arg[1])
            else:
                if int(arg[0]) == 1:
                    ans.append(arg[1])
                else:
       
                    ans.appendleft(arg[1])

    if count % 2 == 0:
        print("".join(ans))
    else:
        ans.reverse()
        print("".join(ans))
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    total = sum(A)
    cnt = 0
    for i in range(N):
        if A[i] < total*1.0/(4.0*M):
            pass
        else:
            cnt += 1
    if cnt >= M:
        print("Yes")
    else:
        print("No")
main()

Fixed submission:
def main():
    N, K  = map(int, input().split())
    if K == 10:
        print(len(str(N)))
    else:
        mod = list()
        count = 0
        for i in range(10**9):
            a, b = divmod(N, K)
            N = a
            count += 1
            if N == 0:
                break
        print(count)
main()
Buggy python submission (verdict: Runtime Error):
def main2():
    N, A, B = map(int, input().split())

    d = B - A - 1
    if d % 2 ==  0:
        print(min(B - 1, N - A))
    else:
        print((d + 1)//2)

if __name__ == "__main__":
    main()

Fixed submission:
def main3():
    N, A, B = map(int, input().split())
    
    d = B - A
    if d % 2 == 0:
        print(d // 2)
    else:
        print(min(((d + 1) // 2 + N - B ), ((d + 1) // 2 + A - 1)))
         
if __name__ == "__main__":
    main3()
Buggy python submission (verdict: Runtime Error):
def main2():
    n = int(input())
    x = int(math.ceil(n / 1.08))
    
    if int(x*1.08) == n:
        print(x)
    else:
        print(":(")

if __name__ == "__main__":
    main2()

Fixed submission:
def main():
    n = int(input())

    x = int(n/1.08)
    if int(x * 1.08) == n:
        print(x)
    elif int((x + 1) * 1.08) == n:
        print(x + 1)
    elif int((x - 1) * 1.08) == n:
        print(x - 1)
    else:
        print(":(")

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main2():
    n = int(input())
    x = int(math.ceil(n / 1.08))
    
    if x == n:
        print(x)
    else:
        print(":(")

if __name__ == "__main__":
    main2()

Fixed submission:
def main():
    n = int(input())

    x = int(n/1.08)
    if int(x * 1.08) == n:
        print(x)
    elif int((x + 1) * 1.08) == n:
        print(x + 1)
    elif int((x - 1) * 1.08) == n:
        print(x - 1)
    else:
        print(":(")

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    words = [ "".join(sorted(list(input()))) for i in range(N)]
    w = set(words)

    pair = 0
    for word in w:
        c = words.count(word)
        if c >= 2:
            pair += c*(c-1)//2
    
    print(pair)

if __name__ == "__main__":
    main()

Fixed submission:
from collections import defaultdict
def main(): 
    N = int(input())
    words = [ "".join(sorted(list(input()))) for i in range(N)]
    w = defaultdict(int)

    for word in words:
        w[word] += 1
        
    pair = 0
    for k, v in w.items():
        if v >= 2:
            pair += v*(v-1)//2
    
    print(pair)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import copy
def main():
    N = int(input())
    A = [int(input()) for a in range(N) ]
    for i in range(N):
        tmp = copy.copy(A[i])
        A[i] = 0
        print(max(A))
        A[i] = copy.copy(tmp)
if __name__ == "__main__":
    main()

Fixed submission:
import copy
def main():
    N = int(input())
    A = [int(input()) for a in range(N) ]
    C = sorted(A)
    Af = C[-1]
    As = C[-2]

    for i in range(N):
        if A[i] != Af:
            print(Af)
        else:
            print(As)
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    L, R = map(int, input().split())
    R = min(R, L + 4038)
    ans = 2018

    for i in range(L, R + 2020):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i*j) % 2019)

    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    L, R = map(int, input().split())
    R = min(R, L + 4038)
    ans = 2018

    for i in range(L, R + 2020):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i*j) % 2019)

    print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    L, R = map(int, input().split())
    R = min(R, L + 4038)
    ans = 2018

    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i*j) % 2019)

    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    L, R = map(int, input().split())
    R = min(R, L + 4038)
    ans = 2018

    for i in range(L, R + 2020):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i*j) % 2019)

    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    W, H, x, y = map(int, input().split())

    if x == W/2 and y == H/2:
        pat = 1

    print(W*H/2.0, pat)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    W, H, x, y = map(int, input().split())
    pat = 0

    if x == W/2 and y == H/2:
        pat = 1

    print((W*H)/2.0, pat)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    W, H, x, y = map(int, input().split())

    area = 0
    pat = 0

    if (x == 0 and y == 0) or (x == 0 and y == H) or (x == W and Y == 0) or (x == W and y == H):
        area = W*H/2.0
        
    else:
        area_H = 0
        area_V = 0

        area_H = min(H - y, y) * W
        area_V = min(x, W - x) * H

        if area_H == area_V:
            pat = 1

        area = max(area_H, area_V)
        
    print(area, pat)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    W, H, x, y = map(int, input().split())
    pat = 0

    if x == W/2 and y == H/2:
        pat = 1

    print((W*H)/2.0, pat)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    menu = [ input() for a in range(5)]
    time = 0
    for i in range(len(menu)):
        if int(menu[i]) % 10 == 0:
            time += int(menu[i])
            menu[i] = "0"
    if len(menu) > 0:
        for i in range(menu.count("0")):
            menu.remove("0")

        menu.sort(key = (lambda x: 10 - int(x[-1])))

        for i in range(len(menu) - 1):
            time += int(menu[i]) + 10 - int(menu[i][-1])
        time += int(menu[-1])
    print(time)
main()

Fixed submission:
def main():
    menu = [ input() for a in range(5)]
    time = 0
    for i in range(len(menu)):
        if int(menu[i]) % 10 == 0:
            time += int(menu[i])
            menu[i] = "0"
    if len(menu) > 0:
        for i in range(menu.count("0")):
            menu.remove("0")
    if len(menu) > 0:
        menu.sort(key = (lambda x: 10 - int(x[-1])))

        for i in range(len(menu) - 1):
            time += int(menu[i]) + 10 - int(menu[i][-1])
        time += int(menu[-1])
    print(time)
main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    S = input()
    cnt = 0
   
    if len(set(S)) == 1 :
        print(0)
    else:
        l_past  = None
        l_new = None
        block = list(S)

        for i in range(10**5):
            block = [ a for a in block if a != "-"]
            l_new = len(block)

            if l_past == l_new :
                break

            for i in range(len(block) - 1):
                if (block[i] == "0" and block[i+1] == "1") or (block[i] == "1" and block[i+1] == "0"):
                    cnt += 2
                    block[i] = "-"
                    block[i+1] = "-"

            l_past = l_new

        print(cnt)

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    S = input()
    print(2*min(S.count("0"), S.count("1")))
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    S = input()
    cnt = 0
    l_past  = None
    l_new = None
    block = list(S)
    for i in range(10**5):
        block = [ a for a in block if a != "-"]
        l_new = len(block)

        if l_past == l_new :
            break

        for i in range(len(block) - 1):
            if (block[i] == "0" and block[i+1] == "1") or (block[i] == "1" and block[i+1] == "0"):
                cnt += 2
                block[i] = "-"
                block[i+1] = "-"

        l_past = l_new

    print(cnt)
    
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    S = input()
    print(2*min(S.count("0"), S.count("1")))
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    S = input()
    cnt = 0
    for i in range(len(S)):
        if S.find("10") != -1 or S.find('01') != -1:
            if S.find("10") != -1:
                S = S.replace("10", "", 1)
                cnt += 1
            if S.find("01") != -1:
                S = S.replace("01", "", 1)
                cnt += 1
        else:
            break
    print(cnt*2)
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    S = input()
    print(2*min(S.count("0"), S.count("1")))
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N, M = map(int, input().split())
    answer = [[0]*M for n in range(N)]
    for i in range(N):
        K, *A = map(int, input().split())
        for a in A:
            answer[i][a] = 1
    count = 0
    for j in range(M):
        same = 0
        for i in range(N):
            same += answer[i][j]
        if same == N:
            count += 1
    print(count)
main()

Fixed submission:
def main():
    N, M = map(int, input().split())
    answer = [[0]*M for n in range(N)]
    for i in range(N):
        K, *A = map(int, input().split())
        for a in A:
            answer[i][a-1] = 1
    count = 0
    for j in range(M):
        same = 0
        for i in range(N):
            same += answer[i][j]
        if same == N:
            count += 1
    print(count)
main()