Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = int(input())
if N < 3 or 2 * (10**5) < N:
	print("error\nボールは3個以上200000以下")
	sys.exit()

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

set_lst = [x for x in set(A)]
nums_mutch = [0] * len(set_lst)
i = 0
while not i == len(set_lst):
	if set_lst[i] == 0:
		i += 1
		continue
	else:
		nums_mutch[i] =  A.count(set_lst[i])
		i += 1

all_flag = [int((x * (x - 1)) / 2) for x  in nums_mutch]
k = 0
while not k == N:
	klist = all_flag.copy()
	index_k = set_lst.index(A[k])
	kflag = nums_mutch[index_k] - 1
	klist[index_k] = int((kflag * (kflag - 1)) / 2)
	print(sum(klist))
	k += 1

Fixed submission:
N=int(input())
A=list(input().split())
check=[0]*N
for i in range(N):
	check[int(A[i])-1]+=1
num=0
for i in range(N):
	num+=check[i]*(check[i]-1)//2
for i in range(N):
	if check[int(A[i])-1]!=2:
		print(num-(check[int(A[i])-1]-1))
	else:
		print(num-1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = int(input())
if N < 3 or 2 * (10**5) < N:
	print("error\nボールは3個以上200000以下")
	sys.exit()

A = list(map(int, input().split()))
k = 0
while not k == len(A):
	# k番目の要素を除外したリストを作成
	tmp = [v for i, v in enumerate(A) if not i == k]
	# 何回等しくなったかflagで確認
	flag = 0
	j = 0
	while not j == len(tmp) - 1:
		h = j + 1
		while not h == len(tmp):

			if (tmp[j] == tmp[h]) and (not j == h):
				flag += 1
			h += 1
		j += 1
	print(flag)
	k += 1

Fixed submission:
N=int(input())
A=list(input().split())
check=[0]*N
for i in range(N):
	check[int(A[i])-1]+=1
num=0
for i in range(N):
	num+=check[i]*(check[i]-1)//2
for i in range(N):
	if check[int(A[i])-1]!=2:
		print(num-(check[int(A[i])-1]-1))
	else:
		print(num-1)
Buggy python submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(n):
        a.append(a[i]+A[i])
for i in range(m):
        b.append(b[i]+B[i])

ans, j = 0, M

for i in range(N+1):
        if a[i] > K:
                break
        while b[j] > K - a[i]:
                j -= 1
        ans = max(ans, i+j)

print(ans)

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

a, b = [0], [0]
for i in range(N):
        a.append(a[i]+A[i])
for i in range(M):
        b.append(b[i]+B[i])

ans, j = 0, M

for i in range(N+1):
        if a[i] > K:
                break
        while b[j] > K - a[i]:
                j -= 1
        ans = max(ans, i+j)

print(ans)

Buggy python submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0],[0]
for i in range(n):
        a.append(a[i]+A[i])
for i in range(m):
        b.append(b[i]+B[i])

ans, j = 0, M

for i in range(N+i):
        if a[i] > K:
                break
        while b[j] > K - a[i]:
                j -= 1
        ans = max(ans, i+j)

print(ans)


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

a, b = [0], [0]
for i in range(N):
        a.append(a[i]+A[i])
for i in range(M):
        b.append(b[i]+B[i])

ans, j = 0, M

for i in range(N+1):
        if a[i] > K:
                break
        while b[j] > K - a[i]:
                j -= 1
        ans = max(ans, i+j)

print(ans)

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

a_sum = [0]
for i, minute in enumerate(a):
        a_sum.append(a_sum(i)+minute)
b_sum = [0]
for i, minute in enumerate(b):
        b_sum.append(b_sum(i)+minute)

B = m
ans_list = []

for i in a_sum:
        if i > k:
                ans_list.append(i)
                continue
        for j in b_sum[::-1]:
                if j <= k-i:
                        ans_list.append(i+B)
                        break
                elif j > k-i:
                        B -= 1

print(max(ans_list))


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

a, b = [0], [0]
for i in range(N):
        a.append(a[i]+A[i])
for i in range(M):
        b.append(b[i]+B[i])

ans, j = 0, M

for i in range(N+1):
        if a[i] > K:
                break
        while b[j] > K - a[i]:
                j -= 1
        ans = max(ans, i+j)

print(ans)
Buggy python submission (verdict: Runtime Error):
t = input()
ans = t.replace(?, D)
print(ans)


Fixed submission:
t = input()
ans = t.replace("?", "D")
print(ans)
Buggy python submission (verdict: Runtime Error):
s, t = input().split()
x = zip(s, t)
y = []
for i, j in x:
    if i == j:
        y.append('')
    else:
        y.append('@')
print(y.count('@'))

Fixed submission:
a = input()
b = input()
u=zip(a,b)
x=[]
for i,j in u: 
    if i==j:
        x.append("") 
    else: 
        x.append("*")
print (x.count("*"))
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
n = n % k
absolutes = abs(k-n)
print(absolutes if absolute < n else n)

Fixed submission:
N,K = map(int, input().split())
N = N%K
absolute = abs(K-N)
print(absolute if absolute < N else N)
Buggy python submission (verdict: Runtime Error):
a, b = map.(int, input().split())
if(a==b):
    print("Yes")
    else:
	print("No")

Fixed submission:
a,b = input().split()
a = int(a)
b = int(b)
string = ""
if a>b:
    for i in range(a):
        string = string+str(b)
elif b>a:
    for i in range(b):
        string = string+str(a)
else:
    for i in range(a):
        string =  string+str(a)
print(string)
Buggy python submission (verdict: Runtime Error):
N = input()
S = input()
count = 0
if(int(N)>=3 and int(N)<=50):
    for i in range(1, int(N)-1):
        if S[i-1]+S[i]+S[i+1] == "ABC":
            count += 1
    print(count)
Seen by Sokhom Sovichea at 19:59

Fixed submission:
n = int(input())
s = str(input())
print(s.count("ABC"))

Buggy python submission (verdict: Runtime Error):
    N = input()
    S = input()
    count = 0
    if int(N) >= 3 and int(N) <= 50:
      for i in range(1, int(N)-1):
        if S[i-1] + S[i] + S[i+1] == "ABC":
          count += 1
    print(count)

Fixed submission:
n = int(input())
s = str(input())
print(s.count("ABC"))

Buggy python submission (verdict: Runtime Error):
N = input()
S = input()
count = 0
if int(N) >= 3 and int(N) <= 50:
  for i in range(1, int(N)-1):
    if s[i-1] + s[i] + s[i+1] == "ABC":
      count += 1
print(count)

Fixed submission:
n = int(input())
s = str(input())
print(s.count("ABC"))

Buggy python submission (verdict: Runtime Error):
N = input()
S = input()
count = 0
for i in range(1, int(N)-1):
  if s[i-1] + s[i] + s[i+1] == "ABC":
    count += 1
print(count)

Fixed submission:
n = int(input())
s = str(input())
print(s.count("ABC"))

Buggy python submission (verdict: Runtime Error):
N = input()
S = input()
for i in range(1, int(N)-1):
    if s[i-1] + s[i] + s[i+1] == "ABC":
        count += 1
print(count)

Fixed submission:
n = int(input())
s = str(input())
print(s.count("ABC"))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

count = [0]*(10**5+1)
for i in range(len(A)):
  count[A[i]] += 1

A = list(set(A))
for i in range(Q):
  B, C = map(int, input().split())
  count[C] += count[B]
  count[B] = 0
  ans = 0
  for i in range(10**5+1):
    ans += count[i] * i
  print(ans)
  

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
S = sum(A)
count = [0]*(10**5+1)
for i in range(len(A)):
  count[A[i]] += 1

A = list(set(A))
for i in range(Q):
  B, C = map(int, input().split())
  S = S - B*count[B] + C*count[B]
  count[C] += count[B]
  count[B] = 0
  print(S)

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

count = [0]*(10**5)
for i in range(len(A)):
  count[A[i]] += 1

A = list(set(A))
for i in range(Q):
  B, C = map(int, input().split())
  count[C] += count[B]
  count[B] = 0
  ans = 0
  for i in range(len(A)):
    ans += count[A[i]] * A[i]
  print(ans)
  

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
S = sum(A)
count = [0]*(10**5+1)
for i in range(len(A)):
  count[A[i]] += 1

A = list(set(A))
for i in range(Q):
  B, C = map(int, input().split())
  S = S - B*count[B] + C*count[B]
  count[C] += count[B]
  count[B] = 0
  print(S)

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

count = [0]*(10**5)
for i in range(len(A)):
  count[A[i]] += 1


for i in range(Q):
  B, C = map(int, input().split())
  if count[B] != 0:
    count[C] += count[B]
    count[B] = 0
  ans = 0
  for i in range(len(A)):
    ans += count[A[i]]*A[i]
  print(ans)
  

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
S = sum(A)
count = [0]*(10**5+1)
for i in range(len(A)):
  count[A[i]] += 1

A = list(set(A))
for i in range(Q):
  B, C = map(int, input().split())
  S = S - B*count[B] + C*count[B]
  count[C] += count[B]
  count[B] = 0
  print(S)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
#A = [0]
B = list(map(int, input().split()))
#A += B
#print(A)

sig = [0] * N

for i in range(N-1):
  print(B.count(i+1))
print(0)

#print(sig)
#for i in sig:
#  print(i)

Fixed submission:
N = int(input())
A = [0]
B = list(map(int, input().split()))
A += B
#print(A)

sig = [0] * N

for i in range(N-1):
  sig[A[i+1]-1] += 1
#print(sig)

#print(sig)
for i in sig:
  print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
#A = [0]
B = list(map(int, input().split()))
#A += B
#print(A)

sig = [0] * N

for i in range(N-1):
  print(B.count(i+1))
print(0)

#print(sig)
#for i in sig:
#  print(i)

Fixed submission:
N = int(input())
A = [0]
B = list(map(int, input().split()))
A += B
#print(A)

sig = [0] * N

for i in range(N-1):
  sig[A[i+1]-1] += 1
#print(sig)

#print(sig)
for i in sig:
  print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0]
B = list(map(int, input().split()))
A += B
#print(A)

sig = [0] * N

for i in range(N):
  sig[i] = A.count(i+1)

#print(sig)
for i in sig:
  print(i)

Fixed submission:
N = int(input())
A = [0]
B = list(map(int, input().split()))
A += B
#print(A)

sig = [0] * N

for i in range(N-1):
  sig[A[i+1]-1] += 1
#print(sig)

#print(sig)
for i in sig:
  print(i)
Buggy python submission (verdict: Time Limit Exceeded):
import math

K = int(input())

sum = 0
for a in range(K):
  for b in range(K):
    for c in range(K):
      sum += math.gcd(math.gcd(a+1, b+1), c+1)
      
print(sum)

Fixed submission:
import math

K = int(input())

sum = 0
gcd = 0
for a in range(K):
  for b in range(K):
    gcd = math.gcd(a+1, b+1)
    for c in range(K):
      sum += math.gcd(gcd, c+1)
      
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for i in range(N)]
S_set = sorted(list(set(S)))
L = len(S_set)

count = [0]*L
for i in range(L):
  count[i] = S.count(S_set[i])

#print(S_set)
M = max(count)
for i in range(L):
  if count[i] == M:
    print(S_set[i])

Fixed submission:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]

S_c = Counter(S)
max_count = max(S_c.values())

ans = []

for key, value in S_c.items():
  if value == max_count:
    ans.append(key)
    
ans.sort()

for i in range(len(ans)):
  print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = [input() for i in range(N)]
S_set = sorted(list(set(S)))

count = [0]*len(S_set)
for i in range(len(S_set)):
  count[i] = S.count(S_set[i])

#print(S_set)
for i in range(len(S_set)):
  if count[i] == max(count):
    print(S_set[i])

Fixed submission:
from collections import Counter
N = int(input())
S = [input() for i in range(N)]

S_c = Counter(S)
max_count = max(S_c.values())

ans = []

for key, value in S_c.items():
  if value == max_count:
    ans.append(key)
    
ans.sort()

for i in range(len(ans)):
  print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))

judge = [1]*N
for i in range(N):
  for j in range(i):
    if P[i] > P[j]:
      judge[i] = 0
      break
print(judge.count(1))

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

ans = 1
tmp = P[0]
for i in range(1,N):
  if P[i] <= tmp:
    ans+=1
    tmp = P[i]
print(ans)

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

judge = [1]*N
for i in range(N):
  for j in range(i):
    if P[i] > P[j]:
      judge[i] = 0
print(judge.count(1))

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

ans = 1
tmp = P[0]
for i in range(1,N):
  if P[i] <= tmp:
    ans+=1
    tmp = P[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
x = []
y = []
words = []
for i in range(N):
  A = int(input())
  W = []
  for _ in range(A):
    x, y = map(int, input().split())
    W.append([x-1, y])
  words.append(W)
  
ans = 0
for bit in range(1<<n):
  ok = True
  is_honest = [(bit>>i) & 1 for i in range(N)]
  for i in range(N):
    if not is_honest[i]:
      continue
    for x, y in words[i]:
      if is_honest[x] != y:
        ok = False
  if ok:
    ans = max(ans, sum(is_honest))
print(ans)

Fixed submission:
N = int(input())
x = []
y = []
words = []
for i in range(N):
  A = int(input())
  W = []
  for _ in range(A):
    x, y = map(int, input().split())
    W.append([x-1, y])
  words.append(W)
  
ans = 0
for bit in range(1<<N):
  ok = True
  is_honest = [(bit>>i) & 1 for i in range(N)]
  for i in range(N):
    if not is_honest[i]:
      continue
    for x, y in words[i]:
      if is_honest[x] != y:
        ok = False
  if ok:
    ans = max(ans, sum(is_honest))
print(ans)
Buggy python submission (verdict: Runtime Error):
k = list(map(int, input().split()))
h = list(map(int, input().split()))
m = [list(map(int, input().split())) for i in range(k[1])]

import networkx as nx

G = nx.Graph()
for i in range(len(k)):
  G.add_node(i +1)
for i in m:
  G.add_edge(i[0],i[1])

#print(k[0] - len(G.nodes()))
re = 0

for i in list(G.nodes):
  max_height = max([h[x - 1] for x in list(nx.all_neighbors(G, i))])
  if h[i-1] > max_height:
    re +=1
print(re + k[0] - len(G.nodes()))

Fixed submission:
k = list(map(int, input().split()))
h = list(map(int, input().split()))
m = [list(map(int, input().split())) for i in range(k[1])]

import networkx as nx
G = nx.Graph()
for i in range(k[0]):
  G.add_node(i +1)
for i in m:
  G.add_edge(i[0],i[1])
re = 0
for i in list(G.nodes):
  if len(list(nx.all_neighbors(G, i))) != 0:
    max_height = max([h[x - 1] for x in list(nx.all_neighbors(G, i))])
    if h[i-1] > max_height:
      re +=1
  else:
    re +=1
print(re)
Buggy python submission (verdict: Runtime Error):
k = int(input())
l = list(map(int, input.split()))
if l[1] - l[0] >= k:
  print("OK")
elif l[0] == l[1]:
  if l[0] % k == 0:
    print("OK")
  else:
    print("NG")
else:
    print("NG")

Fixed submission:
k = int(input())
l = list(map(int, input().split()))
if (l[1] - l[0]) >= k or l[0] % k == 0 or l[1] % k == 0:
  print("OK")
else:
  while l[0] != l[1]:
    l[0] += 1
    if l[0] % k == 0:
      print("OK")
      exit()
  print("NG")

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

if l[1] - l[0] >= k:
  print("OK")
elif l[0] == l[1]:
  if l[0] % k == 0:
    print("OK")
  else:
    print("NG")
else:
    print("NG")

Fixed submission:
k = int(input())
l = list(map(int, input().split()))
if (l[1] - l[0]) >= k or l[0] % k == 0 or l[1] % k == 0:
  print("OK")
else:
  while l[0] != l[1]:
    l[0] += 1
    if l[0] % k == 0:
      print("OK")
      exit()
  print("NG")
Buggy python submission (verdict: Runtime Error):
k = list(map(int,input().split()))
t = k[0]//k[3]
a = k[2]//k[1]
if t >= k:
  print("Yes")
else:
  print("No")

Fixed submission:
k = list(map(int, input().split() ) )
t = 1
while k[0] > 0 and k[2] > 0:
  if t == 1:
    k[2] -= k[1]
    t=2
  else:
    k[0] -= k[3]
    t=1
if t==2:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
k = list(map(int,input().split()))
t = k[0] // k[3]
a = k[2] // k[1]
if t >= k:
  print("Yes")
else:
  print("No")

Fixed submission:
k = list(map(int, input().split() ) )
t = 1
while k[0] > 0 and k[2] > 0:
  if t == 1:
    k[2] -= k[1]
    t=2
  else:
    k[0] -= k[3]
    t=1
if t==2:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = list(map(int, input().split()))
re = True
num = n[0]
if n[1] == 1:
  print(0)
elif n[1] == 2:
  if n[0]%2 == 0:
    print(0)
  else:
    print(1)
else:
  while re:
    k = num - n[1]
    if num > abs(k):
      num = abs(k)
    else:
      re = False
  print(num)

Fixed submission:
n = list(map(int, input().split()))
k = n[0] % n[1]

if abs(k - n[1]) > k:
  print(k)
else:
  print(abs(k - n[1]))

Buggy python submission (verdict: Time Limit Exceeded):
n = list(map(int, input().split()))
re = True
num = n[0]
if n[1] == 1:
  print(0)
else:
  while re:
    k = num - n[1]
    if num > abs(k):
      num = abs(k)
    else:
      re = False
  print(num)

Fixed submission:
n = list(map(int, input().split()))
k = n[0] % n[1]

if abs(k - n[1]) > k:
  print(k)
else:
  print(abs(k - n[1]))
Buggy python submission (verdict: Time Limit Exceeded):
L = int(input())
if L % 3 == 0:
  b = [i + 1 for i in range(L)]
  k = [(i * (L - i) * (L - i)) / 4 for i in b]
  print(max(k))
else: 
  import numpy as np
  b = np.arange(0.1, L+0.001, 0.001)
  k = [(i * (L - i) * (L - i)) / 4 for i in b]
  print(max(k))

Fixed submission:
L = int(input())
if L % 3 == 0:
  b = [i + 1 for i in range(L)]
  k = [(i * (L - i) * (L - i)) / 4 for i in b]
  print(max(k))
else: 
  import numpy as np
  b = np.arange(0.1, L+0.005, 0.005)
  k = [(i * (L - i) * (L - i)) / 4 for i in b]
  print(max(k))
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
l = list(map(int, input().split()))
import collections
z = []
for i in range(k):
  m = [x for x in l]
  m.pop(i)
  n = collections.Counter(m)
  y = [x* (x -1) / 2 for x in n.values()]
  z.append(sum(y))

for i in range(k):
  print(int(z[i]))

Fixed submission:
k = int(input())
l = list(map(int, input().split()))
import collections
z = []
n = collections.Counter(l)
y = [x* (x -1) / 2 for x in n.values()]
mai = {}
plus = {}
for k in n.keys():
  plus.setdefault(k, ((n[k] - 1) * (n[k]) / 2) )
  mai.setdefault(k, ((n[k] - 1) * (n[k] -2) / 2) )

base = sum(y)
q = [base - (plus[i] - mai[i]) for i in l]
for i in range(len(q)):
  print(int(q[i]))
Buggy python submission (verdict: Runtime Error):
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(a[k])

Fixed submission:
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(a[k - 1])
Buggy python submission (verdict: Runtime Error):
Bingo = [ list(map(int,input().split())) for i in range(3)]
n = int(input())
num = [int(input()) for i in range(n)]
Bingo.append([Bingo[0][0] , Bingo[1][1],Bingo[2][2] ])
Bingo.append([Bingo[0][2] , Bingo[1][1],Bingo[2][0] ])
k=0
re = 'No'
for l in range(n):
  if len(list(set(num) & set(Bingo[l]))) == 3:
    re = 'Yes'
    break
print(re)

Fixed submission:
Bingo = [ list(map(int,input().split())) for i in range(3)]
n = int(input())
num = [int(input()) for i in range(n)]
Bingo.append([Bingo[0][0] , Bingo[1][1],Bingo[2][2] ])
Bingo.append([Bingo[0][2] , Bingo[1][1],Bingo[2][0] ])
for k in range(3):
  Bingo.append([Bingo[0][k] , Bingo[1][k],Bingo[2][k] ])
k=0
re = 'No'
for l in range(len(Bingo)):
  if len(list(set(num) & set(Bingo[l]))) == 3:
    re = 'Yes'
    break
print(re)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())

if 500* A >= B:
  print("Yes")
else:
  print("No")

Fixed submission:
A, B = map(int, input().split())
if 500*A >= B:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
A,B,N = map(int, input().split())

import math

ans=0
if N < B:
  end = N + 1
else:
  end = B

for x in range(1,end):
  tmp=math.floor(A*x/B) - A * math.floor(x/B)
  if tmp > ans:
    ans = tmp

for x in range(B-1,N,B):
  tmp=math.floor(A*x/B) - A * math.floor(x/B)
  if tmp > ans:
    ans = tmp
  
print(tmp)


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

import math

ans=0
if N < B:
  end = N
else:
  end = B -1

x = end
tmp=math.floor(A*x/B) - A * math.floor(x/B)
  
print(tmp)
Buggy python submission (verdict: Runtime Error):
import sys
A,B,C,D = list(map(int,input().split()))

while True:
  C = C - B
  A -= D
  print(C)
  print(A)
  if C <= 0:
    print("Yes")
    sys.exit(1)
  elif A <= 0:
    print("No")
    sys.exit(1)

Fixed submission:
import sys
A,B,C,D = list(map(int,input().split()))

while True:
  C = C - B
  A -= D
  if C <= 0:
    print("Yes")
    sys.exit(0)
  elif A <= 0:
    print("No")
    sys.exit(0)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [int(i) for i in input().split()]

a.insert(0,0)
result = []

for i in range(1,N+1):
  idx = a.index(i)
  result.append(idx)

print(*result)

Fixed submission:
N = int(input())
a = [int(i) for i in input().split()]

a.insert(0,0)
result = []

tmp = []
for i in range(N+1):
  tmp.append([a[i],i])

tmp_sorted = sorted(tmp)

for i in range(1,N+1):
  result.append(tmp_sorted[i][1])

print(*result)
Buggy python submission (verdict: Time Limit Exceeded):
import sys

N,K,Q = list(map(int,input().split()))
A = []
for i in range(Q):
  tmp = int(input())
  A.append(tmp)
  
if K > Q:
  for i in range(N):
    print('Yes')
  sys.exit()
K_Q = K-Q
A_set = set(A)
for i in range(N):
  if i + 1 in A_set:
    if K_Q + A.count(i+1) > 0:
      print('Yes')
    else:
      print('No')
  else:
    print('No')

Fixed submission:
import sys
from collections import Counter

N,K,Q = list(map(int,input().split()))
A = []
for i in range(Q):
  tmp = int(input())
  A.append(tmp)
  
if K > Q:
  for i in range(N):
    print('Yes')
  sys.exit()
K_Q = K - Q
A_freq = Counter(A)
for i in range(1,N+1):
  if K_Q + A_freq[i] > 0:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
print(N^^3)

Fixed submission:
N = int(input())
print(N**3)
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N == 1:
  print(0)
elif N == 2:
  print(1)
else:
  print(int(N * (N-1) // 2))


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

c = 0

if S[0] == T[0]:
  c+=1

if S[1] == T[1]:
  c+=1

if S[2] == T[2]:
  c+=1

print(c)