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

Fixed submission:
# import sys
# input = sys.stdin.readline
Q = 10**9+7
def main():
    N = int( input())
    S = input()
    left = 0
    ans = 1
    # for i in range(N*2):
    #     s = S[i]
    for s in S:
        if s == "B":
            if left%2 == 0:
                left += 1
            else:
                ans *= left
                left -= 1
        else:
            if left%2 == 1:
                left += 1
            else:
                ans *= left
                left -= 1
        ans %= Q
    if left > 0 or ans == 0:
        print(0)
        return
    for i in range(1,N+1):
        ans *= i
        ans %= Q
    print(ans)
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def f_c():
    import math
    n = int(input())
    s = input()

    stack, c = [1], 1
    for i in range(1, n*2):
        if s[i]=="B":
            if len(stack)%2==0:
                stack.append(1)
            else:
                c *= len(stack)
                stack.pop()
        else:
            if len(stack)%2==0:
                c *= len(stack)
                stack.pop()
            else:
                stack.append(1)
    o = 0 if len(stack)!=0 else c*math.factorial(n)
    print(o)

if __name__ == "__main__":
    f_c()
Problem p02947 (python)

Fixed submission:
def f_c():

    n = int(input())
    d = {}
    dc = {}
    for _ in range(n):
        s = "".join(sorted(input()))
        if s in d:
            dc[s] += d[s]
            d[s] += 1
        else:
            d[s] = 1
            dc[s] = 0
    print(sum(dc.values()))

if __name__ == "__main__":
    f_c()

Buggy submission (verdict: Runtime Error):
def f_c():

    n = int(input())
    s = ["".join(sorted(input())) for _ in range(n)]

    c = 0
    for _ in range(n):
        si = s.pop()
        if si in s:
            c += s.count(s2)
    print(c)

if __name__ == "__main__":
    f_c()
Problem p02971 (python)

Fixed submission:
n, *a = map(int, open(0).read().split())
a2 = sorted(a)[-2:]
for i in range(n):
    if a[i]==a2[1]:
        print(a2[0])
    else:
        print(a2[1])

Buggy submission (verdict: Runtime Error):
n, *a = map(int, open(0).read().split())
a2 = sorted(a)[:-2]
for i in range(n):
    if a[i]==a2[1]:
        print(a[0])
    else:
        print(a[1])

Buggy submission (verdict: Runtime Error):
n, *a = map(int, read(0).open().split())
a2 = sorted(a)[:-2]
for i in range(n):
    if a[i]==a2[1]:
        print(a[0])
    else:
        print(a[1])
Problem p02995 (python)

Fixed submission:
def f_c():
    import fractions
    a, b, c, d = map(int, input().split())
    c_n = b//c-a//c+1 if a%c==0 else b//c-a//c
    d_n = b//d-a//d+1 if a%d==0 else b//d-a//d
    cd = c*d//fractions.gcd(c, d)
    cd_n = b//cd-a//cd+1 if a%cd==0 else b//cd-a//cd
    print(b-a+1-(c_n+d_n-cd_n))

if __name__ == "__main__":
    f_c()

Buggy submission (verdict: Runtime Error):
def f_c():
    import math
    a, b, c, d = map(int, input().split())
    c_n = b//c-a//c+1 if a%c==0 else b//c-a//c
    d_n = b//d-a//d+1 if a%d==0 else b//d-a//d
    cd = c*d//math.gcd(c, d)
    cd_n = b//cd-a//cd+1 if a%cd==0 else b//cd-a//cd
    print(b-a+1-(c_n+d_n-cd_n))

if __name__ == "__main__":
    f_c()

Buggy submission (verdict: Runtime Error):
def f_c():
    import math
    a, b, c, d = map(int, input().split())
    c_n = b//c-a//c+1 if a%c==0 else b//c-a//c
    d_n = b//d-a//d+1 if a%d==0 else b//d-a//d
    cd = c*d//math.gcd(c, d)
    cd_n = b//cd-a//cd+1 if a%cd==0 else b//cd-a//cd
    print(b-a+1-(c_n+d_n-cd_n))

if __name__ == "__main__":
    f_c()
Problem p03078 (python)

Fixed submission:
def f_d():
    import heapq
    x, y, z, k = map(int, input().split())
    *a, = sorted(list(map(int, input().split())), reverse=True)
    *b, = sorted(list(map(int, input().split())), reverse=True)
    *c, = sorted(list(map(int, input().split())), reverse=True)

    m = set((0, 0, 0))
    q = [[-1*(a[0]+b[0]+c[0]), 0, 0, 0]]
    heapq.heapify(q)
    for _ in range(k):
        ans, ai, bi, ci = heapq.heappop(q)
        if ai+1<x and (ai+1, bi, ci) not in m:
            m.add((ai+1, bi, ci))
            heapq.heappush(q, [-1*(a[ai+1]+b[bi]+c[ci]), ai+1, bi, ci])
        if bi+1<y and (ai, bi+1, ci) not in m:
            m.add((ai, bi+1, ci))
            heapq.heappush(q, [-1*(a[ai]+b[bi+1]+c[ci]), ai, bi+1, ci])
        if ci+1<z and (ai, bi, ci+1) not in m:
            m.add((ai, bi, ci+1))
            heapq.heappush(q, [-1*(a[ai]+b[bi]+c[ci+1]), ai, bi, ci+1])
        print(-1*ans)

if __name__ == "__main__":
    f_d()

Buggy submission (verdict: Runtime Error):
def f_d():
    import heapq
    x, y, z, k = map(int, input().split())
    *a, = sorted(list(map(int, input().split())), reverse=True)
    *b, = sorted(list(map(int, input().split())), reverse=True)
    *c, = sorted(list(map(int, input().split())), reverse=True)

    m, o = [[[0]*z for _ in range(y)] for _ in range(x)], []
    q = [[-1*(a[0]+b[0]+c[0]), 0, 0, 0]]
    heapq.heapify(q)
    for _ in range(k):
        tmp = heapq.heappop(q)
        o.append(-1*tmp[0])
        ai, bi, ci = tmp[1], tmp[2], tmp[3]
        if m[min(ai+1, len(a)-1)][bi][ci]==0:
            m[ai+1][bi][ci] = 1
            heapq.heappush(q, [-1*(a[ai+1]+b[bi]+c[ci]), ai+1, bi, ci])
        if m[ai][min(bi+1, len(b)-1)][ci]==0:
            m[ai][bi+1][ci] = 1
            heapq.heappush(q, [-1*(a[ai]+b[bi+1]+c[ci]), ai, bi+1, ci])
        if m[ai][bi][min(ci+1, len(c)-1)]==0:
            m[ai][bi][ci+1] = 1
            heapq.heappush(q, [-1*(a[ai]+b[bi]+c[ci+1]), ai, bi, ci+1])
    for i in range(k):
        print(o[i])

if __name__ == "__main__":
    f_d()
Problem p03102 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    import numpy as np
    n, m, c = map(int, readline().split())
    ba = list(map(int, read().split()))
    a = np.array(ba[m:]).reshape((n,m))
    b = np.array(ba[:m])

    print(sum(np.dot(a,b)+c>0))

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import numpy as np
    n, m, c = map(int, readline().split())
    ba = list(map(int, read().split()))
    a = np.array(ba[m:]).reshape((n,m))
    b = np.array(ba[:m])

    print(sum(np.dot(a,b)+c>0))

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

Fixed submission:
def main():
    import fractions, functools
    def gcd(li):
        return functools.reduce(fractions.gcd, li)

    n, k, *a = map(int, open(0).read().split())
    g = gcd(a)
    if max(a)>=k and k%g==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import fractions
    def gcd(li):
        fractions.reduce(fractions.gcd, li)

    n, k, *a = map(int, open(0).read().split())
    g = gcd(a)
    if max(a)>=k and k%g==0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

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

Fixed submission:
def f():
    N = int(input())
    A = []
    
    for n in range(N):
        templist = []
        for a in range(int(input())):
            templist.append(list(map(int, input().split())))
        A.append(templist)
    
    # print(A)
    J = [0]
    maxlen = len(str(bin(2**len(A)-1).replace('0b','')))
    for j in reversed((range(2**len(A)))):
        tempb = str(bin(j).replace('0b',''))
        for i in range(maxlen - len(tempb)):
            tempb = '0'+tempb
        # ここでパターン仮置き確定
        tempj = list(map(int, list(tempb)))
        counter = 0
        for jj in range(len(tempj)):
            if tempj[jj] == 1: # 正直者の場合
                # 証言の数だけループを回す
                shocounter = 0
                for s in range(len(A[jj])):
                    if tempj[A[jj][s][0]-1] != A[jj][s][1]:# 本当は違う
                        break
                    else:
                        shocounter += 1
                if shocounter == len(A[jj]):
                    counter += 1
            else:
                # 証言の数だけループを回す
                shocounter = 0
                for s in range(len(A[jj])):
                    if tempj[A[jj][s][0]-1] == A[jj][s][1]:# 本当はあってる
                        continue
                    else:
                        shocounter += 1
                if shocounter > 0:
                    counter += 1
        if counter == len(A):
            J.append(tempj.count(1))
    
    list.sort(J, reverse=True)        
    return print(J[0])
    
f()

Buggy submission (verdict: Runtime Error):
def f():
    N = int(input())
    A = []
    
    for n in range(N):
        templist = []
        for a in range(int(input())):
            templist.extend(list(map(int, input().split())))
        A.append(templist)
    
    print(A)
    
    maxlen = len(str(bin(2**len(A)-1).replace('0b','')))
    for j in reversed((range(2**len(A)))):
        tempb = str(bin(j).replace('0b',''))
        for i in range(maxlen - len(tempb)):
            tempb = '0'+tempb
        # ここでパターン仮置き確定
        tempj = list(map(int, list(tempb)))
        counter = 0
        for jj in range(len(tempj)):
            if tempj[jj] == 1: # 正直者の場合
                if tempj[A[jj][0]-1] != A[jj][1]:# 本当は違う
                    break
                else:
                    counter += 1
            else:
                if tempj[A[jj][0]-1] == A[jj][1]:# 本当はあってる
                    break
                else:
                    counter += 1
        if counter == len(A):
            return print(tempj.count(1))
            
    return print(tempj.count(1))
    
f()
Problem p02882 (python)

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

all_v = a*a*b

if all_v == x:
    print(0)
elif all_v/2 >= x:
    print(90-math.degrees(math.atan(2*x/(a*b*b))))
else:
    print(90-math.degrees(math.atan(a*a*a/(2*(a*a*b-x)))))

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

all_v = a*a*b
#h = x/(a*a)

if all_v/2 >= x:
    print(90-math.degrees(math.atan(2*x/(a*b*b))))
else:
    print(90-math.degrees(math.atan(a*a*a/(2*(a*a*b-x)))))
Problem p02900 (python)

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

#最大公約数
def my_gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
    
gcd_n = my_gcd(max(A,B),min(A,B))

if A==1 or B==1:
    print(1)
else:
    print(len(factorization(gcd_n))+1)

Buggy submission (verdict: Runtime Error):
import math
A,B = map(int,input().split())
gcd_n = math.gcd(A,B)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if A==1 or B==1:
    print(1)
else:
    print(len(factorization(gcd_n))+1)
Problem p03160 (python)

Fixed submission:
N = int(input())
asiba = list(map(int,input().split()))
dp =[10**10] *N

dp[0]=0
dp[1]=abs(asiba[1]-asiba[0])

for i in range(2,N):
    dp[i] = min(dp[i-2]+abs(asiba[i]-asiba[i-2]),dp[i])
    dp[i] = min(dp[i-1]+abs(asiba[i]-asiba[i-1]),dp[i])
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
asiba = list(map(int,input().split()))
dp =[math.inf] *N

dp[0]=0
dp[1]=abs(asiba[1]-asiba[0])

for i in range(2,N):
    dp[i] = min(dp[i-2]+abs(asiba[i]-asiba[i-2]),dp[i])
    dp[i] = min(dp[i-1]+abs(asiba[i]-asiba[i-1]),dp[i])
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
#https://atcoder.jp/contests/dp/tasks/dp_a
import math
N = int(input())
asiba = list(map(int,input().split()))
dp =[math.inf] *N

dp[0]=0
dp[1]=abs(asiba[1]-asiba[0])

for i in range(2,N):
    dp[i] = min(dp[i-2]+abs(asiba[i]-asiba[i-2]),dp[i])
    dp[i] = min(dp[i-1]+abs(asiba[i]-asiba[i-1]),dp[i])
print(dp[N-1])
Problem p03161 (python)

Fixed submission:
def main():
  n, k = [int(e) for e in input().split()]
  h = [int(e) for e in input().split()]
  cost = [0] * n
  for i in range(1, n):
    cost[i] = min(abs(h[i] - h[j]) + cost[j] for j in range(max(0, i - k), i))
  print(cost[n - 1])
main()

Buggy submission (verdict: Runtime Error):
N,K = [int(e) for e in input().split()]
asiba = [int(e) for e in input().split()]
dp =[0] *N

#初期化
dp[0]=0
dp[1]=abs(asiba[1]-asiba[0])

for i in range(2,N):
    dp[i] = min(abs(h[i] - h[j]) + cost[j] for j in range(max(0, i - k), i))
    
print(dp[N-1])

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
asiba = list(map(int,input().split()))
dp =[10**10] *N

#初期化
dp[0]=0
dp[1]=abs(asiba[1]-asiba[0])

for i in range(2,N):
    dp[i] = min(dp[i-j]+abs(asiba[i]-asiba[i-j]),dp[i] j in range(1,min(i+1,K+1)))
    
print(dp[N-1])
Problem p03455 (python)

Fixed submission:
a,b = map(int,input().split())
if(a*b%2==0):
    print('Even')
else:
    print('Odd')

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

x_before = 0
y_before = 0
t_before = 0
ans = 'YES'

for i in range(N):
    t, x, y = map(int, input().split())
    
    #i番目とi+1番目までの距離
    distace = abs(x-x_before) + abs(y-y_before)
    
    #i番目とi+1番目までの時間
    time = abs(t-t_before)
    
    #i+1番目のtimeで行くことが可能か判定
    if((time-distace<0) or (time-distace%2!=0)):
        ans = 'NO'
        break
        
    #i+1番目のtimeで行くことが可能なら値を更新
    x_before = x
    y_before = y
    t_before = t
    
print(ans)
Problem p02953 (python)

Fixed submission:
N = int(input())
HN = input().split()

def build_stairs(N=N, HN=HN):
    if N == 1:
        return "Yes"
    for n in range(N-1):
        if HN[n] - HN[n+1] > 1:
            return "No"
        elif HN[n] - HN[n+1] == 1:
            HN[n+1] += 1
        if HN[n] < HN[n+1]:
            continue
    return "Yes"

HN = [int(i) for i in HN]
ans = build_stairs(N, HN)
print(ans)
print("")

Buggy submission (verdict: Runtime Error):
def build_stairs(N=N, HN=HN):
    if N == 1:
        return "Yes"
    for n in range(N-1):
        if HN[n] - HN[n+1] > 1:
            return "No"
        elif HN[n] - HN[n+1] == 1:
            HN[n+1] += 1
        if HN[n] < HN[n+1]:
            continue
    return "Yes"

N = int(input())
HN = input().split()
HN = [int(i) for i in HN]
ans = build_stairs(N, HN)
print(ans)
print("")
Problem p02981 (python)

Fixed submission:
a, b, c = map(int, input().split())
if a*b <= c:
    print(a*b)
else:
    print(c)
print()

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np
H, W = map(int, input().split())
arr = []
for _ in range(H):
    S = input().split()
    S = [int(s) for s in S]
    arr.append(S)
x = list(itertools.combinations(arr,2))
count = 0
for i in range(len(x)):
    vec_a = np.array(x[i][0])
    vec_b = np.array(x[i][1])
    d = np.linalg.norm(vec_a - vec_b)
    d2 = int(d)
    if d == d2:
        count+=1
print(count)
print()
Problem p03285 (python)

Fixed submission:
N = int(input())

def cakes_and_donuts(N=N):
  if N % 4 ==0 or N % 7 ==0:
    return 'Yes'  
  max_7_num = N//7
  max_4_num = N//4
  for i in range(max_7_num):
    for j in range(max_4_num):
      if 7*(i+1) + 4*(j+1) == N:
        return 'Yes'
  return 'No'

s = cakes_and_donuts(N)
print('{}'.format(s))

Buggy submission (verdict: Runtime Error):
def cakes_and_donuts(N=N):
  max_7_num = N//7
  max_4_num = N//4
  for i in range(max_7_num):
    for j in range(max_4_num):
      if 7*(i+1) + 4*(j+1) == N:
        return 'Yes'
  return 'No'

N = int(input())
s = cakes_and_donuts(N)
print(''.format(s))

Buggy submission (verdict: Runtime Error):
def cakes_and_donuts(N=N):
  max_7_num = N//7
  max_4_num = N//4
  for i in range(max_7_num):
    for j in range(max_4_num):
      if 7*(i+1) + 4*(j+1) == N:
        return 'Yes'
  return 'No'

N = int(input())
cakes_and_donuts(N)
Problem p03657 (python)

Fixed submission:
def solution(a, b):
    total = a + b
    if total % 3 == 0:
        print('Possible')
    elif a % 3 == 0:
        print('Possible')
    elif b % 3 == 0:
        print('Possible')
    else:
        print('Impossible')

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

solution(A, B)

Buggy submission (verdict: Runtime Error):
def solution(n, k, l_list):
    l_list.sort(reverse=True)
    result = sum(l_list[:k])
    return result


N, K = [int(value) for value in input().split(' ')]
l_list = [int(value) for value in input().split(' ')]
print(solution(N, K, l_list))

Buggy submission (verdict: Runtime Error):
def solution(a, b):
    total = a + b
    if total % 3 == 0:
        print('Possible')
    elif a % 3 == 0:
        print('Possible')
    elif:
        b % 3 == 0:
        print('Possible')
    else:
        print('Impossible')

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

solution(A, B)

Buggy submission (verdict: Runtime Error):
def solution(a, b):
    total = a + b
    if (total % 3 == 0) and total >= 3:
        print('Possible')
    else:
        print('Impossible')

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

solution(A, B)

Buggy submission (verdict: Runtime Error):
def solution(a, b):
    total = a + b
    if (total % 3 == 0) and total >= 3:
        print('Possible')
    else:
        print('Impossible')

A, B = raw_input().split(' ')
A, B = int(A), int(B)

solution((A, B))
Problem p03658 (python)

Fixed submission:
def solution(n, k, l_list):
    l_list.sort(reverse=True)
    result = sum(l_list[:k])
    return result


N, K = [int(value) for value in input().split(' ')]
l_list = [int(value) for value in input().split(' ')]
print(solution(N, K, l_list))

Buggy submission (verdict: Runtime Error):
def solution(n, k, l_list):
    l_list.sort(reverse=True)
    result = sum(l_list[:k])
    return result


N, K = [int(value) for value in input().split(' ')]
l_list = [int(value) for value in input().split(' ')]
print(solution(n, k, l_list))
Problem p02848 (python)

Fixed submission:
n = int(input())
s = input()
t = ''
abc = [chr(i) for i in range(65, 65+26)]
for i in s:
  m = abc.index(i)
  if m+n <= 25:
    t += abc[m+n]
  else:
    t += abc[m+n-26]
print(t)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
t = ''
abc = [chr(i) for i in range(65, 65+26)]
for i in s:
  m = abc.index(i)
  if m+n <= 25:
    t += abc[m+n]
  else:
    t += abc[m+n-25]
print(t)
Problem p02885 (python)

Fixed submission:
a, b = input().split()
num_a = int(a)
num_b = int(b)
dif = num_a - num_b*2
if dif >= 0:
  print(dif)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
n = int(input())
taste_list = list(map(int, input().split()))
taste_sum = 0
for i in range(n):
  for j in range(n):
    taste = taste_list[i]*taste_list[j]
    taste_sum += taste
for i in range(len(taste_list)):
  taste_sum -= taste_list[i]**2
print(taste_sum/2)

Buggy submission (verdict: Runtime Error):
num_a = int(A)
num_b = int(B)
dif = num_a - num_b*2
if dif >= 0:
  print(dif)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
a, b = input()
num_a = int(a)
num_b = int(b)
dif = num_a - num_b*2
if dif >= 0:
  print(dif)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
a, b = input()
num_a = int(a)
num_b = int(b)
dif = num_a >= num_b*2
if dif >= 0:
  print(dif)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
a, b = input()
if a >= 2*b:
  print(a-2*b)
else:
  print(0)
Problem p02887 (python)

Fixed submission:
n = int(input())
a = input()
b = '1'
for i in range(n):
  if a[i] != b[-1]:
    b += a[i]
print(len(b)-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = input()
b = ''
for i in range(n):
  if b[-1] != i:
    b += i
print(len(b))
Problem p02947 (python)

Fixed submission:
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
    
    
N = int(input())
ss = []
for i in range(N):
	ss.append("".join(sorted(list(input()))))
	
dicS = {}
for s in ss:
	if s not in dicS:
		dicS[s] = 1
	else:
		dicS[s] += 1
		
#print(dicS)
		
ans = 0
for v in dicS.values():
	if v != 1:
		ans += cmb(v, 2)
	
print(ans)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
    
    
N = int(input())
ss = []
for i in range(N):
	ss.append("".join(sorted(list(input()))))
	
dicS = {}
for s in ss:
	if s not in dicS:
		dicS[s] = 1
	else:
		dicS[s] += 1
		
ans = 0
for v in dicS.values():
	ans += cmb(v, 2)
	
print(ans)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb

N = int(input())
ss = []
for i in range(N):
	ss.append("".join(sorted(list(input()))))
	
dicS = {}
for s in ss:
	if s not in dicS:
		dicS[s] = 1
	else:
		dicS[s] += 1
		
ans = 0
for v in dicS.values():
	ans += comb(v, 2, exact=True)
	
print(ans)

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

def combinations_count(n, r):
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
ss = []
for i in range(N):
	ss.append("".join(sorted(list(input()))))
	
dicS = {}
for s in ss:
	if s not in dicS:
		dicS[s] = 1
	else:
		dicS[s] += 1
		
ans = 0
for v in dicS.values():
	ans += combinations_count(v,2)
	
print(ans)
Problem p03076 (python)

Fixed submission:
def ceil(v):
	if v % 10 == 0:
		return v
	else:
		return (v // 10+1) *10

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

times = [A,B,C,D,E]

minMod = 9
last = times[0]
for time in times:
	if minMod > (time+9) % 10:
		minMod = (time+9) % 10
		last = time
		
times.remove(last)

for i,time in enumerate(times):
	times[i] = ceil(time)
	
times.append(last)

print(sum(times))

Buggy submission (verdict: Runtime Error):
def ceil(v):
	if v % 10 == 0:
		return v
	else:
		return (v // 10+1) *10

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

times = [A,B,C,D,E]

minMod = 9
last = -1
for time in times:
	if minMod > (time+9) % 10:
		minMod = (time+9) % 10
		last = time
		
times.remove(last)

for i,time in enumerate(times):
	times[i] = ceil(time)
	
times.append(last)

print(sum(times))

Buggy submission (verdict: Runtime Error):
def ceil(v):
	if v % 10 == 0:
		return v
	else:
		return (v // 10+1) *10

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

times = [A,B,C,D,E]

minMod = 9
last = -1
for time in times:
	if minMod > (time+9) % 10:
		minMod = (time+9) % 10
		last = time
		
times.remove(last)

for i,time in enumerate(times):
	times[i] = ceil(time)
	
times.append(last)

print(times)
print(sum(times))
Problem p03109 (python)

Fixed submission:
from datetime import datetime

S = input()

nowDate = datetime.strptime(S, '%Y/%m/%d')
lastDate =datetime.strptime('2019/04/30', '%Y/%m/%d')

if lastDate < nowDate:
	print("TBD")
else:
	print("Heisei")

Buggy submission (verdict: Runtime Error):
from datetime import datetime

S = input()

nowDate = datetime.strptime(S, '%Y/%m/%d')
lastDate =datetime.strptime('2019/04/30', '%Y/%m/%d')

if lastDate < nowTime:
	print("TBD")
else:
	print("Heisei")