Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02923 (python)

Fixed submission:
n =  int(input())
arr = input().split()
arr = [int(x) for x in arr]
counts = []
temp = 0
for i in range(n-1):
    if arr[i] >= arr[i+1]:
        temp += 1
        #print(temp)
        counts.append(temp)
    else:
        #counts.append(temp)
        temp = 0
if not counts:
    print(0)
else:
    print(max(counts))

Buggy submission (verdict: Runtime Error):
n =  int(input())
arr = input().split()
arr = [int(x) for x in arr]
def hhhh(arr):
    res = []
    for j in range(1,len(arr)):
        for i in range(j):
            #print(arr[i:j])
            if all([arr[i:j][k] >= arr[i:j][k+1] for k in range(len(arr[i:j])-1)]):
                    res.append(j-i)
                    
    
    return max(res)
a = hhhh(arr)
print(a)

Buggy submission (verdict: Runtime Error):
n =  int(input())
arr = input().split()
arr = [int(x) for x in arr]
def hhhh(arr):
    res = []
    for j in range(1,len(arr)):
        for i in range(j):
            #print(arr[i:j])
            if all([arr[i:j][k] >= arr[i:j][k+1] for k in range(len(arr[i:j])-1)]):
                    res.append(j-i)
                    
    
    return max(res)
hhhh(arr)
Problem p03211 (python)

Fixed submission:
s = list(map(int, input()))
print(min(abs(s[i+2]+s[i+1]*10+s[i]*100-753) for i in range(len(s)-2)))

Buggy submission (verdict: Runtime Error):
s = list(map(int, input()))
print(min(abs(s[i+2]*100+s[i+1]*10+s[i]-753)) for i in range(len(s)-2)
Problem p03219 (python)

Fixed submission:
x, y = map(int, input().split())
print(x+int(y/2))

Buggy submission (verdict: Runtime Error):
x,y = int(input())
print(x+int(y/2))
Problem p02934 (python)

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

def multi_all(A):
  s = 1
  for a in A:
    s *= a
  return s

M = multi_all(A)

if N == 1: print(A[0])
else:
  S = 0
  for a in A:
    S += M / a
  print(M/S)

Buggy submission (verdict: Runtime Error):
A = list(map(int, input().split(' ')))

def multi_all(A):
  s = 1
  for a in A:
    s *= a
  return s

M = multi_all(A)

if N == 1: print(A[0])
else:
  S = 0
  for a in A:
    S += M / a
  print(M/S)
Problem p03644 (python)

Fixed submission:
N = int(input())
ans = 0
for i in range(1,N+1):
    counter = 0
    real_number = i
    while i > 0:
        i //= 2
        counter += 1
    if counter > ans:
        ans = counter
        ans_number = real_number
print(ans_number)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = 0
for i in range(1,N+1):
    counter = 0
    real_number = i
    while i %2 == 0:
        i //= 2
        counter += 1
    if counter > ans:
        ans = counter
        ans_number = real_number
print(ans_number)
Problem p03693 (python)

Fixed submission:
r, g, b = map(int, input().split())
if (100*r + 10*g + b)%4 == 0:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if (100*r + 10*g + b)%4 == 0:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
r = int(input())
g = int(input())
b = int(input())
if (100*r + 10*g + b)%4 == 0:
    print("YES")
else:
    print("NO")
Problem p02909 (python)

Fixed submission:
S = str(input())
if S[-3:] == "nny":
    print("Cloudy")
elif S[-2:] == "dy":
    print("Rainy")
else:
    print("Sunny")

Buggy submission (verdict: Runtime Error):
S = str(input())
if S[-3:] = "nny":
    print(Cloudy)
elif S[-2:] = "dy":
    print(Rainy)
else:
    print(Sunny)

Buggy submission (verdict: Runtime Error):
S = str(input())
if S[-3:] = "nny":
    print("Cloudy")
elif S[-2:] = "dy":
    print("Rainy")
else:
    print("Sunny")
Problem p02934 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
under = 0
for i in range(N):
    under += 1 / A[i]
print(1 / under)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = map(int, input().split())
under = 0
for i in range(N):
    under += 1 / A[i]
print(1 / under)
Problem p02945 (python)

Fixed submission:
A, B = map(int, input().split())
list = []
list.append(A + B)
list.append(A - B)
list.append(A * B)
print(max(list))

Buggy submission (verdict: Runtime Error):
A, B = int(input().split())
list = []
list.append(A + B)
list.append(A - B)
list.append(A * B)
print(max(list))

Buggy submission (verdict: Runtime Error):
A, B = int, input().split()
list = []
list.append(A + B)
list.append(A - B)
list.append(A * B)
print(max(list))
Problem p02957 (python)

Fixed submission:
A, B = map(int, input().split())
if (A + B) % 2 != 0:
    print("IMPOSSIBLE")
else:
    print((A + B) // 2)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
for K in range(10 ** 9):
    if abs(A - K) == abc(B - K):
        print(K)
    else:
        print("IMPOSSIBLE")
Problem p02958 (python)

Fixed submission:
N = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(N):
    if p[i] != i + 1:
        count += 1
if count == 0 or count == 2:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
N = int(input())
p = list(map(int, input().split()))
for i in range(N):
    for j in range(i + 1, N):
        if p[j - 1] < p[i] < p[j + 1] and p[i - 1] < p[j] < p[i + 1]:
            print("YES")
            exit()
        else:
            continue
print("NO")

Buggy submission (verdict: Runtime Error):
N = int(input())
p = list(map(int, input().split()))
for i in range(N):
    for j in range(i + 1, N):
        if p[j - 1] < p[i] < p[j + 1] and p[i - 1] < p[j] < p[i + 1]:
            print("YES")
        else:
            continue
print("NO")

Buggy submission (verdict: Runtime Error):
N = int(input())
p = list(map(int, input().split()))
for i in range(N):
    for j in range(i + 1, N):
        if p[j - 1] < p[i] < p[j + 1] and p[i - 1] < p[j] < p[i + 1]:
            print("YES")
        else:
            print("NO")
Problem p02981 (python)

Fixed submission:
N, A, B = map(int, input().split())
if A * N < B:
    print(A * N)
else:
    print(B)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
ans = []
for i in range(1, N):
    ans.append(A * i + B / N * (N - i))
print(min(ans))

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
ans = []
for i in range(1, N):
    ans.append(A * i + B * (N - i))
print(min(ans))
Problem p02982 (python)

Fixed submission:
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
count = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        r = 0
        for k in range(D):
            r += (X[i][k] - X[j][k]) ** 2
        if r ** 0.5 % 1 == 0:
            count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N, D = map(int, input().split())
X = list(map(int, input().split()))
count = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        r = 0
        for k in range(D):
            r += (X[i][k] - X[j][k]) ** 2
        if r ** 0.5 % 1 == 0:
            count += 1
print(count)

Buggy submission (verdict: Runtime Error):
N, D = map(int, input().split())
X = list(map(int, input().split()))
count = 0
for i in range(N):
    for j in range(i + 1, N):
        r = 0
        for k in range(D):
            r += (X[i][k] - X[j][k]) ** 2
        if r ** 0.5 % 1 == 0:
            count += 1
print(count)
Problem p02988 (python)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(1, n - 1):
    if p[i - 1] < p[i] < p[i + 1]:
        count += 1
    elif p[i + 1] < p[i] < p[i - 1]:
        count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(1, n):
    if p[i - 1] < p[i] < p[i + 1]:
        count += 1
print(count)
Problem p02994 (python)

Fixed submission:
N, L = map(int, input().split())
flavor = []
for i in range(1, N + 1):
    flavor.append(L + i - 1)
import numpy as np
for j in flavor:
    if abs(j) == min(np.abs(flavor)):
        eat = j
print(sum(flavor) - eat)

Buggy submission (verdict: Runtime Error):
N, L = map(int, input().split())
flavor = []
for i in range(1, N + 1):
    flavor.append(L + i - 1)
print(sum(flavor) - min(abs(flavor)))
Problem p03000 (python)

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
count = 1
location = 0
for i in range(N):
    if location + L[i] <= X:
        count += 1
        location += L[i]
    else:
        break
print(count)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))
count = 0
location = 0
for i in range(N + 1):
    if location + L[i] <= X:
        count += 1
        location += L[i]
    else:
        break
print(count)
Problem p03030 (python)

Fixed submission:
N = int(input())
l = []
for i in range(N):
    a = input().split()
    l.append([a[0], 100 - int(a[1]), i + 1])
l.sort()
for i in range(N):
    print(l[i][2])

Buggy submission (verdict: Runtime Error):
N = int(input())
l = []
for i in range(N):
    a = input().split()
    l.append([a[0], a[1], i + 1])
l.sort()
for i in range(N):
    print(a[i][2])
Problem p02885 (python)

Fixed submission:
A,B=map(int,input().split())
if A>=2*B:
    Ans = A-(2*B)
else:
    Ans=0
print(Ans)

Buggy submission (verdict: Runtime Error):
N, M, L = map(int,input().split())
MAX=999999999
A=[]
B=[]
C=[]
D=[[MAX for _ in range(N)] for _ in range(N)]
F=[[MAX for _ in range(N)] for _ in range(N)]
s=[]
t=[]
 
for i in range(M):
    l=list(map(int,input().split()))
    A.append(l[0]-1)
    B.append(l[1]-1)
    C.append(l[2])
 
 
 
Q=int(input())
 
for i in range(Q):
    m=list(map(int,input().split()))
    s.append(m[0]-1)
    t.append(m[1]-1)
 
 
for i in range(M):
    if C[i]>L : continue
    D[A[i]][B[i]]=C[i]
    D[B[i]][A[i]]=C[i]
 
for i in range(N):  D[i][i]=0
 
for k in range(N):
    for i in range(N):
        for j in range(N):
            if (D[i][k]+D[k][j])<D[i][j] :
                D[i][j]=D[i][k]+D[k][j]
 
for i in range(N):
    for j in range(N):
        if i==j : continue
        if D[i][j]<=L: F[i][j]=1
 
 
for i in range(N):  F[i][i]=0
 
for k in range(N):
    for i in range(N):
        for j in range(N):
            if (F[i][k]+F[k][j])<F[i][j] :
                F[i][j]=F[i][k]+F[k][j]
 
 
for p in range(Q) :
    if F[s[p]][t[p]] < MAX :
        print(F[s[p]][t[p]]-1)
    else :
        print(-1)
Problem p02886 (python)

Fixed submission:
N=int(input())
d=list(map(int,input().split()))
res=0

for i in range(N-1):
    for j in range(N-i-1):
        #d[i+1]~d[N-1]
        res+=d[i]*d[i+j+1]


print(res)

Buggy submission (verdict: Runtime Error):
N=int(input())
d=[0]*N
d=map(int,input().sort())
res=0

for i in range(N-1):
    for j in range(N-i):
        res+=d[i]*d[j]

print(res)
Problem p02887 (python)

Fixed submission:
N=int(input())
S=input()
S_list=[]
count = 0
j=''

for i in S:
    count +=1
    if (count>=2) & (i==j): continue
    else:
        S_list.append(i)
        j=i

print(len(S_list))

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
S_list=[]
for i in S:
    S_list.append(i)
set(S_list)
print(lens(S_list))
Problem p02888 (python)

Fixed submission:
N=int(input())
Ln=list(map(int,input().split()))
Ln.sort(reverse=True)
Ans=0
left=0
right=0
 
for i in range(N-2):
    di=i+1
    for j in range(N-di-1):
        dj=di+j+1
        A=Ln[di-1]
        B=Ln[dj-1]
        if (B+Ln[dj])<A : break
 
        right=N-1
        left=dj
        while left<=right :
            mid=int((right+left)/2)
            if (B+Ln[mid])>A :
                left=mid+1
            else :
                right=mid-1
        Ans+=(left-1)-(dj-1)
 
print(Ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ln=list(map(int,input().split()))
ln.sort(reverse=true)
ans=0

for i in range(n-2):
  for j in range(n-i-1):
    a=ln[i]
    b=ln[i+j+1]
    #b+c>aを探す
    
    right=n-1
    left=i+j+2
    while left<=right :
      mid=int((right+left)/2)
      c=ln(mid)
      if(b+c)<a:    
        right=mid-1
      else :
        left=mid+1
    c=ln[left]
    if b+c>a :
      ans+=left-(i+j+1)

print(ans)
Problem p02898 (python)

Fixed submission:
N,K=map(int,input().split())
h=list(map(int, input().split()))
h.sort(reverse=True)
Ans=N
for i in range(N):
    if h[i]<K :
        Ans=i
        break

print(Ans)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
h=list(map(int, input().split()))
h.sort(reverse=True)

for i in range(N):
    if h[i]<K :
        Ans=i
        break

print(Ans)
Problem p02936 (python)

Fixed submission:
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n-1)]
pq=[list(map(int,input().split())) for _ in range(m)]
ab2=sorted(ab, key=lambda x:x[0])
pq2=sorted(pq, key=lambda x:x[0])

res=[0 for _ in range(n)]
for p,q in pq2:
	res[p-1]+=q
for a,b in ab2:
	res[b-1]+=res[a-1]
ans=str(res[0])
for i in range(1,n):
	ans+=" "+(str(res[i]))
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n-1)]
pq=[list(map(int,input().split())) for _ in range(m)]
ab=sorted(ab, key=lambda x:x[0])
pq=sorted(pq, key=lambda x:x[0])

res=[0 for _ in range(n)]
for p,q in pq:
	res[p-1]+=q
for a,b in ab:
	res[b-1]+=res[a-1]
print(" ".join(res))
Problem p02937 (python)

Fixed submission:
s=input()
t=input()
x=list(s)
y=list(t)
import sys
if len(set(y)-set(x))!=0:
	print(-1)
	sys.exit()
a=[[] for _ in range(26)]
for i in range(len(s)):
	a[ord(x[i])-97].append(i)
import bisect

repeat=0
last=-1
for i in range(len(t)):
	temp=a[ord(y[i])-97]
	if last>=temp[-1]:
		repeat+=1
		last=temp[0]
	else:
		last=temp[bisect.bisect_right(temp,last)]
	#print(temp,repeat,last)
print(repeat*len(s)+last+1)

Buggy submission (verdict: Runtime Error):
s=input()
t=input()

x=list(s)
y=list(t)
import sys
if len(set(y)-set(x))!=0:
	print(-1)
	sys.exit()

a=[[] for _ in range(26)]
for i in range(len(s)):
	a[ord(x[i])-97].append(i)



import bisect
#t=bisect.bisect_right(res[p-1],y)

repeat=0
last=0
for i in range(len(t)):
	temp=a[ord(y[i])-97]
	if last>=temp[-1]:
		repeat+=1
		last=temp[0]
	else:
		last=temp[bisect.bisect_right(temp,last)]
	print(temp,repeat,last)
print(repeat*len(s)+last+1)

Buggy submission (verdict: Runtime Error):
s=input()
t=input()

x=list(s)
y=list(t)
import sys
if len(set(y)-set(x))!=0:
	print(-1)
	sys.exit()

a=[[] for _ in range(26)]
for i in range(len(s)):
	a[ord(x[i])-97].append(i)



import bisect
#t=bisect.bisect_right(res[p-1],y)

repeat=0
last=0
for i in range(len(t)):
	temp=a[ord(y[i])-97]
	if last>max(temp):
		repeat+=1
		last=min(temp)
	else:
		last=temp[bisect.bisect_right(temp,last)]
	#print(temp,repeat,last)
print(repeat*len(s)+last+1)
Problem p02972 (python)

Fixed submission:
#43 ABC134D
n=int(input())
a=list(map(int,input().split()))
x=[0 for _ in range(n)]
for i in range(n,0,-1):
	x[i-1]=1 if a[i-1]!=sum([x[j] for j in range(i-1,n,i)])%2 else 0
#print(x)
j=True
for i in range(n):
	if a[i]!=sum([x[j] for j in range(i,n,i+1)])%2:
		j=False
if j:
	print(sum(x))
	if sum(x)!=0:
		res=[]
		for i,t in enumerate(x):
			if t==1:
				res.append(str(i+1))
		print(" ".join(res))
else:
	print(-1)

Buggy submission (verdict: Runtime Error):
#43 ABC134D
n=int(input())
a=list(map(int,input().split()))
x=[0 for _ in range(n)]
for i in range(n,0,-1):
	x[i-1]=sum([a[j] for j in range(i-1,n,i)])%2
j=True
for i in range(a):
	if a[i]!=sum([a[j] for j in range(i,n,i+1)])%2:
		j=False
if j:
	print(sum(x))
	if sum(x)!=0:
		res=[]
		for i,t in enumerate(x):
			if t==1:
				res.append(str(i+1))
		print(" ".join(res))
else:
	print(-1)
Problem p03061 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
a.sort()
x=[a[0]]
for i in range(1,n):
    x.append(gcd(x[-1],a[i]))
y=[a[-1]]
for i in range(2,n+1):
    y.append(gcd(y[-1],a[-i]))
y=y[::-1]
res=[x[-2],y[1]]
for i in range(n-2):
    res.append(gcd(x[i],y[i+2]))
print(max(res))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
a.sort()
a=a[::-1]
res=[a[0]]
for i in range(1,n):
    for t in res:
        x=gcd(t,a[i])
        if x!=t:
            res.append(x)
res.sort()
print(res[1])
Problem p03096 (python)

Fixed submission:
n=int(input())
c=[int(input()) for _ in range(n)]
x=[c[0]]
for i in range(1,n):
    if c[i]!=c[i-1]:
        x.append(c[i])
#print(x)

dp=[0 for _ in range(n)]
res=[[] for _ in range(max(x)+1)]
res[x[0]].append(0)
res2=[0 for _ in range(max(x)+1)]
for i in range(1,len(x)):
    if len(res[x[i]])>0:
        if res[x[i]][-1]==0:#左端スタートで１つ目の場合
            dp[i]=dp[i-1]+1
        else:
            dp[i]=dp[i-1]+len(res[x[i]])+res2[x[i]]
            #print(res2[x[i]])
    else:
        dp[i]=dp[i-1]
    res[x[i]].append(i)
    res2[x[i]]+=dp[i-1]
    #print(dp,res2)
print((dp[len(x)-1]+1)%(10**9+7))
#print(res)

Buggy submission (verdict: Runtime Error):
n=int(input())
c=[int(input()) for _ in range(n)]
x=[c[0]]
for i in range(1,n):
    if c[i]!=c[i-1]:
        x.append(c[i])
#print(x)

dp=[0 for _ in range(n)]
res=[[] for _ in range(max(x)+1)]
res[x[0]].append(0)
res2=[0 for _ in range(max(x)+1)]
for i in range(1,len(x)):
    if len(res[x[i]])>0:
        if res[x[i]][-1]==0:#左端スタートで１つ目の場合
            dp[i]=dp[i-1]+1
        else:
            dp[i]=dp[i-1]+len(res[x[i]])+res2[res[x[i]][-1]-1]
    else:
        dp[i]=dp[i-1]
    res[x[i]].append(i)
    res2[x[i-1]]+=dp[i-1]
    #print(dp,res2)
print((dp[len(x)-1]+1)%(10**9+7))
#print(res)
Problem p03136 (python)

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
if max(l)<sum(l)-max(l):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
y=[x[i+1]-x[i] for i in range(m-1)]
y.sort()
if n<m:
    print(sum(y[:m-n]))
else:
    print(0)
Problem p03239 (python)

Fixed submission:
n,t=map(int,input().split())
ct=[list(map(int,input().split())) for _ in range(n)]
mc=100000
for i in range(n):
    if ct[i][1]<=t:
        if ct[i][0]<mc:
            mc=ct[i][0]
if mc==100000:
    print("TLE")
else:
    print(mc)

Buggy submission (verdict: Runtime Error):
n,t=map(int,input().split())
ct=[list(map(int,input().split())) for _ in range(n)]
mc=100000
for i in range(n):
    if ct[i][1]<=t:
        if ct[i][0]<mc:
            mc=ct[i][0]
if mi==-1:
    print("TLE")
else:
    print(mc)
Problem p03268 (python)

Fixed submission:
n,k=map(int, input().split())
def com(a,b):
    r=1
    for c in range(b):
        r*=(a-c)
        r//=c+1
    return r
if k%2==0:
    x=0
    y=0
    for i in range(1,n+1):
        if i%k==k//2:
            x+=1
        if i%k==0:
            y+=1
    ans=0
    if x>=1:
        ans+=com(x,1)
    if x>=2:
        ans+=6*com(x,2)
    if x>=3:
        ans+=6*com(x,3)
    if y>=1:
        ans+=com(y,1)
    if y>=2:
        ans+=6*com(y,2)
    if y>=3:
        ans+=6*com(y,3)
    print(ans)
else:
    x=0
    for i in range(1,n+1):
        if i%k==0:
            x+=1
    ans=0
    if x>=1:
        ans+=com(x,1)
    if x>=2:
        ans+=6*com(x,2)
    if x>=3:
        ans+=6*com(x,3)
    print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
if k%2==0:
    x=0
    y=0
    for i in range(1,n+1):
        if i%k==k//2:
            x+=1
        if i%k==0:
            y+=1
    ans=0
    if x>=1:
        ans+=com(x,1)
    if x>=2:
        ans+=6*com(x,2)
    if x>=3:
        ans+=6*com(x,3)
    if y>=1:
        ans+=com(y,1)
    if y>=2:
        ans+=6*com(y,2)
    if y>=3:
        ans+=6*com(y,3)
    print(ans)
else:
    x=0
    for i in range(1,n+1):
        if i%k==0:
            x+=1
    ans=0
    if x>=1:
        ans+=com(x,1)
    if x>=2:
        ans+=6*com(x,2)
    if x>=3:
        ans+=6*com(x,3)
    print(ans)
def com(a,b):
    r=1
    for i in range(b):
        r*=(a-i)
        r//=i+1
    return r

Buggy submission (verdict: Runtime Error):
n,k=map(int, input().split())
if k%2==0:
    x=0
    y=0
    for i in range(1,n+1):
        if i%k==k//2:
            x+=1
        if i%k==0:
            y+=1
    ans=0
    if x>=1:
        ans+=com(x,1)
    if x>=2:
        ans+=6*com(x,2)
    if x>=3:
        ans+=6*com(x,3)
    if y>=1:
        ans+=com(y,1)
    if y>=2:
        ans+=6*com(y,2)
    if y>=3:
        ans+=6*com(y,3)
    print(ans)
else:
    x=0
    for i in range(1,n+1):
        if i%k==0:
            x+=1
    ans=0
    if x>=1:
        ans+=com(x,1)
    if x>=2:
        ans+=6*com(x,2)
    if x>=3:
        ans+=6*com(x,3)
    print(ans)
    
def com(a,b):
    r=1
    for i in range(b):
        r*=(a-i)
        r//=i+1
    return r
Problem p03282 (python)

Fixed submission:
s=input()
k=int(input())
t=0
a=1
for i in range(len(s)):
    if s[i]!='1':
        t=i+1
        a=s[i]
        break
if k<t:
    print(s[k-1])
else:
    print(a)

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())

for i in range(len(s)):
    if s[i]!='1':
        t=i+1
        a=s[i]
        break
if k<t:
    print(s[k-1])
else:
    print(a)
Problem p03294 (python)

Fixed submission:
n=int(input())
a=list(map(int, input().split()))
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)
x=1
for t in a:
    x=lcm(x,t)
x-=1
ans=0
for t in a:
    ans+=x%t
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
def lcm(x,y):
    return int(x*y/gcd(x,y))
k=1
for t in a:
    k=lcm(k,t)
k-=1
ans=0
for t in a:
    ans+=k%t
print(ans)
Problem p03355 (python)

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

x = ['a', 'b', 'ab', 'ba', 'aba']
a=[]
m = min(s)
for i in range(len(s)):
    a.append(s[i])
    a.append(s[i:min(len(s),i+2)])
    a.append(s[i:min(len(s),i+3)])
    a.append(s[i:min(len(s),i+4)])
    a.append(s[i:min(len(s),i+5)])
a=list(set(a))
a.sort()
if a[0]=='':
    a=a[1:]
print(a[k-1])

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())

x = ['a', 'b', 'ab', 'ba', 'aba']
a=[]
m = min(s)
for i in range(len(s)):
    a.append(s[i])
    if s[i]==m:
        a.append(s[i:min(len(s)-1,i+2)])
        a.append(s[i:min(len(s)-1,i+3)])
        a.append(s[i:min(len(s)-1,i+4)])
        a.append(s[i:min(len(s)-1,i+5)])
a=list(set(a))
a.sort()
if a[0]=='':
    a=a[1:]
print(a[k-1])
Problem p03359 (python)

Fixed submission:
a,b = map(int, input().split())
if a<=b:
    print(a)
else:
    print(a-1)

Buggy submission (verdict: Runtime Error):
m=1000
while(2**i<m):
    i+=1
m=2**i
print(m)
Problem p03363 (python)

Fixed submission:
def com(x,y):
    a=1
    b=1
    y=min(y,x-y)
    for i in range(x,x-y,-1):
        a*=i
    for i in range(1,y+1):
        b*=i
    return a//b

n=int(input())
a=list(map(int,input().split()))
b=[a[0]]
for i in range(1,n):
    b.append(b[-1]+a[i])
from collections import Counter
c=Counter(b)
d=list(c.items())
ans=0
for t in d:
    if t[0]==0:
        ans+=com(t[1]+1,2)
    elif t[1]>1:
        ans+=com(t[1],2)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import collections
n = int(input())
a = list(map(int, input().split()))
ans=0
x=[a[0]]
for i in range(1,n):
    x.append(a[i]+x[i-1])
c = collections.Counter(x)
for i in c.items():
	if i[1]>=2:
        ans+=math.factorial(i[1]-1)
print(ans)