Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
for r in [A.count(i) for i in range(1, N + 1)]:
    print(r)


Fixed submission:
import collections
N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
for i in range(1, N + 1):
    if c[i]:
        print(c[i])
    else:
        print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
for r in [A.count(i) for i in range(1, N + 1)]:
    print(r)

Fixed submission:
import collections
N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
for i in range(1, N + 1):
    if c[i]:
        print(c[i])
    else:
        print(0)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
res = [A.count(i) for i in range(1, N + 1)]
for r in res:
    print(r)

Fixed submission:
import collections
N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
for i in range(1, N + 1):
    if c[i]:
        print(c[i])
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
count = 0
for i in range(N):
    if S[i] == "A" and S[i + 1] == "B" and S[i + 2] == "C":
        count += 1
print(count)


Fixed submission:
N = int(input())
S = input()
count = 0
for i in range(N):
    try:
        if S[i] == "A" and S[i + 1] == "B" and S[i + 2] == "C":
            count += 1
    except IndexError:
        break
print(count)
Buggy python submission (verdict: Runtime Error):
import math

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


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


print(lcm(A, B))

Fixed submission:
import fractions

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


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


print(lcm(A, B))

Buggy python submission (verdict: Runtime Error):
import math

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


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


print(lcm(A, B))

Fixed submission:
import fractions

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


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


print(lcm(A, B))
Buggy python submission (verdict: Runtime Error):
k = int(input())
for i in range(1,10):
     if k // i <= 9 and k % i == 0:
            print("Yes")
        	exit
     
print("No")

Fixed submission:
k = int(input())
for i in range(1,10):
    if k // i <= 9 and k % i == 0:
       print("Yes")
       exit()
     
print("No")

Buggy python submission (verdict: Runtime Error):
k = int(input())
for i in range(1,10):
     if k // i <= 9 and k % i == 0:
            print("Yes")
        	exit()
     
print("No")

Fixed submission:
k = int(input())
for i in range(1,10):
    if k // i <= 9 and k % i == 0:
       print("Yes")
       exit()
     
print("No")

Buggy python submission (verdict: Runtime Error):
k = int(input())
a = list(range(1,10))
for i in a:
     if k in / i >= 10:
             print("No")
     else:
             print("Yes")

Fixed submission:
k = int(input())
for i in range(1,10):
    if k // i <= 9 and k % i == 0:
       print("Yes")
       exit()
     
print("No")

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

for i in list(range(1,10)):
     if k in / i >= 10:
             print("No")
     else:
             print("Yes")

Fixed submission:
k = int(input())
for i in range(1,10):
    if k // i <= 9 and k % i == 0:
       print("Yes")
       exit()
     
print("No")

Buggy python submission (verdict: Runtime Error):
in = int(input())
for i in list(range(1,10)):
     if in / i >= 10:
             print("No")
     else:
             print("Yes")

Fixed submission:
k = int(input())
for i in range(1,10):
    if k // i <= 9 and k % i == 0:
       print("Yes")
       exit()
     
print("No")

Buggy python submission (verdict: Runtime Error):
in = int(input())
for i in list(range(10)):
     if in / i >= 10:
             print("No")
     else:
             print("Yes")

Fixed submission:
k = int(input())
for i in range(1,10):
    if k // i <= 9 and k % i == 0:
       print("Yes")
       exit()
     
print("No")
Buggy python submission (verdict: Runtime Error):
dict = {'A':'T','C':'G','T':'A', 'G':'C'}
a = input()
print(dict(a))

Fixed submission:
dict = {'A':'T','C':'G','T':'A', 'G':'C'}
a = input()
print(dict[a])
Buggy python submission (verdict: Runtime Error):
S = input()
count = 0
res = []
for i in S:
    if i in ["A", "C", "G", "T"]:
        count += 1
    else:
        res.append(count)
        count = 0
print(max(res))

Fixed submission:
s = input()
ans=0
now=0
for a in s:
    if a in ["A", "C", "G", "T"]:
        now+=1
    else:
        now=0
    ans=max(ans,now)
print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
count = 0
res = []
for i in range(len(S)):
    if S[i] in ["A", "C", "G", "T"]:
        count += 1
    else:
        res.append(count)
        count = 0
print(max(res, 0))


Fixed submission:
s = input()
ans=0
now=0
for a in s:
    if a in ["A", "C", "G", "T"]:
        now+=1
    else:
        now=0
    ans=max(ans,now)
print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
count = 0
res = []
for i in range(len(S)):
    try:
        if S[i] in ["A", "C", "G", "T"]:
            count += 1
        else:
            res.append(count)
            count = 0
    except:
        continue
print(max(res))

Fixed submission:
s = input()
ans=0
now=0
for a in s:
    if a in ["A", "C", "G", "T"]:
        now+=1
    else:
        now=0
    ans=max(ans,now)
print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
count = 0
res = []
for i in range(len(S)):
    if S[i] in ["A", "C", "G", "T"]:
        count += 1
    else:
        res.append(count)
        count = 0
print(max(res))


Fixed submission:
s = input()
ans=0
now=0
for a in s:
    if a in ["A", "C", "G", "T"]:
        now+=1
    else:
        now=0
    ans=max(ans,now)
print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
count = 0
res = []
for i in range(len(S)):
    if S[i] in ["A", "C", "G", "T"]:
        count += 1
    else:
        res.append(count)
        count = 0

print(max(res))

Fixed submission:
s = input()
ans=0
now=0
for a in s:
    if a in ["A", "C", "G", "T"]:
        now+=1
    else:
        now=0
    ans=max(ans,now)
print(ans)
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input())
h,w = map(int,input())
print(int(H * W - h * w))

Fixed submission:
H,W = map(int,input().split())
h,w = map(int,input().split())
A = H - h
B = W - w
print(int(A * B))
Buggy python submission (verdict: Runtime Error):
N,Y = map(int, input().split())
for i in range(N + 1):
    for l in range(N - i + 1):
            if 10000*i + 5000*l + 1000*(N - i - l) == Y:
                print(i ,l ,(N - i - l))
                exit()

print(-1 ,-1 ,-1)


Fixed submission:
s = str(input())
l = s.replace("2017", "2018")
print(l)

Buggy python submission (verdict: Runtime Error):
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")

Fixed submission:
s = str(input())
l = s.replace("2017", "2018")
print(l)

Buggy python submission (verdict: Runtime Error):
N,Y = map(int, input().split())
for i in range(N + 1):
    for l in range(N - i):
            ans = 10000*i + 5000*l + 1000*(N - i - l)
            if ans == Y:
                print("{} {} {} ".format(i ,l  ,(N - i - l)))
                exit()

print(-1 ,-1 ,-1)

Fixed submission:
s = str(input())
l = s.replace("2017", "2018")
print(l)

Buggy python submission (verdict: Runtime Error):
N,Y = map(int, input().split())
for i in range(N):
    for l in range(N):
            ans = 10000*i + 5000*l + 1000*(N - i - l)
            if ans == Y:
                print("{} {} {} ".format(i ,l  ,(N - i - l)))
                exit()

print("-1 -1 -1")

Fixed submission:
s = str(input())
l = s.replace("2017", "2018")
print(l)
Buggy python submission (verdict: Runtime Error):
s = str(input())
print(s.count(1))

Fixed submission:
s = str(input())
print(s.count("1"))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
j = True
count = 0
while j :
     for i in range(N):
             if A[i] % 2 == 0 or A[i] == 0:
                     A[i] =/ 2
             else:
                     j = False
     if j == True:             
     	count += 1
print(count)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
j = True
count = 0
while j :
     for i in A:
             if i % 2 == 0 or i == 0:
                     A[A.index(i)] = i / 2
             else:
                     j = False
     if j == True:             
     	count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
j = True
count = 0
while True:
     for i in A:
             if i % 2 == 0:
                     A[A.index(i)] = i / 2
             else:
                     j = False
             if j != True:
              	break
                     
     count += 1
print(count)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
j = True
count = 0
while j :
     for i in A:
             if i % 2 == 0 or i == 0:
                     A[A.index(i)] = i / 2
             else:
                     j = False
     if j == True:             
     	count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
j = True
count = 0
while j:
     for i in A:
             if i % 2 == 0:
                     A[A.index(i)] = i / 2
             else:
                     j = False
                  	 break
     count += 1
print(count)


Fixed submission:
N = int(input())
A = list(map(int,input().split()))
j = True
count = 0
while j :
     for i in A:
             if i % 2 == 0 or i == 0:
                     A[A.index(i)] = i / 2
             else:
                     j = False
     if j == True:             
     	count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
l = []
for x in ab:
    l += [x[0]] * x[1]
print(sorted(l)[k-1])

Fixed submission:
n, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
length = 0
for x in sorted(ab, key=lambda x: x[0]):
    length += x[1]
    if length >= k:
        print(x[0])
        break
Buggy python submission (verdict: Runtime Error):
a,b,c = input().split()
print(a.upper()[0]+b.upper()[0].c.upper()[0])

Fixed submission:
a,b,c = input().split()
print(a.upper()[0]+b.upper()[0]+c.upper()[0])
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
if b−a==c−b:
  print("YES")
else:
  print("NO")

Fixed submission:
a,b,c = map(int,input().split())
if b-a == c-b:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
import collections

n = int(input())
s = [input() for i in range(n)]
w = ""

if n == 1:
    r = sorted(collections.Counter(s))
    for k, v in r.items():
        w += k * r[k]
    print(w)
    exit()
a = collections.Counter(s[0])
b = collections.Counter(s[1])
res = a & b
if n <= 2:
    for k in sorted(res):
        w += k * res[k]
    print(w)
else:
    for i in s[2:]:
        res = res & collections.Counter(i)
    if not res:
        print("")
    for k in sorted(res):
        w += k * res[k]
    print(w)


Fixed submission:
import collections

n = int(input())
s = [input() for i in range(n)]
w = ""
if n == 1:
    r = collections.Counter(s[0])
    for k in sorted(r):
        w += k * r[k]
    print(w)
    exit()
a = collections.Counter(s[0])
b = collections.Counter(s[1])
res = a & b
if n <= 2:
    for k in sorted(res):
        w += k * res[k]
    print(w)
else:
    for i in s[2:]:
        res = res & collections.Counter(i)
    if not res:
        print("")
    for k in sorted(res):
        w += k * res[k]
    print(w)

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

n = int(input())
s = [input() for i in range(n)]
w = ""

if n == 1:
    r = sorted(collections.Counter(s[0]))
    for k, v in r.items():
        w += k * r[k]
    print(w)
    exit()
a = collections.Counter(s[0])
b = collections.Counter(s[1])
res = a & b
if n <= 2:
    for k in sorted(res):
        w += k * res[k]
    print(w)
else:
    for i in s[2:]:
        res = res & collections.Counter(i)
    if not res:
        print("")
    for k in sorted(res):
        w += k * res[k]
    print(w)

Fixed submission:
import collections

n = int(input())
s = [input() for i in range(n)]
w = ""
if n == 1:
    r = collections.Counter(s[0])
    for k in sorted(r):
        w += k * r[k]
    print(w)
    exit()
a = collections.Counter(s[0])
b = collections.Counter(s[1])
res = a & b
if n <= 2:
    for k in sorted(res):
        w += k * res[k]
    print(w)
else:
    for i in s[2:]:
        res = res & collections.Counter(i)
    if not res:
        print("")
    for k in sorted(res):
        w += k * res[k]
    print(w)

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

n = int(input())
s = [input() for i in range(n)]
a = collections.Counter(s[0])
b = collections.Counter(s[1])
res = a & b
w = ""
if n <= 2:
    for k in sorted(res):
        w += k * res[k]
    print(w)
else:
    for i in s[2:]:
        res = res & collections.Counter(i)
    if not res:
        print("")
    for k in sorted(res):
        w += k * res[k]
    print(w)

Fixed submission:
import collections

n = int(input())
s = [input() for i in range(n)]
w = ""
if n == 1:
    r = collections.Counter(s[0])
    for k in sorted(r):
        w += k * r[k]
    print(w)
    exit()
a = collections.Counter(s[0])
b = collections.Counter(s[1])
res = a & b
if n <= 2:
    for k in sorted(res):
        w += k * res[k]
    print(w)
else:
    for i in s[2:]:
        res = res & collections.Counter(i)
    if not res:
        print("")
    for k in sorted(res):
        w += k * res[k]
    print(w)
Buggy python submission (verdict: Runtime Error):
for A in range(1, int((N / 2))):
    if N % A == 0:
        B = int(N / A)
        if len(str(A)) <= len(str(B)):
            res = len(str(B))
        elif len(str(A)) >= len(str(B)):
            res = len(str(A))
        cont.append(res)
    else:
        continue
print(min(cont))

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


N = int(input())
r = make_divisors(N)
res = []
for i in r:
    y = N // i
    res.append(max(len(str(y)), len(str(i))))
print(min(res))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
cont = []
res = 0
for A in range(1, N + 1):
    if N % A == 0:
        B = int(N / A)
        if len(str(A)) <= len(str(B)):
            res = len(str(B))
        elif len(str(A)) >= len(str(B)):
            res = len(str(A))
        cont.append(res)
    else:
        continue
print(min(cont))

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


N = int(input())
r = make_divisors(N)
res = []
for i in r:
    y = N // i
    res.append(max(len(str(y)), len(str(i))))
print(min(res))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a=="H":
  print(b)
 
  
else:
  if b =="H":
    print("D")
  else:
    print("H")
  

Fixed submission:
a,b = input().split()
if a=="H":
  print(b)
 
  
else:
  if b =="H":
    print("D")
  else:
    print("H")
Buggy python submission (verdict: Runtime Error):
w,a,b = map(int,input().split())
if w+a => b:
  print(0)
else:
	print(b-(a+w))


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

if abs(a-b) <= w:
  print(0)
else:
  print(abs(a-b)-w)

Buggy python submission (verdict: Runtime Error):
w,a,b = map(int,input().split())
print(b-(a+W))

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

if abs(a-b) <= w:
  print(0)
else:
  print(abs(a-b)-w)
Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
cnt = 1
for i in range(1,n+1):
  cnt *= i
print(cnt%(10**9+7))

Fixed submission:
n= int(input())
cnt = 1
for i in range(1,n+1):
  cnt *= i
  cnt %= (10**9+7)
print(cnt)
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
N = math.factorial(N) 

i = 2 　
num = 1
ans = 1

while N != 1: 
    if N % i == 0:
        N //= i
        num += 1
    else:
        ans *= num
        num = 1
        i += 1
ans *= num
ans %= (10 ** 9) + 7

print(ans)

Fixed submission:
import math

N = int(input())
N = math.factorial(N) 

i = 2 
num = 1
ans = 1

while N != 1: 
    if N % i == 0:
        N = N // i
        num += 1
    else:
        ans *= num
        num = 1
        i += 1
ans *= num
ans %= (10 ** 9) + 7

print(ans)

Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
N = math.factorial(N) # N!を出してくれる (N=3, 0+1+2+3=6)

i = 2 　#Nを素因数分解するためまずは2で
num = 1
ans = 1

while N != 1: 
    if N % i == 0:
        N //= i
        num += 1
    else:
        ans *= num
        num = 1
        i += 1
ans *= num
ans %= (10 ** 9) + 7

print(ans)

Fixed submission:
import math

N = int(input())
N = math.factorial(N) 

i = 2 
num = 1
ans = 1

while N != 1: 
    if N % i == 0:
        N = N // i
        num += 1
    else:
        ans *= num
        num = 1
        i += 1
ans *= num
ans %= (10 ** 9) + 7

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())

    def count_div(num):
        count = 0
        upper = num ** 0.5
        i = 1
        while i <= upper:
            if num % i == 0:
                if i == upper:
                    count += 1
                else:
                    count += 2
            i += 1
        return count

    ans = 0
    for c in range(1, n + 1):
        ans += count_div(n - c)
    print(ans)

resolve()

Fixed submission:
def resolve():
    n = int(input())

    count = 0
    a, b = 1, 1
    while a < n:
        while b < n / a:
            count += 1
            b += 1
        b = 1
        a += 1
    print(count)


if 'unittest' not in globals():
    resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    count = [0 for _ in range(10**5)]
    for i in range(n):
        count[a[i] - 1] += 1

    q = int(input())
    for _ in range(q):
        b, c = list(map(int, input().split()))
        count[c - 1] += count[b - 1]
        count[b - 1] = 0
        total = 0
        for i in range(10**5):
            if count[i] == 0:
                continue
            total += count[i] * (i + 1)
        print(total)


if 'unittest' not in globals():
    resolve()

Fixed submission:
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    total = 0
    count = [0 for _ in range(10**5)]
    for i in range(n):
        count[a[i] - 1] += 1
        total += a[i]

    q = int(input())
    for _ in range(q):
        b, c = list(map(int, input().split()))
        count_b = count[b - 1]
        count[b - 1] = 0
        count[c - 1] += count_b

        total -= count_b * (b - c)
        print(total)


if 'unittest' not in globals():
    resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    count = [0 for _ in range(10**5)]
    for i in range(n):
        count[a[i] - 1] += a[i]

    q = int(input())
    for _ in range(q):
        b, c = list(map(int, input().split()))
        count[c - 1] += count[b - 1] * (c / b)
        count[b - 1] = 0
        print(int(sum(count)))


if 'unittest' not in globals():
    resolve()

Fixed submission:
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    total = 0
    count = [0 for _ in range(10**5)]
    for i in range(n):
        count[a[i] - 1] += 1
        total += a[i]

    q = int(input())
    for _ in range(q):
        b, c = list(map(int, input().split()))
        count_b = count[b - 1]
        count[b - 1] = 0
        count[c - 1] += count_b

        total -= count_b * (b - c)
        print(total)


if 'unittest' not in globals():
    resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    x, n = list(map(int, input().split()))

    if n > 0:
        p = list(map(int, input().split()))
        q = [i for i in range(1, max(p)+1)]
        for item in p:
            if item in q:
                q.remove(item)

        ans = []
        current_min = float('inf')
        for item in q:
            diff = abs(x-item)
            if diff < current_min:
                current_min = diff
                ans = []
                ans.append(item)
            elif diff == current_min:
                ans.append(item)

        print(min(ans))
    else:
        print(x)


if 'unittest' not in globals():
    resolve()


Fixed submission:
def resolve():
    x, n = list(map(int, input().split()))

    if n > 0:
        p = list(map(int, input().split()))
        q = [i for i in range(min(p)-1, max(p)+2)]
        for item in p:
            if item in q:
                q.remove(item)

        ans = []
        current_min = float('inf')
        for item in q:
            diff = abs(x-item)
            if diff < current_min:
                current_min = diff
                ans.clear()
                ans.append(item)
            elif diff == current_min:
                ans.append(item)

        print(min(ans))
    else:
        print(x)


if 'unittest' not in globals():
    resolve()
Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    t = input()

    ans = ''
    for s in t:
        if s == '?':
            ans += 'D'
        else:
            ans += s

    print(ans)
resolve()

Fixed submission:
def resolve():
    t = input()

    print(t.replace('?', 'D'))
resolve()
Buggy python submission (verdict: Runtime Error):
a, b, c, k = list(map(int, input().split()))

cards = [1]*a + [0]*b + [-1]*c
print(sum(cards[:k]))

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

left = k
sum = 0
cards = (a, b, c)

for i, card in enumerate(cards):
  if card <= left:
    sum += card * (1-i)
    left -= card
  elif left > 0:
    sum += left * (1-i)
    left = 0

print(sum)