Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
a,b,c=input().split();print('YNEOS'[a[-1]^b[0]^b[-1]^c[0]>0::2])

Fixed submission:
a,b,c=map(list,input().split())
print("YNEOS"[a[-1]!=b[0]or b[-1]!=c[0]::2])

Buggy python submission (verdict: Runtime Error):
a,b,c=input().split();print('YNEOS'[a[-1]^c[0]^b[0]^b[-1]::2])

Fixed submission:
a,b,c=map(list,input().split())
print("YNEOS"[a[-1]!=b[0]or b[-1]!=c[0]::2])
Buggy python submission (verdict: Runtime Error):
print(a[0],end=""for a in input().upper().split())

Fixed submission:
a,b,c=input().split()
print(a[0].upper()+b[0].upper()+c[0].upper())
Buggy python submission (verdict: Runtime Error):
print("HD"[len(set(input().split()))])

Fixed submission:
print("$HD"[len(set(input().split()))])
Buggy python submission (verdict: Runtime Error):
a,b,c,d=[int(input())for i in[0]*4];print(max(a*b,c*d))

Fixed submission:
a,b,c,d=map(int,input().split());print(max(a*b,c*d))
Buggy python submission (verdict: Runtime Error):
/7 7/cNO
cYES

Fixed submission:
a,b,c=map(int,input().split());print("YNEOS"[a+b+c!=17or a^b^c!=7::2])

Buggy python submission (verdict: Runtime Error):
print("YES"if input().count(7)==1else"NO")

Fixed submission:
a,b,c=map(int,input().split());print("YNEOS"[a+b+c!=17or a^b^c!=7::2])
Buggy python submission (verdict: Runtime Error):
s=input()
if s.lowercase():
  print("A")
else:
  print("a")

Fixed submission:
s=input()
if s.islower():
  print("a")
else:
  print("A")
Buggy python submission (verdict: Runtime Error):
a = input()
s = input()
if a >= 3200:
  print(s)
else:
  print('red')

Fixed submission:
a = int(input())
s = input()
if a > 3199:
  print(s)
else:
  print('red')
Buggy python submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = list(map(int, input().split()))

    if 0 in A:
        print(0)
        return

    prod = 1
    for a in A:
        values *= a
        if prod >  1000000000000000000:
            print('-1')
            return
    print(prod)
main()

Fixed submission:
def main ():
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
main ()

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

    if 0 in A:
        print(0)
        return

    prod = 1
    for a in A:
        values *= a
        if prod >  1000000000000000000:
            print('-1')
            return
    print(prod)
main()

Fixed submission:
def main ():
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
main ()

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

value = 1
for i in range(N):
  value *= A[i]

if value > 10e+17:
  print('-1')
else:
  print(value)

Fixed submission:
def main ():
    N = int(input())
    A = list(map(int,input(). split ()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
main ()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
s=str(input())
n=len(n)
print('x'*n)

Fixed submission:
# -*- coding: utf-8 -*-
s=str(input())
n=len(s)
print('x'*n)
Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int,input().split())

#これは立方体の中のどこか一点を選ぶ問題とみなせる
#その中で選ばれた座標の各要素の和が、Sに等しければ良い
#点の総和は(K+1)*3個あり（※ゼロを含むから）、それらが選択可能なx,y,zの集合である
#x,y,zの和がSに達しない場合は、Sを満たす集合はその立方体の外側にある

L=[]
counter=0
for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            L.append([x,y,z])
            if (S==x+y+z):counter+=1

print(counter)

Fixed submission:
K,S=map(int,input().split())
counter=0
for x in range(K+1):
    for y in range(K+1):
        if (S-x-y<=K) and (S-x-y>=0):counter+=1

print(counter)
Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
S = []
for l in range(L):
    S.append(str(input()))
S.sort()

sum_ = ''
for s in S:
    sum_ += s

print(sum_)

Fixed submission:
N, L = map(int, input().split())
S = []
for _ in range(N):
    S.append(str(input()))
S.sort()

sum_ = ''
for s in S:
    sum_ += s

print(sum_)
Buggy python submission (verdict: Runtime Error):
from math import sqrt
t = int(input())
for i in range(t):
     s = input()
     t = input()
     if(t[:-1] == s):
         print("YES")
     else:
         print("NO")



















Fixed submission:
from math import sqrt


s = input()
t = input()
if(t[:-1] == s):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
md = 1000000007
n,m = map(int,input().split())

grid=[]
for i in range(n):
    grid.append(list(input()))

dp=[]
for i in range(m):
    dp.append([0]*m)
dp[0][0]=1
for i in range(1,n):
    if(grid[i][0]!="#"):
        dp[i][0]=dp[i-1][0]
    else:
        dp[i][0]=0

for j in range(1,m):
    if(grid[0][j]!="#"):
        dp[0][j]=dp[0][j-1]
    else:
        dp[0][j]=0

for i in range(1,n):
    for j in range(1,m):
        if(grid[i][j]=="#"):
            dp[i][j]=0
        else:
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%md
print(dp[n-1][m-1])


Fixed submission:
md = 1000000007
n,m = map(int,input().split())

grid=[]
for i in range(n):
    grid.append(list(input()))

dp=[]
for i in range(n):
    dp.append([0]*m)
dp[0][0]=1
for i in range(1,n):
    if(grid[i][0]!="#"):
        dp[i][0]=dp[i-1][0]
    else:
        dp[i][0]=0

for j in range(1,m):
    if(grid[0][j]!="#"):
        dp[0][j]=dp[0][j-1]
    else:
        dp[0][j]=0

for i in range(1,n):
    for j in range(1,m):
        if(grid[i][j]=="#"):
            dp[i][j]=0
        else:
            dp[i][j]=(dp[i-1][j]+dp[i][j-1])%md
print(dp[n-1][m-1])
Buggy python submission (verdict: Runtime Error):
N, K = input().split()
p = [int(i) for i in input().split()]
p.sort()
print(sum(p[:K+1]))


Fixed submission:
N, K = map(int,input().split())
p = [int(i) for i in input().split()]
p.sort()
print(sum(p[:K]))

Buggy python submission (verdict: Runtime Error):
a = input()
print("A" if ord(a) < 92 else "a") 



Fixed submission:
N, K = map(int,input().split())
p = [int(i) for i in input().split()]
p.sort()
print(sum(p[:K]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
first = sorted(A)[-1]
second = sorted(A)[-2]
if first == second:
    for i in range(N):
        print(first)
else:
    for i in range(N):
        if i == A.index(first):
            print(second)
        else:
            print(first)


Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
first = sorted(A)[-1]
second = sorted(A)[-2]
if first == second:
    for i in range(N):
        print(first)
else:
    idx = A.index(first)
    for i in range(N):
        if i == idx:
            print(second)
        else:
            print(first)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
first = sorted(A)[-1]
second = sorted(A)[-2]
if first == second:
    for i in range(N):
        print(first)
else:
    for i in range(N):
        if i == A.index(first):
            print(second)
        else:
            print(first)


Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
first = sorted(A)[-1]
second = sorted(A)[-2]
if first == second:
    for i in range(N):
        print(first)
else:
    idx = A.index(first)
    for i in range(N):
        if i == idx:
            print(second)
        else:
            print(first)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]
for i in range(N):
    if i!=0 and i!= N-1:
        ans = max(max(A[:i]),max(A[i+1:]))
    elif i == 0:
        ans = max(A[i+1:])
    else:
        ans = max(A[:i])
    print(ans)


Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
first = sorted(A)[-1]
second = sorted(A)[-2]
if first == second:
    for i in range(N):
        print(first)
else:
    idx = A.index(first)
    for i in range(N):
        if i == idx:
            print(second)
        else:
            print(first)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
d = [int(i) for i in input().split()]
d.sort()
count = 0
dp = 0
for i in range(1,max(d)+1):
    dp += d.count(i)
    if dp == N / 2:
        count += 1
print(count)


Fixed submission:
from collections import Counter

N = int(input())
d = [int(i) for i in input().split()]
d_dic = Counter(d)
count = 0
dp = 0
for i in range(1,max(d)+1):
    dp += d_dic[i]
    if dp == N / 2:
        count += 1
    elif dp > N / 2:
        break
print(count)
Buggy python submission (verdict: Runtime Error):
enki = {"A":"T", "C":"G", "G":"C", "T":"A"}
print(enki[str(input())])


Fixed submission:
S = input()
count = 0
ans = 0
for s in S:
    if s in "ACGT":
        count += 1
    else:
        if ans < count:
            ans = count
        count = 0
    if ans < count:
        ans = count
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A, B = map(int, input().split())
X = [format(i, "b") for i in range(A, B+1)]
ans = [0 for i in range(len(X[-1]))]
for i in range(len(X)):
    while len(X[i]) != len(X[-1]):
        X[i] = "0" + X[i]

for x in X:
    for j in range(len(x)):
        ans[j] = ans[j] + int(x[j])
        if ans[j] % 2 == 0:
            ans[j] = 0

for i in range(len(ans)):
    ans[i] = str(ans[i])

ans = "".join(ans)
ans = int(ans, 2)
print(ans)


Fixed submission:
def oddsolve(x):
    return int((x+1) / 2 % 2)
def solve(x):
    if x % 2 ==0:
        return oddsolve(x+1)^(x+1)
    else:
        return oddsolve(x)

A, B = map(int,input().split())

print(solve(A-1) ^ solve(B))
Buggy python submission (verdict: Runtime Error):
A, B, K = map(int,input().split())

a = [i for i in range(1, A+1) if A % i == 0]
b = [i for i in range(1, B+1) if B % i == 0]
ans = set(a) & set(b)
print(list(ans)[K])


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

a = [i for i in range(1, A+1) if A % i == 0]
b = [i for i in range(1, B+1) if B % i == 0]
ans = set(a) & set(b)
print(sorted(list(ans))[-K])
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int,input().split())

li = [i for i in range(A, B+1) if i-A < K or B-i < K]

for i in li:
    print(i)

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

li = [i for i in range(A, A+K) if i <= B]
li = li + [i for i in range(B-K+1,B+1) if i >= A]

for i in sorted(set(li)):
    print(i)
Buggy python submission (verdict: Runtime Error):
def main():
  N = int(input())
  K = int(input())

  price = list(map(int, input().split()))

  price.sort()

  part = price[0:K]

  print(sum(part))

if __name__ == '__main__':
  main()

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

  price = list(map(int, input().split()))

  price.sort()

  part = price[0:K]

  print(sum(part))

if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
def main():
	N = int(input())
	K = int(input())

	price = list(map(int, input().split()))
	
	price.sort()

	part = price[0:K]

	print(sum(part))

if __name__ == '__main__':
    main()

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

  price = list(map(int, input().split()))

  price.sort()

  part = price[0:K]

  print(sum(part))

if __name__ == '__main__':
  main()

Buggy python submission (verdict: Runtime Error):
def main():
	N = int(input())
	K = int(input())

	list = []

	for i in range(N):
		list.append(int(input()))
	
	list.sort()

	part = list[0:K]

	print(sum(part))

if __name__ == '__main__':
    main()

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

  price = list(map(int, input().split()))

  price.sort()

  part = price[0:K]

  print(sum(part))

if __name__ == '__main__':
  main()
Buggy python submission (verdict: Runtime Error):
x,y = map(int,input().split())
p = []
ans = 0
z=x+1

for i in range(x):
    p.append(4)

for a in range(z):
    if sum(p)==y:
        ans = 1
        break
    else:
        p.remove(4)
        p.append(2)

if ans == 1:
    print('Yes')
else:
    if (y==2)&(x==1):
        print('Yes')
    if (y==4)&(x==1):
        print('Yes')
    else :
        print('No')


Fixed submission:
x,y = map(int, input().split())
list = []
ans = 0
for i in range(x) :
    list.append(4)

if sum(list) == y:
    print('Yes')
    ans = 1

else :
    for i in range(x) :
        list.remove(4)
        list.append(2)
        if sum(list) == y:
            print('Yes')
            ans = 1
            break

    if ans == 0:
        print('No')

Buggy python submission (verdict: Runtime Error):
x,y = map(int,input().split())
p = []
ans = 0
z=x+1

for i in range(x):
    p.append(4)

for i in range(z):
    if sum(p)==y:
        ans = 1
        break
    else:
        p.remove(4)
        p.append(2)

if ans == 1:
    print('Yes')
else:
    if (y==2)&(x==1):
        print('Yes')
    if (y==4)&(x==1):
        print('Yes')
    else :
        print('No')


Fixed submission:
x,y = map(int, input().split())
list = []
ans = 0
for i in range(x) :
    list.append(4)

if sum(list) == y:
    print('Yes')
    ans = 1

else :
    for i in range(x) :
        list.remove(4)
        list.append(2)
        if sum(list) == y:
            print('Yes')
            ans = 1
            break

    if ans == 0:
        print('No')

Buggy python submission (verdict: Runtime Error):
x,y = map(int,input().split())
p = []
ans = 0

for i in range(x):
    p.append(4)

for i in range(x+1):
    if sum(p)==y:
        ans = 1
        break
    else:
        p.remove(4)
        p.append(2)

if ans == 1:
    print('Yes')
else:
    if (y==2)&(x==1):
        print('Yes')
    elif (y==4)&(x==1):
        print('Yes')
    else :
        print('No')


Fixed submission:
x,y = map(int, input().split())
list = []
ans = 0
for i in range(x) :
    list.append(4)

if sum(list) == y:
    print('Yes')
    ans = 1

else :
    for i in range(x) :
        list.remove(4)
        list.append(2)
        if sum(list) == y:
            print('Yes')
            ans = 1
            break

    if ans == 0:
        print('No')
Buggy python submission (verdict: Runtime Error):
val1 = input()
val2 = input()

print(int(val1) * int(val2))


Fixed submission:
val1,val2 = (int(x) for x in input().split())

print(int(val1) * int(val2))
Buggy python submission (verdict: Runtime Error):
N,K = tuple(map(int,input.split(" ")))
cont = list(map(int,input.split(" ")))
print(sum(cont[:K]))

Fixed submission:
N,K = tuple(map(int,input().split(" ")))
cont = sorted(list(map(int,input().split(" "))))
print(sum(cont[:K]))
Buggy python submission (verdict: Runtime Error):
n=int(input())
n_d=len(str(n))
ans=1
for i in range(1,n,2):
	part1=9
	part2=10**i
	total=part1*part2
	total/=10
	ans+=total
part1=10**n
part2=n-part1
ans+=(part2+1)
print(ans)


Fixed submission:
n=int(input())
n_d=len(str(n))
ans=0
if n_d >1:
	for i in range(1,n_d,2):
		part1=9
		part2=10**i
		total=part1*part2
		total=total//10
		ans+=total
if n_d%2!=0:		
	part1=10**(n_d-1)
	part2=n-part1
	ans+=(part2+1)
print(int(ans))
# your code goes here
Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
for i,v in enumerate(p):
    ans += v
    if i == 2:
        print(ans)
        exit()
print(ans)

Fixed submission:
N,K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
ans = 0
for i,v in enumerate(p):
    ans += v
    if i == K - 1:
        print(ans)
        exit()
print(ans)

Buggy python submission (verdict: Runtime Error):
N,K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
print(p[0]+p[1]+p[2])

Fixed submission:
N,K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
ans = 0
for i,v in enumerate(p):
    ans += v
    if i == K - 1:
        print(ans)
        exit()
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A, B = map(int, input().split())
ans = A * B
for i in range(min(A, B) * 2,(A * B) + 1):
    if i % A == 0 and i % B == 0:
        ans = i
        break

print(ans)

Fixed submission:
# 約数列挙
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

A, B = map(int, input().split())
ptn = list(reversed(make_divisors(A * B)))

for i in range(0, len(ptn), 2):
    if ptn[i] % A == 0 and ptn[i] % B == 0:
        print(ptn[i])
        exit()
print(A * B)
Buggy python submission (verdict: Runtime Error):
H,W,A,B = map(int, input().split())

W1 = '1' * A + '0' * (W - A)
W0 = '0' * A + '1' * (W - A)

if A > (H // 2) or B > (W // 2):
    print('No')
    exit()

if H == 1:
    print(W1)
    exit()
elif W == 1:
    for _ in range(B):
        print('1')
    for _ in range(H - B):
        print('0')
	    exit()


ans = []
ans.append(W1)

for _ in range(B):
    ans.append(W0)

for _ in range(H - B - 1):
    ans.append(W1)

for i in ans:
    print(i)


Fixed submission:
H,W,A,B = map(int, input().split())

W1 = '1' * A + '0' * (W - A)
W0 = '0' * A + '1' * (W - A)

if A > (W // 2) or B > (H // 2):
    print('No')
    exit()

if H == 1:
    print(W1)
    exit()
elif W == 1:
    for _ in range(B):
        print('1')
    for _ in range(H - B):
        print('0')
    exit()


ans = []
ans.append(W1)

for _ in range(B):
    ans.append(W0)

for _ in range(H - B - 1):
    ans.append(W1)

for i in ans:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [list(sorted(input())) for i in range(N)]
# s.sort()

ans = 0
for c in s:
        tmp = s.count(c)
        if tmp > 1:
                ans += tmp - 1

print(ans // 2)


Fixed submission:
N = int(input())
s = [list(sorted(input())) for i in range(N)]
s.sort()

ans = []
tmp = 1
for idx,val in enumerate(s):
        if idx == 0:
                continue
        if val == s[idx - 1]:
                tmp += 1
        else:
                ans.append(tmp)
                tmp = 1
else:
        ans.append(tmp)

res = 0
for i in ans:
        res += (i * (i - 1)) // 2
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [list(sorted(input())) for i in range(N)]
s.sort()

ans = 0
for c in s:
        tmp = s.count(c)
        if tmp > 1:
                ans += tmp - 1

print(ans // 2)


Fixed submission:
N = int(input())
s = [list(sorted(input())) for i in range(N)]
s.sort()

ans = []
tmp = 1
for idx,val in enumerate(s):
        if idx == 0:
                continue
        if val == s[idx - 1]:
                tmp += 1
        else:
                ans.append(tmp)
                tmp = 1
else:
        ans.append(tmp)

res = 0
for i in ans:
        res += (i * (i - 1)) // 2
print(res)

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

N = int(input())
s = [list(input()) for i in range(N)]

cnts = []
for i in s:
        cnts.append(collections.Counter(i))

ans = 0
for c in cnts:
        tmp = cnts.count(c)
        if tmp > 1:
                ans += tmp - 1

print(ans // 2)


Fixed submission:
N = int(input())
s = [list(sorted(input())) for i in range(N)]
s.sort()

ans = []
tmp = 1
for idx,val in enumerate(s):
        if idx == 0:
                continue
        if val == s[idx - 1]:
                tmp += 1
        else:
                ans.append(tmp)
                tmp = 1
else:
        ans.append(tmp)

res = 0
for i in ans:
        res += (i * (i - 1)) // 2
print(res)
Buggy python submission (verdict: Runtime Error):
L,R = map(int, input().split())
if L * R < 2019:
        print(L * R)
        exit()

if R - L >= 2019:
        print(0)
        exit()

li=range(L, R)
tmp = []
for i in range(min(2019 * 2, R - L)):
        if li[i] % 2019 == 0:
                print(0)
                exit()
        tmp.append(li[i] % 2019)
tmp.sort()

print(tmp[0]* tmp[1])



Fixed submission:
import itertools
L,R = map(int, input().split())
if (R - L) + 1 >= 2019:
        print(0)
        exit()
elif (R - L) + 1 >= 673:
        print(0)
        exit()

if (R - 1) * R < 2019:
        print(L * R)
        exit()


if L % 2019 == 0:
        print(0)
        exit()
elif L % 673 < R % 673:
        li = range(L, R + 1)
        cmb = list(itertools.combinations(li,2))
        ans = (R-1) * R
        for i,j in cmb:
                ans = min(ans, (i*j) % 2019)
        print(ans)

else:
        print(0)
        exit()

Buggy python submission (verdict: Runtime Error):
L,R = map(int, input().split())
if L * R < 2019:
        print(L * R)
        exit()

if R - L >= 2019:
        print(0)
        exit()

li=range(L, R)
tmp = []
for i in range(min(2019, R - L)):
        if li[i] % 2019 == 0:
                print(0)
                exit()
        tmp.append(li[i] % 2019)
tmp.sort()

print(tmp[0]* tmp[1])



Fixed submission:
import itertools
L,R = map(int, input().split())
if (R - L) + 1 >= 2019:
        print(0)
        exit()
elif (R - L) + 1 >= 673:
        print(0)
        exit()

if (R - 1) * R < 2019:
        print(L * R)
        exit()


if L % 2019 == 0:
        print(0)
        exit()
elif L % 673 < R % 673:
        li = range(L, R + 1)
        cmb = list(itertools.combinations(li,2))
        ans = (R-1) * R
        for i,j in cmb:
                ans = min(ans, (i*j) % 2019)
        print(ans)

else:
        print(0)
        exit()
Buggy python submission (verdict: Runtime Error):
5
3 8 7 5 5

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N):
        if i % 2 == 0:
                ans += A[i]
        else:
                ans -= A[i]
tmp = []
tmp.append(ans)
for j in range(1,N + 1):
        tmp.append(A[j - 1] * 2 - tmp[j - 1])

for i in range(len(tmp) -1 ):
        print(tmp[i])