Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):

strings=[input() for string in range(2)]
string=strings[0]
num=int(strings[1])
i=0
check=True

while check:
    s=string[i:i+num]
    if len(s)<num:
        check=False
    print(s)
    i=i+num

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

check=0
if a[0]+a[1]==15:
    check=1
elif a[0]*a[1]==15:
    check=2

if check==1:
    print("+")
elif check==2:
    print("*")
else:
    print("x")

Buggy python submission (verdict: Runtime Error):

a=int(input().split())
check=0
if a[0]+a[1]==15:
    check=1
elif a[0]*a[1]=15:
    check=2

if check==1:
    print("+")
elif check==2:
    print("*")
else:
    print("x")


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

check=0
if a[0]+a[1]==15:
    check=1
elif a[0]*a[1]==15:
    check=2

if check==1:
    print("+")
elif check==2:
    print("*")
else:
    print("x")

Buggy python submission (verdict: Runtime Error):
# coding: UTF-8
num = (raw_input("")).split("")
if (num[0] * num[1]) == 15:
    print "*"
el if (num[0] + num[1]) == 15:
    print "+"
else:
    print "x"


Fixed submission:
# coding: UTF-8
num = (raw_input("")).split()
x = (int(num[0]) * int(num[1]))
y = (int(num[0]) + int(num[1]))
if x == 15:
    print "*"
elif y == 15:
    print "+"
else:
    print "x"

Buggy python submission (verdict: Runtime Error):
# coding: UTF-8
num = (raw_input("")).split("")
if num[0]*num[1] == 15:
    print "*"
el if num[0]+num[1] == 15:
    print "+"
else:
    print "x"

Fixed submission:
# coding: UTF-8
num = (raw_input("")).split()
x = (int(num[0]) * int(num[1]))
y = (int(num[0]) + int(num[1]))
if x == 15:
    print "*"
elif y == 15:
    print "+"
else:
    print "x"
Buggy python submission (verdict: Runtime Error):
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(a):
    s = 0
    for b in str(a):
        s += int(b)
    if a%s==0:
        return "Yes"
    else:
        return "No"
        
# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return line

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()

Fixed submission:
import sys

# 関数 solve は，もちろん，問題に応じて書き換える
def solve(a):
    s = 0
    for b in str(a):
        s += int(b)
    if a%s==0:
        return "Yes"
    else:
        return "No"
# ここから下は，入力・出力形式が同じであれば，変えなくて良い．
def readQuestion():
    line = sys.stdin.readline().rstrip()
    return int(line)

def main():
    n = readQuestion()
    answer = solve(n)
    print(answer)
    
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate

def S(a, b):
    return cl[b] - (0 if a == 0 else cl[a-1])

def partial(start, end, last):
    odiff = None
    for c in range(start, end+1):
        p = S(start,c)
        q = S(c+1,end)
        diff = abs(p-q)
        if odiff is None:
            odiff = diff
        if odiff < diff:
            return c, mp, mq
        odiff = diff
        mp = p
        mq = q

if __name__ == '__main__':
    # read input
    n = int(input())
    l = list(map(int, input().split()))
    # create cumlative list first
    cl = list(accumulate(l))
    clen = len(l)

    #  0  F(i)      i i+1 G(i)      len-1
    #  |------|------|-------|-------|
    #         c0    c1       c2
    #  <-----L------> <------R------->
    # pick up a c1 (i:i+1) and evaluate
    result = None
    c1 = 1
    c3 = 3
    for i in range(1,clen-2):
        # LEFT
        (c1, mb, mc) = partial(0, i, c1)
        # RIGHT
        c3, md, me = partial(i+1, clen-1, c3)

        # evaluate
        diff = abs(max(mb, mc, md, me) - min(mb, mc, md, me))
        if result is None:
            result = diff
        else:
            if result > diff:
                result = diff

    print(result)

Fixed submission:
def gcd(a, b):
    while (b > 0):
        a, b = b, a%b
    return a

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

if __name__ == '__main__':
    r = int(input())
    print(lcm(2, r))
Buggy python submission (verdict: Runtime Error):
def sadness(l, b):
    sad = 0
    for i, a in enumerate(l, 1):
        sad += abs(a - (b+i))
    return sad

if __name__ == '__main__':
    n = int(input())
    l = list(map(int, input().split()))

    # y=x+b
    # rough estimate
    if len(l) > 5:
        ls = l[0:5]

    diffset = set()
    for i, a in enumerate(l, 1):
        #print("{} {}".format(i, a))
        diff = i-a
        diffset.add(diff)

    s = set()
    for i in range(max(diffset)+1):
        s.add(sadness(l, i*-1))
    if max(diffset) == 0:
        s.add(sadness(l, 0))

    print("{}".format(min(s)))

Fixed submission:
import numpy as np
def sadness(l, b):
    sad = 0
    for a in l:
        sad += abs(a - b)
    return int(sad)

if __name__ == '__main__':
    n = int(input())
    l = list(map(int, input().split()))
    if n == 1:
        print('0')
        exit()

    for i in range(len(l)):
        l[i] -= (i+1)
    nl = np.array(l)
    nl.sort()
    m = np.median(nl)

    s = sadness(l, m)
    print("{}".format(s))
Buggy python submission (verdict: Runtime Error):

A = int(input())
B = int(input())

if A<9 and B< 9:
    print("Yay!")
else:
    print(":(")

Fixed submission:

A, B = map(int,input().split())
if A<9 and B< 9:
    print("Yay!")
else:
    print(":(")
Buggy python submission (verdict: Time Limit Exceeded):

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

a = N


for i in range(N):
    X = S[:i]
    Y = S[i+1:]
    a = min(X.count("W")+Y.count("E"),a)
    
print(a)
    

Fixed submission:

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

a = []
t = 0
for i,s in enumerate(S):
    if s == "E":
        t += 1
        a.append(t)
    else:
        t -= 1
        a.append(t)

index = a.index(max(a))

X = S[:index]
Y = S[index+1:]

print(X.count("W")+Y.count("E"))
Buggy python submission (verdict: Runtime Error):

X = int(input())

lim = int(X**(1/2))

listx =[]

for i in range(lim+1):
    if i == 0 or i ==1:
        continue
    a = i
    p = 0
    while a < X:
        a = i ** p
        p += 1
    listx.append(i**(p-2))

print(max(listx))
        

Fixed submission:
import sys
X = int(input())

lim = int(X**(1/2))

listx =[]

if X == 1 or X == 2 or X ==3:
    print(1)
    sys.exit()

if X >= 4 and X <= 8:
    print(4)
    sys.exit()

for i in range(lim+1):
    if i == 0 or i ==1:
        continue
    a = i
    p = 0
    while a <= X:
        a = i ** p
        p += 1
    listx.append(i**(p-2))

print(max(listx))
Buggy python submission (verdict: Runtime Error):
a,b = input().split()

if a>b:
    print(a-1)
else:
    print(a)

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

if a>b:
    print(a-1)
else:
    print(a)

Buggy python submission (verdict: Runtime Error):
a = input()
b = input()

if a>b:
    print(a-1)
else:
    print(a)

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

if a>b:
    print(a-1)
else:
    print(a)
Buggy python submission (verdict: Runtime Error):
import collections

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

S = [0]

def comb(n,r):
    if n < 0 or r < 0 or n < r: 
        return 0
    elif n == 0 or r == 0: 
        return 1
    return comb(n-1,r-1)+comb(n-1,r)

for i in A:
    S.append(S[-1] + i)

count = 0
count_dict = collections.Counter(S)
for i in count_dict.values():
    count += comb(i,2)
print(count)

Fixed submission:
from math import factorial
from collections import Counter

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

S = [0]

for i in A:
    S.append(S[-1] + i)

count = 0
count_dict = Counter(S)
for i in count_dict.values():
    if i == 1:
        continue
    count += factorial(i) // (factorial(i - 2) * factorial(2))
print(count)

Buggy python submission (verdict: Time Limit Exceeded):

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

S = [0]

for i in A:
    S.append(S[-1] + i)

S.sort()

count = 0
for i,s in enumerate(S):
    for j in range(len(S)-i-1):
        if s == S[i+j+1]:
            count += 1
        else: break
    
print(count)

Fixed submission:
from math import factorial
from collections import Counter

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

S = [0]

for i in A:
    S.append(S[-1] + i)

count = 0
count_dict = Counter(S)
for i in count_dict.values():
    if i == 1:
        continue
    count += factorial(i) // (factorial(i - 2) * factorial(2))
print(count)
Buggy python submission (verdict: Runtime Error):
from statistics import median
N = int(input())
X = list(map(int, input.split()))

Y = X + [0]
Z = X + [10*9+1]

ymed = median(ymed)
zmed = median(zmed)

if ymed == zmed:
  for _ in range(N):
    print(ymed)
else:
  for i in X:
    if i <= ymed:
      print(zmed)
    else:
      print(ymed)

Fixed submission:
from statistics import median
N = int(input())
X = list(map(int, input().split()))

Y = X + [0]
Z = X + [10**9 + 1]

ymed = median(Y)
zmed = median(Z)

if ymed == zmed:
    for _ in range(N):
        print(ymed)
else:
    for i in X:
        if i <= ymed:
            print(zmed)
        else:
            print(ymed)
Buggy python submission (verdict: Runtime Error):
T = list(map(int, input().split()))
T.sort()
T.reverse()

ope = 0

while T[1]!=T[0]:
    ope += 1
    T[1] += 1
    T[2] += 1
    
while T[2]<T[0]:
    ope += 1
    T[2] += 2

if T[0]==T[2]:
    print(ope)
    
else:print(ope+1)T = list(map(int, input().split()))
T.sort()
T.reverse()

ope = 0

while T[1]!=T[0]:
    ope += 1
    T[1] += 1
    T[2] += 1
    
while T[2]<T[0]:
    ope += 1
    T[2] += 2

if T[0]==T[2]:
    print(ope)
    
else:print(ope+1)

Fixed submission:
T = list(map(int, input().split()))
T.sort()
T.reverse()

ope = 0

while T[1]!=T[0]:
    ope += 1
    T[1] += 1
    T[2] += 1
    
while T[2]<T[0]:
    ope += 1
    T[2] += 2

if T[0]==T[2]:
    print(ope)
    
else:print(ope+1)
Buggy python submission (verdict: Runtime Error):

N = int(input())

S = list(map(input().split()))

if "Y" in S:
    print("four")

else:
    print("three")

Fixed submission:
N = int(input())

S = list(map(str,input().split()))

if "Y" in S:
    print("Four")

else:
    print("Three")
Buggy python submission (verdict: Runtime Error):
import itertools

N = int(input())

S = []
for _ in range(N):
    S.append(input())
    
M, A, R, C, H = [], [], [], [], []

march = ["M","A","R","C","H"]

for s in S:
    top = s[0]
    if top in march:
        if top == "M":
            M.append(s)
        elif top == "A":
            A.append(s)
        elif top == "R":
            R.append(s)
        elif top == "C":
            C.append(s)
        elif top == "H":
            H.append(s)

MARCH = [len(M), len(A), len(R), len(C), len(H)]

for i in range(len(MARCH)):
    if MARCH[i] == 0:
        del march[i]

if len(march) <= 2:
    print(0)

else:
    x = 0
    pattern = list(itertools.combinations(MARCH, 3))
    for i in pattern:
        x += i[0]*i[1]*i[2]
    print(x)
    

Fixed submission:
import itertools

N = int(input())

S = []
for _ in range(N):
    S.append(input())
    
M, A, R, C, H = [], [], [], [], []

march = ["M","A","R","C","H"]

for s in S:
    top = s[0]
    if top in march:
        if top == "M":
            M.append(s)
        elif top == "A":
            A.append(s)
        elif top == "R":
            R.append(s)
        elif top == "C":
            C.append(s)
        elif top == "H":
            H.append(s)

MARCH = [len(M), len(A), len(R), len(C), len(H)]

if MARCH.count(0) >= 3:
    print(0)

else:
    x = 0
    pattern = list(itertools.combinations(MARCH, 3))
    for i in pattern:
        x += i[0]*i[1]*i[2]
    print(x)
Buggy python submission (verdict: Time Limit Exceeded):

N, H = map(int, input().split())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

attack = 0

FWA = max(A)
FW = A.index(max(A))
D = max(B)
FA = 0

while FWA < D:
    W = B.index(D)
    if FW == W:
        FA = D
        B[W] = 0
        D = max(B)
        continue
    H -= D
    attack += 1
    B[W] = 0
    D = max(B)

if FWA >= FA:
    attack += H // FWA
    if H % FWA > 0:
        attack += 1
else:
    H -= FA
    attack += H // FWA + 1
    if H % FWA > 0:
        attack += 1
    
print(attack)
 


Fixed submission:
import sys
N, H = map(int, input().split())
A, B = [], []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

attack = 0

FWA = max(A)
B.append(0)
B.sort()

while True: 
    D = B.pop()
    if FWA >= D:
        break
    H -= D
    attack += 1
    if H <= 0:
        print(attack)
        sys.exit()

attack += H // FWA
if H % FWA > 0:
    attack += 1

print(attack)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, raw_input().split())
a={}
b={}
for i in range(M):
    k,l=map(int, raw_input().split())
    if k==1:
        a.add(k)
    if l==N:
        b.add(l)
if a&b:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Fixed submission:
x=input()
print("ABC"+str(x))

Buggy python submission (verdict: Runtime Error):
N, M = map(int, raw_input().split())
a={}
b={}
for i in range(M):
    k,l=a.append(map(int, raw_input().split()))
    if k==1:
        a.add(k)
    if l==1: 
        b.add(l)
if a&b: 
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Fixed submission:
x=input()
print("ABC"+str(x))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
a={}
b={}
for i in range(M):
    k,l=map(int, input().split())
    if k==1:
        a.add(k)
    if l==N:
        b.add(l)
if a&b:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Fixed submission:
N, M = map(int, input().split())
a=set()
b=set()
for i in range(M):
    k,l=map(int, input().split())
    if k==1:
        a.add(l)
    if l==N:
        b.add(k)
if a&b:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
N, M = map(int, raw_input().split())
a={}
b={}
for i in range(M):
    k,l=map(int, raw_input().split())
    if k==1:
        a.add(k)
    if l==N:
        b.add(l)
if a&b:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Fixed submission:
N, M = map(int, input().split())
a=set()
b=set()
for i in range(M):
    k,l=map(int, input().split())
    if k==1:
        a.add(l)
    if l==N:
        b.add(k)
if a&b:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
N, M = map(int, raw_input().split())
a={}
b={}
for i in range(M):
    k,l=map(int, raw_input().split())
    if k==1:
        a.add(k)
    if l==1: 
        b.add(l)
if a&b: 
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Fixed submission:
N, M = map(int, input().split())
a=set()
b=set()
for i in range(M):
    k,l=map(int, input().split())
    if k==1:
        a.add(l)
    if l==N:
        b.add(k)
if a&b:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
N, M = map(int, raw_input().split())
a={}
b={}
for i in range(M):
    k,l=a.append(map(int, raw_input().split()))
    if k==1:
        a.add(k)
    if l==1: 
        b.add(l)
if a&b: 
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Fixed submission:
N, M = map(int, input().split())
a=set()
b=set()
for i in range(M):
    k,l=map(int, input().split())
    if k==1:
        a.add(l)
    if l==N:
        b.add(k)
if a&b:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
N = int(input())
a_li = list(map(int,input().split()))
     
cnt = 0
for i in a_li:
    while i % 2 == 0:
        cnt += 1
        i //= 2
        if i % 2 != 0:
            break
     
print(cnt)

Fixed submission:
a, b = (int(i) for i in input().split())
if a > 8 or b > 8:
  print(':(')
else:
  print('Yay!')
Buggy python submission (verdict: Runtime Error):
    N = int(input())
    a_li = list(map(int,input().split()))
     
    count = 0
    for i in a_li:
        while i % 2 == 0:
            cnt += 1
            i //= 2
            if i % 2 != 0:
                break
     
    print(count)

Fixed submission:
N = int(input())
a_li = list(map(int,input().split()))
         
cnt = 0
for i in a_li:
    while i % 2 == 0:
        cnt += 1
        i //= 2
        if i % 2 != 0:
            break
        
print(cnt)

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


count = 0
i=0
while(i <= len(a)):
    if a[i] % 2 == 0:
        count += 1
        a[i] = int(a[i] // 2)
        continue
    else:
        i += 1

print(count)

Fixed submission:
N = int(input())
a_li = list(map(int,input().split()))
         
cnt = 0
for i in a_li:
    while i % 2 == 0:
        cnt += 1
        i //= 2
        if i % 2 != 0:
            break
        
print(cnt)

Buggy python submission (verdict: Runtime Error):
count = 0
i=0
while(i < len(a)):
    if a[i] % 2 == 0:
        count += 1
        a[i] = int(a[i] // 2)
        continue
    else:
        i += 1

print(count)        

Fixed submission:
N = int(input())
a_li = list(map(int,input().split()))
         
cnt = 0
for i in a_li:
    while i % 2 == 0:
        cnt += 1
        i //= 2
        if i % 2 != 0:
            break
        
print(cnt)

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


count = 0



while(True):
    even_count = 0
    even_index = 0
    for i in range(len(a)):
        if a[i] % 2 == 0:
            even_index = i
            even_count += 1

    if even_count >= 1:
        count += 1
        a[even_index] = int(a[even_index] / 2)
    else:
        break

print(count)

Fixed submission:
N = int(input())
a_li = list(map(int,input().split()))
         
cnt = 0
for i in a_li:
    while i % 2 == 0:
        cnt += 1
        i //= 2
        if i % 2 != 0:
            break
        
print(cnt)

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


count = 0



while(True):
    even_count = 0
    even_index = 0
    for i in range(len(i)):
        if a[i] % 2 == 0:
            even_index = i
            even_count += 1

    if even_count >= 2:
        count += 1
        a[even_index] = int(a[even_index] / 2)
    else:
        break

print(count)

Fixed submission:
N = int(input())
a_li = list(map(int,input().split()))
         
cnt = 0
for i in a_li:
    while i % 2 == 0:
        cnt += 1
        i //= 2
        if i % 2 != 0:
            break
        
print(cnt)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n,k = map(int, input().split())
a = input().split()
c = Counter(a)
t = len(c) - k
r = 0

if t > 0:
    serial = c.most_common[-t:]
    for s in serial:
        r += s[1]

print(r)

Fixed submission:
from collections import Counter

n,k = map(int, input().split())
a = input().split()
c = Counter(a)
t = len(c) - k
r = 0

if t > 0:
    serial = c.most_common()[-t:]
    for s in serial:
        r += s[1]

print(r)

Buggy python submission (verdict: Runtime Error):
from collections import Counter

n,k = map(int, input().split())
a = input().split()
c = Counter(a)
t = len(c) - k
r = 0

if t > 0:
    serial = list(map(list, c.most_common[-t:]))
    for s in serial:
        r += s[1]

print(r)

Fixed submission:
from collections import Counter

n,k = map(int, input().split())
a = input().split()
c = Counter(a)
t = len(c) - k
r = 0

if t > 0:
    serial = c.most_common()[-t:]
    for s in serial:
        r += s[1]

print(r)

Buggy python submission (verdict: Runtime Error):
from collections import Counter

n,k = map(int, input().split())
a = [input() for _ in range(n)]
c = Counter(a)
t = len(c) - k
r = 0

if t > 0:
    serial = list(map(list, c.most_common[-t:]))
    for s in serial:
        r += s[1]

print(r)

Fixed submission:
from collections import Counter

n,k = map(int, input().split())
a = input().split()
c = Counter(a)
t = len(c) - k
r = 0

if t > 0:
    serial = c.most_common()[-t:]
    for s in serial:
        r += s[1]

print(r)
Buggy python submission (verdict: Runtime Error):
q,h,s,d = int(input().strip().split())
n = int(input())

h = min(h, q*2)
s = min(s, h*2)
d = min(d, s*2)

d_num, s_num = n//2, n%2
cost = d_num*d + s_num*s
print(cost)

Fixed submission:
q,h,s,d = list(map(int, input().strip().split()))
n = int(input())

h = min(h, q*2)
s = min(s, h*2)
d = min(d, s*2)

d_num, s_num = n//2, n%2
cost = d_num*d + s_num*s
print(cost)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

s = sum(A) - N*(N-1)
m = sum(list(map(lambda x: (x+s)//N, A)))
while m > s:
    s = m
    m = sum(list(map(lambda x: (x+s)//N, A)))
else:
    print(m)

Fixed submission:
N, M = map(int,input().split())
route_1 = set()
route_N = set()

for _ in range(M):
    a, b = map(int,input().split())
    if a == 1:
        route_1.add(b)
    elif b == N:
        route_N.add(a)

if route_1&route_N:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

s = sum(A) - N*(N-1)
m = list(map(lambda x: (x+s)//N, A))
while m > s:
    s = m
    m = list(map(lambda x: (x+s)//N, A))
else:
    print(m)

Fixed submission:
N, M = map(int,input().split())
route_1 = set()
route_N = set()

for _ in range(M):
    a, b = map(int,input().split())
    if a == 1:
        route_1.add(b)
    elif b == N:
        route_N.add(a)

if route_1&route_N:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

if a+b=15:
    print('+')

elif:
    a*b=15
    print('*')

else:
    print('×')

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

if a + b == 15:
    print('+')
elif a*b==15:
    print('*')
else:
    print('x')
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

n = int(input())
m = int(input())
d = int(input())

if n < d:
    print(0.00000)
    exit()

print((m-d)/n)

Fixed submission:
# -*- coding: utf-8 -*-

s = input().split()
n = int(s[0])
m = int(s[1])
d = int(s[2])

if d==0:
    print(1.0*n*(m-1)/n/n)
else:
    print(2.0*(n-d)*(m-1)/n/n)