buggy_code stringlengths 11 625k | fixed_code stringlengths 17 625k | bug_type stringlengths 2 4.45k | language int64 0 8 | token_count int64 5 200k |
|---|---|---|---|---|
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,fl... | from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,fl... | [["-", 8, 196, 0, 37, 0, 23, 0, 657, 31, 22], ["-", 8, 196, 0, 37, 0, 23, 0, 657, 17, 33], ["+", 8, 196, 0, 37, 0, 23, 0, 657, 17, 33], ["+", 8, 196, 0, 37, 0, 23, 0, 657, 12, 22]] | 5 | 515 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
// j-i=a[j]+a[i]
// j-a[j]=i+a[i]
int main() {
ll n;
cin >> n;
vector<ll> wa(200000), sa(20000);
for (int i = 0; i < n; i++) {
ll a;
cin >> a;
if (a + i + 1 < 200000)
wa[a + i + 1]++;
if (i + 1 ... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
// j-i=a[j]+a[i]
// j-a[j]=i+a[i]
int main() {
ll n;
cin >> n;
vector<ll> wa(200000), sa(200000);
for (int i = 0; i < n; i++) {
ll a;
cin >> a;
if (a + i + 1 < 200000)
wa[a + i + 1]++;
if (i + 1... | [["-", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 4, 0, 13]] | 1 | 149 |
n = int(input())
a = list(map(int,input().split()))
p = []
q = []
d = collections.defaultdict(int)
e = collections.defaultdict(int)
for i in range(n):
p.append(a[i]+i+1)
for i in range(n):
q.append(-a[i]+i+1)
ans = 0
for i in range(n):
d[p[i]] += 1
e[q[i]] += 1
for i in d.keys():
ans += d[i]*e[i]
pr... | n = int(input())
a = list(map(int,input().split()))
import collections
p = []
q = []
d = collections.defaultdict(int)
e = collections.defaultdict(int)
for i in range(n):
p.append(a[i]+i+1)
for i in range(n):
q.append(-a[i]+i+1)
ans = 0
for i in range(n):
d[p[i]] += 1
e[q[i]] += 1
for i in d.keys():
... | [["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]] | 5 | 145 |
from bisect import bisect_left, bisect, insort
def main():
n = int(input())
a = list(map(int, input().split()))
h_plus_i = [ai+i for i, ai in enumerate(a, 1)]
h_minus_i = [ai-i for i, ai in enumerate(a, 1)]
s_h_plus_i = list(sorted(h_plus_i))
s_h_minus_i = list(sorted(h_minus_i))
ans = 0
... | from bisect import bisect_left, bisect, insort
def main():
n = int(input())
a = list(map(int, input().split()))
h_plus_i = [ai+i for i, ai in enumerate(a, 1)]
h_minus_i = [ai-i for i, ai in enumerate(a, 1)]
s_h_plus_i = list(sorted(h_plus_i))
s_h_minus_i = list(sorted(h_minus_i))
ans = 0
... | [["-", 0, 7, 8, 196, 0, 57, 75, 665, 0, 683], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121]] | 5 | 197 |
import collections
import sys
readline = sys.stdin.readline
def main():
n = int(readline().rstrip())
A = list(map(int, readline().rstrip().split()))
ans = 0
c = collections.Counter()
for i in range(n):
ans += c[i + 1 - A[i]]
c[i + 1 + A[i]] += 1
print(c)
print(ans)
if ... | import collections
import sys
readline = sys.stdin.readline
def main():
n = int(readline().rstrip())
A = list(map(int, readline().rstrip().split()))
ans = 0
c = collections.Counter()
for i in range(n):
ans += c[i + 1 - A[i]]
c[i + 1 + A[i]] += 1
print(ans)
if __name__ == '_... | [["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25], ["-", 0, 14, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24]] | 5 | 111 |
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
#cnt = 0
#for i in range(N):
# for j in range(i, N):
# if j - i == A[i] + A[j]:
# cnt += 1
Ap = [A[i]+i for i in range(len(A))]
Am = [i-A[i] for i in range(len(A))]
S = set(Ap) & set(Am)
Cp = Counter(Ap)
Cm = Counter(Am)
... | from collections import Counter
N = int(input())
A = list(map(int, input().split()))
#cnt = 0
#for i in range(N):
# for j in range(i, N):
# if j - i == A[i] + A[j]:
# cnt += 1
Ap = [A[i]+i for i in range(len(A))]
Am = [i-A[i] for i in range(len(A))]
S = set(Ap) & set(Am)
Cp = Counter(Ap)
Cm = Counter(Am)
... | [["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 116 |
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a) * (a)
#define M(a, b) make_pair(a, b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define d... | #include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a) * (a)
#define M(a, b) make_pair(a, b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define d... | [["-", 31, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 31, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 64, 37, 0, 34, 31, 16, 31, 16, 12, 22], ["+", 64, 37, 0, 34, 31, 16, 31, 16, 12, 22]] | 1 | 370 |
def input_int():
return int(input())
def input_ints():
return list(map(int, input().split()))
X = input_int()
def divs(n):
i = 1
res = []
while i * i <= n:
if n % i == 0:
res.append(i)
res.append(n // i)
i += 1
return res
import sys
for d in divs(X):
... | def input_int():
return int(input())
def input_ints():
return list(map(int, input().split()))
X = input_int()
def divs(n):
i = 1
res = []
while i * i <= n:
if n % i == 0:
res.append(i)
res.append(n // i)
i += 1
return res
import sys
for d in divs(X):
... | [["-", 64, 196, 0, 1, 0, 652, 3, 4, 0, 21], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 21], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 22]] | 5 | 134 |
#include <bits/stdc++.h>
#include <fstream>
#pragma GCC optimize("O2")
using namespace std;
#define F first
#define S second
#define migmig \
ios::sync_with_stdio(false); \
cin.tie(0); ... | #include <bits/stdc++.h>
#include <fstream>
#pragma GCC optimize("O2")
using namespace std;
#define F first
#define S second
#define migmig \
ios::sync_with_stdio(false); \
cin.tie(0); ... | [["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]] | 1 | 223 |
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplac... | #include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplac... | [["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 107]] | 1 | 353 |
from bisect import bisect_left, bisect_right
N = int(input())
A = list(map(int, input().split()))
Ap = [i - A[i] for i in range(N)]
Ap.sort()
print(Ap)
ans = 0
for i in range(N):
ans += bisect_right(Ap, i + A[i]) - bisect_left(Ap, i + A[i])
print(ans) | from bisect import bisect_left, bisect_right
N = int(input())
A = list(map(int, input().split()))
Ap = [i - A[i] for i in range(N)]
Ap.sort()
ans = 0
for i in range(N):
ans += bisect_right(Ap, i + A[i]) - bisect_left(Ap, i + A[i])
print(ans) | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 97 |
n=int(input())
y=list(map(int,input().split()))
from collections import Counter
lhs=Counter([j+y[j] for j in range(n)])
rhs=Counter([j-y[j] for j in range(n)])
count=0
for i in lhs:
if i in rhs:
count+=lhs[i]+rhs[i]
print(count) | n=int(input())
y=list(map(int,input().split()))
from collections import Counter
lhs=Counter([j+y[j] for j in range(n)])
rhs=Counter([j-y[j] for j in range(n)])
count=0
for i in lhs:
if i in rhs:
count+=lhs[i]*rhs[i]
print(count)
| [["-", 64, 196, 0, 1, 0, 677, 12, 657, 17, 72], ["+", 64, 196, 0, 1, 0, 677, 12, 657, 17, 48]] | 5 | 97 |
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
p = [i+Ai for i, Ai in zip(range(1, N+1), A)]
q = [j-Aj for j, Aj in zip(range(1, N+1), A)]
pc = Counter(p)
qc = Counter(q)
r = sum(pc[k]*qc[k] for k in pc.keys() & qc.keys()) | from collections import Counter
N = int(input())
A = list(map(int, input().split()))
p = [i+Ai for i, Ai in zip(range(1, N+1), A)]
q = [j-Aj for j, Aj in zip(range(1, N+1), A)]
pc = Counter(p)
qc = Counter(q)
r = sum(pc[k]*qc[k] for k in pc.keys() & qc.keys())
print(r) | [["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 119 |
n = int(input())
a = list(map(int, input().split()))
dict_diffs = dict()
for i in range(1, n+1):
dict_diffs[i+a[i-1]] = dict_diffs1.get(i+a[i-1], 0) + 1
total = 0
for j in range(1, n+1):
total += dict_diffs1.get(j-a[j-1], 0)
print(total) | n = int(input())
a = list(map(int, input().split()))
dict_diffs = dict()
for i in range(1, n+1):
dict_diffs[i+a[i-1]] = dict_diffs.get(i+a[i-1], 0) + 1
total = 0
for j in range(1, n+1):
total += dict_diffs.get(j-a[j-1], 0)
print(total) | [["-", 0, 662, 12, 657, 31, 652, 63, 319, 500, 22], ["+", 0, 662, 12, 657, 31, 652, 63, 319, 500, 22], ["-", 0, 1, 0, 677, 12, 652, 63, 319, 500, 22], ["+", 0, 1, 0, 677, 12, 652, 63, 319, 500, 22]] | 5 | 107 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2e5 + 5;
map<int, int> mp;
int a[maxn], n;
ll ans;
int main() {
cin >> n;
for (int i = i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++)
if (i - a[i] > 0)
mp[i - a[i]]++;
for (int i = 1; i <= n; i++)
... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2e5 + 5;
map<int, int> mp;
int a[maxn], n;
ll ans;
int main() {
cin >> n;
for (int i = i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++)
if (i - a[i] > 0)
mp[i - a[i]]++;
for (int i = 1; i <= n; i++)
... | [["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]] | 1 | 146 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P = pair<int, int>;
using ll = long long;
const int INF = 1001001001;
int main() {
int n;
cin >> n;
int a[n];
map<int, int> h;
rep(i, n) {
cin >> a[i];
h[abs(i - a[i])]++;
}
int ans = 0;
rep(i, n... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P = pair<int, int>;
using ll = long long;
const int INF = 1001001001;
int main() {
int n;
cin >> n;
int a[n];
map<int, int> h;
rep(i, n) {
cin >> a[i];
h[i - a[i]]++;
}
ll ans = 0;
rep(i, n) { an... | [["-", 0, 27, 28, 69, 341, 342, 0, 2, 63, 22], ["-", 28, 69, 341, 342, 0, 2, 3, 4, 0, 24], ["-", 28, 69, 341, 342, 0, 2, 3, 4, 0, 25], ["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]] | 1 | 126 |
n=int(input())
A=list(map(int,input().split()))
L,R={},{}
for i,a in enumerate(A):
l,r = i-a,i+a
if l in L: L[l]=0
if r in R: R[r]=0
L[l]+=1
R[r]+=1
count = 0
for x in L:
if x not in R: continue
count += L[x]*R[x]
print(count) | n=int(input())
A=list(map(int,input().split()))
L,R={},{}
for i,a in enumerate(A):
l,r = i-a,i+a
if l not in L: L[l]=0
if r not in R: R[r]=0
L[l]+=1
R[r]+=1
count = 0
for x in L:
if x not in R: continue
count += L[x]*R[x]
print(count) | [["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 699]] | 5 | 119 |
n = int(input())
a = list(map(int, input().split()))
count = 0
d={}
for i in range(n):
if i - a[i] in d:
count+=d[i - a[i]]
if i + a[i] in d:
d[i+a[i]] + 1
else:
d[i+a[i]] = 1
print(count) | n = int(input())
a = list(map(int, input().split()))
count = 0
d={}
for i in range(n):
if i - a[i] in d:
count+=d[i - a[i]]
if i + a[i] in d:
d[i+a[i]] += 1
else:
d[i+a[i]] = 1
print(count) | [["-", 0, 57, 64, 196, 0, 1, 0, 657, 17, 72], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107]] | 5 | 99 |
# class Map(dict):
# def __missing__(self, key):
# # この割当てなしのほうが速い。
# # self[key] = 0
# return 0
def main():
int(input())
d = {}
ans = 0
for i, height in enumerate(input().split()):
height = int(height)
# 引き算のほうの i は足し算のよりも大きい。
# 従って,このように順番に見ていく必要が... | # class Map(dict):
# def __missing__(self, key):
# # この割当てなしのほうが速い。
# # self[key] = 0
# return 0
def main():
int(input())
d = {}
ans = 0
for i, height in enumerate(input().split()):
height = int(height)
# 引き算のほうの i は足し算のよりも大きい。
# 従って,このように順番に見ていく必要が... | [["-", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32]] | 5 | 98 |
N = int(input())
# N = int(input())
A = list(map(int, input().split()))
ans = 0
d1 = {}
d2 = {}
for i in range(N):
if i+1 + A[i] in d1:
d1[i+1 + A[i]] += 1
else:
d1[i+1 + A[i]] = 1
if i+1 - A[i] in d2:
d2[i+1 - A[i]] += 1
else:
d2[i+1 - A[i]] = 1
for a in d1.keys():
... | N = int(input())
# N = int(input())
A = list(map(int, input().split()))
ans = 0
d1 = {}
d2 = {}
for i in range(N):
if i+1 + A[i] in d1:
d1[i+1 + A[i]] += 1
else:
d1[i+1 + A[i]] = 1
if i+1 - A[i] in d2:
d2[i+1 - A[i]] += 1
else:
d2[i+1 - A[i]] = 1
for a in d1.keys():
... | [["-", 0, 57, 64, 196, 0, 1, 0, 677, 31, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 677, 17, 107], ["+", 64, 196, 0, 1, 0, 677, 12, 657, 17, 48], ["-", 64, 196, 0, 1, 0, 677, 12, 657, 17, 33], ["-", 64, 196, 0, 1, 0, 677, 12, 657, 12, 612]] | 5 | 160 |
import collections
N = int(input())
A = list(map(int, input().split()))
L = [i + A[i] for i in range(N)]
R = [i - A[i] for i in range(N)]
countL = collections.Counter(L)
countR = collections.Counter(R)
print([countL[n] * countR[n] for n in countL.keys()]) | import collections
N = int(input())
A = list(map(int, input().split()))
L = [i + A[i] for i in range(N)]
R = [i - A[i] for i in range(N)]
countL = collections.Counter(L)
countR = collections.Counter(R)
print(sum([countL[n] * countR[n] for n in countL.keys()])) | [["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 99 |
import sys
input = sys.stdin.readline
def main():
n = int(input())
a_list = list(map(int, input().split()))
c = [0] * n
s = 0
for i, a in enumerate(a_list):
if i+a < n:
d[i+a] += 1
if i-a >= 0:
s += d[i-a]
print(s)
if __name__ == '__main__':
main() | import sys
input = sys.stdin.readline
def main():
n = int(input())
a_list = list(map(int, input().split()))
c = [0] * n
s = 0
for i, a in enumerate(a_list):
if i+a < n:
c[i+a] += 1
if i-a >= 0:
s += c[i-a]
print(s)
if __name__ == '__main__':
main() | [["-", 64, 196, 0, 1, 0, 677, 31, 206, 51, 22], ["+", 64, 196, 0, 1, 0, 677, 31, 206, 51, 22], ["-", 64, 196, 0, 1, 0, 677, 12, 206, 51, 22], ["+", 64, 196, 0, 1, 0, 677, 12, 206, 51, 22]] | 5 | 103 |
N = int(input())
A = list(map(int, input().split()))
check = {}
ans = 0
for i in range(N):
x = i - A[i]
y = A[i] + i
ans += check.get(x, 0)
check.setdefault(y, 0)
check[y] += 1
print(ans)
print(check) | N = int(input())
A = list(map(int, input().split()))
check = {}
ans = 0
for i in range(N):
x = i - A[i]
y = A[i] + i
ans += check.get(x, 0)
check.setdefault(y, 0)
check[y] += 1
print(ans) | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 88 |
#include <bits/stdc++.h>
using namespace std;
#define NewNode (ListNode *)malloc(sizeof(ListNode))
#define Mem(a, b) memset(a, b, sizeof(a))
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
const unsigned long long mod = 998244353;
const double II = 3.1415926535;
typedef long long ll;
typede... | #include <bits/stdc++.h>
using namespace std;
#define NewNode (ListNode *)malloc(sizeof(ListNode))
#define Mem(a, b) memset(a, b, sizeof(a))
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
const unsigned long long mod = 998244353;
const double II = 3.1415926535;
typedef long long ll;
typede... | [["+", 28, 69, 341, 342, 0, 16, 31, 16, 31, 13], ["+", 28, 69, 341, 342, 0, 16, 31, 16, 17, 48]] | 1 | 190 |
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#pr... | #include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#pr... | [["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["-", 0, 11, 31, 69, 341, 342, 0, 16, 31, 22], ["-", 0, 11, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 17, 72], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 12, 22]] | 1 | 369 |
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <stdio.h>
#include <stdlib.h>
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define abs(a) ((a) > 0 ? (a) : (-1 * (a)))
#define rep(i, n) for ((i) = 0; (i) < (n); (i)++)
#define rep2(i, s, e) for ((i) = (s); (i) < (e); (... | #pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <stdio.h>
#include <stdlib.h>
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define abs(a) ((a) > 0 ? (a) : (-1 * (a)))
#define rep(i, n) for ((i) = 0; (i) < (n); (i)++)
#define rep2(i, s, e) for ((i) = (s); (i) < (e); (... | [["+", 0, 9, 0, 52, 15, 23, 0, 16, 17, 98], ["+", 0, 52, 15, 23, 0, 16, 12, 16, 31, 22], ["+", 0, 52, 15, 23, 0, 16, 12, 16, 17, 18], ["+", 0, 52, 15, 23, 0, 16, 12, 16, 12, 22]] | 0 | 530 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
typedef long long ll;
typedef pair<ll, ll> P;
template <class T> inline bool chmax(T &a, T b)... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
typedef long long ll;
typedef pair<ll, ll> P;
template <class T> inline bool chmax(T &a, T b)... | [["-", 36, 36, 36, 36, 0, 30, 0, 43, 39, 78], ["+", 36, 36, 36, 36, 0, 30, 0, 43, 39, 40], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 17, 72], ["+", 0, 43, 49, 50, 51, 4, 0, 16, 12, 13]] | 1 | 245 |
n = int(input())
a = list(map(int,input().split()))
box = [[0,0] for i in range(n)]
for i in range(n):
num = i + 1
if 0 < num - a[i] < n:
box[a[i]-num][0] += 1
if 0 < a[i]+num < n:
box[a[i]-num][1] += 1
ans = 0
for i in range(n):
ans += box[i][0] * box[i][1]
print(ans)
| n = int(input())
a = list(map(int,input().split()))
box = [[0,0] for i in range(n)]
for i in range(n):
num = i + 1
if 0 < num - a[i] < n:
box[num - a[i]][0] += 1
if 0 < a[i]+num < n:
box[a[i]+num][1] += 1
ans = 0
for i in range(n):
ans += box[i][0] * box[i][1]
print(ans)
| [["+", 0, 677, 31, 206, 51, 206, 206, 657, 31, 22], ["+", 0, 677, 31, 206, 51, 206, 206, 657, 17, 33], ["-", 0, 677, 31, 206, 51, 206, 206, 657, 17, 33], ["-", 0, 677, 31, 206, 51, 206, 206, 657, 12, 22], ["+", 0, 677, 31, 206, 51, 206, 206, 657, 17, 72]] | 5 | 138 |
from collections import defaultdict
n = int(input())
a = np.array(list(map(int, input().split())))
ci = defaultdict(int)
cj = defaultdict(int)
for i in range(n):
ci[a[i]+i] += 1
cj[i-a[i]] += 1
cnt = 0
for k in ci.keys():
cnt += ci[k] * cj[k]
print(cnt) | from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
ci = defaultdict(int)
cj = defaultdict(int)
for i in range(n):
ci[a[i]+i] += 1
cj[i-a[i]] += 1
cnt = 0
for k in ci.keys():
cnt += ci[k] * cj[k]
print(cnt) | [["-", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22], ["-", 0, 1, 0, 662, 12, 652, 63, 319, 0, 131], ["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]] | 5 | 103 |
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int main() {
int n;
cin >> n;
vector<int> l(n + 1, 0), r(n + 1, 0);
for (int i = 1; i <= n; i++) {
int a;
cin >> a;
if (i - a >= 1)
l[i - 1]++;
if (i + a <= n)
r[i + a]++;
}
ll ans = 0;
for (int i = 1; i <= ... | #include "bits/stdc++.h"
using namespace std;
using ll = long long;
int main() {
int n;
cin >> n;
vector<int> l(n + 1, 0), r(n + 1, 0);
for (int i = 1; i <= n; i++) {
int a;
cin >> a;
if (i - a >= 1)
l[i - a]++;
if (i + a <= n)
r[i + a]++;
}
ll ans = 0;
for (int i = 1; i <= ... | [["-", 0, 27, 28, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 27, 28, 69, 341, 342, 0, 16, 12, 22]] | 1 | 146 |
import collections
N = int(input())
A = list((map(int,input().split())))
index = list(range(1,N+1))
R = [index[i] - A[i] for i in range(N)]
L = [index[j] + A[j] for j in range(N)]
R_dict = collections.Counter(R)
L_dict = collections.Counter(L)
ans=0
for i in R_dict.keys()&L_dict.keys():
ans+=max(R_dict[i], L_di... | import collections
N = int(input())
A = list((map(int,input().split())))
index = list(range(1,N+1))
R = [index[i] - A[i] for i in range(N)]
L = [index[j] + A[j] for j in range(N)]
R_dict = collections.Counter(R)
L_dict = collections.Counter(L)
ans=0
for i in R_dict.keys()&L_dict.keys():
ans+=R_dict[i]*L_dict[i]... | [["-", 8, 196, 0, 1, 0, 677, 12, 652, 63, 22], ["-", 0, 1, 0, 677, 12, 652, 3, 4, 0, 24], ["-", 0, 1, 0, 677, 12, 652, 3, 4, 0, 21], ["+", 8, 196, 0, 1, 0, 677, 12, 657, 17, 48], ["-", 0, 1, 0, 677, 12, 652, 3, 4, 0, 25]] | 5 | 134 |
n = gets.to_i
as = gets.split.map(&:to_i)
count = Hash.new(0)
ans = 0
n.times do |r, i|
ans += count[i - as[i]]
count[i + as[i]] += 1
end
puts ans
| n = gets.to_i
as = gets.split.map(&:to_i)
count = Hash.new(0)
ans = 0
n.times do |i|
ans += count[i - as[i]]
count[i + as[i]] += 1
end
puts ans
| [["-", 0, 493, 0, 652, 196, 737, 54, 758, 0, 22], ["-", 0, 493, 0, 652, 196, 737, 54, 758, 0, 21]] | 4 | 61 |
#include <bits/stdc++.h>
using namespace std;
const int NMAX = 2e5 + 10;
typedef long long ll;
int a[NMAX];
int main(int argc, char const *argv[]) {
int n;
scanf("%d", &n);
map<int, int> mp;
for (register int i = 1; i <= n; i++)
scanf("%d", a + i), mp[a[i] + 1]++;
ll ans = 0;
for (register int i = 1; ... | #include <bits/stdc++.h>
using namespace std;
const int NMAX = 2e5 + 10;
typedef long long ll;
int a[NMAX];
int main(int argc, char const *argv[]) {
int n;
scanf("%d", &n);
map<int, int> mp;
for (register int i = 1; i <= n; i++)
scanf("%d", a + i), mp[a[i] + i]++;
ll ans = 0;
for (register int i = 1; ... | [["-", 12, 27, 28, 69, 341, 342, 0, 16, 12, 13], ["+", 12, 27, 28, 69, 341, 342, 0, 16, 12, 22]] | 1 | 143 |
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
d = dict(collections.Counter([i + A[i-1] for i in range(1, N+1)]))
ans = sum([d.get(i - A[i-1], 0) for i in range(1, N+1)])
print(ans)
| from collections import Counter
N = int(input())
A = list(map(int, input().split()))
d = dict(Counter([i + A[i-1] for i in range(1, N+1)]))
ans = sum([d.get(i - A[i-1], 0) for i in range(1, N+1)])
print(ans)
| [["-", 12, 652, 3, 4, 0, 652, 63, 319, 500, 22], ["-", 12, 652, 3, 4, 0, 652, 63, 319, 0, 131]] | 5 | 97 |
N = int(input())
A = list(map(int, input().split()))
lst = [0] * N
ans = 0
for i in range(N):
if i + 1 + A[i] < n: #iは0から始まるので +1 してあげる
lst[i + A[i]] += 1
if i + 1 - A[i] >= 1:
ans += lst[i - A[i]]
print(ans) | N = int(input())
A = list(map(int, input().split()))
lst = [0] * N
ans = 0
for i in range(N):
if i + 1 + A[i] < N: #iは0から始まるので +1 してあげる
lst[i + A[i]] += 1
if i + 1 - A[i] >= 1:
ans += lst[i - A[i]]
print(ans) | [["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22]] | 5 | 94 |
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
r = []
for i, ai in enumerate(a):
l.append(i+ai)
r.append(i-ai)
ans = 0
b = Counter(r)
for i in l:
ans += b.get(i, 0)
print(ans)
| from collections import Counter
n = int(input())
a = list(map(int, input().split()))
l = []
r = []
for i, ai in enumerate(a):
l.append(i+ai)
r.append(i-ai)
ans = 0
b = Counter(r)
for i in l:
ans += b.get(i, 0)
print(ans)
| [["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 70], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 73]] | 5 | 87 |
#include <bits/stdc++.h>
using namespace std;
#define itn int
int main(void) {
int n;
cin >> n;
int a[n];
map<long long, long long> mp;
for (int i = 0; i < n; i++)
cin >> a[i];
long long sum = 0;
for (int i = 0; i < n; i++) {
// mp[a[i]-(i+1)]++;
mp[abs(a[i] - (i + 1))]++;
}
for (int i... | #include <bits/stdc++.h>
using namespace std;
#define itn int
int main(void) {
int n;
cin >> n;
int a[n];
map<long long, long long> mp;
for (int i = 0; i < n; i++)
cin >> a[i];
long long sum = 0;
for (int i = 0; i < n; i++) {
// mp[a[i]-(i+1)]++;
mp[(-a[i] + (i + 1))]++;
}
for (int i =... | [["-", 0, 27, 28, 69, 341, 342, 0, 2, 63, 22], ["+", 341, 342, 0, 23, 0, 16, 31, 91, 17, 33], ["-", 341, 342, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 28, 69, 341, 342, 0, 23, 0, 16, 17, 72]] | 1 | 184 |
N = int(input())
A = list(map(int, input().split()))
S = [0]*N
D = [0]*N
for i in range(N):
if A[i]+i < N:
S[A[i]+i] += 1
if i - A[i] > 0:
D[i - A[i]] += 1
ans = 0
print(S,D)
for l in range(N):
ans += S[l]*D[l]
print(ans) | N = int(input())
A = list(map(int, input().split()))
S = [0]*N
D = [0]*N
for i in range(N):
if A[i]+i < N:
S[A[i]+i] += 1
if i - A[i] > 0:
D[i - A[i]] += 1
ans = 0
for l in range(N):
ans += S[l]*D[l]
print(ans) | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 21], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 121 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import ... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import ... | [["-", 0, 16, 31, 504, 71, 16, 31, 16, 31, 22], ["-", 0, 16, 31, 504, 71, 16, 31, 16, 17, 33], ["-", 3, 4, 0, 16, 31, 504, 71, 16, 17, 33], ["-", 3, 4, 0, 16, 31, 504, 71, 16, 12, 499]] | 3 | 896 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a[1000007];
int main() {
ll i, j, k, l, test, n;
cin >> n;
for (i = 1; i <= n; i++)
cin >> a[i];
map<ll, ll> m;
for (i = 1; i <= n; i++) {
m[abs(a[i] - i)]++;
}
ll sum = 0;
for (i = 1; i <= n; i++) {
sum += m[a[i] + i];
... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a[1000007];
int main() {
ll i, j, k, l, test, n;
cin >> n;
for (i = 1; i <= n; i++)
cin >> a[i];
map<ll, ll> m;
for (i = 1; i <= n; i++) {
m[(a[i] - i)]++;
}
ll sum = 0;
for (i = 1; i <= n; i++) {
sum += m[-(a[i] + i)];
... | [["-", 0, 27, 28, 69, 341, 342, 0, 2, 63, 22], ["+", 0, 11, 12, 69, 341, 342, 0, 91, 17, 33], ["+", 12, 69, 341, 342, 0, 91, 28, 23, 0, 24], ["+", 12, 69, 341, 342, 0, 91, 28, 23, 0, 25]] | 1 | 135 |
import collections
N = int(input())
A = list(map(int, input().split()))
L = [i+j for i, j in enumerate(A)]
R = [i-j for i, j in enumerate(A)]
l = collections.Counter(L)
r = collections.Counter(R)
for i in l.keys():
ans += l[i]*r[i]
print(ans) | import collections
N = int(input())
A = list(map(int, input().split()))
L = [i+j for i, j in enumerate(A)]
R = [i-j for i, j in enumerate(A)]
l = collections.Counter(L)
r = collections.Counter(R)
ans = 0
for i in l.keys():
ans += l[i]*r[i]
print(ans) | [["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]] | 5 | 99 |
# -*- coding: utf-8 -*-
# 入力を整数に変換して受け取る
def input_int():
return int(input())
# マイナス1した値を返却
def int1(x):
return int(x) - 1
# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
return map(int, input().split())
# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
return tuple(map(int, input().spl... | # -*- coding: utf-8 -*-
# 入力を整数に変換して受け取る
def input_int():
return int(input())
# マイナス1した値を返却
def int1(x):
return int(x) - 1
# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
return map(int, input().split())
# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
return tuple(map(int, input().spl... | [["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]] | 5 | 207 |
n=gets.to_i
a=gets.split.map(&:to_i)
t=[]
h=Hash.new(0)
a.each_with_index{|e,i|t<<e+i+1; h[(i+1-e).abs]+=1}
ans=0
t.each{|e|ans+=h[e.abs]}
p ans
| n=gets.to_i
a=gets.split.map(&:to_i)
t=[]
h=Hash.new(0)
a.each_with_index{|e,i|t<<e+i+1; h[i+1-e]+=1}
ans=0
t.each{|e|ans+=h[e]}
p ans
| [["-", 0, 755, 31, 742, 0, 652, 486, 739, 0, 24], ["-", 0, 755, 31, 742, 0, 652, 486, 739, 0, 25], ["-", 8, 734, 0, 755, 31, 742, 0, 652, 17, 131], ["-", 8, 734, 0, 755, 31, 742, 0, 652, 735, 22], ["-", 36, 36, 36, 36, 0, 493, 0, 768, 0, 769], ["+", 36, 36, 36, 36, 0, 493, 0, 768, 0, 769]] | 4 | 61 |
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i <= end; i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;... | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i <= end; i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;... | [["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]] | 1 | 521 |
n = gets.to_i
a = gets.split.map &:to_i
memo = Array.new(1000000000, 0)
ans = 0
n.times{|i|
ans += memo[i - a[i]]
memo[i + a[i]] += 1
}
puts ans | n = gets.to_i
a = gets.split.map &:to_i
memo = Hash.new(0)
ans = 0
n.times{|i|
ans += memo[i - a[i]]
memo[i + a[i]] += 1
}
puts ans | [["-", 36, 36, 0, 493, 0, 662, 12, 652, 486, 743], ["+", 36, 36, 0, 493, 0, 662, 12, 652, 486, 743], ["-", 0, 493, 0, 662, 12, 652, 3, 4, 0, 612], ["-", 0, 493, 0, 662, 12, 652, 3, 4, 0, 21]] | 4 | 59 |
from collections import defaultdict
n = int(input())
A = list(map(int, input().split()))
B = []
for j in range(n):
B.append(j - A[j])
C = []
for i in range(n):
C.append(i + A[i])
d = defaultdict(int)
for j in A:
d[j] += 1
count = 0
for k in B:
count += d[k]
print(count) | from collections import defaultdict
n = int(input())
A = list(map(int, input().split()))
B = []
for j in range(n):
B.append(j - A[j])
C = []
for i in range(n):
C.append(i + A[i])
d = defaultdict(int)
for j in C:
d[j] += 1
count = 0
for k in B:
count += d[k]
print(count)
# 時間超過
# count = 0
# for i... | [["-", 36, 36, 36, 36, 0, 656, 0, 7, 12, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 7, 12, 22]] | 5 | 110 |
#include <bits/stdc++.h>
// int n=132;
// bitset<16>binar(n);
// int a = bitset<16>(binar).to_ulong();
// cout<<a;
#define int long long
#define pb push_back
#define rep(i, b) for (int i = 0; i < b; i++)
#define all(c) (c).begin(), (c).end()
using namespace std;
signed main() {
int n;
cin >> n;
ve... | #include <bits/stdc++.h>
// int n=132;
// bitset<16>binar(n);
// int a = bitset<16>(binar).to_ulong();
// cout<<a;
#define int long long
#define pb push_back
#define rep(i, b) for (int i = 0; i < b; i++)
#define all(c) (c).begin(), (c).end()
using namespace std;
signed main() {
int n;
cin >> n;
ve... | [["+", 8, 9, 0, 43, 49, 53, 54, 55, 0, 24], ["+", 0, 43, 49, 53, 54, 55, 0, 56, 39, 78], ["+", 8, 9, 0, 43, 49, 53, 54, 55, 0, 25]] | 1 | 114 |
n = int(input())
a = input().split()
pl = []
sb = []
for i in range(len(a)):
pl.append(i+int(a[i])+1)
if i - int(a[i]) > 1:
sb.append(i-int(a[i])+1)
if len(sb) == 0:
print('0')
else:
# spl = sorted(pl)
isb = [int(i) for i in sb]
ipl = [int(i) for i in pl]
ssb = sorted(isb)
t = min(ssb)
# tl = [0] * max(ipl... | n = int(input())
a = input().split()
pl = []
sb = []
for i in range(len(a)):
pl.append(i+int(a[i])+1)
if i - int(a[i]) > 0:
sb.append(i-int(a[i])+1)
if len(sb) == 0:
print('0')
else:
# spl = sorted(pl)
isb = [int(i) for i in sb]
ipl = [int(i) for i in pl]
ssb = sorted(isb)
t = min(ssb)
# tl = [0] * max(ipl... | [["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["-", 8, 196, 0, 1, 0, 662, 12, 657, 12, 612], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 612]] | 5 | 210 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
using P = pair<int, int>;
#define LOG(variable) cout << #variable ":\t" << (variable) << endl
#define LOGCON(i, container) \
for (int(i) = 0; (i) < (container).size(); ++(i)) ... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
using P = pair<int, int>;
#define LOG(variable) cout << #variable ":\t" << (variable) << endl
#define LOGCON(i, container) \
for (int(i) = 0; (i) < (container).size(); ++(i)) ... | [["-", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152]] | 1 | 695 |
#include <assert.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef long long ll;
typedef long double ld;
#define rep(i, l, r) for (ll i = (l); i < (r); i++)
#define repp(i, l, r, k) for (ll i = (l); i < (r); i += (k))
#define rrep(i, l, r) for (ll i = (l); i >=... | #include <assert.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef long long ll;
typedef long double ld;
#define rep(i, l, r) for (ll i = (l); i < (r); i++)
#define repp(i, l, r, k) for (ll i = (l); i < (r); i += (k))
#define rrep(i, l, r) for (ll i = (l); i >=... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]] | 0 | 1,545 |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int, Int> p;
int main() {
int N;
cin >> N;
vector<Int> A(N), B(N);
rep(i, N) {
cin >> A[i];
B[i] = A[i] + i;
}
... | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int, Int> p;
int main() {
int N;
cin >> N;
vector<Int> A(N), B(N);
rep(i, N) {
cin >> A[i];
B[i] = A[i] + i;
}
... | [["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 14, 8, 9, 0, 14, 49, 53, 49, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35]] | 1 | 146 |
n=int(input())
A=list(map(int,input().split()))
L=[]
R=[]
for i in range(n):
L.append(i+A[i])
R.append(i-A[i])
from collections import Counter
zisyo=R.Counter(R)
ans=0
for i in L:
ans=ans+get(i,0)
print(ans)
| n=int(input())
A=list(map(int,input().split()))
L=[]
R=[]
for i in range(n):
L.append(i+A[i])
R.append(i-A[i])
from collections import Counter
zisyo=Counter(R)
ans=0
for i in L:
ans=ans+zisyo.get(i,0)
print(ans)
| [["-", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22], ["-", 0, 1, 0, 662, 12, 652, 63, 319, 0, 131], ["+", 0, 662, 12, 657, 12, 652, 63, 319, 500, 22], ["+", 0, 662, 12, 657, 12, 652, 63, 319, 0, 131]] | 5 | 97 |
#include <algorithm>
#include <cmath>
#include <complex>
#include <functional>
#include <iostream>
#include <limits>
#include <numeric>
#include <sstream>
#include <string>
#include <map>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
in... | #include <algorithm>
#include <cmath>
#include <complex>
#include <functional>
#include <iostream>
#include <limits>
#include <numeric>
#include <sstream>
#include <string>
#include <map>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
in... | [["+", 0, 7, 10, 43, 49, 50, 51, 16, 17, 33], ["+", 0, 7, 10, 43, 49, 50, 51, 16, 12, 13], ["-", 0, 27, 28, 69, 341, 342, 0, 16, 17, 72], ["+", 0, 27, 28, 69, 341, 342, 0, 16, 17, 33], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 33], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72]] | 1 | 195 |
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
D = defaultdict(int)
ans = 0
for i, x in enumerate(A, 1):
ans += D[i-x]
D[x+i] += 1
print(ans, D) | from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
D = defaultdict(int)
ans = 0
for i, x in enumerate(A, 1):
ans += D[i-x]
D[x+i] += 1
print(ans) | [["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 21], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22]] | 5 | 72 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t n;
cin >> n;
vector<int64_t> L(n), R(n);
for (int i = 0; i < n; i++) {
int64_t A;
cin >> A;
L.at(i) = i + 1 + A;
R.at(i) = i + 1 - A;
}
map<int64_t, int64_t> check;
for (int i = 0; i < n; i++) {
if (check.count(L.at... |
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t n;
cin >> n;
vector<int64_t> L(n), R(n);
for (int i = 0; i < n; i++) {
int64_t A;
cin >> A;
L.at(i) = i + 1 + A;
R.at(i) = i + 1 - A;
}
map<int64_t, int64_t> check;
for (int i = 0; i < n; i++) {
if (check.count(L.at... | [["-", 12, 2, 3, 4, 0, 2, 63, 118, 28, 22], ["+", 12, 2, 3, 4, 0, 2, 63, 118, 28, 22]] | 1 | 204 |
from collections import Counter
N,*A = map(int,open(0).read().split())
#j - i = Aj + Ai
#j - Aj = Ai + i
#L = i + Ai, R = j - Aj とおく
L = []
R = []
for i in range(N):
L.append(i+1 + A[i])
R.append(i+1 - A[i])
l = Counter(L)
r = Counter(R)
cnt = 0
for i in range(1,N+1):
if i in l and i in r:
cnt +=... | from collections import Counter
N,*A = map(int,open(0).read().split())
#j - i = Aj + Ai
#j - Aj = Ai + i
#L = i + Ai, R = j - Aj とおく
L = []
R = []
for i in range(N):
L.append(i+1 + A[i])
R.append(i+1 - A[i])
l = Counter(L)
r = Counter(R)
cnt = 0
a = []
for i in range(1,N+1):
if i in l and i in r:
... | [["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 70], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 73]] | 5 | 128 |
def main():
n,a=map(int,open(0).read().split());d,s=[0]*n,0
for i,x in enumerate(a):
if i+x<n:d[i+x]+=1
if i-x>=0:s+=d[i-x]
print(s)
main() | def main():
n, *a = map(int,open(0).read().split())
d, s = [0]*n, 0
for i, x in enumerate(a):
if i+x<n:
d[i+x]+=1
if i-x>=0:
s+=d[i-x]
print(s)
main() | [["+", 0, 1, 0, 662, 31, 684, 0, 695, 0, 48], ["-", 36, 36, 0, 656, 0, 14, 8, 196, 0, 35]] | 5 | 85 |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vi vector<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vvi vector<vi>
#define vll vector<ll>
#define vvll vector<vll>
#define all(a) a.begin(), a.end()
#define mp(a, b) make_pair(a, b)
#define pb push_bac... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vi vector<int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vvi vector<vi>
#define vll vector<ll>
#define vvll vector<vll>
#define all(a) a.begin(), a.end()
#define mp(a, b) make_pair(a, b)
#define pb push_bac... | [["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25]] | 1 | 284 |
import bisect as bi
import collections as cc
I=lambda:list(map(int,input().split()))
f=cc.defaultdict(int)
n,=I()
l=I()
ans=0
for i in range(n):
d[l[i]+i]+=1
ans+=d[i-l[i]]
print(ans)
| import bisect as bi
import collections as cc
I=lambda:list(map(int,input().split()))
d=cc.defaultdict(int)
n,=I()
l=I()
ans=0
for i in range(n):
d[l[i]+i]+=1
ans+=d[i-l[i]]
print(ans)
| [["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22]] | 5 | 83 |
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n):
b[i]= i-a[0]-a[i]
d = defaultdict(int)
for i in range(1,n):
d[b[i]] += 1
ans = 0
x = 0
for i in range(n-1):
ans+=d[x]
d[b[i+1]]-=1
x -= -1+(a[i]-a[i+1])
print(ans) | from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n):
b[i]= i-a[0]-a[i]
d = defaultdict(int)
for i in range(1,n):
d[b[i]] += 1
ans = 0
x = 0
for i in range(n-1):
ans+=d[x]
d[b[i+1]]-=1
x -= -1+(a[i]-a[i+1])
print(ans) | [["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 314], ["+", 36, 36, 0, 656, 0, 686, 687, 673, 0, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 487], ["+", 36, 36, 0, 656, 0, 686, 141, 673, 0, 22]] | 5 | 136 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int N;
cin >> N;
ll ans = 0;
vector<pair<ll, ll>> A(N);
for (int i = 0; i < N; i++) {
ll a;
cin >> a;
A[i].first = i + 1 + a;
A[i].second = i + 1 - a;
}
vector<int> B(N + 1, 0);
for (int i = N - 1; i >= 0; i... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int N;
cin >> N;
ll ans = 0;
vector<pair<ll, ll>> A(N);
for (int i = 0; i < N; i++) {
ll a;
cin >> a;
A[i].first = i + 1 + a;
A[i].second = i + 1 - a;
}
vector<int> B(N + 1, 0);
for (int i = N - 1; i >= 0; i... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 57, 64, 116, 0, 117], ["-", 0, 7, 8, 9, 0, 57, 64, 116, 0, 35], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]] | 1 | 181 |
N = int(input())
A = tuple( map(int, input().split()) )
dict_ = {}
ans = 0
for i in range(N):
k = (i+1) - A[i]
if k in dict_:
ans += dict[k]
ad = (i+1) + A[i]
if ad in dict_:
dict_[ad] = dict_[ad] + 1
dict_[ad] = 1
print(ans) | N = int(input())
A = tuple( map(int, input().split()) )
dict_ = {}
ans = 0
for i in range(N):
k = (i+1) - A[i]
if k in dict_:
ans += dict_[k]
ad = (i+1) + A[i]
if ad in dict_:
dict_[ad] = dict_[ad] + 1
else:
dict_[ad] = 1
print(ans)
| [["-", 64, 196, 0, 1, 0, 677, 12, 206, 51, 22], ["+", 64, 196, 0, 1, 0, 677, 12, 206, 51, 22], ["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 95], ["+", 0, 7, 8, 196, 0, 57, 75, 76, 0, 102]] | 5 | 101 |
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <time.h>
#include <unordered_map>
#include <vector>
using namespace std;
#define ll long long
#define rep(i, n) for (i = 0; i < n; i++)
int main() {
int ... | #include <algorithm>
#include <assert.h>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <time.h>
#include <unordered_map>
#include <vector>
using namespace std;
#define ll long long
#define rep(i, n) for (i = 0; i < n; i++)
int main() {
int ... | [["-", 0, 14, 8, 9, 0, 7, 26, 27, 17, 68], ["+", 0, 14, 8, 9, 0, 7, 26, 27, 17, 29]] | 1 | 145 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string.h>
#include <string>
#include <u... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string.h>
#include <string>
#include <u... | [["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 85], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 185 |
n = int(input())
A=list(map(int,input().split()))
cnt=0
B=[]
C=[]
for i,a in enumerate(A):
B.append(A[i]+i)
C.append(A[i]-i)
from collections import Counter
Bd=dict(Counter(B))
Cd=dict(Counter(C))
cnt=0
for k in Bd.keys():
b=Bd.get(k)
c=Cd.get(k)
if b and c:
cnt+=b*c
print(cnt)
| n = int(input())
A=list(map(int,input().split()))
cnt=0
B=[]
C=[]
for i,a in enumerate(A):
B.append(A[i]+i)
C.append(A[i]-i)
from collections import Counter
Bd=dict(Counter(B))
Cd=dict(Counter(C))
cnt=0
for k in Bd.keys():
b=Bd.get(k)
c=Cd.get(-k)
if b and c:
cnt+=b*c
print(cnt)
| [["+", 0, 662, 12, 652, 3, 4, 0, 664, 17, 33]] | 5 | 132 |
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main() {
int n, i, ans = 0, k, a, c;
map<int, int> mp;
cin >> n;
for (i = 1; i <= n; i++) {
cin >> c;
k = i + c;
ans += mp[k];
a = i - c;
mp[a]++;
}
cout << ans;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main() {
int n, i, ans = 0, k, a, c;
map<int, int> mp;
cin >> n;
for (i = 1; i <= n; i++) {
cin >> c;
k = i - c;
ans += mp[k];
a = i + c;
mp[a]++;
}
cout << ans;
return 0;
} | [["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 72]] | 1 | 93 |
#include <iostream>
#include <unordered_map>
using namespace std;
using int64 = long long;
int main() {
int64 n;
cin >> n;
unordered_map<int64, int64> L;
unordered_map<int64, int64> R;
for (int64 i = 0; i < n; ++i) {
int64 a;
cin >> a;
L[i + a] = L[i + a] + 1;
R[i - a] = L[i - a] + 1;
}
... | #include <iostream>
#include <unordered_map>
using namespace std;
using int64 = long long;
int main() {
int64 n;
cin >> n;
unordered_map<int64, int64> L;
unordered_map<int64, int64> R;
for (int64 i = 0; i < n; ++i) {
int64 a;
cin >> a;
L[i + a] = L[i + a] + 1;
R[i - a] = R[i - a] + 1;
}
... | [["-", 0, 1, 0, 11, 12, 16, 31, 69, 28, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 69, 28, 22]] | 1 | 137 |
#include <bits/stdc++.h>
using namespace std;
#define INCANT \
cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), \
cout << fixed << setprecision(20);
#define int long long
const int INF = 1e18, MOD = 1e9 + 7;
signed main(... | #include <bits/stdc++.h>
using namespace std;
#define INCANT \
cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), \
cout << fixed << setprecision(20);
#define int long long
const int INF = 1e18, MOD = 1e9 + 7;
signed main(... | [["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["-", 0, 1, 0, 11, 12, 16, 12, 118, 28, 22], ["-", 0, 1, 0, 11, 12, 16, 12, 118, 17, 131], ["-", 0, 1, 0, 11, 12, 16, 12, 118, 119, 120]] | 1 | 128 |
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/), cid = 0;
main();
function main() {
// console.log(cin);
// cin = cin.map(i => +i);
let n = +cin.shift();
let B = {};
let C = {};
cin.forEach((v, i) => {
const x = Number(v);
B[i + 1 + x] = ... | "use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.trim().split(/ |\n/), cid = 0;
main();
function main() {
// console.log(cin);
// cin = cin.map(i => +i);
let n = +cin.shift();
let B = {};
let C = {};
cin.forEach((v, i) => {
const x = Number(v);
B[i + 1 ... | [["+", 51, 2, 63, 558, 500, 2, 63, 558, 559, 560], ["+", 51, 2, 63, 558, 500, 2, 3, 3, 0, 24], ["+", 51, 2, 63, 558, 500, 2, 3, 3, 0, 25], ["+", 0, 198, 0, 200, 51, 2, 63, 558, 0, 131]] | 2 | 199 |
#include <bits/stdc++.h>
int main() {
int N;
std::cin >> N;
std::vector<int> A(N);
for (int i = 0; i < N; i++) {
std::cin >> A[i];
}
std::map<int, int> dist;
long long cnt = 0;
for (int i = 0; i < N; i++) {
int tmp = i - A[i];
auto itr = dist.find(tmp);
if (itr != dist.end()) {
c... | #include <bits/stdc++.h>
int main() {
int N;
std::cin >> N;
std::vector<int> A(N);
for (int i = 0; i < N; i++) {
std::cin >> A[i];
}
std::map<int, int> dist;
long long cnt = 0;
for (int i = 0; i < N; i++) {
int tmp = i - A[i];
auto itr = dist.find(tmp);
if (itr != dist.end()) {
c... | [["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]] | 1 | 184 |
n, *A = map(int, open(0).read().split())
ans = 0
for i, a in enumerate(A, 1):
x, y = i+a, i-a
d[x] = d.get(x, 0)+1
ans += d.get(y, 0)
print(ans) | n, *A = map(int, open(0).read().split())
ans, d = 0, {}
for i, a in enumerate(A, 1):
x, y = i+a, i-a
d[x] = d.get(x, 0)+1
ans += d.get(y, 0)
print(ans) | [["+", 0, 656, 0, 1, 0, 662, 31, 684, 0, 21], ["+", 0, 656, 0, 1, 0, 662, 31, 684, 0, 22], ["+", 0, 656, 0, 1, 0, 662, 12, 432, 0, 21], ["+", 0, 1, 0, 662, 12, 432, 0, 680, 0, 45], ["+", 0, 1, 0, 662, 12, 432, 0, 680, 0, 46]] | 5 | 77 |
# 二分探索モジュール bisect
# 添字はiとjの分で相殺(本当の添字は+1が必要だが[(i+1)-(j+1)]なのでいらない(以下は式変形))
import bisect
N = int(input())
A = list(map(int, input().split()))
X = [A[i]+i for i in range(N)]
Y = [j - A[j] for j in range(N)]
ans = 0
X.sort()
for i in range(N):
ans += bisect.bisect_left(Y,X[i]) - bisect.bisect_right(Y,X[i])
print(ans... | # 二分探索モジュール bisect
# 添字はiとjの分で相殺(本当の添字は+1が必要だが[(i+1)-(j+1)]なのでいらない(以下は式変形))
import bisect
N = int(input())
A = list(map(int, input().split()))
X = [A[i]+i for i in range(N)]
Y = [j - A[j] for j in range(N)]
ans = 0
Y.sort()
for i in range(N):
ans += bisect.bisect_right(Y,X[i]) - bisect.bisect_left(Y,X[i])
print(ans... | [["-", 0, 656, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 0, 656, 0, 1, 0, 652, 63, 319, 500, 22], ["-", 0, 677, 12, 657, 31, 652, 63, 319, 319, 22], ["+", 0, 677, 12, 657, 31, 652, 63, 319, 319, 22], ["-", 0, 677, 12, 657, 12, 652, 63, 319, 319, 22], ["+", 0, 677, 12, 657, 12, 652, 63, 319, 319, 22]] | 5 | 111 |
// int a = stoi(c); 文字列をintへ
//小文字から大文字
// transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
// map<キー,値> p は辞書。p[キー] = 値
// map 全探索
// auto begin = p.begin(), end = p.end();
// for (auto it = begin; it != end; it++) {}
// mapのキー:it->first mapのバリュー:it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
... | // int a = stoi(c); 文字列をintへ
//小文字から大文字
// transform(a.begin(), a.end(), a.begin(), ::toupper);
//数値計算 個数以外はdouble
// map<キー,値> p は辞書。p[キー] = 値
// map 全探索
// auto begin = p.begin(), end = p.end();
// for (auto it = begin; it != end; it++) {}
// mapのキー:it->first mapのバリュー:it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
... | [["-", 0, 27, 28, 69, 341, 342, 0, 16, 17, 72], ["+", 0, 27, 28, 69, 341, 342, 0, 16, 17, 33]] | 1 | 576 |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define Mod 1000000007
int main() {
ll n;
cin >> n;
ll h[n];
for (int i = 0; i < n; ++i) {
cin >> h[i];
}
vector<ll> sa;
for (ll j = 0; j < n; ++j) {
sa.push_back(j - h[j]);
}
ll ans = 0;
sort(sa.begin(), sa.end());
for (l... | #include <bits/stdc++.h>
#define ll long long
using namespace std;
#define Mod 1000000007
int main() {
ll n;
cin >> n;
ll h[n];
for (int i = 0; i < n; ++i) {
cin >> h[i];
}
vector<ll> sa;
for (ll j = 0; j < n; ++j) {
sa.push_back(j - h[j]);
}
ll ans = 0;
sort(sa.begin(), sa.end());
for (l... | [["-", 0, 1, 0, 16, 31, 16, 12, 16, 17, 85], ["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]] | 1 | 181 |
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define int long long... | #include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define int long long... | [["+", 0, 1, 0, 2, 3, 4, 0, 103, 0, 104]] | 1 | 789 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define all(c) begin(c), end(c)
template <typename T1, typename T2> bool chmax(T1 &a, T2 b) {
if (a < b) {
a = b;
return true;
} else
return false;
}
template <typename T1, typename T2> bool ... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define all(c) begin(c), end(c)
template <typename T1, typename T2> bool chmax(T1 &a, T2 b) {
if (a < b) {
a = b;
return true;
} else
return false;
}
template <typename T1, typename T2> bool ... | [["+", 8, 9, 0, 1, 0, 27, 28, 23, 0, 24], ["+", 8, 9, 0, 1, 0, 27, 28, 23, 0, 25]] | 1 | 497 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;... | [["-", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22]] | 1 | 989 |
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b) \
for (int i = 0; i <= a; i++) \
for (int j = 0; j <= b; j++) \
... | #include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define initdp(a, b) \
for (int i = 0; i <= a; i++) \
for (int j = 0; j <= b; j++) \
... | [["-", 0, 14, 8, 9, 0, 9, 0, 43, 0, 21], ["+", 0, 14, 8, 9, 0, 9, 0, 43, 0, 35], ["+", 0, 14, 8, 9, 0, 9, 0, 43, 39, 40], ["-", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 68]] | 1 | 503 |
#include <bits/stdc++.h>
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) _range(i, 0, n)
#define _range(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload(__VA_ARGS__, _range, _rep, )(__VA_ARGS__)
#define _rrep(i, n) _rrange(i, 0, n)
#define _rrange(i, a, b) for (int i = (i... | #include <bits/stdc++.h>
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) _range(i, 0, n)
#define _range(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload(__VA_ARGS__, _range, _rep, )(__VA_ARGS__)
#define _rrep(i, n) _rrange(i, 0, n)
#define _rrange(i, a, b) for (int i = (i... | [["-", 0, 34, 12, 27, 28, 69, 341, 342, 0, 22], ["+", 0, 34, 12, 27, 28, 69, 341, 342, 0, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 2, 63, 22], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 147], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["-", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35]] | 1 | 1,732 |
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a... | #include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a... | [["+", 0, 1, 0, 2, 3, 4, 0, 103, 0, 104]] | 1 | 657 |
N, A, B, C = gets.split.map(&:to_i)
S = N.times.map { gets.chomp }
ans = []
counter = Hash.new(0)
counter['A'] = A
counter['B'] = B
counter['C'] = C
N.times do |i|
s1, s2 = S[i].chars
if counter[s1] == 0 && counter[s2] == 0
puts 'No'
exit
end
if i == N - 1
if counter[s1] < counter[s2]
coun... | N, A, B, C = gets.split.map(&:to_i)
S = N.times.map { gets.chomp }
ans = []
counter = Hash.new(0)
counter['A'] = A
counter['B'] = B
counter['C'] = C
N.times do |i|
s1, s2 = S[i].chars
if counter[s1] == 0 && counter[s2] == 0
puts 'No'
exit
end
if i == N - 1
if counter[s1] < counter[s2]
coun... | [["+", 75, 95, 0, 662, 12, 652, 486, 739, 0, 24], ["+", 75, 95, 0, 662, 12, 652, 486, 739, 0, 25], ["+", 0, 121, 75, 95, 0, 662, 12, 652, 17, 131], ["+", 0, 121, 75, 95, 0, 662, 12, 652, 735, 22]] | 4 | 297 |
N, A, B, C = map(int, input().split())
v = [A, B, C]
s = [-1 for i in range(N)]
for i in range(N):
t = input()
print(t)
if t == "AB":
s[i] = 0
if t == "BC":
s[i] = 1
if t == "AC":
s[i] = 2
ans = [-1 for i in range(N)]
OK = True
for i in range(N):
p = s[i]
q = (s[i]+1... | N, A, B, C = map(int, input().split())
v = [A, B, C]
s = [-1 for i in range(N)]
for i in range(N):
t = input()
if t == "AB":
s[i] = 0
if t == "BC":
s[i] = 1
if t == "AC":
s[i] = 2
ans = [-1 for i in range(N)]
OK = True
for i in range(N):
p = s[i]
q = (s[i]+1)%3
if v[... | [["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 335 |
#include <bits/stdc++.h>
using namespace std;
int n, a, b, c;
string s[100005];
char ans[100005];
void print() {
cout << "Yes" << endl;
for (int i = 1; i <= n; i++)
cout << ans[i] << endl;
}
void check() {
for (int i = 1; i <= n; i++) {
if (s[i] == "AB") {
if (a == 0 && b == 0) {
cout << "No... | #include <bits/stdc++.h>
using namespace std;
int n, a, b, c;
string s[100005];
char ans[100005];
void print() {
cout << "Yes" << endl;
for (int i = 1; i <= n; i++)
cout << ans[i] << endl;
}
void check() {
for (int i = 1; i <= n; i++) {
if (s[i] == "AB") {
if (a == 0 && b == 0) {
cout << "No... | [["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 60]] | 1 | 653 |
// header {{{
#include <bits/stdc++.h>
using namespace std;
// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF INT_MAX / 3
#define LLINF LLONG_MAX / 3
#define MOD (1000000007LL)
#define MODA(a, b) a = ((a) + (b)) % MOD
#define MODP(a, b) a = ((a) * (b)) % MOD
#define inc(i, l, r) for (int i = (l); i < (r); i++)
#define dec(... | // header {{{
#include <bits/stdc++.h>
using namespace std;
// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF INT_MAX / 3
#define LLINF LLONG_MAX / 3
#define MOD (1000000007LL)
#define MODA(a, b) a = ((a) + (b)) % MOD
#define MODP(a, b) a = ((a) * (b)) % MOD
#define inc(i, l, r) for (int i = (l); i < (r); i++)
#define dec(... | [["-", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46], ["+", 75, 76, 0, 9, 0, 57, 64, 9, 0, 46], ["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46]] | 1 | 700 |
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <vector>
using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constex... | #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <vector>
using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constex... | [["-", 0, 57, 15, 339, 51, 16, 12, 5, 0, 6], ["+", 0, 57, 15, 339, 51, 16, 12, 5, 0, 6], ["-", 64, 9, 0, 1, 0, 34, 31, 27, 28, 22], ["+", 64, 9, 0, 1, 0, 34, 31, 27, 28, 22], ["-", 64, 9, 0, 1, 0, 11, 12, 103, 0, 125], ["+", 64, 9, 0, 1, 0, 11, 12, 103, 0, 125], ["-", 0, 9, 0, 1, 0, 34, 31, 27, 28, 22], ["+", 0, 9, 0, ... | 1 | 686 |
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i, m, n) for (lli i = m; i < n; i++)
#define rrep(i, m, n) for (lli i = m - 1; i... | #include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i, m, n) for (lli i = m; i < n; i++)
#define rrep(i, m, n) for (lli i = m - 1; i... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 687 |
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tupl... | #include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tupl... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22]] | 1 | 1,394 |
#
# ⋀_⋀
# (・ω・)
# ./ U ∽ U\
# │* 合 *│
# │* 格 *│
# │* 祈 *│
# │* 願 *│
# │* *│
#  ̄
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないyp
from heapq import heappop, heappush, heappushpop
from collections import Counter,default... | #
# ⋀_⋀
# (・ω・)
# ./ U ∽ U\
# │* 合 *│
# │* 格 *│
# │* 祈 *│
# │* 願 *│
# │* *│
#  ̄
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないyp
from heapq import heappop, heappush, heappushpop
from collections import Counter,default... | [["-", 75, 665, 15, 23, 0, 679, 31, 666, 667, 18], ["+", 75, 665, 15, 23, 0, 679, 31, 666, 667, 47]] | 5 | 685 |
n,a,b,c = map(int,input().split())
s = [input() for i in range(n)]+[0]
# if [a,b,c].count(0) >= 2:
# print("No")
ans = ""
# print("Yes")
for i in range(n):
if s[i] == "AB":
if a==1 and b==1:
if s[i+1] =="BC":
ans+="B"
b+=1
a-=1
elif a<... | n,a,b,c = map(int,input().split())
s = [input() for i in range(n)]+[0]
# if [a,b,c].count(0) >= 2:
# print("No")
ans = ""
# print("Yes")
for i in range(n):
if s[i] == "AB":
if a==1 and b==1 and s[i+1] =="BC":
ans+="B"
b+=1
a-=1
elif a<=b:
ans+="A"... | [["-", 8, 196, 0, 57, 64, 196, 0, 57, 0, 102], ["-", 64, 196, 0, 57, 64, 196, 0, 57, 0, 121], ["+", 0, 57, 64, 196, 0, 57, 15, 679, 17, 355]] | 5 | 303 |
#include <bits/stdc++.h>
#define ll long long
#define dl double
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define rep(i, a, b) for (i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define mod 1000000007LL
#define CIN(V, s, n) ... | #include <bits/stdc++.h>
#define ll long long
#define dl double
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define rep(i, a, b) for (i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define mod 1000000007LL
#define CIN(V, s, n) ... | [["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]] | 1 | 918 |
#include <algorithm>
#include <array>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctype.h>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stac... | #include <algorithm>
#include <array>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctype.h>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stac... | [["+", 0, 57, 64, 9, 0, 1, 0, 2, 63, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35]] | 1 | 8,000 |
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, st[3];
cin >> n >> st[0] >> st[1] >> st[2];
vector<string> inp(n);
vector<char>... | #pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, st[3];
cin >> n >> st[0] >> st[1] >> st[2];
vector<string> inp(n);
vector<char>... | [["-", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 57, 64, 1, 0, 16, 12, 5, 0, 6], ["-", 0, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 696 |
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
int N, A, B, C;
cin >> N >> A >> B >> C;
vector<int> s(N);
... | #include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
int N, A, B, C;
cin >> N >> A >> B >> C;
vector<int> s(N);
... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22]] | 1 | 388 |
def f(A, i, j, k, nex,res):
if A[i] == A[j] == 0:
print("No")
exit()
elif A[i] == A[j] == 1 and A[k] == 0:
if i in nex:
A[i] += 1
A[j] -= 1
return "ABC"[i]
else:
A[i] -= 1
A[j] += 1
return "ABC"[j]
else:
... | def f(A, i, j, k, nex,res):
if A[i] == A[j] == 0:
print("No")
exit()
elif A[i] == A[j] == 1 and A[k] == 0:
if i in nex:
A[i] += 1
A[j] -= 1
return "ABC"[i]
else:
A[i] -= 1
A[j] += 1
return "ABC"[j]
else:
... | [["+", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 8, 196, 0, 1, 0, 662, 12, 634, 0, 70], ["+", 8, 196, 0, 1, 0, 662, 12, 634, 0, 73]] | 5 | 465 |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxs = 2e5 + 5;
const ll lmaxs = 20;
ll mod = 1e9 + 7;
ll oo = 1e15;
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxs = 2e5 + 5;
const ll lmaxs = 20;
ll mod = 1e9 + 7;
ll oo = 1e15;
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(... | [["-", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6]] | 1 | 501 |
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
//#include <numeric>
#pragma w... | #include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
//#include <numeric>
#pragma w... | [["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]] | 1 | 678 |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#incl... | #include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#incl... | [["-", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 28, 22]] | 1 | 628 |
import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
sys.setrecursionlimit(500000)
N,A,B,C = map(int,input().split())
ABC = [A,B,C]
S = []
SS = ('A','B','C')
d = [0,0,0]
flag = True
for i in range(N):
s = input()
if s=="AB":
S.appen... | import sys, copy, math, heapq, bisect
from itertools import accumulate
from collections import deque, defaultdict, Counter
sys.setrecursionlimit(500000)
N,A,B,C = map(int,input().split())
ABC = [A,B,C]
S = []
SS = ('A','B','C')
d = [0,0,0]
flag = True
for i in range(N):
s = input()
if s=="AB":
S.appen... | [["-", 0, 57, 64, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 0, 22]] | 5 | 412 |
"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/), cid = 0;
function next(a) { return a ? cin[cid++] : +cin[cid++]; }
function nexts(n, a) {
return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a);
}
function nextm(h, w, a) {
var r = [], i ... | "use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/), cid = 0;
function next(a) { return a ? cin[cid++] : +cin[cid++]; }
function nexts(n, a) {
return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a);
}
function nextm(h, w, a) {
var r = [], i ... | [["-", 64, 1, 0, 2, 3, 3, 0, 557, 0, 491], ["+", 64, 1, 0, 2, 3, 3, 0, 557, 0, 491], ["-", 0, 1, 0, 2, 3, 3, 0, 557, 0, 491], ["+", 0, 1, 0, 2, 3, 3, 0, 557, 0, 491]] | 2 | 787 |
n,a,b,c=gets.split.map(&:to_i)
l=[]
ss=[]
n.times do
ss << gets.chomp
end
n.times do |i|
s=ss[i]
if s=="AB"
if a<b||(a==b&&i<n-1&&s[i+1]=="AC")
a+=1
l << "A"
b-=1
if b<0
puts "No"
exit
end
else
b+=1
l << "B"
a-=1
if a<0
puts "No... | n,a,b,c=gets.split.map(&:to_i)
l=[]
ss=[]
n.times do
ss << gets.chomp
end
n.times do |i|
s=ss[i]
if s=="AB"
if a<b||(a==b&&i<n-1&&ss[i+1]=="AC")
a+=1
l << "A"
b-=1
if b<0
puts "No"
exit
end
else
b+=1
l << "B"
a-=1
if a<0
puts "N... | [["-", 12, 739, 0, 738, 12, 738, 31, 742, 500, 22], ["+", 12, 739, 0, 738, 12, 738, 31, 742, 500, 22]] | 4 | 287 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.