Datasets:

problem_id
stringlengths
6
6
buggy_code
stringlengths
8
526k
fixed_code
stringlengths
12
526k
labels
listlengths
0
15
buggy_submission_id
int64
1
1.54M
fixed_submission_id
int64
2
1.54M
user_id
stringlengths
10
10
language
stringclasses
8 values
p02765
s = input().split() N = int(s[0]) R = int(s[1]) if N < 9: ans = R + 100 *(10 - N) else: ans = R print(ans)
s = input().split() N = int(s[0]) R = int(s[1]) if N < 10: ans = R + 100 *(10 - N) else: ans = R print(ans)
[ "literal.number.integer.change", "control_flow.branch.if.condition.change" ]
556,707
556,708
u749512407
python
p02765
n,r = list(map(int,input().split())) if n>=10: print(r) else: t = 100*(10-n) print(r-t)
n,r = list(map(int,input().split())) if n>=10: print(r) else: t = 100*(10-n) print(r+t)
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
556,709
556,710
u896451538
python
p02765
a,b = map(int,input().split()) if a >= 10: print(b) else : print(b + a*100)
a,b = map(int,input().split()) if a >= 10: print(b) else : print(b + ((10-a)*100))
[ "call.arguments.change" ]
556,723
556,724
u408958033
python
p02765
def main(): N, R = map(int, input().split()) if N >= 10: return R else: return R - 100 * (10 - N) if __name__ == '__main__': print(main())
def main(): N, R = map(int, input().split()) if N >= 10: return R else: return R + 100 * (10 - N) if __name__ == '__main__': print(main())
[ "misc.opposites", "expression.operator.arithmetic.change", "function.return_value.change", "expression.operation.binary.change" ]
556,758
556,759
u116002573
python
p02765
N,R = map(int,input().split()) if N >= 10: rat = R else: rat = R - 100*(10-N) print(int(rat))
N,R = map(int,input().split()) if N >= 10: rat = R else: rat = R + 100*(10-N) print(int(rat))
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
556,768
556,769
u517930510
python
p02765
N,R = map(int,input().split()) if N > 9: print(R) else: print(R -1000 +100*N)
N,R = map(int,input().split()) if N > 9: print(R) else: print(R +1000 -100*N)
[ "expression.operation.binary.remove" ]
556,770
556,771
u185424824
python
p02765
n, r = map(int, input().split()) if n < 10: print(r + 100*(10-k)) else: print(r)
n, r = map(int, input().split()) if n < 10: print(r + 100*(10-n)) else: print(r)
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
556,786
556,787
u524489226
python
p02765
n, r = map(int, input().split()) print(n, r) ans = 0 if n >= 10: ans = r else: ans = r + (100 * (10 - n)) print(ans)
n, r = map(int, input().split()) ans = 0 if n >= 10: ans = r else: ans = r + (100 * (10 - n)) print(ans)
[ "call.remove" ]
556,796
556,797
u079182025
python
p02765
a, m = map(int, input().split()) if a >=10: print(m) else: out = m - 100 *(10-a) if out <= 1: print(1) else: print(out)
a, m = map(int, input().split()) if a >=10: print(m) else: out = m + 100 *(10-a) if out <= 1: print(1) else: print(out)
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
556,813
556,814
u267029978
python
p02765
N, R = list(map(int, input().split())) ans = R - 100 * max((10 - N), 0) print(ans)
N, R = list(map(int, input().split())) ans = R + 100 * max((10 - N), 0) print(ans)
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
556,816
556,817
u325264482
python
p02765
N,R = list(map(int,input().split())) if N >= 10: print(R) else: print(R-100*(10-N))
N,R = list(map(int,input().split())) if N >= 10: print(R) else: print(100*(10-N)+R)
[ "expression.operation.binary.remove" ]
556,823
556,824
u489762173
python
p02765
N,R = list(map(int,input().split())) if N >= 10: print(R) else: print(100*(10-N))
N,R = list(map(int,input().split())) if N >= 10: print(R) else: print(100*(10-N)+R)
[ "expression.operation.binary.add" ]
556,825
556,824
u489762173
python
p02765
n, r = map(int,input().split()) print(100*(10-n) if n < 10 else r)
n, r = map(int,input().split()) print(r+100*(10-n) if n < 10 else r)
[ "expression.operation.binary.add" ]
556,828
556,829
u463775490
python
p02765
def main(): K = 0 N, R = [int(_) for _ in input().split()] if N >= 10: K = R else: K = R + 100(10 - N) print(K) main()
def main(): K = 0 N, R = [int(_) for _ in input().split()] if N >= 10: K = R else: K = R + 100 * (10 - N) print(K) main()
[]
556,830
556,831
u571395477
python
p02765
N, R = map(int, input().split()) if N >= 10: ans = R else: ans = R - 100 * (10 - N) print(ans)
N, R = map(int, input().split()) if N >= 10: ans = R else: ans = R + 100 * (10 - N) print(ans)
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
556,832
556,833
u732870425
python
p02765
N, R = map(int, input().split()) if N >= 10: ans = R else: ans = R - 100 * (10 - K) print(ans)
N, R = map(int, input().split()) if N >= 10: ans = R else: ans = R + 100 * (10 - N) print(ans)
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change", "identifier.change" ]
556,834
556,833
u732870425
python
p02765
deta = input().split() n = deta[0] r = deta[1] if int(n)>=10: print(r) else: rate = 100*(10-int(n)) print(rate)
deta = input().split() n = deta[0] r = deta[1] if int(n)>=10: print(r) else: rate = 100*(10-int(n))+int(r) print(rate)
[ "assignment.change" ]
556,835
556,836
u953379577
python
p02765
""" じょえチャンネルおもしろいよ~~~ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ """ n,r=map(int,input().split()) if n==10:print(r) else:print(r+100*(10-n))
""" じょえチャンネルおもしろいよ~~~ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ """ n,r=map(int,input().split()) if n>=10:print(r) else:print(r+100*(10-n))
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
556,844
556,845
u227082700
python
p02765
""" じょえちゃんねる 高評価・チャンネル登録よろしくお願いします! https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ """ n, r = map(int, input().split()) if n >= 10: print(r) else: print(r + 100 * (10 - k))
""" じょえちゃんねる 高評価・チャンネル登録よろしくお願いします! https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ """ n, r = map(int, input().split()) if n >= 10: print(r) else: print(r + 100 * (10 - n))
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
556,846
556,847
u143509139
python
p02765
N,R = input().split() N = int(N) R = int(R) if N >= 10: print(R) else: print(100*(10-N))
N,R = input().split() N = int(N) R = int(R) if N >= 10: print(R) else: print(R + 100*(10-N))
[ "expression.operation.binary.add" ]
556,852
556,853
u651822741
python
p02765
N,R = input() N = int(N) R = int(R) if N >= 10: print(R) else: print(100*(10-N))
N,R = input().split() N = int(N) R = int(R) if N >= 10: print(R) else: print(R + 100*(10-N))
[ "expression.operation.binary.add" ]
556,854
556,853
u651822741
python
p02765
N,R=map(int, input().split()) print(R if N>=10 else R-100*(10-N))
N,R=map(int, input().split()) print(R if N>=10 else R+100*(10-N))
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
556,857
556,856
u748311048
python
p02765
i = list(map(int, input().split())) N = i[0] R = i[1] if N >= 10: insc = R else: insc = R + 100(10-N) print(insc)
i = list(map(int, input().split())) N = i[0] R = i[1] if N >= 10: insc = R else: insc = R + 100*(10-N) print(insc)
[]
556,858
556,859
u891125728
python
p02765
N,R=list(map(int,input().split())) if N>=10: print(R) else: print(A+100*(10-N))
N,R=list(map(int,input().split())) if N>=10: print(R) else: print(R+100*(10-N))
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
556,866
556,867
u903179665
python
p02765
import sys input = sys.stdin.readline N, R = [int(x) for x in input().split()] if N >= 10: print(R) else: print(R + 100 * (10 - K))
import sys input = sys.stdin.readline N, R = [int(x) for x in input().split()] if N >= 10: print(R) else: print(R + 100 * (10 - N))
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
556,868
556,869
u609061751
python
p02765
import sys input = sys.stdin.readline N, R = [int(x) for x in input().split()] if N >= 10: print(R) else: print(R + 100 * (10 - R))
import sys input = sys.stdin.readline N, R = [int(x) for x in input().split()] if N >= 10: print(R) else: print(R + 100 * (10 - N))
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
556,870
556,869
u609061751
python
p02765
_input = input() number = _input.split() N = number[0] R = number[1] if N<10: R += 100 * (10-N) print(R)
_input = input() number = _input.split() N = int(number[0]) R = int(number[1]) if N<10: R += 100 * (10-N) print(R)
[ "call.add", "call.arguments.change" ]
556,879
556,880
u052331051
python
p02765
n,r = map(int,input().split()) print(r if n >= 10 else 100*(10-n))
n,r = map(int,input().split()) print(r if n >= 10 else r+100*(10-n))
[ "expression.operation.binary.add" ]
556,883
556,884
u836737505
python
p02765
n,r=map(int,input.split()) if n >= 10: print(r) else: in_rate = r + 100 * (10-n) print(in_rate)
n,r = map(int,input().split()) if n >= 10: print(r) else: in_rating = r + 100 * (10-n) print(in_rating)
[ "call.add", "assignment.variable.change", "identifier.change", "call.arguments.change", "io.output.change" ]
556,887
556,886
u752522099
python
p02765
n,r=map(int,input.split()) if n >= 10: print(r) else: in_rate = r + 100 * (10-n) print(in_rate)
n,r = map(int,input().split()) if n >= 10: print(r) else: in_rating = r + 100 * (10-n) print(in_rating)
[ "call.add", "assignment.variable.change", "identifier.change", "call.arguments.change", "io.output.change" ]
556,887
556,888
u752522099
python
p02765
n,r=map(int,input.split()) if n >= 10: print(r) else: in_rate = r + 100 * (10-n) print(in_rate)
n,r=map(int,input().split()) if n >= 10: print(r) else: in_rate = r + 100 * (10-n) print(in_rate)
[ "call.add" ]
556,887
556,889
u752522099
python
p02763
class SegmentTree(): """A segment Tree. This is a segment tree without recursions. This can support queries as follows: - update a single value in O(logN). - get the folded value of values in a segment [l, r) in O(logN) N is the length of the given iterable value. Parameters ---------- iterable : Iterable[_T] An iterable value which will be converted into a segment tree func : Callable[[_T, _T], _T] A binary function which returns the same type as given two. This has to satisfy the associative law: func(a, func(b, c)) = func(func(a, b), c) e : _T The identity element of the given func. In other words, this satisfies: func(x, e) = func(e, x) = x """ def __init__(self, iterable, func, e): self.func = func self.e = e ls = list(iterable) self.n = 1 << len(ls).bit_length() ls.extend( [self.e] * (self.n - len(ls)) ) self.data = [self.e] * self.n + ls for i in range(self.n-1, 0, -1): self.data[i] = self.func(self.data[2*i], self.data[2*i+1]) def replace(self, index, value): """replace the old value of the given index with the given new value. This replaces the old value of the given index with the given new value in O(logN). This is like "list[index] = value". Parameters ---------- index : int The index of the value which will be replaced. value : _T The new value with which the old value will be replaced. """ index += self.n self.data[index] = value index //= 2 while index > 0: self.data[index] = self.func(self.data[2*index], self.data[2*index+1]) index //= 2 def folded(self, l, r): """get the folded value of values in a segment [l, r). This get the folded value of values in a segment [l, r) in O(logN). If func is add, it returns the sum of values in [l, r). In other words, this is eqivalent to "sum(list[l:r])". If func is other functions, then this is equivalent to "accumulate(list[l:r], func)". Parameters ---------- l : int The left edge. r : int The right edge. Returns ------- _T(the same type as the type of the element of the given iterable) This is equivalent to func(list[l], func(list[l+1], ... ) ). If func is represented as '*', then it's: list[l] * list[l+1] * ... * list[r-1] """ left_folded = self.e right_folded = self.e l += self.n r += self.n while l < r: if l % 2: left_folded = self.func(left_folded, self.data[l]) l += 1 if r % 2: r -= 1 right_folded = self.func(self.data[r], right_folded) l //= 2 r //= 2 return self.func(left_folded, right_folded) from operator import or_ N = int(input()) S = input() ls = [1 << (ord(c) - ord('a')) for c in S] segtree = SegmentTree(ls, or_, 0) Q = int(input()) for _ in range(Q): s = input() if s[0] == '1': i, c = s[2:].split() segtree.replace(int(i), 1 << (ord(c) - ord('a'))) else: l, r = map(int, s[2:].split()) value = segtree.folded(l-1, r) print(format(value, 'b').count('1'))
class SegmentTree(): """A segment Tree. This is a segment tree without recursions. This can support queries as follows: - update a single value in O(logN). - get the folded value of values in a segment [l, r) in O(logN) N is the length of the given iterable value. Parameters ---------- iterable : Iterable[_T] An iterable value which will be converted into a segment tree func : Callable[[_T, _T], _T] A binary function which returns the same type as given two. This has to satisfy the associative law: func(a, func(b, c)) = func(func(a, b), c) e : _T The identity element of the given func. In other words, this satisfies: func(x, e) = func(e, x) = x """ def __init__(self, iterable, func, e): self.func = func self.e = e ls = list(iterable) self.n = 1 << len(ls).bit_length() ls.extend( [self.e] * (self.n - len(ls)) ) self.data = [self.e] * self.n + ls for i in range(self.n-1, 0, -1): self.data[i] = self.func(self.data[2*i], self.data[2*i+1]) def replace(self, index, value): """replace the old value of the given index with the given new value. This replaces the old value of the given index with the given new value in O(logN). This is like "list[index] = value". Parameters ---------- index : int The index of the value which will be replaced. value : _T The new value with which the old value will be replaced. """ index += self.n self.data[index] = value index //= 2 while index > 0: self.data[index] = self.func(self.data[2*index], self.data[2*index+1]) index //= 2 def folded(self, l, r): """get the folded value of values in a segment [l, r). This get the folded value of values in a segment [l, r) in O(logN). If func is add, it returns the sum of values in [l, r). In other words, this is eqivalent to "sum(list[l:r])". If func is other functions, then this is equivalent to "accumulate(list[l:r], func)". Parameters ---------- l : int The left edge. r : int The right edge. Returns ------- _T(the same type as the type of the element of the given iterable) This is equivalent to func(list[l], func(list[l+1], ... ) ). If func is represented as '*', then it's: list[l] * list[l+1] * ... * list[r-1] """ left_folded = self.e right_folded = self.e l += self.n r += self.n while l < r: if l % 2: left_folded = self.func(left_folded, self.data[l]) l += 1 if r % 2: r -= 1 right_folded = self.func(self.data[r], right_folded) l //= 2 r //= 2 return self.func(left_folded, right_folded) from operator import or_ N = int(input()) S = input() ls = [1 << (ord(c) - ord('a')) for c in S] segtree = SegmentTree(ls, or_, 0) Q = int(input()) for _ in range(Q): s = input() if s[0] == '1': i, c = s[2:].split() segtree.replace(int(i)-1, 1 << (ord(c) - ord('a'))) else: l, r = map(int, s[2:].split()) value = segtree.folded(l-1, r) print(format(value, 'b').count('1'))
[ "expression.operation.binary.add" ]
556,911
556,912
u034128150
python
p02763
import sys input = lambda: sys.stdin.readline().rstrip() class SegTree: def __init__(self, init_val, segfunc, ide_ele): n = len(init_val) self.ide_ele = ide_ele self.segfunc = segfunc self.num = 2**(n - 1).bit_length() self.seg = [self.ide_ele] * 2 * self.num for i in range(n): self.seg[i + self.num - 1] = init_val[i] for i in range(self.num - 2, -1, -1): self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2]) def update(self, k, x): k += self.num - 1 self.seg[k] = x while k: k = (k - 1) // 2 self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2]) def query(self, p, q): if q <= p: return self.ide_ele p += self.num - 1 q += self.num - 2 res = self.ide_ele while q - p > 1: if p & 1 == 0: res = self.segfunc(res, self.seg[p]) if q & 1 == 1: res = self.segfunc(res, self.seg[q]) q -= 1 p = p // 2 q = (q - 1) // 2 if p == q: res = self.segfunc(res, self.seg[p]) else: res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q]) return res def solve(): N = int(input()) S = list(input()) Q = int(input()) seg = [1 << (ord(s) - ord('a')) for s in S] segtree = [] segfunc = lambda a, b: a | b segtree = SegTree(seg, segfunc, 0) ans = [] for i in range(Q): a, b, c = input().split() a = int(a) if a == 1: b = int(b) - 1 al = ord(c) - ord('a') segtree.update(b, al) elif a == 2: b, c = int(b) - 1, int(c) res = segtree.query(b, c) res = sum(list(map(int, bin(res)[2:]))) ans.append(res) print('\n'.join(map(str, ans))) if __name__ == '__main__': solve()
import sys input = lambda: sys.stdin.readline().rstrip() class SegTree: def __init__(self, init_val, segfunc, ide_ele): n = len(init_val) self.ide_ele = ide_ele self.segfunc = segfunc self.num = 2**(n - 1).bit_length() self.seg = [self.ide_ele] * 2 * self.num for i in range(n): self.seg[i + self.num - 1] = init_val[i] for i in range(self.num - 2, -1, -1): self.seg[i] = self.segfunc(self.seg[2 * i + 1], self.seg[2 * i + 2]) def update(self, k, x): k += self.num - 1 self.seg[k] = x while k: k = (k - 1) // 2 self.seg[k] = self.segfunc(self.seg[k * 2 + 1], self.seg[k * 2 + 2]) def query(self, p, q): if q <= p: return self.ide_ele p += self.num - 1 q += self.num - 2 res = self.ide_ele while q - p > 1: if p & 1 == 0: res = self.segfunc(res, self.seg[p]) if q & 1 == 1: res = self.segfunc(res, self.seg[q]) q -= 1 p = p // 2 q = (q - 1) // 2 if p == q: res = self.segfunc(res, self.seg[p]) else: res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q]) return res def solve(): N = int(input()) S = list(input()) Q = int(input()) seg = [1 << (ord(s) - ord('a')) for s in S] segtree = [] segfunc = lambda a, b: a | b segtree = SegTree(seg, segfunc, 0) ans = [] for i in range(Q): a, b, c = input().split() a = int(a) if a == 1: b = int(b) - 1 al = ord(c) - ord('a') segtree.update(b, 1 << al) elif a == 2: b, c = int(b) - 1, int(c) res = segtree.query(b, c) res = sum(list(map(int, bin(res)[2:]))) ans.append(res) print('\n'.join(map(str, ans))) if __name__ == '__main__': solve()
[ "expression.operation.binary.add" ]
556,917
556,918
u163783894
python
p02763
from bisect import bisect_left,bisect_right import string dic = {c:[] for c in string.ascii_lowercase} n = int(input()) s = list(input()) q = int(input()) for i,c in enumerate(s,start=1): dic[c].append(i) print(dic) for i in range(q): p,l,r = map(str,input().split()) if p =='1': j = int(l) if r == s[j-1]: continue c = s[j-1] dic[c].pop(bisect_left(dic[c],j)) dic[r].insert(bisect_left(dic[r],j),j) s[j-1] = r else: ans = 0 l = int(l) r = int(r) for c in string.ascii_lowercase: pl = bisect_left(dic[c],l) if pl < len(dic[c]): if dic[c][pl] <= r: ans += 1 print(ans)
from bisect import bisect_left,bisect_right import string dic = {c:[] for c in string.ascii_lowercase} n = int(input()) s = list(input()) q = int(input()) for i,c in enumerate(s,start=1): dic[c].append(i) for i in range(q): p,l,r = map(str,input().split()) if p =='1': j = int(l) if r == s[j-1]: continue c = s[j-1] dic[c].pop(bisect_left(dic[c],j)) dic[r].insert(bisect_left(dic[r],j),j) s[j-1] = r else: ans = 0 l = int(l) r = int(r) for c in string.ascii_lowercase: pl = bisect_left(dic[c],l) if pl < len(dic[c]): if dic[c][pl] <= r: ans += 1 print(ans)
[ "call.remove" ]
556,919
556,920
u572142121
python
p02763
class segtree: def __init__(self,N): self.n=(1<<len(bin(N-1)[2:])) self.x=[0 for _ in range(2*self.n)] def build(self,seq): for i, j in enumerate(seq, start=self.n): self.x[i]=1<<j for i in range(self.n-1, 0, -1): self.x[i]=self.x[i*2]|self.x[i*2+1] def update(self, i, c): j=i+self.n self.x[j]=1<<c while j>1: j//=2 self.x[j]=self.x[j*2]|self.x[j*2+1] def get(self,l,r): ans=0 l+=self.n r+=self.n while l<r: if l%2==1: ans|=self.x[l] l+=1 if r%2==0: ans|=self.x[r] r-=1 l//=2 r//=2 if l==r: ans|=self.x[r] cnt=sum(list(map(int, list(bin(ans)[2:])))) print(cnt) n=int(input()) s=list(input()) s=[ord(i)-97 for i in s] seg=segtree(n) seg.build(s) #print(seg.x) for _ in range(int(input())): que=list(input().split()) if que[0]=='1': seg.update(int(que[1]), ord(que[2])-97) elif que[0]=='2': seg.get(int(que[1])-1,int(que[2])-1)
class segtree: def __init__(self,N): self.n=(1<<len(bin(N-1)[2:])) self.x=[0 for _ in range(2*self.n)] def build(self,seq): for i, j in enumerate(seq, start=self.n): self.x[i]=1<<j for i in range(self.n-1, 0, -1): self.x[i]=self.x[i*2]|self.x[i*2+1] def update(self, i, c): j=i+self.n self.x[j]=1<<c while j>1: j//=2 self.x[j]=self.x[j*2]|self.x[j*2+1] def get(self,l,r): ans=0 l+=self.n r+=self.n while l<r: if l%2==1: ans|=self.x[l] l+=1 if r%2==0: ans|=self.x[r] r-=1 l//=2 r//=2 if l==r: ans|=self.x[l] cnt=sum(list(map(int, list(bin(ans)[2:])))) print(cnt) n=int(input()) s=list(input()) s=[ord(i)-97 for i in s] seg=segtree(n) seg.build(s) #print(seg.x) for _ in range(int(input())): que=list(input().split()) if que[0]=='1': seg.update(int(que[1])-1, ord(que[2])-97) elif que[0]=='2': seg.get(int(que[1])-1,int(que[2])-1)
[ "identifier.change", "variable_access.subscript.index.change" ]
556,926
556,927
u260216890
python
p02763
#!/usr/bin/env python3 import sys sys.setrecursionlimit(300000) def update(i, val, n, bi_tree, sign=1): i += 1 while i < n: bi_tree[i][val] += (1 * sign) i += i & -i def get_sum(i, bi_tree): ans = [0] * 26 while i > 0: tmp = bi_tree[i] for j in range(26): ans[j] += tmp[j] #ans += bi_tree[index] i -= i & -i return ans def get_range_sum(left, right, bi_tree): r_sum = get_sum(right, bi_tree) l_sum = get_sum(left - 1, bi_tree) for i in range(26): r_sum[i] -= l_sum[i] return r_sum from pprint import pprint def solve(N, S, Q, queries): #arr.insert(0, 0) # insert dummy node for 1-based indexing #bit = [0 for i in range(n+1)] bit = [[0] * 26 for i in range(N + 1)] s = [] for i, c in enumerate(S): if 'a' <= c <= 'z': update(i, ord(c) - ord('a'), N + 1, bit) s.append(c) #pprint(bit) #return for q in queries: if q[0] == '1': i, c = int(q[1]) - 1, q[2] p = s[i] update(i, ord(p) - ord('a'), N, bit, -1) update(i, ord(c) - ord('a'), N, bit, 1) s[i] = c if q[0] == '2': l, r = int(q[1]), int(q[2]) counts = get_range_sum(l, r, bit) ret = 0 for x in counts: if x > 0: ret += 1 print(ret) return def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) S = str(next(tokens)) Q = int(next(tokens)) q = [] for i in range(Q): q.append(list(map(str, input().split()))) solve(N, S, Q, q) if __name__ == '__main__': main()
#!/usr/bin/env python3 import sys sys.setrecursionlimit(300000) def update(i, val, n, bi_tree, sign=1): i += 1 while i < n: bi_tree[i][val] += (1 * sign) i += i & -i def get_sum(i, bi_tree): ans = [0] * 26 while i > 0: tmp = bi_tree[i] for j in range(26): ans[j] += tmp[j] i -= i & -i return ans def get_range_sum(left, right, bi_tree): r_sum = get_sum(right, bi_tree) l_sum = get_sum(left - 1, bi_tree) for i in range(26): r_sum[i] -= l_sum[i] return r_sum from pprint import pprint def solve(N, S, Q, queries): #arr.insert(0, 0) # insert dummy node for 1-based indexing #bit = [0 for i in range(n+1)] bit = [[0] * 26 for i in range(N + 1)] s = [] for i, c in enumerate(S): if 'a' <= c <= 'z': update(i, ord(c) - ord('a'), N + 1, bit) s.append(c) for q in queries: if q[0] == '1': i, c = int(q[1]) - 1, q[2] p = s[i] update(i, ord(p) - ord('a'), N + 1, bit, -1) update(i, ord(c) - ord('a'), N + 1, bit, 1) s[i] = c if q[0] == '2': l, r = int(q[1]), int(q[2]) counts = get_range_sum(l, r, bit) ret = 0 for x in counts: if x > 0: ret += 1 print(ret) #pprint(get_range_sum(1, 5, bit)) #print(s) #print() return def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) S = str(next(tokens)) Q = int(next(tokens)) q = [] for i in range(Q): q.append(list(map(str, input().split()))) solve(N, S, Q, q) if __name__ == '__main__': main()
[ "expression.operation.binary.add" ]
556,958
556,959
u200785298
python
p02763
import sys, bisect, math, itertools, heapq, collections from operator import itemgetter # a.sort(key=itemgetter(i)) # i番目要素でsort from functools import lru_cache # @lru_cache(maxsize=None) sys.setrecursionlimit(10**8) input = sys.stdin.readline INF = float('inf') mod = 10**9+7 eps = 10**-7 def inp(): ''' 一つの整数 ''' return int(input()) def inpl(): ''' 一行に複数の整数 ''' return list(map(int, input().split())) class SegmentTree(): def __init__(self, init_val, N): """ Parameters ---------- init_val:int identity element N:int the number of nodes """ self.init_val=init_val # Range Minimum Query self.N0 = 2**(N-1).bit_length() #Nを超える最小の2のべき乗 # 0-indexedで管理(N0-1からはじまる) self.data = [self.init_val] * (2 * self.N0) def _segfunc(self, left, right): res= left | right return res def update(self,k, x): """ Parameters ---------- k:int target index(0-index) x:any target value """ k += self.N0-1 self.data[k] = x while k > 0: k = (k - 1) // 2 self.data[k] = self._segfunc(self.data[2*k+1], self.data[2*k+2]) def query(self, l, r): """ Parameters ---------- l,r:int target range [l,r) Return ---------- res:any val """ L = l + self.N0 R = r + self.N0 s = self.init_val while L < R: if R & 1: R -= 1 s = self._segfunc(s, self.data[R-1]) if L & 1: s = self._segfunc(s, self.data[L-1]) L += 1 L >>= 1; R >>= 1 return s def chartobit(c): return 1<<(ord(c)-97) n=inp() s=[chartobit(i) for i in list(input()) if i!="\n"] st = SegmentTree(0, n) for i in range(n): st.update(i,s[i]) q = inp() ans = [] for i in range(q): mode, first, second = input().split() if mode == "1": # if second in st.data[int(first) - 1 + st.N0 - 1]: # continue st.update(int(first) - 1, chartobit(second)) else: ans.append((st.query(int(first) - 1, int(second)))) for i in ans: print(sum(map(int,bin(i)[2:]))) print(st.data)
import sys, bisect, math, itertools, heapq, collections from operator import itemgetter # a.sort(key=itemgetter(i)) # i番目要素でsort from functools import lru_cache # @lru_cache(maxsize=None) sys.setrecursionlimit(10**8) input = sys.stdin.readline INF = float('inf') mod = 10**9+7 eps = 10**-7 def inp(): ''' 一つの整数 ''' return int(input()) def inpl(): ''' 一行に複数の整数 ''' return list(map(int, input().split())) class SegmentTree(): def __init__(self, init_val, N): """ Parameters ---------- init_val:int identity element N:int the number of nodes """ self.init_val=init_val # Range Minimum Query self.N0 = 2**(N-1).bit_length() #Nを超える最小の2のべき乗 # 0-indexedで管理(N0-1からはじまる) self.data = [self.init_val] * (2 * self.N0) def _segfunc(self, left, right): res= left | right return res def update(self,k, x): """ Parameters ---------- k:int target index(0-index) x:any target value """ k += self.N0-1 self.data[k] = x while k > 0: k = (k - 1) // 2 self.data[k] = self._segfunc(self.data[2*k+1], self.data[2*k+2]) def query(self, l, r): """ Parameters ---------- l,r:int target range [l,r) Return ---------- res:any val """ L = l + self.N0 R = r + self.N0 s = self.init_val while L < R: if R & 1: R -= 1 s = self._segfunc(s, self.data[R-1]) if L & 1: s = self._segfunc(s, self.data[L-1]) L += 1 L >>= 1; R >>= 1 return s def chartobit(c): return 1<<(ord(c)-97) n=inp() s=[chartobit(i) for i in list(input()) if i!="\n"] st = SegmentTree(0, n) for i in range(n): st.update(i,s[i]) q = inp() ans = [] for i in range(q): mode, first, second = input().split() if mode == "1": # if second in st.data[int(first) - 1 + st.N0 - 1]: # continue st.update(int(first) - 1, chartobit(second)) else: ans.append((st.query(int(first) - 1, int(second)))) for i in ans: print(sum(map(int,bin(i)[2:])))
[ "call.remove" ]
556,969
556,970
u802977614
python
p02763
import sys, bisect, math, itertools, heapq, collections from operator import itemgetter # a.sort(key=itemgetter(i)) # i番目要素でsort from functools import lru_cache # @lru_cache(maxsize=None) sys.setrecursionlimit(10**8) input = sys.stdin.readline INF = float('inf') mod = 10**9+7 eps = 10**-7 def inp(): ''' 一つの整数 ''' return int(input()) def inpl(): ''' 一行に複数の整数 ''' return list(map(int, input().split())) class SegmentTree(): def __init__(self, init_val, N): """ Parameters ---------- init_val:int identity element N:int the number of nodes """ self.init_val=init_val # Range Minimum Query self.N0 = 2**(N-1).bit_length() # 0-indexedで管理 self.data = [self.init_val] * (2 * self.N0) def _segfunc(self, left, right): res= left | right return res def update(self,k, x): """ Parameters ---------- k:int target index(0-index) x:any target value """ k += self.N0-1 self.data[k] = x while k > 0: k = (k - 1) // 2 self.data[k] = self._segfunc(self.data[2*k+1], self.data[2*k+2]) def query(self, l, r): """ Parameters ---------- l,r:int target range [l,r) Return ---------- res:any val """ L = l + self.N0 R = r + self.N0 s = self.init_val while L < R: if R & 1: R -= 1 s = self._segfunc(s, self.data[R-1]) if L & 1: s = self._segfunc(s, self.data[L-1]) L += 1 L >>= 1; R >>= 1 return s n=inp() s=input() st = SegmentTree(0,n) for i in range(n): st.update(i,1<<(int.from_bytes(s[i].encode(),'little')-int.from_bytes('a'.encode(),'little'))) q = inp() ans = [] for i in range(q): mode, first, second = input().split() if mode == "1": st.update(int(first),1<<(int.from_bytes(str(second).encode(),'little')-int.from_bytes('a'.encode(),'little'))) else: ans.append(bin(st.query(int(first) - 1, int(second))).count("1")) for i in ans: print(i)
import sys, bisect, math, itertools, heapq, collections from operator import itemgetter # a.sort(key=itemgetter(i)) # i番目要素でsort from functools import lru_cache # @lru_cache(maxsize=None) sys.setrecursionlimit(10**8) input = sys.stdin.readline INF = float('inf') mod = 10**9+7 eps = 10**-7 def inp(): ''' 一つの整数 ''' return int(input()) def inpl(): ''' 一行に複数の整数 ''' return list(map(int, input().split())) class SegmentTree(): def __init__(self, init_val, N): """ Parameters ---------- init_val:int identity element N:int the number of nodes """ self.init_val=init_val # Range Minimum Query self.N0 = 2**(N-1).bit_length() # 0-indexedで管理 self.data = [self.init_val] * (2 * self.N0) def _segfunc(self, left, right): res= left | right return res def update(self,k, x): """ Parameters ---------- k:int target index(0-index) x:any target value """ k += self.N0-1 self.data[k] = x while k > 0: k = (k - 1) // 2 self.data[k] = self._segfunc(self.data[2*k+1], self.data[2*k+2]) def query(self, l, r): """ Parameters ---------- l,r:int target range [l,r) Return ---------- res:any val """ L = l + self.N0 R = r + self.N0 s = self.init_val while L < R: if R & 1: R -= 1 s = self._segfunc(s, self.data[R-1]) if L & 1: s = self._segfunc(s,self.data[L-1]) L += 1 L >>= 1; R >>= 1 return s n=inp() s=input() st = SegmentTree(0,n) for i in range(n): st.update(i,1<<(int.from_bytes(s[i].encode(),'little')-int.from_bytes('a'.encode(),'little'))) q = inp() ans = [] for i in range(q): mode, first, second = input().split() if mode == "1": st.update(int(first)-1,1<<(int.from_bytes(second.encode(),'little')-int.from_bytes('a'.encode(),'little'))) else: ans.append(bin(st.query(int(first) - 1, int(second))).count("1")) for i in ans: print(i)
[ "call.remove", "call.arguments.change" ]
556,971
556,972
u168579419
python
p02763
def main(sample_file = ''): """ convenient functions # for i, a in enumerate(iterable) # q, mod = divmod(a, b) # divmod(x, y) returns the tuple (x//y, x%y) # Higher-order function: reduce(operator.mul, xyz_count, 1) # manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f """ """convenient decorator # @functools.lru_cache(): # to facilitate use of recursive function # ex: # from functools import lru_cache # import sys # sys.setrecursionlimit(10**9) # @lru_cache(maxsize=None) # def fib(n): # if n < 2: # return n # return fib(n-1) + fib(n-2) # print(fib(1000)) """ # import numpy as np import sys sys.setrecursionlimit(10**7) from itertools import accumulate, combinations, permutations, product # https://docs.python.org/ja/3/library/itertools.html # accumulate() returns iterator! to get list: list(accumulate()) from math import factorial, ceil, floor, sqrt def factorize(n): """return the factors of the Arg and count of each factor Args: n (long): number to be resolved into factors Returns: list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)] """ fct = [] # prime factor b, e = 2, 0 # base, exponent while b * b <= n: while n % b == 0: n = n // b e = e + 1 if e > 0: fct.append((b, e)) b, e = b + 1, 0 if n > 1: fct.append((n, 1)) return fct def combinations_count(n, r): """Return the number of selecting r pieces of items from n kinds of items. Args: n (long): number r (long): number Raises: Exception: not defined when n or r is negative Returns: long: number """ # TODO: How should I do when n - r is negative? if n < 0 or r < 0: raise Exception('combinations_count(n, r) not defined when n or r is negative') if n - r < r: r = n - r if r < 0: return 0 if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2,r+1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r) % p for k in range(p-1,r,p): numerator[k - offset] /= pivot denominator[k] /= pivot result = 1 for k in range(r): if numerator[k] > 1: result *= int(numerator[k]) return result def combinations_with_replacement_count(n, r): """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once. Args: n (long): number r (long): number Raises: Exception: not defined when n or r is negative Returns: long: number """ if n < 0 or r < 0: raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative') elif n == 0: return 1 else: return combinations_count(n + r - 1, r) from bisect import bisect_left, bisect_right from collections import deque, Counter, defaultdict # https://docs.python.org/ja/3/library/collections.html#collections.deque from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest # https://docs.python.org/ja/3/library/heapq.html from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html import operator from operator import itemgetter #sort # ex1: List.sort(key=itemgetter(1)) # ex2: sorted(tuples, key=itemgetter(1,2)) from functools import reduce, lru_cache def chmin(x, y): """change minimum if x > y, x = y and return (x, True). convenient when solving problems of dp[i] Args: x (long): current minimum value y (long): potential minimum value Returns: (x, bool): (x, True) when updated, else (x, False) """ if x > y: x = y return (x, True) else: return (x, False) def chmax(x, y): """change maximum if x < y, x = y and return (x, True). convenient when solving problems of dp[i] Args: x (long): current maximum value y (long): potential maximum value Returns: (x, bool): (x, True) when updated, else (x, False) """ if x < y: x = y return (x, True) else: return (x, False) from math import gcd # Deprecated since version 3.5: Use math.gcd() instead. def gcds(numbers): return reduce(gcd, numbers) def lcm(x, y): return (x * y) // gcd(x, y) def lcms(numbers): return reduce(lcm, numbers, 1) def make_divisors(n, reversed=False): """create list of divisors Args: number (int): number from which list of divisors is created reversed (bool, optional): ascending order if False. Defaults to False. Returns: list: list of divisors """ divisors = set() for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.add(i) divisors.add(n//i) return sorted(list(divisors),reverse=reversed) # first create factorial_list # fac_list = mod_factorial_list(n) INF = 10 ** 18 MOD = 10 ** 9 + 7 AtoZ = list('abcdefghijklmnopqrsruvwxyz') # 26 modpow = lambda a, n, p = MOD: pow(a, n, p) # Recursive function in python is slow! def modinv(a, p = MOD): # evaluate reciprocal using Fermat's little theorem: # a**(p-1) is identical to 1 (mod p) when a and p is coprime return modpow(a, p-2, p) def modinv_list(n, p = MOD): if n <= 1: return [0,1][:n+1] else: inv_t = [0,1] for i in range(2, n+1): inv_t += [inv_t[p % i] * (p - int(p / i)) % p] return inv_t def modfactorial_list(n, p = MOD): if n == 0: return [1] else: l = [0] * (n+1) tmp = 1 for i in range(1, n+1): tmp = tmp * i % p l[i] = tmp return l def modcomb(n, k, fac_list = [], p = MOD): # fac_list = modfactorial_list(100) # print(modcomb(100, 5, modfactorial_list(100))) from math import factorial if n < 0 or k < 0 or n < k: return 0 if n == 0 or k == 0: return 1 if len(fac_list) <= n: a = factorial(n) % p b = factorial(k) % p c = factorial(n-k) % p else: a = fac_list[n] b = fac_list[k] c = fac_list[n-k] return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p def modadd(a, b, p = MOD): return (a + b) % MOD def modsub(a, b, p = MOD): return (a - b) % p def modmul(a, b, p = MOD): return ((a % p) * (b % p)) % p def moddiv(a, b, p = MOD): return modmul(a, modpow(b, p-2, p)) class UnionFindTree: """union find tree class TODO: fix this description... how to use (example): >> uf = UnionFindTree(N) >> if uf.find_root(a) == uf.find_root(b): >> do something >> else: >> do something >> uf.unite(a, b) """ def __init__(self, N): self.root = [-1] * (N+1) self.rank = [0] * (N+1) self.connected_num = [1] * (N+1) def find_root(self,x): root = self.root while root[x] != -1: x = root[x] return x def unite(self,x,y): root = self.root rank = self.rank connected_num = self.connected_num find_root = self.find_root rx = find_root(x) ry = find_root(y) if rx != ry: if rank[rx] < rank[ry]: root[rx] = ry rx,ry = ry,rx else: if rank[rx] == rank[ry]: rank[rx] += 1 root[ry] = rx connected_num[rx] += connected_num[ry] # ************ Graph ************ # Graph: https://en.wikipedia.org/wiki/Directed_graph # 最短経路問題: https://ja.wikipedia.org/wiki/%E6%9C%80%E7%9F%AD%E7%B5%8C%E8%B7%AF%E5%95%8F%E9%A1%8C # Bellman-Ford: O(|V||E|). Use this if there exists an edge with negative length in the graph # After N steps, the shortest path has converded if there doesn't exist an cycle of edges with negative # Watch out: d[N] == d[2*N] doesn't necessarily mean the graph doesn't have negative cycle # ref: https://www.youtube.com/watch?v=1Z6ofKN03_Y def BellmanFord(N, M, ABC, vertex_start, vertex_end, value_if_inf = -1, find_shortest = False): """to calculate furthest or shortest length between vertex_start and vertex_end using BellmanFord algorithm Args: N (int): number of vertices M (int): number of edges ABC (list): [(ai, bi, ci) for _ in range(N)] where i-th edge is directed from vertex ai to vertex bi and the length is ci vertex_start (int): start vertex. usually use 0. vertex_end (int): end vertex. usually use N-1. value_if_inf (int or string as you like, optional): value you want when the furthest (or shortest) distance is infinite (or -infinite). Defaults to -1. find_shortest (bool, optional): choose False to find furthest path. Defaults to False. Returns: int or string: normally int (but can be str if you set value_if_inf to str) Example: N, M, P = R() ABC = [R() for _ in range(M)] ABC = [(a-1, b-1, c-P) for a, b, c in ABC] print(BellmanFord(N, M, ABC, 0, N-1, value_if_inf = 'inf')) """ def make_reachable_list(N, M, ABC, vertex_start, vertex_end): reachable_to_direct = defaultdict(list) reachable_from_direct = defaultdict(list) reachable_from_start = [False] * N reachable_to_end = [False] * N reachable_from_start[vertex_start] = True reachable_to_end[vertex_end] = True reachable_from_both_sides = [False] * N dfs_from_start = [] dfs_to_end = [] for a, b, c in ABC: reachable_to_direct[a].append(b) reachable_from_direct[b].append(a) if a == vertex_start: dfs_from_start.append(b) reachable_from_start[b] = True if b == vertex_end: dfs_to_end.append(a) reachable_to_end[a] = True while dfs_from_start: v = dfs_from_start.pop() for i in reachable_to_direct[v]: if not reachable_from_start[i]: reachable_from_start[i] = True dfs_from_start.append(i) while dfs_to_end: v = dfs_to_end.pop() for i in reachable_from_direct[v]: if not reachable_to_end[i]: reachable_to_end[i] = True dfs_to_end.append(i) for i in range(N): reachable_from_both_sides[i] = reachable_from_start[i] and reachable_to_end[i] return reachable_from_both_sides reachable_from_both_sides = make_reachable_list(N, M, ABC, vertex_start, vertex_end) if find_shortest: dist = [INF for i in range(N)] else: dist = [-INF for i in range(N)] dist[vertex_start] = 0 for i in range(N): updated = False for a, b, c in ABC: if not reachable_from_both_sides[a]: continue elif find_shortest: update_condition = dist[a] + c < dist[b] else: update_condition = dist[a] + c > dist[b] if dist[a] != INF and update_condition: dist[b] = dist[a] + c updated = True if i == N-1: return value_if_inf if not updated: break return dist[vertex_end] # Warshall Floyd O(V**3) def warshall_floyd(number_vertex, XYD, shift_one_for_vertex=False): # ref: https://juppy.hatenablog.com/entry/2018/11/01/%E8%9F%BB%E6%9C%AC_python_%E5%85%A8%E7%82%B9%E5%AF%BE%E6%9C%80%E7%9F%AD%E7%B5%8C%E8%B7%AF%E6%B3%95%EF%BC%88%E3%83%AF%E3%83%BC%E3%82%B7%E3%83%A3%E3%83%AB%E3%83%95%E3%83%AD%E3%82%A4%E3%83%89%E6%B3%95 # number_vertex: len(vertex) # XYD: list of distance from x to y # shift_one_for_vertex: XYDの値が1~Nの時(0~N-1でない時)に調整するフラグ。 # d[i][j]: iからjへの最短距離 d = [[float("inf")]*number_vertex for i in range(number_vertex)] for x, y, dist in XYD: if shift_one_for_vertex: x = x - 1 y = y - 1 d[x][y] = dist d[y][x] = dist for i in range(number_vertex): d[i][i] = 0 # distance of same vertex is 0 for k in range(number_vertex): for i in range(number_vertex): for j in range(number_vertex): d[i][j] = min(d[i][j],d[i][k] + d[k][j]) return d """ initialize variables and set inputs # initialize variables # to initialize list, use [0] * n # to initialize two dimentional array: # ex) [[0] * N for _ in range(N)] # ex2) dp = [[0] * (N+1) for _ in range(W*2)] # set inputs # put inputs between specific values (almost as quickly) # ex) S = [-INF] + [int(r()) for _ in range(A)] + [INF] # open(0).read() is sometimes useful: # ex) n, m, *x = map(int, open(0).read().split()) # min(x[::2]) - max(x[1::2]) # ex2) *x, = map(int, open(0).read().split()) # don't forget to add comma after *x if only one variable is used # preprocessing # transpose = [x for x in zip(*data)] # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [(1, 4, 7), (2, 5, 8), (3, 6, 9)] # flat = [flatten for inner in data for flatten in inner] # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [1, 2, 3, 4, 5, 6, 7, 8, 9] # calculate and output # output pattern # ex1) print(*l) => when l = [2, 5, 6], printed 2 5 6 """ # functions to read input r = lambda: sys.stdin.readline().strip() r_int = lambda: int(r()) r_float = lambda: float(r()) R = lambda: list(map(int, r().split())) R_str = lambda: r().split() R_map = lambda: map(int, r().split()) R_float = lambda: list(map(float, r().split())) R_tuple = lambda: tuple(map(int, r().split())) """ how to treat input # single int: int(r()) # single string: r() # single float: float(r()) # line int: R() # line string: r().split() # line (str, int, int): [j if i == 0 else int(j) for i, j in enumerate(r().split())] # lines int: [R() for _ in range(n)] """ # for test if sample_file: sys.stdin = open(sample_file) # ---------------------------------- # main #%% N = r_int() S = r() Q = r_int() Que = [R_str() for _ in range(Q)] # 小文字をカウントしたリストを持つセグ木で行けそう。 class SegTree: """ ref: https://qiita.com/takayg1/items/c811bd07c21923d7ec69 init(init_val, ide_ele): 配列init_valで初期化 O(N) update(k, x): k番目の値をxに更新 O(logN) query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN) """ def __init__(self, init_val, segfunc, ide_ele): """ init_val: 配列の初期値 segfunc: 区間にしたい操作 ide_ele: 単位元 n: 要素数 num: n以上の最小の2のべき乗 tree: セグメント木(1-index) """ n = len(init_val) self.segfunc = segfunc self.ide_ele = ide_ele self.num = 1 << (n - 1).bit_length() self.tree = [ide_ele] * 2 * self.num # 配列の値を葉にセット for i in range(n): self.tree[self.num + i] = init_val[i] # 構築していく for i in range(self.num - 1, 0, -1): self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1]) def update(self, k, x): """ k番目の値をxに更新 k: index(0-index) x: update value """ k += self.num self.tree[k] = x while k > 1: self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1]) k >>= 1 def query(self, l, r): """ [l, r)のsegfuncしたものを得る l: index(0-index) r: index(0-index) """ res = self.ide_ele l += self.num r += self.num while l < r: if l & 1: res = self.segfunc(res, self.tree[l]) l += 1 if r & 1: res = self.segfunc(res, self.tree[r - 1]) l >>= 1 r >>= 1 return res # a = [14, 5, 9, 13, 7, 12, 11, 1, 7, 8] def segfunc(x, y): return x | y def count_ones_by_bitmask(num): count = 0 while num: count += num & 1 num >>= 1 return count S_int = [2**(ord(i)-97) for i in S] ide_ele = 0 seg = SegTree(S_int, segfunc, ide_ele) for i, a, b in Que: if i == '1': seg.update(int(a), 2**(ord(b)-97)) else: print(count_ones_by_bitmask(seg.query(int(a)-1, int(b)))) #%% # end of main # ---------------------------------- """memo: how to use defaultdict of list # initialize Dic = defaultdict(list) # append / extend Dic[x].append(y) # three methods for loop: keys(), values(), items() for k, v in Dic.items(): """ """memo: how to solve binary problems # to make binary digits text >>> a = 5 >>> bin_str_a = format(a, '#06b') >>> print(bin_str_a) 0b0101 # first 2 strings (='0b') indicates it is binary """ """memo: how to solve the problem creating simple test/answer greed simple dp graph """ if __name__ == '__main__': main()
def main(sample_file = ''): """ convenient functions # for i, a in enumerate(iterable) # q, mod = divmod(a, b) # divmod(x, y) returns the tuple (x//y, x%y) # Higher-order function: reduce(operator.mul, xyz_count, 1) # manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f """ """convenient decorator # @functools.lru_cache(): # to facilitate use of recursive function # ex: # from functools import lru_cache # import sys # sys.setrecursionlimit(10**9) # @lru_cache(maxsize=None) # def fib(n): # if n < 2: # return n # return fib(n-1) + fib(n-2) # print(fib(1000)) """ # import numpy as np import sys sys.setrecursionlimit(10**7) from itertools import accumulate, combinations, permutations, product # https://docs.python.org/ja/3/library/itertools.html # accumulate() returns iterator! to get list: list(accumulate()) from math import factorial, ceil, floor, sqrt def factorize(n): """return the factors of the Arg and count of each factor Args: n (long): number to be resolved into factors Returns: list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)] """ fct = [] # prime factor b, e = 2, 0 # base, exponent while b * b <= n: while n % b == 0: n = n // b e = e + 1 if e > 0: fct.append((b, e)) b, e = b + 1, 0 if n > 1: fct.append((n, 1)) return fct def combinations_count(n, r): """Return the number of selecting r pieces of items from n kinds of items. Args: n (long): number r (long): number Raises: Exception: not defined when n or r is negative Returns: long: number """ # TODO: How should I do when n - r is negative? if n < 0 or r < 0: raise Exception('combinations_count(n, r) not defined when n or r is negative') if n - r < r: r = n - r if r < 0: return 0 if r == 0: return 1 if r == 1: return n numerator = [n - r + k + 1 for k in range(r)] denominator = [k + 1 for k in range(r)] for p in range(2,r+1): pivot = denominator[p - 1] if pivot > 1: offset = (n - r) % p for k in range(p-1,r,p): numerator[k - offset] /= pivot denominator[k] /= pivot result = 1 for k in range(r): if numerator[k] > 1: result *= int(numerator[k]) return result def combinations_with_replacement_count(n, r): """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once. Args: n (long): number r (long): number Raises: Exception: not defined when n or r is negative Returns: long: number """ if n < 0 or r < 0: raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative') elif n == 0: return 1 else: return combinations_count(n + r - 1, r) from bisect import bisect_left, bisect_right from collections import deque, Counter, defaultdict # https://docs.python.org/ja/3/library/collections.html#collections.deque from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest # https://docs.python.org/ja/3/library/heapq.html from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html import operator from operator import itemgetter #sort # ex1: List.sort(key=itemgetter(1)) # ex2: sorted(tuples, key=itemgetter(1,2)) from functools import reduce, lru_cache def chmin(x, y): """change minimum if x > y, x = y and return (x, True). convenient when solving problems of dp[i] Args: x (long): current minimum value y (long): potential minimum value Returns: (x, bool): (x, True) when updated, else (x, False) """ if x > y: x = y return (x, True) else: return (x, False) def chmax(x, y): """change maximum if x < y, x = y and return (x, True). convenient when solving problems of dp[i] Args: x (long): current maximum value y (long): potential maximum value Returns: (x, bool): (x, True) when updated, else (x, False) """ if x < y: x = y return (x, True) else: return (x, False) from math import gcd # Deprecated since version 3.5: Use math.gcd() instead. def gcds(numbers): return reduce(gcd, numbers) def lcm(x, y): return (x * y) // gcd(x, y) def lcms(numbers): return reduce(lcm, numbers, 1) def make_divisors(n, reversed=False): """create list of divisors Args: number (int): number from which list of divisors is created reversed (bool, optional): ascending order if False. Defaults to False. Returns: list: list of divisors """ divisors = set() for i in range(1, int(n**0.5)+1): if n % i == 0: divisors.add(i) divisors.add(n//i) return sorted(list(divisors),reverse=reversed) # first create factorial_list # fac_list = mod_factorial_list(n) INF = 10 ** 18 MOD = 10 ** 9 + 7 AtoZ = list('abcdefghijklmnopqrsruvwxyz') # 26 modpow = lambda a, n, p = MOD: pow(a, n, p) # Recursive function in python is slow! def modinv(a, p = MOD): # evaluate reciprocal using Fermat's little theorem: # a**(p-1) is identical to 1 (mod p) when a and p is coprime return modpow(a, p-2, p) def modinv_list(n, p = MOD): if n <= 1: return [0,1][:n+1] else: inv_t = [0,1] for i in range(2, n+1): inv_t += [inv_t[p % i] * (p - int(p / i)) % p] return inv_t def modfactorial_list(n, p = MOD): if n == 0: return [1] else: l = [0] * (n+1) tmp = 1 for i in range(1, n+1): tmp = tmp * i % p l[i] = tmp return l def modcomb(n, k, fac_list = [], p = MOD): # fac_list = modfactorial_list(100) # print(modcomb(100, 5, modfactorial_list(100))) from math import factorial if n < 0 or k < 0 or n < k: return 0 if n == 0 or k == 0: return 1 if len(fac_list) <= n: a = factorial(n) % p b = factorial(k) % p c = factorial(n-k) % p else: a = fac_list[n] b = fac_list[k] c = fac_list[n-k] return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p def modadd(a, b, p = MOD): return (a + b) % MOD def modsub(a, b, p = MOD): return (a - b) % p def modmul(a, b, p = MOD): return ((a % p) * (b % p)) % p def moddiv(a, b, p = MOD): return modmul(a, modpow(b, p-2, p)) class UnionFindTree: """union find tree class TODO: fix this description... how to use (example): >> uf = UnionFindTree(N) >> if uf.find_root(a) == uf.find_root(b): >> do something >> else: >> do something >> uf.unite(a, b) """ def __init__(self, N): self.root = [-1] * (N+1) self.rank = [0] * (N+1) self.connected_num = [1] * (N+1) def find_root(self,x): root = self.root while root[x] != -1: x = root[x] return x def unite(self,x,y): root = self.root rank = self.rank connected_num = self.connected_num find_root = self.find_root rx = find_root(x) ry = find_root(y) if rx != ry: if rank[rx] < rank[ry]: root[rx] = ry rx,ry = ry,rx else: if rank[rx] == rank[ry]: rank[rx] += 1 root[ry] = rx connected_num[rx] += connected_num[ry] # ************ Graph ************ # Graph: https://en.wikipedia.org/wiki/Directed_graph # 最短経路問題: https://ja.wikipedia.org/wiki/%E6%9C%80%E7%9F%AD%E7%B5%8C%E8%B7%AF%E5%95%8F%E9%A1%8C # Bellman-Ford: O(|V||E|). Use this if there exists an edge with negative length in the graph # After N steps, the shortest path has converded if there doesn't exist an cycle of edges with negative # Watch out: d[N] == d[2*N] doesn't necessarily mean the graph doesn't have negative cycle # ref: https://www.youtube.com/watch?v=1Z6ofKN03_Y def BellmanFord(N, M, ABC, vertex_start, vertex_end, value_if_inf = -1, find_shortest = False): """to calculate furthest or shortest length between vertex_start and vertex_end using BellmanFord algorithm Args: N (int): number of vertices M (int): number of edges ABC (list): [(ai, bi, ci) for _ in range(N)] where i-th edge is directed from vertex ai to vertex bi and the length is ci vertex_start (int): start vertex. usually use 0. vertex_end (int): end vertex. usually use N-1. value_if_inf (int or string as you like, optional): value you want when the furthest (or shortest) distance is infinite (or -infinite). Defaults to -1. find_shortest (bool, optional): choose False to find furthest path. Defaults to False. Returns: int or string: normally int (but can be str if you set value_if_inf to str) Example: N, M, P = R() ABC = [R() for _ in range(M)] ABC = [(a-1, b-1, c-P) for a, b, c in ABC] print(BellmanFord(N, M, ABC, 0, N-1, value_if_inf = 'inf')) """ def make_reachable_list(N, M, ABC, vertex_start, vertex_end): reachable_to_direct = defaultdict(list) reachable_from_direct = defaultdict(list) reachable_from_start = [False] * N reachable_to_end = [False] * N reachable_from_start[vertex_start] = True reachable_to_end[vertex_end] = True reachable_from_both_sides = [False] * N dfs_from_start = [] dfs_to_end = [] for a, b, c in ABC: reachable_to_direct[a].append(b) reachable_from_direct[b].append(a) if a == vertex_start: dfs_from_start.append(b) reachable_from_start[b] = True if b == vertex_end: dfs_to_end.append(a) reachable_to_end[a] = True while dfs_from_start: v = dfs_from_start.pop() for i in reachable_to_direct[v]: if not reachable_from_start[i]: reachable_from_start[i] = True dfs_from_start.append(i) while dfs_to_end: v = dfs_to_end.pop() for i in reachable_from_direct[v]: if not reachable_to_end[i]: reachable_to_end[i] = True dfs_to_end.append(i) for i in range(N): reachable_from_both_sides[i] = reachable_from_start[i] and reachable_to_end[i] return reachable_from_both_sides reachable_from_both_sides = make_reachable_list(N, M, ABC, vertex_start, vertex_end) if find_shortest: dist = [INF for i in range(N)] else: dist = [-INF for i in range(N)] dist[vertex_start] = 0 for i in range(N): updated = False for a, b, c in ABC: if not reachable_from_both_sides[a]: continue elif find_shortest: update_condition = dist[a] + c < dist[b] else: update_condition = dist[a] + c > dist[b] if dist[a] != INF and update_condition: dist[b] = dist[a] + c updated = True if i == N-1: return value_if_inf if not updated: break return dist[vertex_end] # Warshall Floyd O(V**3) def warshall_floyd(number_vertex, XYD, shift_one_for_vertex=False): # ref: https://juppy.hatenablog.com/entry/2018/11/01/%E8%9F%BB%E6%9C%AC_python_%E5%85%A8%E7%82%B9%E5%AF%BE%E6%9C%80%E7%9F%AD%E7%B5%8C%E8%B7%AF%E6%B3%95%EF%BC%88%E3%83%AF%E3%83%BC%E3%82%B7%E3%83%A3%E3%83%AB%E3%83%95%E3%83%AD%E3%82%A4%E3%83%89%E6%B3%95 # number_vertex: len(vertex) # XYD: list of distance from x to y # shift_one_for_vertex: XYDの値が1~Nの時(0~N-1でない時)に調整するフラグ。 # d[i][j]: iからjへの最短距離 d = [[float("inf")]*number_vertex for i in range(number_vertex)] for x, y, dist in XYD: if shift_one_for_vertex: x = x - 1 y = y - 1 d[x][y] = dist d[y][x] = dist for i in range(number_vertex): d[i][i] = 0 # distance of same vertex is 0 for k in range(number_vertex): for i in range(number_vertex): for j in range(number_vertex): d[i][j] = min(d[i][j],d[i][k] + d[k][j]) return d """ initialize variables and set inputs # initialize variables # to initialize list, use [0] * n # to initialize two dimentional array: # ex) [[0] * N for _ in range(N)] # ex2) dp = [[0] * (N+1) for _ in range(W*2)] # set inputs # put inputs between specific values (almost as quickly) # ex) S = [-INF] + [int(r()) for _ in range(A)] + [INF] # open(0).read() is sometimes useful: # ex) n, m, *x = map(int, open(0).read().split()) # min(x[::2]) - max(x[1::2]) # ex2) *x, = map(int, open(0).read().split()) # don't forget to add comma after *x if only one variable is used # preprocessing # transpose = [x for x in zip(*data)] # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [(1, 4, 7), (2, 5, 8), (3, 6, 9)] # flat = [flatten for inner in data for flatten in inner] # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [1, 2, 3, 4, 5, 6, 7, 8, 9] # calculate and output # output pattern # ex1) print(*l) => when l = [2, 5, 6], printed 2 5 6 """ # functions to read input r = lambda: sys.stdin.readline().strip() r_int = lambda: int(r()) r_float = lambda: float(r()) R = lambda: list(map(int, r().split())) R_str = lambda: r().split() R_map = lambda: map(int, r().split()) R_float = lambda: list(map(float, r().split())) R_tuple = lambda: tuple(map(int, r().split())) """ how to treat input # single int: int(r()) # single string: r() # single float: float(r()) # line int: R() # line string: r().split() # line (str, int, int): [j if i == 0 else int(j) for i, j in enumerate(r().split())] # lines int: [R() for _ in range(n)] """ # for test if sample_file: sys.stdin = open(sample_file) # ---------------------------------- # main #%% N = r_int() S = r() Q = r_int() Que = [R_str() for _ in range(Q)] # 小文字をカウントしたリストを持つセグ木で行けそう。 class SegTree: """ ref: https://qiita.com/takayg1/items/c811bd07c21923d7ec69 init(init_val, ide_ele): 配列init_valで初期化 O(N) update(k, x): k番目の値をxに更新 O(logN) query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN) """ def __init__(self, init_val, segfunc, ide_ele): """ init_val: 配列の初期値 segfunc: 区間にしたい操作 ide_ele: 単位元 n: 要素数 num: n以上の最小の2のべき乗 tree: セグメント木(1-index) """ n = len(init_val) self.segfunc = segfunc self.ide_ele = ide_ele self.num = 1 << (n - 1).bit_length() self.tree = [ide_ele] * 2 * self.num # 配列の値を葉にセット for i in range(n): self.tree[self.num + i] = init_val[i] # 構築していく for i in range(self.num - 1, 0, -1): self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1]) def update(self, k, x): """ k番目の値をxに更新 k: index(0-index) x: update value """ k += self.num self.tree[k] = x while k > 1: self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1]) k >>= 1 def query(self, l, r): """ [l, r)のsegfuncしたものを得る l: index(0-index) r: index(0-index) """ res = self.ide_ele l += self.num r += self.num while l < r: if l & 1: res = self.segfunc(res, self.tree[l]) l += 1 if r & 1: res = self.segfunc(res, self.tree[r - 1]) l >>= 1 r >>= 1 return res # a = [14, 5, 9, 13, 7, 12, 11, 1, 7, 8] def segfunc(x, y): return x | y def count_ones_by_bitmask(num): count = 0 while num: count += num & 1 num >>= 1 return count S_int = [2**(ord(i)-97) for i in S] ide_ele = 0 seg = SegTree(S_int, segfunc, ide_ele) for i, a, b in Que: if i == '1': seg.update(int(a)-1, 2**(ord(b)-97)) else: print(count_ones_by_bitmask(seg.query(int(a)-1, int(b)))) #%% # end of main # ---------------------------------- """memo: how to use defaultdict of list # initialize Dic = defaultdict(list) # append / extend Dic[x].append(y) # three methods for loop: keys(), values(), items() for k, v in Dic.items(): """ """memo: how to solve binary problems # to make binary digits text >>> a = 5 >>> bin_str_a = format(a, '#06b') >>> print(bin_str_a) 0b0101 # first 2 strings (='0b') indicates it is binary """ """memo: how to solve the problem creating simple test/answer greed simple dp graph """ if __name__ == '__main__': main()
[ "expression.operation.binary.add" ]
556,980
556,981
u988402778
python
p02763
import sys read = sys.stdin.readline def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_matrix(H): ''' H is number of rows ''' return [list(map(int, read().split())) for _ in range(H)] def read_map(H): ''' H is number of rows 文字列で与えられた盤面を読み取る用 ''' return [read()[:-1] for _ in range(H)] def read_tuple(H): ''' H is number of rows ''' ret = [] for _ in range(H): ret.append(tuple(map(int, read().split()))) return ret def read_col(H, n_cols): ''' H is number of rows n_cols is number of cols A列、B列が与えられるようなとき ''' ret = [[] for _ in range(n_cols)] for _ in range(H): tmp = list(map(int, read().split())) for col in range(n_cols): ret[col].append(tmp[col]) return ret def index(a, x): 'Locate the leftmost value exactly equal to x' i = bisect_left(a, x) if i != len(a) and a[i] == x: return i raise ValueError # ポイント # 文字列update # 文字種の高速取得 # 文字種の高速取得について考えてみる # 文字のidxを取得しておいて二分探索することで高速に取得することが可能 N = read_a_int() S = read()[:-1] from collections import defaultdict from bisect import bisect_left, bisect_right, insort_left char_idxs = defaultdict(lambda: []) for i, s in enumerate(S): char_idxs[s].append(i) def get_syurui(char_idxs, l, r): ret = 0 for v in char_idxs.values(): l_idx = bisect_left(v, l) r_idx = bisect_right(v, r) # print(v,l_idx,r_idx) if r_idx - l_idx > 0: ret += 1 return ret Q = read_a_int() for q in range(Q): com, a, b = read().split() if int(com) == 2: a, b = int(a) - 1, int(b) - 1 print(get_syurui(char_idxs, a, b)) else: i = int(a) - 1 if S[i] == b: continue # i文字目を消す tmp = char_idxs[S[i]] # S[i]を更新しなきゃ del char_idxs[S[i]][index(tmp, i)] # cのidxに挿入し直す insort_left(char_idxs[b], i) # S[i]を更新しなきゃ S[i] = b
import sys read = sys.stdin.readline def read_ints(): return list(map(int, read().split())) def read_a_int(): return int(read()) def read_matrix(H): ''' H is number of rows ''' return [list(map(int, read().split())) for _ in range(H)] def read_map(H): ''' H is number of rows 文字列で与えられた盤面を読み取る用 ''' return [read()[:-1] for _ in range(H)] def read_tuple(H): ''' H is number of rows ''' ret = [] for _ in range(H): ret.append(tuple(map(int, read().split()))) return ret def read_col(H, n_cols): ''' H is number of rows n_cols is number of cols A列、B列が与えられるようなとき ''' ret = [[] for _ in range(n_cols)] for _ in range(H): tmp = list(map(int, read().split())) for col in range(n_cols): ret[col].append(tmp[col]) return ret def index(a, x): 'Locate the leftmost value exactly equal to x' i = bisect_left(a, x) if i != len(a) and a[i] == x: return i raise ValueError # ポイント # 文字列update # 文字種の高速取得 # 文字種の高速取得について考えてみる # 文字のidxを取得しておいて二分探索することで高速に取得することが可能 N = read_a_int() S = list(read()[:-1]) from collections import defaultdict from bisect import bisect_left, bisect_right, insort_left char_idxs = defaultdict(lambda: []) for i, s in enumerate(S): char_idxs[s].append(i) def get_syurui(char_idxs, l, r): ret = 0 for v in char_idxs.values(): l_idx = bisect_left(v, l) r_idx = bisect_right(v, r) # print(v,l_idx,r_idx) if r_idx - l_idx > 0: ret += 1 return ret Q = read_a_int() for q in range(Q): com, a, b = read().split() if int(com) == 2: a, b = int(a) - 1, int(b) - 1 print(get_syurui(char_idxs, a, b)) else: i = int(a) - 1 if S[i] == b: continue # i文字目を消す tmp = char_idxs[S[i]] # S[i]を更新しなきゃ del char_idxs[S[i]][index(tmp, i)] # cのidxに挿入し直す insort_left(char_idxs[b], i) # S[i]を更新しなきゃ S[i] = b
[ "call.add", "call.arguments.change" ]
557,026
557,027
u179169725
python
p02763
class SegmentTree(): """一点更新、区間取得クエリをそれぞれO(logN)で答えるデータ構造を構築する。 built(array) := arrayを初期値とするセグメント木を構築する O(N)。 update(i, val) := i番目の要素をvalに変更する。 get_val(l, r) := 区間[l, r)に対する二項演算の畳み込みの結果を返す。 """ def __init__(self, n, op, e): """要素数、二項演算、単位元を引数として渡す 例) 区間最小値 SegmentTree(n, min, 10 ** 18) 区間和 SegmentTree(n, lambda a, b : a + b, 0) """ self.n = n self.op = op self.e = e self.size = 2 ** ((n - 1).bit_length()) self.node = [self.e] * (2 * self.size) def build(self, array): """arrayを初期値とするセグメント木を構築する""" for i in range(self.n): self.node[self.size + i] = array[i] for i in range(self.size - 1, 0, -1): self.node[i] = self.op(self.node[i << 1], self.node[(i << 1) + 1]) def update(self, i, val): """i番目の要素をvalに変更する""" i += self.size self.node[i] = val while i > 1: i >>= 1 self.node[i] = self.op(self.node[i << 1], self.node[(i << 1) + 1]) def get_val(self, l, r): """[l, r)の畳み込みの結果を返す""" l, r = l + self.size, r + self.size res_l, res_r = self.e, self.e while l < r: if l & 1: res_l = self.op(res_l, self.node[l]) l += 1 if r & 1: r -= 1 res_r = self.op(self.node[r], res_r) l, r = l >> 1, r >> 1 return self.op(res_l, res_r) ALPH = "abcdefghijklmnopqrstuvwxyz" to_int = {char: i for i, char in enumerate(ALPH)} n = int(input()) s = input() q = int(input()) query = [list(input().split()) for i in range(q)] init = [0] * n for i, char in enumerate(s): init[i] = 1 << to_int[char] op = lambda a, b: a | b st = SegmentTree(n, op, 0) st.build(init) for i in range(q): if query[i][0] == "1": _, ind, char = query[i] ind = int(ind) st.update(ind, 1 << to_int[char]) else: _, l, r = query[i] l, r = int(l) - 1, int(r) print(bin(st.get_val(l, r)).count("1"))
class SegmentTree(): """一点更新、区間取得クエリをそれぞれO(logN)で答えるデータ構造を構築する。 built(array) := arrayを初期値とするセグメント木を構築する O(N)。 update(i, val) := i番目の要素をvalに変更する。 get_val(l, r) := 区間[l, r)に対する二項演算の畳み込みの結果を返す。 """ def __init__(self, n, op, e): """要素数、二項演算、単位元を引数として渡す 例) 区間最小値 SegmentTree(n, min, 10 ** 18) 区間和 SegmentTree(n, lambda a, b : a + b, 0) """ self.n = n self.op = op self.e = e self.size = 2 ** ((n - 1).bit_length()) self.node = [self.e] * (2 * self.size) def build(self, array): """arrayを初期値とするセグメント木を構築する""" for i in range(self.n): self.node[self.size + i] = array[i] for i in range(self.size - 1, 0, -1): self.node[i] = self.op(self.node[i << 1], self.node[(i << 1) + 1]) def update(self, i, val): """i番目の要素をvalに変更する""" i += self.size self.node[i] = val while i > 1: i >>= 1 self.node[i] = self.op(self.node[i << 1], self.node[(i << 1) + 1]) def get_val(self, l, r): """[l, r)の畳み込みの結果を返す""" l, r = l + self.size, r + self.size res_l, res_r = self.e, self.e while l < r: if l & 1: res_l = self.op(res_l, self.node[l]) l += 1 if r & 1: r -= 1 res_r = self.op(self.node[r], res_r) l, r = l >> 1, r >> 1 return self.op(res_l, res_r) ALPH = "abcdefghijklmnopqrstuvwxyz" to_int = {char: i for i, char in enumerate(ALPH)} n = int(input()) s = input() q = int(input()) query = [list(input().split()) for i in range(q)] init = [0] * n for i, char in enumerate(s): init[i] = 1 << to_int[char] op = lambda a, b: a | b st = SegmentTree(n, op, 0) st.build(init) for i in range(q): if query[i][0] == "1": _, ind, char = query[i] ind = int(ind) - 1 st.update(ind, 1 << to_int[char]) else: _, l, r = query[i] l, r = int(l) - 1, int(r) print(bin(st.get_val(l, r)).count("1"))
[ "assignment.change" ]
557,043
557,044
u794173881
python
p02763
import sys input = sys.stdin.readline def segfunc(x,y): return x | y def init(init_val): #set_val for i in range(n): seg[i+num-1]=init_val[i] #built for i in range(num-2,-1,-1) : seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) def update(k,x): k += num-1 seg[k] = x while k: k = (k-1)//2 seg[k] = segfunc(seg[k*2+1],seg[k*2+2]) def query(p,q): if q<=p: return ide_ele p += num-1 q += num-2 res=ide_ele while q-p>1: if p&1 == 0: res = segfunc(res,seg[p]) if q&1 == 1: res = segfunc(res,seg[q]) q -= 1 p = p//2 q = (q-1)//2 if p == q: res = segfunc(res,seg[p]) else: res = segfunc(segfunc(res,seg[p]),seg[q]) return res n = int(input()) s = input() q = int(input()) li = [] for i in range(n): li.append(1 << ord(s[i]) - ord('a')) #####単位元###### ide_ele = 0 #num:n以上の最小の2のべき乗 num =2**(n-1).bit_length() seg=[ide_ele]*2*num init(li) for _ in range(q): q1 = list(input().split()) if q1[0] == '1': update(int(q1[1]), 1 << ord(q1[2]) - ord('a')) else: l,r = int(q1[1]), int(q1[2]) print(bin(query(l-1,r)).count('1'))
import sys input = sys.stdin.readline def segfunc(x,y): return x | y def init(init_val): #set_val for i in range(n): seg[i+num-1]=init_val[i] #built for i in range(num-2,-1,-1) : seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) def update(k,x): k += num-1 seg[k] = x while k: k = (k-1)//2 seg[k] = segfunc(seg[k*2+1],seg[k*2+2]) def query(p,q): if q<=p: return ide_ele p += num-1 q += num-2 res=ide_ele while q-p>1: if p&1 == 0: res = segfunc(res,seg[p]) if q&1 == 1: res = segfunc(res,seg[q]) q -= 1 p = p//2 q = (q-1)//2 if p == q: res = segfunc(res,seg[p]) else: res = segfunc(segfunc(res,seg[p]),seg[q]) return res n = int(input()) s = input() q = int(input()) li = [] for i in range(n): li.append(1 << ord(s[i]) - ord('a')) #####単位元###### ide_ele = 0 #num:n以上の最小の2のべき乗 num =2**(n-1).bit_length() seg=[ide_ele]*2*num init(li) for _ in range(q): q1 = list(input().split()) if q1[0] == '1': update(int(q1[1]) - 1, 1 << ord(q1[2]) - ord('a')) else: l,r = int(q1[1]), int(q1[2]) print(bin(query(l-1,r)).count('1'))
[ "expression.operation.binary.add" ]
557,047
557,048
u623231048
python
p02765
A = input().split( ) N = int(A[0]) R = int(A[1]) if N >= 10: print(R + N) else : print(100*(10-N))
A = input().split( ) N = int(A[0]) R = int(A[1]) if N >= 10: print(R) else : print(100*(10-N) + R)
[ "expression.operation.binary.remove" ]
557,064
557,065
u288430479
python
p02765
A = input().split( ) N = int(A[0]) R = int(A[1]) if N >= 10: print(R) else : print(100*(10-N))
A = input().split( ) N = int(A[0]) R = int(A[1]) if N >= 10: print(R) else : print(100*(10-N) + R)
[ "expression.operation.binary.add" ]
557,066
557,065
u288430479
python
p02765
A = input().split( ) N = int(A[0]) R = int(A[1]) if N >= 10: print(R + N) else : print(100*(10-N))
A = input().split( ) N = int(A[0]) R = int(A[1]) if N >= 10: print(R) else : print(100*(10-N) + R)
[ "expression.operation.binary.remove" ]
557,064
557,067
u288430479
python
p02765
A = input().split( ) N = int(A[0]) R = int(A[1]) if N >= 10: print(R) else : print(100*(10-N))
A = input().split( ) N = int(A[0]) R = int(A[1]) if N >= 10: print(R) else : print(100*(10-N) + R)
[ "expression.operation.binary.add" ]
557,066
557,067
u288430479
python
p02765
a, b = map(int, input().split) print(b + max(0, 10 -a))
a, b = map(int, input().split()) print(b + (max(0, 10 -a) * 100) )
[ "call.add", "call.arguments.change" ]
557,069
557,070
u832871520
python
p02765
N,R = map(int, input().split()) if N < 10: R = R - (100 * (10 - N)) if R < 0: R = 0 print(R)
N,R = map(int, input().split()) if N < 10: R = R + (100 * (10 - N)) if R < 0: R = 0 print(R)
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
557,079
557,080
u482157295
python
p02765
i = list(map(int, input().split())) N = i[0] R = i[1] result = R if N >= 10 else R - 100 * (10 - N) print(result)
i = list(map(int, input().split())) N = i[0] R = i[1] result = R if N >= 10 else R + 100 * (10 - N) print(result)
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
557,081
557,082
u504194367
python
p02765
i = list(map(int, input().split())) N = i[0] R = i[1] result = R if N >= 10 else 100 * (10 - N) print(result)
i = list(map(int, input().split())) N = i[0] R = i[1] result = R if N >= 10 else R + 100 * (10 - N) print(result)
[ "assignment.change" ]
557,083
557,082
u504194367
python
p02765
def resolve(): N, R = map(int, input().split()) if N < 10: print(R) else: R = R + 100 * (10 - N) print(R) if __name__ == "__main__": resolve()
def resolve(): N, R = map(int, input().split()) if N >= 10: print(R) else: R = R + 100 * (10 - N) print(R) if __name__ == "__main__": resolve()
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
557,111
557,112
u644546699
python
p02765
def resolve(): N, R = map(int, input().split()) if N < 10: print(R) else: R = R - 100 * (10 - N) print(R) if __name__ == "__main__": resolve()
def resolve(): N, R = map(int, input().split()) if N >= 10: print(R) else: R = R + 100 * (10 - N) print(R) if __name__ == "__main__": resolve()
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
557,114
557,112
u644546699
python
p02765
def resolve(): N, R = map(int, input().split()) if N >= 10: print(R) else: R = R - 100 * (10 - N) print(R) if __name__ == "__main__": resolve()
def resolve(): N, R = map(int, input().split()) if N >= 10: print(R) else: R = R + 100 * (10 - N) print(R) if __name__ == "__main__": resolve()
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
557,115
557,112
u644546699
python
p02765
def resolve(): N, R = map(int, input().split()) if N >= 10: print(R) else: R = R - 100 * (10 - K) print(R) if __name__ == "__main__": resolve()
def resolve(): N, R = map(int, input().split()) if N >= 10: print(R) else: R = R + 100 * (10 - N) print(R) if __name__ == "__main__": resolve()
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change", "identifier.change" ]
557,116
557,112
u644546699
python
p02765
m,n = map(int,input().split()) if m>=10: print(n) else: print(n+(100-m))
m,n = map(int,input().split()) if m>=10: print(n) else: print(n+(100*(10-m)))
[ "call.arguments.change" ]
557,117
557,118
u089032511
python
p02765
m,n = map(int,input().split()) if m>=10: print(n) else: print(n-(100-m))
m,n = map(int,input().split()) if m>=10: print(n) else: print(n+(100*(10-m)))
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
557,119
557,118
u089032511
python
p02765
m,n = map(int,input().split()) if m>9: print(n) else: print(n+(100-m))
m,n = map(int,input().split()) if m>=10: print(n) else: print(n+(100*(10-m)))
[ "call.arguments.change" ]
557,121
557,118
u089032511
python
p02765
l = list(map(int, input().split())) N = l[0] R = l[1] if N >= 10: print(R) else: printint((R + 100(10 - N)))
l = list(map(int, input().split())) N = l[0] R = l[1] if N >= 10: print(R) elif N < 10: print((R + 100 * (10 - N)))
[ "control_flow.branch.if.condition.change", "identifier.change", "call.function.change", "io.output.change", "call.arguments.change" ]
557,124
557,125
u163874353
python
p02765
n, r = map(int, input().split()) print(r - (10 - min(n, 10)) * 100)
n, r = map(int, input().split()) print(r + (10 - min(n, 10)) * 100)
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
557,131
557,132
u975039852
python
p02765
N, R = int(input().split()) if N < 10: N = R + 100 * (10 - N) print(N) else: N = R print(N)
N, R = (int(x) for x in input().split()) if N < 10: N = R + 100 * (10 - N) print(N) else: N = R print(N)
[]
557,135
557,136
u288547705
python
p02765
n, r = map(int, input().split()) if n >= 10: print(r) else: print(r - 100 * (10 - n))
n, r = map(int, input().split()) if n >= 10: print(r) else: print(r + 100 * (10 - n))
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
557,144
557,145
u347452770
python
p02765
n, r = map(int, input().split()) if n >= 10: print(r) else: print(100 * (10 - n))
n, r = map(int, input().split()) if n >= 10: print(r) else: print(r + 100 * (10 - n))
[ "expression.operation.binary.add" ]
557,146
557,145
u347452770
python
p02765
N, R = map(int, input().split()) print(R+100*(10-min(10,K)))
N, R = map(int, input().split()) print(R+100*(10-min(10,N)))
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
557,152
557,153
u047816928
python
p02765
n,r =int(input().split()) if n < 10 : print(100 * (10 - n) + r) else: print(r)
n,r =map(int,input().split()) if n < 10 : print(100 * (10 - n) + r) else: print(r)
[ "assignment.value.change", "identifier.change", "call.function.change", "call.arguments.add" ]
557,156
557,157
u932225778
python
p02765
n,r = map(int(input(),split())) if n < 10 : print(100 * (10 - n) + r) else: print(r)
n,r =map(int,input().split()) if n < 10 : print(100 * (10 - n) + r) else: print(r)
[ "assignment.value.change", "call.arguments.change" ]
557,158
557,157
u932225778
python
p02765
a,b=map(int,input().split()) if a >=10: c=int(b) print(c) else: c=int(b-1000+100*a) print(c)
a,b=map(int,input().split()) if a >=10: c=int(b) print(c) else: c=int(b+1000-100*a) print(c)
[ "expression.operation.binary.remove" ]
557,162
557,163
u403547519
python
p02765
a,b=map(int,input().split()) print(b if a>=10 else b+100*(10-b))
a,b=map(int,input().split()) print(b if a>=10 else b+100*(10-a))
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
557,164
557,165
u123745130
python
p02765
n, r = map(int, input().split()) if n < 10: ans = r - (100 * (10 - n)) print(ans) else: print(r)
n, r = map(int, input().split()) if n < 10: ans = r + (100 * (10 - n)) print(ans) else: print(r)
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
557,174
557,175
u375172966
python
p02765
N, R = map(int, input().split(' ')) if N < 9: L = R+100*(10-N) print('{}'.format(L)) else: print('{}'.format(R))
N, R = map(int, input().split(' ')) if N < 10: L = R+100*(10-N) print('{}'.format(L)) else: print('{}'.format(R))
[ "literal.number.integer.change", "control_flow.branch.if.condition.change" ]
557,178
557,179
u670606123
python
p02765
n, r = map(int,input().split()) print(r) if n < 10: r = r + 100*(10-n) print(r)
n, r = map(int,input().split()) if n < 10: r = r + 100*(10-n) print(r)
[ "call.remove" ]
557,193
557,194
u774197297
python
p02765
N, R = map(int, input().split()) A = int(0) if N>=10: A = N else: A = 100*(10-N)+R print(A)
N, R = map(int, input().split()) A = int(0) if N>=10: A = R else: A = 100*(10-N)+R print(A)
[ "assignment.value.change", "identifier.change" ]
557,205
557,206
u507237474
python
p02765
n,r = map(int,input().split()) a = min(10,n) a = 100*(10-a) print(r-a)
n,r = map(int,input().split()) a = min(10,n) a = 100*(10-a) print(r+a)
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
557,211
557,212
u424967964
python
p02765
a = [int(i) for i in a.split()] # N:参加回数 R:表示レーティング N = a[0] R = a[1] # X:内部レーティング #R = X - 100 * (10 - N) if N >= 10: print(R) else: print(R + 100 * (10 - N))
a = [int(i) for i in input().split()] # N:参加回数 R:表示レーティング N = a[0] R = a[1] # X:内部レーティング #R = X - 100 * (10 - N) if N >= 10: print(R) else: print(R + 100 * (10 - N))
[ "assignment.value.change", "call.add" ]
557,216
557,217
u108072608
python
p02765
a = input().split() a=[int(i) for i in a] n,r=a[0],a[1] if n>=9: b=r else: b=r+1000-100*n print(b)
a = input().split() a=[int(i) for i in a] n,r=a[0],a[1] if n>=10: b=r else: b=r+1000-100*n print(b)
[ "literal.number.integer.change", "control_flow.branch.if.condition.change" ]
557,220
557,221
u548069143
python
p02765
n,r=map(int,input()); print(r+100*min(10-n,0));
n,r=map(int,input().split()); print(r+100*max(10-n,0));
[ "call.add", "misc.opposites", "identifier.change", "call.function.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
557,224
557,225
u367866606
python
p02765
N,R = input().split(" ") N = int(N) R = int(R) if(N >= 10): print(R) else: print(R-100*(10-N))
N,R = input().split(" ") N = int(N) R = int(R) if(N >= 10): print(R) else: print(R+100*(10-N))
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
557,229
557,230
u282574080
python
p02765
N, R = map(int, input().split(" ")) if N < 10: print(R + N*100) else: print(R)
N, R = map(int, input().split(" ")) if N < 10: print(R + (10-N)*100) else: print(R)
[ "call.arguments.change" ]
557,231
557,232
u111473084
python
p02765
N, R = map(int, input().split(" ")) if N < 10: print(R - N*100) else: print(R)
N, R = map(int, input().split(" ")) if N < 10: print(R + (10-N)*100) else: print(R)
[ "call.arguments.change" ]
557,233
557,232
u111473084
python
p02765
N, R = [int(x) for x in input().split(' ')] if N > 9: print(R) else: print(R - 100 * (10 - N))
N, R = [int(x) for x in input().split(' ')] if N > 9: print(R) else: print(R + 100 * (10 - N))
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
557,236
557,237
u707659359
python
p02765
N, R = [int(x) for x in input().split(' ')] if N > 9: print(R) else: print(R - 100 * (10 - K))
N, R = [int(x) for x in input().split(' ')] if N > 9: print(R) else: print(R + 100 * (10 - N))
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change", "identifier.change" ]
557,238
557,237
u707659359
python
p02765
sum,rate=map(int,input().split()) if sum>=10: print(rate) else: ans=rate-100*(10-sum) print(ans)
sum,rate=map(int,input().split()) if sum>=10: print(rate) else: ans=rate+100*(10-sum) print(ans)
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
557,263
557,264
u129961029
python
p02765
sum,rate=map(int,input().split()) if sum>=10: print(rate) else: ans=rate-(100*(10-sum)) print(ans)
sum,rate=map(int,input().split()) if sum>=10: print(rate) else: ans=rate+100*(10-sum) print(ans)
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
557,265
557,264
u129961029
python
p02765
n, r = int(input().split()) if n>=10: inner_rate = r else: inner_rate = r + 100*(10-n) print(str(inner_rate))
n, r = map(int, input().split()) if n>=10: inner_rate = r else: inner_rate = r + 100*(10-n) print(str(inner_rate))
[ "assignment.value.change", "identifier.change", "call.function.change", "call.arguments.add" ]
557,270
557,271
u861109991
python
p02765
l=[int(x) for x in input().split()] N=l[0] R=l[1] ans = 0 if N >= 10: ans = R print(ans) else: ans = R + 100*(10-k) print(ans)
l=[int(x) for x in input().split()] N=l[0] R=l[1] if N >= 10: ans = R print(ans) else: ans = R + 100*(10-N) print(ans)
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
557,277
557,276
u763025768
python
p02765
l=[int(x) for x in input().split()] N=l[0] R=l[1] ans = 0 if N <= 10: ans = R print(ans) else: ans = R + 100*(10-k) print(ans)
l=[int(x) for x in input().split()] N=l[0] R=l[1] if N >= 10: ans = R print(ans) else: ans = R + 100*(10-N) print(ans)
[ "misc.opposites", "expression.operator.compare.change", "control_flow.branch.if.condition.change", "assignment.value.change", "identifier.change", "expression.operation.binary.change" ]
557,278
557,276
u763025768
python
p02765
[n, r] = map(int, input().rstrip().split(' ')) if n > 10: print(r) else: print(r - 100 * (10 - n))
[n, r] = map(int, input().rstrip().split(' ')) if n > 10: print(r) else: print(r + 100 * (10 - n))
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
557,279
557,280
u293838812
python
p02765
def main(): n, r = map(int,input().split()) if n > 9: print(r) else: print(n + 100 * (10 - n)) main()
def main(): n, r = map(int,input().split()) if n > 9: print(r) else: print(r + 100 * (10 - n)) main()
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
557,289
557,290
u749224760
python
p02765
x,y = map(int,input().split()) if x<10: r=y+100(10-x) else: r=y print(r)
x,y = map(int,input().split()) if x<11: r=y+100*(10-x) else: r=y print(r)
[ "literal.number.integer.change", "control_flow.branch.if.condition.change" ]
557,306
557,307
u246492017
python
p02765
x,y = map(int,input().split()) if x<11: r=y+100(10-x) else: r=y print(r)
x,y = map(int,input().split()) if x<11: r=y+100*(10-x) else: r=y print(r)
[]
557,308
557,307
u246492017
python
p02765
x,y = map(int,input().split()) if x<11: r=y-100(10-x) else: r=y print(r)
x,y = map(int,input().split()) if x<11: r=y+100*(10-x) else: r=y print(r)
[ "misc.opposites", "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
557,309
557,307
u246492017
python
p02765
n, r = map(lambda x: int(x), input().split()) if n < 10: print(100*(10-n)+r) return print(r)
n, r = map(lambda x: int(x), input().split()) if n < 10: print(100*(10-n)+r) else: print(r)
[ "function.return_value.change" ]
557,322
557,323
u087099834
python
p02765
NandK = input() NandK = NandK.split(' ') N = int(NandK[0]) K = int(NandK[1]) if N >= 10: print(K) else: print(100 * (10 - K))
NandK = input() NandK = NandK.split(' ') N = int(NandK[0]) K = int(NandK[1]) if N >= 10: print(K) else: print(K + 100 * (10 - N))
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
557,340
557,341
u795928154
python
p02765
n,r=map(int,input().split()) if n>=10: print(r) else: r-=100*(10-n) print(r)
n,r=map(int,input().split()) if n>=10: print(r) else: r+=100*(10-n) print(r)
[ "expression.operator.change" ]
557,346
557,347
u170410075
python
p02765
n, r = [int(elem) for elem in input().split()] if n < 10: print(r - 100 *(10-n)) else: print(r)
n, r = [int(elem) for elem in input().split()] if n < 10: print(r + 100 *(10-n)) else: print(r)
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
557,348
557,349
u047197186
python
p02765
n, r = map(int, input().split()) print( r if n >= 10 else r-100*(10-n))
n, r = map(int, input().split()) print( r if n >= 10 else r+100*(10-n))
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
557,356
557,357
u813098295
python
p02765
n, r = map(int, input().split()) print( r if n <= 10 else r-100*(10-n))
n, r = map(int, input().split()) print( r if n >= 10 else r+100*(10-n))
[ "misc.opposites", "expression.operator.compare.change", "call.arguments.change", "io.output.change", "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
557,358
557,357
u813098295
python
p02765
n,r = map(int,input().split()) print(r if n >= 10 else r - 100*(10-n))
n,r = map(int,input().split()) print(r if n >= 10 else r + 100*(10-n))
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
557,359
557,360
u082861480
python
p02765
a,b=map(int,input().split()) if(a<10): print(b-100*(10-a)) else: print(b)
a,b=map(int,input().split()) if(a<10): print(b+100*(10-a)) else: print(b)
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
557,363
557,364
u777028980
python
p02765
import numpy as np i = list(map(int, input().split())) N = i[0] R = i[1] if N>=10: print(R) else: print(R-(100*(10-N)))
import numpy as np i = list(map(int, input().split())) N = i[0] R = i[1] if N>=10: print(R) else: print(R+(100*(10-N)))
[ "misc.opposites", "expression.operator.arithmetic.change", "call.arguments.change", "expression.operation.binary.change", "io.output.change" ]
557,367
557,368
u927105328
python
p02765
N, R = list(map(int, input().split())) if N < 10: print(100 * (10 - N)) else: print(R)
N, R = list(map(int, input().split())) if N < 10: print(100 * (10 - N) + R) else: print(R)
[ "expression.operation.binary.add" ]
557,373
557,374
u786168796
python