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

Fixed submission:
from collections import deque

n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]

def make_dict(x,y):
    for i in ll:
        if i[x] in d.keys():
            d[i[x]]+=[i[y]]
        else:
            d[i[x]]=[i[y]]

cnt=0
for i in range(m):
    ll=l[:i]+l[i+1:]
#    print(ll)
    d={}
    make_dict(0,1)
    make_dict(1,0)
#    print(d)
    k_l=list(d.keys())
    v_l=list(d.values())
#    print(k_l)

    x=0
    sk=k_l[x]
    dq=deque()
    dq.append(sk)
#    while dq:
#    print(dq)
#    x=0
    seen=[]
    while dq:
#    while n<10:
        k=dq.pop()
        k_ll=d[k]
        seen.append(k)
#        print(k_ll)
        for i in k_ll:
            if i not in seen:
                dq.append(i)
#        d=d.pop(sk)
#        print(dq)
        x+=1
#    print(set(seen),len(set(seen)))
    if len(set(seen))!=n:
        cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import floyd_warshall

n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]

cnt=0
for i in range(m):
  ll=deepcopy(l)
  del ll[i]

  d=[[float('inf')]*n for i in range(n)]
  for i in range(n):
    d[i][i]=0

  for a,b in ll:
    a-=1
    b-=1
    d[a][b]=1
    d[b][a]=1

  s=floyd_warshall(d)
  for i in s:
    if float('inf') in i:
      cnt+=1
      break

print(cnt)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import floyd_warshall

n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]

ans=0
for i in range(m):
    ll=l[:i]+l[i+1:]

    d=[[float('inf')]*n for i in range(n)]
    for i in range(n):
        d[i][i]=0

    for j in ll:
        d[j[0]-1][j[1]-1]=1
        d[j[1]-1][j[0]-1]=1

    d=floyd_warshall(d)

    if float('inf') in d:
        ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import floyd_warshall

n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]

ans=0
for i in range(m):
    ll=l[:i]+l[i+1:]

    d=[[float('inf')]*n for i in range(n)]
    for i in range(n):
        d[i][i]=0

    for j in ll:
        d[j[0]-1][j[1]-1]=1
        d[j[1]-1][j[0]-1]=1

    d=floyd_warshall(d)

    if float('inf') in d:
        ans+=1

print(ans)
Problem p03608 (python)

Fixed submission:
import itertools
from scipy.sparse.csgraph import floyd_warshall

N,M,R=map(int,input().split())
r=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(M)]

s=[[float('inf') for i in range(N)] for i in range(N)]
for i in range(M):
    a,b,c=l[i]
    s[a-1][b-1]=c
    s[b-1][a-1]=c
for i in range(N):
    s[i][i]=0

s=floyd_warshall(s)
#print(s)
ans=10**9
for i in itertools.permutations(r):
#    print(i)
    temp_ans=0
    for j in range(R-1):
        temp_ans+=s[i[j]-1][i[j+1]-1]
    ans=min(ans,temp_ans)
print(int(ans))

Buggy submission (verdict: Runtime Error):
import itertools
from scipy.sparse.csgraph import floyd_warshall

N,M,R=map(int,input().split())
r=list(map(int,input().split()))
l=[list(map(int,input().split())) for i in range(M)]

s=[[float('inf') for i in range(N)] for i in range(N)]
for i in range(M):
    a,b,c=l[i]
    s[a-1][b-1]=c
    s[b-1][a-1]=c
for i in range(N):
    s[i][i]=0

s=floyd_warshall(s)
#print(s)
ans=10**9
for i in itertools.permutations(r):
#    print(i)
    temp_ans=0
    for j in range(R-1):
        temp_ans+=s[i[j]-1][i[j+1]-1]
    ans=min(ans,temp_ans)
print(int(ans))
Problem p03612 (python)

Fixed submission:
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n):
    if p[i]==i+1:
        cnt+=1
        x=1
        if i==n-1:
            break
        while True:
            if p[i+x]!=i+1:
                temp_v=p[i+x]
                p[i+x]=p[i]
                p[i]=temp_v
                break
            else:
                x+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n):
    if p[i]==i+1:
        cnt+=1
        x=1
        if i==n:
            break
        while True:
            if p[i+x]!=i+1:
                temp_v=p[i+x]
                p[i+x]=p[i]
                p[i]=temp_v
                break
            else:
                x+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
p=list(map(int,input().split()))
cnt=0
for i in range(n):
    if p[i]==i+1:
        cnt+=1
        x=1
        while True:
            if p[i+x]!=i+1:
                temp_v=p[i+x]
                p[i+x]=p[i]
                p[i]=temp_v
                break
            else:
                x+=1
print(cnt)
Problem p03633 (python)

Fixed submission:
from fractions import gcd

n=int(input())
t=[int(input()) for i in range(n)]

lcm=t[0]
for i in range(n-1):
    lcm=(t[i]*t[i+1]//gcd(t[i],t[i+1]))
    t[i+1]=lcm
print(lcm)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

n=int(input())
t=[int(input()) for i in range(n)]

for i in range(0,n-1):
    lcm=(t[i]*t[i+1]//gcd(t[i],t[i+1]))
    t[i+1]=lcm
print(lcm)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

n=int(input())
t=[int(input()) for i in range(n)]

for i in range(1,n):
    lcm=(t[i]*t[i-1]//gcd(t[i],t[i-1]))
    t[i]=lcm
print(lcm)
Problem p03637 (python)

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

cnt1,cnt2=0,0
for i in a:
    if i%2!=0:
        cnt1+=1
    if i%4==0:
        cnt2+=1
print('Yes' if cnt2>=cnt1 or (len(a)%2!=0 and cnt2+1>=cnt1) else 'No')

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
print((n-1)*(m-1))
Problem p03695 (python)

Fixed submission:
n=int(input())
a_l=list(map(int,input().split()))
a,b,c,d,e,f,g,h=0,0,0,0,0,0,0,0
cnt=0
for i in a_l:
    if i<400*1:
        a+=1
    elif 400*1<=i<400*2:
        b+=1
    elif 400*2<=i<400*3:
        c+=1
    elif 400*3<=i<400*4:
        d+=1
    elif 400*4<=i<400*5:
        e+=1
    elif 400*5<=i<400*6:
        f+=1
    elif 400*6<=i<400*7:
        g+=1
    elif 400*7<=i<400*8:
        h+=1
    else:
        cnt+=1
ans=0
for i in [a,b,c,d,e,f,g,h]:
    if i!=0:
        ans+=1
if ans!=0:
    print(ans, ans+cnt)
else:
    print(1,cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split())

cnt=0
l=[]
for i in a:
  p=i//400
  if p<=7:
    l.append(p)
  else:
    cnt+=1

d=len(set(l))
if d==0:
  d+=1
print(d,d+cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split())

cnt=0
l=[]
for i in a:
  p=i//400
  if p<=7:
    l.append(p)
  else:
    cnt+=1

def=len(set(l))
if def==0:
  def+=1
print(def,def+cnt)
Problem p03696 (python)

Fixed submission:
n=int(input())
s=input()
ans=s
s+='#'

c=s.count('()')
while c!=0:
  s=list(s)

  i=0
  n_s=''
  while i<=len(s)-1:
    if s[i]=='(' and s[i+1]==')':
      i+=2
    else:
      n_s+=s[i]
      i+=1

  s=''.join(n_s)
  c=s.count('()')

c_a=s.count('(')
c_b=s.count(')')

ans='('*c_b+ans+')'*c_a
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
ans=s

c=s.count('()')
while c!=0:
  s=list(s)

  i=0
  n_s=''
  while i<=len(s)-1:
    if s[i]=='(' and s[i+1]==')':
      i+=2
    else:
      n_s+=s[i]
      i+=1

  s=''.join(n_s)
  c=s.count('()')

c_a=s.count('(')
c_b=s.count(')')

ans='('*c_b+ans+')'*c_a
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
ans=s

c=s.count('()')
while c!=0:
  s=list(s)
  i=0
  while i<=len(s)-1:
    if s[i]=='(' and s[i+1]==')':
      del s[i]
      del s[i+1]
    else:
      i+=1
  s=''.join(s)
  c=s.count('()')

c_a=s.count('(')
c_b=s.count(')')

ans='('*c_b+ans+')'*c_a
print(ans)
Problem p03711 (python)

Fixed submission:
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]

if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
a=[4,6,9,11]
print('Yes' if x==y==2 or (x in a and y in a) or (x not in a and y not in a))
Problem p03712 (python)

Fixed submission:
h,w=map(int,input().split())
print('#'*(w+2))
for i in range(h):
    print('#'+input()+'#')
print('#'*(w+2))

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
print('#'*(w+2))
for i in range(h):
  print('#'+input()+'#')
print('#'+(w+2))
Problem p03721 (python)

Fixed submission:
n,k=map(int,input().split())
d={}
for i in range(n):
    a,b=map(int,input().split())
    if a in d.keys():
        d[a]+=b
    else:
        d[a]=b
l=sorted(d.keys())
cnt=0
for i in l:
    cnt+=d[i]
    if cnt>=k:
        print(i)
        exit()

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left

n,k=map(int,input().split())

l=[]
for i in range(n):
  a,b=nii()
  l.append([a,b])

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

a_l=[]
b_l=[]
for a,b in l:
  a_l.append(a)
  b_l.append(b)

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

inx=bisect_left(b_rui,k)
print(a_l[inx])
Problem p03761 (python)

Fixed submission:
from collections import Counter

n=int(input())
count=Counter(input())
for i in range(n-1):
    t_count=Counter(input())
    for c_k in count.keys():
        if c_k in t_count.keys():
            count[c_k]=min(count[c_k],t_count[c_k])
        else:
            count[c_k]=0
s=''
for c_k in sorted(count.keys()):
    s+=c_k*count[c_k]
print(s)

Buggy submission (verdict: Runtime Error):
from collections import Counter

n=int(input())
c=Counter(input())
for i in range(n-1):
    c&=Counter(input())
s=''
for k,v in sorted(count.items()):
    s+=k*v
print(s)
Problem p03838 (python)

Fixed submission:
x,y=map(int,input().split())
cnt=0
if x<0<y or y<=0<=x:
    cnt=1
elif 0<y<x or y<x<0:
    cnt=2
print(abs(abs(x)-abs(y))+cnt)

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
if 0<=x<=y or x<=0<=y<=-x or x<=y<=0:
    print(y-x)
elif y<=-x<=0<=x:
    print(-y-x+1)
elif y<=x<=0 or o<=y<=x:
    print(x-y+2)
else:
    print(y+x+1)
Problem p03844 (python)

Fixed submission:
A, op, B = input().split()
if op == '+':
    print(int(A) + int(B))
else:
    print(int(A) - int(B))

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
print(a+c if b=='+' else a-c)
Problem p03945 (python)

Fixed submission:
s=input()

ans=0
bef=s[0]
for i in s[1:]:
  if bef!=i:
    ans+=1
  bef=i
print(ans)

Buggy submission (verdict: Runtime Error):
w, h, n = map(int,input().split())

y_min = 0
y_max = h

x_min = 0
x_max = w

for i in range(n):
  x, y, a = map(int,input().split())

  if a == 1:
    x_min = max(x_min, x)

  if a == 2:
    x_max = min(x_max, x)

  if a == 3:
    y_min = max(y_min, y)

  if a == 4:
    y_max = min(y_max, y)

white = (y_max - y_min) * (x_max - x_min)
if (y_max - y_min)>=0 and (x_max - x_min)>=0:
  print(max(white, 0))
else:
  print(0)

Buggy submission (verdict: Runtime Error):
w, h, n = map(int,input().split())

#とりうるx,yの範囲
y_min = 0
y_max = h

x_min = 0
x_max = w

for i in range(n):
  x, y, a = map(int,input().split())

  if a == 1:
    x_min = max(x_min, x)

  if a == 2:
    x_max = min(x_max, x)

  if a == 3:
    y_min = max(y_min, y)

  if a == 4:
    y_max = min(y_max, y)

white = (y_max - y_min) * (x_max - x_min)
if (y_max - y_min)>=0 and (x_max - x_min)>=0:
  print(max(white, 0))
else:
  print(0)
Problem p03951 (python)

Fixed submission:
n=int(input())
s=input()
t=input()
cnt=0
for i in range(n):
 if s[-i-1:]==t[:i+1]:
  cnt=max(cnt,i+1)
print(2*n-cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
t=input()
for i in range(n):
 if s[-i-1:]==t[:i+1]:
  cnt=i+1
print(2*n-cnt)
Problem p03970 (python)

Fixed submission:
s=input()
a='CODEFESTIVAL2016'
cnt=0
for i in range(len(s)):
    if s[i]!=a[i]:
        cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
s=input()
a='CODEFESTIVAL2016'
cnt=0
for i in range(len(s)):
    if s[i]!=a[i]:
        cnt+=1
print(ans)
Problem p03998 (python)

Fixed submission:
sa=input()
sb=input()
sc=input()

t='a'
while True:
  if t=='a':
    if sa=='':
      print('A')
      exit()
    t=sa[0]
    sa=sa[1:]
  if t=='b':
    if sb=='':
      print('B')
      exit()
    t=sb[0]
    sb=sb[1:]
  if t=='c':
    if sc=='':
      print('C')
      exit()
    t=sc[0]
    sc=sc[1:]

Buggy submission (verdict: Runtime Error):
sa=input()
sb=input()
sc=input()

t='a'
while True:
  if t=='a':
    if sa=='':
      print('A')
      exit()
    t=sa[0]
    sa=sa[1:]
  if t=='b':
    if sb=='':
      print('B')
    t=sb[0]
    sb=sb[1:]
  if t=='c':
    if sc=='':
      print('C')
      exit()
    t=sc[0]
    sc=sc[1:]

Buggy submission (verdict: Runtime Error):
a, b, c = [int(input()) for i in range(3)]

a_list = list(a)
b_list = list(b)
c_list = list(c)

def decide_turn(list):
    next_turn = list[0]
    del list[0]
    return next_turn

next_turn = decide_turn(a_list)

while 1 > 0:
    if next_turn == a:
        if a_list:
            next_turn = decide_turn(a_list)
        else:
            print('A')
            break
    elif next_turn == b:
        if b_list:
            next_turn = decide_turn(b_list)
        else:
            print('B')
            break
    else:
        if c_list:
            next_turn = decide_turn(c_list)
        else:
            print('C')
            break
Problem p03999 (python)

Fixed submission:
s=input()
sl=len(s)

if sl==1:
  print(int(s))
  exit()

ans=0
for i in range(2**(sl-1)):
  l=['' for j in range(sl-1)]
  for k in range(sl-1):
    if (i>>k)&1:
      l[k]='+'

  t_ans=0
  t_s=s[0]

  for k in range(1,sl):
    if l[k-1]=='+':
      t_ans+=int(t_s)
      t_s=s[k]
    else:
      t_s+=s[k]

    if k==sl-1:
      t_ans+=int(t_s)

  ans+=t_ans

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

n,m=map(int,input().split())

tree=[[] for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  tree[a].append(b)
  tree[b].append(a)

dist=[-1 for i in range(n)]
dist[0]=0

dq=deque()
dq.append(0)

while dq:
  x=dq.popleft()

  if x==n-1:
    if dist[x]==2:
      print('POSSIBLE')
    else:
      print('IMPOSSIBLE')

  for i in tree[x]:
    if dist[i]==-1:
      dist[i]=dist[x]+1
      dq.append(i)
Problem p04030 (python)

Fixed submission:
S = input()

S_list = list(S)

answer = []
for S_num in S_list:
    if S_num == '0':
        answer.append('0')
    elif S_num == '1':
        answer.append('1')
    elif not answer:
        continue
    else:
        del answer[-1]

answer_honmono = ''
answer_honmono = ''.join(answer)
print(answer_honmono)

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

S_list = list(S)

answer = []
for S_num in range(S_list):
    if S_num == '0':
        answer.append('0')
    elif S_num == '1':
        answer.append('1')
    elif not answer:
        continue
    else:
        del answer[-1]

print(answer)

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

S_list = list(S)
answer = []
for S_num in range(S_list):
    if S_num == '0':
        answer.append('0')
    elif S_num == '1':
        answer.append('1')
    else:
        del answer[-1]

print(answer)
Problem p04043 (python)

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

if A+B+C == 17 and A*B*C == 175:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())
C = int(input())

if A+B+C == 17 and A*B*C == 175:
    print('YES')
else:
    print('NO')
Problem p02574 (python)

Fixed submission:
from math import gcd
from functools import reduce
from sys import exit

# O(NlogA+AloglogA)解
MAX_A = 1000000
lowerst_prime = [10**9] * (MAX_A + 1) # 最小の素因数をいれる(2以上をみていけばいい)
count = [0] * (MAX_A + 1) # 約数として出てくる回数を数える

for i in range(2, MAX_A + 1): # エラトステネスの篩
    if lowerst_prime[i] != 10**9:
        continue
    lowerst_prime[i] = i
    for j in range(i * i, MAX_A + 1, i): # i * iスタートでいいのは、i * bはbの約数でもあるため
        if lowerst_prime[j] == 10**9:
            lowerst_prime[j] = i
# 入力
N = int(input())
A = [*map(int, input().split())]

if reduce(gcd, A) != 1:
    print("not coprime")
    exit(0)

for i in range(N):
    while A[i] > 1:
        divide = lowerst_prime[A[i]]
        count[divide] += 1
        while A[i] % divide == 0: # 割れるだけ割る
            A[i] //= divide

for i in range(MAX_A + 1):
    if count[i] >= 2:
        print("setwise coprime")
        exit(0)
print("pairwise coprime")

Buggy submission (verdict: Runtime Error):
from math import gcd
from functools import reduce
from sys import exit

# O(A+N)解
MAX_A = 1000000
lowerst_prime = [0] * (MAX_A + 1) # 最小の素因数をいれる(2以上をみていけばいい)
primes = [] # MAX_A以下の素数の集合
count = [0] * (MAX_A + 1) # 約数として出てくる回数を数える
for i in range(2, MAX_A + 1): # 線形時間で処理してくれる
    if lowerst_prime[i] == 0:
        continue
    lowerst_prime[i] = i
    for p in primes:
        if i * p > MAX_A:
            break
        lowerst_prime[i * p] = p # p がi * p のもっとも小さな素因数となるときのみ更新されるので、線形時間アルゴリズムとなる
# 入力
N = int(input())
A = [*map(int, input().split())]
if reduce(gcd, A) != 1:
    print("not coprime")
    exit(0)
for i in range(N):
    while A[i] > 1:
        divide = lowerst_prime[A[i]]
        if count[divide]:
            # A[x] % i == A[y] % i == 0 となるx != yが存在するので、i | gcd(x, y)となる
            print("setwise coprime")
            exit(0)
        count[divide] += 1
        while A[i] % divide == 0: # 割れるだけ割る
            A[i] //= divide
print("pairwise coprime")
Problem p02586 (python)

Fixed submission:
def next_line():
    return input()


def next_int():
    return int(input())


def next_int_array_one_line():
    return list(map(int, input().split()))


def next_int_array_multi_lines(size):
    return [int(input()) for _ in range(size)]


def next_str_array(size):
    return [input() for _ in range(size)]


def main():
    r, c, k = map(int, input().split())
    dp = [[[0] * (c+1) for i in range(r+1)] for i in range(4)]
    v = [[0] * (c+1) for i in range(r+1)]
    for i in range(k):
        row, col, val = map(int, input().split())
        v[row][col] = val

    for row in range(1, r + 1):
        for col in range(1, c + 1):
            for num in range(0, 4):
                if num == 0:
                    dp[num][row][col] = dp[3][row-1][col]  # simple down
                else:
                    dp[num][row][col] = max(dp[num-1][row][col],  # str
                                            dp[num][row][col-1],  # right x
                                            dp[3][row-1][col] + \
                                            v[row][col],  # down o
                                            dp[num-1][row][col-1] + \
                                            v[row][col],  # right o
                                            )
    print(dp[3][r][c])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import numpy as np


def next_line():
    return input()


def next_int():
    return int(input())


def next_int_array_one_line():
    return list(map(int, input().split()))


def next_int_array_multi_lines(size):
    return [int(input()) for _ in range(size)]


def next_str_array(size):
    return [input() for _ in range(size)]


def main():
    r, c, k = map(int, input().split())
    dp = [[[0] * (c+1) for i in range(r+1)] for i in range(4)]
    v = [[0] * (c+1) for i in range(r+1)]
    for i in range(k):
        row, col, val = map(int, input().split())
        v[row][col] = val

    for row in range(1, r + 1):
        for col in range(1, c + 1):
            for num in range(0, 4):
                if num == 0:
                    dp[num][row][col] = dp[3][row-1][col]  # simple down
                else:
                    dp[num][row][col] = max(dp[num-1][row][col],  # str
                                            dp[num][row][col-1],  # right x
                                            dp[3][row-1][col] + \
                                            v[row][col],  # down o
                                            dp[num-1][row][col-1] + \
                                            v[row][col],  # right o
                                            )
    print(dp[3][r][c])


if __name__ == '__main__':
    main()
Problem p02599 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n, q = map(int, input().split())
c = list(map(lambda x: int(x) - 1, input().split()))
query = []
for i in range(q):
    l, r = map(lambda x: int(x) - 1, input().split())
    query.append(l << 40 | r << 20 | i)

query.sort()
ball = [list() for i in range(n)]
for i, x in enumerate(c):
    ball[x].append(i)

# binary indexed tree
bit = [0] * (n + 1)
def add(i, x):
    i += 1
    while i <= n:
        bit[i] += x
        i += i & -i

def get(i):
    i += 1
    s = 0
    while i:
        s += bit[i]
        i -= i & -i
    return s

for i in ball:
    if i:
        add(i[0], 1)
        i.reverse()

at = 0
ans = [0] * q
for x in query:
    l = x >> 40
    r = x >> 20 & 0xfffff
    i = x & 0xfffff
    while at < l:
        b = ball[c[at]]
        add(b[-1], -1)
        b.pop()
        if b:
            add(b[-1], 1)
        at += 1
    ans[i] = get(r) - get(l - 1)

for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
I=lambda:map(int,input().split())
N=0xfffff
n,q=I()
c=list(I())
Q=[]
R=range
for i in R(q):l,r=I();Q.append(l<<40|r<<20|i)
Q.sort()
A=[[]for i in R(N)]
for i in R(n):A[c[i]].append(i)
B=[0]*N
def P(i,x):
	i+=1
	while i<=n:B[i]+=x;i+=i&-i
for i in A:
	if i:P(i[0],1);i.reverse()
t=0
o=[0]*q
for x in Q:
	l=x>>40-1
	r=x>>20&N
	i=x&N
	while t+1<l:
		b=A[c[t]]
		P(b[-1],-1)
		b.pop()
		if b:P(b[-1],1)
		t+=1
	while r:o[i]+=B[r];r-=r&-r
	while l:o[i]-=B[l];l-=l&-l
for i in o:print(i)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n, q = 500000, 500000
c = [randint(1, n) - 1 for i in range(n)]
query = []
for i in range(q):
    l, r = randint(1, n) - 1, randint(1, n) - 1
    if l > r:
        l, r = r, l
    query.append(l << 40 | r << 20 | i)

query.sort()
ball = [list() for i in range(n)]
for i, x in enumerate(c):
    ball[x].append(i)

# binary indexed tree
bit = [0] * (n + 1)
def add(i, x):
    i += 1
    while i <= n:
        bit[i] += x
        i += i & -i

def get(i):
    i += 1
    s = 0
    while i:
        s += bit[i]
        i -= i & -i
    return s

for i in ball:
    if i:
        add(i[0], 1)
        i.reverse()

at = 0
ans = [0] * q
for x in query:
    l = x >> 40
    r = x >> 20 & 0xfffff
    i = x & 0xfffff
    while at < l:
        b = ball[c[at]]
        add(b[-1], -1)
        b.pop()
        if b:
            add(b[-1], 1)
        at += 1
    ans[i] = get(r) - get(l - 1)

for i in ans:
    print(i)
Problem p02755 (python)

Fixed submission:
# 制約が小さいので全探索
def main():
  a, b = map(int, input().split())
  for i in range(1100):
    if int(i * 0.08) == a and int(i * 0.1) == b:
      print(i)
      return
  print(-1)

main()

Buggy submission (verdict: Runtime Error):
# 制約が小さいので全探索
def main():
  a, b = int(input().split())
  for i in range(1100):
    if int(i * 0.08) == a and int(i * 0.1) == b:
      print(i)
      return
  print(-1)

main()
Problem p02640 (python)

Fixed submission:
X, Y = list(map(int, input().split()))
ans = "No"
for a in range(X + 1):
    b = X - a
    if 2 * a + 4 * b == Y:
        ans = "Yes"
print(ans)

Buggy submission (verdict: Runtime Error):
X, Y = map(int,input().split)
ans = "No"
for a in range(X + 1):
    b = X - a
    if 2 * a + 4 * b == Y:
        ans = "Yes"
print(ans)
Problem p02675 (python)

Fixed submission:
a = int(input())
b = a % 10
if b == 0 :
    print("pon")
if b == 1 :
    print("pon")
if b == 2 :
    print("hon")
if b == 3 :
    print("bon")
if b == 4 :
    print("hon")
if b == 5 :
    print("hon")
if b == 6 :
    print("pon")
if b == 7 :
    print("hon")
if b == 8 :
    print("pon")
if b == 9 :
    print("hon")

Buggy submission (verdict: Runtime Error):
n = input()
s = 10
N = n % s
if N == 0 :
    print("pon")
if N == 1 :
    print("pon")
if N == 2 :
    print("hon")
if N == 3 :
    print("bon")
if N == 4 :
    print("hon")
if N == 5 :
    print("hon")
if N == 6 :
    print("pon")
if N == 7 :
    print("hon")
if N == 8 :
    print("pon")
if N == 9 :
    print("hon")