Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    long N, A, B;
    cin >> N >> A >> B;
    vector<long> h;
    for (int i=0; i<N; i++){
        long input;
        cin >> input;
        h.push_back(input);
    }

    
    long ans = 0;
    vector<long> temp;
    while (h.size() != 0){
        bool first = true;
        make_heap(h.begin(),h.end());
        for (auto x : h){
            if (first) {x -= A; first = false;}
            else{ x -= B;}
            if (x > 0) temp.push_back(x);
        }
        h.clear();
        for (auto x : temp) h.push_back(x);
        temp.clear();
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Fixed submission:
with open(0) as f:
    N, A, B, *H = map(int, f.read().split())

diff = A - B #追加ダメージ
T = (max(H)+B-1)//B #答えはT以下

def clearable(t): #t回以内で敵を全滅できるか判定
    Higher = [h-B*t for h in H if h-B*t > 0]
    return True if sum([(h+diff-1)//diff for h in Higher]) <= t else False

def binary_search(a, b, judge): #b must be a or higher
    if a == b:
        return a, b
    
    c = a + (b - a)// 2
    return (a, c) if judge(c) else (c+1, b)

a, b = 0, T
while a != b:
    a, b = binary_search(a, b, clearable)
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
with open(0) as f:
    N, *a = map(int, f.read().split())
F = [x for x in a[:N]] #Fの要素は加えるか取り除くかの2択
C = [x for x in a[N:2*N]] 
B = [-x for x in a[2*N:]] #Bの要素は引くか取り除くかの二択
import heapq as hq
hq.heapify(F)
hq.heapify(B)

#Cを二分し、前半はFと、後半はBとで演算を行う
#演算方法(c in C)
#前半：cがF[0]より大きければF[0]を取り除くN個の一つとし、cをスコアに加える
#後半：-cがB[0]より大きければB[0]を取り除くN個の一つとし、cをスコアから引く
#どちらも場合も条件を満たさない場合はそのｃを取り除くN個の一つとする
#計算量：O(N*N*logN)
#途中計算をメモして計算量軽減
from copy import deepcopy
memoF = [[]] * (N+1) #C[:i]を前半としたときのFとの演算結果
memoF[0] = deepcopy(F)
memoB = [[]] * (N+1) #C[i:]を後半としたときのBとの演算結果
memoB[N] = deepcopy(B)
for i in range(N):
    if C[i] > F[0]:
        hq.heapreplace(F, C[i])
    if -C[N-1-i] > B[0]:
        hq.heapreplace(B, -C[N-1-i])
    memoF[i+1] = deepcopy(F)
    memoB[N-1-i] = deepcopy(B)

Scores = [sum(memoF[i])+sum(memoB[i]) for i in range(N+1)]
ans = max(Scores)
print(ans)

Fixed submission:
with open(0) as f:
    N, *a = map(int, f.read().split())
F = [x for x in a[:N]] #Fの要素は加えるか取り除くかの2択
C = [x for x in a[N:2*N]] 
B = [-x for x in a[2*N:]] #Bの要素は引くか取り除くかの二択
import heapq as hq
#ヒープにして常に最小値を追跡
hq.heapify(F)
hq.heapify(B)

#Cを二分し、前半はFと、後半はBとで演算を行う
#演算方法(c in C)
#前半：cがF[0]より大きければF[0]を取り除くN個の一つとし、cをスコアに加える
#後半：-cがB[0]より大きければB[0]を取り除くN個の一つとし、cをスコアから引く
#どちらも場合も条件を満たさない場合はそのｃを取り除くN個の一つとする
#計算量：O(N*N*logN)
#途中計算をメモして計算量軽減
from copy import deepcopy
memoF = [0] * (N+1) #C[:i]を前半としたときのFとの演算結果の要素和
memoF[0] = sum(F)
memoB = [0] * (N+1) #C[i:]を後半としたときのBとの演算結果の要素和
memoB[N] = sum(B)
for i in range(N):
    if C[i] > F[0]:
        memoF[i+1] = memoF[i] + C[i] - hq.heapreplace(F, C[i])
    else:
        memoF[i+1] = memoF[i]

    if -C[N-1-i] > B[0]:
        memoB[N-1-i] = memoB[N-i] - C[N-1-i] - hq.heapreplace(B, -C[N-1-i])
    else:
        memoB[N-1-i] = memoB[N-i]

Scores = [memoF[i]+memoB[i] for i in range(N+1)]
ans = max(Scores)
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = open(0).readline().split()
from collections import Counter
cnt = Counter(open(0).read().split())
for i in range(1,int(N)+1):
    print(cnt[str(i)])

Fixed submission:
N, M, *cnt = open(0).read().split()
from collections import Counter
cnt = Counter(cnt)
for i in range(1,int(N)+1):
    print(cnt[str(i)])

Buggy python submission (verdict: Runtime Error):
N, M = open(0).readline().split()
from collections import Counter
cnt = Counter(open(0).read().split())
print('\n'.join(list(map(str,cnt.values()))))

Fixed submission:
N, M, *cnt = open(0).read().split()
from collections import Counter
cnt = Counter(cnt)
for i in range(1,int(N)+1):
    print(cnt[str(i)])

Buggy python submission (verdict: Runtime Error):
N, M = open(0).readline().split()
from collections import Counter
cnt = Counter(open(0).read().split())
print('\n'.join(map(str,cnt.values())))

Fixed submission:
N, M, *cnt = open(0).read().split()
from collections import Counter
cnt = Counter(cnt)
for i in range(1,int(N)+1):
    print(cnt[str(i)])

Buggy python submission (verdict: Runtime Error):
N, M = open(0).readline().split()
from collections import Counter
cnt = Counter([x for x in open(0).read().split()])
print('\n'.join(map(str,cnt.values())))

Fixed submission:
N, M, *cnt = open(0).read().split()
from collections import Counter
cnt = Counter(cnt)
for i in range(1,int(N)+1):
    print(cnt[str(i)])

Buggy python submission (verdict: Runtime Error):
N, M = open(0).readline().split()
from collections import Counter
cnt = Counter([int(x) for x in open(0).read().split()])
print('\n'.join(map(str,cnt.values())))

Fixed submission:
N, M, *cnt = open(0).read().split()
from collections import Counter
cnt = Counter(cnt)
for i in range(1,int(N)+1):
    print(cnt[str(i)])
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
w, v = [], []
for _ in range(N):
    x, y = map(int, input().split())
    w.append(x)
    v.append(y)
from collections import defaultdict
dp = defaultdict(lambda: 0)
dp[0,0] = 0

for i in range(N):
    for weight in range(W+1):
        if weight >= w[i]:
            dp[i+1,weight] = max(dp[i,weight], dp[i,weight-w[i]]+v[i])
        else:
            dp[i+1,weight] = dp[i,weight]
print(dp[N,W])


Fixed submission:
N, W = map(int, input().split())
Items = [tuple(map(int, input().split())) for _ in range(N)]
from collections import defaultdict as dd
Bag = dd(lambda:0)
Bag[0] = 0
for w,v in Items:
    temp = [(key+w,Bag[key]+v) for key in Bag if key + w <= W]
    for key,value in temp:
        Bag[key] = max(Bag[key],value)
ans = max(Bag.values())
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = input().split()
print('H' if (a == 'H') ^ (b == 'D') else 'D')

Fixed submission:
a, b, c = map(int, input().split())
if b - a == c - b:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
x = [x for x in map(int, input().split())]
y = [y for y in map(int, input().split())]
sum_x = 0
sum_y = 0
ans = 0
for i in range(n):
    sum_x += (2*i - n + 1) * x[i+1] 
for j in range(m):
    sum_y += (2*j - m + 1) * y[j+1]
ans = sum_x * sum_y
print(ans%1000000007)

Fixed submission:
n, m = map(int, input().split())
x = [x for x in map(int, input().split())]
y = [y for y in map(int, input().split())]
sum_x = 0
sum_y = 0
ans = 0
for i in range(n):
    sum_x += (2*i - n + 1) * x[i] 
for j in range(m):
    sum_y += (2*j - m + 1) * y[j]
ans = sum_x * sum_y
print(ans%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
x = [x for x in map(int, input().split())]
y = [y for y in map(int, input().split())]
ans = 0
for i in range(n-1):
    for j in range(m-1):
        v = (i+1)*(n-1-i) * (j+1)*(m-1-j) #面積係数
        x_width = x[i+1] - x[i]
        y_width = y[j+1] - y[j]
        ans += v * x_width * y_width #面積係数*最小長方形面積
print(ans%1000000007)

Fixed submission:
n, m = map(int, input().split())
x = [x for x in map(int, input().split())]
y = [y for y in map(int, input().split())]
sum_x = 0
sum_y = 0
ans = 0
for i in range(n):
    sum_x += (2*i - n + 1) * x[i] 
for j in range(m):
    sum_y += (2*j - m + 1) * y[j]
ans = sum_x * sum_y
print(ans%1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
dp = {}
dp[0] = 0

for i in range(1,X+1):
    dp_ = dp.copy()
    for key in dp.keys():
        if not key+i in dp.keys(): dp_[key+i] = i
        else: dp_[key+i] = min(dp_[key+i], i)

        #if not key-i in dp.keys(): dp_[key-i] = i
        #else: dp_[key-i] = min(dp_[key-i],i)
    dp = dp_
ans = dp[X]
print(ans)



Fixed submission:
import math
X = int(input())
n =  math.ceil((math.sqrt(1+8*X) - 1)/2)
ans = n
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
X = int(input())
dp = {}
dp[0] = 0

for i in range(1,X+1):
    dp_ = dp.copy()
    for key in dp.keys():
        if not key+i in dp.keys(): dp_[key+i] = i
        else: dp_[key+i] = min(dp_[key+i], i)

        if not key-i in dp.keys(): dp_[key-i] = i
        else: dp_[key-i] = min(dp_[key-i],i)
    dp = dp_
ans = dp[X]
print(ans)



Fixed submission:
import math
X = int(input())
n =  math.ceil((math.sqrt(1+8*X) - 1)/2)
ans = n
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
X = int(input())
time = X
for i in range(X+1):
    if i > time: continue
    n = - 1 + math.sqrt(1+8*(X-i))
    if n < 2*i and n%2 == 0:
        time = min(time, i)
print(time)

Fixed submission:
import math
X = int(input())
n =  math.ceil((math.sqrt(1+8*X) - 1)/2)
ans = n
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
X = int(input())
time = X
for i in range(X+1):
    j = X - i
    if j > time: continue
    n = - 1 + math.sqrt(1+8*(X-j))
    if n < 2*j and math.floor(n) == n:
        time = min(time, j)
print(time)

Fixed submission:
import math
X = int(input())
n =  math.ceil((math.sqrt(1+8*X) - 1)/2)
ans = n
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
X = int(input())
time = X
for i in range(X+1):
    if i > time: continue
    n = - 1 + math.sqrt(1+8*(X-i))
    if n < 2*i and math.floor(n) == n:
        time = min(time, i)
print(time)

Fixed submission:
import math
X = int(input())
n =  math.ceil((math.sqrt(1+8*X) - 1)/2)
ans = n
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
time = X
for i in range(X+1):
    if i > time: continue
    for j in range(i+1):
        dist = i + sum(range(j))
        if dist == X:  
            time = i
print(time)

Fixed submission:
import math
X = int(input())
n =  math.ceil((math.sqrt(1+8*X) - 1)/2)
ans = n
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
mod = int(10e9+7)
f = lambda n:1 if n==1 else n * f(n-1) % mod
print(f(N))

Fixed submission:
N = int(input())
power = 1
for i in range(N):
    power *= i + 1
    power %= 1000000007
print(power)
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = input()

init = ["SS", "SW","WS","WW"]
next_animal = { ("S","o","S"):"S",
                ("S","o","W"):"W",
                ("S","x","S"):"W",
                ("S","x","W"):"S",
                ("W","o","S"):"W",
                ("W","o","W"):"S",
                ("W","x","S"):"S",
                ("W","x","W"):"W "}
for X in init:
    SW = X
    for i in range(1,N):
        SW += next_animal[SW[i],s[i],SW[i-1]]
    if SW[0] == SW[len(SW)-1]:
        print(SW[:len(SW)-1])
        break
else:
    print(-1) 


Fixed submission:
N = int(input())
s = input()

init = ["SS", "SW", "WS", "WW"]
next_animal = { ("S","o","S"):"S",
                ("S","o","W"):"W",
                ("S","x","S"):"W",
                ("S","x","W"):"S",
                ("W","o","S"):"W",
                ("W","o","W"):"S",
                ("W","x","S"):"S",
                ("W","x","W"):"W"}
for X in init:
    SW = X
    for i in range(1,N):
        SW += next_animal[SW[i],s[i],SW[i-1]]
    ls = len(SW)
    if SW[0] == SW[ls-1] and next_animal[SW[0],s[0],SW[ls-2]] == SW[1]:
        print(SW[:ls-1])
        break
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]
from collections import defaultdict as dd
Dict = dd(lambda:0)
for a in A:
    Dict[a] += 1
    
if N & 1: Dict[0] += 1
f = (lambda:(lambda x:0 if x&1 else 2) if N&1 else (lambda x:2 if x&1 else 0))()
Possible = {i:f(i) for i in range(N)}
for key,value in Dict.items:
    if value != Possible[key]:
        print(0)
        exit()
else:
    print(2**(N//2)%1000000007)
                



Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]

cnt = {}
if N & 1:
    bit = 1
else:
    bit = 0

for a in A:
    if a & bit:
        ans = 0
        break
    if a in cnt:
        cnt[a] += 1
    else:
        cnt[a] = 1

for key in cnt.keys():
    if key == 0 and cnt[key] != 1:
        ans = 0
        break
    if key != 0 and cnt[key] != 2:
        ans = 0
        break
else:
    ans = 2**(N//2) %1000000007
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
if s == "a" or s == "i" or s == "u" or s == "e" or s == "o":
    print(vowel)
else:
    print(consonant)

Fixed submission:
s = input()
if s == "a" or s == "i" or s == "u" or s == "e" or s == "o":
    print("vowel")
else:
    print("consonant")
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
C = []
for i in range(H):
    C[i] = input()
for i in range(H):
    print(C[i])
    print(C[i])

Fixed submission:
H, W = map(int, input().split())
C = []
for i in range(H):
    C.append(input())
for i in range(H):
    print(C[i])
    print(C[i])
Buggy python submission (verdict: Runtime Error):
s = input()
while 1:
    if len(S) == 0:
        print("YES")
        break
    if s[len(s)-5:] == "dream":
        s = s[:len(s)-5]
        continue
    elif s[len(s)-7:] == "dreamer":
        s = s[:len(s)-7]
        continue
    elif s[len(s)-5:] == "erase":
        s = s[:len(s)-5]
        continue
    elif s[len(s)-6:] == "eraser":
        s = s[:len(s)-6]
        continue
    else:
        print("NO")
        break
    

Fixed submission:
s = input()
while 1:
    if len(s) == 0:
        print("YES")
        break
    if s[len(s)-5:] == "dream":
        s = s[:len(s)-5]
        continue
    elif s[len(s)-7:] == "dreamer":
        s = s[:len(s)-7]
        continue
    elif s[len(s)-5:] == "erase":
        s = s[:len(s)-5]
        continue
    elif s[len(s)-6:] == "eraser":
        s = s[:len(s)-6]
        continue
    else:
        print("NO")
        break
Buggy python submission (verdict: Runtime Error):
import math
N, x = map(int, input().split())
L = [int(x) for x in input().split()]
ans = 0
for i in L[1:]:
    if L[i-1] + L[i] > x:
        if L[i-1] > x:
            ans += L[i-1] - x
            ans += L[i]
            L[i] = 0
        else:
            ans += L[i] + L[i-1] - x
            L[i] = x - L[i-1]
print(ans)


Fixed submission:
import math
N, x = map(int, input().split())
L = [int(x) for x in input().split()]
ans = 0
for i in range(1,N):
    if L[i-1] + L[i] > x:
        if L[i-1] > x:
            ans += L[i-1] - x
            ans += L[i]
            L[i] = 0
        else:
            ans += L[i] + L[i-1] - x
            L[i] = x - L[i-1]
print(ans)

Buggy python submission (verdict: Runtime Error):
N, A = map(int, input().split())
n = 0
def pick(list, num):
    4yu
for i in range(N):
    x = int(input().split())
    if x != A:
        L.append(int(input().split())-A)
    else:
        n += 1
L.sort()






Fixed submission:
import math
N, x = map(int, input().split())
L = [int(x) for x in input().split()]
ans = 0
for i in range(1,N):
    if L[i-1] + L[i] > x:
        if L[i-1] > x:
            ans += L[i-1] - x
            ans += L[i]
            L[i] = 0
        else:
            ans += L[i] + L[i-1] - x
            L[i] = x - L[i-1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
turn = 1
k = -1
while 1:
    for i in range(len(s)-2):
        if s[i] != s[i+2]:
            k = i
            if i < len(s) - 3:
                if s[i+1] == s[i+3]:
                    s = s[:i+1] + s[i+2:]
                    turn += 1
                    break
            if i > 0:
                if s[i+1] == s[i-1]:
                    s = s[:i+1] + s[i+2:]
                    turn += 1
                    break
    else:
        if k != -1:
            s = s[:k+1] + s[k+2:]
            turn += 1
            k = -1
        else:
            break
if turn%2 == 0:
    print("First")
else:
    print("Second")


        


Fixed submission:
s = input()
turn = len(s)
if s[0] == s[turn-1]:
    turn += 1
if turn & 1:
    print("First")
else:
    print("Second")
Buggy python submission (verdict: Runtime Error):
L = sorted(list(map(int, input().split())))
print('Yes' if sum(L[:2] == L[2]) else 'No')

Fixed submission:
L = [int(x) for x in input().split()]
L.sort()
if L[0] + L[1] == L[2]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
S = input()
X = S[0]
ans = 0
while 1:    
    for i in range(S):
        if S[i] != X:
            ans += 1
            X =S[i]
            S = S[i:]
            break
    else:
        break
print(ans)
    


Fixed submission:
S = input()
X = S[0]
ans = 0
while 1:    
    for i in range(len(S)):
        if S[i] != X:
            ans += 1
            X =S[i]
            S = S[i:]
            break
    else:
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
N = len(s)
D = {}
for i in range(N):
    if s[i] in D:
        D[s[i]] += 1
    else:
        D[s[i]] = 1
my_p = N//2
score = my_p - D["p"]
print(score)

Fixed submission:
s = input()
N = len(s)
D = {"g":0, "p":0}
for i in range(N):
    D[s[i]] += 1
my_p = N//2
score = my_p - D["p"]
print(score)

Buggy python submission (verdict: Runtime Error):
s = input()
N = len(s)
D = {}
for i in range(N):
    if s[i] in D:
        D[s[i]] += 1
    else:
        D[s[i]] = 1
my_g = (N+1)//2
my_p = N//2
score = my_p - D["p"]
print(score)

Fixed submission:
s = input()
N = len(s)
D = {"g":0, "p":0}
for i in range(N):
    D[s[i]] += 1
my_p = N//2
score = my_p - D["p"]
print(score)
Buggy python submission (verdict: Runtime Error):
H, W, N = map(int, input().split())
Grid = [[0]*(W-2) for _ in range(H-2)] #3*3正方形を左上のマスで区別。値は正方形内の黒塗りの個数
Ans = [(H-2)*(W-2) if i == 0 else 0 for i in range(10)] 
f = lambda x:int(x)-1
Draw = lambda x,y:[(x-i,y-j) for i in range(3) for j in range(3) if 0<=x-i<H-2 and 0<=y-j<W-2] #塗りつぶしたマスを含む正方形の座標のリストを返す関数
for _ in range(N):
    a, b = map(f, input().split())
    for x,y in Draw(a,b): #Ans及びGridの更新
        Ans[Grid[x][y]] += -1
        Ans[Grid[x][y]+1] += 1
        Grid[x][y] += 1
for ans in Ans:print(ans)

Fixed submission:
H, W, N = map(int, input().split())
from collections import defaultdict as dd
Grid =  dd(lambda:0) #3*3正方形を左上のマスで区別。値は正方形内の黒塗りの個数
Draw = lambda x,y:[(x-i,y-j) for i in range(3) for j in range(3) if 0<=x-i<H-2 and 0<=y-j<W-2] #塗りつぶしたマスを含む正方形の座標のリストを返す関数
for _ in range(N):
    a, b = map(int, input().split())
    for x,y in Draw(a-1,b-1): #Gridの更新
        Grid[x,y] += 1
Ans = [(H-2)*(W-2)-len(Grid) if i == 0 else sum(v==i for v in Grid.values()) for i in range(10)]         
for ans in Ans:
    print(ans)
Buggy python submission (verdict: Runtime Error):
n, s = int(input()), int(input())

f = lambda b,n:n if n < b else n%b + f(b,n//b)
import math
ans = n+2
for b in range(2,math.ceil(math.sqrt(n))): #O(√n)の全探索
    if f(b,n) == s:
        ans = b; break
else:
    for p in range(math.ceil(math.sqrt(n))): #n=pb+q (b>√n, p+q=s)に基づいたO(√n)の全探索
        q = s-p
        if p > 0: b = (n-q)/p
        else: b = n+1
        if b == int(b) and f(b,n) == s:
           ans = min(ans,int(b))
if ans == n+2: ans = -1
print(ans) 

Fixed submission:
n, s = int(input()), int(input())

f = lambda b,n:n if n < b else n%b + f(b,n//b)
import math
ans = math.inf
if n == s: ans = n+1
for b in range(2,math.ceil(math.sqrt(n))+1): #O(√n)の全探索
    if f(b,n) == s:
        ans = b; break
else:
    for p in range(1,math.ceil(math.sqrt(n))): #n=pb+q (b>√n, p+q=s)に基づいたO(√n)の全探索
        b = (n-s)/p+1
        if b > 1 and b == int(b) and f(b,n) == s:
           ans = min(ans,int(b))
if ans == math.inf: ans = -1
print(ans)
Buggy python submission (verdict: Runtime Error):
A = input()
B = input()
C = input()

L = [A, B, C]

for x in L:
    if len(x) == 7:
        L.remove(x)
        for y in L:
            if len(y) != 5:
                break
        else:
            print("YES")
            break
else:
    print("NO")


Fixed submission:
L = [int(x) for x in input().split()]
L.sort()

if L == [5,5,7]:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
A = input()
B = input()
C = input()

L = [A, B, C]

for x in L:
    if len(x) == 7:
        L.remove(x)
        for y in L:
            if len(y) != 5:
                break
        else:
            print("YES")
            break
else:
    print("NO")


Fixed submission:
L = [int(x) for x in input().split()]
L.sort()

if L == [5,5,7]:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = tuple(map(int,input().split()))

MOD = 10**9+7
count = 0
for i in range(N-1):
  count += ((sum(A[0:i+1])%MOD)*(A[i+1]%MOD))%MOD


print(count%MOD)


Fixed submission:
D,T,S = map(int,input().split())
if D/S <= T:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N,K = list(map(int,input().split()))
P = list(map(int,input().split()))
C = list(map(int,input().split()))
##################################################################
max_point = -10000000000000
for i in range(N):
  point = 0
  now = i
  for j in range(K):
    next_place = P[now]-1
    point += C[next_place]
    max_point = max(point,max_point)
    now = next_place

print(max_point)

Fixed submission:
n,k = map(int, input().split())
p = list(map(lambda z:int(z)-1, input().split()))
c = list(map(int, input().split()))

data = [[0 for i in range(n+1)] for j in range(n)]
loop = [10**10 for i in range(n)]
for i in range(n):
    j = i
    for t in range(1,n+1):
        j = p[j]
        data[i][t] += data[i][t-1] + c[j]
        if j == i:
            loop[i] = min(loop[i],t)

ans = -10**10
#print(data)
#print([data[i][loop[i]] for i in range(n)])

for i in range(n):
    for j in range(1,min(n,k)+1):
        if j > loop[i]:break
        if data[i][loop[i]] <= 0:
            ans = max(ans,data[i][j])
        else:
            ans = max(ans,data[i][loop[i]]*((k-j)//loop[i])+data[i][j])

print(ans)
Buggy python submission (verdict: Runtime Error):
K = int(input())
target = 7
for i in range(1,100000):
  if target %  K == 0:
    print(i)
    sys.exit()
  else:
    target *= 10
    target += 7
  
print("-1")

Fixed submission:
K = int(input())
 
if K%2 == 0 or K%5==0:
    print(-1)
    exit()
 
nw = 7%K
ans = 1
while nw != 0:
    nw = nw*10+7
    nw %= K
    ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
K = int(input())
target = 7
for i in range(1,100000):
  if target %  K == 0:
    print(i)
    sys.exit()
  else:
    target *= 10
    target += 7
  
print("-1")
    

Fixed submission:
K = int(input())
 
if K%2 == 0 or K%5==0:
    print(-1)
    exit()
 
nw = 7%K
ans = 1
while nw != 0:
    nw = nw*10+7
    nw %= K
    ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = list(map(int,input().split()))
LIST_A = list(map(int,input().split()))


import functools
import operator

for i in range(N-K):
  target_1 = LIST_A[i:i+K]
  target_2 = LIST_A[i+1:i+K+1]
  #print(target_1,target_2)
  result_1 = functools.reduce(operator.mul, target_1)
  result_2 = functools.reduce(operator.mul, target_2)
    
  if result_1 < result_2:
    print("Yes")
  else:
    print("No")

	



Fixed submission:
N,K = list(map(int,input().split()))
LIST_A = list(map(int,input().split()))

for i in range(N-K):
  target_1 = LIST_A[i+K]-LIST_A[i]  
  if target_1 > 0:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=input()
key_list = {}

LENGTH = len(S)
count = 0
for i in range(LENGTH):
  for j in range(i+1,LENGTH):
    for k in range(j+1,LENGTH):
      #print(i,j,k)
      target = str(S[i]+S[j]+S[k])
      #print(target)
      if target in key_list:
        #print("exist")
        pass
      else:
        key_list[target] = 0
        count += 1
print(count)

Fixed submission:
N=int(input())
S=input()


count = 0
for i in range(1000):
  if i < 100:
    target_1 = "0"
    if i < 10:
      target_2 = "0"
      target_3 = str(i)
    else:
      target_2 = str(i)[0]
      target_3 = str(i)[1]
  else:
    target_1 = str(i)[0]
    target_2 = str(i)[1]
    target_3 = str(i)[2]
  
  step = 1
  for j in range(N):
    if S[j] == target_1 and step == 1:
      step = 2
      pass
    
    elif S[j] == target_2 and step == 2:
      step = 3
      
    elif S[j] == target_3 and step == 3:
      count += 1
      break

print(count)