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
b=int(input()) sum=0 for a in range(0,b): if a%3 ==0 or a%5==0: pass else: sum+=a print(sum)
b=int(input()) sum=0 for a in range(0,b+1): if a%3 ==0 or a%5==0: pass else: sum+=a print(sum)
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
44
def main(): n = int(input()) ans = 0 for i in range(n): if (i%3==0) and (i%5==0): continue if (i%3==0): continue if (i%5==0): continue ans += i print(ans) main()
def main(): n = int(input()) ans = 0 for i in range(1, n+1): if (i%3==0) and (i%5==0): continue if (i%3==0): continue if (i%5==0): continue ans += i print(ans) main()
[["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
72
#include <iostream> using namespace std; int main() { int N; cin >> N; long long sum = 0; for (int i = 1; i < N; i++) { if (i % 15 == 0 || i % 3 == 0 || i % 5 == 0) { continue; } sum += i; } cout << sum << endl; }
#include <iostream> using namespace std; int main() { int N; cin >> N; long long sum = 0; for (int i = 1; i <= N; i++) { if (i % 15 == 0 || i % 3 == 0 || i % 5 == 0) { continue; } sum += i; } cout << sum << endl; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
75
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def main(): n = int(input().strip()) sum = 0 for i in range(n): sum += i if i % 3 != 0 and i % 5 != 0 else 0 print(sum) if __name__ == '__main__': main()
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def main(): n = int(input().strip()) sum = 0 for i in range(1, n + 1): sum += i if i % 3 != 0 and i % 5 != 0 else 0 print(sum) if __name__ == '__main__': main()
[["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
61
# -*- coding: utf-8 -*- import sys # 整数の入力 n = int(input()) s = 0 for i in range(1, n): if i % 3 != 0 and i % 5 != 0: s += i print(s)
# -*- coding: utf-8 -*- import sys # 整数の入力 n = int(input()) s = 0 for i in range(1, n + 1): if i % 3 != 0 and i % 5 != 0: s += i print(s)
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
45
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using ll = long long; using namespace std; int main() { ll n, ans; cin >> n; ans = 0; rep(i, n) { if (i % 3 != 0 && i % 5 != 0) { ans += i; } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> #define rep(i, n) for (int i = 1; i <= (n); i++) using ll = long long; using namespace std; int main() { ll n, ans; cin >> n; ans = 0; rep(i, n) { if (i % 3 != 0 && i % 5 != 0) { ans += i; } } cout << ans << endl; return 0; }
[["-", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59]]
1
76
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define nl cout << "\n"; #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); ...
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define nl cout << "\n"; #define fastio \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
86
#include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; long long int sum = 0; cin >> n; for (int i = 1; i < n; i++) { if (i % 3 != 0 && i % 5 != 0) { sum += i; } } cout << sum; // system("pause"); return 0; }
#include <bits/stdc++.h> #define endl '\n' using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; long long int sum = 0; cin >> n; for (int i = 1; i <= n; i++) { if (i % 3 != 0 && i % 5 != 0) { sum += i; } } cout << sum; // system("pause"); return 0; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
87
# -*- coding: utf-8 -*- def run(): n = int(input()) num = 0 for i in range(n): if i % 3 == 0 or i % 5 == 0: continue num += i print(num) if __name__ == '__main__': run()
# -*- coding: utf-8 -*- def run(): n = int(input()) num = 0 for i in range(n + 1): if i % 3 == 0 or i % 5 == 0: continue num += i print(num) if __name__ == '__main__': run()
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
56
n = int(input()) ans = 0 for i in range(n): if i % 3 == 0 or i % 5 == 0: x = 0 else: ans += i print(ans)
n = int(input()) ans = 0 for i in range(1,n+1): if i % 3 == 0 or i % 5 == 0: x = 0 else: ans += i print(ans)
[["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
44
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int k; cin >> k; ll ans = 0; for (int a = 1; a < k; a++) { for (int b = 1; b < k; b++) { for (int c = 1; c < k; c++) { ans += gcd(a, gcd(b, c)); } } } cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { int k; cin >> k; ll ans = 0; for (int a = 1; a <= k; a++) { for (int b = 1; b <= k; b++) { for (int c = 1; c <= k; c++) { ans += gcd(a, gcd(b, c)); } } } cout << ans << endl; return 0; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
101
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) #define rep3(i, n) for (long long i = 0; i < (long long)(n); i++) using Graph = vector<vector<int>>; using ll = long long; int main() { int k; cin >> k; ll...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) #define rep3(i, n) for (long long i = 0; i < (long long)(n); i++) using Graph = vector<vector<int>>; using ll = long long; int main() { int k; cin >> k; ll...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 17, 72], ["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 64, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 64, 9, 0, 57, 64, 9, 0, 93, 0, 94]]
1
180
import math k = int(input()) sum = [] for a in range(1,k+1): for b in range(1,k+1): ab = math.gcd(a,b) for c in range(1,k+1): sum += math.gcd(ab,c) print(sum)
import math k = int(input()) sum = 0 for a in range(1,k+1): for b in range(1,k+1): ab = math.gcd(a,b) for c in range(1,k+1): sum += math.gcd(ab,c) print(sum)
[["-", 0, 656, 0, 1, 0, 662, 12, 634, 0, 70], ["-", 0, 656, 0, 1, 0, 662, 12, 634, 0, 73], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612]]
5
74
#include <stdio.h> int GCD(int a, int b) { int r = 1; while (r != 0) { r = a % b; a = b; b = r; } return a; } int main() { int k; scanf("%d", &k); int gcdsum = 0; for (int i = 1; i <= k; i++) { for (int j = 1; j <= k; j++) { for (int m = 1; m <= k; m++) { gcdsum += GCD(GCD(...
#include <stdio.h> int GCD(int a, int b) { int r = 1; while (r != 0) { r = a % b; a = b; b = r; } return a; } int main() { int k; scanf("%d", &k); int gcdsum = 0; for (int i = 1; i <= k; i++) { for (int j = 1; j <= k; j++) { for (int m = 1; m <= k; m++) { gcdsum += GCD(GCD(...
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
0
141
#include <stdio.h> int main(void) { long int K; long int sum = 0; scanf("%ld", &K); for (int a = 1; a <= K; a++) { for (int b = 1; b <= a; b++) { for (int c = 1; c <= b; c++) { for (int i = c; i > 0; i--) { if (a % i == 0 && b % i == 0 && c % i == 0) { if (a == b && b ==...
#include <stdio.h> int main(void) { long int K; long int sum = 0; scanf("%ld", &K); for (int a = 1; a <= K; a++) { for (int b = 1; b <= a; b++) { for (int c = 1; c <= b; c++) { for (int i = c; i > 0; i--) { if (a % i == 0 && b % i == 0 && c % i == 0) { if (a == b && b ==...
[["+", 0, 57, 64, 9, 0, 57, 75, 76, 0, 95]]
0
178
from math import gcd k = int(input()) ans = 0 for a in range(1,k+1): for b in range(1,k+1): for c in range(1,k+1): ans += gcd(gcd(a,c),b)
from math import gcd k = int(input()) ans = 0 for a in range(1,k+1): for b in range(1,k+1): for c in range(1,k+1): ans += gcd(gcd(a,c),b) 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
64
import math K = int(input()) gcd3 = 0 for a in range(1,K-1): for b in range(a+1,K): for c in range(b+1,K+1): gcd3 += math.gcd(math.gcd(a,b),c) gcd2 = 0 for a in range(1,K): for b in range(a+1,K+1): gcd2 += math.gcd(a,b) ans = gcd3 * 6 + gcd2 * 3 + K*(K+1)//2 print(ans)
import math K = int(input()) gcd3 = 0 for a in range(1,K-1): for b in range(a+1,K): for c in range(b+1,K+1): gcd3 += math.gcd(math.gcd(a,b),c) gcd2 = 0 for a in range(1,K): for b in range(a+1,K+1): gcd2 += math.gcd(a,b) ans = gcd3 * 6 + gcd2 * 6 + K*(K+1)//2 print(ans)
[["-", 0, 662, 12, 657, 31, 657, 12, 657, 12, 612], ["+", 0, 662, 12, 657, 31, 657, 12, 657, 12, 612]]
5
128
from math import gcd k=map(int,input()) r=range(1,k+1) ans=0 for i in r: for j in r: for k in r: ans+=gcd(k,gcd(i,j)) print(ans) # 間に合うはずなくない??
from math import gcd k=int(input()) r=range(1,k+1) ans=0 for i in r: for j in r: for k in r: ans+=gcd(k,gcd(i,j)) print(ans) # 間に合うはずなくない??
[["-", 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, 21], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24]]
5
60
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) using namespace std; using P = pair<int, int>; using ll = long long; int main() { int n; cin >> n; int ans = 0; for (int i = 0; i <= n; i++) { for (int j = 0; j <= n; j++...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) using namespace std; using P = pair<int, int>; using ll = long long; int main() { int n; cin >> n; int ans = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
129
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; long ans = 0; for (int i = 1; i < N; i++) { for (int j = 1; j < N; j++) { for (int k = 1; k < N; k++) { ans += gcd(gcd(i, j), k); } } } cout << ans << "\n"; }
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; long ans = 0; for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { for (int k = 1; k <= N; k++) { ans += gcd(gcd(i, j), k); } } } cout << ans << "\n"; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
94
#162C #Sum of gcd of Tuples (Easy) import math k=int(input())+1 ans=0 for a in range(1,k): for b in range(1,k): g=math.gcd(a,b) for c in range(1,k): ans+=gcd(g,c) print(ans)
#162C #Sum of gcd of Tuples (Easy) import math k=int(input())+1 ans=0 for a in range(1,k): for b in range(1,k): g=math.gcd(a,b) for c in range(1,k): ans+=math.gcd(g,c) print(ans)
[["+", 0, 1, 0, 677, 12, 652, 63, 319, 500, 22], ["+", 0, 1, 0, 677, 12, 652, 63, 319, 0, 131]]
5
69
from math import gcd num = (int)(input()) total = 0 for i in range(1, num + 1): for j in range(1, num + 1): sub = math.gcd(i, j) for k in range(1, num + 1): total += math.gcd(sub, k) print(total)
from math import gcd num = (int)(input()) total = 0 for i in range(1, num + 1): for j in range(1, num + 1): sub = gcd(i, j) for k in range(1, num + 1): total += gcd(sub, k) print(total)
[["-", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22], ["-", 0, 1, 0, 662, 12, 652, 63, 319, 0, 131], ["-", 0, 1, 0, 677, 12, 652, 63, 319, 500, 22], ["-", 0, 1, 0, 677, 12, 652, 63, 319, 0, 131]]
5
77
f = gets.chomp.to_i all = 0 1.upto(f).each do |a| 1.upto(f).each do |b| e = b.gcd(a) 1.upto(f).each do |c| all = e.gcd(c) end end end puts all
f = gets.chomp.to_i all = 0 1.upto(f).each do |a| 1.upto(f).each do |b| e = a.gcd(b) 1.upto(f).each do |c| all += c.gcd(e) end end end puts all
[["-", 196, 737, 8, 736, 0, 662, 12, 652, 486, 22], ["+", 196, 737, 8, 736, 0, 662, 12, 652, 486, 22], ["-", 8, 736, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 8, 736, 0, 662, 12, 652, 3, 4, 0, 22], ["-", 0, 652, 196, 737, 8, 736, 0, 662, 0, 32], ["+", 0, 652, 196, 737, 8, 736, 0, 755, 17, 107], ["+", 196, 737, 8, 736, 0, 75...
4
67
k = int(input()) sum = 0 def euclid(a, b): while b: a, b = b, a%b return a for a in range(1, k + 1): for b in range(a, k + 1): for c in range(b, k + 1): if a == b == c: sum += a elif a == b or b == c: sum += euclid(euclid(a,b), c) * ...
k = int(input()) sum = 0 def euclid(a, b): while b: a, b = b, a % b return a for a in range(1, k + 1): for b in range(a, k + 1): for c in range(b, k + 1): if a == b == c: sum += a elif a == b or b == c: sum += euclid(euclid(a, b), c...
[["+", 8, 196, 0, 1, 0, 677, 12, 657, 17, 48], ["+", 8, 196, 0, 1, 0, 677, 12, 657, 12, 612]]
5
122
# ABC 162 A = int(input()) # 最小公倍数 ans = 0 import math for i in range(1,A+1): for j in range(1,A+1): for k in range(1,A+1): ans += gcd(gcd(i,j),k) print(ans)
A = int(input()) # 最小公倍数 ans = 0 from math import gcd for i in range(1,A+1): for j in range(1,A+1): for k in range(1,A+1): ans += gcd(gcd(i,j),k) print(ans)
[["-", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 314], ["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 487], ["+", 36, 36, 0, 656, 0, 686, 141, 673, 0, 22]]
5
68
import math import queue from collections import defaultdict def readInt(): return int(input()) def readInts(): return list(map(int, input().split())) def readChar(): return input() def readChars(): return input().split() def factorization(n): res = [] if n%2==0: res.append(2) for i in range(3,math.floor(n//...
import math import queue from collections import defaultdict def readInt(): return int(input()) def readInts(): return list(map(int, input().split())) def readChar(): return input() def readChars(): return input().split() def factorization(n): res = [] if n%2==0: res.append(2) for i in range(3,math.floor(n//...
[["+", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 0, 131], ["+", 0, 1, 0, 677, 12, 652, 63, 319, 500, 22], ["+", 0, 1, 0, 677, 12, 652, 63, 319, 0, 131]]
5
404
from collections import defaultdict, deque, Counter from heapq import heappush, heappop from itertools import permutations, accumulate, combinations, combinations_with_replacement from math import sqrt, ceil, floor, gcd from bisect import bisect_left, bisect_right from copy import deepcopy from operator import itemgett...
from collections import defaultdict, deque, Counter from heapq import heappush, heappop from itertools import permutations, accumulate, combinations, combinations_with_replacement from math import sqrt, ceil, floor, gcd from bisect import bisect_left, bisect_right from copy import deepcopy from operator import itemgett...
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 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
378
#include <bits/stdc++.h> using namespace std; #define MOD (long long int)(1e9 + 7) #define ll long long int #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define reps(i, n) for (int i = 1; i <= (int)(n); i++) #define REP(i, n) for (int i = n - 1; i >= 0; i--) #define REPS(i, n) for (int i = n; i > 0; i--) #defin...
#include <bits/stdc++.h> using namespace std; #define MOD (long long int)(1e9 + 7) #define ll long long int #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define reps(i, n) for (int i = 1; i <= (int)(n); i++) #define REP(i, n) for (int i = n - 1; i >= 0; i--) #define REPS(i, n) for (int i = n; i > 0; i--) #defin...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
331
from math import gcd k = int(input()) num = 0 for a in range(0, k + 1): for b in range(0, k + 1): c = gcd(a, b) num += sum(gcd(c, d) for d in range(1, k + 1)) print(num)
from math import gcd k = int(input()) num = 0 for a in range(1, k + 1): for b in range(1, k + 1): c = gcd(a, b) num += sum(gcd(c, d) for d in range(1, k + 1)) print(num)
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612]]
5
73
K = int(input()) import math import itertools def better_gcd(a,b,c): tup = set((a,b,c)) kinds = len(tup) if kinds == 3: return math.gcd(a, math.gcd(b, c)) * 6 elif kinds == 2: return math.gcd(*tup) * 3 else: return a ans = 0 cands = list(itertools.combinations_with_replace...
K = int(input()) import math import itertools def better_gcd(a,b,c): tup = set((a,b,c)) kinds = len(tup) if kinds == 3: return math.gcd(a, math.gcd(b, c)) * 6 elif kinds == 2: return math.gcd(*tup) * 3 else: return a ans = 0 cands = list(itertools.combinations_with_replacem...
[["-", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 31, 22], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 17, 72], ["+", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]]
5
119
import math n = int(input()) ans = 0 for i in range(1,n): for j in range(1, n): for k in range(1, n): ans += math.gcd(i, math.gcd(j, k)) print(ans)
import math n = int(input()) ans = 0 for i in range(1,n+1): for j in range(1, n+1): for k in range(1, n+1): ans += math.gcd(i, math.gcd(j, k)) print(ans)
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
64
import java.math.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int k = in.nextInt(); int ans = 0; for (int i = 1; i <= k; i++) { for (int j = 1; j <= k; j++) { for (int l = 1; l <= k; l++) { ans += gcd(g...
import java.math.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int k = in.nextInt(); long ans = 0; for (int i = 1; i <= k; i++) { for (int j = 1; j <= k; j++) { for (int l = 1; l <= k; l++) { ans += gcd(...
[["-", 0, 195, 8, 196, 0, 503, 39, 506, 0, 507], ["+", 0, 195, 8, 196, 0, 503, 39, 506, 0, 96], ["-", 0, 195, 8, 196, 0, 57, 75, 37, 0, 22], ["+", 0, 195, 8, 196, 0, 57, 75, 37, 0, 22]]
3
188
import functions from functools import reduce K=int(input()) ans=K*(1+K)/2 for i in range(1, K+1): for j in range(i+1, K+1): ans+=functions.gcd(i,j)*6 for k in range(j+1,K+1): ans+=reduce(functions.gcd, [i,j,k])*6 print(str(int(ans)))
import math from functools import reduce K=int(input()) ans=K*(1+K)/2 for i in range(1, K+1): for j in range(i+1, K+1): ans+=math.gcd(i,j)*6 for k in range(j+1,K+1): ans+=reduce(math.gcd, [i,j,k])*6 print(str(int(ans)))
[["-", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["-", 0, 677, 12, 657, 31, 652, 63, 319, 500, 22], ["+", 0, 677, 12, 657, 31, 652, 63, 319, 500, 22], ["-", 12, 657, 31, 652, 3, 4, 0, 319, 500, 22], ["+", 12, 657, 31, 652, 3, 4, 0, 319, 500, 22]]
5
105
import math K = int(input()) S = 0 for i in range(K+1): for j in range(K+1): for l in range(K+1): S = S + math.gcd(l, math.gcd(j,i)) print(S)
import math K = int(input()) S = 0 for i in range(1,K+1): for j in range(1,K+1): for l in range(1,K+1): S = S + math.gcd(l, math.gcd(j,i)) print(S)
[["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 21], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21]]
5
66
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 1; i <= (int)(n); i++) int main() { int n; cin >> n; int sum = 0; rep(i, 200) { rep(j, 200) { rep(k, 200) { sum += gcd(gcd(i, j), k); } } } cout << sum << endl; return 0; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 1; i <= (int)(n); i++) int main() { int n; cin >> n; int sum = 0; rep(i, n) { rep(j, n) { rep(k, n) { sum += gcd(gcd(i, j), k); } } } cout << sum << endl; return 0; }
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 78], ["-", 0, 1, 0, 2, 3, 4, 0, 25, 0, 35], ["-", 0, 9, 0, 1, 0, 2, 3, 4, 0, 13]]
1
82
import sys input = sys.stdin.readline from itertools import * from functools import * from collections import * from heapq import heapify, heappop, heappush, heappushpop import math INF = float('inf') NIL = - 1 import time from functools import wraps def stop_watch(func): @wraps(func) def wrapper(*args, **k...
import sys input = sys.stdin.readline from itertools import * from functools import * from collections import * from heapq import heapify, heappop, heappush, heappushpop import math INF = float('inf') NIL = - 1 import time from functools import wraps def stop_watch(func): @wraps(func) def wrapper(*args, **k...
[["-", 36, 36, 0, 656, 0, 692, 0, 693, 0, 549], ["-", 36, 36, 0, 656, 0, 692, 0, 693, 0, 22]]
5
378
import numpy as np K = int(input()) a = np.arange(a,K+1) b = np.gcd.outer(np.gcd.outer(a, a), a) print(np.sum(b))
import numpy as np K = int(input()) a = np.arange(1,K+1) b = np.gcd.outer(np.gcd.outer(a, a), a) print(np.sum(b))
[["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612]]
5
54
a=int(input()) import math print(sum(gcd(gcd(i,j),k)for i in range(1,a+1) for j in range(1,a+1) for k in range(1,a+1)))
a=int(input()) import math print(sum(math.gcd(math.gcd(i,j),k)for i in range(1,a+1) for j in range(1,a+1) for k in range(1,a+1)))
[["+", 0, 652, 3, 668, 8, 652, 63, 319, 500, 22], ["+", 0, 652, 3, 668, 8, 652, 63, 319, 0, 131], ["+", 8, 652, 3, 4, 0, 652, 63, 319, 500, 22], ["+", 8, 652, 3, 4, 0, 652, 63, 319, 0, 131]]
5
60
#include <algorithm> #include <iostream> using namespace std; int gcd(int a, int b) { if (b > a) { swap(a, b); } while (b != 0) { a = a % b; swap(a, b); } return a; } int main() { int ans = 0; int n; cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { int k = ...
#include <algorithm> #include <iostream> using namespace std; int gcd(int a, int b) { if (b > a) { swap(a, b); } while (b != 0) { a = a % b; swap(a, b); } return a; } int main() { int ans = 0; int n; cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { int k = ...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
152
def gcd(a, b): if a < b: a_init = a b = a a = a_init while b != 0: r = a % b a = b b = r return a K = int(input()) count = 0 temp = [] for a in range(1, K+1): for b in range(1, a): temp.append(gcd(a, b)) for c in range(1, K+1): for j in range(len(temp)): count += gcd(c, temp[j]) * ...
def gcd(a, b): if a < b: a_init = a a = b b = a_init while b != 0: r = a % b a = b b = r return a K = int(input()) count = 0 temp = [] for a in range(1, K+1): for b in range(1, a): temp.append(gcd(a, b)) for c in range(1, K+1): for j in range(len(temp)): count += gcd(c, temp[j]) * ...
[["-", 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, 57, 64, 196, 0, 1, 0, 662, 0, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 12, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 662, 31, 22]]
5
148
#pragma region kyomukyomupurin /** * author : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏 * created : 2020-04-21 16:17:12 **/ #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <chrono> #include <cmath> #include <complex> #include <deque> #include <iomanip> #include <iostream> #include ...
#pragma region kyomukyomupurin /** * author : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏 * created : 2020-04-21 16:17:12 **/ #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <chrono> #include <cmath> #include <complex> #include <deque> #include <iomanip> #include <iostream> #include ...
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
1
694
def main(): k = int(input()) k1 = k + 1 sum = 0 for i in range(1, k1): for j in range(1, k1): for m in range(1, k1): sum += math.gcd(math.gcd(i, j), m) print(sum) main()
import math def main(): k = int(input()) k1 = k + 1 sum = 0 for i in range(1, k1): for j in range(1, k1): for m in range(1, k1): sum += math.gcd(math.gcd(i, j), m) print(sum) main()
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]]
5
75
#include "bits/stdc++.h" #define rep(i, N) for (int i = 0; i < N; i++) #define int long long #define INF 1e10 using namespace std; int gcd(int p, int q) { if (p % q == 0) return q; return gcd(q, p % q); } signed main(void) { int K; int ans = 0; cin >> K; rep(a, K) { rep(b, K) { rep(c, K...
#include "bits/stdc++.h" #define rep(i, N) for (int i = 0; i < N; i++) #define int long long #define INF 1e10 using namespace std; int gcd(int p, int q) { if (p % q == 0) return q; return gcd(q, p % q); } signed main(void) { int K; int ans = 0; cin >> K; rep(a, K) { rep(b, K) { rep(c, K...
[["+", 3, 4, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]]
1
120
import math from functools import reduce def gcd(*numbers): return reduce(math.gcd, numbers) K = int(input()) count = 0 for i in range(1,K+1): for j in range(i+1,K+1): for k in range(j+1,K+1): count += 6*(gcd(i,j,k)) for i in range(1,K+1): for j in range(i+1,K+1): count += 3*(gcd(i,j)) ...
import math from functools import reduce def gcd(*numbers): return reduce(math.gcd, numbers) K = int(input()) count = 0 for i in range(1,K-1): for j in range(i+1,K): for k in range(j+1,K+1): count += 6*(gcd(i,j,k)) for i in range(1,K): for j in range(i+1,K+1): count += 6*(gcd(i,j)) for...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 8, 196, 0, 1, 0, 677, 12, 657, 31, 612], ["+", 8, 196, 0, 1, 0, 677, 12, 657, 31, 612]]
5
144
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a % b == 0) return b; else return gcd(a, a % b); } int gcdtry(int a, int b, int c) { int d, e; d = gcd(a, b); e = gcd(d, c); return e; } int main() { int k; cin >> k; long int ans = 0; for (int i = 1; i <= k; i++) { ...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (a % b == 0) return b; else return gcd(b, a % b); } int gcdtry(int a, int b, int c) { int d, e; d = gcd(a, b); e = gcd(d, c); return e; } int main() { int k; cin >> k; long int ans = 0; for (int i = 1; i <= k; i++) { ...
[["-", 75, 76, 0, 37, 0, 2, 3, 4, 0, 22], ["+", 75, 76, 0, 37, 0, 2, 3, 4, 0, 22]]
1
163
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) using namespace std; typedef long long ll; typedef pair<int, int> P; const int inf = 1 << 21; const ll INF = 1LL << 60; const ll mod = 1e9 + 7; const int dx[4] = {-1, 0, 1, 0}; co...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) using namespace std; typedef long long ll; typedef pair<int, int> P; const int inf = 1 << 21; const ll INF = 1LL << 60; const ll mod = 1e9 + 7; const int dx[4] = {-1, 0, 1, 0}; co...
[["-", 8, 9, 0, 37, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 37, 0, 2, 3, 4, 0, 22]]
1
228
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) using namespace std; typedef long long ll; typedef pair<int, int> P; const int inf = 1 << 21; const ll INF = 1LL << 60; const ll mod = 1e9 + 7; const int dx[4] = {-1, 0, 1, 0}; co...
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define chmin(x, y) x = min(x, y) #define chmax(x, y) x = max(x, y) using namespace std; typedef long long ll; typedef pair<int, int> P; const int inf = 1 << 21; const ll INF = 1LL << 60; const ll mod = 1e9 + 7; const int dx[4] = {-1, 0, 1, 0}; co...
[["+", 3, 4, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 3, 4, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]]
1
179
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; #define ll long long #define sz(a) int((a).size()) #define pb push_back #define all(c) (c).begin(), (c).end() #define tr(c, i) for (typeof((c)).begin() i = (c).begin(); i != (c).end(); i++) #define...
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; #define ll long long #define sz(a) int((a).size()) #define pb push_back #define all(c) (c).begin(), (c).end() #define tr(c, i) for (typeof((c)).begin() i = (c).begin(); i != (c).end(); i++) #define...
[["+", 0, 52, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 52, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 152], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
260
import math K = int(input()) Sum = [] for a in range(1, K+1): for b in range(1, K + 1): gcd2 = math.gcd(i.j) for c in range(1, K + 1): gcd = math.gcd(gcd2, c) Sum.append(gcd) print(sum(Sum))
import math K = int(input()) Sum = [] for a in range(1, K+1): for b in range(1, K + 1): gcd2 = math.gcd(a, b) for c in range(1, K + 1): gcd = math.gcd(gcd2, c) Sum.append(gcd) print(sum(Sum))
[["-", 0, 662, 12, 652, 3, 4, 0, 319, 500, 22], ["-", 0, 662, 12, 652, 3, 4, 0, 319, 0, 131], ["-", 0, 662, 12, 652, 3, 4, 0, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 21]]
5
83
K = int(input()) import math ans = 0 for i in range(1, K+1): for j in range(1, K+1): a = gcd(i, j) for k in range(1, K+1): ans += gcd(a,k) print(ans)
K = int(input()) import math ans = 0 for i in range(1, K+1): for j in range(1, K+1): a = math.gcd(i, j) for k in range(1, K+1): ans += math.gcd(a,k) print(ans)
[["+", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 0, 131], ["+", 0, 1, 0, 677, 12, 652, 63, 319, 500, 22], ["+", 0, 1, 0, 677, 12, 652, 63, 319, 0, 131]]
5
69
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b, int c) { int ans = 1; for (int i = 1; i <= min(min(a, b), c); i++) { if (a % i == 0 && b % i == 0 && c % i == 0) ans *= i; } return ans; } int main() { int n; cin >> n; long long ans = 0; for (int i = 1; i <= n; i++) { fo...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b, int c) { long long ans = 1; for (int i = 1; i <= min(min(a, b), c); i++) { if (a % i == 0 && b % i == 0 && c % i == 0) ans = i; } return ans; } int main() { long long n; cin >> n; long long ans = 0; for (int i = 1; i <= n; i+...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 17, 108], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 17, 32]]
1
160
from sys import stdin def gcd(x, y): if x % y == 0: return y return gcd(y, x % y) def main(): k = int(stdin.readline()) ans = 0 for a in range(1, k + 1): for b in range(a, k + 1): d = gcd(a, b) for c in range(b, k + 1): e = gcd(d, c) ...
from math import factorial from sys import stdin def gcd(x, y): if x % y == 0: return y return gcd(y, x % y) def main(): k = int(stdin.readline()) ans = 0 for a in range(1, k + 1): for b in range(a, k + 1): d = gcd(a, b) for c in range(b, k + 1): ...
[["+", 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], ["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 314]]
5
143
import math K=int(input()) total = 0 for a in range(1,K+1): for b in range(a+1,K+1): for c in range(b+1,K+1): total += math.gcd(a, math.gcd(b,c) ) total *= 6 for a in range(1,K+1): for b in range(a+1,K+1): total += math.gcd(a, b) total *= 6 for a in range(1,K+1): total += a print(total)
import math K=int(input()) total = 0 for a in range(1,K+1): for b in range(a+1,K+1): for c in range(b+1,K+1): total += math.gcd(a, math.gcd(b,c) ) * 6 for a in range(1,K+1): for b in range(a+1,K+1): total += math.gcd(a, b)*6 for a in range(1,K+1): total += a print(total)
[["-", 36, 36, 0, 656, 0, 1, 0, 677, 31, 22], ["-", 36, 36, 0, 656, 0, 1, 0, 677, 17, 108], ["+", 8, 196, 0, 1, 0, 677, 12, 657, 17, 48]]
5
131
import math k = int(input()) ans = 0 for a in range(k): for b in range(k): d = math.gcd(a + 1, b + 1) for c in range(k): ans += math(d, c + 1) print(ans)
import math k = int(input()) ans = 0 for a in range(k): for b in range(k): d = math.gcd(a + 1, b + 1) for c in range(k): ans += math.gcd(d, c + 1) print(ans)
[["+", 0, 1, 0, 677, 12, 652, 63, 319, 0, 131], ["+", 0, 1, 0, 677, 12, 652, 63, 319, 319, 22]]
5
65
n=int(input()) import math ans=0 for i in range(2,n+1): for j in range(1,n+1): ij=math.gcd(i,j) if ij==1: ans+=n else: for k in range(1,n+1): ans+=math.gcd(ij,k) print(ans)
n=int(input()) import math ans=0 for i in range(1,n+1): for j in range(1,n+1): ij=math.gcd(i,j) if ij==1: ans+=n else: for k in range(1,n+1): ans+=math.gcd(ij,k) print(ans)
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612]]
5
83
import math K = 200 #int(input()) total = 0 for a in range(1, K + 1): for b in range(1, K + 1): ab = math.gcd(a, b) for c in range(1, K + 1): total += math.gcd(ab, c) print(total)
import math K = int(input()) total = 0 for a in range(1, K + 1): for b in range(1, K + 1): ab = math.gcd(a, b) for c in range(1, K + 1): total += math.gcd(ab, c) print(total)
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 12, 612], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 24], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
69
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; typedef long long int LL; typedef vector<int> ivec; typedef vector<string> svec; const int MOD = 1000...
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; // typedef __int64 LL; typedef long long int LL; typedef vector<int> ivec; typedef vector<string> svec...
[["+", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 152], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
240
#include <bits/stdc++.h> using namespace std; template <class T> using V = vector<T>; template <class S, class T> using P = pair<S, T>; using ll = long long; using ull = unsigned long long; using vll = V<ll>; using vvll = V<vll>; using vvvll = V<vvll>; using pl = P<ll, ll>; using vpl = V<pl>; using vvpl = V<vpl>; usi...
#include <bits/stdc++.h> using namespace std; template <class T> using V = vector<T>; template <class S, class T> using P = pair<S, T>; using ll = long long; using ull = unsigned long long; using vll = V<ll>; using vvll = V<vll>; using vvvll = V<vvll>; using pl = P<ll, ll>; using vpl = V<pl>; using vvpl = V<vpl>; usi...
[["-", 0, 14, 8, 9, 0, 14, 49, 53, 49, 22], ["+", 0, 14, 8, 9, 0, 14, 49, 53, 49, 22]]
1
1,747
from math import gcd K = int(iniput()) sum_gcd = [0]*201 ans = 0 for i in range(1,K+1): for j in range(1,K+1): sum_gcd[gcd(i,j)] += 1 for i in range(1,K+1): for k in range(1,K+1): ans += sum_gcd[i]*gcd(i,k) print(ans)
from math import gcd K = int(input()) sum_gcd = [0]*201 ans = 0 for i in range(1,K+1): for j in range(1,K+1): sum_gcd[gcd(i,j)] += 1 for i in range(1,K+1): for k in range(1,K+1): ans += sum_gcd[i]*gcd(i,k) print(ans)
[["-", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 652, 63, 22]]
5
98
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; int sum = 0; for (int i = 1; i <= k; i++) { for (int j = 1; j <= k; j++) { for (int l = 1; l <= k; l++) { sum += __gcd(__gcd(i, j), k); } } } cout << sum; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; int sum = 0; for (int i = 1; i <= k; i++) { for (int j = 1; j <= k; j++) { for (int l = 1; l <= k; l++) { sum += __gcd(__gcd(i, j), l); } } } cout << sum; return 0; }
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
1
93
K = int(input()) S = 0 def gcd(a,b): while b != 0: a, b = b, a % b if b ==0: return a A1 = [0,0] A2 = [0,0,0] for i in range(1, K): S = S + i if K > 1: for j in range(1, K): A1[0] = j for k in range(j+1,K+1): A1[1] = k S += 6 * gcd(A1[1],A1[...
K = int(input()) S = 0 def gcd(a,b): while b != 0: a, b = b, a % b if b ==0: return a A1 = [0,0] A2 = [0,0,0] for i in range(1, K+1): S = S + i if K > 1: for j in range(1, K): A1[0] = j for k in range(j+1,K+1): A1[1] = k S += 6 * gcd(A1[1],A...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
243
#include <iostream> using namespace std; /* gcd(a,b,c) = gcd(gcd(a,b),c) */ int gcd(int a, int b) { /*ユークリッドの互除法*/ if (a % b == 0) return b; return gcd(b, a % b); } int main() { int k; int ans = 0; cin >> k; for (int i = 1; i <= k; i++) { for (int j = 1; j <= k; j++) { for (int l = 1; l <=...
#include <iostream> using namespace std; /* gcd(a,b,c) = gcd(gcd(a,b),c) */ int gcd(int a, int b) { /*ユークリッドの互除法*/ if (a % b == 0) return b; return gcd(b, a % b); } int main() { int k; int ans = 0; cin >> k; for (int i = 1; i <= k; i++) { for (int j = 1; j <= k; j++) { for (int l = 1; l <=...
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
1
126
from math import gcd k = int(input()) ans = 0 for i in range(1,k+1): for j in range(1,k+1): sub += gcd(i,j) for l in range(1,k+1): ans += gcd(sub,l) print(ans)
from math import gcd k = int(input()) ans = 0 for i in range(1,k+1): for j in range(1,k+1): sub = gcd(i,j) for l in range(1,k+1): ans += gcd(sub,l) print(ans)
[["-", 0, 7, 8, 196, 0, 1, 0, 677, 17, 107], ["+", 0, 7, 8, 196, 0, 1, 0, 662, 0, 32]]
5
71
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) int main() { int K; cin >> K; int sum = 0; rep(a, K) rep(b, K) rep(c, K) sum += gcd(a, gcd(b, c)); cout << sum << endl; }
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 1; i <= (n); i++) int main() { int K; cin >> K; int sum = 0; rep(a, K) rep(b, K) rep(c, K) sum += gcd(a, gcd(b, c)); cout << sum << endl; }
[["-", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59]]
1
72
K = int(input()) x = np.arange(1, K + 1) nums = np.gcd.outer(np.gcd.outer(x, x), x) print(nums.sum())
import numpy as np K = int(input()) x = np.arange(1, K + 1) nums = np.gcd.outer(np.gcd.outer(x, x), x) print(nums.sum())
[["+", 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
49
import math k = int(input())+1 for i in range(1, k): for j in range(1, k): temp = math.gcd(i, j) for x in range(1, k): sum += math.gcd(temp, x) print(sum)
import math sum = 0 k = int(input())+1 for i in range(1, k): for j in range(1, k): temp = math.gcd(i, j) for x in range(1, k): sum += math.gcd(temp, x) print(sum)
[["+", 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
66
from math import * K = int(input()) ans = 0 for i in range(1, K+1): for j in range(i, K+1): tmp = gcd(i, j) for k in range(j, K+1): ans += gcd(tmp, k) print(ans)
from math import * K = int(input()) ans = 0 for i in range(1, K+1): for j in range(1, K+1): tmp = gcd(i, j) for k in range(1, K+1): ans += gcd(tmp, k) print(ans)
[["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612]]
5
71
import math k = int(input()) gcd_sum_dict = collections.defaultdict(int) for i in range(1, k+1): gcd_sum_dict[i] = 0 for j in range(1, k+1): gcd_sum_dict[i] += gcd(i, j) ans = 0 for i in range(1, k+1): for j in range(1, k+1): ans += gcd_sum_dict[gcd(i, j)] print(ans)
import math import collections k = int(input()) gcd_sum_dict = collections.defaultdict(int) for i in range(1, k+1): gcd_sum_dict[i] = 0 for j in range(1, k+1): gcd_sum_dict[i] += math.gcd(i, j) ans = 0 for i in range(1, k+1): for j in range(1, k+1): ans += gcd_sum_dict[math.gcd(i, j)] pr...
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22], ["+", 0, 1, 0, 677, 12, 652, 63, 319, 500, 22], ["+", 0, 1, 0, 677, 12, 652, 63, 319, 0, 131], ["+", 0, 677, 12, 206, 206, 652, 63, 319, 500, 22], ["+", 0, 677, 12, 206, 206, 652, 63, 319, 0, 131]]
5
101
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int main() { int k; cin >> k; long long sum = 0; for (int i = 1; i <= k; i++) { for (int j = 1; j < k; j++) { for (int l = 1; l < k; l++) { sum += gcd(gcd(i, j), l); } } } c...
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int main() { int k; cin >> k; long long sum = 0; for (int i = 1; i <= k; i++) { for (int j = 1; j <= k; j++) { for (int l = 1; l <= k; l++) { sum += gcd(gcd(i, j), l); } } } ...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
120
#include <iostream> using namespace std; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { int k; cin >> k; int ans = 0; for (int i = 1; i <= k; ++i) { for (int j = 1; j <= k; ++j) { for (int l = 1; l <= k; ++l) { ans += gcd(i, gcd(j, k)); } } } cout << ans ...
#include <iostream> using namespace std; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { int k; cin >> k; long long ans = 0; for (int i = 1; i <= k; ++i) { for (int j = 1; j <= k; ++j) { for (int l = 1; l <= k; ++l) { ans += gcd(i, gcd(j, l)); } } } cout <...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 12, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 22]]
1
122
#include <bits/stdc++.h> using namespace std; int gcds(int i, int j, int k) { int e = gcd(i, j); int d = gcd(e, k); return d; } int main() { int k; cin >> k; int sum = 0; for (int i = 0; i < k + 1; i++) { for (int j = 0; j < k + 1; j++) { for (int l = 0; l < k + 1; l++) { sum = sum + gc...
#include <bits/stdc++.h> using namespace std; int gcds(int i, int j, int k) { int e = gcd(i, j); int d = gcd(e, k); return d; } int main() { int k; cin >> k; int sum = 0; for (int i = 1; i < k + 1; i++) { for (int j = 1; j < k + 1; j++) { for (int l = 1; l < k + 1; l++) { sum = sum + gc...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
134
#c import math k=int(input()) sum(math.gcd(math.gcd(a,b),c) for a in range(1,k+1)for b in range(1,k+1)for c in range(1,k+1))
#c import math k=int(input()) print( sum(math.gcd(math.gcd(a,b),c) for a in range(1,k+1)for b in range(1,k+1)for c in range(1,k+1)) )
[["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["+", 3, 668, 0, 659, 12, 652, 3, 4, 0, 25]]
5
62
#!/usr/bin/env python3 import sys import math # import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s) # from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.poplef...
#!/usr/bin/env python3 import sys import math # import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s) # from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.poplef...
[["+", 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
253
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; int res = 0; for (int i = 1; i <= k; i++) { for (int j = 1; j <= k; j++) { for (int x = 1; x <= k; x++) { int l = __gcd(j, x); res += __gcd(i, l); } } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; int res = 0; for (int i = 1; i <= k; i++) { for (int j = 1; j <= k; j++) { for (int x = 1; x <= k; x++) { int l = __gcd(j, x); res += __gcd(i, l); } } } cout << res; return 0; }
[["+", 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
94
#include <algorithm> #include <cmath> #include <iostream> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define mod 1000000007 #define mp make_pair #define rep(i, n) for (int i = 0; i < n; i++) #define _GLIBCXX_DEBUG #define _LIBCPP_DEBUG 0 using namespace std...
#include <algorithm> #include <cmath> #include <iostream> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #define mod 1000000007 #define mp make_pair #define rep(i, n) for (int i = 0; i < n; i++) #define _GLIBCXX_DEBUG #define _LIBCPP_DEBUG 0 using namespace std...
[["+", 0, 41, 64, 2, 3, 4, 0, 11, 17, 132], ["+", 0, 41, 64, 2, 3, 4, 0, 11, 12, 22]]
1
182
import math K = int(input()) count = 0 for i in range(1,K+1): for j in range(i,K+1): for k in range(1,K+1): if i != j: count += math.gcd(math.gcd(i,j),k) else: count += math.gcd(math.gcd(i,j),k) print(count)
import math K = int(input()) count = 0 for i in range(1,K+1): for j in range(i,K+1): for k in range(1,K+1): if i != j: count += 2 * math.gcd(math.gcd(i,j),k) else: count += math.gcd(math.gcd(i,j),k) print(count)
[["+", 64, 196, 0, 1, 0, 677, 12, 657, 31, 612], ["+", 64, 196, 0, 1, 0, 677, 12, 657, 17, 48]]
5
94
from math import gcd def gcd(a, b, c): g = gcd(a, b) return gcd(g, c) K = int(input()) ans = 0 for i in range(1, K+1): for j in range(1, K+1): for k in range(1, K+1): ans += gcd(i, j, k) print(ans)
from math import gcd def gcd_3(a, b, c): g = gcd(a, b) return gcd(g, c) K = int(input()) ans = 0 for i in range(1, K+1): for j in range(1, K+1): for k in range(1, K+1): ans += gcd_3(i, j, k) print(ans)
[["-", 36, 36, 36, 36, 0, 656, 0, 14, 141, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 14, 141, 22], ["-", 8, 196, 0, 1, 0, 677, 12, 652, 63, 22], ["+", 8, 196, 0, 1, 0, 677, 12, 652, 63, 22]]
5
90
K = int(input()) ans = 0 for i in range(1, K+1): for j in range(i, K+1): for k in range(j, K+1): if i==j and i==k: g = i elif (i==j and i!=k): g = math.gcd(i,math.gcd(j,k))*3 elif (i==k and i!=j): g = math.gcd(i,math.gcd(j,k))*3 ...
import math K = int(input()) ans = 0 for i in range(1, K+1): for j in range(i, K+1): for k in range(j, K+1): if i==j and i==k: g = i elif (i==j and i!=k): g = math.gcd(i,math.gcd(j,k))*3 elif (i==k and i!=j): g = math.gcd(i,math.gcd(j,k))...
[["+", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 0, 656, 0, 596, 141, 673, 0, 22]]
5
177
from math import gcd K = int(input()); sum = 0; for a in range(1,K+1): for b in range(1,K+1): for c in range(1,K+1): sum += gcd(gcd(a,b),c); print(gcd)
from math import gcd K = int(input()); sum = 0; for a in range(1,K+1): for b in range(1,K+1): for c in range(1,K+1): sum += gcd(gcd(a,b),c); print(sum)
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22]]
5
71
#include <bits/stdc++.h> using namespace std; #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define rep(i...
#include <bits/stdc++.h> using namespace std; #define IOS \ ios_base::sync_with_stdio(false); \ cin.tie(NULL); \ cout.tie(NULL); #define rep(i...
[["+", 8, 9, 0, 37, 0, 41, 75, 2, 63, 22], ["+", 0, 37, 0, 41, 75, 2, 3, 4, 0, 24], ["+", 0, 37, 0, 41, 75, 2, 3, 4, 0, 22], ["+", 0, 37, 0, 41, 75, 2, 3, 4, 0, 21], ["+", 0, 37, 0, 41, 75, 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
280
#include <algorithm> #include <bits/stdc++.h> #include <iostream> using namespace std; int gcd3(int a, int b, int c) { return gcd(gcd(a, b), c); } int main() { int a, b, c; int K; scanf("%d", &K); int sum = 0; for (a = 0; a <= K; a++) { for (b = 0; b <= K; b++) { for (c = 0; c <= K; c++) { ...
#include <algorithm> #include <bits/stdc++.h> #include <iostream> using namespace std; int gcd3(int a, int b, int c) { return gcd(gcd(a, b), c); } int main() { int a, b, c; int K; scanf("%d", &K); int sum = 0; for (a = 1; a <= K; a++) { for (b = 1; b <= K; b++) { for (c = 1; c <= K; c++) { ...
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 7, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 7, 8, 9, 0, 7, 10, 11, 12, 13]]
1
133
#ユークリッドの互除法 def euclid(m,n): # m > n となるように入れ替え if m < n: m, n = n, m while n != 0: m, n = n, m % n return m num = int(input('')) #input()で入力を受け取ってint()で数字型に変換します。 ans_sum = 0 for a in range(1,num+1): for b in range(1,num+1): gcd_ab = euclid(a,num+1) for c in rang...
#ユークリッドの互除法 def euclid(m,n): # m > n となるように入れ替え if m < n: m, n = n, m while n != 0: m, n = n, m % n return m num = int(input('')) #input()で入力を受け取ってint()で数字型に変換します。 ans_sum = 0 for a in range(1,num+1): for b in range(1,num+1): gcd_ab = euclid(a,b) for c in range(1,...
[["-", 0, 662, 12, 652, 3, 4, 0, 657, 31, 22], ["-", 0, 662, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 662, 12, 652, 3, 4, 0, 657, 12, 612], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 22]]
5
115
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; long long res = 0; for (int i = 1; i <= k; ++i) { for (int j = 1; j <= k; ++j) { for (int l = 1; l <= k; ++l) { res += gcd(i, gcd(j, k)); } } } cout << res << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; long long res = 0; for (int i = 1; i <= k; ++i) { for (int j = 1; j <= k; ++j) { for (int l = 1; l <= k; ++l) { res += gcd(i, gcd(j, l)); } } } cout << res << endl; return 0; }
[["-", 12, 2, 3, 4, 0, 2, 3, 4, 0, 22], ["+", 12, 2, 3, 4, 0, 2, 3, 4, 0, 22]]
1
96
#include <algorithm> #include <iostream> #include <math.h> using namespace std; int gcd(int a, int b, int c) { int temp; for (int i = 1; i < min(a, b) && i < min(b, c); ++i) { if (a % i == 0 && b % i == 0 && c % i == 0) { temp = i; } } return temp; } int main() { long long total = 0; int N; ...
#include <algorithm> #include <iostream> #include <math.h> using namespace std; int gcd(int a, int b, int c) { int temp; for (int i = 1; i <= min(a, b) && i <= min(b, c); ++i) { if (a % i == 0 && b % i == 0 && c % i == 0) { temp = i; } } return temp; } int main() { long long total = 0; int N...
[["-", 8, 9, 0, 7, 15, 16, 31, 16, 17, 18], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 17, 19], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 18], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 19]]
1
173
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int sum = 0; for (int i = 0; i < n; i++) { for (int k = 0; k < n; k++) { for (int j = 0; j < n; j++) { sum += gcd(i, gcd(k, j)); } } } cout << sum << endl; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int sum = 0; for (int i = 1; i <= n; i++) { for (int k = 1; k <= n; k++) { for (int j = 1; j <= n; j++) { sum += gcd(i, gcd(k, j)); } } } cout << sum << endl; }
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 19]]
1
92
#include <bits/stdc++.h> using namespace std; int main() { int K; cin >> K; int s = 0; for (int i = 0; i <= K; i++) { for (int j = 0; j <= K; j++) { for (int k = 0; k <= K; k++) { s += gcd(i, gcd(j, k)); } } } cout << s << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int K; cin >> K; int s = 0; for (int i = 1; i <= K; i++) { for (int j = 1; j <= K; j++) { for (int k = 1; k <= K; k++) { s += gcd(i, gcd(j, k)); } } } cout << s << endl; return 0; }
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
95
#include <bits/stdc++.h> using namespace std; int main() { long long n, m, k, sum = 0, a = 0, b = 0; long long mod = 1000000007; cin >> k; for (long i = 0; i <= k; i++) { for (long j = 0; j <= k; j++) { for (long l = 0; l <= k; l++) { sum += gcd(gcd(i, j), l); } } } cout << sum ...
#include <bits/stdc++.h> using namespace std; int main() { long n, m, k, sum = 0, a = 0, b = 0; long long mod = 1000000007; cin >> k; for (long i = 1; i <= k; i++) { for (long j = 1; j <= k; j++) { for (long l = 1; l <= k; l++) { sum += gcd(gcd(i, j), l); } } } cout << sum << en...
[["-", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 0, 30, 0, 14, 39, 86, 0, 96]]
1
142
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { int k; cin >> k; ll ans = 0; rep(a, k) rep(b, k) rep(c, k) ans += gcd(a, gcd(b, c)); cout << ans << endl; return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 1; i <= (int)(n); i++) int main() { int k; cin >> k; ll ans = 0; rep(a, k) rep(b, k) rep(c, k) ans += gcd(a, gcd(b, c)); cout << ans << endl; return 0; }
[["-", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59]]
1
81
import math from functools import reduce def gcd_list(numbers): return reduce(math.gcd, numbers) n=int(input()) l1=range(1,n+1) l2=range(1,n+1) l3=range(1,n+1) count=0 for i in l1: for j in l2: te=gcd(i,j) for k in l3: count+=(te,k) print(count)
import math from functools import reduce def gcd_list(numbers): return reduce(math.gcd, numbers) n=int(input()) l1=range(1,n+1) l2=range(1,n+1) l3=range(1,n+1) count=0 for i in l1: for j in l2: te=math.gcd(i,j) for k in l3: count+=math.gcd(te,k) print(count)
[["+", 0, 1, 0, 662, 12, 652, 63, 319, 500, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 0, 131], ["+", 0, 1, 0, 677, 12, 652, 63, 319, 500, 22], ["+", 0, 1, 0, 677, 12, 652, 63, 319, 0, 131], ["+", 0, 1, 0, 677, 12, 652, 63, 319, 319, 22]]
5
96
K=gets.chomp.to_i i=0 1.upto(K){|a| 1.upto(K){|b| 1.upto(K){|c| d=a.gcd(b).gcd(c) if i < d i=d end } } } puts i
K=gets.chomp.to_i i=0 1.upto(K){|a| 1.upto(K){|b| 1.upto(K){|c| d=a.gcd(b).gcd(c) i+=d } } } puts i
[["-", 0, 652, 196, 196, 8, 734, 0, 121, 0, 121], ["-", 196, 196, 8, 734, 0, 121, 15, 738, 17, 18], ["-", 196, 196, 8, 734, 0, 121, 15, 738, 12, 22], ["-", 8, 734, 0, 121, 64, 749, 0, 662, 31, 22], ["-", 8, 734, 0, 121, 64, 749, 0, 662, 0, 32], ["+", 0, 652, 196, 196, 8, 734, 0, 755, 17, 107], ["-", 0, 652, 196, 196, 8...
4
66
#include <algorithm> #include <iostream> using namespace std; int n; int main() { scanf("%d", &n); int ans = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { int temp = __gcd(i, j); for (int k = 1; k <= n; k++) { ans += __gcd(i, temp); } } } cout << ans << ...
#include <algorithm> #include <iostream> using namespace std; int n; int main() { scanf("%d", &n); int ans = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { int temp = __gcd(i, j); for (int k = 1; k <= n; k++) { ans += __gcd(k, temp); } } } cout << ans << ...
[["-", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22], ["+", 0, 1, 0, 11, 12, 2, 3, 4, 0, 22]]
1
108
import java.util.*; class Main { private static int gcd(int a, int b) { if (a < b) return gcd(b, a); if (b == 1) return a; return gcd(b, b % a); } static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int N = sc.nextInt(); int ans = 0; for (int ...
import java.util.*; class Main { private static int gcd(int a, int b) { if (a < b) return gcd(b, a); if (b == 0) return a; return gcd(b, a % b); } static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int N = sc.nextInt(); int ans = 0; for (int ...
[["-", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["-", 0, 37, 0, 492, 3, 4, 0, 16, 31, 22], ["-", 0, 37, 0, 492, 3, 4, 0, 16, 17, 109], ["+", 0, 37, 0, 492, 3, 4, 0, 16, 17, 109], ["+", 0, 37, 0, 492, 3, 4, 0, 16, 12, 22]]
3
168
import math from functools import reduce def resolve(): k = int(input()) ans = 0 for i in range(1, k+1): for j in range(1, k + 1): for k in range(1, k + 1): ans += reduce(math.gcd, [i, j, k]) print(ans) ressolve()
import math from functools import reduce def resolve(): k = int(input()) ans = 0 for i in range(1, k+1): for j in range(1, k + 1): for k in range(1, k + 1): ans += reduce(math.gcd, [i, j, k]) print(ans) resolve()
[["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22]]
5
81
#include <stdio.h> int main(void) { int K, a, b, c; long int sum = 0; scanf("%d", &K); for (a = 1; a <= K; a++) { for (b = 1; b <= K; b++) { for (c = 1; c <= K; c++) { sum += gcd3(a, b, c); } } } printf("%d", sum); return 0; } int gcd2(int a, int b) { if (b == 0) retu...
#include <stdio.h> int main(void) { int K, a, b, c; long int sum = 0; scanf("%d", &K); for (a = 1; a <= K; a++) { for (b = 1; b <= K; b++) { for (c = 1; c <= K; c++) { sum += gcd3(a, b, c); } } } printf("%ld", sum); return 0; } int gcd2(int a, int b) { if (b == 0) ret...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 14, 8, 9, 0, 37, 0, 2, 63, 22]]
0
158
import math k = int(input()) sum =0 for a in range(1, k+1): for b in range(1, k+1): x = gcd(a, b) for c in range(1, k+1): sum += gcd(x, c) print(sum)
from math import gcd k = int(input()) sum =0 for a in range(1, k+1): for b in range(1, k+1): x = gcd(a, b) for c in range(1, k+1): sum += gcd(x, c) print(sum)
[["-", 36, 36, 36, 36, 0, 656, 0, 596, 0, 487], ["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 314], ["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 487], ["+", 36, 36, 0, 656, 0, 686, 141, 673, 0, 22]]
5
69
// BISMILLAH #include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return (b, a % b); } int main() { int n, sum = 0, flag = 0; cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) for (int k = 1; k <= n; k++) { sum += gcd(i, gcd(j, k)...
// BISMILLAH #include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int main() { int n, sum = 0, flag = 0; cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) for (int k = 1; k <= n; k++) sum += gcd(i, gcd(j, ...
[["+", 0, 14, 8, 9, 0, 37, 0, 2, 63, 22], ["-", 0, 7, 8, 7, 8, 7, 8, 9, 0, 45], ["-", 0, 7, 8, 7, 8, 7, 8, 9, 0, 46]]
1
121
#include <bits/stdc++.h> using namespace std; using ll = long long; #define FOR(i, m, n) for (int i = (m); i < (n); i++) #define print(n) cout << n << "/n" int main() { int K; cin >> K; ll ans = 0; FOR(a, 1, K + 1) FOR(b, 1, K + 1) FOR(c, 1, K + 1) ans += __gcd(a, __gcd(b, c)); print(ans); }
#include <bits/stdc++.h> using namespace std; using ll = long long; #define FOR(i, m, n) for (int i = (m); i < (n); i++) #define print(n) cout << n << endl int main() { int K; cin >> K; ll ans = 0; FOR(a, 1, K + 1) FOR(b, 1, K + 1) FOR(c, 1, K + 1) ans += __gcd(a, __gcd(b, c)); print(ans); return 0; }
[["-", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 112, 51, 59], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 38], ["+", 0, 30, 0, 14, 8, 9, 0, 37, 0, 13]]
1
97
from itertools import combinations import math n = int(input()) ans = 0 for r in range(1,4): if r>n: break for x in combinations([x+1 for x in range(n)],r): if len(x)==1: ans += x[0] elif len(x)==2: ans += math.gcd(x[0],x[1])*6 else: tmp = ma...
from itertools import combinations import math n = int(input()) ans = 0 for r in range(1,4): if r>n: break for x in combinations([x+1 for x in range(n)],r): if len(x)==1: ans += x[0] elif len(x)==2: ans += math.gcd(x[0],x[1])*6 else: tmp = ma...
[["+", 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
127
import math K=int(input()) sum=0 for i in range(1, K): for j in range(i, K+1): for k in range(j, K+1): sum+=math.gcd(math.gcd(i, j), k) print(3*sum)
import math K=int(input()) sum=0 for i in range(1, K+1): for j in range(1, K+1): for k in range(1, K+1): sum+=math.gcd(math.gcd(i, j), k) print(sum)
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 31, 612], ["-", 0, 1, 0, 652, 3, 4, 0, 657, 17, 48]]
5
70
#include <bits/stdc++.h> using namespace std; using ll = long long; int gcd(int x, int y) { int r; // 引数チェック if (x == 0 || y == 0) { return 0; } // ユーグリッドの互除法 // yで割り切れるまでループ while ((r = x % y) != 0) { x = y; y = r; } return y; } int main(int argc, const char *argv[]) { int k; cin...
#include <bits/stdc++.h> using namespace std; using ll = long long; int gcd(int x, int y) { int r; // 引数チェック if (x == 0 || y == 0) { return 0; } // ユーグリッドの互除法 // yで割り切れるまでループ while ((r = x % y) != 0) { x = y; y = r; } return y; } int main(int argc, const char *argv[]) { int k; cin...
[["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
174