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

Fixed submission:
N, Q = map(int, input().split())
s = input()
T = []
D = []
for _ in range(Q):
	t, d = input().split()
	T.append(t)
	D.append(d)


ans = 0
left = 0
right = N-1
for i in range(Q-1,-1,-1):
	if D[i] == 'R':
		if T[i] == s[right]:
			right -= 1
			if right == 0:
				print(0)
				exit()
		if left > 0 and s[left-1]==T[i]:
			left -= 1

	else:
		if T[i] == s[left]:
			left += 1
			if left == N-1:
				print(0)
				exit()
		if right < N-1 and s[right+1]==T[i]:
			right += 1
	# print(s[left:right+1])
print(max(0,right-left+1))

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
s = input()
T = []
D = []
for _ in range(Q):
	t, d = input().split()
	T.append(t)
	D.append(d)


ans = 0
left = 0
right = N-1
for i in range(Q-1,-1,-1):
	if D[i] == 'R':
		if T[i] == s[right]:
			right -= 1
		if left > 0 and s[left-1]==T[i]:
			left -= 1

	else:
		if T[i] == s[left]:
			left += 1
		if right < N-1 and s[right+1]==T[i]:
			right += 1
	# print(s[left:right+1])
print(max(0,right-left+1))

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
s = input()
T = []
D = []
for _ in range(Q):
	t, d = input().split()
	T.append(t)
	D.append(d)


ans = 0
left = 0
right = N-1
for i in range(Q-1,-1,-1):
	if D[i] == 'R':
		if T[i] == s[right]:
			right -= 1
		if left > 0 and s[left-1]==T[i]:
			left -= 1

	else:
		if T[i] == s[left]:
			left += 1
		if right < N-1 and s[right+1]==T[i]:
			right += 1
	# print(s[left:right+1])
print(right-left+1)

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
s = input()
T = []
D = []
for _ in range(Q):
	t, d = input().split()
	T.append(t)
	D.append(d)


ans = 0
left = 0
right = N-1
for i in range(Q-1,-1,-1):
	# print(D[i])
	if D[i] == 'R':
		if T[i] == s[right]:
			right -= 1
		if left > 0 and s[left-1]==T[i]:
			left -= 1

	else:
		if T[i] == s[left]:
			left += 1
		if right < N-1 and s[right+1]==T[i]:
			right += 1
	print(s[left:right+1])
print(right-left+1)
Problem p03087 (python)

Fixed submission:
N, Q = map(int, input().split())
S = input()
L = []
R = []
# ans = []
for _ in range(Q):
	l, r = map(int, input().split())
	L.append(l)
	R.append(r)
sum = [0] * (N+1)
for i in range(1, N):
	if S[i-1] == 'A' and S[i] == 'C':
		sum[i+1] = sum[i] + 1
	else:
		sum[i+1] = sum[i]
# print(sum)


for i in range(Q):
	print(sum[R[i]] - sum[L[i]])

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
L = []
R = []
# ans = []
for _ in range(Q):
	l, r = map(int, input().split())
	L.append(l)
	R.append(r)
flag = []
for i in range(N):
	if S[i] == 'A' and S[i+1] == 'C':
		flag.append(1)
		i += 1
	else:
		flag.append(0)
# print(flag)

for i in range(Q):
	print(sum(flag[L[i]-1:R[i]-1]))

# for i in range(Q):
# 	print(ans[i])

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
L = []
R = []
ans = []
for _ in range(Q):
	l, r = map(int, input().split())
	L.append(l)
	R.append(r)
flag = [0]*(N-1)

for i in range(N):
	if S[i] == 'A' and S[i+1] == 'C':
		flag[i] = 1
		i += 1
	else:
		pass
# print(flag)

for i in range(Q):
	print(sum(flag[L[i]-1:R[i]-1]))

# for i in range(Q):
# 	print(ans[i])
Problem p03106 (python)

Fixed submission:
from sys import stdin

def f(num):
  d = []
  if num != 1:
    for i in range(1,num):
      if num % i == 0:
    	  d.append(i)
      d.append(num)
  else:
      d = [1]
  return d

A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
a = f(A)
b = f(B)
d = set(a)&set(b)
d = sorted(list(d),reverse=True)
print(d[C-1])

Buggy submission (verdict: Runtime Error):
import sys
from sys import stdin

def f(num):
  d = []
  if num != 1:
    for i in range(1,num):
      if num % i == 0:
    	  d.append(i)
  else:
      d = [1]
  return d

A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
a = f(A)
b = f(B)
d = set(a)&set(b)
d = list(d)
print(d[C-1])
Problem p03109 (python)

Fixed submission:
s = input().replace('/','')
if s[4:5] == '1':
  print('TBD')
else:
  if int(s[5:6]) > 4:
    print('TBD')
  else:
    print('Heisei')

Buggy submission (verdict: Runtime Error):
s = input().replace('/','')
if s[4:5] == 1:
  print('TBD')
else:
  if s[5:6] > 4:
    print('TBD')
  else:
    print('Heisei')

Buggy submission (verdict: Runtime Error):
s = input().replace('/','')
if s[4:5] == 1:
  return TBD
else:
  if s[5:6] > 4:
    return TBD
  else:
    return Heisei
Problem p03110 (python)

Fixed submission:
N = int(input())
sum = 0
for i in range (N):
  X = input().split()
  if X[1] == 'JPY':
    sum += float(X[0])
  else:
  	sum += float(X[0])*380000
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range N:
  X = input().split()
  if X[1] == 'JPY':
    sum += float(X[0])
  else:
  	sum += float(X[0])*380000
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in N:
  X = input().split()
  if X[1] == 'JPY':
    sum += float(X[0])
  else:
  	sum += float(X[0])*380000
print(sum)

Buggy submission (verdict: Runtime Error):
from sys import stdin

N = int(input())
sum = 0
for i in N:
  X = input().split()
  if x[1] == 'JPY':
    sum += float(x[1])
  else:
  	sum += float(x)*380000
print(sum)

Buggy submission (verdict: Runtime Error):
from sys import stdin

N = int(input())
sum = 0
for i in N:
  x,u = stdin.readline().rstrip().split()
  if u == 'JPY':
    sum += int(x)
  else:
  	sum += float(x)*380000
print(sum)

Buggy submission (verdict: Runtime Error):
from sys import stdin

N = int(input())
sum = 0
for i in N:
  x,u = stdin.readline().rstrip().split()
  if u == 'JPY':
    sum += int(x)
  else:
  	sum += float(x)*38000
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in N:
  x,u = stdin.readline().rstrip().split()
  if u == 'JPY':
    sum += int(x)
  else:
  	sum += float(x)*38000
print(sum)

Buggy submission (verdict: Runtime Error):
N = input()
sum = 0
for i in N:
  x,u = stdin.readline().rstrip().split()
  if u == 'JPY':
    sum += int(x)
  else:
  	sum += float(x)*38000
print(sum)
Problem p03125 (python)

Fixed submission:
from sys import stdin
A, B = [int(x) for x in stdin.readline().rstrip().split()]
if (B%A==0):
  print(A+B)
else:
  print(B-A)

Buggy submission (verdict: Runtime Error):
A,B = int(input().split())
if (B%A==0):
  print(A+B)
else:
  print(B-A)
Problem p03126 (python)

Fixed submission:
from sys import stdin
N, M = [int(x) for x in stdin.readline().rstrip().split()]
l = []
m = []
for i in range(N):
    l.append(stdin.readline().rstrip().split())
    l[i].pop(0)
k = l[N-1]
for i in range(N-1):
    k = set(k)&set(l[i])
print(len(k))

Buggy submission (verdict: Runtime Error):
from sys import stdin
N, M = [int(x) for x in stdin.readline().rstrip().split()]
l = []
for i in range(N):
    l.append(stdin.readline().rstrip().split())
k = l[0]
for i in range(N):
    k = k&l[i]
print(len(k))
Problem p03145 (python)

Fixed submission:
L = list(map(int,input().split()))
print(int(L[0]*L[1]/2))

Buggy submission (verdict: Runtime Error):
L = map(int, input().split())
print(L[0]*L[1]/2)
Problem p03146 (python)

Fixed submission:
l = []
l.append(int(input()))
i = 0
key = 1
while key:
  if l[i]%2:
    l.append(3*l[i]+1)
  else:
    l.append(l[i]/2)
  i += 1
  for j in range(i-1):
    if l[j] == l[i]:
      key = 0
      print(i+1)
      break

Buggy submission (verdict: Runtime Error):
l = []
l.append(int(input()))
i = 0
while True:
  if s&2:
    l.append(3*l[i]+1)
  else:
    l.append(l[i]/2)
  i += 1
  for j in range(j,i):
    if l[j] == l[i]:
      break
print(i)
Problem p03231 (python)

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

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

def lcm(m, n):
	return int(m*n/gcd(m,n))


L = lcm(N, M)
X = {}


for i in range(0,N):
	X[i*L//N] = S[i]
# print(X)
for i in range(0,M):
	if X.get(i*L//M) != None:
		if X[i*L//M] != T[i]:
			print(-1)
			exit()
	else:
		pass
print(L)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
S = input()
T = input()

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

def lcm(m, n):
	return int(m*n/gcd(m,n))


L = lcm(N, M)
X = {}


for i in range(0,N):
	X[i*L//N] = S[i]
	# X[i*L//N] = S[i]
for i in range(0,M):
	if T[i] in X.values():
		if X[i*L//M] != T[i]:
			print(-1)
			exit()
	else:
		pass
print(L)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
S = input()
T = input()

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

def lcm(m, n):
	return int(m*n/gcd(m,n))
L = lcm(N, M)
X = ['0'] * L

for i in range(0,N):
	X[i*L//N] = S[i]
for i in range(0,M):
	if X[i*L//M] != '0':
		if X[i*L//M] != T[i]:
			print(-1)
			exit()
	else:
		pass
print(lcm(N, M))
Problem p03240 (python)

Fixed submission:
N = int(input())
p = [0, 0, 0]*N

p = [list(map(int, input().split())) for _ in range(N)]
p = sorted(p, key=lambda x:-x[2])
for cx in range(101):
	for cy in range(101):
		H = abs(p[0][0]-cx)+abs(p[0][1]-cy)+p[0][2]
		for i in range(N):
			# if H != abs(x[i]-cx)+abs(y[i]-cy)+h[i]:
			if p[i][2] != max(H-abs(p[i][0]-cx)-abs(p[i][1]-cy), 0):
				break
			if i == N-1:
				ans = [cx, cy, H]
				break
print(ans[0],ans[1],ans[2])

Buggy submission (verdict: Runtime Error):
N = int(input())
x = [0]*N
y = [0]*N
h = [0]*N

for i in range(N):
	x[i], y[i], h[i] = map(int, input().split())
for cx in range(101):
	for cy in range(101):
		H = abs(x[0]-cx)+abs(y[0]-cy)+h[0]
		for i in range(N):
			# if H != abs(x[i]-cx)+abs(y[i]-cy)+h[i]:
			if h[i] != max(H-abs(x[i]-cx)-abs(y[i]-cy), 0):
				break
			if i == N-1:
				ans = [cx, cy, H]
				break
print(ans[0],ans[1],ans[2])

Buggy submission (verdict: Runtime Error):
N = int(input())
x = [0]*N
y = [0]*N
h = [0]*N

for i in range(N):
	x[i], y[i], h[i] = map(int, input().split())
for cx in range(101):
	for cy in range(101):
		H = abs(x[0]-cx)+abs(y[0]-cy)+h[0]
		for i in range(N):
			if H != abs(x[i]-cx)+abs(y[i]-cy)+h[i]:
				break
			if i == N-1:
				ans = [cx, cy, H]
				break
print(ans[0],ans[1],ans[2])
Problem p03243 (python)

Fixed submission:
n = input()
a,b,c = [int(n[i]) for i in range(len(n))]

if a > b:
  print(a*111)
elif a == b:
  if b >= c:
    print(a*111)
  else:
    print((a+1)*111)
else:
  print((a+1)*111)

Buggy submission (verdict: Runtime Error):
a,b,c = int(input().split())
if a > b:
  print(a*111)
elif a == b:
  if b >= c:
    print(a*111)
  else:
    print((a+1)*111)
else:
  print((a+1)*111)
Problem p03244 (python)

Fixed submission:
from collections import Counter
n = int(input())
v = list(map(int, input().split()))

a = []
b = []
for i in range(n//2):
    a.append(v[2*i])
    b.append(v[2*i+1])

def change(list):
    counter = Counter(list)
    m_ap1 = '0'
    m_ap2 = '0'
    if len(counter.most_common()) > 1:
        m_ap1, m_ap2 = counter.most_common()[0][0], counter.most_common()[1][0]
    else:
        m_ap1 = counter.most_common()[0][0]
    l = len(list)
    cnt1 = 0
    cnt2 = 0
    for i in range(l):
        if list[i] != m_ap1:
            cnt1 += 1
        if list[i] != m_ap2:
            cnt2 += 1
    return cnt1, cnt2, m_ap1, m_ap2
ca1, ca2, ma1, ma2 = change(a)
cb1, cb2, mb1, mb2 = change(b)
# print(change(a))
# print(change(b))
if ca1+cb1:
    if ma1 != mb1:
        print(ca1+cb1)
    else:
        print(min(ca1+cb2,cb1+ca2))
else:
    if ma1 != mb1:
        print(ca1+cb1)
    else:
        print(n//2)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
v = list(map(int, input().split()))

a = []
b = []
for i in range(n//2):
    a.append(v[2*i])
    b.append(v[2*i+1])

def change(list):
    counter = Counter(list)
    m_ap1, m_ap2 = counter.most_common()[0][0], counter.most_common()[1][0]
    l = len(list)
    cnt = 0
    for i in range(l):
        if list[i] != m_ap1:
            cnt1 += 1
        if list[i] != m_ap2:
            cnt2 += 1
    return cnt1, cnt2, m_ap1, m_ap2
ca1, ca2, ma1, ma2 = change(a)
cb1, cb2, mb1, mb2 = change(b)

if ca1+cb1:
    if ma1 != mb1:
        print(ca1+cb1)
    else:
        print(min(ca1+cb2,cb1+ca2))
else:
    print(n//2)
Problem p03288 (python)

Fixed submission:
R = int(input())
if R < 1200:
  print('ABC')
elif 1200 <= R < 2800:
  print('ARC')
else:
  print('AGC')

Buggy submission (verdict: Runtime Error):
R = int(input(R))
if R < 1200:
  print('ABC')
elif 1200 <= R < 2800:
  print('ARC')
else:
  print('AGC')
Problem p03292 (python)

Fixed submission:
from sys import stdin
A = [int(x) for x in stdin.readline().rstrip().split()]

print(max(A)-min(A))

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
A = []
A.append(a)
A.append(b)
A.append(c)
A = A.sort()
sum = 0
for i in range(4):
	sum += int(A[i]) - int(A[i-1])
print(sum)

Buggy submission (verdict: Runtime Error):
A = list(map(int, input().split()))
N = len(A)
A = A.sort()
sum = 0

for i in range(1,N):
	sum += A[i]-A[i-1]
print(sum)
Problem p03304 (python)

Fixed submission:
n, m ,d = map(int, input().split())
ans = 0
if d == 0:
	ans = (m-1)/n
else:
	ans = (m-1)*2*(n-d)/n**2
print(ans)

Buggy submission (verdict: Runtime Error):
n, m ,d = map(int, input().split())
ans = 0for i in range(1,m):
if d == 0:
	ans = m/n
else:
	ans = m*2*(n-d)/n**2
print(ans)
Problem p03308 (python)

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


for i in range(0,N):
	a[i] = int(a[i])
mi = 0
for i in range(0,N-1):
	for j in range(i+1,N):
		if abs(a[i]-a[j]) > mi:
			mi = abs(a[i]-a[j])
print(mi)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = input().split()
ans = 0
min = max(a)
for i in range(0,N):
	a[i] = int(a[i])
for i in range(0,N-1):
	for j in range(1,N):
		if abs(a[i]-a[j]) < min
			min = abs(a[i]-a[j])
print(min)
Problem p03328 (python)

Fixed submission:
a, b = map(int, input().split())
d = b - a
print(int((d*(d+1)/2)-b))

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

def memorize(f):
	table = []
	def func(*args):
		if not args in table:
			table[args] = f(*args)
		return table[args]
	return func

@memorize
def s(n):
	if n <= 1:
		return 1
	else:
		return s(n-1)+n
print(s(d-1)-a)

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

def memorize(f):
	table = {}
	def func(*args):
		if not args in table:
			table[args] = f(*args)
		return table[args]
	return func

@memorize
def s(n):
	if n <= 1:
		return 1
	else:
		return s(n-1)+n
print(s(d-1)-a)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
d = b - a
def s(n):
	if n == 1:
		return 1
	else:
		return s(n-1)+n
print(s(d)-b)
Problem p03424 (python)

Fixed submission:
flag = 0
N = int(input())
c = input().split()
for i in range(0,N):
  if c[i] == 'Y':
    flag = 1
if flag:
  print('Four')
else:
  print('Three')

Buggy submission (verdict: Runtime Error):
flag = 'False'
N = int(input())
c = raw_input().split()
for i in range(0,N):
  if c[i] == 'Y':
    flag = 'True'
if flag:
  print('Four')
else:
  print('Three')

Buggy submission (verdict: Runtime Error):
N = int(input())
flag = 'False'
for i in range(0,N):
  c = input()
  if c == 'Y':
    flag = 'True'
if flag:
  print('Four')
else:
  print('Three')
Problem p03493 (python)

Fixed submission:
s = input()
ans = 0
for i in range(0,len(s)):
	if s[i]=='1':
		ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
sum = 0
for i in range(0,len[s]):
	sum += int(s[i])
return(sum)

Buggy submission (verdict: Runtime Error):
s = input()
sum = 0
for i in range(0,len[s]):
	sum += i
return(sum)
Problem p03786 (python)

Fixed submission:
N = int(input())
a = input().split()
for i in range(0,N):
	a[i] = int(a[i])
a.sort()
t = 0
flag = 1
sum_a = 0
for i in range(0,N-1):
	sum_a += a[i]
	if sum_a*2 < a[i+1]:
		t = i+1

			
print(N-t)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = input().split()
for i in range(0,N):
	a[i] = int(a[i])
a.sort()
t = 0
flag = 1
sum_a = 0
for i in range(0,N):
	sum_a += a[i]
	if sum_a*2 < a[i+1]:
		t = i+1
		flag = 0
	if flag == 0:
		break
			
print(N-t)
Problem p02684 (python)

Fixed submission:
n,k=map(int,input().split())
A=list(map(int,input().split()))
A=list(map(lambda x:x-1,A))

next=0
hoge=[]
zisyo={}

for i in range(n):
    next=A[next]
    if next in zisyo:
        t=next
        break
    else:
        zisyo[next]=1
        hoge.append(next)
hoge_1=[]
hoge_2=[]
for i in range(len(hoge)):
    if hoge[i]==t:
        hoge_1=hoge[:i]
        hoge_2=hoge[i:]

ans=0
if k<=len(hoge_1):
    for i in range(k):
        ans=A[ans]
else:
    k=k-len(hoge_1)-1
    k=k%len(hoge_2)
    ans=hoge_2[0]
    for i in range(k):
        ans=A[ans]


print(ans+1)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=list(map(int,input().split()))
A=list(map(lambda x:x-1,A))

next=0
hoge=[]
zisyo={}
for i in range(k):
    next=A[next]
    if next in zisyo:
        t=next
        break
    else:
        zisyo[next]=1
        hoge.append(next)
hoge_1=[]
hoge_2=[]
for i in range(len(hoge)):
    if hoge[i]==t:
        hoge_1=hoge[:i]
        hoge_2=hoge[i:]

ans=0
if k<=len(hoge_1):
    for i in range(k):
        ans=A[ans]
else:
    k=k-len(hoge_1)-1
    k=k%len(hoge_2)
    ans=hoge_2[0]
    for i in range(k):
        ans=A[ans]


print(ans+1)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=list(map(int,input().split()))
A=list(map(lambda x:x-1,A))

next=0
hoge=[]
zisyo={}
for i in range(k):
    next=A[next]
    if next in zisyo:
        t=next
        break
    else:
        zisyo[next]=1
        hoge.append(next)

for i in range(len(hoge)):
    if hoge[i]==t:
        hoge_1=hoge[:i]
        hoge_2=hoge[i:]

if k<=len(hoge_1):
    ans = 0
    for i in range(k):
        ans=A[ans]
else:
    k=k-len(hoge_1)-1
    k=k%len(hoge_2)
    ans=hoge_2[0]
    for i in range(k):
        ans=A[ans]


print(ans+1)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
A=list(map(int,input().split()))
A=list(map(lambda x:x-1,A))

next=0
hoge=[]
for i in range(k):
    next=A[next]
    if next in hoge:
        t=next
        break
    else:
        hoge.append(next)

for i in range(len(hoge)):
    if hoge[i]==t:
        hoge_1=hoge[:i]
        hoge_2=hoge[i:]

if k<=len(hoge_1):
    ans = 0
    for i in range(k):
        ans=A[ans]
else:
    k=k-len(hoge_1)-1
    k=k%len(hoge_2)
    ans=hoge_2[0]
    for i in range(k):
        ans=A[ans]


print(ans+1)
Problem p02705 (python)

Fixed submission:
from math import pi

R=int(input())

print(2*pi*R)

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

nissuu=sum(A)

if nissuu>N:
    print(-1)
else:
    print(N-nissuu)
Problem p02765 (python)

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

if N>=10:
    print(R)
else:
    print(R+100*(10-N))

Buggy submission (verdict: Runtime Error):
N,R=map(int,input().split())

if N>=10:
    print(R)
else:
    print(100*(10-K))
Problem p02837 (python)

Fixed submission:
N=int(input())
A=[]
g=[[-1]*(N) for i in range(N)]#g[i][j]はi番目からのj番目に対する証言

for i in range(N):
    a=int(input())
    A.append(a)
    for j in range(a):
        x,y=map(int,input().split())
        x-=1
        g[i][x]=y
""""
num=[]
for i in range(2 **N):
  chars = list(f"{i:0{N}b}")
  chars=list(map(int,chars))
  num.append(chars)
"""
num=[]
for i in range(2**N):
    x=[]
    for j in range(N):
        if i>>j & 1:
            x.append(1)
        else:
            x.append(0)
    num.append(x)

ans=[]
for x in num:
    ok = True
    for k in range(N):#k番目の人
        if x[k]:
            for j in range(N):
                if g[k][j]==-1:
                    continue
                elif g[k][j]!=x[j]:
                    ok=False
    if ok:
        ans.append(x.count(1))
print(max(ans))

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[]
g=[[-1]*(N) for i in range(N)]#g[i][j]はi番目からのj番目に対する証言

for i in range(N):
    a=int(input())
    A.append(a)
    for j in range(a):
        x,y=map(int,input().split())
        x-=1
        g[i][x]=y
num=[]
for i in range(2 **N):
  chars = list(f"{i:0{N}b}")
  chars=list(map(int,chars))
  num.append(chars)


ans=[]
for x in num:
    ok = True
    for k in range(N):#k番目の人
        if x[k]:
            for j in range(N):
                if g[k][j]==-1:
                    continue
                elif g[k][j]!=x[j]:
                    ok=False
    if ok:
        ans.append(x.count(1))
print(max(ans))
Problem p02639 (python)

Fixed submission:
a = input()
b = a.split(" ")
for i in range(len(b)):
    if b[i] == "0":
        print(i + 1)
        break

Buggy submission (verdict: Runtime Error):
a = input()
b = a.split(" ")
for i in len(b):
  if b[i] == "0":
    print(i+1)
    break
Problem p02641 (python)

Fixed submission:
a = input()

t, c = int(a.split(" ")[0]), int(a.split(" ")[1])

if not c:
    print(t)
else:
    b = input()
    lst = [int(x) for x in b.split(" ")]

    for i in range(c+2):
        if t - i not in lst:
            print(t - i)
            break
        if t + i not in lst:
            print(t + i)
            break

Buggy submission (verdict: Runtime Error):
a = input()

t, c = int(a.split(" ")[0]), int(a.split(" ")[1])

if not c:
    print(t)

b = input()
lst = [int(x) for x in b.split(" ")]

for i in range(c):
    if t - i not in lst:
        print(t - i)
        break
    if t + i not in lst:
        print(t + i)
        break

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
t = int(a.split(" ")[0])
lst = [int(x) for x in b.split(" ")]
x = len(lst)
if not x:
    print(t)
for i in range(x):
    if t - i not in lst:
        print(t - i)
        break
    if t + i not in lst:
        print(t + i)
        break

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
t = int(a.split(" ")[0])
lst = [int(x) for x in b.split(" ")]
x = len(lst)
if not x:
  print(t)
for i in range(x):
  if t - x not in lst:
    print(t - x)
    break
  if t + x not in lst:
    print(t + x)
    break
Problem p02732 (python)

Fixed submission:
# https://atcoder.jp/contests/abc159/tasks/abc159_d

N = int(input())
A_list = list(map(int, input().split()))

box = [0] * (N + 1)
box_2 = [0] * (N + 1)
box_3 = [0] * (N + 1)

for i in range(N):
    box[A_list[i]] += 1

for i in range(N + 1):
    if box[i] > 1:
        box_2[i] = (box[i] * (box[i] - 1)) / 2
        box_3[i] = ((box[i] - 1) * (box[i] - 2)) / 2

ans_base = sum(box_2)

for i in range(N):

    if box[A_list[i]] > 0:
        diff = box_2[A_list[i]] - box_3[A_list[i]]
        print(int(ans_base - diff))
    else:
        print(int(ans_base))

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc159/tasks/abc159_d

N = int(input())
A_list = list(map(int, input().split()))

box = [0] * (N + 1)
box_2 = [0] * (N + 1)
box_3 = [0] * (N + 1)

for i in range(N):
    box[A_list[i] + 1] += 1

for i in range(N + 1):
    if box[i] > 1:
        box_2[i] = (box[i] * (box[i] - 1)) / 2
        box_3[i] = ((box[i] - 1) * (box[i] - 2)) / 2

ans_base = sum(box_2)

for i in range(N):

    if box[A_list[i] + 1] > 0:
        diff = box_2[A_list[i] + 1] - box_3[A_list[i] + 1]
        print(int(ans_base - diff))
    else:
        print(int(ans_base))

Buggy submission (verdict: Runtime Error):
# https://atcoder.jp/contests/abc159/tasks/abc159_d

N = int(input())
A_list = list(map(int, input().split()))

box = [0] * (N + 1)
box_2 = [0] * (N + 1)
box_3 = [0] * (N + 1)

for i in range(N):
    box[A_list[i] + 1] += 1

for i in range(N):
    if box[i] > 1:
        box_2[i] = (box[i] * (box[i] - 1)) / 2
        box_3[i] = ((box[i] - 1) * (box[i] - 2)) / 2

ans_base = sum(box_2)

for i in range(N):

    if box[A_list[i]] > 0:
        diff = box_2[A_list[i]] - box_3[A_list[i]]
        print(int(ans_base - diff))
    else:
        print(int(ans_base))