Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a=int(input)
b=int(input)
c=int(input)
print(a*b*c//2)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
print((a+b)*c//2)

Buggy python submission (verdict: Runtime Error):
a=int(input)
b=int(input)
c=int(input)
print(a*b*h//2)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
print((a+b)*c//2)

Buggy python submission (verdict: Runtime Error):
a=int(input)
b=int(input)
c=int(input)
print(a*b*h///2)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
print((a+b)*c//2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = int(input())

red = 0
blue = 0
for _ in s:
  if _ == "B":
    blue += 1
  else:
    red += 1

if red > blue:
  print("Yes")
else:
  print("No")

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

red = 0
blue = 0
for _ in s:
  if _ == "B":
    blue += 1
  else:
    red += 1

if red > blue:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
data = [list(map(int,input().split())) for _ in range(m)]

s = None
for d in data:
  if s is None:
    s = set(d[1:])
  else:
    s = s & set(d[1:])
print(len(s))

Fixed submission:
n, m = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(n)]
s = None
for d in data:
    if s is None:
        s = set(d[1:])
    else:
        s = s & set(d[1:])
print(len(s))
Buggy python submission (verdict: Runtime Error):
from sys import stdin
 
n = int(stdin.readline().rstrip())
data = map(int, stdin.readline().rstrip().split())
 
def is_s(hens):
  m = max(hens)
  hens.remove(m)
  if m < sum(hens):
  	return True
  else:
    return False
 
print(is_s(data))

Fixed submission:
from sys import stdin
 
n = int(stdin.readline().rstrip())
data = list(map(int, stdin.readline().rstrip().split()))
 
def is_s(hens):
  m = max(hens)
  hens.remove(m)
  if m < sum(hens):
  	return "Yes"
  else:
    return "No"
 
print(is_s(data))

Buggy python submission (verdict: Runtime Error):
from sys import stdin

n = int(stdin.readline().rstrip())
data = map(int, stdin.readline().rstrip().split())

def is_s(hens):
  m = max(hens)
  hens.remove(m)
  if m < sum(hens):
  	return True
  else:
    return False

pritn(is_s(data))

Fixed submission:
from sys import stdin
 
n = int(stdin.readline().rstrip())
data = list(map(int, stdin.readline().rstrip().split()))
 
def is_s(hens):
  m = max(hens)
  hens.remove(m)
  if m < sum(hens):
  	return "Yes"
  else:
    return "No"
 
print(is_s(data))
Buggy python submission (verdict: Runtime Error):
S = input()
list = []
j = -1
for i in range(0, len(S)):
    if not(S[i]=="A" or S[i]=="C" or S[i]=="G" or S[i]=="T"):
        list.append(i-j-1)
        j = i
print("{}".format(max(list)))


Fixed submission:
S = input()
S = S+"0"
max = 0
j = -1
for i in range(0, len(S)):
    if not(S[i]=="A" or S[i]=="C" or S[i]=="G" or S[i]=="T"):
        if max<i-j-1:
            max = i-j-1
        j = i
print("{}".format(max))
Buggy python submission (verdict: Runtime Error):
N = int(input())
t0 = 0
x0 = 0
y0 = 0
for i in range(0, N):
    t1, x1, y1 = map(int, input().split())
    indicator = (t1-t0)-abs(x1-x0)-abs(y1-y0)
    if indicator<0 or indicator%2==1:
        print("No")
        break
    elif i==N-1:
        print("Yes")
        break
    t0 = t1
    x0 = x1
    y0 = y1


Fixed submission:
a, b = map(int, input().split())
if a*b%2==0:
    print("Even")
else:
    print("Odd")
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

X, Y, Z, K = (int(i) for i in input().split())
A = [int(i) for i in input().split()] 
B = [int(i) for i in input().split()] 
C = [int(i) for i in input().split()] 

A = sorted(A)[::-1][:K]
B = sorted(B)[::-1][:K]
C = sorted(C)[::-1][:K]

T = [A, B]
score = []
for cand in itertools.product(*T):
  score.append(sum(cand))
  
T = [sorted(score)[::-1][:K], C]
res = []
for cand in itertools.product(*T):
  res.append(sum(cand))

res = sorted(res)[::-1][:K]
for i in range(K):
    print(res[i])

Fixed submission:
import itertools

X, Y, Z, K = (int(i) for i in input().split())
A = [int(i) for i in input().split()] 
B = [int(i) for i in input().split()] 
C = [int(i) for i in input().split()] 

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

D = [a+b for a,b in itertools.product(A[:K], B[:K])]
D.sort(reverse=True)

E = [c+d for c,d in itertools.product(C[:K], D[:K])]
E.sort(reverse=True)

for i in range(K):
    print(E[i])

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

X, Y, Z, K = (int(i) for i in input().split())
A = [int(i) for i in input().split()] 
B = [int(i) for i in input().split()] 
C = [int(i) for i in input().split()] 

A = sorted(A)[::-1]
B = sorted(B)[::-1]
C = sorted(C)[::-1]

T = [A[:K], B[:K]]
score = []
for cand in itertools.product(*T):
  score.append(sum(cand))

score = sorted(score)[::-1][:K]
  
T = [score, C[:K]]
res = []
for cand in itertools.product(*T):
  res.append(sum(cand))

res = sorted(res)[::-1][:K]
for i in range(K):
    print(res[i])

Fixed submission:
import itertools

X, Y, Z, K = (int(i) for i in input().split())
A = [int(i) for i in input().split()] 
B = [int(i) for i in input().split()] 
C = [int(i) for i in input().split()] 

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

D = [a+b for a,b in itertools.product(A[:K], B[:K])]
D.sort(reverse=True)

E = [c+d for c,d in itertools.product(C[:K], D[:K])]
E.sort(reverse=True)

for i in range(K):
    print(E[i])

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

X, Y, Z, K = (int(i) for i in input().split())
A = [int(i) for i in input().split()] 
B = [int(i) for i in input().split()] 
C = [int(i) for i in input().split()] 

T = [A, B, C]
cand_list = itertools.product(*T)
score = []
for cand in cand_list:
  score.append(sum(cand))

score = sorted(score)[::-1]
for i in range(K):
	print(score[i])

Fixed submission:
import itertools

X, Y, Z, K = (int(i) for i in input().split())
A = [int(i) for i in input().split()] 
B = [int(i) for i in input().split()] 
C = [int(i) for i in input().split()] 

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

D = [a+b for a,b in itertools.product(A[:K], B[:K])]
D.sort(reverse=True)

E = [c+d for c,d in itertools.product(C[:K], D[:K])]
E.sort(reverse=True)

for i in range(K):
    print(E[i])
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = (int(i) for i in input().split())
S = input()

L = []
R = []
for i in range(Q):
    L, R = (int(i) for i in input().split())
    old_len = len(S)
    print(S[(L-1):R].count('AC'))

Fixed submission:
N, Q = (int(i) for i in input().split())
S = input()

counts = 0
totals = [0]
for i in range(1, N):
  if S[i-1] == 'A' and S[i] == 'C':
    counts += 1
  totals.append(counts)

L = []
R = []
for i in range(Q):
    L, R = (int(i) for i in input().split())
    print(totals[R-1] - totals[L-1])
Buggy python submission (verdict: Runtime Error):
INPUT = list(map(int, input().split))
A = INPUT[0]
B = INPUT[1]
C = INPUT[2]

if (B//A) > C:
    ANS = C
else:
    ANS = B//A

print(ANS)

Fixed submission:
A, B, C = (int(i) for i in input().split())  

if (B//A) > C:
    ANS = C
else:
    ANS = B//A

print(ANS)

Buggy python submission (verdict: Runtime Error):
INPUT = list(int, input().split)
A = INPUT[0]
B = INPUT[1]
C = INPUT[2]

if (B//A) > C:
    ANS = C
else:
    ANS = B//A

print(ANS)

Fixed submission:
A, B, C = (int(i) for i in input().split())  

if (B//A) > C:
    ANS = C
else:
    ANS = B//A

print(ANS)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
X = list(map(int, input().split()))
 
 
def mindist(XLIST):
    cand1 = abs(XLIST[0]) + abs(XLIST[0] - XLIST[-1])
    cand2 = abs(XLIST[-1]) + abs(XLIST[0] - XLIST[-1])
    return(min([cand1, cand2]))
 
dist = float('Inf')
for i in range(N - K + 1):
    dist_ = mindist(X[i:(i+K)])
    if (dist_ < dist):
        dist = dist_
 
print(dist)

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

dist = []
for i in range(N-K+1):
    dist.append(abs(X[i]) + abs(X[K+i-1]-X[i]))
    dist.append(abs(X[K+i-1]) + abs(X[i]-X[K+i-1]))

if not len(dist) == 0:
    print(min(dist))
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N, K = map(int, input().split())
X = list(map(int, input().split()))


def mindist(XLIST):
    cand1 = abs(XLIST[0]) + abs(XLIST[0] - XLIST[-1])
    cand2 = abs(XLIST[-1]) + abs(XLIST[0] - XLIST[-1])
    return(min([cand1, cand2]))

dist = float('Inf')
for i in range(N - K + 1):
    dist_ = mindist(X[i:(i+K)])
    if (dist_ < dist):
        dist = dist_

print(dist)

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

dist = []
for i in range(N-K+1):
    dist.append(abs(X[i]) + abs(X[K+i-1]-X[i]))
    dist.append(abs(X[K+i-1]) + abs(X[i]-X[K+i-1]))

if not len(dist) == 0:
    print(min(dist))
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N, K = map(int, input().split())
X = list(map(int, input().split()))


def mindist(XLIST):
    dist = float('Inf')
    for i in itertools.permutations(XLIST, len(XLIST)):
        dist_ = 0
        curx = 0
        for j in range(len(i)):
            dist_ += abs(i[j]-curx)
            curx = i[j]
        if (dist_ < dist):
            dist = dist_
    return(dist)

dist = float('Inf')
for i in range(N - K + 1):
    dist_ = mindist(X[i:(i+K)])
    if (dist_ < dist):
        dist = dist_

print(dist)


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

dist = []
for i in range(N-K+1):
    dist.append(abs(X[i]) + abs(X[K+i-1]-X[i]))
    dist.append(abs(X[K+i-1]) + abs(X[i]-X[K+i-1]))

if not len(dist) == 0:
    print(min(dist))
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N, K = map(int, input().split())
X = list(map(int, input().split()))


def mindist(XLIST):
    dist = float('Inf')
    for i in itertools.permutations(XLIST, len(XLIST)):
        dist_ = 0
        curx = 0
        for j in range(len(i)):
            dist_ += abs(i[j]-curx)
            curx = i[j]
        if (dist_ < dist):
            dist = dist_
    return(dist)

dist = float('Inf')
for i in itertools.combinations(X, K):
    dist_ = mindist(i)
    if (dist_ < dist):
        dist = dist_

print(dist)


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

dist = []
for i in range(N-K+1):
    dist.append(abs(X[i]) + abs(X[K+i-1]-X[i]))
    dist.append(abs(X[K+i-1]) + abs(X[i]-X[K+i-1]))

if not len(dist) == 0:
    print(min(dist))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())

# A, B = map(int, input().split())
print(A*B - A - B + 1)

Fixed submission:
A, B = map(int, input().split())
print(A*B - A - B + 1)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())

for i in range(len(S)):
    if (int(S[i]) == 1):
        continue
    if (int(S[i]) >= 2):
        ans = int(S[i])
    break

print(ans)


Fixed submission:
S = input()
K = int(input())

for i in range(K):
    if (int(S[i]) == 1):
        ans = int(S[i])
        continue
    if (int(S[i]) >= 2):
        ans = int(S[i])
    break

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

N = int(input())

A = list(map(int, input().split()))
X = np.zeros(N+1, dtype='int64')

for i in range(1,N+1): # 1 から N まで
    X[i] = X[i-1] + A[i-1]

ans = 0
for l in range(1,N+1): # 1 から N まで
    for r in range(l,N+1): # l から N まで
        if X[r] - X[l-1] == 0: ans += 1
print(ans)

Fixed submission:
import numpy as np

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

S = np.zeros(N+1, dtype='int64') # 累積和
D = {0: 1} # ディクショナリ（連想配列） 各値が何回出てくるか
for i in range(1,N+1): # 1 から N まで
    S[i] = S[i-1] + A[i-1]
    if S[i] in D: D[S[i]] += 1
    else: D[S[i]] = 1

ans = 0
for i in D:
    ans += int(D[i]*(D[i]-1)/2) # 同じ値を2つ選ぶ選び方
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
P = [list(input().split()) for i in range(N)] # list of [x, y, c] as string
ans = 0
for x0 in range(K * 2):
    for y0 in range(K):
        count = 0
        for i in range(N):
            x = int(P[i][0])
            y = int(P[i][1])
            c = P[i][2]
            f = 1 # 希望が叶うかどうかのフラグ
            if ((x - x0) % (K * 2)) in range(K):
                if ((y - y0) % (K * 2)) in range(K):
                    if c == "W":
                        f = 0
                else:
                    if c == "B":
                        f = 0
            else:
                if ((y - y0) % (K * 2)) in range(K):
                    if c == "B":
                        f = 0
                else:
                    if c == "W":
                        f = 0
            if f == 1:
                count += 1
        if count > ans:
            ans = count
print(ans)

Fixed submission:
import numpy as np

N, K = map(int, input().split())
_3K = 3 * K
_2K = 2 * K
G = np.zeros((_2K, _3K), dtype='int64') # 後から 2K * K に圧縮する
for _ in range(N):
    x, y, c = input().split()
    x, y = int(x), int(y)
    # 2K * 2K の黒の希望に置き換え
    if c == 'B':
        x = x % _2K
        y = y % _2K
    else:
        x = (x + K) % _2K
        y = y % _2K
    # さらに、 2K * K の黒の希望に圧縮する
    if (y >= K) and (x >= K):
        x -= K
        y -= K
    if (y >= K) and (x < K):
        x += K
        y -= K
    # 塗り方は右下がどのマスに来るかの 2K * K 通り
    # → 最終的に 2K * K のグリッドで表すことができる
    # 各希望を満たす塗り方は K * K 通り
    # → 2K * K のグリッド内の希望を満たす K * K マスに 1 を加算すれば、
    #   全希望の加算後には各マス＝各塗り方がいくつの希望を満たすかがわかる
    # K * K マスに 1 を加算するには o(K^2) かかってしまう
    # → いもす法を使う
    # 塗り方を 3K * 2K の範囲で考えて累積和をとった後、 2K * K の範囲に圧縮する
    G[y, x] += 1
    G[y+K, x+K] += 1
    G[y+K, x] -= 1
    G[y, x+K] -= 1

# 3K * 2K の範囲の累積和をとる
G = G.cumsum(axis=1).cumsum(axis=0)
# 2K * K の範囲に圧縮
G = G[:K, :_2K] + G[K:_2K, K:_3K] + np.concatenate((G[:K, _2K:_3K], G[K:_2K, :K]), axis=1)
ans = G.max()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

while True:
    if len(A) == 1:
        break
    max_i = A.index(max(A))
    min_i = A.index(min(A))
    life = A[max_i] % A[min_i]
    if life == 0:
        A.pop(max_i)
    else:
        A[max_i] = life

print(A[0])


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

while True:
    if len(A) == 1:
        break
    pop_i = []
    A.sort()
    for i in range(1, len(A)):
        life = A[i] % A[0]
        if life == 1:
            print(life)
            exit()
        else:
            A[i] = life
    A = [n for n in A if n > 0]

print(A[0])
Buggy python submission (verdict: Runtime Error):
a = int(input())                                                        
b = int(input())                                                        
c = int(input())                                                        
d = int(input())                                                        
e = int(input())                                                        
                                                                        
orders = [a, b, c, d, e]                                                
orders = list(map(str, orders))                                         
orders = sorted(orders, key=lambda x:int(x[-1]))                        
                                                                        
a = []                                                                  
b = []                                                                  
for order in orders:                                                    
    if order[-1] == "0":                                                
        a.append(int(order))                                            
    else:                                                               
        b.append(order)                                                 
                                                                        
o = sum(a) + int(b[0]) + sum([10-int(_b[-1])+int(_b) for _b in b[1:]])  
print(o) 

Fixed submission:
a = input()                                                             
b = input()                                                             
c = input()                                                             
d = input()                                                             
e = input()                                                             
                                                                        
orders = [a, b, c, d, e]                                                
orders = sorted(orders, key=lambda x:int(x[-1]))                        
                                                                        
a = []                                                                  
b = []                                                                  
for order in orders:                                                    
    if order[-1] == "0":                                                
        a.append(int(order))                                            
    else:                                                               
        b.append(order)                                                 
                                                                        
if len(a) == 5:                                                         
    o = sum(a)                                                          
else:                                                                   
    o = sum(a) + int(b[0]) + sum([10 - int(_b[-1])+int(_b) for _b in b[1:]])
print(o)
Buggy python submission (verdict: Runtime Error):
def main():
    N, K = map(int, input().split())
    h = [int(input()) for count in range(N)]
    h.sort()
    min_value = min(h[i + K - 1] - h[i] for i in range(N - K + 1))
    print(min_value)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    day = int(input())
    if day == 22:
        print('Christmas Eve Eve Eve')
    elif day == 23:
        print('Christmas Eve Eve')
    elif day == 24:
        print('Christmas Eve')
    elif day == 25:
        print('Christmas')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    N, K = map(int, input().split())
    h = [int(input()) for count in range(n)]
    h.sort()
    min_value = min(h[i + K - 1] - h[i] for i in range(N - K + 1))
    print(min_value)


if __name__ == '__main__':
    main()


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


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if b % a == 0:
  print (a + b)
else:
  print (b - a)

Fixed submission:
a, b = map(int, input().split(' '))
if b % a == 0:
  print (a + b)
else:
  print (b - a)
Buggy python submission (verdict: Runtime Error):
num, num_of_coordinates = map(int, input().split(" "))
coordinates = list(map(int, input().split(" ")))
total = 0
abs_distance = []
coordinates.sort()
for i in range(0, len(coordinates)-1):
  dist = abs(coordinates[i] - coordinates[i+1])
  total += dist
  abs_distance.append(dist)  

#でかいやつ順に並べる
abs_distance.sort()
abs_distance.reverse()
for i in range(num-1):
  total -= abs_distance[i]

print(total)

Fixed submission:
num, num_of_coordinates = map(int, input().split(" "))
if num >= num_of_coordinates:
  print ("0")
else:
  coordinates = list(map(int, input().split(" ")))
  total = 0
  abs_distance = []
  coordinates.sort()
  for i in range(0, len(coordinates)-1):
    dist = abs(coordinates[i] - coordinates[i+1])
    total += dist
    abs_distance.append(dist)  

  #でかいやつ順に並べる
  abs_distance.sort()
  abs_distance.reverse()
  for i in range(num-1):
    total -= abs_distance[i]

  print(total)
Buggy python submission (verdict: Runtime Error):
N = int(input().rstrip())
A = [int(s) for s in input().rstrip().split()]
A.sort()

squared = [2]
tmp = 2
while tmp < 2 * 10**9:
    tmp *= 2
    squared.append(tmp)

pairs = []
for i in range(N):
    for j in range(i+1, N):
        if A[i] + A[j] in squared:
            pairs.append([A[i], A[j]])

adopt = [format(i, 'b').rjust(len(pairs), '0') for i in range(2**len(pairs))]
max_pair = 0

for i in range(len(adopt)):
    num = []
    for j in range(len(pairs)):
        if adopt[i][j] == '1':
            num.append(pairs[j][0])
            num.append(pairs[j][1])
    if len(num) == len(set(num)) and len(num) > max_pair:
        max_pair = len(num)

print(max_pair // 2)

Fixed submission:
state = input().rstrip()
ans = 0
cnt = 0
for i, s in enumerate(state):
    if s == 'B':
        cnt += 1
    else:
        ans += cnt
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(s) for s in input().rstrip().split()]
pref = [[] for _ in range(N)]
P = []
for m in range(M):
    p, year = [int(s) for s in input().rstrip().split()]
    pref[p-1].append([year, m])
    pref[p-1].sort()
    P.append(p)

id = [None] * M
for n, p in enumerate(pref):
    if not p:
        continue    
    p.sort()
    for x, (year, m) in enumerate(p):
        id[m] = '{0:06d}{1:06d}'.format(n+1, x+1)

print('\n'.join(id))

Fixed submission:
N, M = [int(s) for s in input().rstrip().split()]
pref = [[] for _ in range(N)]
P = []
for m in range(M):
    p, year = [int(s) for s in input().rstrip().split()]
    pref[p-1].append([year, m])
    P.append(p)

id = [None] * M
for n, p in enumerate(pref):
    if not p:
        continue    
    p.sort()
    for x, (year, m) in enumerate(p):
        id[m] = '{0:06d}{1:06d}'.format(n+1, x+1)

print('\n'.join(id))

Buggy python submission (verdict: Time Limit Exceeded):
def year(x):
    return Y[x]

N, M = [int(s) for s in input().rstrip().split()]
pref = [[] for _ in range(N)]
P = []
for m in range(M):
    p, year = [int(s) for s in input().rstrip().split()]
    pref[p-1].append([year, m])
    P.append(p)

id = []    
for n in range(N):
    if pref[n]:
        pref[n].sort()

for i, p in enumerate(P):
    for j, city in enumerate(pref[p-1]):
        if city[1] == i:
            x = j+1
    id.append('{0:06d}{1:06d}'.format(p, x))

for m in range(M):
    print(id[m])

Fixed submission:
N, M = [int(s) for s in input().rstrip().split()]
pref = [[] for _ in range(N)]
P = []
for m in range(M):
    p, year = [int(s) for s in input().rstrip().split()]
    pref[p-1].append([year, m])
    P.append(p)

id = [None] * M
for n, p in enumerate(pref):
    if not p:
        continue    
    p.sort()
    for x, (year, m) in enumerate(p):
        id[m] = '{0:06d}{1:06d}'.format(n+1, x+1)

print('\n'.join(id))