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
#include <algorithm> #include <iostream> #include <math.h> #include <string> #include <utility> #include <vector> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, ans; ans = 1; cin >> N; vector<string> vec(N); for (int i = 0; i < N; i++) { cin >> vec.at(i); } so...
#include <algorithm> #include <iostream> #include <math.h> #include <string> #include <utility> #include <vector> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, ans; ans = 1; cin >> N; vector<string> vec(N); for (int i = 0; i < N; i++) { cin >> vec.at(i); } so...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
145
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> S(200010); int counter = 0; for (int i = 0; i < N; i++) { cin >> S.at(i); } sort(S.begin(), S.end()); reverse(S.begin(), S.end()); for (int i = 0; i < N - 1; i++) { if (S.at(i) != S.at(i + 1)) { ...
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> S(200010); int counter = 0; for (int i = 0; i < N; i++) { cin >> S.at(i); } sort(S.begin(), S.end()); reverse(S.begin(), S.end()); for (int i = 0; i < N - 1; i++) { if (S.at(i) != S.at(i + 1)) { ...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
135
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> S(N); int count = 0; for (int i = 0; i < N; i++) { cin >> S.at(i); } sort(S.begin(), S.end()); for (int i = 0; i < N - 1; i++) { if (S.at(i) == S.at(i++)) count++; } cout << N - count; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> S(N); int count = 0; for (int i = 0; i < N; i++) { cin >> S.at(i); } sort(S.begin(), S.end()); for (int i = 0; i < N - 1; i++) { if (S.at(i) == S.at(i + 1)) count++; } cout << N - count; }
[["-", 51, 16, 12, 2, 3, 4, 0, 27, 17, 29], ["+", 51, 16, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 51, 16, 12, 2, 3, 4, 0, 16, 12, 13]]
1
117
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; unordered_set<int> ans; for (int i = 0; i < n; ++i) { int temp = 0; cin >> temp; ans.insert(temp); } cout << ans.size() << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; unordered_set<string> ans; for (int i = 0; i < n; ++i) { string temp; cin >> temp; ans.insert(temp); } cout << ans.size() << endl; }
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78], ["-", 8, 9, 0, 7, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 7, 8, 9, 0, 43, 39, 78], ["-", 0, 7, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 7, 8, 9, 0, 43, 49, 50, 51, 13]]
1
67
#include <bits/stdc++.h> using namespace std; using ll = long long int; int main(void) { cout << fixed << setprecision(16); cin.tie(0); ios::sync_with_stdio(false); ll n; set<string> s; while (n--) { string t; cin >> t; s.insert(t); } cout << s.size() << endl; }
#include <bits/stdc++.h> using namespace std; using ll = long long int; int main(void) { cout << fixed << setprecision(16); cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; set<string> s; while (n--) { string t; cin >> t; s.insert(t); } cout << s.size() << endl; }
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
83
N = int(input()) li = [] while len(li) <N: li.append(input()) print(len(set(lottery)))
N = int(input()) li = [] while len(li) <N: li.append(input()) print(len(set(li)))
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
5
38
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> S(N); for (int i = 0; i < N; i++) { cin >> S.at(i); } sort(S.begin(), S.end()); int count = N; for (int i = 1; i < N; i++) { if (S.at(0) == S.at(i)) { count--; } } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<string> S(N); for (int i = 0; i < N; i++) { cin >> S.at(i); } sort(S.begin(), S.end()); int count = N; for (int i = 1; i < N; i++) { if (S.at(i - 1) == S.at(i)) { count--; } } cout << count << endl; ...
[["-", 15, 339, 51, 16, 31, 2, 3, 4, 0, 13], ["+", 51, 16, 31, 2, 3, 4, 0, 16, 31, 22], ["+", 51, 16, 31, 2, 3, 4, 0, 16, 17, 33], ["+", 51, 16, 31, 2, 3, 4, 0, 16, 12, 13]]
1
116
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Set<String> set = new HashSet<>(); for (int i = 0; i < n; i++) { String s = sc.nextLine(); set.add(s); } sc.close(); System.out.print...
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); Set<String> set = new HashSet<>(); for (int i = 0; i < n; i++) { String s = sc.next(); set.add(s); } sc.close(); System.out.println(s...
[["-", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22]]
3
108
#include <bits/stdc++.h> using namespace std; int main() { int N, k; map<string, int> score; string s = " "; for (int i = 0; i < N; i++) { cin >> s; score[s] = 0; } k = score.size(); cout << k << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N, k; cin >> N; map<string, int> score; string s = " "; for (int i = 0; i < N; i++) { cin >> s; score[s] = 1; } k = score.size(); cout << k << endl; }
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["-", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13]]
1
73
n = int(input()) obj= [] for i in range (n): obj.append(input()) dictOfElems = dict() for elem in obj: if elem in dictOfElems: dictOfElems[elem] += 1 else: dictOfElems[elem] = 1 print(len(dict))
n = int(input()) obj= [] for i in range (n): obj.append(input()) dictOfElems = dict() for elem in obj: if elem in dictOfElems: dictOfElems[elem] += 1 else: dictOfElems[elem] = 1 print(len(dictOfElems))
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
5
64
#include <bits/stdc++.h> using namespace std; using lint = long long int; using pint = pair<int, int>; using plint = pair<lint, lint>; struct fast_ios { fast_ios() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define ALL(x) (x).begin(), (x).end() #define ...
#include <bits/stdc++.h> using namespace std; using lint = long long int; using pint = pair<int, int>; using plint = pair<lint, lint>; struct fast_ios { fast_ios() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define ALL(x) (x).begin(), (x).end() #define ...
[["+", 0, 1, 0, 16, 31, 16, 12, 16, 17, 72], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 13]]
1
224
import collections n = int(input()) a = [list(input() for i in range(n))] b = collections.Counter(a) print(len(b))
import collections n = int(input()) a = [input() for i in range(n)] b = collections.Counter(a) print(len(b))
[["-", 0, 1, 0, 662, 12, 634, 0, 652, 63, 22], ["-", 0, 662, 12, 634, 0, 652, 3, 668, 0, 24], ["-", 3, 668, 0, 659, 12, 652, 3, 4, 0, 25]]
5
42
import math def main(): n = input() s = {} print(n) while int(n)>0: m = input() if m in s: s[m]+=1 else: s[m]=1 n = int(n) - 1 print(len(s)) return 0 main()
import math def main(): n = input() s = {} while int(n)>0: m = input() if m in s: s[m]+=1 else: s[m]=1 n = int(n) - 1 print(len(s)) return 0 main()
[["-", 0, 14, 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
72
#include <bits/stdc++.h> using namespace std; int main() { int n; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s.at(i); } int ans = 1; sort(s.begin(), s.end()); for (int i = 0; i < n - 1; i++) { if (s.at(i) != s.at(i + 1)) { ans++; } } cout << ans << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s.at(i); } int ans = 1; sort(s.begin(), s.end()); for (int i = 0; i < n - 1; i++) { if (s.at(i) != s.at(i + 1)) { ans++; } } cout << ans << endl; }...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
116
n = int(input()) s = [] s_append = s.append for i in range(n): s_append(i) print(len(set(s)))
n = int(input()) s = [] s_append = s.append for i in range(n): s_append(input()) print(len(set(s)))
[["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 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
39
import collections N=int(input()) list=[input() for i in range(N)] c= collections.Counter(list) m=0 for i in c.values(): m+=i print(m)
import collections N=int(input()) list=[input() for i in range(N)] c= collections.Counter(list) m=0 for i in c.values(): m+=1 print(m)
[["-", 0, 7, 8, 196, 0, 1, 0, 677, 12, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 12, 612]]
5
51
N = int(input()) items = [] for i in range(N): item = input() items.append(item) items.sort() cnt = 0 before = "" for index,item in enumerate(items): if index == 0: cnt += 1 before = item elif before != item: cnt += 1 print(cnt)
N = int(input()) items = [] for i in range(N): item = input() items.append(item) items.sort() cnt = 0 before = "" for index,item in enumerate(items): if index == 0: cnt += 1 elif before != item: cnt += 1 before = item print(cnt)
[["-", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["-", 0, 57, 64, 196, 0, 1, 0, 662, 12, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 12, 22]]
5
76
from collections import Counter n = int(input()) items = [] for _ in range(n): items.append(input()) freq = Counter(items) print(len(items))
from collections import Counter n = int(input()) items = [] for _ in range(n): items.append(input()) freq = Counter(items) print(len(freq))
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
5
45
import pandas as pd n = int(input()) s = [input() for _ in range(n)] x = set(s) print(len(x))
n = int(input()) s = [input() for _ in range(n)] x = set(s) print(len(x))
[["-", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["-", 0, 656, 0, 596, 141, 704, 141, 673, 0, 22], ["-", 36, 36, 0, 656, 0, 596, 141, 704, 0, 272], ["-", 36, 36, 0, 656, 0, 596, 141, 704, 705, 22]]
5
39
// 失敗するからこそ // そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから #ifdef DAIJOBU #include "/home/v-o_o-v/deb.h" #define deb(x...) \ cerr << "[" << #x << "] = ["; \ _print(x) #else #include <bits/stdc++.h> #define deb(x......
// 失敗するからこそ // そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから #ifdef DAIJOBU #include "/home/v-o_o-v/deb.h" #define deb(x...) \ cerr << "[" << #x << "] = ["; \ _print(x) #else #include <bits/stdc++.h> #define deb(x......
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
205
n=int(input()) l=[input() for i in range(n)] print(len(set()))
n=int(input()) l=[input() for i in range(n)] print(len(set(l)))
[["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 22]]
5
31
count = gets.chomp.to_i table = {} count.times do |i| s = gets.chomp unless table[s] table[s] = true end end gets table.length
count = gets.chomp.to_i table = {} count.times do |i| s = gets.chomp unless table[s] table[s] = true end end puts table.length
[["-", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["+", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22]]
4
40
n = int(input()) li = [] count = 0 for i in range(n): li.append(input()) li.sort() print(li) for i in range(n-1): if li[i] == li[i+1]: count += 1 print(n-count)
n = int(input()) li = [] count = 0 for i in range(n): li.append(input()) li.sort() for i in range(n-1): if li[i] == li[i+1]: count += 1 print(n-count)
[["-", 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
72
n = int(input()) ls = [] count = 0 for x in range(n): ls.append(input()) set(ls) print(len(ls))
n = int(input()) ls = [] count = 0 for x in range(n): ls.append(input()) ls = set(ls) print(len(ls))
[["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 0, 32]]
5
42
num=int(input()) list=[] for i in range(num): a=input() list.append(a) b=set(a) print(len(b))
num=int(input()) list=[] for i in range(num): a=input() list.append(a) b=set(list) print(len(b))
[["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]]
5
44
#include <iostream> using namespace std; #include <algorithm> #include <map> #include <set> #include <string> #include <vector> typedef long long ll; #include <cmath> #include <cstdio> #include <iomanip> int main(int argc, char *argv[]) { int n; set<string> a; for (int i = 0; i < n; i++) { string s; cin...
#include <iostream> using namespace std; #include <algorithm> #include <map> #include <set> #include <string> #include <vector> typedef long long ll; #include <cmath> #include <cstdio> #include <iomanip> int main(int argc, char *argv[]) { int n; cin >> n; set<string> a; for (int i = 0; i < n; i++) { strin...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
93
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (n); i++) #define ll long long using namespace std; int main() { ll n; vector<string> s; cin >> n; rep(i, n) { string a; cin >> a; s.push_back(a); } sort(s.begin(), s.end()); ll begin = 0, ans = n; for (int i = 1; i < n; i+...
#include <bits/stdc++.h> #define rep(i, n) for (long long i = 0; i < (n); i++) #define ll long long using namespace std; int main() { ll n; vector<string> s; cin >> n; rep(i, n) { string a; cin >> a; s.push_back(a); } sort(s.begin(), s.end()); ll begin = 0, ans = n; for (int i = 1; i < n; i+...
[["-", 75, 76, 0, 1, 0, 11, 12, 16, 17, 72], ["-", 75, 76, 0, 1, 0, 11, 12, 16, 12, 13]]
1
137
numOfStr= int(input()) strlist = [] total = 0 for i in range(0,numOfStr): strlist.append(input()) strlist.sort() for i in range(1,numOfStr): if strlist[i] != strlist[i-1]: total += 1 print(total)
numOfStr= int(input()) strlist = [] total = 1 for i in range(0,numOfStr): strlist.append(input()) strlist.sort() for i in range(1,numOfStr): if strlist[i] != strlist[i-1]: total += 1 print(total)
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
5
68
#include <bits/stdc++.h> #define ll long long #define inf 0x7fffffff #define infll 0x7fffffffffffffff #define clr(c) memset(c, 0, sizeof(c)) using namespace std; int mod = 998244353; const int M = 1e6 + 10; const int N = 2e5 + 10; inline ll read() { ll b = 1, sum = 0; char c = getchar(); while (!isdigit(c)) { ...
#include <bits/stdc++.h> #define ll long long #define inf 0x7fffffff #define infll 0x7fffffffffffffff #define clr(c) memset(c, 0, sizeof(c)) using namespace std; int mod = 998244353; const int M = 1e6 + 10; const int N = 2e5 + 10; inline ll read() { ll b = 1, sum = 0; char c = getchar(); while (!isdigit(c)) { ...
[["-", 64, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 64, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 57, 64, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 17, 19], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 17, 72], ["+", 49, 50, 51, 2, 3, 4, 0, 16, 12, 13]]
1
475
#include <algorithm> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> //#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a), i##formax = (b); i < i##formax; i++) typedef long long ll; int main() { int n; cin >> n; vector<int> vec(n); FOR(i,...
#include <algorithm> #include <iostream> #include <list> #include <map> #include <math.h> #include <queue> //#include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a), i##formax = (b); i < i##formax; i++) typedef long long ll; int main() { int n; cin >> n; vector<string> vec(n); FOR...
[["-", 0, 43, 39, 344, 3, 347, 0, 77, 39, 40], ["+", 0, 43, 39, 344, 3, 347, 0, 77, 39, 78]]
1
126
io = STDINa n=io.gets.to_i hash=Hash.new{|h,k|h[k]=0} n.times do hash[io.gets.chomp]+=1 end puts hash.size
io = STDIN n=io.gets.to_i hash=Hash.new{|h,k|h[k]=0} n.times do hash[io.gets.chomp]+=1 end puts hash.size
[["-", 36, 36, 36, 36, 0, 493, 0, 662, 12, 743], ["+", 36, 36, 36, 36, 0, 493, 0, 662, 12, 743]]
4
47
def gacha(sl): print(len(set(sl))) n = int(input()) sl = [] for _ in range(n): sl.append(input()) print(sl) gacha(sl)
def gacha(sl): print(len(set(sl))) n = int(input()) sl = [] for _ in range(n): sl.append(input()) # print(sl) gacha(sl)
[["-", 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
52
x=set() c=0 n=int(input()) for i in range(0,n): s=input() if s in x: pass else: x.add(s) c+=1
x=set() c=0 n=int(input()) for i in range(0,n): s=input() if s in x: pass else: x.add(s) c+=1 print(c)
[["+", 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
48
#include <bits/stdc++.h> #define N 200009 using namespace std; typedef long long ll; int main() { // freopen("in.txt", "r", stdin); int n; set<string> s; while (n--) { string a; cin >> a; s.insert(a); } cout << s.size(); return 0; }
#include <bits/stdc++.h> #define N 200009 using namespace std; typedef long long ll; int main() { // freopen("in.txt", "r", stdin); int n; cin >> n; set<string> s; while (n--) { string a; cin >> a; s.insert(a); } cout << s.size(); return 0; }
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
62
n = int(input()) s = set() for i in s: s.add(input()) print(len(s))
n = int(input()) s = set() for i in range(n): s.add(input()) print(len(s))
[["-", 36, 36, 36, 36, 0, 656, 0, 7, 12, 22], ["+", 36, 36, 0, 656, 0, 7, 12, 652, 63, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 24], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 25]]
5
33
n = int(input) lis = [input() for i in range(n)] print(len(set(lis)))
n = int(input()) lis = [input() for i in range(n)] print(len(set(lis)))
[["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
30
#include <bits/stdc++.h> #define rip(i, a, b) for (int i = a; i < b; i++) using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); set<string> g; int n; string s; while (n--) { cin >> s; g.insert(s); } cout << g.size(); return 0; }
#include <bits/stdc++.h> #define rip(i, a, b) for (int i = a; i < b; i++) using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); set<string> g; int n; string s; cin >> n; while (n--) { cin >> s; g.insert(s); } cout << g.size(); return 0; }
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
77
import collections N=int(input()) L=[input() for i in range(N)] C = collections.Counter(L) D = list(C.values()) E=sum(D) print(E)
import collections N=int(input()) L=[input() for i in range(N)] C = collections.Counter(L) D = list(C.values()) print(len(D))
[["-", 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, 652, 63, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, ...
5
52
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <string> #include <vector> using namespace std; int main() { int n; int cnt = 0; cin >> n; vector<string> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } sort(v.begin(), v.end()); for (in...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <limits> #include <string> #include <vector> using namespace std; int main() { int n; int cnt = 1; cin >> n; vector<string> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } sort(v.begin(), v.end()); for (in...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
131
#include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> PLL; #define rep(i, n) for (ll i = 0;...
#include <algorithm> #include <bitset> #include <cmath> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <stack> #include <string> #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> PLL; #define rep(i, n) for (ll i = 0;...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 12, 13]]
1
1,530
N = int(input()) n_list = [] for i in range(N): n_list.append(input()) print(len(dict(Counter(n_list))))
from collections import Counter N = int(input()) n_list = [] for i in range(N): n_list.append(input()) print(len(dict(Counter(n_list))))
[["+", 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
41
#include <iostream> #include <string> #include <unordered_set> using namespace std; int main() { int N; cin >> N; string S; unordered_set<string> A; for (int i = 0; i < N; i++) { cin >> S; A.insert(S); } cout << S.size() << endl; return 0; }
#include <iostream> #include <string> #include <unordered_set> using namespace std; int main() { int N; cin >> N; string S; unordered_set<string> A; for (int i = 0; i < N; i++) { cin >> S; A.insert(S); } cout << A.size() << endl; return 0; }
[["-", 0, 16, 31, 16, 12, 2, 63, 118, 28, 22], ["+", 0, 16, 31, 16, 12, 2, 63, 118, 28, 22]]
1
72
n=input() s=[0]*n for i in range(n): s[i]=input() se=set(s) print(len(se))
n=int(input()) s=[0]*n for i in range(n): s[i]=input() se=set(s) print(len(se))
[["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
41
// C++ program to find 3 elements such that max(abs(A[i]-B[j]), abs(B[j]- // C[k]), abs(C[k]-A[i])) is minimized. #include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define MOD 998244353 // Driver program int main() { int n; set<string> s; for (int i = 1; i <= n; i++) { ...
// C++ program to find 3 elements such that max(abs(A[i]-B[j]), abs(B[j]- // C[k]), abs(C[k]-A[i])) is minimized. #include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define MOD 998244353 // Driver program int main() { int n; cin >> n; set<string> s; for (int i = 1; i <...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
75
from collections import defaultdict def solve(): N = int(input()) A = [input() for _ in range(N)] d = defaultdict(int) for a in A: d[a] += 1 return len(d) # print(solve()) # def solve()が@return voidのとき solve()
from collections import defaultdict def solve(): N = int(input()) A = [input() for _ in range(N)] d = defaultdict(int) for a in A: d[a] += 1 return len(d) print(solve()) # def solve()が@return voidのとき #solve()
[["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
58
/* --------DO NOT COPY I REQUEST YOU PLEASE-------- AUTHOR : Chandan Agrawal College : Poornima College of Engg. jaipur, Raj Mail : chandanagrawal23@gmail.com ___ _ _ __ _ _ ____ __ _ _ / __)( )_( ) /__\ ( \( )( _ \ /__\ ( \( ) ( (__ ) _ ( /(__)\ ) ( )(_) )/(__)\ ) ( \___)(_) (_)(__...
/* --------DO NOT COPY I REQUEST YOU PLEASE-------- AUTHOR : Chandan Agrawal College : Poornima College of Engg. jaipur, Raj Mail : chandanagrawal23@gmail.com ___ _ _ __ _ _ ____ __ _ _ / __)( )_( ) /__\ ( \( )( _ \ /__\ ( \( ) ( (__ ) _ ( /(__)\ ) ( )(_) )/(__)\ ) ( \___)(_) (_)(__...
[["-", 0, 1, 0, 16, 12, 2, 63, 118, 28, 22], ["+", 0, 1, 0, 16, 12, 2, 63, 118, 28, 22]]
1
2,199
N = int(input()) ans = {} for i in range(N): ans.add(input()) print(len(ans))
N = int(input()) ans = set() for i in range(N): ans.add(input()) print(len(ans))
[["-", 0, 656, 0, 1, 0, 662, 12, 680, 0, 45], ["-", 0, 656, 0, 1, 0, 662, 12, 680, 0, 46], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
35
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define ld long double #define ull unsigned long long int #define ll long long int #define SPEED \ ios_base::sync_with_stdio(false); ...
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define ld long double #define ull unsigned long long int #define ll long long int #define SPEED \ ios_base::sync_with_stdio(false); ...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
405
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; typedef vector<string> vec; int main() { int n, ans = 0; cin >> n; vec s(n); rep(i, n) cin >> s[i]; sort(s.begin(), s.end()); for (int i = 1; i < n; i++) { if (s[i] != s[i - 1]) ans+...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) typedef long long ll; typedef vector<string> vec; int main() { int n, ans = 1; cin >> n; vec s(n); rep(i, n) cin >> s[i]; sort(s.begin(), s.end()); for (int i = 1; i < n; i++) { if (s[i] != s[i - 1]) ans+...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
117
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 1; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) cin >> s[i]; sort(s.begin(), s.end()); for (int i = 1; i < n; i++) { if (s[i] == s[i - 1]) ans++; } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, ans = 1; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) cin >> s[i]; sort(s.begin(), s.end()); for (int i = 1; i < n; i++) { if (s[i] != s[i - 1]) ans++; } cout << ans << endl; return 0; }
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79]]
1
110
from collections import defaultdict a = defaultdict(int) n = int(input()) for i in range(n): w = input() a[w] += 1 print(max(a.values()))
from collections import defaultdict a = defaultdict(int) n = int(input()) for i in range(n): w = input() a[w] += 1 print(len(a.items()))
[["-", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 652, 63, 22], ["-", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 319, 22]]
5
48
#include <bits/stdc++.h> using namespace std; int main() { int N; map<string, bool> acquired; cin >> N; int count = 0; for (int i = 0; i < N; i++) { string S; cin >> S; if (acquired.count(S) != 0) break; count++; acquired[S] = true; } cout << count << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int N; map<string, bool> acquired; cin >> N; int count = 0; for (int i = 0; i < N; i++) { string S; cin >> S; if (acquired.count(S) != 0) continue; count++; acquired[S] = true; } cout << count << endl; }
[["-", 0, 7, 8, 9, 0, 57, 64, 93, 0, 94], ["+", 0, 7, 8, 9, 0, 57, 64, 116, 0, 117]]
1
84
n=int(input()) #n,k=list(map(int,input().split())) ans=defaultdict(int) for i in range(n): s=input() ans[s]+=1 print(len(ans.keys()))
from collections import defaultdict n=int(input()) #n,k=list(map(int,input().split())) ans=defaultdict(int) for i in range(n): s=input() ans[s]+=1 print(len(ans.keys()))
[["+", 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
45
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<vector<int>> Graph; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; #define pi 3.14159265359 #define inf 2147483647 #define INF 9223372036854775807 #define mod 1000000007 #define mod2 998244353 ...
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<vector<int>> Graph; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; #define pi 3.14159265359 #define inf 2147483647 #define INF 9223372036854775807 #define mod 1000000007 #define mod2 998244353 ...
[["-", 8, 9, 0, 57, 64, 1, 0, 27, 17, 29], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 17, 107], ["+", 0, 57, 64, 1, 0, 11, 12, 118, 28, 22], ["+", 0, 57, 64, 1, 0, 11, 12, 118, 17, 131], ["+", 0, 57, 64, 1, 0, 11, 12, 118, 119, 120]]
1
386
S = input() N = len(S) counter = [0] * 2019 counter[0] = 1 T = 0 R = 1 for i in range(N): T = (T + R * int(S[n - i - 1])) % 2019 R = 10 * R % 2019 counter[T] += 1 ans = 0 for i in range(2019): m = counter[i] ans += m * (m - 1) // 2 print(ans)
S = input() N = len(S) counter = [0] * 2019 counter[0] = 1 T = 0 R = 1 for i in range(N): T = (T + R * int(S[N - i - 1])) % 2019 R = 10 * R % 2019 counter[T] += 1 ans = 0 for i in range(2019): m = counter[i] ans += m * (m - 1) // 2 print(ans)
[["-", 3, 4, 0, 206, 206, 657, 31, 657, 31, 22], ["+", 3, 4, 0, 206, 206, 657, 31, 657, 31, 22]]
5
104
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 dd=[(-1,0),(0,1),(1,0),(0,-1)] ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] # def LF(): return [float(x) for x in s...
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy sys.setrecursionlimit(10**7) inf=10**20 mod=10**9+7 dd=[(-1,0),(0,1),(1,0),(0,-1)] ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] # def LF(): return [float(x) for x in s...
[["-", 0, 7, 8, 196, 0, 57, 75, 665, 0, 683], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121]]
5
415
def egcd(a, b): """Returns a triple (g, x, y), such that ax + by = g = gcd(a,b). Assumes a, b >= 0, and that at least one of them is > 0. Bounds on output values: |x|, |y| <= max(a, b).""" if a == 0: return (b, 0, 1) else: g, y, x = egcd(b % a, a) return (g, x - (b // a...
def egcd(a, b): """Returns a triple (g, x, y), such that ax + by = g = gcd(a,b). Assumes a, b >= 0, and that at least one of them is > 0. Bounds on output values: |x|, |y| <= max(a, b).""" if a == 0: return (b, 0, 1) else: g, y, x = egcd(b % a, a) return (g, x - (b // a...
[["-", 0, 57, 64, 196, 0, 1, 0, 677, 12, 612], ["+", 64, 196, 0, 1, 0, 677, 12, 206, 51, 22], ["+", 64, 196, 0, 1, 0, 677, 12, 206, 0, 70], ["+", 64, 196, 0, 1, 0, 677, 12, 206, 206, 22], ["+", 64, 196, 0, 1, 0, 677, 12, 206, 0, 73]]
5
251
def inN(): return int(input()) def inL(): return list(map(int,input().split())) def inNL(n): return [list(map(int,input().split())) for i in range(n)] s = input() n = int(s) l = len(s) cnt = 0 mod = [0]*2019 m = 0 for i in range(l): m = (int(s[l-1-i])*pow(10,i,2019) + m)%2019 mod[m] += 1 cnt += mo...
def inN(): return int(input()) def inL(): return list(map(int,input().split())) def inNL(n): return [list(map(int,input().split())) for i in range(n)] s = input() n = int(s) l = len(s) cnt = 0 mod = [0]*2019 m = 0 for i in range(l): m = (int(s[l-1-i])*pow(10,i,2019) + m)%2019 mod[m] += 1 cnt += mo...
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21]]
5
186
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, n, m) for (int i = (int)(n); i <= (int)(m); i++) #define RFOR(i, n, m) for (int i = (int)(n); i >= (int)(m); i--) #define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++) #define RITR(x, c) for (__typeof(c....
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, n, m) for (int i = (int)(n); i <= (int)(m); i++) #define RFOR(i, n, m) for (int i = (int)(n); i >= (int)(m); i--) #define ITR(x, c) for (__typeof(c.begin()) x = c.begin(); x != c.end(); x++) #define RITR(x, c) for (__typeof(c....
[["+", 12, 69, 341, 342, 0, 16, 12, 16, 17, 109], ["+", 12, 69, 341, 342, 0, 16, 12, 16, 12, 22]]
1
803
package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func nextInt() int { sc.Scan() i, e := strconv.Atoi(sc.Text()) if e != nil { panic(e) } return i } func nextString() string { sc.Scan() return sc.Text() } func Reverse(s string) string { runes := []rune(s) for i...
package main import ( "bufio" "fmt" "os" "strconv" ) var sc = bufio.NewScanner(os.Stdin) func nextInt() int { sc.Scan() i, e := strconv.Atoi(sc.Text()) if e != nil { panic(e) } return i } func nextString() string { sc.Scan() return sc.Text() } func Reverse(s string) string { runes := []rune(s) for i...
[["+", 12, 432, 0, 2, 3, 4, 0, 446, 0, 447], ["+", 12, 432, 0, 2, 3, 4, 0, 446, 448, 78], ["-", 0, 431, 12, 432, 0, 2, 3, 4, 0, 21], ["-", 0, 431, 12, 432, 0, 2, 3, 4, 0, 22]]
7
345
s = input() n = len(s) dp = [0 for _ in range(n)] dp[-1] = int(s[-1]) memo = dp[-1] cnt_dic = {} tmp = 1 ans = 0 cnt_dic[0] = 1 for i in range(n-2, -1, -1): memo = (memo + int(s[i]) * pow(10, n-i-1, 2019)) % 2019 if not memo in cnt_dic: cnt_dic[memo] = 0 ans += cnt_dic[memo] cnt_dic[memo] += 1 ...
s = input() n = len(s) dp = [0 for _ in range(n)] dp[-1] = int(s[-1]) memo = 0 cnt_dic = {} tmp = 1 ans = 0 cnt_dic[0] = 1 for i in range(n-1, -1, -1): memo = (memo + int(s[i]) * pow(10, n-i-1, 2019)) % 2019 if not memo in cnt_dic: cnt_dic[memo] = 0 ans += cnt_dic[memo] cnt_dic[memo] += 1 print...
[["-", 0, 656, 0, 1, 0, 662, 12, 206, 51, 22], ["-", 0, 656, 0, 1, 0, 662, 12, 206, 0, 70], ["-", 0, 1, 0, 662, 12, 206, 206, 664, 17, 33], ["-", 0, 1, 0, 662, 12, 206, 206, 664, 28, 612], ["-", 0, 656, 0, 1, 0, 662, 12, 206, 0, 73], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 6...
5
132
import sys S = input()[::-1] c = [0] * 2019 c[0] = 1 num = 0 d = 1 for a in S: num += int(a) * d num %= 2019 d *= 10 d %= 2019 c[num] += 1 a = 0 for i in c: a += i * (i - 1) // 2
import sys S = input()[::-1] c = [0] * 2019 c[0] = 1 num = 0 d = 1 for a in S: num += int(a) * d num %= 2019 d *= 10 d %= 2019 c[num] += 1 a = 0 for i in c: a += i * (i - 1) // 2 print(a)
[["+", 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
79
# s = list(input()) s = list(str(10**200000)) n = len(s) ans = 0 s.reverse() # print(s) x = 1 tot = 0 count = [0]*2019 for i in range(n): count[tot]+=1 tot += int(s[i])*x # print(tot) tot %= 2019 ans += count[tot] x = x*10%2019 print(ans)
s = list(input()) # s = list(str(10**200000)) n = len(s) ans = 0 s.reverse() # print(s) x = 1 tot = 0 count = [0]*2019 for i in range(n): count[tot]+=1 tot += int(s[i])*x # print(tot) tot %= 2019 ans += count[tot] x = x*10%2019 print(ans)
[["-", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 31, 612], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 17, 578], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]]
5
86
#include <bits/stdc++.h> using namespace std; using lint = long long; template <typename T> using V = vector<T>; template <typename T> using VV = vector<vector<T>>; template <typename T> using VVV = vector<vector<vector<T>>>; #define rep(i, n) for (int i = 0; i < int(n); i++) #define repu(i, a, b, s) for (int i = int(...
#include <bits/stdc++.h> using namespace std; using lint = long long; template <typename T> using V = vector<T>; template <typename T> using VV = vector<vector<T>>; template <typename T> using VVV = vector<vector<vector<T>>>; #define rep(i, n) for (int i = 0; i < int(n); i++) #define repu(i, a, b, s) for (int i = int(...
[["+", 8, 9, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 17, 132], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 12, 22], ["+", 0, 14, 8, 9, 0, 9, 0, 1, 0, 35]]
1
283
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) using namespace std; typedef long long ll; typedef pair<int, int> P; const ll INF = 1LL << 60; const ll MOD = 2019; string S; int main() { cin >> S; reverse(S.begin(), S.end()); map<ll, ll> mp; mp[0] = 1; ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) using namespace std; typedef long long ll; typedef pair<int, int> P; const ll INF = 1LL << 60; const ll MOD = 2019; string S; int main() { cin >> S; reverse(S.begin(), S.end()); map<ll, ll> mp; mp[0] = 1; ...
[["+", 8, 9, 0, 9, 0, 1, 0, 11, 31, 22], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 17, 132], ["+", 8, 9, 0, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 9, 0, 1, 0, 35]]
1
189
s=input() l=len(s) se=dict() k=0 for i in range(l-1,-1,-1): k+=(pow(10,l-1-i,2019)*int(s[i])) k%=2019 if k in se: se[k]+=1 else: se[k]=1 ans=0 for j in se: if se[j]>1: ans+=(i*(i-1)//2) if j==0: ans+=i print(ans)
s=input() l=len(s) se=dict() k=0 for i in range(l-1,-1,-1): k+=(pow(10,l-1-i,2019)*int(s[i])) k%=2019 if k in se: se[k]+=1 else: se[k]=1 ans=0 for j in se: i=se[j] if i>1: ans+=(i*(i-1)//2) if j==0: ans+=i print(ans)
[["-", 0, 656, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 656, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22]]
5
122
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, a) for (int i = 0; i < (a); i++) const ll MOD = 1000000007; // const ll MOD=998244353; int cnt[2020]; int main() { string S; cin >> S; cnt[0] = 1; ll sum = 0, pre = 0, x = 1; for (int i = S.length() - 1; i >= 0; i--) { in...
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, a) for (int i = 0; i < (a); i++) const ll MOD = 1000000007; // const ll MOD=998244353; int cnt[2020]; int main() { string S; cin >> S; cnt[0] = 1; ll sum = 0, pre = 0, x = 1; for (int i = S.length() - 1; i >= 0; i--) { in...
[["-", 8, 9, 0, 1, 0, 16, 31, 23, 0, 24], ["-", 0, 1, 0, 16, 31, 23, 0, 42, 0, 108], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["-", 8, 9, 0, 1, 0, 16, 31, 23, 0, 25], ["-", 0, 7, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 1...
1
143
#include <bits/stdc++.h> typedef long long ll; const int INF = 1e9; const int MOD = 1e9 + 7; const ll LINF = 1e18; using namespace std; #define rep(i, a, b) for (int i = a; i < b; i++) #define rrep(i, a, b) for (int i = a; i <= b; i++) #define all(a) begin((a)), end((a)) #define uniq(c) (c).erase(unique(all((c))), e...
#include <bits/stdc++.h> typedef long long ll; const int INF = 1e9; const int MOD = 1e9 + 7; const ll LINF = 1e18; using namespace std; #define rep(i, a, b) for (int i = a; i < b; i++) #define rrep(i, a, b) for (int i = a; i <= b; i++) #define all(a) begin((a)), end((a)) #define uniq(c) (c).erase(unique(all((c))), e...
[["+", 0, 338, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 338, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 338, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 338, 8, 9, 0, 1, 0, 35]]
1
205
#include <iostream> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; int main() { string s; cin >> s; int n = s.size(), a = 0, b = 1, r[2019]; rep(i, 2019) r[i] = 0; rep(i, n) { a = (a + (s[n - 1 - i] - '0') * b) % 2019; b = (b * 10) % 2019; r[a]+...
#include <iostream> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef long long ll; int main() { string s; cin >> s; int n = s.size(), a = 0, b = 1, r[2019]; rep(i, 2019) r[i] = 0; rep(i, n) { a = (a + (s[n - 1 - i] - '0') * b) % 2019; b = (b * 10) % 2019; r[a]+...
[["+", 8, 9, 0, 43, 49, 50, 51, 69, 28, 22], ["+", 0, 43, 49, 50, 51, 69, 341, 342, 0, 70], ["+", 0, 43, 49, 50, 51, 69, 341, 342, 0, 73], ["-", 12, 16, 31, 16, 12, 23, 0, 16, 17, 72], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 17, 33]]
1
154
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def solve(S): dp = [0] * 2019 pow10 = 1 answer = 0 for x in S[::-1]: dp[0] += 1 x = x * pow10 % 2019 newdp = [0] * 2019 for i in range(x, 2019): ...
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines def solve(S): dp = [0] * 2019 pow10 = 1 answer = 0 for x in S[::-1]: dp[0] += 1 x = x * pow10 % 2019 newdp = [0] * 2019 for i in range(2019-x): ...
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 22]]
5
167
from collections import Counter S = str(input()) memo = [0] d = 0 mod = 2019 for s in S[::-1]: tmp = int(s) * pow(10, d, mod) % mod tmp = memo[-1] + tmp memo.appemd(tmp%mod) d += 1 c = Counter(memo) ans = sum(v * (v-1)/2 for v in c.values()) print(ans)
from collections import Counter S = str(input()) memo = [0] d = 0 mod = 2019 for s in S[::-1]: tmp = int(s) * pow(10, d, mod) % mod tmp = memo[-1] + tmp memo.append(tmp%mod) d += 1 c = Counter(memo) ans = sum(v * (v-1)/2 for v in c.values()) print(int(ans))
[["-", 8, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 8, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 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
103
#dpでできないかな? import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappus...
#dpでできないかな? import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappus...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
421
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, a, n) for (int i = a; i < n; i++) #define been(ix) (ix).begin(), (ix).end() using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; const ll INFL = 1e18; const int INF = 1001001001; typedef ...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) #define rep2(i, a, n) for (int i = a; i < n; i++) #define been(ix) (ix).begin(), (ix).end() using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<long long> vl; const ll INFL = 1e18; const int INF = 1001001001; typedef ...
[["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25]]
1
265
#include <bits/stdc++.h> using namespace std; typedef long long ll; string S; ll np[2020]; int main() { ios_base::sync_with_stdio(0); cin >> S; int p10 = 1; int vv = 0; np[0]++; for (int i = S.length() - 1; i >= 0; i--) { vv = (vv + p10 * (S[i] - '0')) % 2019; p10 = (10 * p10) % 2019; np[vv...
#include <bits/stdc++.h> using namespace std; typedef long long ll; string S; ll np[2020]; int main() { ios_base::sync_with_stdio(0); cin >> S; int p10 = 1; int vv = 0; np[0]++; for (int i = S.length() - 1; i >= 0; i--) { vv = (vv + p10 * (S[i] - '0')) % 2019; p10 = (10 * p10) % 2019; np[vv...
[["+", 12, 23, 0, 16, 31, 69, 341, 342, 0, 73], ["-", 0, 16, 12, 23, 0, 69, 341, 342, 0, 73]]
1
159
#include <bits/stdc++.h> using namespace std; int cnt[2010]; int main() { // freopen("in.txt", "r", stdin); string s; cin >> s; int num = 0, t = 1, res = 0; cnt[0] = 1; for (int i = s.size() - 1; i > 0; i--) { num = (num + (s[i] - '0') * t) % 2019; res += cnt[num]++; t = t * 10 % 2019; } p...
#include <bits/stdc++.h> using namespace std; int cnt[2010]; int main() { string s; cin >> s; int num = 0, t = 1, res = 0; cnt[0] = 1; for (int i = s.size() - 1; i >= 0; i--) { num = (num + (s[i] - '0') * t) % 2019; res += cnt[num]; cnt[num]++; t = t * 10 % 2019; } printf("%d\n", res); ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 47], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 20], ["+", 8, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 70], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 22], ["+", 0, 1, 0, 11, 12, 69, 341, 342, 0, 73], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
118
#include <bits/stdc++.h> using namespace std; int cnt[2010]; int main() { // freopen("in.txt", "r", stdin); string s; cin >> s; int num = 0, t = 1, res = 0; cnt[0] = 1; for (int i = s.size() - 1; i > 0; i--) { num = (num + (s[i] - '0') * t) % 2019; res += cnt[num]++; t = t * 10 % 2019; } p...
#include <bits/stdc++.h> using namespace std; int cnt[2010]; int main() { // freopen("in.txt", "r", stdin); string s; cin >> s; int num = 0, t = 1, res = 0; cnt[0] = 1; for (int i = s.size() - 1; i >= 0; i--) { num = (num + (s[i] - '0') * t) % 2019; res += cnt[num]++; t = t * 10 % 2019; } ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 47], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 20]]
1
118
#include <bits/stdc++.h> using namespace std; #define ll long long string s; ll num, t = 1, ans; ll cnt[2200]; int main() { cnt[0] = 1; cin >> s; for (int i = s.size() - 1; i > 0; i--) { num = (num + (s[i] - '0') * t) % 2019; ans += cnt[num]; cnt[num]++; t = t * 10 % 2019; } cout << ans; ret...
#include <bits/stdc++.h> using namespace std; #define ll long long string s; ll num, t = 1, ans; ll cnt[2200]; int main() { cnt[0] = 1; cin >> s; for (int i = s.size() - 1; i >= 0; i--) { num = (num + (s[i] - '0') * t) % 2019; ans += cnt[num]; cnt[num]++; t = t * 10 % 2019; } cout << ans; re...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 47], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 20]]
1
115
#include <bits/stdc++.h> using namespace std; // #define int long long #define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i) #define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i) #define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--) #define rreps(i, n)...
#include <bits/stdc++.h> using namespace std; // #define int long long #define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i) #define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i) #define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--) #define rreps(i, n)...
[["-", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 70], ["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 13], ["-", 0, 16, 31, 16, 12, 69, 341, 342, 0, 73], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
486
S = input() cnt = [0]*2019 cnt[0] = 1 n = 0 t = 1 for i in reversed(S): n += i*t n %= 2019 cnt[n] += 1 t *= 10 t %= 2019 print(sum(i*(i-1)//2 for i in cnt))
S = input() cnt = [0]*2019 cnt[0] = 1 n = 0 t = 1 for i in reversed(S): n += int(i)*t n %= 2019 cnt[n] += 1 t *= 10 t %= 2019 print(sum(i*(i-1)//2 for i in cnt))
[["+", 0, 1, 0, 677, 12, 657, 31, 652, 63, 22], ["+", 0, 677, 12, 657, 31, 652, 3, 4, 0, 24], ["+", 0, 677, 12, 657, 31, 652, 3, 4, 0, 25]]
5
71
#include <bits/stdc++.h> using namespace std; using ll = long long; const int m = 2019; int main() { string s; cin >> s; int n = s.size(); reverse(s.begin(), s.end()); int x = 1; int tot = 0; vector<int> count(m); ll ans = 0; for (int i = 0; i < n; i++) { count[tot]++; tot += (s[i] - '0') * ...
#include <bits/stdc++.h> using namespace std; using ll = long long; const int m = 2019; int main() { string s; cin >> s; int n = s.size(); reverse(s.begin(), s.end()); int x = 1; int tot = 0; vector<int> count(m); ll ans = 0; for (int i = 0; i < n; i++) { count[tot]++; tot += (s[i] - '0') * ...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 22], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
140
package main import ( "fmt" "strconv" ) func main() { var x string fmt.Scan(&x) rest := map[int]int{ 0: 1, } ten := 1 sum := 0 for i := len(x) - 1; i >= 0; i-- { val, _ := strconv.Atoi(string(x[i])) sum = ((ten%2019)*val + sum) % 2019 ten *= 10 rest[sum]++ } ans := 0 for _, v := range rest { a...
package main import ( "fmt" "strconv" ) func main() { var x string fmt.Scan(&x) rest := map[int]int{ 0: 1, } ten := 1 sum := 0 for i := len(x) - 1; i >= 0; i-- { val, _ := strconv.Atoi(string(x[i])) sum = ((ten%2019)*val + sum) % 2019 ten *= 10 ten %= 2019 rest[sum]++ } ans := 0 for _, v := ra...
[["+", 0, 7, 8, 196, 0, 436, 31, 432, 0, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 436, 17, 132], ["+", 0, 7, 8, 196, 0, 436, 12, 432, 0, 433], ["+", 0, 435, 8, 196, 0, 7, 8, 196, 0, 165]]
7
151
package main import ( "fmt" "strconv" ) var S string func main() { fmt.Scan(&S) a := make([]int, len(S)) for i, v := range S { a[i], _ = strconv.Atoi(string(v)) } c := 1 d := map[int]int{ 0: 1, } res := 0 sum := 0 for i := len(S) - 1; i >= 0; i-- { sum = (a[i]*c + sum) % 2019 c *= 10 d[sum]++ ...
package main import ( "fmt" "strconv" ) var S string func main() { fmt.Scan(&S) a := make([]int, len(S)) for i, v := range S { a[i], _ = strconv.Atoi(string(v)) } c := 1 d := map[int]int{ 0: 1, } res := 0 sum := 0 for i := len(S) - 1; i >= 0; i-- { sum = (a[i]*c + sum) % 2019 c *= 10 c %= 2019 ...
[["+", 0, 7, 8, 196, 0, 436, 31, 432, 0, 22], ["+", 8, 196, 0, 7, 8, 196, 0, 436, 17, 132], ["+", 0, 7, 8, 196, 0, 436, 12, 432, 0, 433], ["+", 0, 435, 8, 196, 0, 7, 8, 196, 0, 165]]
7
174
#include <bits/stdc++.h> #define itn int #define REP(i, n) for (ll i = 0; i < n; i++) #define IREP(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i < b + 1; i++) #define all(v) v.begin(), v.end() #define SENTINEL 2000000000 #define NIL -1 using namespace std; typedef long long ll; const ll I...
#include <bits/stdc++.h> #define itn int #define REP(i, n) for (ll i = 0; i < n; i++) #define IREP(i, n) for (ll i = n - 1; i >= 0; i--) #define FOR(i, a, b) for (ll i = a; i < b + 1; i++) #define all(v) v.begin(), v.end() #define SENTINEL 2000000000 #define NIL -1 using namespace std; typedef long long ll; const ll I...
[["-", 8, 9, 0, 9, 0, 57, 75, 76, 0, 95], ["-", 0, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["-", 0, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
1
274
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # D - Multiple of 2019 s = input() count = 0 counter = Counter([0]) suffix = 0 pow = 1 for i in range(len(s) - 1, -1, -1): suffix = (int(s[i]) * pow + suffix) % 2019 pow = pow * 10 % 2019 count += counter[suffix] counter[suffix] += 1 print(count)
# D - Multiple of 2019 from collections import Counter s = input() count = 0 counter = Counter([0]) suffix = 0 pow = 1 for i in range(len(s) - 1, -1, -1): suffix = (int(s[i]) * pow + suffix) % 2019 pow = pow * 10 % 2019 count += counter[suffix] counter[suffix] += 1 print(count)
[["+", 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
84
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; #define PI 3.14159265358979323846264338327950 int main() { string S; cin >> S; reverse(S.begin(), S.end()); vector<int> a(2019); int tot = 0; int x = 1; int n = S.s...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; #define PI 3.14159265358979323846264338327950 int main() { string S; cin >> S; reverse(S.begin(), S.end()); vector<int> a(2019); int tot = 0; int x = 1; int n = S.s...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 14, 8, 9, 0, 1, 0, 11, 17, 107]]
1
148
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; const int mod = 2019; int main() { string s; cin >> s; int n = s.size(); reverse(s.begin(), s.end()); ll d = 1, r = 0; vector<ll> cnts(mod); cnts[r]++; rep(i, n...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; using P = pair<int, int>; const int mod = 2019; int main() { string s; cin >> s; int n = s.size(); reverse(s.begin(), s.end()); ll d = 1, r = 0; vector<ll> cnts(mod); cnts[r]++; rep(i, n...
[["-", 0, 11, 12, 16, 31, 23, 0, 16, 17, 72], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 48]]
1
180
s=list(map(int,list(input()))) #print(s) #modで考える # 2019100を # 2019100%2019 と100%1019 #同じmodの組み合わせ #右から見ていく mod=[0]*2019 tmp=0 ten=1 #hoge="" for ii in range(len(s)): i=len(s)-ii-1 if ii==0: ten=1 else: ten=(ten*10)%2019 tmp=((tmp+s[i]*ten)%2019) #hoge=str(s[i])+hoge #print...
s=list(map(int,list(input()))) #print(s) #modで考える # 2019100を # 2019100%2019 と100%1019 #同じmodの組み合わせ #右から見ていく mod=[0]*2019 tmp=0 ten=1 #hoge="" for ii in range(len(s)): i=len(s)-ii-1 if ii==0: ten=1 else: ten=(ten*10)%2019 tmp=((tmp+s[i]*ten)%2019) #hoge=str(s[i])+hoge #print...
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21]]
5
144
s=input() """ ◆エッセンス1:割り切れるとは、二つに分けた数字のmodが一緒 例) 1817181712114の 18171が2019で割り切れるかどうかを判断する。 18171は(181712114-2114)/10000となるので、 181712114mod2019=2114mod2019の時、2019で割り切れる。 1817181712114mod2019 817181712114mod2019 17181712114mod2019 7181712114mod2019 181712114mod2019 81712114mod2019 1712114mod2019...
s=input() """ ◆エッセンス1:割り切れるとは、二つに分けた数字のmodが一緒 例) 1817181712114の 18171が2019で割り切れるかどうかを判断する。 18171は(181712114-2114)/10000となるので、 181712114mod2019=2114mod2019の時、2019で割り切れる。 1817181712114mod2019 817181712114mod2019 17181712114mod2019 7181712114mod2019 181712114mod2019 81712114mod2019 1712114mod2019...
[["+", 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], ["-", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107], ["-", 0, 1, 0, 677, 12, 657, 31, 657, 31, 22], ["+", 0, 1, 0, 677, 12, 657, 31, 657, 31, 22], ["-"...
5
100
#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...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 85], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
639
#include <bits/stdc++.h> #define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++) #define rep(i, n) for (decltype(n) i = 0; i < (n); i++) #define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++) #define REP(i, n) for (decltype(n) i = 0; i <= (n); i++) #define ALL(v) v.begin(), v.end() #define len(v) ((ll)(v...
#include <bits/stdc++.h> #define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++) #define rep(i, n) for (decltype(n) i = 0; i < (n); i++) #define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++) #define REP(i, n) for (decltype(n) i = 0; i <= (n); i++) #define ALL(v) v.begin(), v.end() #define len(v) ((ll)(v...
[["-", 8, 9, 0, 338, 8, 9, 0, 43, 39, 40], ["+", 8, 9, 0, 338, 8, 9, 0, 43, 39, 78], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
465
#include <bits/stdc++.h> #define rep(i, z, n) for (int i = z; i <= n; i++) #define all(v) v.begin(), v.end() typedef long long ll; using namespace std; int main() { string s; int counter = 0; ll sum_of_digits = 0; ll digits = 1; int mods[2019] = {}; cin >> s; reverse(all(s)); for (char i : s) { in...
#include <bits/stdc++.h> #define rep(i, z, n) for (int i = z; i <= n; i++) #define all(v) v.begin(), v.end() typedef long long ll; using namespace std; int main() { string s; int counter = 0; ll sum_of_digits = 0; ll digits = 1; int mods[2019] = {}; cin >> s; reverse(all(s)); for (char i : s) { in...
[["+", 0, 338, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 338, 8, 9, 0, 1, 0, 11, 17, 132], ["+", 0, 338, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 338, 8, 9, 0, 1, 0, 35]]
1
173
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; reverse(s.begin(), s.end()); int ten = 1, sum = 0, cnt[2019] = {}; long long ans = 0; for (int i = 0; i < s.size(); i++) { cnt[sum]++; sum += (s[i] - '0') * ten; sum %= 2019; ans += cnt[sum]; ten = (ten * 10...
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; reverse(s.begin(), s.end()); int ten = 1, sum = 0, cnt[2019] = {}; long long ans = 0; for (int i = 0; i < s.size(); i++) { cnt[sum]++; sum += (s[i] - '0') * ten; sum %= 2019; ans += cnt[sum]; ten = (ten * 10...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
123
#include <bits/stdc++.h> #define rep(i, f, n) for (ll i = (f); (i) < (n); i++) #define repe(i, f, n) for (ll i = (f); (i) <= (n); i++) using namespace std; using ll = long long; #define MOD (ll)1000000007 #define PI 3.14159265359 //#define P pair<ll, ll> // printf("%.10f\n") // cout << fixed << setprecision(10); templa...
#include <bits/stdc++.h> #define rep(i, f, n) for (ll i = (f); (i) < (n); i++) #define repe(i, f, n) for (ll i = (f); (i) <= (n); i++) using namespace std; using ll = long long; #define MOD (ll)1000000007 #define PI 3.14159265359 //#define P pair<ll, ll> // printf("%.10f\n") // cout << fixed << setprecision(10); templa...
[["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25]]
1
260
#include <bits/stdc++.h> using namespace std; int main(void) { long long int n = 0, h = 1, z = 0; string s; cin >> s; n = s.size(); reverse(s.begin(), s.end()); vector<long long int> a(n); vector<long long int> b(n); vector<long long int> c(n, 0); int l[2020] = {}; for (int i = 0; i < n; i++) { ...
#include <bits/stdc++.h> using namespace std; int main(void) { long long int n = 0, h = 1, z = 0; string s; cin >> s; n = s.size(); reverse(s.begin(), s.end()); vector<long long int> a(n); vector<long long int> b(n); vector<long long int> c(n, 0); int l[2020] = {}; for (int i = 0; i < n; i++) { ...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 109], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 13]]
1
282
from collections import Counter S = input() S = S + '0' mod = 2019 p = [-1] * len(S) r = 0 d = 1 for i,s in enumerate(S[::-1]): t = int(s)%mod r += t*d r %= mod d = d*10%mod p[i] = r ans = 0 c = Counter(p) for k,n in c.most_common(): if n > 1: ans += n//2 else:break print(ans)
from collections import Counter S = input() S = S + '0' mod = 2019 p = [-1] * len(S) r = 0 d = 1 for i,s in enumerate(S[::-1]): t = int(s)%mod r += t*d r %= mod d = d*10%mod p[i] = r ans = 0 c = Counter(p) for k,n in c.most_common(): if n > 1: ans += n*(n-1)//2 else:break print(ans)
[["+", 0, 1, 0, 677, 12, 657, 31, 657, 17, 48], ["+", 0, 677, 12, 657, 31, 657, 12, 23, 0, 24], ["+", 12, 657, 31, 657, 12, 23, 0, 657, 31, 22], ["+", 12, 657, 31, 657, 12, 23, 0, 657, 17, 33], ["+", 12, 657, 31, 657, 12, 23, 0, 657, 12, 612], ["+", 0, 677, 12, 657, 31, 657, 12, 23, 0, 25]]
5
118
console.log((args => { const S = args.trim().split``.map(v => v | 0); const L = S.length; const M = Array(2019).fill(0); let e = 0, d = 1; for (let i = L - 1; i >= 0; i--) { e = (e + S[i] * d) % 2019; M[e]++; d = d * 10 % 2019; } let a = M[0]; for (let i = 1; i < 2019; i++) { if (M[i] < ...
console.log((args => { const S = args.trim().split``.map(v => v | 0); const L = S.length; const M = Array(2019).fill(0); let e = 0, d = 1; for (let i = L - 1; i >= 0; i--) { e = (e + S[i] * d) % 2019; M[e]++; d = d * 10 % 2019; } let a = M[0]; for (let i = 0; i < 2019; i++) { if (M[i] < ...
[["-", 8, 556, 0, 7, 10, 570, 0, 200, 51, 555], ["+", 8, 556, 0, 7, 10, 570, 0, 200, 51, 555]]
2
189
S = input()[::-1] cur = 0 mods = Counter() mods[0] += 1 MOD = 2019 for i,d in enumerate(S): cur += int(d) * pow(10, i, MOD) mods[cur%MOD] += 1 res = 0 for k,v in mods.items(): res += (v * (v-1) // 2) print(res)
from collections import Counter S = input()[::-1] cur = 0 mods = Counter() mods[0] += 1 MOD = 2019 for i,d in enumerate(S): cur += int(d) * pow(10, i, MOD) mods[cur%MOD] += 1 res = 0 for k,v in mods.items(): res += (v * (v-1) // 2) print(res)
[["+", 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
92
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int N = S.size(), M = 2019; reverse(S.begin(), S.end()); vector<int> sur(M); int dig = 1, sum = 0; sur.at(sum)++; for (int i = 0; i < N; i++) { sum += (S.at(i) - '0') * dig; sum %= M; sur.at(sum)++; dig *= 10...
#include <bits/stdc++.h> using namespace std; int main() { string S; cin >> S; int N = S.size(), M = 2019; reverse(S.begin(), S.end()); vector<int> sur(M); int dig = 1, sum = 0; sur.at(sum)++; for (int i = 0; i < N; i++) { sum += (S.at(i) - '0') * dig; sum %= M; sur.at(sum)++; dig *= 10...
[["+", 8, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["+", 0, 11, 12, 16, 31, 16, 12, 23, 0, 24], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 31, 22], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 12, 13], ["+", 0, 11, 12, 16, 31, 16, 12, 23, 0, 25]]
1
152
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define all(v) (v).begin(), (v).end() using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; const ll LINF = 1LL << 60; const int INF = 1 << 29; const int MOD = 2019; ll modpow(int a, int n) { ll res = 1; while (n > 0) { ...
#include <bits/stdc++.h> #define _GLIBCXX_DEBUG #define all(v) (v).begin(), (v).end() using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; const ll LINF = 1LL << 60; const int INF = 1 << 29; const int MOD = 2019; ll modpow(int a, int n) { ll res = 1; while (n > 0) { ...
[["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 108], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48]]
1
255
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { string s; cin >> s; reverse(s.begin(), s.end()); int len = s.size(); // vector<int> digit_MOD_res(len); vector<int> d(len + 1); int keta = 1; d[0] = 0; vector<int> count(2019, 0); coun...
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int main() { string s; cin >> s; reverse(s.begin(), s.end()); int len = s.size(); // vector<int> digit_MOD_res(len); vector<int> d(len + 1); int keta = 1; d[0] = 0; vector<int> count(2019, 0); coun...
[["-", 12, 16, 31, 23, 0, 16, 31, 16, 17, 72], ["+", 0, 11, 12, 16, 31, 23, 0, 16, 17, 48], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 24], ["+", 12, 16, 31, 23, 0, 16, 12, 23, 0, 25]]
1
230