Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
from bisect import bisect_left

n,m,k=map(int,input().split())
a=accumulate([0]+list(map(int,input().split())))
b=accumulate([0]+list(map(int,input().split())))
mx=0
for i in range(n+1):
  idx=bisect_left(max(k-a[i],0),b)
  mx=max(mx,i+idx)
print(mx)
  
  


Fixed submission:
from itertools import accumulate
from bisect import bisect_left
 
n,m,k=map(int,input().split())
a=list(accumulate([0]+list(map(int,input().split()))))
b=list(accumulate([0]+list(map(int,input().split()))))
#print(b)
mx=0
for i in range(n+1):
  if a[i]>k:continue
  #print('a[i];'+str(a[i]))
  idx=min(bisect_left(b,k-a[i]),m)
  #print(idx)
  if b[idx]>k-a[i]:idx-=1
  if a[i]+b[idx]>k:continue
  mx=max(mx,i+idx)
print(mx)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
from bisect import bisect_left
n=int(input())
a=sorted(list(map(int,input().split())))

sus=deque([sum(a)])
q=int(input())
for i in range(q):
  count=0
  b,c=map(int,input().split())
  idx=bisect_left(a,b)
  while True:
    if idx>=n:break
    if a[idx]==b:
      a[idx]=c
      count+=1
      idx+=1
    else:
      break
  a=sorted(a)
  sus.append(sus[-1]+(c-b)*count)
  print(sus[-1])

Fixed submission:
n=int(input())
a=[0]*(10**5)
A=list(map(int,input().split()))
su=0
for i in range(n):
  su+=A[i]
  a[A[i]-1]+=1
q=int(input())
sus=[su]
for i in range(q):
  
  b,c=map(lambda x:int(x)-1,input().split())
  sus.append(sus[-1]+(c-b)*a[b])
  a[c]+=a[b]
  a[b]-=a[b]
  print(sus[-1])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n=int(input())
a=list(map(int,input().split()))

sus=deque([sum(a)])
q=int(input())
for i in range(q):
  count=0
  b,c=map(int,input().split())
  for j in range(n):
    if a[j]==b:
      a[j]=c
      count+=1
  sus.append(sus[-1]+(c-b)*count)
  print(sus[-1])
#print(sus)

Fixed submission:
n=int(input())
a=[0]*(10**5)
A=list(map(int,input().split()))
su=0
for i in range(n):
  su+=A[i]
  a[A[i]-1]+=1
q=int(input())
sus=[su]
for i in range(q):
  
  b,c=map(lambda x:int(x)-1,input().split())
  sus.append(sus[-1]+(c-b)*a[b])
  a[c]+=a[b]
  a[b]-=a[b]
  print(sus[-1])

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))


q=int(input())
for i in range(q):
  s=0
  b,c=map(int,input().split())
  for j in a:
    if a[j]==b:
      a[j]=c
      s+=a[j]
    else:s+=a[j]
  print(s)
  

Fixed submission:
n=int(input())
a=[0]*(10**5)
A=list(map(int,input().split()))
su=0
for i in range(n):
  su+=A[i]
  a[A[i]-1]+=1
q=int(input())
sus=[su]
for i in range(q):
  
  b,c=map(lambda x:int(x)-1,input().split())
  sus.append(sus[-1]+(c-b)*a[b])
  a[c]+=a[b]
  a[b]-=a[b]
  print(sus[-1])
Buggy python submission (verdict: Runtime Error):
x,n=map(int,,input().split())
a=sorted(list(map(int,input().split())))
if n==0:
  print(x)
  exit()
else:
  for i in range(100):
    aa=x-i
    if aa not in a:
      print(aa)
      exit()
    bb=x+i
    if bb not in a:
      print(bb)
      exit()
    
    

Fixed submission:
x,n=map(int,input().split())
a=sorted(list(map(int,input().split())))
if n==0:
  print(x)
  exit()
else:
  for i in range(100):
    aa=x-i
    if aa not in a:
      print(aa)
      exit()
    bb=x+i
    if bb not in a:
      print(bb)
      exit()
Buggy python submission (verdict: Runtime Error):
from bisect import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
y=set(a)
acc=0
if a[0]==1 and a[1]!=1:acc+=1
dp=[True]*(a[-1]+1)
for i in range(2,a[-1]+1):
  if i in y:
    if dp[i]==True:
      idx=bisect(a,i)
      if a[idx-1]==a[idx-2]:
        dp[i]=False
      else:acc+=1
    dp[2*i::i]=[False]*len(dp[2*i::i])
print(acc)

Fixed submission:
from bisect import bisect
from collections import Counter
n=int(input())
b=sorted(list(map(int,input().split())))
a=Counter(b)
mA=b[-1]
acc=0
dp=[True]*(mA+1)
for i,v in a.items():
  if dp[i]==True and v==1:
    acc+=1
  else:dp[i]=False
  for k in range(mA//i+1):
    dp[k*i]=False
print(acc)
Buggy python submission (verdict: Runtime Error):
n=int(input())
alis=sorted(list(map(int,input().split())))
p=alis[0]
if p==0:
  print(0)
  exit()
for i in range(1,n):
  p*=alis[i]
  if len(list(str(p)))>18:
  sa=list(map(int,list(str(p))))
    
  if sum(sa)!=1:
    print(-1)
    exit()
print(p)

Fixed submission:
n=int(input())
alis=sorted(list(map(int,input().split())))
p=alis[0]
if p==0:
  print(0)
  exit()
bre=False
for i in range(1,n):
  p*=alis[i]
  
  
  if len(list(str(p)))>18:
    bre=True
    break


if bre:
  sa=list(map(int,list(str(p))))
  if sum(sa)!=1:print(-1)
  else:print(p)
else:print(p)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
alis=sorted(list(map(int,input().split())))
p=alis[0]
if p==0:
  print(0)
  exit()
for i in range(1,n):
  p*=alis[i]
  
if len(list(str(p)))>18:
  sa=list(map(int,list(str(p))))
    
  if sum(sa)!=1:
    print(-1)
    exit()
print(p)

Fixed submission:
n=int(input())
alis=sorted(list(map(int,input().split())))
p=alis[0]
if p==0:
  print(0)
  exit()
bre=False
for i in range(1,n):
  p*=alis[i]
  
  
  if len(list(str(p)))>18:
    bre=True
    break


if bre:
  sa=list(map(int,list(str(p))))
  if sum(sa)!=1:print(-1)
  else:print(p)
else:print(p)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
alis=list(map(int,input().split()))
p=alis[0]

for i in range(1,n):
  p*=alis[i]
  
if len(list(str(p)))>18:
  sa=list(map(int,list(str(p))))
    
  if sum(sa)!=1:
    print(-1)
    exit()
print(p)

Fixed submission:
n=int(input())
alis=sorted(list(map(int,input().split())))
p=alis[0]
if p==0:
  print(0)
  exit()
bre=False
for i in range(1,n):
  p*=alis[i]
  
  
  if len(list(str(p)))>18:
    bre=True
    break


if bre:
  sa=list(map(int,list(str(p))))
  if sum(sa)!=1:print(-1)
  else:print(p)
else:print(p)
Buggy python submission (verdict: Runtime Error):
a,b=input().split()

a=list(a)
b=list(b)
a0=int(''.join(a))
a1=int(''.join(a[:-1]))
a2=int(''.join(a[:-2]))
b0=int(b[0])
b1=int(b[2])
b2=int(b[3])
ss=a0*b0+a1*b1+a2*b2
print(ss)

Fixed submission:
# fp = open('integer.txt')
A,B = input().split()
B = B.split('.')
B = B[0]+B[1]
B = int(B)
X = str(int(A)*B)
if len(X)<=2:
    print(0)
else:
    print(X[0:len(X)-2])
Buggy python submission (verdict: Runtime Error):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

t=int(input())
if t==1:
  print(0)
  exit()

fac=factorization(t)

def pcount(a):
  p=1
  cout=0
  while a>0:
    a=a-p
    p+=1
    if a<0:break
    cout+=1
  return cout

tt=0
for po in range(len(fac)):
  cc=pconut(po[i][1])
  tt+=cc

print(cc)

Fixed submission:
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
 
    if temp!=1:
        arr.append([temp, 1])
 
    if arr==[]:
        arr.append([n, 1])
 
    return arr
 
t=int(input())
if t==1:
  print(0)
  exit()
 
fac=factorization(t)
 
def pcount(a):
  p=1
  cout=0
  while a>0:
    a=a-p
    p+=1
    if a<0:break
    cout+=1
  return cout
#print(fac)
tt=0
 
for po in fac:
  
  cc=pcount(po[1])
  #print(cc)
  tt+=cc

print(tt)
Buggy python submission (verdict: Runtime Error):
n=int(input())
alis=[]
blis=[]
for i in range(n):
  a,b=map(int,input().split())
  alis.ppend(a)
  blis.append(b)
  
  
alis=sorted(alis)
blis=sorted(blis)
if n%2!=0:
  print(blis[int((n-1)/2)]-alis[int((n-1)/2)]+1)
else:
  bb=(blis[int(n/2)-1]+blis[int(n/2)])
  aa=(alis[int(n/2)-1]+alis[int(n/2)])
  print(bb-aa+1)

Fixed submission:
n=int(input())
alis=[]
blis=[]
for i in range(n):
  a,b=map(int,input().split())
  alis.append(a)
  blis.append(b)
  
  
alis=sorted(alis)
blis=sorted(blis)
if n%2!=0:
  print(blis[int((n-1)/2)]-alis[int((n-1)/2)]+1)
else:
  bb=(blis[int(n/2)-1]+blis[int(n/2)])
  aa=(alis[int(n/2)-1]+alis[int(n/2)])
  print(bb-aa+1)

Buggy python submission (verdict: Runtime Error):
n=int(input())
alis=[]
blis=[]
for i in range(n):
  a,b=map(int,input().split())
  alis.ppend(a)
  blis.append(b)
  
  
alis=sorted(alis)
blis=sorted(blis)
if n%2!=0:
  print(blis[int((n-1)/2)]-alis[int((n-1)/2)+1]
else:
  bb=(blis[int(n/2)-1]+blis[int(n/2)])
  aa=(alis[int(n/2)-1]+alis[int(n/2)])
  print(bb-aa+1)

Fixed submission:
n=int(input())
alis=[]
blis=[]
for i in range(n):
  a,b=map(int,input().split())
  alis.append(a)
  blis.append(b)
  
  
alis=sorted(alis)
blis=sorted(blis)
if n%2!=0:
  print(blis[int((n-1)/2)]-alis[int((n-1)/2)]+1)
else:
  bb=(blis[int(n/2)-1]+blis[int(n/2)])
  aa=(alis[int(n/2)-1]+alis[int(n/2)])
  print(bb-aa+1)
Buggy python submission (verdict: Runtime Error):
N=input()
w=int(n[-1])
h=[2,4,5,7,9]
p=[0,1,6,8]
b=3
if w==b:
  print('bon')
elif w in p:
  print('pon')
else:
  print('hon')

Fixed submission:
N=input()
w=int(N[-1])
h=[2,4,5,7,9]
p=[0,1,6,8]
b=3
if w==b:
  print('bon')
elif w in p:
  print('pon')
else:
  print('hon')
Buggy python submission (verdict: Runtime Error):
k=int(input())
s=input()
n=len(s)
if s<=k:
  print(s)
else:
  print(s[:k]+'...')

Fixed submission:
k=int(input())
s=input()
n=len(s)
if n<=k:
  print(s)
else:
  print(s[:k]+'...')
Buggy python submission (verdict: Runtime Error):
S=list(input())
T=list(input())
flag = True
for i in range(N):
    s = S[i]
    t = T[i]
    if s != t:
        flag = False
        
if flag:
    if len(T) == N+1:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Fixed submission:
s = input()
t = input()
if s == t[:-1]:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
S=input()
T=input()
flag = True
for i in range(N):
    s = S[i]
    t = T[i]
    if s != t:
        flag = False
        
if flag:
    if len(T) == N+1:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Fixed submission:
s = input()
t = input()
if s == t[:-1]:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
flag = True
for i in range(N):
    s = S[i]
    t = T[i]
    if s != t:
        flag = False
        
if flag:
    if len(T) == N+1:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Fixed submission:
s = input()
t = input()
if s == t[:-1]:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
import numpy as np
S=np.array(list(input()))
T=np.array(list(input()))
if all(S==T[:-2]):
  print("Yes")
else:
  print('No')

Fixed submission:
s = input()
t = input()
if s == t[:-1]:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
a,b,c,k=map(int,input().split())
if a>=k:
  print(a)
  break
else:
  if a+b>=k:
    print(a)
    break
  else:
    print(a-(k-a-b))
    break

Fixed submission:
a,b,c,k=map(int,input().split())
if a>=k:
  print(k)
else:
  if a+b>=k:
    print(a)
  else:
    print(a-(k-a-b))
Buggy python submission (verdict: Runtime Error):
n,m,x=map(int,input().split())
clis=[]
alis=[]
for _ in range(n):
  tu=list(map(int,input().split()))
  clis.append(tu[0])
  alis.append(tu[1:])


ma_c=[]
for i in range(2**n):
  bag=[]
  price=0
  for j in range(n):
    if ((i>>j)&1):
      price+=clis[j]
      bag.append(alis[j])
  pac=[0]*m
  for t in range(len(bag)):
    for k in range(m):
        pac[k]+=bag[t][k]
  if all([pac[t]>=x for t in range(m)]):
    ma_c.append(price)

print(min(ma_c))

Fixed submission:
n,m,x=map(int,input().split())
clis=[]
alis=[]
for _ in range(n):
  tu=list(map(int,input().split()))
  clis.append(tu[0])
  alis.append(tu[1:])


ma_c=[]
for i in range(2**n):
  bag=[]
  price=0
  for j in range(n):
    if ((i>>j)&1):
      price+=clis[j]
      bag.append(alis[j])
  pac=[0]*m
  for t in range(len(bag)):
    for k in range(m):
        pac[k]+=bag[t][k]
  if all([pac[t]>=x for t in range(m)]):
    ma_c.append(price)


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

Buggy python submission (verdict: Runtime Error):
import pandas as pd
import numpy as np
n,m,x=map(int,input().split())
zen=np.array(list(map(int,input().split()) for _ in range(n)))
a=pd.Series(zen.sum(1))
df=pd.DataFrame(zen)
df=df.join(a)
df=df.sort_values(a)

p=df.iloc[-1]
df=df.drop(df.index[[-1]])
while all(p[1:]>=x):
  p+=df.iloc[-1]
print(p[0].sum())
  


Fixed submission:
n,m,x=map(int,input().split())
clis=[]
alis=[]
for _ in range(n):
  tu=list(map(int,input().split()))
  clis.append(tu[0])
  alis.append(tu[1:])


ma_c=[]
for i in range(2**n):
  bag=[]
  price=0
  for j in range(n):
    if ((i>>j)&1):
      price+=clis[j]
      bag.append(alis[j])
  pac=[0]*m
  for t in range(len(bag)):
    for k in range(m):
        pac[k]+=bag[t][k]
  if all([pac[t]>=x for t in range(m)]):
    ma_c.append(price)


if len(ma_c)!=0:
  print(min(ma_c))
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N,M =map(int,input().split())
h_lis=np.array(list(map(int,input().split())))
way_lis=[list(map(int,input().split())) for _ in range(M)]

tes=0
for i in range(N):
    nears=[]
    for way in way_lis:
        if i+1 in way:
            nears.extend(way)
    for j,ne in enumerate(nears):
        if j==0:
            h=max(h_lis[ne[0]-1],h_lis[ne[1]-1])
            z=h
        else:
            k=z
            h=max(h_lis[ne[0]-1],h_lis[ne[1]-1])
            z=max(k,h)
    if z==h_lis[i]:
        tes+=1
print(tes)

Fixed submission:
S=input()
if S=="ABC":
  print("ARC")
else:
  print("ABC")
Buggy python submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split())
N_lis=np.zeros(N)
for i in range(K):
    d=int(input())
    sweet=np.array(list(map(int, input().split())))
    #print(sweet)
    sweet-=1
    for j in sweet:
        N_lis[j]+=1
print(N_lis)
no_sweet=N_lis==0
print(no_sweet)
print(no_sweet.sum()))

Fixed submission:
import numpy as np
N, K = map(int, input().split())
N_lis=np.zeros(N)
for i in range(K):
    d=int(input())
    sweet=np.array(list(map(int, input().split())))
    #print(sweet)
    sweet-=1
    for j in sweet:
        N_lis[j]+=1
#print(N_lis)
no_sweet=N_lis==0
#print(no_sweet)
print(no_sweet.sum())

Buggy python submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split())
N_lis=np.zeros(N)
for i in range(K):
  d=int(input())
  sweet=np.array(map(int, input().split()))
  sweet-=1
  for j in sweet:
    N_lis[j]+=1
 
no_sweet=N_lis[N_lis==0]
print(no_sweet.sum())

Fixed submission:
import numpy as np
N, K = map(int, input().split())
N_lis=np.zeros(N)
for i in range(K):
    d=int(input())
    sweet=np.array(list(map(int, input().split())))
    #print(sweet)
    sweet-=1
    for j in sweet:
        N_lis[j]+=1
#print(N_lis)
no_sweet=N_lis==0
#print(no_sweet)
print(no_sweet.sum())

Buggy python submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split())
N_lis=np.zeros(N)
for i in range(K):
  d=int(input())
  sweet=np.arrray(map(int, input().split()))
  sweet-=1
  for j in sweet:
    N_lis[j]+=1

no_sweet=N_lis[N_lis==0]
print(no_sweet.sum())


 

Fixed submission:
import numpy as np
N, K = map(int, input().split())
N_lis=np.zeros(N)
for i in range(K):
    d=int(input())
    sweet=np.array(list(map(int, input().split())))
    #print(sweet)
    sweet-=1
    for j in sweet:
        N_lis[j]+=1
#print(N_lis)
no_sweet=N_lis==0
#print(no_sweet)
print(no_sweet.sum())
Buggy python submission (verdict: Runtime Error):
H=[int(x) for x in input().split()]
way=[]
for i in range(M):
    way.append([int(x) for x in input().split()])
 
dic={}
for i in range(N):
    dic[i]=set()
 
for h in way:
    dic[h[0]-1].add(h[1]-1)
    dic[h[1]-1].add(h[0]-1)
    
 
print(sum(all([H[i]>H[hs] for hs in dic[i]])for i in range(N)))

Fixed submission:
n,m=map(int,input().split())
h=list(map(int,input().split()))
dic={i:set() for i in range(n)}
for j in range(m):
  a,b=map(lambda x:int(x)-1,input().split())
  dic[a].add(b)
  dic[b].add(a)
co=0
for i in range(n):
  if all([h[i]>h[way] for way in dic[i]]):co+=1
print(co)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N,M =map(int,input().split())
h_lis=np.array(list(map(int,input().split())))
way_lis=[list(map(int,input().split())) for _ in range(M)]

tes=0
for i in range(N):
    nears=[]
    for way in way_lis:
        if i+1 in way:
            near.extend(way)
    for j,ne in enumerate(nears):
        if j==0:
            h=max(h_lis[ne[0]-1],h_lis[ne[1]-1])
            z=h
        else:
            k=z
            h=max(h_lis[ne[0]-1],h_lis[ne[1]-1])
            z=max(k,h)
    if z==h_lis[i]:
        tes+=1
print(tes)

Fixed submission:
n,m=map(int,input().split())
h=list(map(int,input().split()))
dic={i:set() for i in range(n)}
for j in range(m):
  a,b=map(lambda x:int(x)-1,input().split())
  dic[a].add(b)
  dic[b].add(a)
co=0
for i in range(n):
  if all([h[i]>h[way] for way in dic[i]]):co+=1
print(co)
Buggy python submission (verdict: Runtime Error):
from itertools import combinations
n,m,q=map(int,input().split())
aa=[]
bb=[]
cc=[]
dd=[]
for i in range(q):
  a,b,c,d=map(int,input().split())
  aa.append(a-1)
  bb.append(b-1)
  cc.append(c)
  dd.append(d)
sumd=[]
#print(list(combinations(range(1,m+1),n)))
for Alis in combinations(range(1,m+1),n):
  
  di=0
  
  for i in range(q):
    if cc[i]==(Alis[bb[i]]-Alis[aa[i]]):
      di+=dd[i]
      
  sumd.append(di)
print(max(sumd))

Fixed submission:
from itertools import combinations_with_replacement
n,m,q=map(int,input().split())
aa=[]
bb=[]
cc=[]
dd=[]
for i in range(q):
  a,b,c,d=map(int,input().split())
  aa.append(a-1)
  bb.append(b-1)
  cc.append(c)
  dd.append(d)
sumd=[]
#print(list(combinations(range(1,m+1),n)))
for Alis in combinations_with_replacement(range(1,m+1),n):
  
  di=0
  
  for i in range(q):
    if cc[i]==(Alis[bb[i]]-Alis[aa[i]]):
      di+=dd[i]
      
  sumd.append(di)
print(max(sumd))

Buggy python submission (verdict: Runtime Error):
for i in range(q):
  a,b,c,d=map(int,input().split())
  aa.append(a-1)
  bb.append(b-1)
  cc.append(c)
  dd.append(d)
sumd=[]
#print(list(combinations(range(1,m+1),n)))
for Alis in combinations(range(1,m+1),n):
  
  di=0
  
  for i in range(q):
    if cc[i]==(Alis[bb[i]]-Alis[aa[i]]):
      di+=dd[i]
      
  sumd.append(di)
print(max(sumd))

Fixed submission:
from itertools import combinations_with_replacement
n,m,q=map(int,input().split())
aa=[]
bb=[]
cc=[]
dd=[]
for i in range(q):
  a,b,c,d=map(int,input().split())
  aa.append(a-1)
  bb.append(b-1)
  cc.append(c)
  dd.append(d)
sumd=[]
#print(list(combinations(range(1,m+1),n)))
for Alis in combinations_with_replacement(range(1,m+1),n):
  
  di=0
  
  for i in range(q):
    if cc[i]==(Alis[bb[i]]-Alis[aa[i]]):
      di+=dd[i]
      
  sumd.append(di)
print(max(sumd))
Buggy python submission (verdict: Runtime Error):
N=int(input())
A_=set(list(map(int,input().split())))
print(len(A_))


Fixed submission:
N=int(input())
A_=set([input() for i in range(N)])
print(len(A_))

Buggy python submission (verdict: Runtime Error):
import pandas
N=int(input())
A_=list(map(int,input().split()))
ss=pd.Series(A_)
print(len(pd.unique(ss))


Fixed submission:
N=int(input())
A_=set([input() for i in range(N)])
print(len(A_))
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
a=(N*(N+1)*(N+2)-(K*(K-1)*(3*N-2*K+4)))/6
print(a%(10**9+7)

Fixed submission:
po=pow(10,9)+7
n,k=map(int,input().split())
cc=0
for i in range(k,n+2):
  cc+=(n*i-i*(i-1)+1)%po
print(cc%po)
Buggy python submission (verdict: Time Limit Exceeded):
import math
k=int(input())
a=0
for i in range(1,k+1):
  for j in range(1,k+1):
    for h in range(1,k+1):
      a+=math.gcd(math.gcd(i,j),h)
    
print(a)

Fixed submission:
import math
k=int(input())
a=0
for i in range(1,k+1):
  for j in range(1,k+1):
    for h in range(1,k+1):
      a+=math.gcd(math.gcd(i,j),h)
    
print(a)
Buggy python submission (verdict: Runtime Error):
import numpy as np
from bisect import bisect

n=int(input())
dic={ 'R':[], 'G':[], 'B':[] }

stri=list(input())
count=0
for i,v in enumerate(stri):
  #print(i,v)
  dic[v].append(i)
  
for name in dic:
  dic[name]=np.asarray(dic[name])
#print(dic)
for i in range(n):
  lib=['R','G','B']
  lib.remove(stri[i])
  #print(lib)
  for col in lib:
    for j in dic[col][dic[col]>i]:
      t=[i for i in lib if i != col].pop()
      skip_k=2*i-j
      idx=bisect(dic[t],skip_k)-1
      if dic[t][idx]==skip_k:
        count+=len(dic[t][dic[t]>j])-1
      else:
        count+=len(dic[t][dic[t]>j])
      
print(count)

Fixed submission:
from collections import Counter
n=int(input())
stri=list(input())
cc=Counter(stri)

count=cc['R']*cc['G']*cc['B']


for i in range(n-2):
  for j in range(i+1,n-1):
    if stri[j]==stri[i]:continue
      
    lib=['R','G','B']
    lib.remove(stri[i])
    lib.remove(stri[j])
    t=lib.pop()
    
    skip_k=2*j-i
    #print(i,j,skip_k)
    if skip_k>n-1:continue
    if stri[skip_k]==t:
      count-=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n=int(input())
dic={ 'R':[], 'G':[], 'B':[] }

stri=list(input())
count=0
for i,v in enumerate(stri):
  #print(i,v)
  dic[v].append(i)
  
for name in dic:
  dic[name]=np.asarray(dic[name])
#print(dic)
for i in range(n):
  lib=['R','G','B']
  lib.remove(stri[i])
  #print(lib)
  for col in lib:
    for j in dic[col][dic[col]>i]:
      t=[i for i in lib if i != col].pop()
      #print(i,j)
      for k in dic[t][dic[t]>j]:
        if 2*j-i-k!=0:
          #print(i,j,k)
          count+=1
print(count)

Fixed submission:
from collections import Counter
n=int(input())
stri=list(input())
cc=Counter(stri)

count=cc['R']*cc['G']*cc['B']


for i in range(n-2):
  for j in range(i+1,n-1):
    if stri[j]==stri[i]:continue
      
    lib=['R','G','B']
    lib.remove(stri[i])
    lib.remove(stri[j])
    t=lib.pop()
    
    skip_k=2*j-i
    #print(i,j,skip_k)
    if skip_k>n-1:continue
    if stri[skip_k]==t:
      count-=1
print(count)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
if k>=n:
  print(min(k-n,n))
else:
  
  print(min(n%k,abs(n%k-k))

Fixed submission:
n,k=map(int,input().split())
if k>=n:
  print(min(k-n,n))
else:
  
  print(min(n%k,abs(n%k-k)))

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
if k>=n:
  print(min(k-n,n))
else:
  
  print(min(n%k,abs(n%k-k))

Fixed submission:
n,k=map(int,input().split())
if k>=n:
  print(min(k-n,n))
else:
  
  print(min(n%k,abs(n%k-k)))
Buggy python submission (verdict: Runtime Error):
n=int(input())
from collections import deque
q=deque([])
i=0
while True:
  if i<=8:
    q.append(i+1)
    i+=1
    if i==k:break
    continue
  
  x=q.popleft()
  
  if x%10!=0:
    q.append(x*10+x%10-1)
    i+=1
    if i==k:break
    
  q.append(x*10+x%10)
  i+=1
  if i==k:break
  
  if x%10!=9:
    q.append(x*10+x%10+1)
    i+=1
    if i==k:break
      
print(q.pop())

Fixed submission:
k=int(input())
from collections import deque
q=deque([])
i=0
while True:
  if i<=8:
    q.append(i+1)
    i+=1
    if i==k:break
    continue
  
  x=q.popleft()
  
  if x%10!=0:
    q.append(x*10+x%10-1)
    i+=1
    if i==k:break
    
  q.append(x*10+x%10)
  i+=1
  if i==k:break
  
  if x%10!=9:
    q.append(x*10+x%10+1)
    i+=1
    if i==k:break
      
print(q.pop())
Buggy python submission (verdict: Runtime Error):
a=list(input())
b=a[:int((n-1)/2)+1]
c=a[int((n+3)/2):]
n=len(a)
anal = a==reversed(a)
manco = b==reversed(b)
portio = c==reversed(c)

if anal and manco and portio:
  print('Yes')
esle:
  print('No')

Fixed submission:
s=list(input())
n=len(s)
a=all([p==q for p,q in zip(s,reversed(s))])
b=all([p==q for p,q in zip(s[:(n-1)//2],reversed(s[:(n-1)//2]))])
c=all([p==q for p,q in zip(s[(n+3)//2-1:],reversed(s[(n+3)//2-1:]))])

if a and b and c:
  print('Yes')
else:
  print('No')