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

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

S = list(input())

S[K-1] = S[K-1].lower()

s_new = ""
for i in range(N):
  s_new += S[i]
    
print(s_new)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())

S = list(input())

S[K-1] = S[K-1].lower()

for i in range(N):
  s_new += S[i]
    
print(s_new)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())

S = list(input())

S[K-1] = S[K-1].lower()

for i in S:
  s_new += i
    
print(s_new)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())

S = list(input())

S[K-1] = S[K-1].lower()

for i in S:
    s_new += i
    
print(s_new)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())

S = list(input())

S[K-1] = S[K-1].lower

for i in S:
    s_new += i
    
print(s_new)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())

S = list(input())

S[K-1] = S[K-1].lower

for i in S[0,K]:
    s_new += S[i]
    
print(s_new)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = str(input())
S_new = S.lower[K-1]
print(S_new)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = str(input())

print(S.lower(K-1))
Problem p02847 (python)

Fixed submission:
# get the date as a string
s = input()

WEEKDAYS=['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
integer_day = WEEKDAYS[::-1].index(s) + 1
print(integer_day)

Buggy submission (verdict: Runtime Error):
# get the date as a string
s = input()

WEEKDAYS=['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
integer_day = WEEKDAYS[::-1].indexof(s) + 1
print(integer_day)

Buggy submission (verdict: Runtime Error):
# get the date as a string
s = raw_input()

WEEKDAYS=['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
integer_day = WEEKDAYS[::-1].indexof(s) + 1
print(integer_day)
Problem p02879 (python)

Fixed submission:
A, B = list(map(int, input().split(" ")))
if not A >9 and not B >9:
    print(A*B)
else:
    print("-1")

Buggy submission (verdict: Runtime Error):
import numpy as np

N,K = list(map(int, input().split(" ")))
A = list(map(int, input().split(" "))) # consumption coefficient of members
F = list(map(int, input().split(" "))) # difficulty of food

# pair fastest eaters (low consumption coefficient) with most difficult foods
A.sort()
F.sort(reverse=True)
A = np.array(A)
F = np.array(F)

maxT = np.max(A*F)
# use binary search to find lowest possible T
left = -1
right = maxT
while left+1< right:
    mid = (left+right)//2
    if np.maximum(0, A - (mid//F)).sum() <= K:
        right  = mid
    else:
        left = mid
print(right)

Buggy submission (verdict: Runtime Error):
import numpy as np

N,K = list(map(int, input().split(" ")))
A = list(map(int, input().split(" "))) # consumption coefficient of members
F = list(map(int, input().split(" "))) # difficulty of food

# pair fastest eaters (low consumption coefficient) with most difficult foods
A.sort()
F.sort(reverse=True)
A = np.array(A)
F = np.array(F)

def how_many_K(A,F,T,K):
    """
    Returns whether the number of training sessions needed for group A with foods F to have a score equal to T is less than K
    """
    num_trains = 0
    for i in range(len(A)):
        a = A[i]
        f = F[i]
        num_trains += max(0, a-T//f)

    if num_trains > K:
        return False
    else:
        return True

maxT = np.max(A*F)
# use binary search to find lowest possible T
left = -1
right = maxT
while left+1< right:
    mid = (left+right)//2
    if how_many_K(A,F,mid,K):
        right  = mid
    else:
        left = mid
print(right)
Problem p02879 (python)

Fixed submission:
x,y = map(int,input().split())
if x<=9 and y<=9:
    print(x*y)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
if A<=0 or 10<=A:
    print(-1)
elif B<=0 or 10<=B:
    print(-1)
else:
    print(A*B)
Problem p02847 (python)

Fixed submission:
YOUBI = input()
if YOUBI == "MON":
  print(6)
if YOUBI == "TUE":
  print(5)
if YOUBI == "WED":
  print(4)
if YOUBI == "THU":
  print(3)
if YOUBI == "FRI":
  print(2) 
if YOUBI == "SAT":
  print(1)
if YOUBI == "SUN":
   print(7)

Buggy submission (verdict: Runtime Error):
YOUBI = input()
if YOUBI == "MON":
  print"6"
if YOUBI == "TUE":
  print"5"
if YOUBI == "WED":
  print"4"
if YOUBI == "THU":
  print"3"
if YOUBI == "FRI":
  print"2" 
if YOUBI == "SAT":
  print"1"
if YOUBI == "SUN":
   print"7"

Buggy submission (verdict: Runtime Error):
YOUBI = input()
if YOUBI == "MON":
  print"6"
if YOUBI == "TUE":
  print"5"
if YOUBI == "WED":
  print"4"
if YOUBI == "THU":
  print"3"
if YOUBI == "FRI":
  print"2" 
if YOUBI == "SAT":
  print"1"
if YOUBI == "SUN":
   print"7"
    
    
    SUN,MON,TUE,WED,THU,FRI,SAT

Buggy submission (verdict: Runtime Error):
YOUBI = input()
if YOUBI == "MON
Problem p02862 (python)

Fixed submission:
import sys
import math
sys.setrecursionlimit(200000)
MOD = 10 ** 9 + 7


def extgcd(a, b):
    r = [1, 0, a]
    w = [0, 1, b]
    while w[2] != 1:
        q = r[2] // w[2]
        r2 = w
        w2 = [r[0] - q * w[0], r[1] - q * w[1], r[2] - q * w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0], w[1]]
# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)


def mod_inv(a,m):
    x = extgcd(a, m)[0]
    return (m + x % m) % m


def main():
    X, Y = map(int, input().split())
    if (X + Y) % 3 != 0:
        print(0)
        exit()
    else:
        m = (2 * X - Y) // 3
        n = (2 * Y - X) // 3
        if m < 0 or n < 0:
            print(0)
            exit()
        else:
            res = 1
            for i in range(1, n + m + 1):
                res = res * i % MOD
            for i in range(1, n + 1):
                res = res * mod_inv(i, MOD) % MOD
            for i in range(1,m + 1):
                res = res * mod_inv(i, MOD) % MOD
            print(res)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import math
sys.setrecursionlimit(200000)
MOD = 10 ** 9 + 7


def main():
    X, Y = map(int, input().split())
    while X != Y and X >= 0 and Y >= 0:
        if X > Y:
            X -= 2
            Y -= 1
        else:
            X -= 1
            Y -= 2
    if X % 2 == 1 and Y % 2 == 1:
        ab = math.factorial((X + Y) // 3)
        a = math.factorial(X // 3)
        b = math.factorial(Y // 3)
        print(ab // (a * b) % MOD)
    else:
        print(0)



if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
import math
sys.setrecursionlimit(200000)
MOD = 10 ** 9 + 7


def main():
    X, Y = map(int, input().split())
    while X != Y:
        if X > Y:
            X -= 2
            Y -= 1
        else:
            X -= 1
            Y -= 2
    if X % 2 == 1 and Y % 2 == 1:
        ab = math.factorial((X + Y) // 3)
        a = math.factorial(X // 3)
        b = math.factorial(Y // 3)
        print(ab // (a * b) % MOD)
    else:
        print(0)



if __name__ == "__main__":
    main()
Problem p02916 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
score = 0

for i in range(N):
    j = A[i] - 1
    if i > 0 and A[i] - A[i-1] == 1:
        score += B[j] + C[j-1]
    else:
        score += B[j]
print(score)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
score = 0
num = 0

for i in range(N):
    j = A[i] - 1
    if a[i] == j:
        score += B[j] + C[j-1]
    else:
        score += B[j]
print(score)
Problem p02951 (python)

Fixed submission:
i = list(map(int, input().split()))
n = i[2] - (i[0] - i[1])
if n > 0:
    print(n)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
i = list(map(int, input().split()))
print(i[2] - (i[0] - i[1]))
i = list(map(int, input().split()))
n = i[2] - (i[0] - i[1])
if n > 0:
    print(n)
else:
    print(0)
Problem p03077 (python)

Fixed submission:
n=int(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if n%(min([a,b,c,d,e]))==0:
    res=4+ n//(min([a,b,c,d,e]))
else:
    res=5+ n//(min([a,b,c,d,e]))
print(res)

Buggy submission (verdict: Runtime Error):
n=nt(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if n % min([a,b,c,d,e]) ==0:
    res=5+ n//(min[a,b,c,d,e])
else:
    res=5+ (n//(min[a,b,c,d,e])+1)
print(res)

Buggy submission (verdict: Runtime Error):
n=nt(input())
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
if min([a,b,c,d,e])==1:
    res=5+ n//(min[a,b,c,d,e])
else:
    res=5+ (n//(min[a,b,c,d,e])+1)
print(res)
Problem p02859 (python)

Fixed submission:
print(int(input())**2)

Buggy submission (verdict: Runtime Error):
print(int(input()**2))
Problem p03127 (python)

Fixed submission:
from functools import reduce
def gcd(a, b):
    if a < b:
        return gcd(b, a)
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
input()
Ai = list(map(int, input().split()))
print(reduce(gcd, Ai))

Buggy submission (verdict: Runtime Error):
from functools import reduce
from math import gcd
input()
Ai = list(map(int, input().split()))
print(reduce(gcd, Ai))

Buggy submission (verdict: Runtime Error):
from functools import reduce
from math import gcd
input()
Ai = list(map(int, input().strip()))
print(reduce(gcd, Ai))
Problem p03135 (python)

Fixed submission:
a,b=map(int,input().split());print(a/b)

Buggy submission (verdict: Runtime Error):
print(int(input())/int(input()))
Problem p02847 (python)

Fixed submission:
s = input()

dic = {
    'SUN' : 7, 'MON' : 6, 'TUE' : 5, 'WED' : 4, 'THU' : 3, 'FRI' : 2, 'SAT' : 1
}

print(dic[s])

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

dic = {'SUN' : 6, 'MON' : 5, 'WED' : 4, 'THU' : 3, 'FRI' : 2, 'SAT' : 1}

print(dic[s])
Problem p02847 (python)

Fixed submission:
s = input()
day = {'SUN':7,'MON':6,'TUE':5,'WED':4,'THU':3,'FRI':2,'SAT':1 }
print(day[s])

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
def get_price(a,b,n):
    return a * n + b * int (math.log10(n) + 1)    
a, b, x = map(int,input().split(' '))
currnt_max = 0
price_range = [get_price(a,b,10 ** i) for i in range(0,10)]    
price_range = np.asarray(price_range)

start = price_range[price_range < x].argmax()
end = 10 ** (start + 1)
start = 10 ** start
if start == 10 ** 9:
    print(10 ** 9)
    exit()

for i in range(start,10**9 + 1):
    tmp = get_price(a,b,i)
    if tmp < x:
        currnt_max = i
    else:
        break
print(currnt_max)
Problem p02862 (python)

Fixed submission:
import math

MAX=1000000
MOD=1000000007

fac=[1,1]
finv=[1,1]
inv=[1,1]

for i in range(2,MAX):
	fac.append(fac[i-1] * i % MOD)
	inv.append(MOD - inv[ MOD % i ] * (int(MOD / i)) % MOD)
	finv.append(finv[i - 1] * inv[i] % MOD)

def COM(nnn, kkk):
	if nnn < kkk:
		return 0
	
	if nnn < 0 or kkk < 0:
		return 0
	
	return fac[nnn] * (finv[kkk] * finv[nnn-kkk] % MOD) % MOD


x,y = map(int, input().split())

n = 2 * x - y
m = 2 * y - x

ans = 0
if n % 3 == 0:
	if m % 3 == 0:
		nn = int(n / 3)
		mm= int(m / 3)
		ans = COM(nn+mm,nn)

print(ans)

Buggy submission (verdict: Runtime Error):
import math
x,y = map(int, input().split())
n = 2 * x - y
m = 2 * y - x

ans = 0
if n % 3 == 0:
	if m % 3 == 0:
		nn = int(n / 3)
		mm= int(m / 3)
		ans = math.factorial(nn+ mm) / math.factorial(nn) * math.factorial(mm)
		ans = int(ans % ((10**9) + 7))

print(ans)
Problem p02935 (python)

Fixed submission:
n=int(input())
v=list(map(int, input().split()))
v.sort()
s=0
while(len(v)>1):
    v0=v.pop(0)
    v1=v.pop(0)
    v.append((v0+v1)/2)
    v.sort()
print(v[0])

Buggy submission (verdict: Runtime Error):
n=input()
v=[]
for i in range(n):
  v.append(input())
v.sort()
s=0
while(len(v)>1):
    v0=v.pop(0)
    v1=v.pop(0)
    v.append((v0+v1)/2)
    v.sort()
print(v[0])
Problem p02847 (python)

Fixed submission:
str = input()
if str == 'SUN':
  print(7)
elif str == 'MON':
  print(6)
elif str == 'TUE':
  print(5)
elif str == 'WED':
  print(4)
elif str == 'THU':
  print(3)
elif str == 'FRI' :
  print(2)
elif str == 'SAT':
  print(1)

Buggy submission (verdict: Runtime Error):
inputStr = input().split()
intA = int(inputStr[0])
intB = int(inputStr[1])
intX = int(inputStr[2])

intN = 0
sum = 0

while(sum < intX):
  sum = intA * intN + intB * len(str(intN))
  intN+=1

print(intN - 2)
Problem p02847 (python)

Fixed submission:
def main():
  mapping = {
    "SUN": 0,
    "MON": 1,
    "TUE": 2,
    "WED": 3,
    "THU": 4,
    "FRI": 5,
    "SAT": 6,
  }
 
 
  S = input()
  print(7-mapping[S])
 
if __name__ == '__main__':
  main()

Buggy submission (verdict: Runtime Error):
mapping = {
  "SUN": 0,
  "MON": 1,
  "TUE": 2,
  "WED": 3,
  "THU": 4,
  "FRI": 5,
  "SAT": 6,
}


S = input()
return 7-mapping[S]
Problem p02933 (python)

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

if a>=3200:
  print(s)
elif a<3200:
  print('red')

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

if a>=3200:
  print(s)
else if a<3200:
  print('red')
Problem p03036 (python)

Fixed submission:
r,d,x = map(int,input().split())

for i in range(10):
  s = r*x-d
  print(s)
  x = s

Buggy submission (verdict: Runtime Error):
a,d,x = map(int,input().split())

for i in range(10):
  s = r*x-d
  print(s)
  x = s
Problem p02881 (python)

Fixed submission:
import sys
import math

n = int(input())
ans = 0

for i in range(int(math.sqrt(n)), 0, -1):
    if n%i is 0:
        ans = int(n/i + i - 2)
        break
if ans is not 0:
    print(ans)
else:
    print(n-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = 0
b = 0

for i in range(1, n+1):
    if n%i = 0:
        if a == n/i:
            b = i
        else:
            a = i

print(a+b-2)
Problem p03207 (python)

Fixed submission:
n = int(input())
p = list(map(int, [input() for i in range(n)]))

print(int(sum(p)-max(p)/2))

Buggy submission (verdict: Runtime Error):
n = int(input())
p = [map(int, input()) for i in range(n)]

print(sum(p)-int(max(d)/2))
Problem p03208 (python)

Fixed submission:
N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
print(min(h[i+K-1] - h[i] for i in range(N-K+1)))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
h = sorted(list(map(int, [input() for i in range(n)])))
ans = h[n-1]
for j in range(n-k+1):
    ans = min(ans, (h[j+k]-h[j]))
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
2 h = [int(input()) for i in range(N)]
3 h.sort()
4 print(min(h[i+K-1] - h[i] for i in range(N-K+1)))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
h = list(map(int, [input() for i in range(n)])).sort()
dif = []
for j in range(n-k+1):
  dif.appned(max(h[j:j+k-1])-min(h[j:j+k-1]))
print(min(dif))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
h = list(map(int, [input() for i in range(n)])).sort()
dif = []
for j in range(n-k+1):
  dif.appned(max(h[i:i+k-1])-min(h[i:i+k-1]))
print(min(dif))
Problem p03208 (python)

Fixed submission:
NK = list(map(int, input().split()))
a = [0]*NK[0]
for i in range(len(a)):
    a[i] = int(input())
a.sort()
N = NK[0]
K = NK[1]

minimum = a[N-1]
for i in range(N-K+1):
    offset = a[i+K-1] - a[i]
    if minimum > offset:
        minimum = offset

print(minimum)

Buggy submission (verdict: Runtime Error):
NK = list(map(int, input().split()))
a = [0]*NK[0]
for i in range(len(a)):
    a[i] = int(input())
a.sort()

b = [0]*NK[1]
offsets = [0]*(NK[0]-NK[1]+1)
for i in range(len(offsets)):
    for j in range(NK[1]):
        b[j] = a[i+j]
    offsets[i] = b[K-1] - b[0]

print(min(offsets))
Problem p02847 (python)

Fixed submission:
str = input()
 
day = {"MON":1, "TUE":2, "WED":3, "THU":4, "FRI":5, "SAT":6, "SUN":7}
 
if str == "SUN":
    print(7)
else:
    print(day["SUN"] - day[str])

Buggy submission (verdict: Runtime Error):
str = input()

day = {"MON":1, "TUE":2, "WED":3, "THU":4, "FRI":5, "SAT":6 "SUN":7}

print(day["SUN"]() - day[str]())
Problem p02897 (python)

Fixed submission:
N = int(input())
ans =0
for i in range(N+1):
    if i%2 != 0:
        ans += 1
print(ans/N)

Buggy submission (verdict: Runtime Error):
N=int(input())
nums = [int(x) for x in input().split()]

ans = [0]*N
for i in nums:
    ans[i-1] = nums.index(i)+1

print(*ans)
Problem p02860 (python)

Fixed submission:
N = int(input())
S = str(input())
if S[0:N//2] * 2 == S:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = str(input())
if N % 2 != 0:
    print("No")
if S[0:N/2] * 2 == S:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = str(input())
if S[0:N * 0.5] * 2 == S:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = str(input())
if S[0:N/2] * 2 == S:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = str(input())
if S[0:N/2] * 2 = S:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = int(input())
if S[0:N/2] * 2 = S:
    print("Yes")
else:
    print("No")
Problem p02879 (python)

Fixed submission:
A, B = map(int, input().split(" "))
if 1 <= A <= 9 and 1 <= B <= 9:
    print(A * B)
else:
    print("-1")

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split(" "))
if 1 <= A, B <= 9:
    print(A * B)
else:
    print("-1")
Problem p03041 (python)

Fixed submission:
N, K = map(int, input().split())
S = list(input())
if S[K - 1] == "A":
    S[K - 1] = "a"
    print("".join(S))
elif S[K - 1] == "B":
    S[K - 1] = "b"
    print("".join(S))
else:
    S[K - 1] = "c"
    print("".join(S))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = str(input())
if S[K - 1] == "A":
    S[K - 1] = "a"
    print("".join(S))
elif S[K - 1] == "B":
    S[K - 1] = "b"
    print("".join(S))
else:
    S[K - 1] = "c"
    print("".join(S))

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = str(input())
if S[K - 1] == "A":
    S[K - 1] = "a"
    print(S)
elif S[K - 1] == "B":
    S[K - 1] = "b"
    print(S)
else:
    S[K - 1] = "c"
    print(S)
Problem p02847 (python)

Fixed submission:
S = input()

mydict = {"SUN":7, "MON":6, "TUE":5, "WED":4, "THU":3, "FRI":2, "SAT":1} 

O = mydict[S]

print(O)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()

ns = []

for ch in S:
        
    if ('A' <= ch and ch <= 'Z'):
        ns.append(chr((ord(ch) - ord('A') + N) % 26 + ord('A')))

O = "".join(ns)
print(O)
Problem p02881 (python)

Fixed submission:
N=int(input())
c=0
d=10000000000000
rN=int(N**0.5)

for i in range(rN):
    if (N%(i+1)==0) :
        x=i+1
        y=int(N/(i+1))
        if d>(x+y):
            d=x+y

print(d-2)

Buggy submission (verdict: Runtime Error):
N=int(input())
c=0
rN=int(N**0.5)+1

for i in range(rN):
    xi = rN - i
    for j in range(N-xi) :
        yj= xi+j
        if ((xi)*(yj))==N:
            x=xi
            y=yj
            c=1
            break
    if c==1:break


d=x+y-2

print(d)

Buggy submission (verdict: Runtime Error):
N=int(input())
c=0
INF=2000000
x=[]
y=[]

rN=int(N**0.5)

for i in range(rN):
    if (i>1)&(i%2==1) : continue
    xi = rN - i
    for j in range(rN-i) :
        yj= rN - j
        if ((xi)*(yj))==N:
            x=xi
            y=yj
            C=1
            break
    if c==1:break


d=x+y-2
print(d)
Problem p02859 (python)

Fixed submission:
r=int(input())
print(r**2)

Buggy submission (verdict: Runtime Error):

r=input()
print(r**2)
Problem p02955 (python)

Fixed submission:
#56 ABC136E
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=sum(a)

res=[]
for d in range(1,int(s**0.5)+1):
	if s%d==0:
		res.append(d)
		res.append(s//d)
ans=[]
for d in res:
	r1=[t%d for t in a]
	r1.sort()
	r2=[(d-t)%d for t in r1]
	r2=r2[::-1]
	x=[r1[0]]
	_=[x.append(x[-1]+r1[i]) for i in range(1,n)]
	y=[r2[0]]
	_=[y.append(y[-1]+r2[i]) for i in range(1,n)]
	#print(r1,r2,d,x,y)
	for i in range(n-1):
		#print(x[i],y[-i-2])
		if x[i]==y[-i-2] and x[i]<=k:
			ans.append(d)
			break
print(max(ans))

Buggy submission (verdict: Runtime Error):
#56 ABC136E
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=sum(a)

res=[]
for d in range(1,int(s**0.5)+1):
	if s%d==0:
		res.append(d)
		res.append(s//d)
ans=[]
for d in res:
	r1=[t%d for t in a]
	r1.sort()
	r2=[d-t for t in r1]
	r2=r2[::-1]
	x=[r1[0]]
	_=[x.append(x[-1]+r1[i]) for i in range(1,n)]
	y=[r2[0]]
	_=[y.append(y[-1]+r2[i]) for i in range(1,n)]
	#print(r1,r2,d,x,y)
	for i in range(n-1):
		#print(x[i],y[-i-2])
		if x[i]==y[-i-2] and x[i]<k:
			ans.append(d)
print(max(ans))
Problem p02990 (python)

Fixed submission:
#41 ABC132D
n,k=map(int,input().split())

c=[[0 for i in range(j+1)] for j in range(n+1)]
c[0][0]=1
for i in range(1,n+1):
	for j in range(i+1):
		if j==0:
			c[i][j]=c[i-1][j]
		elif j==i:
			c[i][j]=c[i-1][j-1]
		else:
			c[i][j]=c[i-1][j]+c[i-1][j-1]
for i in range(1,k+1):
	try:
		print(c[n-k+1][i]*c[k-1][i-1]%(10**9+7))
	except:
		print(0)

Buggy submission (verdict: Runtime Error):
#41 ABC132D
n,k=map(int,input().split())

c=[[0 for i in range(j+1)] for j in range(n+1)]
c[0][0]=1
for i in range(1,n+1):
	for j in range(i+1):
		if j==0:
			c[i][j]=c[i-1][j]
		elif j==i:
			c[i][j]=c[i-1][j-1]
		else:
			c[i][j]=c[i-1][j]+c[i-1][j-1]
for i in range(1,k+1):
	print(c[n-k+1][i]*c[k-1][i-1]%(10**9+7))
Problem p03038 (python)

Fixed submission:
#36 ABC127D
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
bc=[list(map(int,input().split())) for _ in range(m)]
bc=sorted(bc, key=lambda x:-x[1])

i=0
for b,c in bc:
	while(i<n and a[i]<c and b>0):
		a[i]=c
		b-=1
		i+=1
print(sum(a))

Buggy submission (verdict: Runtime Error):
#36 ABC127D
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
bc=[list(map(int,input().split())) for _ in range(m)]
bc=sorted(bc, key=lambda x:-x[1])

i=0
for b,c in bc:
	while(a[i]<c and b>0 and i<n):
		a[i]=c
		b-=1
		i+=1
print(sum(a))

Buggy submission (verdict: Runtime Error):
#36 ABC127D
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
bc=[list(map(int,input().split())) for _ in range(m)]
bc=sorted(bc, key=lambda x:-x[1])

i=0
for b,c in bc:
	if i==n:
		break
	while(a[i]<c and b>0):
		a[i]=c
		b-=1
		i+=1
print(sum(a))
Problem p03253 (python)

Fixed submission:
import collections
def com(x,y):
    y=min(y,x-y)
    a=1
    for i in range(x,x-y,-1):
        a*=i
    b=1
    for i in range(1,y+1):
        b*=i
    return a//b
n,m=map(int,input().split())
y=[]
i=2
z=m
while(i*i<=m):
    if m%i:
        i+=1
    else:
        m//=i
        y.append(i)
if m>1:
    y.append(m)
c=collections.Counter(y).values()
ans=1
mod=10**9+7
for t in c:
    ans*=com(t+n-1,t)
    ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
def kaijo(x):
    a=1
    for i in range(1,x+1):
        a*=i
    return a
def perm(x,y):
    ans=1
    for i in range(x,x-y,-1):
        ans*=i
    return ans
def com(x,y):
    return perm(x,min(y,x-y))//kaijo(min(y,x-y))

nn,m=map(int,input().split())
x=primes(int(m**0.5+1))
y=[]
z=m
t=1
while(t**2<=m):
    t+=1
    while(z%t==0):
        y.append(t)
        z//=t
if len(y)==0 and m>1:
    y.append(m)
c=collections.Counter(y).values()
ans=1
mod=10**9+7
for t in c:
    ans*=com(t+nn-1,t)
    ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
def kaijo(x):
    a=1
    for i in range(1,x+1):
        a*=i
    return a
def perm(x,y):
    ans=1
    for i in range(x,x-y,-1):
        ans*=i
    return ans
def com(x,y):
    return perm(x,min(y,x-y))//kaijo(min(y,x-y))

nn,m=map(int,input().split())
x=primes(int(m**0.5+1))
y=[]
z=m
for t in x:
    while(z%t==0):
        z//=t
        y.append(t)
c=list(collections.Counter(y).values())

ans=1
for t in c:
    ans*=com(t+nn-1,t)
    ans%=mod
print(ans)