Problem:
Range Add Query (RAQ)

Write a program which manipulates a sequence A = {a1, a2, . . . , an} with the following operations:

add(s, t, x): add x to as, as+1, ..., at.

get(i): output the value of ai.

Note that the initial values of ai (i = 1, 2, . . . , n) are 0.

Input

n q
query1
query2
:
queryq

In the first line, n (the number of elements in A) and q (the number of queries) are given. Then, ith query queryi is given in the following format:

0 s t x

or

1 t

The first digit represents the type of the query. '0' denotes add(s, t, x) and '1' denotes get(i).

Output

For each get operation, print the value.

Constraints

1 ≤ n ≤ 100000

1 ≤ q ≤ 100000

1 ≤ s ≤ t ≤ n

1 ≤ i ≤ n

0 ≤ x ≤ 1000

Sample Input 1

3 5
0 1 2 1
0 2 3 2
0 3 3 3
1 2
1 3

Sample Output 1

3
5

Sample Input 2

4 3
1 2
0 1 4 1
1 2

Sample Output 2

0
1

Solution in Ruby (judge verdict: Accepted)

def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

def max(a,b)
  return a>b ? a : b
end
def min(a,b)
  return a>b ? b : a
end
class SD
  attr_accessor:data,:bucket,:add,:n,:n_sqrt
  def initialize(n)
    @n_sqrt=(n**0.5).to_i
    @n=(n+@n_sqrt-1)/@n_sqrt
    @data=array(@n*@n_sqrt,1,0)
    @add=array(@n,1,0)
    @bucket=array(@n,1,0)
  end

  def add(s,t,x)
    @n.times do|i|
      l=i*@n_sqrt
      r=l+@n_sqrt
      next if r<=s or t<=l
      if s<=l and r<=t
        @add[i]+=x
      else
        for j in max(s,l)..min(t,r)-1
          @data[j]+=x
          @bucket[i]+=x
        end
      end
    end
  end

  def getSum(s,t)
    sum=0
    @n.times do|i|
      l=@n_sqrt*i
      r=l+@n_sqrt
      next if r<=s or t<=l
      if s<=l and r<=t
        sum+=@add[i]*@n_sqrt+@bucket[i]
      else
        for j in max(s,l)..min(t,r)-1
          sum+=@data[j]+@add[i]
        end
      end
    end 
    return sum
  end
end

n,q=get_i
sd=SD.new(n)
q.times do
  que=get_i
  case que[0]
  when 0 then
    s=que[1]-1
    t=que[2]-1
    x=que[3]
    sd.add(s,t+1,x)
  when 1 then
    s=que[1]-1
    puts sd.getSum(s,s+1)
  end
end