Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
L=list(map(int,input().split()))
L.sort(reverse = True)
ans = 0
for i in range(n):
    for j in range(i+1,n):
        cnt = 0
        start=j+1
        goal=n
        while goal!=start:
            half = (start + goal)//2
            if L[i] < L[j] + L[half]:
                start = half + 1
                cnt = max(half-j,cnt)
            else:
                goal = half
        ans += cnt
print(ans)

Fixed submission:
n=int(input())
L=list(map(int,input().split()))
L.sort(reverse = True)
ans = 0
for i in range(n):
    for j in range(i+1,n):
        cnt = 0
        start=j+1
        goal=n
        while goal!=start:
            half = (start + goal)//2
            if L[i] < L[j] + L[half]:
                start = half + 1
                cnt = max(half-j,cnt)
            else:
                goal = half
        ans += cnt
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int,input().split())
print(max(0,c - (a - b))

Fixed submission:
a, b, c = map(int,input().split())
print(max(0,c-a+b))
Buggy python submission (verdict: Runtime Error):
a, b = map(Int,input().split())
if (a + b) % 2 == 0:
  print((a + b)//2)
else:
  print('IMPOSSIBLE')

Fixed submission:
a, b = map(int,input().split())
if (a + b) % 2 == 0:
  print((a + b)//2)
else:
  print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
def f(n):
    cnt = 0
    while n != 0:
        n //= 2
        cnt += 1
    return cnt

n, k = map(int,input().split())

cnt = f(k)
ans = 0
num = n
for i in range(n):
    if k // (i+1) < 2**(cnt - 1):
        cnt -= 1
    ans += (1 / num)*(0.5 ** cnt)
print(ans)

Fixed submission:
import math

def f(n):
    cnt = 0
    while n != 0:
        n //= 2
        cnt += 1
    return max(cnt,1)

n, k = map(int,input().split())

cnt = f(k)
ans = 0
num = n
for i in range(n):
    while cnt != 0 and k / (i+1) <= 2**(cnt - 1):
        cnt -= 1
    ans += (1 / num)*math.pow(0.5,cnt)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
L = [input() for i in range(n)]
kekka = 0
for i in range(n):
  if 2*L[i] > sum(L):
    kekka = 1
    break
    
if kekka == 1:
  print('No')
else:
  print('Yes')

Fixed submission:
n = int(input())
L = list(map(int,input().split()))
kekka = 0
for i in range(n):
  if 2*L[i] >= sum(L):
    kekka = 1
    break
    
if kekka == 1:
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
H=list(map(int,input().split()))
dp=[0]*n
for i in range(1,n):
    S=[]
    for j in range(1,min(k+1,i+1)):
        S.append(dp[i-j]+abs(H[i]-H[i-j]))
    dp[i]=min(S)
print(dp[n-1])

Fixed submission:
n,k=map(int,input().split())
H=list(map(int,input().split()))
dp=[0]*n
for i in range(1,n):
    S=[]
    for j in range(1,min(k+1,i+1)):
        S.append(dp[i-j]+abs(H[i]-H[i-j]))
    dp[i]=min(S)
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
int A,B,C

if

Fixed submission:
L=list(map(int,input().split()))
L.sort()
if L==[5,5,7]:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
class TrieNode: 
    def __init__(self): 
    	self.children = [None]*26
    	self.isEndOfWord = False

class Trie: 
    def __init__(self): 
	    self.root = self.getNode() 

    def getNode(self):
        return TrieNode()

    def _charToIndex(self,ch): 
        return ord(ch)-ord('a') 

    def insert(self,key): 
	    pCrawl = self.root 
	    length = len(key) 
	    for level in range(length): 
		    index = self._charToIndex(key[level]) 
		    if not pCrawl.children[index]: 
			    pCrawl.children[index] = self.getNode() 
		    pCrawl = pCrawl.children[index] 
	    pCrawl.isEndOfWord = True
    
    def search(self, key):
        pCrawl = self.root
        length = len(key)
        for level in range(length):
            index = self._charToIndex(key[level])
            if not pCrawl.children[index]:
                return False
            pCrawl = pCrawl.children[index]
        return pCrawl != None and pCrawl.isEndOfWord

t = Trie()
count = 0
n = int(input())
for i in range(n):
    s = input()
    if not t.search(s):
        count += 1
        t.insert(s)
print(count)

Fixed submission:
n = int(input())
str_list = []
count = 1
for _ in range(n):
    s = input()
    str_list.append(s)
str_list.sort()
for i in range(n-1):
    if str_list[i] != str_list[i+1]:
        count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = {}
count = 0
for _ in range(n):
    res = 5381
    s = input()
    for i in s:
        res = ((res << 5) + res)
    if res not in a:
        a[res] = []
        a[res].append(s)
        count += 1
    else:
        if s not in a[res]:
            a[res].append(s)
            count += 1
print(count)

Fixed submission:
n = int(input())
str_list = []
count = 1
for _ in range(n):
    s = input()
    str_list.append(s)
str_list.sort()
for i in range(n-1):
    if str_list[i] != str_list[i+1]:
        count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = {}
count = 0
for _ in range(n):
    res = 0
    s = input()
    for i in s:
        res += (ord(i)-ord('a'))
    if res not in a:
        a[res] = []
        a[res].append(s)
        count += 1
    else:
        if s not in a[res]:
            a[res].append(s)
            count += 1
print(count)	

Fixed submission:
n = int(input())
str_list = []
count = 1
for _ in range(n):
    s = input()
    str_list.append(s)
str_list.sort()
for i in range(n-1):
    if str_list[i] != str_list[i+1]:
        count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
count = 0
for _ in range(n):
    s = input()
    if s not in a:
        a.append(s)
        count += 1
print(count)

Fixed submission:
n = int(input())
str_list = []
count = 1
for _ in range(n):
    s = input()
    str_list.append(s)
str_list.sort()
for i in range(n-1):
    if str_list[i] != str_list[i+1]:
        count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
s=input()
if(s=="Rainy"):
print("Sunny")
elif(s=="Sunny"):
print("Cloudy")
else:
print("Rainy")

Fixed submission:
s=input()
if(s=="Rainy"):
    print("Sunny")
elif(s=="Sunny"):
    print("Cloudy")
else:
    print("Rainy")
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import math


def lcm(a,b):
  return int(a * b / math.gcd(a, b))

A, B= [int(x) for x in stdin.readline().rstrip().split()]



print(lcm(A,B))

Fixed submission:
from sys import stdin
import math

def gcd(a,b):
  if (b == 0):
    return a

  return gcd(b, a % b)


def lcm(a,b):
  return int(a * b / gcd(a, b))

A, B= [int(x) for x in stdin.readline().rstrip().split()]



print(lcm(A,B))
Buggy python submission (verdict: Runtime Error):
_input = input
#'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

#ここに書きたいコードを書く
#データ読み込み

N=int(input())
S=input()

RGB_num=[0]*3

for c in S:
	if c=='R':
		RGB_num[0] += 1
	elif c=='G':
		RGB_num[1] += 1
	else:
		RGB_num[2] += 1

#print(RGB_num)
joken2=0

print(S[0])
for i in range(N-2):
	#print("i",i,S[i+1])
	for j in range(min(i+1,N-i-2)):
		if S[i+1] != S[i-j] and S[i+1] != S[i+j+2] and S[i-j] != S[i+j+2]:
			joken2 += 1
			#print(i,j,S[i-j]+S[i+1]+S[i+j+2],"j2")
		#else:
			#print(i,j,S[i-j]+S[i+1]+S[i+j+2])

joken1=RGB_num[0]*RGB_num[1]*RGB_num[2]

print(joken1-joken2)

input = _input


Fixed submission:
_input = input
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''

#ここに書きたいコードを書く
#データ読み込み

N=int(input())
S=input()

RGB_num=[0]*3

for c in S:
	if c=='R':
		RGB_num[0] += 1
	elif c=='G':
		RGB_num[1] += 1
	else:
		RGB_num[2] += 1

#print(RGB_num)
joken2=0

for i in range(N-2):
	#print("i",i,S[i+1])
	for j in range(min(i+1,N-i-2)):
		if S[i+1] != S[i-j] and S[i+1] != S[i+j+2] and S[i-j] != S[i+j+2]:
			joken2 += 1
			#print(i,j,S[i-j]+S[i+1]+S[i+j+2],"j2")
		#else:
			#print(i,j,S[i-j]+S[i+1]+S[i+j+2])

joken1=RGB_num[0]*RGB_num[1]*RGB_num[2]

print(joken1-joken2)

input = _input
Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
ans = 0
for i in range(1,n):
   for j in range(int(math.sqrt(i))):
      if i%(j+1)==0:
        ans+=2
print(ans-int(math.sqrt(n-1)))

Fixed submission:
import math
n = int(input())
ans = 0
for i in range(1,n):
   ans += (n-1)//i
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = str(input())
d = s.split()
mod = 10 ** 18
ans = int(d[0])
d.pop(0)
z = 0
if '0' in d:
	print(0)
else:
	for i in d:
		i = int(i)
		ans *= i
		if ans > mod:
			print(-1)
			z = 1
	if z == 1:
		pass
	else:
		print(ans)

Fixed submission:
s = str(input())
d = s.split()
a = int(d[0])
b = int(d[1])
c = a * b 
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
d = s.split()
mod = 10 ** 18
ans = int(d[0])
d.pop(0)
if '0' in d:
	print(0)
else:
	for i in d:
		i = int(i)
		ans = ans * i 
	if ans > mod:
		print(-1)
	else:
		print(ans)


Fixed submission:
n = int(input())
s = str(input())
d = s.split()
mod = 10 ** 18
ans = int(d[0])
d.pop(0)
z = 0
if '0' in d:
	print(0)
else:
	for i in d:
		i = int(i)
		ans *= i
		if ans > mod:
			print(-1)
			z = 1
			break
	if z == 1:
		pass
	else:
		print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a, b, c = map(int, input().split())
a_sqrt = math.sqrt(a)
b_sqrt = math.sqrt(b)
c_sqrt = math.sqrt(c)

if (a==c) or (b==c):
	print('No')

elif (a_sqrt+b_sqrt) < c_sqrt:
	print('Yes')

else:
	print('No') 

Fixed submission:
list_32 = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
K -= 1
print(list_32[K])

Buggy python submission (verdict: Runtime Error):
import math
a, b, c = map(int, input().split())
a_sqrt = math.sqrt(a)
b_sqrt = math.sqrt(b)
c_sqrt = math.sqrt(c)

if (a+b) > c:
	print('No')

if (a_sqrt+b_sqrt) < c_sqrt:
	print('Yes')
else:
	print('No') 

Fixed submission:
list_32 = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
K -= 1
print(list_32[K])

Buggy python submission (verdict: Runtime Error):
import math
a, b, c = map(int, input().split())
a_sqrt = math.sqrt(a)
b_sqrt = math.sqrt(b)
c_sqrt = math.sqrt(c)

a_sqrt = round(a_sqrt,-13)
b_sqrt = round(b_sqrt,-13)
c_sqrt = round(c_sqrt,-13)

if (a_sqrt+b_sqrt) < c_sqrt:
	print('Yes')
else:
	print('No')

Fixed submission:
list_32 = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
K -= 1
print(list_32[K])
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
A = list(map(int, input().split()))

loc = 1
loclog=[1]
flag = 0

for i in range(K):
    loc = A[loc-1]
    if loc in loclog:
        roopstart = loclog.index(loc)
        roopend = len(loclog)
        flag = 1
        break
    loclog.append(loc)

if flag == 0:
    ans = loc
else:
    roopidx = (K+1-roopstart)%(roopend-roopstart)
    if roopidx == 0:
        ans = loclog[roopend-1]
    else:
        ans = loclog[roopstart+roopidx-1]
print(ans)

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

loc = 1
loclog=[1]
flag = 0
hist = [0]*N

for i in range(K):
    hist[loc-1] = 1
    loc = A[loc-1]
    if hist[loc-1] != 0:
        roopstart = loclog.index(loc)
        roopend = len(loclog)
        flag = 1
        break
    loclog.append(loc)

if flag == 0:
    ans = loc
else:
    roopidx = (K+1-roopstart)%(roopend-roopstart)
    if roopidx == 0:
        ans = loclog[roopend-1]
    else:
        ans = loclog[roopstart+roopidx-1]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
A = list(map(int, input().split()))

loc = 1
loclog=[1]
flag = 0

for i in range(1,K+1):
    loc = A[loc-1]
    if loc in loclog:
        roopstart = loclog.index(loc)
        roopend = len(loclog)
        flag = 1
        break
    loclog.append(loc)

if flag == 0:
    ans = loc
else:
    roopidx = (K+1-roopstart)%(roopend-roopstart)
    if roopidx == 0:
        ans = loclog[roopend-1]
    else:
        ans = loclog[roopstart+roopidx-1]
print(ans)

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

loc = 1
loclog=[1]
flag = 0
hist = [0]*N

for i in range(K):
    hist[loc-1] = 1
    loc = A[loc-1]
    if hist[loc-1] != 0:
        roopstart = loclog.index(loc)
        roopend = len(loclog)
        flag = 1
        break
    loclog.append(loc)

if flag == 0:
    ans = loc
else:
    roopidx = (K+1-roopstart)%(roopend-roopstart)
    if roopidx == 0:
        ans = loclog[roopend-1]
    else:
        ans = loclog[roopstart+roopidx-1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
from itertools import product

def gcd_(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())

ans = 3*K*(K-1) + 1

for i,j,k in product(range(2,K+1),range(2,K+1),range(2,K+1)):
    ans += gcd_(i,j,k)

print(ans)

Fixed submission:
import math
from functools import reduce
from itertools import product,combinations_with_replacement

def gcd_(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())

ans = 3*K*(K-1) + 1

# for i,j,k in product(range(2,K+1),repeat=3):
#     ans += gcd_(i,j,k)
for i,j,k in combinations_with_replacement(range(2,K+1),3):
    if i==j and j==k:
        ans += i
    elif i==j or j==k or k==i:
        ans += gcd_(i,j,k) * 3
    else:
        ans += gcd_(i,j,k)*6
# for i in range(2,K+1):
#     for j in range(2,K+1):
#         for k in range(2,K+1):
#             ans += gcd_(i,j,k)

print(ans)
Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
A = list(map(int, input().split()))

th = sum(A)*0.25/M

A.sort(reverse=True)

if A[M] >= th:
    print('Yes')
else:
    print('No')

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

th = sum(A)*0.25/M

A.sort(reverse=True)

if A[M-1] >= th:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import collections

N = int(input())

A = list(map(int, input().split()))

c = collections.Counter(A)
# print(c)
dic = {}
for k,v in c.items():
    dic[k] = int(v*(v-1)/2)
# print(dic)

for k in range(N):
    Ak = A[k]
    ans = dic.copy()
    ans[Ak] = int((c[Ak]-1)*(c[Ak]-2)/2)
    # print(dic,ans)
    print(sum(ans.values()))

Fixed submission:
import collections

N = int(input())

A = list(map(int, input().split()))

c = collections.Counter(A)
# print(c)
# dic = {}
ans = 0
# for k,v in c.items():
#     dic[k] = int(v*(v-1)/2)
# print(dic)
for v in c.values():
    ans += int(v*(v-1)/2)

for k in range(N):
    Ak = A[k]
    cAk = c[Ak]
    ansk = ans - cAk + 1
    # ans[Ak] = int((cAk-1)*(cAk-2)/2)
    # print(dic,ans)
    print(ansk)
Buggy python submission (verdict: Runtime Error):
import numpy as np

A = []
for i in range(3):
    A.append(list(map(int, input().split())))
A = np.array(A)

N = int(input())
b = np.zeros(N, dtype=np.int)
for i in range(N):
    b[i] = int(input())
# print(A)
# print(b)
# T = A[A in b]
T = np.isin(A,b)
# print(T)
ans=[0,0,0,0]
ans[0]=T.all(axis=0).all()
ans[1]=T.all(axis=1).all()
ans[2]=np.diag(T).all()
ans[3]=np.diag(T[:,[2,1,0]]).all()
# print(ans)
if any(ans):
    print('Yes')
else:
    print('No')

Fixed submission:
import numpy as np

def in1d(ar1, ar2, assume_unique=False, invert=False):
    # Ravel both arrays, behavior for the first array could be different
    ar1 = np.asarray(ar1).ravel()
    ar2 = np.asarray(ar2).ravel()

    # Check if one of the arrays may contain arbitrary objects
    contains_object = ar1.dtype.hasobject or ar2.dtype.hasobject

    # This code is run when
    # a) the first condition is true, making the code significantly faster
    # b) the second condition is true (i.e. `ar1` or `ar2` may contain
    #    arbitrary objects), since then sorting is not guaranteed to work
    if len(ar2) < 10 * len(ar1) ** 0.145 or contains_object:
        if invert:
            mask = np.ones(len(ar1), dtype=bool)
            for a in ar2:
                mask &= (ar1 != a)
        else:
            mask = np.zeros(len(ar1), dtype=bool)
            for a in ar2:
                mask |= (ar1 == a)
        return mask

    # Otherwise use sorting
    if not assume_unique:
        ar1, rev_idx = np.unique(ar1, return_inverse=True)
        ar2 = np.unique(ar2)

    ar = np.concatenate((ar1, ar2))
    # We need this to be a stable sort, so always use 'mergesort'
    # here. The values from the first array should always come before
    # the values from the second array.
    order = ar.argsort(kind='mergesort')
    sar = ar[order]
    if invert:
        bool_ar = (sar[1:] != sar[:-1])
    else:
        bool_ar = (sar[1:] == sar[:-1])
    flag = np.concatenate((bool_ar, [invert]))
    ret = np.empty(ar.shape, dtype=bool)
    ret[order] = flag

    if assume_unique:
        return ret[:len(ar1)]
    else:
        return ret[rev_idx]

def isin(element, test_elements, assume_unique=False, invert=False):
    element = np.asarray(element)
    return in1d(element, test_elements, assume_unique=assume_unique,
                invert=invert).reshape(element.shape)
A = []
for i in range(3):
    A.append(list(map(int, input().split())))
A = np.array(A)

N = int(input())
b = np.zeros(N, dtype=np.int)
for i in range(N):
    b[i] = int(input())
T = isin(A,b)
ans=[0,0,0,0]
ans[0]=T.all(axis=0).any()
ans[1]=T.all(axis=1).any()
ans[2]=np.diag(T).all()
ans[3]=np.diag(T[:,[2,1,0]]).all()
if any(ans):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N=input()
ans=int(round(N/2.0)-1)
print(ans)

Fixed submission:
import math
N=int(input())
ans=int(math.ceil(N/2.0)-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
from collections import Counter
N=int(input())
D=input().split()
T=[]
D_dict=Counter(D)
D_keys=list(D_dict.keys())
D_keyi=[int(n) for n in D_keys]
maxD=max(D_keyi)
D_keyi.sort()
ans=1
if D[0] != '0' or D_dict['0']!=1 or D_keyi != list(range(maxD+1)):
    print(0)
else:
    for i in range(maxD+1):
        T.append(D_dict[str(i)])
    for i in range(len(T)-1):
        ans=ans*(T[i]**T[i+1])
    print(mod(ans,998244353))


Fixed submission:
import math
from collections import Counter
N=int(input())
D=input().split()
T=[]
D_dict=Counter(D)
D_keys=list(D_dict.keys())
D_keyi=[int(n) for n in D_keys]
maxD=max(D_keyi)
D_keyi.sort()
ans=1
if D[0] != '0' or D_dict['0']!=1 or D_keyi != list(range(maxD+1)):
    print(0)
else:
    for i in range(maxD+1):
        T.append(D_dict[str(i)])
    for i in range(len(T)-1):
        ans=ans*(T[i]**T[i+1])
    print((ans%998244353))
Buggy python submission (verdict: Runtime Error):
li = list(map(int,input().split()))
ans=li[2]-(li[0]-li[1])
if ans>=0:
  print(ans)
elif:
  print("0")

Fixed submission:
li = list(map(int,input().split()))
ans=li[2]-(li[0]-li[1])
if ans>=0:
    print(ans)
else:
    print("0")
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

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

comb = list(combinations(range(N), 2))
sum = 0
mod = 10**9 + 7
for i in range(len(comb)):
        sum += A[comb[i][0]] * A[comb[i][1]] % mod
print(sum % mod)
        

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

c_sum = sum(A)
mod = 10**9 + 7
ans = 0

for i in range(N-1):
    c_sum -= A[i]
    ans += A[i] * c_sum % mod
ans %= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

sum = 0
mod = 10**9 + 7
for i in range(N-1):
    for j in range(i+1, N):
        sum += A[i] * A[j] % mod
print(sum % mod)
        

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

c_sum = sum(A)
mod = 10**9 + 7
ans = 0

for i in range(N-1):
    c_sum -= A[i]
    ans += A[i] * c_sum % mod
ans %= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

sum = 0
mod = 10**9 + 7
for i in range(N-1):
    for j in range(i+1, N):
        sum += A[i] * A[j] % mod
print(sum % mod)
        

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

c_sum = sum(A)
mod = 10**9 + 7
ans = 0

for i in range(N-1):
    c_sum -= A[i]
    ans += A[i] * c_sum % mod
ans %= mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = len(str(N))
sum = 0

while True:
    a = N // 10**(l-1)
    N -= 10 ** (l-1) * a
    sum += a
    l -= 1
    if l < 0:
        break
if sum % 9 == 0:
    print("Yes")
else:
    print("No")

Fixed submission:
N = str(input())
N = list(N)
N = [int(i) for i in N]

if sum(N) % 9 == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = -float("inf")
for start in range(N):
    x = start
    cyc_score = []
    total_cyc_score = 0
    while True:
        x = P[x]-1
        cyc_score.append(C[x])
        total_cyc_score += C[x]
        if x == start: # 周期を検出
            break
    t = 0
    for i in range(len(cyc_score)):
        t += cyc_score[i]
        if i + 1 > K: break
        now_score = t
        if total_cyc_score > 0:
            e = int((K - i - 1) / len(cyc_score))
            now_score += total_cyc_score * e
        ans = max(ans, now_score)
print(ans)

Fixed submission:
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = -float("inf")
for start in range(N):
    x = start
    cyc_score = []
    total_cyc_score = 0
    while True:
        x = P[x]-1
        cyc_score.append(C[x])
        total_cyc_score += C[x]
        if x == start: # 周期を検出
            break
    t = 0
    for i in range(len(cyc_score)):
        t += cyc_score[i]
        if i + 1 > K: break
        now_score = t
        if total_cyc_score > 0:
            e = int((K - i - 1) / len(cyc_score))
            now_score += total_cyc_score * e
        ans = max(ans, now_score)
print(ans)
Buggy python submission (verdict: Runtime Error):
N, D = map(int, input().split())
X, Y = [map(int, input().split()) for i in range(N)]

cnt = 0
for i in range(N):
    if X[i]**2 + Y[i]**2 < D**2:
        cnt += 1
print(cnt)

Fixed submission:
N, D = map(int, input().split())

cnt = 0
for i in range(N):
    X, Y = map(int, input().split())
    if X**2 + Y**2 <= D**2:
        cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N, M, X = list(map(int, input().split()))
CA = [list(map(int, input().split())) for i in range(N)]

set_list = []
for i in range(2 ** N):
    select = []
    for j in range(N):
        if ((i >> j) & 1):
            select.append(j)
    if len(select) != 0:
        set_list.append(select)
    
cost = []
for i in range(2 ** N - 1):
    cost.append(sum([CA[set_list[i][j]][0] for j in range(len(set_list[i]))]))

skill = []
for i in range(2 ** N - 1):
    tmp = [0]*M
    for j in set_list[i]:
        for k in range(M):
            tmp[k] += CA[j][k+1]
    skill.append(tmp)

pool = []
for i in range(2**N - 1):
    flag = 0
    for j in skill[i]:
        if j < X:
            flag = 1
    if flag == 0:
        pool.append(cost[i])
        

print(min(pool))


Fixed submission:
N, M, X = list(map(int, input().split()))
CA = [list(map(int, input().split())) for i in range(N)]

set_list = []
for i in range(2 ** N):
    select = []
    for j in range(N):
        if ((i >> j) & 1):
            select.append(j)
    if len(select) != 0:
        set_list.append(select)
    
cost = []
for i in range(2 ** N - 1):
    cost.append(sum([CA[set_list[i][j]][0] for j in range(len(set_list[i]))]))

skill = []
for i in range(2 ** N - 1):
    tmp = [0]*M
    for j in set_list[i]:
        for k in range(M):
            tmp[k] += CA[j][k+1]
    skill.append(tmp)

pool = []
for i in range(2**N - 1):
    flag = 0
    for j in skill[i]:
        if j < X:
            flag = 1
    if flag == 0:
        pool.append(cost[i])
        

if len(pool) == 0:
	print(-1)
else:
    print(min(pool))