Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def cul(x,X):
    dic={0:1}
    for i in range(len(x)):
        tmp={}
        for j in dic:
            tmp[j+x[i]]=1
            tmp[j-x[i]]=1
        dic=tmp
    if X in dic: return True
    else: return False

s=list(input().split("T"))
X,Y=map(int,input().split())
x,y=[len(i) for i in s[::2]],[len(i) for i in s[1::2]]
if s[0][0]=="F": X=abs(X-x.pop(0))
Y=abs(Y)

x.sort(reverse=True)
y.sort(reverse=True)

print("Yes" if cul(x,X) and cul(y,Y) else "No")

Fixed submission:
def f(s):
    return abs(int(s))

def cul(x,X):
    dic={0:1}
    for i in range(len(x)):
        tmp={}
        for j in dic:
            tmp[j+x[i]]=1
            tmp[j-x[i]]=1
        dic=tmp
    if X in dic: return True
    else: return False

s=input()
X,Y=map(int,input().split())
x,y=[],[]
d,tmp=0,0
for i in range(len(s)):
    if s[i]=="T":
        if tmp!=0:
            if d==0: x.append(tmp)
            else: y.append(tmp)
        d^=1
        tmp=0
        
    else: tmp+=1
if tmp!=0:
    if d==0: x.append(tmp)
    else: y.append(tmp)


if s[0]=="F": X=abs(X-x.pop(0))
Y=abs(Y)


print("Yes" if cul(x,X) and cul(y,Y) else "No")
Buggy python submission (verdict: Runtime Error):
import sys
import math
from itertools import accumulate as acc

input=sys.stdin.readline

N=int(input())
a=list(map(int,input().split()))
b=[abs(a[i]) for i in range(N)]
l=b.index(max(b))

if a[l]==0: print(0),sys.exit()
elif a[l]>0:
	print(N*2)
	for i in range(2):
		print(l+1,1)
	for i in range(1,N):
		for j in range(2):
			print(i,i+1)

else:
	print(N*2)
	for i in range(2):
		print(l+1,N)
	for i in range(N,1,-1):
		for j in range(2):
			print(i,i-1)

Fixed submission:
s=input()
print(sum( int(s[i]) for i in range(3) ))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)

def cur(p):
    for x in neighbor[p]:
        if x==par[p]: continue
        else:
            par[x]=p
            descend[p]+=cur(x)
    neighbor[p].remove(par[p])
    return descend[p]

n=int(input())
neighbor=[[]  for _ in range(n+1)]
descend=[1]*(n+1)
par=[0]*(n+1)

for _ in range(n-1):
    a,b=map(int,input().split())
    neighbor[a].append(b)
    neighbor[b].append(a)
neighbor[1].append(0)
cur(1)


x=[descend[n]-1]
t=n
while t!=1:
    t,pret=par[t],t
    x.append(descend[t]-descend[pret]-1)

l=len(x)
p,q=sum(x[:l//2]),sum(x[l//2:])
if l%2==0: print("Fennec" if p<q else "Snuke")
else: print("Fennec" if p<=q else "Snuke")

Fixed submission:
a,b=map(int,input().split())
print("Possible" if a*b*(a+b)%3==0 else "Impossible")
Buggy python submission (verdict: Time Limit Exceeded):
import math
a, b, n = map(int, input().split())
m = 0
t = min(b, n)
for i in range(b//a, t+1):
    if m < math.floor((a*i)/b) - a*math.floor(i/b):
        m = math.floor((a*i)/b) - a*math.floor(i/b)
print(m)

Fixed submission:
import math
a, b, n = map(int, input().split())
if n < b: print(math.floor((a*n)/b) - a*math.floor(n/b))
else: print(math.floor((a*(b-1))/b) - a*math.floor((b-1)/b))
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
q = int(input())
c = 0
for i in range(q):
    qy = list(input().split())
    if qy[0] == "1":
        c += 1
    else:
        if (qy[1] == "1" and c % 2 == 0) or (qy[1] == "2" and c % 2 == 1):
            s = [qy[2]] + s
        else:
            s = s + [qy[2]]
if c % 2 == 0:
    print("".join(s))
else:
    print("".join(reversed(s)))

Fixed submission:
s = input()
q = int(input())
c = 0
t = ""
u = ""
for i in range(q):
    qy = list(input().split())
    if qy[0] == "1":
        c += 1
    else:
        if (qy[1] == "1" and c % 2 == 0) or (qy[1] == "2" and c % 2 == 1):
            t = qy[2] + t
        else:
            u = u + qy[2]
ans = t + s + u
if c % 2 == 0:
    print(t + s + u)
else:
    print(ans[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
c = 0
for i in range(q):
    qy = list(input().split())
    if qy[0] == "1":
        c += 1
    else:
        if qy[1] == "1" and c % 2 == 0:
            s = qy[2] + s
        elif qy[1] == "1" and c % 2 == 1:
            s = s + qy[2]
        elif qy[1] == "2" and c % 2 == 0:
            s = s + qy[2]
        else:
            s = qy[2] + s
if c % 2 == 0:
    print(s)
else:
    print(s[::-1])

Fixed submission:
s = input()
q = int(input())
c = 0
t = ""
u = ""
for i in range(q):
    qy = list(input().split())
    if qy[0] == "1":
        c += 1
    else:
        if (qy[1] == "1" and c % 2 == 0) or (qy[1] == "2" and c % 2 == 1):
            t = qy[2] + t
        else:
            u = u + qy[2]
ans = t + s + u
if c % 2 == 0:
    print(t + s + u)
else:
    print(ans[::-1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
for i in range(q):
    qy = list(input().split())
    if qy[0] == "1":
        s = s[::-1]
    else:
        if qy[1] == "1":
            s = qy[2] + s
        else:
            s = s + qy[2]
print(s)

Fixed submission:
s = input()
q = int(input())
c = 0
t = ""
u = ""
for i in range(q):
    qy = list(input().split())
    if qy[0] == "1":
        c += 1
    else:
        if (qy[1] == "1" and c % 2 == 0) or (qy[1] == "2" and c % 2 == 1):
            t = qy[2] + t
        else:
            u = u + qy[2]
ans = t + s + u
if c % 2 == 0:
    print(t + s + u)
else:
    print(ans[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = []
m = 0
for i in range(n):
    S.append(input())
A = set(S)
al = {}
for i in A:
    al[i] = S.count(i)
    if S.count(i) > m:
        m = S.count(i)
s = []
for i in al:
    if al[i] == m:
        s.append(i)
s.sort()
for i in s:
    print(i)

Fixed submission:
import collections

n = int(input())
S = []
for i in range(n):
    S.append(input())

a = collections.Counter(S)
m = max(a.values())
s = []
for i in a:
    if a[i] == m:
        s.append(i)
s.sort()
for i in s:
    print(i)
Buggy python submission (verdict: Runtime Error):
h, a = map(int, input().split())
  print((h+a-1)//a)

Fixed submission:
h, a = map(int, input().split())
print((h+a-1)//a)

Buggy python submission (verdict: Runtime Error):
h, a = map(int, input().split())
  print(h//a + h%a != 0)

Fixed submission:
h, a = map(int, input().split())
print((h+a-1)//a)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
H = list(map(int, input().split()))
if k >= n: print(0)
else:
    for i in range(k):
        H.remove(max(H))
    print(sum(H))

Fixed submission:
n, k = map(int, input().split())
H = list(map(int, input().split()))
if k >= n: print(0)
else:
    H.sort()
    H = H[:n-k]
    print(sum(H))
Buggy python submission (verdict: Runtime Error):
n, k, s = map(int, input().split())
if s = 10**9:
    ans = [s]*k + [s-1]*(n-k)
else:
    ans = [s]*k + [s+1]*(n-k)
print(*ans)

Fixed submission:
n, k, s = map(int, input().split())
if s == 10**9:
    ans = [s]*k + [s-1]*(n-k)
else:
    ans = [s]*k + [s+1]*(n-k)
print(*ans)

Buggy python submission (verdict: Runtime Error):
n, k, s = map(int, input().split())
print(*[s]*k, *[s+1]*(n-k))

Fixed submission:
n, k, s = map(int, input().split())
if s == 10**9:
    ans = [s]*k + [s-1]*(n-k)
else:
    ans = [s]*k + [s+1]*(n-k)
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
rx = int(x**(1/2)) + 1
P = [2] + [2*i+1 for i in range(1, rx//2)]
while True:
    flag = True
    for i in P:
        if x % i == 0:
            flag = False
            break
    if flag:
        print(x)
        break 
    if P[-1] != int(x**(1/2)):
        P.append(int(x**(1/2)))
    x += 1

Fixed submission:
x = int(input())
rx = int(x**(1/2)) + 1
P = [2] + [2*i+1 for i in range(1, rx//2)]
while True:
    flag = True
    for i in P:
        if x % i == 0:
            flag = False
            break
    if flag or x == 2:
        print(x)
        break
    P.append(int(x**(1/2)+1))
    x += 1
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
cap = 0
count = 0
if b = 1:
    print(count)
else:
    while cap < b:
        cap += a
        if cap < b:
            cap -= 1
        count += 1
    print(count)

Fixed submission:
a, b = map(int, input().split())
cap = 0
count = 0
if b == 1:
    print(count)
else:
    while cap < b:
        cap += a
        if cap < b:
            cap -= 1
        count += 1
    print(count)
Buggy python submission (verdict: Runtime Error):
import math

a,b,c,d = map(int, input().split())
cnt = 0
ansb1 = b // c
ansb2 = b // d
ansb12 = b // (c*d//(math.gcd(c,d)))
bb = (ansb1 + ansb2) - ansb12

ansa1 = (a-1) // c
ansa2 = (a-1) // d
ansa12 = (a-1) // (c*d//(math.gcd(c,d)))
aa = (ansa1 + ansa2) - ansa12
print((b-a+1)-(bb-aa))

Fixed submission:
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)


a,b,c,d = map(int, input().split())
cnt = 0
ansb1 = b // c
ansb2 = b // d
ansb12 = b // (c*d//(gcd(c,d)))
bb = (ansb1 + ansb2) - ansb12

ansa1 = (a-1) // c
ansa2 = (a-1) // d
ansa12 = (a-1) // (c*d//(gcd(c,d)))
aa = (ansa1 + ansa2) - ansa12
print((b-a+1)-(bb-aa))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = []
for i in range(m):
    l, r = map(int, input().split())
    if i == 0: a = set([int(i) for i in range(l, r+1)])
    else:
        a &= set([int(i) for i in range(l, r+1)])
print(len(a))

Fixed submission:
n, m = map(int, input().split())
a = []
flag = True
for i in range(m):
    l, r = map(int, input().split())
    if i == 0: 
        l1 = l
        r1 = r
    else:
        if r < l1 or r1 < l:
            flag = False
        elif l1 < l:
            l1 = l
        elif r1 > r:
            r1 = r
if flag: print(r1-l1+1)
else: print(0)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
count = 0
bunki = N
countb = 0
l = N-1
for i in range(0, N):
	if(S[i] == '#'):
		bunki = i
		break
if(bunki != N):
	for j in range(bunki, N):
		if(S[j] == '.'):
			count += 1
		else:
			countb += 1 
	while(0 < l):
		if(S[l] == '#'):
			countb -= 1
		else:
			break
		l -= 1
if(countb < count):
	print(countb)
else:
	print(count)

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

if((C > A and C < B) or (C < A and C > B)):
	print('Yes')
else:
	print('No')
Buggy python submission (verdict: Runtime Error):
import math
a = []
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
t = []
b = []
u = []
for i in a:
	if(i%10 == 0):
		b.append(i)
	else:
		t.append(i)
		u.append(i%10)
min_t = u.index(min(u))
ss = t.pop(min_t)
u.pop(min_t)

for i in range(len(t)): 
	u[i] = 10 - u[i]
	t[i] = t[i] + u[i]
print(sum(b) + sum(t) + ss)

Fixed submission:
import math
a = []
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
t = []
b = []
u = []
for i in a:
	if(i%10 == 0):
		b.append(i)
	else:
		t.append(i)
		u.append(i%10)
if(sum(u) != 0):
	min_t = u.index(min(u))
	ss = t.pop(min_t)
	u.pop(min_t)

	for i in range(len(t)): 
		u[i] = 10 - u[i]
		t[i] = t[i] + u[i]
	print(sum(b) + sum(t) + ss)

else:
	print(sum(b))

Buggy python submission (verdict: Runtime Error):
import math
a = []
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
t = []
b = []
u = []
for i in a:
	if(i%10 == 0):
		b.append(i)
	else:
		t.append(i)
		u.append(i%10)
min_t = u.index(min(u))
ss = t.pop(min_t)
u.pop(min_t)

for i in range(len(t)): 
	u[i] = 10 - u[i]
	t[i] = t[i] + u[i]
print(sum(b) + sum(t) + ss)

Fixed submission:
import math
a = []
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
t = []
b = []
u = []
for i in a:
	if(i%10 == 0):
		b.append(i)
	else:
		t.append(i)
		u.append(i%10)
if(sum(u) != 0):
	min_t = u.index(min(u))
	ss = t.pop(min_t)
	u.pop(min_t)

	for i in range(len(t)): 
		u[i] = 10 - u[i]
		t[i] = t[i] + u[i]
	print(sum(b) + sum(t) + ss)

else:
	print(sum(b))
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()

for i in range(Q):
	count = 0
	l, r = map(int, input().split())
	Sr = S[l-1:r]
	print(Sr.count('AC'))
	

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0]*(N+1)
for i in range(N):
	t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])

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

for i in range(Q):
	count = 0
	l, r = map(int, input().split())
	Sr = S[l-1:r]
	j = 0
	while (j < (len(Sr)-1)):
		if(Sr[j] == 'A' and Sr[j+1] == 'C'):
			count += 1
			j += 1
		elif(Sr[j+1] != 'A'):
			j += 1
		elif(j+2!=len(Sr) and Sr[j+2] != 'C'):
			j += 2
		j += 1
	print(count)
	

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0]*(N+1)
for i in range(N):
	t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])

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

for i in range(Q):
	count = 0
	l, r = map(int, input().split())
	Sr = S[l-1:r]
	j = 0
	while (j < (len(Sr)-1)):
		if(Sr[j] == 'A' and Sr[j+1] == 'C'):
			count += 1
			j += 1
		elif(Sr[j+1] != 'A'):
			j += 1
		j += 1
	print(count)
	

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0]*(N+1)
for i in range(N):
	t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])

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

for i in range(Q):
	count = 0
	l, r = map(int, input().split())
	Sr = S[l-1:r]
	for j in range(len(Sr)-1):
		if(Sr[j] == 'A' and Sr[j+1] == 'C'):
			count += 1
	print(count)
	

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0]*(N+1)
for i in range(N):
	t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
C = []
if m <= n:
	print(0)
	exit()
for i in range(1, m):
	C.append(abs(X[i] - X[i-1]))
for i in range(n-1):
	t = max(C)
	C[C.index(t)] = 0
print(sum(C))

Fixed submission:
n, m = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
C = []
if m <= n:
	print(0)
	exit()
for i in range(1, m):
	C.append(abs(X[i] - X[i-1]))
C.sort()
for i in range(n-1):
	C[m-2-i] = 0
print(sum(C))
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
#文字列と文字列の長さ取得、文字列をリスト化
S = input()
N = len(S)
S = list(S)

#文字列に"BW"が含まれていないかのチェック
i=0
count = 0
while(i<N):
	#iがリストの最後に到達するとbreak
	if(i==N-1):
		break
	else:
		#i番目が"B"でi+1番目が"W"のとき置き換え、置き換えた回数を数える。
		if(S[i] == 'B' and S[i+1] == 'W'):
			S[i] = 'W'
			S[i+1] = 'B'
			count = count + 1
			i = -1
	i = i + 1
print(count)

Fixed submission:
# -*- coding: utf-8 -*-
S = input()
N = len(S)
S = list(S)

count = 0
count2 = 0
kekka = 0
for i in range(len(S)):
	if(S[i] == 'B'):
		count = count + 1
		count2 = count2 + i
for j in range(count):
	kekka = kekka + N - j-1

print(kekka-count2)
Buggy python submission (verdict: Runtime Error):
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) 

n, X = map(int, input().split())
x = list(map(int, input().split()))
if len(x) == 1:
  print(abs(x[0] - X))
else:
  x.sort()
  s = []
  for i in range(n-1):
    s.append(x[i+1] - x[i])

  for i in range(len(s)-1):
    a = gcd(s[i], s[i+1])
  u = 0
  for i in range(n):
    u = max(u, gcd(abs(X-x[i]), a))
  print(u)

Fixed submission:
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) 

n, X = map(int, input().split())
x = list(map(int, input().split()))
if len(x) == 1:
  print(abs(x[0] - X))
else:
  x.sort()
  s = x[1] - x[0]
  for i in range(1, n-1):
    s = gcd(s, x[i+1]-x[i])
  a = 1
  for i in range(n):
    a = max(a, gcd(abs(X-x[i]), s))
  print(a)
Buggy python submission (verdict: Runtime Error):
1 2
7444

Fixed submission:
a, b = map(int, input().split())
s = input()
if s[a] == "-" and s.count("-") == 1:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
c = 0
B = []
C = []
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        B.append(b)
    elif b == n:
        C.append(a)
for i in B:
    if i in C:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Fixed submission:
import collections
n, m = map(int, input().split())
c = 0
B = []
C = []
for i in range(m):
    a, b = map(int, input().split())
    if a == 1:
        B.append(b)
    elif b == n:
        B.append(a)
C = collections.Counter(B)
for i in C:
    if C[i] > 1:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
B = []
C = []
for i in range(n):
    if i % 2 == 0:
        B.append(A[i])
    else:
        C.append(A[i])
if len(B) > len(C):
    print(*reversed(B), *C)
else:
    print(*reversed(C), *B)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
B = []
C = []
for i in range(n):
    if i % 2 == 0:
        B.append(A[i])
    else:
        C.append(A[i])
if len(B) > len(C):
    ans = list(reversed(B)) + C
    print(*ans)
else:
    ans = list(reversed(C)) + B
    print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
log_l = [0]
i = 0
count = 0
flag = False
while i != 1: 
    i = a[i]-1
    count +=1
    if i in log_l: break
    else: log_l.append(i)
    if i == 1:
        flag = True
        break
if flag: print(count)
else: print(-1)

Fixed submission:
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
i = 0
j = 0
count = -1
while i < n:
    j = a[j]-1
    i += 1
    if j == 1:
        count = i
        break
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
R = [0 for i in range(9)]
for i in range(n):
    R[A[i]//400] += 1
mi = 0
for i in range(8):
    if R[i] > 0: mi += 1
if mi == 0 and R[8] > 0:
    print(mi+1, min(8, mi+R[8]))
else:
    print(mi, min(8, mi+R[8]))

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
R = [0 for i in range(9)]
for i in range(n):
    if A[i] < 3200: R[A[i]//400] += 1
    else: R[8] += 1
mi = 0
for i in range(8):
    if R[i] > 0: mi += 1
if mi == 0 and R[8] > 0:
    print(mi+1, mi+R[8])
else:
    print(mi, mi+R[8])
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())
A = [i for i in range(1, x//2+1)]
if sum(A) < x: print(x//2 + 1)
else: print(x//2)


Fixed submission:
import math
x = int(input())
for i in range(1, x+1):
    if i*(i+1)//2 >= x:
        print(i)
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
count = 0
c1 = s
for i in range(k+1):
    if 0 <= s-i <= 2*k:
        for j in range(0, k+1):
            if 0<= s-i-j <= k:
                for l in range(0,k+1):
                    if i + j + l == s:
                        count += 1
print(count)

Fixed submission:
k, s = map(int, input().split())
cnt = 0
for i in range(k+1):
    for j in range(k+1):
        if 0<= s-i-j <= k:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
aList = list(map(int, input().split()))
t = [0 for i in range(20001)]
for a in aList:
    t[a] += 1
for i in range(1, n+1):
    print(t[i])

Fixed submission:
n = int(input())
aList = list(map(int, input().split()))
t = [0 for i in range(200001)]
for a in aList:
    t[a] += 1
for i in range(1, n+1):
    print(t[i])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
aList = list(map(int, input().split()))
for i in range(1, n+1):
    print(aList.count(i))

Fixed submission:
n = int(input())
aList = list(map(int, input().split()))
t = [0 for i in range(200001)]
for a in aList:
    t[a] += 1
for i in range(1, n+1):
    print(t[i])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
aList = list(map(int, input().split()))
for i in range(1, n+1):
    print(aList.count(i))

Fixed submission:
n = int(input())
aList = list(map(int, input().split()))
t = [0 for i in range(200001)]
for a in aList:
    t[a] += 1
for i in range(1, n+1):
    print(t[i])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())

def e(x):
    x = int(x)
    return sum(range(1, x+1)) / x

p = list(map(e, input().split()))

s = 0
for i in range(n-k+1):
    s = max(s, sum(p[i:i+k]))
print(s)

Fixed submission:
n, k = map(int, input().split())
e = list(map(lambda x: (int(x)+1)/2, input().split()))

s = [e[0]]
for i in range(1, n):
    s.append(s[i-1]+e[i])

a = 0
for i in range(n-k+1):
    if i == 0:
        a = max(a, s[i+k-1])
    else:
        a = max(a, s[i+k-1] - s[i-1])
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
solved = []
wa_history = {}

for i in range(m):
    t1, t2 = input().split()
    if t1 in solved:
        pass
    elif t2 == 'WA':
        if t1 in wa_history:
            wa_history[t1] += 1
        else:
            wa_history[t1] = 1
    else: # t2 == AC
        solved.append(t1)

wa = 0
for key in wa_history.keys():
    if key in solved:
        wa += wa_history[key]

print(len(solved), wa)

Fixed submission:
n, m = map(int, input().split())
ss = []

for i in range(m):
    t1, t2 = input().split()
    ss.append([t1, t2])

ss.sort(key=lambda x:x[0])

t = ''
ac = 0
wa = 0
awa = 0
cIsSolved = False
for s in ss:
    if s[0] != t:
        t = s[0]
        cIsSolved = False
        wa = 0
    if s[1] == 'AC' and not cIsSolved:
        cIsSolved = True
        ac += 1
        awa += wa
    if s[1] == 'WA' and not cIsSolved:
        wa += 1
print(ac, awa)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
solved = []
wa_history = {}

for i in range(m):
    t1, t2 = input().split()
    if t1 in solved:
        pass
    elif t2 == 'WA':
        if t1 in wa_history:
            wa_history[t1] += 1
        else:
            wa_history[t1] = 1
    else: # t2 == AC
        solved.append(t1)

wa = 0
for key, value in wa_history.items():
    if key in solved:
        wa += value

print(len(solved), wa)

Fixed submission:
n, m = map(int, input().split())
ss = []

for i in range(m):
    t1, t2 = input().split()
    ss.append([t1, t2])

ss.sort(key=lambda x:x[0])

t = ''
ac = 0
wa = 0
awa = 0
cIsSolved = False
for s in ss:
    if s[0] != t:
        t = s[0]
        cIsSolved = False
        wa = 0
    if s[1] == 'AC' and not cIsSolved:
        cIsSolved = True
        ac += 1
        awa += wa
    if s[1] == 'WA' and not cIsSolved:
        wa += 1
print(ac, awa)
Buggy python submission (verdict: Runtime Error):
import math
a, b, x = map(int, input().split())
s = x / a
if s > a * b / 2:
  rad = math.atan(a ** 3 / (2 * a * a * b - 2 * x))
  print(90 - (rad * 180 / math.pi))
else:
  rad = math.atan(a * b * b / (2 * x))
  print(rad * 180 / math.pi)

Fixed submission:
import math
a, b, x = map(int, input().split())
s = x / a
if s > a * b / 2:
  if x == a * a * b:
    print(0)
  else:
    rad = math.atan(a ** 3 / (2 * a * a * b - 2 * x))
    print(90 - (rad * 180 / math.pi))
else:
  rad = math.atan(a * b * b / (2 * x))
  print(rad * 180 / math.pi)