Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
solve_problem = []
d = {i: 0 for i in range(1, N+1)}
ans = 0
penalty = 0
for i in range(M):
    p, S = input().split()
    if S == 'AC' and p not in solve_problem:
        solve_problem.append(p)
        ans += 1
        penalty += d[int(p)]
    if S == 'WA':
        d[int(p)] += 1

print('{} {}'.format(ans, penalty))



Fixed submission:
c = input()

alphabet = 'abcdefghijklmnopqrstuvwxyz'

index = alphabet.index(c)
print(alphabet[index+1])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
solve_problem = []
d = {i: 0 for i in range(1, N+1)}
ans = 0
penalty = 0
for i in range(M):
    p, S = input().split()
    if S == 'AC' and p not in solve_problem:
        solve_problem.append(p)
        ans += 1
        penalty += d[int(p)]
    if S == 'WA':
        d[int(p)] += 1

print('{} {}'.format(ans, penalty))



Fixed submission:
N, M = map(int, input().split())
solve_problem = set()
WA = [0 for _ in range(N)]

ans = 0
penalty = 0

for i in range(M):
    p, S = input().split()
    if p in solve_problem:
        continue

    if S == 'AC':
        solve_problem.add(p)
        ans += 1
        penalty += WA[int(p)-1]
    if S == 'WA':
        WA[int(p)-1] += 1

print('{} {}'.format(ans, penalty))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
solve_problem = []
d = {i: 0 for i in range(1, N+1)}
ans = 0
penalty = 0
for i in range(M):
    p, S = input().split()
    if S == 'AC' and p not in solve_problem:
        solve_problem.append(p)
        ans += 1
        penalty += d[int(p)]
    if S == 'WA':
        d[int(p)] += 1

print('{} {}'.format(ans, penalty))



Fixed submission:
N, M = map(int, input().split())
solve_problem = set()
WA = [0 for _ in range(N)]

ans = 0
penalty = 0

for i in range(M):
    p, S = input().split()
    if p in solve_problem:
        continue

    if S == 'AC':
        solve_problem.add(p)
        ans += 1
        penalty += WA[int(p)-1]
    if S == 'WA':
        WA[int(p)-1] += 1

print('{} {}'.format(ans, penalty))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))

ans = 0
m = 1
for i in a:
    m *= i

while True:
    if m % 2 == 0:
        ans += 1
        m //= 2
    else:
        break

print(ans)


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

ans = 0
for i in a:
    count = 0
    while True:
        if i % 2**(count+1) == 0:
            count += 1
        else:
            ans += count
            break

print(ans)
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())

S = ["."*W]
ans = 'Yes'
for i in range(H):
    s = input()
    S.append('.'+s+'.')

S.append('.'*W)

for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j] == '#':
            if S[i][j+1] == '#' or S[i][j-1] == '#' or S[i+1][j] == '#' or S[i-1][j] == '#':
                continue
            else:
                ans = 'No'
                break

print(ans)


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

S = ["."*(W+2)]
ans = 'Yes'
for i in range(H):
    s = input()
    S.append('.'+s+'.')

S.append('.'*(W+2))

for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j] == '#':
            if S[i][j+1] == '#' or S[i][j-1] == '#' or S[i+1][j] == '#' or S[i-1][j] == '#':
                continue
            else:
                ans = 'No'
                break

print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

l = list(range(a, b+1))


if a + k -1 >= b -k +1:
    for i in l:
        print(i)
else:
    for i in range(k):
        print(a+i)
    for i in range(k):
        print(b-k+i+1)





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

if b-a+1>2*k:
    for i in range(a, a+k):
        print(i)
    for i in range(b-k+1, b+1):
        print(i)
else:
    for i in range(a, b+1):
        print(i)

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

l = list(range(a, b+1))

small = l[0:k]
large = l[-k:]

ans = set(small+large)

for i in ans:
    print(i)


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

if b-a+1>2*k:
    for i in range(a, a+k):
        print(i)
    for i in range(b-k+1, b+1):
        print(i)
else:
    for i in range(a, b+1):
        print(i)
Buggy python submission (verdict: Runtime Error):
S = input()
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

for i in range(2):
    s = A
    op1 = '+' if i == 0 else '-'
    s += B if op1 == '+' else -1 * B
    for j in range(2):
        op2 = '+' if j == 0 else '-'
        s += C if op2 == '+' else -1 * C
        for k in range(2):
            op3 = '+' if k == 0 else '-'
            s += D if op3 == '+' else -1 * D
            if s == 7:
                ans = str(A)+op1+str(B)+op2+str(C)+op3+str(D)+'=7'

print(ans)


Fixed submission:
S = input()
A = S[0]
B = S[1]
C = S[2]
D = S[3]

op = ['+', '-']

def check(A, B, C, D):
    for i in range(2):
        for j in range(2):
            for k in range(2):
                x = A+op[i]+B+op[j]+C+op[k]+D
                if eval(x) == 7:
                    return x

print(check(A, B, C, D)+'=7')

Buggy python submission (verdict: Runtime Error):
A, B, C, D = list(input())
A = int(A)
B = int(B)
C = int(C)
D = int(D)

for i in range(2):
    s = A
    op1 = '+' if i == 0 else '-'
    s += B if op1 == '+' else -1 * B
    for j in range(2):
        op2 = '+' if j == 0 else '-'
        s += C if op2 == '+' else -1 * C
        for k in range(2):
            op3 = '+' if k == 0 else '-'
            s += D if op3 == '+' else -1 * D
            if s == 7:
                ans = str(A)+op1+str(B)+op2+str(C)+op3+str(D)+'=7'

print(ans)


Fixed submission:
S = input()
A = S[0]
B = S[1]
C = S[2]
D = S[3]

op = ['+', '-']

def check(A, B, C, D):
    for i in range(2):
        for j in range(2):
            for k in range(2):
                x = A+op[i]+B+op[j]+C+op[k]+D
                if eval(x) == 7:
                    return x

print(check(A, B, C, D)+'=7')
Buggy python submission (verdict: Runtime Error):
X = int(input())

ans = 10**9

def func(current, t):
    global ans
    if ans < t or current > X:
        return
    if current == X :
        ans = min([ans, t])
        return

    func(current+(t+1), t+1)
    func(current-(t+1), t+1)
    func(current, t+1)

func(0, 0)

print(ans)


Fixed submission:
X = int(input())

t = 0
i = 1
while True:
    t += i
    if t >= X:
        print(i)
        break
    else:
        i += 1
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

power = 1
for i in range(N):
    power *= (i+1)

print(power % (10**9+7))



Fixed submission:
N = int(input())

power = 1
for i in range(N):
    power *= (i+1)
    power = power % (10**9+7)

print(power)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

ans = 0

while True:
    if N >= 1 and M >= 2:
        N -= 1
        M -= 2
        ans += 1
    elif M >= 4:
        M -= 4
        ans += 1
    else:
        break
print(ans)


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

ans = 0

ans += min(N, M//2)

N -= ans
M -= ans * 2

ans += M // 4

print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()

ans = 'NO'
def func(T):
    global ans
    if len(T) > len(S):
        return
    if S == T:
        ans = 'YES'
        return

    if S[len(T)] == 'd':
        func(T+'dream')
        func(T+'dreamer')
    if S[len(T)] == 'e':
        func(T+'erase')
        func(T+'eraser')

func('')

print(ans)



Fixed submission:
S = input()

ans = 'YES'

while S:
    if S.endswith('eraser'):
        S = S[:-6]
    elif S.endswith('erase'):
        S = S[:-5]
    elif S.endswith('dreamer'):
        S = S[:-7]
    elif S.endswith('dream'):
        S = S[:-5]
    else:
        ans = 'NO'
        break

print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()

ans = 'NO'
def func(T):
    global ans
    if len(T) > len(S):
        return
    if S == T:
        ans = 'YES'
        return

    func(T+'dream')
    func(T+'dreamer')
    func(T+'erase')
    func(T+'eraser')

func('')

print(ans)



Fixed submission:
S = input()

ans = 'YES'

while S:
    if S.endswith('eraser'):
        S = S[:-6]
    elif S.endswith('erase'):
        S = S[:-5]
    elif S.endswith('dreamer'):
        S = S[:-7]
    elif S.endswith('dream'):
        S = S[:-5]
    else:
        ans = 'NO'
        break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
INF = 10**10

def chmax(a, b):
    if(a>b):
        return a
    else:
        return b

def chmin(a, b):
    if(a<b):
        return a
    else:
        return b


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

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

dp = N*[INF]
dp[0]=0


for i in range(1,N):
    for j in range(1,K+1):
        dp[i] = chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
        if i < j:
            break

#print(dp)
print(dp[N-1])

Fixed submission:
INF = 10**10

def chmax(a, b):
    if(a>b):
        return a
    else:
        return b

def chmin(a, b):
    if(a<b):
        return a
    else:
        return b


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

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

dp = N*[INF]
dp[0]=0


for i in range(1,N):
    for j in range(1,K+1):
        dp[i] = chmin(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
        if i < j:
            break

#print(dp)
print(dp[N-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
print(N - K + 1)

Fixed submission:
IN1 = input().split()
N = int(IN1[0])
K = int(IN1[1])
print(N - K + 1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split(" ")]
Q = int(input())
for i in range(Q):
    B,C = map(int,input().split(" "))
    A = [C if i == B else i for i in A]
    print(sum(A))

Fixed submission:
from collections import Counter
N = int(input())
A = [int(i) for i in input().split(" ")]
count = Counter(A)
S = sum(A)
Q = int(input())
for i in range(Q):
    B,C = map(int,input().split(" "))
    n = count[B]
    count[B] -= n
    count[C] += n
    S = S - B*n + C*n
    print(S)
Buggy python submission (verdict: Time Limit Exceeded):
import math
def is_prime(num):
    for i in range(2, num):  # 第二引数は sqrt(num)+1 でも良い
        if num % i == 0:
            return False

    return True
X = int(input())
if X==1:
    print(0,-1) 
else:
    if is_prime(X):
        d = X
    else:
        d = 2
        while(X%d!=0):
            d+=1
            
    b = -(10**3)
    a = b+d
    
    while(X!=((a**5)-(b**5))):
        b+=1
        a+=1
    print(a,b)

Fixed submission:
X = int(input())

A = range(-118,120)
B = range(-118,120)
flag = 0
for a in A:
  for b in B:
    ans = a**5 - b**5
    if ans == X:
      print("{} {}".format(a,b))
      flag=1
      break
  if flag:
    break

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
if X==1:
    print(0,-1) 
else:
    d = 2
    while(X%d!=0):
        d+=1
    b = -(10)
    a = b+d
    while(X!=((a**5)-(b**5))):
        b+=1
        a+=1
    print(a,b)

Fixed submission:
X = int(input())

A = range(-118,120)
B = range(-118,120)
flag = 0
for a in A:
  for b in B:
    ans = a**5 - b**5
    if ans == X:
      print("{} {}".format(a,b))
      flag=1
      break
  if flag:
    break

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
if X==1:
    print(0,-1) 
else:
    d = 2
    while(X%d!=0):
        d+=1
    b = -(10**2)
    a = b+d
    while(X!=((a**5)-(b**5))):
        b+=1
        a=b+d
    print(a,b)

Fixed submission:
X = int(input())

A = range(-118,120)
B = range(-118,120)
flag = 0
for a in A:
  for b in B:
    ans = a**5 - b**5
    if ans == X:
      print("{} {}".format(a,b))
      flag=1
      break
  if flag:
    break

Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())
d = 2
while(X%d!=0):
    d+=1
b = -(10**4)
a = b+d
while(X!=((a**5)-(b**5))):
    b+=1
    a=b+d
print(a,b)

Fixed submission:
X = int(input())

A = range(-118,120)
B = range(-118,120)
flag = 0
for a in A:
  for b in B:
    ans = a**5 - b**5
    if ans == X:
      print("{} {}".format(a,b))
      flag=1
      break
  if flag:
    break
Buggy python submission (verdict: Runtime Error):
from collections import Counter

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

s = ""

while(len(s)<=N):
  s+="b"*A
  if len(s)>N:
      break
  s+="r"*B
ans = Counter(s[:N])["b"]
print(ans)

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

M = A+B

C = N//M

b = N-(C*M)
if b>=A:
    print((C+1)*A)
else:
    print(b+C*A)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
List = [int(i) for i in input().split(" ")]
flag = 0
for j in range(N-1):
    for k in range(j+1,N):
        if List[j]==List[k]:
            flag = 1
            break
        if flag==1:
            break
if flag==1:
    print("NO")
else:
    print("YES")

Fixed submission:
N = int(input())
List = [i for i in input().split(" ")]
Dict = {}
flag=0
for i in range(N):
    try:
        Dict[List[i]] += 1
    except KeyError:
        Dict[List[i]] = 1
        
list2 = list(Dict.values())
for j in range(len(list2)):
    if list2[j]>1:
        flag=1
if flag==1:
    print("NO")
else:
    print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
Input1 = [int(_) for _ in input().split(" ")]
Input2 = [(int(i)+1)/2 for i in input().split(" ")]

cemsum = [0]*(Input1[0]-Input1[1]+1)

for j in range(0,Input1[0]-Input1[1]+1):
    cemsum[j] = sum(Input2[j:j+Input1[1]])

print(max(cemsum))

Fixed submission:
Input1 = [int(_) for _ in input().split(" ")]
Input2 = [(int(i)+1)/2 for i in input().split(" ")]

sum_ = sum(Input2[:Input1[1]])
Max = sum_
for j in range(Input1[0]-Input1[1]):
    sum_ = sum_-Input2[j]+Input2[j+Input1[1]]
    if Max  < sum_:
        Max = sum_
        
print(Max)

Buggy python submission (verdict: Time Limit Exceeded):
NK = [int(i) for i in input().split(" ")]
list1 = [(int(i)+1)/2 for i in input().split(" ")]
list2 = []
for j in range(NK[0]-NK[1]+1):
    list2.append(sum(list1[j:j+NK[1]]))
        
print(max(list2))

Fixed submission:
Input1 = [int(_) for _ in input().split(" ")]
Input2 = [(int(i)+1)/2 for i in input().split(" ")]

sum_ = sum(Input2[:Input1[1]])
Max = sum_
for j in range(Input1[0]-Input1[1]):
    sum_ = sum_-Input2[j]+Input2[j+Input1[1]]
    if Max  < sum_:
        Max = sum_
        
print(Max)

Buggy python submission (verdict: Time Limit Exceeded):
NK = [int(i) for i in input().split(" ")]
list1 = [(int(i)+1)/2 for i in input().split(" ")]
Max = 0
for j in range(NK[0]-NK[1]+1):
    if Max<sum(list1[j:j+NK[1]]):
        Max=sum(list1[j:j+NK[1]])
print(Max)

Fixed submission:
Input1 = [int(_) for _ in input().split(" ")]
Input2 = [(int(i)+1)/2 for i in input().split(" ")]

sum_ = sum(Input2[:Input1[1]])
Max = sum_
for j in range(Input1[0]-Input1[1]):
    sum_ = sum_-Input2[j]+Input2[j+Input1[1]]
    if Max  < sum_:
        Max = sum_
        
print(Max)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = input().split(" ")
P = [int(n) for n in l]

# i=1は必ずOK
c = 1

for i in range(1,N):
  n_i = P[i]
  p = P[:i+1]
  
  for j in range(i+1):
    if p[j] < n_i:
      break
      
  if j==i:
    c+=1
    
print(c)

Fixed submission:
N = int(input())
l = input().split(" ")
P = [int(n) for n in l]

# i=1は必ずOK
c = 1
min = P[0]

for i in range(1,N):
  p = P[i]
  if p<=min:
    c+=1
    min=p
    
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
In = input().split(" ")
T = int(In[0])
A = int(In[1])
K = int(In[2])
 
if K>=T+A:
  print("0 0")
else:
  if (K > T):
    print("0 {0}".format(A-(K-T)))
  elif (T > K):
    print("{0} {1}".format(T-K, A))
  else:
    for i in range(K):
      if T >= 1:
        T -= 1
      else:
        if A >= 1:
          A -= 1
        else:
          break
    print("{0} {1}".format(T, A))

Fixed submission:
In = input().split(" ")
T = int(In[0])
A = int(In[1])
K = int(In[2])
 
if K <= T:
  print("{0} {1}".format(T-K,A))
elif K <= T+A:
  print("0 {0}".format(A-(K-T)))
else:
  print("0 0")

Buggy python submission (verdict: Runtime Error):
In = input().split(" ")
T = int(In[0])
A = int(In[1])
K = int(In[2])
 
if K>=T+A:
  print("0 0")
else:
	if (K > T):
  		print("0 {0}".format(A-(K-T)))
	elif (T > K):
  		print("{0} {1}".format(T-K, A))
	else:
  		for i in range(K):
    		if T >= 1:
     			 T -= 1
    		else:
    			if A >= 1:
      				A -= 1
    			else:
      				break
  		print("{0} {1}".format(T, A))

Fixed submission:
In = input().split(" ")
T = int(In[0])
A = int(In[1])
K = int(In[2])
 
if K <= T:
  print("{0} {1}".format(T-K,A))
elif K <= T+A:
  print("0 {0}".format(A-(K-T)))
else:
  print("0 0")

Buggy python submission (verdict: Time Limit Exceeded):
In = input().split(" ")
T = int(In[0])
A = int(In[1])
K = int(In[2])
 
if K>=T+A:
  print("0 0")
  
elif (K > T):
  print("0 {0}".format(A-(K-T)))
elif (T > K):
  print("{0} {1}".format(T-K, A))
else:
  for i in range(K):
    if T >= 1:
      T -= 1
    else:
    	if A >= 1:
      		A -= 1
    	else:
      		break
  print("{0} {1}".format(T, A))

Fixed submission:
In = input().split(" ")
T = int(In[0])
A = int(In[1])
K = int(In[2])
 
if K <= T:
  print("{0} {1}".format(T-K,A))
elif K <= T+A:
  print("0 {0}".format(A-(K-T)))
else:
  print("0 0")

Buggy python submission (verdict: Time Limit Exceeded):
In = input().split(" ")
T = int(In[0])
A = int(In[1])
K = int(In[2])
 
if K>=T+A:
  print("0 0")
  
elif (K > T):
  print("0 {0}".format(A-(K-T)))
elif (T > K):
  print("{0} {1}".format(T-K, A))
else:
  for i in range(K):
    if T >= 1:
      T -= 1
    elif A >= 1:
      A -= 1
    else:
      break
  print("{0} {1}".format(T, A))

Fixed submission:
In = input().split(" ")
T = int(In[0])
A = int(In[1])
K = int(In[2])
 
if K <= T:
  print("{0} {1}".format(T-K,A))
elif K <= T+A:
  print("0 {0}".format(A-(K-T)))
else:
  print("0 0")

Buggy python submission (verdict: Time Limit Exceeded):
In = input().split(" ")
T = int(In[0])
A = int(In[1])
K = int(In[2])

if K>=T+A:
  print("0 0")
  
elif (K > T):
  print("0 {0}".format(A-(K-T)))
elif (T > K):
  print("{0} {1}".format(T-K, A))
else:
  for i in range(K):
    if T >= 1:
      T -= 1
    elif A >= 1:
      A -= 1
  print("{0} {1}".format(T, A))

Fixed submission:
In = input().split(" ")
T = int(In[0])
A = int(In[1])
K = int(In[2])
 
if K <= T:
  print("{0} {1}".format(T-K,A))
elif K <= T+A:
  print("0 {0}".format(A-(K-T)))
else:
  print("0 0")
Buggy python submission (verdict: Runtime Error):
N = int(input())
List = [int(j) for j in input().split(" ")]
Sum = 0
for n in range(0,N-1):
  for m in range(n+1,N):
    Sum += List[i]*List[j]
print(Sum)

Fixed submission:
N = int(input())
List = [int(j) for j in input().split(" ")]
Sum = 0
for n in range(0,N-1):
  for m in range(n+1,N):
    Sum += List[n]*List[m]
print(Sum)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split(" "))
List = sorted([int(i) for i in input().split(" ")],reverse=True)
h=0
while(List[h]>=K):
    h+=1
print(h)

Fixed submission:
N,K = map(int,input().split(" "))
List = [int(i) for i in input().split(" ") if int(i)>=K]
print(len(List))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,K,Q = map(int, input().split(" "))

List = np.array([K]*N)

for i in range(Q):
  diff = np.array([1]*N)
  n = int(input())
  diff[n-1] = 0
  List-=diff

for i in range(N):
  if List[i]>0:
    print("Yes")
  else:
    print("No")

Fixed submission:
N,K,Q = map(int, input().split(" "))

List = [K-Q]*N

for i in range(Q):
  n = int(input())
  List[n-1]+=1

for i in range(N):
  if List[i]>0:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
print(int(N*(N-1)/2))

Fixed submission:
S = input()
T = input()
count = 0

for i in range(len(S)):
  if S[i]==T[i]:
    count += 1
    
print(count)

Buggy python submission (verdict: Runtime Error):
T = input()
count = 0

for i in range(len(S)):
  if S[i]==T[i]:
    count += 1
    
print(count)

Fixed submission:
S = input()
T = input()
count = 0

for i in range(len(S)):
  if S[i]==T[i]:
    count += 1
    
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
list = [i+1 for i in range(N)]
sum = 0

for i in range(1,N):
  sum += i

print(sum)

Fixed submission:
N = int(input())
print(N*(N-1)//2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
list = [i+1 for i in range(N)]
sum = 0

for i in range(1,N+1):
  if i == N:
    sum += i%1
  else:
    sum += i%list[i]

print(sum)

Fixed submission:
N = int(input())
print(N*(N-1)//2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
str = [input().sort for i in range(N)]
dict = {}
count = 0

print(str)

Fixed submission:
N = int(input())
str = [''.join(sorted(input())) for i in range(N)]
dict = {}
sum = 0

for i in range(N):
  try:
    dict[str[i]] += 1
  except KeyError:
    dict[str[i]] = 1

for i in dict.values():
  sum += (i*(i-1))//2

print(sum)
Buggy python submission (verdict: Runtime Error):
S = input()

Dict = {}

for i in range(4):
  s = S[i]
  if s in Dict:
    Dict[s] += 1
  else:
    Dict[s]=1
if len(Dict)!=2:
  print("No")
else:
  if Dict[0]!=2 or Dict[1]!=2:
    print("No")
  else:
    print("Yes")

Fixed submission:
S = input()
 
Dict = {}
 
for i in range(4):
  s = S[i]
  if s in Dict:
    Dict[s] += 1
  else:
    Dict[s]=1
    
if len(Dict)!=2:
  print("No")
else:
    List = list(Dict.values())
    if List[0]!=2 or List[1]!=2:
        print("No")
    else:
        print("Yes")
Buggy python submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split(" "))
W = (B-A+1)
x = C*D//math.gcd(C,D)

c = (B//C) - ((A-1)//C)
d = (B//D) - ((A-1)//D)
j = (B//x) - ((A-1)//x)

div = (c+d-j)
print(W-div)

Fixed submission:
import fractions
A, B, C, D = map(int, input().split(" "))
W = (B-A+1)
x = C*D//fractions.gcd(C,D)

c = (B//C) - ((A-1)//C)
d = (B//D) - ((A-1)//D)
j = (B//x) - ((A-1)//x)

div = (c+d-j)
print(W-div)
Buggy python submission (verdict: Runtime Error):
def next_pos(D,L):
    return D+L
    
N, X = map(int,input().split(" "))
L = [int(i) for i in input().split(" ")]
D = 0
count = 0
i = 0

while(D<=X or i<N):
    D = next_pos(D,L[i])
    count+=1
    i+=1
    
print(count)

Fixed submission:
N, X = map(int,input().split(" "))
L = [int(i) for i in input().split(" ")]
D = 0
count = 1
for i in range(N):
    D+=L[i]
    if D<=X:
        count+=1
    
print(count)

Buggy python submission (verdict: Runtime Error):
def next_pos(D,L):
    return D+L
    
N, X = map(int,input().split(" "))
L = [int(i) for i in input().split(" ")]
D = 0
count = 0
i = 0

while(D<=X):
    D = next_pos(D,L[i])
    count+=1
    i+=1
    
print(count)

Fixed submission:
N, X = map(int,input().split(" "))
L = [int(i) for i in input().split(" ")]
D = 0
count = 1
for i in range(N):
    D+=L[i]
    if D<=X:
        count+=1
    
print(count)
Buggy python submission (verdict: Runtime Error):
W,H,x,y = map(float,input().split(" "))

WH = W*H
W,H,x,y = map(float,input().split(" "))

WH = W*H

w = (W-x)*H
h = (H-y)*W

if (WH-w)<w:
    w = (WH-w)
if (WH-h)<h:
    h = (WH-h)

if w>h:
    print("{} ".format(w),end="")
else:
    print("{} ".format(h),end="")

if w!=h:
    print("0")
else:
    print("1")

Fixed submission:
W,H,x,y = map(int,input().split(" "))

Max = W*H/2

if x*2 == W and y*2 == H:
    ver = 1
else:
    ver = 0
    
print("{} {}".format(Max,ver))
Buggy python submission (verdict: Runtime Error):
if Age>=13:
  print(Fee)
elif Age<13 and Age>=6:
  print(Fee//2)
else:
  print(0)


Fixed submission:
Age, Fee = map(int,input().split(" "))
if Age>=13:
  print(Fee)
elif Age<13 and Age>=6:
  print(Fee//2)
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,M = map(int,input().split(" "))
ID = np.array([0]*N)

for _ in range(M):
    l = np.array([0]*N)
    L,R = map(int,input().split(" "))
    l[L-1:R] = 1
    ID+=l

print(len(ID[ID==M]))
    

Fixed submission:
N,M = map(int,input().split(" "))
Min = 1
Max = N

for _ in range(M):
    L,R = map(int,input().split(" "))
    if L>Min:
        Min=L
    if R<Max:
        Max=R
if Max-Min>=0:
    print(Max-Min+1)
else:
    print(0)