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
change_count
int64
0
100
#include <cmath> #include <iostream> using namespace std; int main(void) { int n; cin >> n; bool f1 = false; for (int j = n - 1; j > 1; j--) { for (int i = 2; i <= sqrt(j); i++) { if ((j % i) == 0) { f1 = true; break; } } if (!f1) { cout << j << " "; break...
#include <cmath> #include <iostream> using namespace std; int main(void) { int n; while (cin >> n) { bool f1 = false; for (int j = n - 1; j > 1; j--) { for (int i = 2; i <= sqrt(j); i++) { if ((j % i) == 0) { f1 = true; break; } } if (!f1) { ...
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 52, 8, 9, 0, 7, 8, 9, 0, 46]]
1
180
6
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <string> #include <vector> #define loop(i, b, n) for (int i = b; i < n; i++) #define rep(i, n) loop(i, 0, n) #define INF 10000 #define MAX 1e6 using namespace std; int main() { vector<bool> check(MAX + 1); rep(i, MAX + 1) check[i...
#include <algorithm> #include <cmath> #include <cstring> #include <iostream> #include <string> #include <vector> #define loop(i, b, n) for (int i = b; i < n; i++) #define rep(i, n) loop(i, 0, n) #define INF 10000 #define MAX 1e7 using namespace std; int main() { vector<bool> check(MAX + 1); rep(i, MAX + 1) check[i...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22]]
1
252
4
#include <algorithm> #include <cctype> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <vector> using namespace std; bool is_prime(int x) { for (int i = 2; i...
#include <algorithm> #include <cctype> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <vector> using namespace std; bool is_prime(int x) { for (int i = 2; i...
[["-", 8, 9, 0, 52, 15, 339, 51, 27, 17, 68], ["+", 8, 9, 0, 52, 15, 339, 51, 27, 17, 29]]
1
147
2
#include <bits/stdc++.h> using namespace std; using db = double; using ll = long long; using vi = vector<int>; #define op operator #define pb push_back const int N = 6e4L + 11; int p[N]; int main() { iota(p, p + N, 0); for (int i = 2; i < N; i++) if (p[i] == i) for (int j = i; j < N; j += i) p[...
#include <bits/stdc++.h> using namespace std; using db = double; using ll = long long; using vi = vector<int>; #define op operator #define pb push_back const int N = 6e4L + 11; int p[N]; int main() { iota(p, p + N, 0); for (int i = 2; i < N; i++) if (p[i] == i) for (int j = i; j < N; j += i) p[...
[["-", 64, 9, 0, 1, 0, 16, 12, 103, 0, 125], ["+", 64, 9, 0, 1, 0, 16, 12, 103, 0, 44]]
1
197
2
#include <iostream> using namespace std; bool is_sosu(int a) { for (int i = 2; i * i < a; i++) { if (a % i == 0) return false; } return true; } int main() { int n; while (cin >> n) { for (int i = n - 1; i >= 2; i--) { if (is_sosu(i)) { cout << i << " "; break; } ...
#include <iostream> using namespace std; bool is_sosu(int a) { for (int i = 2; i * i <= a; i++) { if (a % i == 0) return false; } return true; } int main() { int n; while (cin >> n) { for (int i = n - 1; i >= 2; i--) { if (is_sosu(i)) { cout << i << " "; break; } ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
135
2
#include <iostream> #include <vector> using namespace std; bool IsPrime[60000]; vector<int> Prime; void PrimeCalc() { for (int i = 0; i < 60000; ++i) { IsPrime[i] = true; } IsPrime[0] = IsPrime[1] = false; for (int i = 2; i < 60000; ++i) { if (IsPrime[i]) { Prime.push_back(i); for (int j =...
#include <iostream> #include <vector> using namespace std; bool IsPrime[60000]; vector<int> Prime; void PrimeCalc() { for (int i = 0; i < 60000; ++i) { IsPrime[i] = true; } IsPrime[0] = IsPrime[1] = false; for (int i = 2; i < 60000; ++i) { if (IsPrime[i]) { Prime.push_back(i); for (int j =...
[["-", 15, 339, 51, 69, 341, 342, 0, 69, 28, 22], ["-", 51, 69, 341, 342, 0, 69, 341, 342, 0, 70], ["-", 51, 69, 341, 342, 0, 69, 341, 342, 0, 22], ["-", 51, 69, 341, 342, 0, 69, 341, 342, 0, 73], ["+", 0, 57, 15, 339, 51, 69, 341, 342, 0, 22]]
1
218
5
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; while (cin >> n) { bool prime[500000]; fill(prime, prime + 500000, 0); vector<int> nums; for (int i = 2; i < 500000; ++i) { if (prime[i]) continue; nums.push_back(i); for (i...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { int n; while (cin >> n) { bool prime[500000]; fill(prime, prime + 500000, 0); vector<int> nums; for (int i = 2; i < 500000; ++i) { if (prime[i]) continue; nums.push_back(i); for (i...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79]]
1
196
2
#include <iostream> #include <string> using namespace std; int main() { bool prime[60000]; for (int i = 0; i < 60000; i++) { prime[i] = 1; } prime[0] = prime[1] = 0; for (int i = 0; i * i < 60000; i++) { if (prime[i] == 1) { for (int j = i * 2; j < 60000; j += i) { prime[j] = 0; }...
#include <iostream> #include <string> using namespace std; int main() { bool prime[60000]; for (int i = 0; i < 60000; i++) { prime[i] = 1; } prime[0] = prime[1] = 0; for (int i = 0; i * i < 60000; i++) { if (prime[i] == 1) { for (int j = i * 2; j < 60000; j += i) { prime[j] = 0; }...
[["-", 0, 52, 8, 9, 0, 7, 26, 27, 17, 68], ["+", 0, 52, 8, 9, 0, 7, 26, 27, 17, 29]]
1
180
2
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <vector> using namespace std; int main() { const int END = -1; const int NUM = 50000; int num; int i, index, index2, index3; cin >> num; vector<int> eratos(NUM); for (i = 0; i < NUM - 1; i++) eratos[i] = i + 2; ...
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <vector> using namespace std; int main() { const int END = -1; const int NUM = 50022; int num; int i, index, index2, index3; cin >> num; vector<int> eratos(NUM); for (i = 0; i < NUM - 1; i++) eratos[i] = i + 2; ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13], ["-", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 103, 0, 104]]
1
285
8
#include <cstdio> #include <cstring> #include <iostream> using namespace std; int main(void) { int prime[50000]; int prime_f[51001]; int k; int n; int i, j; int n_size; while (cin >> n) { k = 0; memset(prime_f, 0, sizeof(prime_f)); prime_f[0] = prime_f[1] = 1; for (i = 2; i < 51000; i++...
#include <cstdio> #include <cstring> #include <iostream> using namespace std; int main(void) { int prime[50000]; int prime_f[51001]; int k; int n; int i, j; int n_size; while (cin >> n) { k = 0; memset(prime_f, 0, sizeof(prime_f)); prime_f[0] = prime_f[1] = 1; for (i = 2; i < 51000; i++...
[["-", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 7, 15, 16, 12, 13], ["-", 64, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 64, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 17, 33], ["+", 31, 16, 12, 69, 341, 342, 0, 16, 12, 13], ["-", 31, 16, 12, 69, 341, 342, 0, 16, 17, 72...
1
228
8
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; const int SIZE = 50100; bool isP[SIZE]; int main() { fill(isP, isP + SIZE + 1, true); for (int i = 2; i <= SIZE; i++) { if (isP[i]) { for (int j = i * 2;...
#include <algorithm> #include <cstdio> #include <cstdlib> #include <iostream> #include <map> #include <string> #include <vector> using namespace std; const int SIZE = 50100; bool isP[SIZE]; int main() { fill(isP, isP + SIZE + 1, true); for (int i = 2; i <= SIZE; i++) { if (isP[i]) { for (int j = i * 2;...
[["-", 0, 57, 64, 9, 0, 1, 0, 16, 12, 22], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 62], ["+", 64, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
184
4
#include <iostream> using namespace std; int main() { bool num[10001] = {false}; for (int i = 2; i < 100; i++) if (!num[i]) for (int j = i * i; j < 10001; j += i) num[j] = true; for (int n; cin >> n;) { for (int i = n - 1;; i--) if (!num[i]) { cout << i << " "; break; ...
#include <iostream> using namespace std; int main() { bool num[1000001] = {false}; for (int i = 2; i < 1000; i++) if (!num[i]) for (int j = i * i; j < 1000001; j += i) num[j] = true; for (int n; cin >> n;) { for (int i = n - 1;; i--) if (!num[i]) { cout << i << " "; bre...
[["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 7, 8, 57, 64, 7, 15, 16, 12, 13], ["+", 0, 7, 8, 57, 64, 7, 15, 16, 12, 13]]
1
147
19
#include <iostream> using namespace std; bool prime(int x) { if (x == 0 || x == 1) return false; for (int i = 2; i * i < x; i++) { if (x % i == 0) return false; } return true; } int main() { int n, nl, nh; while (cin >> n) { nl = n; nh = n; while (1) { nl--; if (prime...
#include <iostream> using namespace std; bool prime(int x) { if (x == 0 || x == 1) return false; for (int i = 2; i * i <= x; i++) { if (x % i == 0) return false; } return true; } int main() { int n, nl, nh; while (cin >> n) { nl = n; nh = n; while (1) { nl--; if (prim...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
139
2
#include <iostream> using namespace std; int main() { int n; cin >> n; int math[100000] = {0}; math[1] = 1; for (int i = 2; i < 100000; i++) { int bell = i; while (bell + i <= 100000) { bell += i; if (math[bell] == 0) { math[bell] = 1; } } } int hess = n; while (1)...
#include <iostream> using namespace std; int main() { int n; while (cin >> n) { int math[100000] = {0}; math[1] = 1; for (int i = 2; i < 100000; i++) { int bell = i; while (bell + i <= 100000) { bell += i; if (math[bell] == 0) { math[bell] = 1; } } ...
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 24], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 46]]
1
161
6
n = 50021 a = Array.new(n){|i| i+1} a[0] = 0 (2..n**(0.50)).each do |i| (2..(n/i)).each{|j| a[i*j-1] = 0} if a[i-1]>0 end a.delete(0) while gets q = $_.to_i i = 1 while a[i] < q do i+=1 end puts "#{a[i-1]}, #{a[i]==q ? a[i+1]:a[i]}" end
n = 50021 a = Array.new(n){|i| i+1} a[0] = 0 (2..n**(0.50)).each do |i| (2..(n/i)).each{|j| a[i*j-1] = 0} if a[i-1]>0 end a.delete(0) while gets q = $_.to_i i = 1 while a[i] < q do i+=1 end puts "#{a[i-1]} #{a[i]==q ? a[i+1]:a[i]}" end
[["-", 8, 170, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 8, 170, 0, 652, 3, 4, 0, 557, 0, 6]]
4
137
2
var input = require('fs').readFileSync('/dev/stdin', 'utf8'); var Arr = (input.trim()).split("\n"); var cnt = 1; while (true) { var W = Arr.shift() - 0; if (W == 0) break; var N = Arr.shift() - 0; var dp = []; for (var y = 0; y < N + 1; y++) { dp[y] = []; for (var x = 0; x <= W; x++) { dp[y]...
var input = require('fs').readFileSync('/dev/stdin', 'utf8'); var Arr = (input.trim()).split("\n"); var cnt = 1; while (true) { var W = Arr.shift() - 0; if (W == 0) break; var N = Arr.shift() - 0; var dp = []; for (var y = 0; y < N + 1; y++) { dp[y] = []; for (var x = 0; x <= W; x++) { dp[y]...
[["-", 0, 2, 3, 3, 0, 69, 500, 69, 71, 22], ["+", 0, 2, 3, 3, 0, 69, 500, 69, 71, 22], ["-", 0, 198, 0, 200, 51, 69, 500, 69, 71, 22], ["+", 0, 198, 0, 200, 51, 69, 500, 69, 71, 22], ["-", 15, 23, 0, 16, 12, 69, 500, 69, 71, 22], ["+", 15, 23, 0, 16, 12, 69, 500, 69, 71, 22]]
2
378
6
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int cnt = 1; while (sc.hasNext()) { int W = sc.nextInt(); if (W == 0) break; int N = sc.nextInt(); int[] dp = new int[W + 1]...
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int cnt = 1; while (sc.hasNext()) { int W = sc.nextInt(); if (W == 0) break; int N = sc.nextInt(); int[] dp = new int[W + 1]...
[["-", 8, 196, 0, 1, 0, 492, 3, 4, 0, 22], ["+", 8, 196, 0, 1, 0, 492, 3, 4, 0, 22]]
3
376
4
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { try (Scanner sc = new Scanner(System.in)) { int count = 0; while (true) { int W = sc.nextInt(); if (W == 0) break; count++; int N = sc.nextInt(); /...
import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { try (Scanner sc = new Scanner(System.in)) { int count = 0; while (true) { int W = sc.nextInt(); if (W == 0) break; count++; int N = sc.nextInt(); /...
[["+", 0, 1, 0, 492, 3, 4, 0, 16, 17, 72], ["+", 0, 492, 3, 4, 0, 16, 12, 5, 0, 62], ["+", 0, 492, 3, 4, 0, 16, 12, 5, 0, 491]]
3
352
4
import java.util.*; public class Main { Scanner sc = new Scanner(System.in); public static void main(String[] args) { new Main(); } public Main() { new aoj0042().doIt(); } class aoj0042 { void DP(int W, int TE[], int TW[], int n, int sum[]) { for (int i = 0; i < n; i++) { for (int j = W; j...
import java.util.*; public class Main { Scanner sc = new Scanner(System.in); public static void main(String[] args) { new Main(); } public Main() { new aoj0042().doIt(); } class aoj0042 { void DP(int W, int TE[], int TW[], int n, int sum[]) { for (int i = 0; i < n; i++) { for (int j = W; j...
[["-", 49, 200, 51, 227, 497, 505, 0, 16, 31, 499], ["+", 49, 200, 51, 227, 497, 505, 0, 16, 31, 499]]
3
428
2
import java.io.*; class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = ""; int count = 1; while (!(line = br.readLine()).equals("0")) { int weight = 0; int W = Integer.parseInt(line...
import java.io.*; class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = ""; int count = 1; while (!(line = br.readLine()).equals("0")) { int weight = 0; int W = Integer.parseInt(line...
[["-", 0, 7, 502, 503, 49, 200, 51, 16, 17, 33], ["-", 0, 7, 502, 503, 49, 200, 51, 16, 12, 499]]
3
477
2
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int No = 1; while (true) { int W = in.nextInt(); if (W == 0) break; int N = in.nextInt(); List<Integer> va = new ArrayList<>(), wa = new ArrayList<>(); ...
import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int No = 1; while (true) { int W = in.nextInt(); if (W == 0) break; int N = in.nextInt(); List<Integer> va = new ArrayList<>(), wa = new ArrayList<>(); ...
[["-", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491], ["+", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491], ["+", 8, 196, 0, 52, 8, 196, 0, 1, 0, 35], ["+", 0, 52, 8, 196, 0, 1, 0, 27, 0, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 27, 0, 29]]
3
392
5
import java.util.*; class Main { public static void main(String[] z) { Scanner s = new Scanner(System.in); for (int t = 1, W, v, w, i, n; (W = s.nextInt()) > 0; System.out.printf("Case %d:\n%d\n%d\n", t++, v, w)) { int[] d = new int[W + 1]; for (n = s.nextInt(); n-- > 0; d[w] = d[w] > v ?...
import java.util.*; class Main { public static void main(String[] z) { Scanner s = new Scanner(System.in); for (int t = 1, W, v, w, i, n; (W = s.nextInt()) > 0; System.out.printf("Case %d:\n%d\n%d\n", t++, v, w)) { int[] d = new int[W + 1]; for (n = s.nextInt(); n-- > 0; d[w] = d[w] > v ?...
[["-", 0, 7, 8, 7, 15, 16, 31, 27, 0, 68], ["+", 8, 196, 0, 7, 8, 7, 26, 27, 0, 68], ["+", 8, 196, 0, 7, 8, 7, 26, 27, 0, 22]]
3
256
3
import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; import java.io.*; import java.util.*; public class Main { int INF = 1 << 28; // long INF = 1L << 62; double EPS = 1e-10; void run() { Scanner sc = new Scanner(System.in); for (int c = 1;; c++) {...
import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; import java.io.*; import java.util.*; public class Main { int INF = 1 << 28; // long INF = 1L << 62; double EPS = 1e-10; void run() { Scanner sc = new Scanner(System.in); for (int c = 1;; c++) {...
[["-", 3, 4, 0, 16, 31, 16, 31, 5, 0, 491], ["+", 3, 4, 0, 16, 31, 16, 31, 5, 0, 491]]
3
428
2
import java.util.*; public class Main { public void doIt() { Scanner sc = new Scanner(System.in); int count = 1; while (true) { int w = sc.nextInt(); if (w == 0) break; int n = sc.nextInt(); int[][] dp = new int[n + 1][w + 1]; int[][] data = new int[n + 1][2]; ...
import java.util.*; public class Main { public void doIt() { Scanner sc = new Scanner(System.in); int count = 1; while (true) { int w = sc.nextInt(); if (w == 0) break; int n = sc.nextInt(); int[][] dp = new int[n + 1][w + 1]; int[][] data = new int[n + 1][2]; ...
[["-", 0, 52, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 196, 0, 7, 15, 16, 17, 19]]
3
423
2
import static java.lang.Math.*; import static java.lang.System.out; import java.util.*; import java.util.regex.*; // AOJ public class Main { Scanner sc = new Scanner(System.in); public static void main(String[] args) { new Main().AOJ0042(); } void AOJ0004() { while (sc.hasNext()) { int a = sc.nextInt...
import static java.lang.Math.*; import static java.lang.System.out; import java.util.*; import java.util.regex.*; // AOJ public class Main { Scanner sc = new Scanner(System.in); public static void main(String[] args) { new Main().AOJ0042(); } void AOJ0004() { while (sc.hasNext()) { int a = sc.nextInt...
[["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19]]
3
5,569
2
import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); for (int i = 1;; i++) { int w = sc.nextInt(); if (w == 0) { break; } int n = sc.nextInt(); int[][] treasure = new int[n][2]; for (int j = 0; j < n; j++) {...
import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); for (int i = 1;; i++) { int w = sc.nextInt(); if (w == 0) { break; } int n = sc.nextInt(); int[][] treasure = new int[n][2]; for (int j = 0; j < n; j++) {...
[["-", 0, 57, 15, 15, 0, 16, 31, 16, 17, 47], ["+", 0, 57, 15, 15, 0, 16, 31, 16, 17, 20]]
3
511
2
import static java.lang.System.out; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String args[]) { new Main().run(); } int toInt(String s) { return Integer.parseInt(s); } void run() { Scanner sc = new Scanner(System.in); int caseNumber = 1; while (t...
import static java.lang.System.out; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String args[]) { new Main().run(); } int toInt(String s) { return Integer.parseInt(s); } void run() { Scanner sc = new Scanner(System.in); int caseNumber = 1; while (t...
[["-", 0, 492, 3, 4, 0, 16, 31, 5, 0, 491], ["+", 3, 4, 0, 16, 31, 16, 31, 5, 0, 491], ["+", 0, 1, 0, 492, 3, 4, 0, 16, 17, 72], ["+", 0, 492, 3, 4, 0, 16, 12, 5, 0, 62], ["+", 0, 492, 3, 4, 0, 16, 12, 5, 0, 491]]
3
467
6
import java.util.Scanner; public class Main { public static void main(String[] arg) { Scanner in = new Scanner(System.in); int case_ = 0; while (in.hasNext()) { int w = in.nextInt(); if (w != 0) { System.out.print("case "); System.out.print(++case_); System.out.println...
import java.util.Scanner; public class Main { public static void main(String[] arg) { Scanner in = new Scanner(System.in); int case_ = 0; while (in.hasNext()) { int w = in.nextInt(); if (w != 0) { System.out.print("Case "); System.out.print(++case_); System.out.println...
[["-", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491], ["+", 0, 1, 0, 492, 3, 4, 0, 5, 0, 491]]
3
273
45
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] args) { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); List<String> inputDataList = ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; public class Main { public static void main(String[] args) { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); List<String> inputDataList = ...
[["+", 0, 7, 502, 503, 49, 200, 51, 16, 17, 33], ["+", 0, 7, 502, 503, 49, 200, 51, 16, 12, 499]]
3
508
2
import java.util.Arrays; import java.util.Scanner; import java.util.Stack; public class Main { static int W, N; static int[][] dp; static int[][] a; static Stack<Integer> stack; public static void main(String[] args) { Scanner cin = new Scanner(System.in); int T = 0; for (;;) { T++; ...
import java.util.Arrays; import java.util.Scanner; import java.util.Stack; public class Main { static int W, N; static int[][] dp; static int[][] a; static Stack<Integer> stack; public static void main(String[] args) { Scanner cin = new Scanner(System.in); int T = 0; for (;;) { T++; ...
[["-", 0, 11, 12, 227, 497, 505, 0, 16, 12, 499], ["+", 0, 11, 12, 227, 497, 505, 0, 16, 12, 499], ["-", 0, 7, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 7, 8, 196, 0, 7, 15, 16, 17, 19], ["-", 3, 4, 0, 16, 12, 23, 0, 16, 17, 33], ["-", 3, 4, 0, 16, 12, 23, 0, 16, 12, 499]]
3
787
6
#include <stdio.h> int mx(int a, int b) { if (a < b) return b; else return a; } int main() { int N, W, c = 1, mi, max, i, j; int k[1001], w[1001]; while (1) { scanf("%d", &W); if (!W) break; scanf("%d", &N); int dp[1001][1001] = {0}; for (i = 0; i < N; i++) { scanf("%d,...
#include <stdio.h> int mx(int a, int b) { if (a < b) return b; else return a; } int main() { int N, W, c = 1, mi, max, i, j; int k[1001], w[1001]; while (1) { scanf("%d", &W); if (!W) break; scanf("%d", &N); int dp[1001][1001] = {0}; for (i = 0; i < N; i++) { scanf("%d,...
[["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
0
316
2
#include <stdio.h> int max(int a, int b) { return a > b ? a : b; } int W, N, v[1000], w[1000], dp[1001][1001]; int main(void) { int n_case = 1; while (1) { int x, y; scanf("%d", &W); if (W == 0) break; scanf("%d", &N); for (x = 0; x < N; x++) { scanf("%d,%d", &v[x], &w[x]); } ...
#include <stdio.h> int max(int a, int b) { return a > b ? a : b; } int W, N, v[1001], w[1001], dp[1001][1001]; int main(void) { int n_case = 1; while (1) { int x, y; scanf("%d", &W); if (W == 0) break; scanf("%d", &N); for (x = 1; x <= N; x++) { scanf("%d,%d", &v[x], &w[x]); }...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
0
328
8
#include <limits.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> int main() { int W, N, i, j, k, max_coin = 0, weg = 0, count = 0; int wg, coin; int dp[102][102] = {}; while (1) { scanf("%d", &W); if (W == 0) break; scanf("%d", &N); for ...
#include <limits.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> int main() { int W, N, i, j, k, max_coin = 0, weg = 0, count = 0; int wg, coin; int dp[1002][1002] = {}; while (1) { scanf("%d", &W); if (W == 0) break; scanf("%d", &N); fo...
[["-", 0, 43, 49, 50, 49, 80, 49, 80, 81, 13], ["+", 0, 43, 49, 50, 49, 80, 49, 80, 81, 13], ["-", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13], ["+", 8, 9, 0, 43, 49, 50, 49, 80, 81, 13]]
0
266
4
#include <stdio.h> #define max(a, b) (a) > (b) ? (a) : (b); main() { int N, W; int v[1000], w[1000]; int dp[2][1001] = { { 0, }, }; int i, j; int maxv, minw; int c = 1; while (scanf("%d", &W) != EOF) { if (!W) break; for (i = 0; i <= W; i++) dp[0][i] = 0; ...
#include <stdio.h> #define max(a, b) (a) > (b) ? (a) : (b); main() { int N, W; int v[1000], w[1000]; int dp[2][1001] = { { 0, }, }; int i, j; int maxv, minw; int c = 1; while (scanf("%d", &W) != EOF) { if (!W) break; for (i = 0; i <= W; i++) dp[0][i] = 0; ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
348
2
t[9999][9999], j; main(p, W, a, b, c) { for (; scanf("%d", &W), W; printf("Case %d:\n%d\n%d\n", p++, t[0][W], j)) { for (scanf("%d", &c); c && scanf("%d,%d", &b, &a); c--) { for (j = 0; j <= W; j++) { t[c - 1][j] = (j < a) ? t[c][j] : (t[c][j] > t[c][j - ...
t[9999][9999], j; main(p, W, a, b, c) { for (; scanf("%d", &W), W; printf("Case %d:\n%d\n%d\n", p++, t[0][W], j)) { for (scanf("%d", &c); c && scanf("%d,%d", &b, &a); c--) { for (j = 0; j <= W; j++) { t[c - 1][j] = (j < a) ? t[c][j] : (t[c][j] > t[c][j - ...
[["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 60], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 79]]
0
208
2
t[9999][9999], j; main(p, W, a, b, c) { for (; scanf("%d", &W), W; printf("Case %d:\n%d\n%d\n", p++, t[0][W], j)) { for (scanf("%d", &c); c && scanf("%d,%d", &b, &a); c--) for (j = 0; j <= W; j++) t[c - 1][j] = (j < a) ? t[c][j] : (t[c][j] > t[c][j - a] + ...
t[9999][999], j; main(p, W, a, b, c) { for (; scanf("%d", &W), W; printf("Case %d:\n%d\n%d\n", p++, t[0][W], j)) { for (scanf("%d", &c); c && scanf("%d,%d", &b, &a); c--) for (j = 0; j <= W; j++) t[c - 1][j] = (j < a) ? t[c][j] : (t[c][j] > t[c][j - a] + b...
[["-", 36, 36, 0, 30, 0, 1, 0, 69, 71, 13], ["+", 36, 36, 0, 30, 0, 1, 0, 69, 71, 13], ["-", 0, 7, 8, 9, 0, 7, 15, 16, 17, 60], ["+", 0, 7, 8, 9, 0, 7, 15, 16, 17, 33]]
0
204
29
t[9999], W, N, a, b, i; main(c) { for (; scanf("%d", &W), W; printf("Case %d:\n%d\n%d", c++, t[W], i), memset(t, 0, W * 9)) { for (scanf("%d", &N); N-- && scanf("%d,%d", &a, &b);) { for (i = W; i >= b; i--) t[i] = fmax(t[i], t[i - b] + a); } for (i = 0; t[i] - t[W]; i++) ; } }
t[9999], W, N, a, b, i; main(c) { for (; scanf("%d", &W), W; printf("Case %d:\n%d\n%d\n", c++, t[W], i), memset(t, 0, W * 9)) { for (scanf("%d", &N); N-- && scanf("%d,%d", &a, &b);) { for (i = W; i >= b; i--) t[i] = fmax(t[i], t[i - b] + a); } for (i = 0; t[i] - t[W]; i++) ; }...
[["+", 26, 34, 31, 2, 3, 4, 0, 5, 0, 44]]
0
156
27
#include <stdio.h> #include <string.h> #define Max(x, y) (((x) > (y)) ? (x) : (y)) #define min(x, y) (((x) < (y)) ? (x) : (y)) int dp[1005][1005], w[1005], v[1005]; int main() { int i, j, n, m, wl; n = 1; while (1) { scanf("%d", &wl); if (wl == 0) break; scanf("%d", &m); for (i = 0; i < m; i...
#include <stdio.h> #include <string.h> #define Max(x, y) (((x) > (y)) ? (x) : (y)) #define min(x, y) (((x) < (y)) ? (x) : (y)) int dp[1005][1005], w[1005], v[1005]; int main() { int i, j, n, m, wl; n = 1; while (1) { scanf("%d", &wl); if (wl == 0) break; scanf("%d", &m); for (i = 1; i <= m; ...
[["-", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 10, 11, 12, 13], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]]
0
319
4
#include <math.h> #include <stdio.h> int tre[1000][2]; int mem[1000][10000]; int main(void) { int w, n, aw, av, k = 0, m, i, j; while (scanf("%d", &w) * w) { scanf("%d", &n); for (i = 0; i < n; i++) { for (j = 0; j <= w; j++) { mem[i][j] = 0; } } for (i = 0; i < n; i++) { s...
#include <math.h> #include <stdio.h> int tre[1000][2]; int mem[1000][10000]; int main(void) { int w, n, aw, av, k = 0, m, i, j; while (scanf("%d", &w) * w) { scanf("%d", &n); for (i = 0; i < n; i++) { for (j = 0; j <= w; j++) { mem[i][j] = 0; } } for (i = 0; i < n; i++) { s...
[["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 46]]
0
451
2
#include <bits/stdc++.h> using namespace std; int main() { int W, N; int dp[1001]; int num = 1; while (scanf("%d", &W), W) { scanf("%d", &N); memset(dp, 0, sizeof(dp)); for (int i = 0; i < N; i++) { int v, w; scanf("%d,%d", &v, &w); for (int j = W; j >= 0; j--) { if (j + ...
#include <bits/stdc++.h> using namespace std; int main() { int W, N; int dp[1001]; int num = 1; while (scanf("%d", &W), W) { scanf("%d", &N); memset(dp, 0, sizeof(dp)); for (int i = 0; i < N; i++) { int v, w; scanf("%d,%d", &v, &w); for (int j = W; j >= 0; j--) { if (j + ...
[["+", 0, 1, 0, 16, 31, 16, 12, 27, 17, 29]]
1
192
1
while True: cnt = 0 cnt += 1 maxweight = int(input()) if maxweight == 0: break length = int(input()) tresure = [] dp = [[0 for n in range(length+1)] for m in range(maxweight + 1)] answeight = 0 ansvalue = 0 for l in range(length): v,w = (int(n) for n in input().sp...
cnt = 0 while True: cnt += 1 maxweight = int(input()) if maxweight == 0: break length = int(input()) tresure = [] dp = [[0 for n in range(length+1)] for m in range(maxweight + 1)] answeight = 0 ansvalue = 0 for l in range(length): v,w = (int(n) for n in input().split(...
[["-", 36, 36, 36, 36, 0, 656, 0, 52, 0, 89], ["-", 36, 36, 36, 36, 0, 656, 0, 52, 15, 146], ["-", 36, 36, 36, 36, 0, 656, 0, 52, 0, 102], ["+", 36, 36, 36, 36, 0, 656, 0, 52, 0, 89], ["+", 36, 36, 36, 36, 0, 656, 0, 52, 15, 146], ["+", 36, 36, 36, 36, 0, 656, 0, 52, 0, 102]]
5
312
6
c=1 while 1: W=int(input()) if W==0:break n=int(input()) dp=[0]*(W+1) for i in range(n): v,w = map(int, input().split(',')) for j in range(W,w-1,-1): dp[j]=max(dp[j-w]+v,dp[j]) for i in range(W): if dp[W]==dp[i]:break print('Case %d:\n%d\n%d'%(c,dp[W],i)) ...
c=1 while 1: W=int(input()) if W==0:break n=int(input()) dp=[0]*(W+1) for i in range(n): v,w = map(int, input().split(',')) for j in range(W,w-1,-1): dp[j]=max(dp[j-w]+v,dp[j]) for i in range(W+1): if dp[W]==dp[i]:break print('Case %d:\n%d\n%d'%(c,dp[W],i)...
[["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
146
2
c=1 while 1: W=int(input()) if W==0:break dp=[0]*(W+1) for i in range(int(input())): v,w = map(int, input().split(',')) for j in range(W,w-1,-1): if dp[j]<dp[j-w]:dp[j]=dp[j-w] for i in range(W+1): if dp[W]==dp[i]:break print('Case %d:\n%d\n%d'%(c,dp[W],i)) ...
c=1 while 1: W=int(input()) if W==0:break dp=[0]*(W+1) for i in range(int(input())): v,w=map(int, input().split(',')) for j in range(W,w-1,-1): if dp[j]<dp[j-w]+v:dp[j]=dp[j-w]+v for i in range(W+1): if dp[W]==dp[i]:break print('Case %d:\n%d\n%d'%(c,dp[W],i)) ...
[["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 72], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 22], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["+", 64, 196, 0, 1, 0, 662, 12, 657, 12, 22]]
5
148
4
""" 0-1ナップザック dp[i][j]...i個目までの宝で重さjの時の価値の最大 wi = wlst[i]...i個目の重さ vi = vlst[i]...i個目の価値 dp[i][j] = max(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - wi] + vi) (wi <= j) dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) (wi > j) """ def main(): case = 0 while True: w = int(input()) if not...
""" 0-1ナップザック dp[i][j]...i個目までの宝で重さjの時の価値の最大 wi = wlst[i]...i個目の重さ vi = vlst[i]...i個目の価値 dp[i][j] = max(dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - wi] + vi) (wi <= j) dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) (wi > j) """ def main(): case = 0 while True: w = int(input()) if not...
[["-", 8, 196, 0, 57, 15, 666, 0, 206, 51, 22], ["-", 8, 196, 0, 57, 15, 666, 0, 206, 0, 70], ["-", 8, 196, 0, 57, 15, 666, 0, 206, 206, 22], ["-", 8, 196, 0, 57, 15, 666, 0, 206, 0, 73], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["-", 0, 662, 12, 652, 3, 4, 0, 206, 51, 22], ["+", 0, 662, 12, 652, 3, 4, 0, 206, 51, 2...
5
286
7
def get(): p,w = list(map(int, input().split(","))) for i in range(W-w+1,-1,-1): if bag[i] > 0 and bag[i]+p > bag[i+w]: bag[i+w] = bag[i]+p else: if p > bag[w]: bag[w] = p return c = 1 while True: W = int(input()) if W == 0: break bag = [0]*(W+1) N = int(input()) for i in range(N): get() w_all = max(b...
def get(): p,w = list(map(int, input().split(","))) for i in range(W-w,-1,-1): if bag[i] > 0 and bag[i]+p > bag[i+w]: bag[i+w] = bag[i]+p else: if p > bag[w]: bag[w] = p return c = 1 while True: W = int(input()) if W == 0: break bag = [0]*(W+1) N = int(input()) for i in range(N): get() w_all = max(bag...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
183
2
function Puzzle() { var obj = {}; var arrA = "123,234,345,456,567,678,789,111,222,333,444,555,666,777,888,999".split( ","); var arrB = "11,22,33,44,55,66,77,88,99".split(","); for (var i = 0; i < 16; i++) for (var j = 0; j < 16; j++) for (var k = 0; k < 16; k++) for (var l = 0;...
function Puzzle() { var obj = {}; var arrA = "123,234,345,456,567,678,789,111,222,333,444,555,666,777,888,999".split( ","); var arrB = "11,22,33,44,55,66,77,88,99".split(","); for (var i = 0; i < 16; i++) for (var j = 0; j < 16; j++) for (var k = 0; k < 16; k++) for (var l = 0;...
[["+", 8, 556, 0, 198, 0, 200, 51, 516, 0, 21], ["+", 8, 556, 0, 198, 0, 200, 51, 516, 0, 555]]
2
434
85
r, i, f, N[]; C(n) { int *p = N + 9; for (r += !n; p-- > N; ++*p, ++p[1], ++p[2]) (*p -= 3) < 0 || C(n - 1), (*p += 2) < 0 | !p[1]-- | !p[2]-- || C(n - 1); } main(j) { for (; j = getchar() + 1;) if (++i == 14 || !++N[j - 50]) { for (i = -1; ++i < 9; N[i]--) if (++N[i] < 5) { for (r...
r, i, f, N[11]; C(n) { int *p = N + 9; for (r += !n; p-- > N; ++*p, ++p[1], ++p[2]) (*p -= 3) < 0 || C(n - 1), (*p += 2) < 0 | !p[1]-- | !p[2]-- || C(n - 1); } main(j) { for (; j = getchar() + 1;) if (++i == 14 || !++N[j - 50]) { for (i = -1; ++i < 9; N[i]--) if (++N[i] < 5) { for ...
[["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
0
243
39
#include <cstdio> #include <iostream> using namespace std; bool ans; void solve(int cntnum[], int progress) { int cntnum_c[10], cntcont = 0; /*printf("%d: ",progress); for(int i=0;i<10;i++){ printf("%d",cntnum[i]); }puts("");*/ for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) cn...
#include <cstdio> #include <iostream> using namespace std; bool ans; void solve(int cntnum[], int progress) { int cntnum_c[10], cntcont = 0; /*printf("%d: ",progress); for(int i=0;i<10;i++){ printf("%d",cntnum[i]); }puts("");*/ for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) cn...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
445
2
#include <bits/stdc++.h> using namespace std; using db = double; using ll = long long; using vi = vector<int>; #define op operator #define pb push_back const int N = 15; int c[N]; bool ans; void dfs(int a, int b) { if (!a && !b) { ans = 1; return; } int i = find_if(c, c + N, [](int i) { return i > 0; }...
#include <bits/stdc++.h> using namespace std; using db = double; using ll = long long; using vi = vector<int>; #define op operator #define pb push_back const int N = 15; int c[N]; bool ans; void dfs(int a, int b) { if (!a && !b) { ans = 1; return; } int i = find_if(c, c + N, [](int i) { return i > 0; }...
[["-", 75, 76, 0, 9, 0, 1, 0, 16, 31, 22], ["-", 75, 76, 0, 9, 0, 1, 0, 16, 17, 151], ["-", 0, 9, 0, 1, 0, 16, 12, 103, 0, 104], ["-", 0, 9, 0, 1, 0, 16, 12, 103, 0, 44], ["-", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35]]
1
444
6
#include <bits/stdc++.h> #define e(i, n) for (int i = 0; i < n; i++) using namespace std; int m[9], t[9], d; bool F() { e(i, 9) { e(j, 9) t[j] = m[j]; if (t[i] >= 2) { t[i] -= 2; bool o = 1; e(j, 4) { int p = 0; d = 0; while (!t[p]) p++; if (!d && t[...
#include <bits/stdc++.h> #define e(i, n) for (int i = 0; i < n; i++) using namespace std; int m[9], t[9]; bool F() { e(i, 9) { e(j, 9) t[j] = m[j]; if (t[i] >= 2) { t[i] -= 2; bool o = 1; e(j, 4) { int p = 0, d = 0; while (!t[p]) p++; if (!d && t[p] >= 3) ...
[["-", 36, 36, 36, 36, 0, 30, 0, 43, 0, 21], ["-", 36, 36, 36, 36, 0, 30, 0, 43, 49, 22], ["-", 0, 57, 64, 9, 0, 9, 0, 43, 0, 35], ["+", 0, 57, 64, 9, 0, 9, 0, 43, 0, 21], ["+", 8, 9, 0, 52, 8, 9, 0, 43, 39, 40]]
1
337
5
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; int x[14]; bool r[14][100]; bool tempai(int num, int jan, int chou, bool make) { for (int i = 0; i < 14; i++) { if (!r[i][num]) { if (jan == 1 && i < 13) { if (x[i] == x[i + 1] && !(r[...
#include <algorithm> #include <cstdio> #include <iostream> #include <string> #include <vector> using namespace std; int x[14]; bool r[14][100]; bool tempai(int num, int jan, int chou, bool make) { for (int i = 0; i < 14; i++) { if (!r[i][num]) { if (jan == 1 && i < 13) { if (x[i] == x[i + 1] && !(r[...
[["-", 8, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60]]
1
898
2
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int cnt[10]; string str; bool done; bool ok(int pos) { if (pos == 10) return true; if (cnt[pos] == 0) return ok(pos + 1); if (cnt[pos] >= 3) { cnt[pos] -= 3; if (ok(pos)) { cnt[pos] += 3; ...
#include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; int cnt[10]; string str; bool done; bool ok(int pos) { if (pos == 10) return true; if (cnt[pos] == 0) return ok(pos + 1); if (cnt[pos] >= 3) { cnt[pos] -= 3; if (ok(pos)) { cnt[pos] += 3; ...
[["+", 0, 52, 8, 9, 0, 57, 64, 1, 0, 35], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22]]
1
455
2
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; int u[10]; bool solve() { bool f = false; int sum = 0; for (int i = 1; i < 10; i++) sum += u[i]; if (sum == 0) return true; for (int i = 1; i < 10; i++) { if (u[i] > 2) { u[...
#include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <vector> using namespace std; int u[10]; bool solve() { bool f = false; int sum = 0; for (int i = 1; i < 10; i++) sum += u[i]; if (sum == 0) return true; for (int i = 1; i < 10; i++) { if (u[i] > 2) { u[...
[["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 116, 0, 117], ["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 46]]
1
518
4
#include <algorithm> #include <cmath> #include <complex> #include <iostream> #include <map> #include <queue> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < int(n); ++i) #define ALL(v) (v).begin(), (v).end() #define ...
#include <algorithm> #include <cmath> #include <complex> #include <iostream> #include <map> #include <queue> #include <stack> #include <stdio.h> #include <string.h> #include <string> #include <vector> using namespace std; #define rep(i, n) for (int i = 0; i < int(n); ++i) #define ALL(v) (v).begin(), (v).end() #define ...
[["-", 8, 9, 0, 57, 64, 1, 0, 16, 17, 151], ["-", 8, 9, 0, 57, 64, 1, 0, 16, 12, 22]]
1
441
2
def check(table) result = 0 if table.sum <= 2 table.find {|x| x == 2} else (1..7).each do |i| tmp = table.dup if tmp[i].nonzero? and tmp[i + 1].nonzero? and tmp[i + 2].nonzero? 3.times {|x| tmp[i + x] -= 1} return true if check(tmp) end end (1..9).each do |j| ...
def check(table) result = 0 if table.sum <= 2 table.find {|x| x == 2} else (1..7).each do |i| tmp = table.dup if tmp[i].nonzero? and tmp[i + 1].nonzero? and tmp[i + 2].nonzero? 3.times {|x| tmp[i + x] -= 1} return true if check(tmp) end end (1..9).each do |j| ...
[["-", 0, 652, 486, 652, 486, 652, 486, 652, 486, 22], ["+", 0, 652, 486, 652, 486, 652, 486, 652, 486, 744]]
4
247
2
import sys def pokakito(num_line): if not num_line and flag == 1: result_lis.append(check_num) return True for num in num_line: if three(num, num_line): return True if two(num, num_line): return True if straight(num, num_line): return True def three(num, num_line): ...
import sys def pokakito(num_line): if not num_line and flag == 1: result_lis.append(check_num) return True for num in num_line: if three(num, num_line): return True if two(num, num_line): return True if straight(num, num_line): return True def three(num, num_line): ...
[["-", 36, 36, 0, 656, 0, 7, 75, 76, 0, 95], ["-", 36, 36, 0, 656, 0, 7, 75, 76, 0, 102]]
5
418
56
import java.io.*; class Main { public static void main(String args[]) { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); String buf; try { while ((buf = br.readLine()) != null) { int n = Integer.parseInt(buf); boolean list[]...
import java.io.*; class Main { public static void main(String args[]) { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); String buf; try { while ((buf = br.readLine()) != null) { int n = Integer.parseInt(buf); boolean list[]...
[["+", 0, 7, 502, 503, 49, 200, 51, 16, 17, 33], ["+", 0, 7, 502, 503, 49, 200, 51, 16, 12, 499], ["+", 0, 7, 502, 503, 49, 200, 51, 16, 17, 72]]
3
251
4
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class Main { static List<Integer> primes = findPrimes(50021); private static List<Integer> findPrimes(int n) { boolean[] isPrime = new boolean[n]; Arrays.fill(isPrime, true); isPrime[0] = fal...
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Scanner; public class Main { static List<Integer> primes = findPrimes(50021); private static List<Integer> findPrimes(int n) { boolean[] isPrime = new boolean[n]; Arrays.fill(isPrime, true); isPrime[0] = fal...
[["-", 0, 52, 8, 196, 0, 1, 0, 492, 141, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 492, 141, 22]]
3
383
2
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int i, n, j; boolean f[] = new boolean[6000]; for (i = 2; i < f.length; i++) f[i] = true; for (i = 2; i < f.length; i++) { if (f[i]) { for (j = 2; j * i...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int i, n, j; boolean f[] = new boolean[60000]; for (i = 2; i < f.length; i++) f[i] = true; for (i = 2; i < f.length; i++) { if (f[i]) { for (j = 2; j * ...
[["-", 0, 503, 49, 200, 51, 227, 497, 505, 0, 499], ["+", 0, 503, 49, 200, 51, 227, 497, 505, 0, 499]]
3
225
2
import java.util.*; class Main { Scanner sc = new Scanner(System.in); public boolean isPrime(int n) { if (n < 2) return false; for (int i = 2; i * i <= n; i++) { if (n % 2 == 0) return false; } return true; } public void run() { while (sc.hasNext()) { int val = ...
import java.util.*; class Main { Scanner sc = new Scanner(System.in); public boolean isPrime(int n) { if (n < 2) return false; for (int i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return true; } public void run() { while (sc.hasNext()) { int val = ...
[["-", 0, 57, 15, 15, 0, 16, 31, 16, 12, 499], ["+", 0, 57, 15, 15, 0, 16, 31, 16, 12, 22]]
3
254
2
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String arg[]) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int n = sc.nextInt(); boolean a[] = new boolean[n + n]; Arrays.fill(a, true); a[0] = a[1] = false; for (int...
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String arg[]) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int n = sc.nextInt(); boolean a[] = new boolean[n + n + 1]; Arrays.fill(a, true); a[0] = a[1] = false; for ...
[["+", 49, 200, 51, 227, 497, 505, 0, 16, 17, 72], ["+", 49, 200, 51, 227, 497, 505, 0, 16, 12, 499]]
3
235
2
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int num = sc.nextInt(); for (int i = num - 1; i >= 0; i--) { if (i != 2 && i % 2 == 0) continue; boolean ok = true; ...
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int num = sc.nextInt(); for (int i = num - 1; i >= 0; i--) { if (i != 2 && i % 2 == 0) continue; boolean ok = true; ...
[["-", 0, 57, 64, 196, 0, 1, 0, 492, 141, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 492, 141, 22]]
3
243
2
#include <math.h> #include <stdio.h> int prime(long x) { int key = 1; long i; for (i = 3; i <= sqrt(x); i += 2) { if (x % i == 0) { key = 0; break; } } return key; } int main(void) { long n; while (scanf(" %ld", &n) != EOF) { long a = n, b = n; if (n % 2 == 0) { --a; ...
#include <math.h> #include <stdio.h> int prime(long x) { int key = 1; long i; for (i = 3; i <= sqrt(x); i += 2) { if (x % i == 0) { key = 0; break; } } return key; } int main(void) { long n; while (scanf(" %ld", &n) != EOF) { long a = n, b = n; if (n % 2 == 0) { --a; ...
[["+", 0, 52, 8, 9, 0, 57, 75, 76, 0, 95], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 45], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
0
177
3
#include <stdio.h> #define MAX 50001 int n; int p[MAX]; int prime[1000]; int main() { int i, j, count = 0; for (i = 0; i < MAX; i++) { p[i] = 1; } for (i = 2; i * i < MAX; i++) { if (p[i] == 1) { for (j = i + i; j < MAX; j = j + i) { p[j] = 0; } } } for (i = 2; i < MAX; i++)...
#include <stdio.h> #define MAX 50100 int n; int p[MAX]; int prime[10000]; int main() { int i, j, count = 0; for (i = 0; i < MAX; i++) { p[i] = 1; } for (i = 2; i * i < MAX; i++) { if (p[i] == 1) { for (j = i + i; j < MAX; j = j + i) { p[j] = 0; } } } for (i = 2; i < MAX; i++...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13]]
0
250
4
#include <cstdio> using namespace std; int main() { int i, n, m, total = 0, num = 0; for (i = 1; scanf("%d,%d", &n, &m) != EOF; i++) { total += n * m; num += m; } printf("%d\n%d\n", total, (int)(num / (double)i + 0.5)); }
#include <cstdio> using namespace std; int main() { int i, n, m, total = 0, num = 0; for (i = 0; scanf("%d,%d", &n, &m) != EOF; i++) { total += n * m; num += m; } printf("%d\n%d\n", total, (int)(num / (double)i + 0.5)); }
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 12, 13]]
1
89
2
#include <iostream> using namespace std; int main() { int sum = 0, ave = 0; int i; int n, m; for (i = 0; cin >> n; ++i) { char a; cin >> a >> m; sum += n; ave += m; } if (i != 0) { double a; a = double(ave) / i + 0.5; ave = a; cout << sum << "\n" << ave << endl; } else ...
#include <iostream> using namespace std; int main() { int sum = 0, ave = 0; int i; int n, m; for (i = 0; cin >> n; ++i) { char a; cin >> a >> m; sum += n * m; ave += m; } if (i != 0) { double a; a = double(ave) / i + 0.5; ave = a; cout << sum << "\n" << ave << endl; } e...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
112
2
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; int main() {...
#include <algorithm> #include <bitset> #include <cfloat> #include <climits> #include <cmath> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> using namespace std; int main() {...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
121
2
#include <stdio.h> int main() { int kiro, s, ksum, ssum, n; double h; ksum = ssum = n = 0; while (scanf("%d,%d", &kiro, &s) != EOF) { ksum += kiro * s; s++; ssum += s; } h = (double)ssum / (double)s; if ((h - (double)((int)h)) >= 0.5) s = (int)h + 1; else s = (int)h; printf("%d\n%...
#include <stdio.h> int main() { int kiro, s, ksum, ssum, n; double h; ksum = ssum = n = 0; while (scanf("%d,%d", &kiro, &s) != EOF) { ksum += kiro * s; n++; ssum += s; } h = (double)ssum / (double)n; if ((h - (double)((int)h)) >= 0.5) s = (int)h + 1; else s = (int)h; printf("%d\n%...
[["-", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["-", 0, 1, 0, 11, 12, 16, 12, 74, 51, 22], ["+", 0, 1, 0, 11, 12, 16, 12, 74, 51, 22]]
1
126
4
#include <cstdio> #include <iostream> using namespace std; int main() { int value, num, i = 0, total = 0, ave = 0; while (scanf("%d, %d", &value, &num) != EOF) { total += value * num; ave += num; i++; } cout << total << endl << (int)(ave / i + 0.5) << endl; return 0; }
#include <cstdio> #include <iostream> using namespace std; int main() { int value, num, i = 0, total = 0, ave = 0; while (scanf("%d, %d", &value, &num) != EOF) { total += value * num; ave += num; i++; } cout << total << endl << (int)(ave / (double)i + 0.5) << endl; return 0; }
[["+", 51, 23, 0, 16, 31, 16, 12, 74, 0, 24], ["+", 0, 16, 31, 16, 12, 74, 39, 77, 39, 40], ["+", 51, 23, 0, 16, 31, 16, 12, 74, 0, 25]]
1
85
3
#include <iostream> using namespace std; int main(void) { int value, num; int sum = 0, ave = 0, row = 0; while (cin >> value >> num) { sum += value * num; ave += num; row++; } cout << sum << endl << (int)(ave / (double)row + 0.5) << endl; return 0; }
#include <iostream> using namespace std; int main(void) { int value, num; int sum = 0, ave = 0, row = 0; char a; while (cin >> value >> a >> num) { sum += value * num; ave += num; row++; } cout << sum << endl << (int)(ave / (double)row + 0.5) << endl; return 0; }
[["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 49, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 0, 35], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 17, 152], ["+", 0, 52, 15, 339, 51, 16, 31, 16, 12, 22]]
1
79
5
#include <cstdio> #include <iostream> using namespace std; int main() { int price, num, sump = 0, sum = 0, i = 0; double ave; while (scanf("%d,%d", &price, &num) != EOF) { sump += price; sum += num; i++; } ave = sum / (double)i; ave += 0.5; cout << sump << endl << (int)ave << endl; return 0;...
#include <cstdio> #include <iostream> using namespace std; int main() { int price, num, sump = 0, sum = 0, i = 0; double ave; while (scanf("%d,%d", &price, &num) != EOF) { sump += price * num; sum += num; i++; } ave = sum / (double)i; ave += 0.5; cout << sump << endl << (int)ave << endl; re...
[["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 48], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22]]
1
93
2
total = [] average = [] while tmp = gets break if tmp == nil p tmp = gets.chomp.split(",").map(&:to_i) # puts tmp.split(",").map(&:to_i) total << tmp[0] * tmp[1] average << tmp[1] end puts total.inject(:+) puts (average.inject(:+)/average.size).round
total = [] average = [] while tmp = gets break if tmp == nil tmp = tmp.chomp.split(",").map(&:to_i) # puts tmp.split(",").map(&:to_i) total << tmp[0] * tmp[1] average << tmp[1] end puts total.inject(:+) puts (average.inject(:+).to_f/average.size).round
[["-", 0, 493, 0, 89, 8, 170, 0, 652, 735, 22], ["-", 0, 662, 12, 652, 486, 652, 486, 652, 486, 22], ["+", 0, 662, 12, 652, 486, 652, 486, 652, 486, 22], ["+", 0, 652, 486, 739, 0, 738, 31, 652, 17, 131], ["+", 0, 652, 486, 739, 0, 738, 31, 652, 735, 22]]
4
77
5
def main sum = 0 sumnum = 0 count = 0 while arg = gets arg = arg.split(",").map(&:to_i) sum += arg[0] * arg[1] sumnum += arg[0] count += 1 end puts sum, (sumnum.to_f / count).round end main
def main sum = 0 sumnum = 0 count = 0 while arg = gets arg = arg.split(",").map(&:to_i) sum += arg[0] * arg[1] sumnum += arg[1] count += 1 end puts sum, (sumnum.to_f / count).round end main
[["-", 0, 89, 8, 170, 0, 755, 12, 742, 0, 612], ["+", 0, 89, 8, 170, 0, 755, 12, 742, 0, 612]]
4
66
2
A = [] B = [] while True: try: x,y = map(int,input().split(',')) A.append(x) B.append(y) except EOFError: break N = len(A) print(sum(A [i] * B [i] for i in range(N)),sum(B) * 2 // N - sum(B) // N)
A = [] B = [] while True: try: x,y = map(int,input().split(',')) A.append(x) B.append(y) except EOFError: break N = len(A) print(sum(A [i] * B [i] for i in range(N))) print(sum(B) * 2 // N - sum(B) // N)
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 21], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25], ["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24]]
5
92
4
import sys s=[list(map(int,e.split(',')))for e in sys.stdin] print(sum(a*n for a,n in s),int([sum(x)for x in zip(*s)][1]/len(s)+.5))
import sys s=[list(map(int,e.split(',')))for e in sys.stdin] print(sum(a*n for a,n in s)) print(int([sum(x)for x in zip(*s)][1]/len(s)+.5))
[["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 21], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25], ["+", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24]]
5
71
4
i, all, sum = 0, 0, 0 while True: try: price, n = list(map(int, input().split(","))) i += 1; all += n; sum += price except: break print(sum) print(int(round(float(all)/i)))
i, all, sum = 0, 0, 0 while True: try: price, n = list(map(int, input().split(","))) i += 1; all += n; sum += price*n except: break print(sum) print(int(round(float(all)/i)))
[["+", 8, 196, 0, 1, 0, 677, 12, 657, 17, 48], ["+", 8, 196, 0, 1, 0, 677, 12, 657, 12, 22]]
5
71
2
import static java.lang.Math.*; import static java.util.Arrays.*; import java.io.*; import java.lang.*; import java.math.*; import java.util.*; public class Main { Scanner sc; static final int INF = 1 << 28; static final double EPS = 1e-9; void run() { sc = new Scanner(System.in); double max = 0, m...
import static java.lang.Math.*; import static java.util.Arrays.*; import java.io.*; import java.lang.*; import java.math.*; import java.util.*; public class Main { Scanner sc; static final int INF = 1 << 28; static final double EPS = 1e-9; void run() { sc = new Scanner(System.in); double max = 0, m...
[["-", 8, 196, 0, 7, 8, 196, 0, 93, 0, 94], ["-", 8, 196, 0, 7, 8, 196, 0, 93, 0, 35]]
3
213
2
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { private static double x; private static double max; private static double min; private static String val; public static void main(String args[]) throws Exception { BufferedReader br = new BufferedReader(new InputStreamR...
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { private static double x; private static double max; private static double min; private static String val; public static void main(String args[]) throws Exception { BufferedReader br = new BufferedReader(new InputStreamR...
[["-", 0, 195, 8, 196, 0, 1, 0, 11, 12, 499], ["+", 0, 195, 8, 196, 0, 1, 0, 11, 12, 499]]
3
136
2
#include <stdio.h> int main(void) { double max = 0, a, min = 0; while (scanf("%lf", &a) != EOF) { if (max < a) max = a; if (min > a) min = a; } printf("%lf\n", max - min); return 0; }
#include <stdio.h> int main(void) { double max = 0, a, min = 10000; while (scanf("%lf", &a) != EOF) { if (max < a) max = a; if (min > a) min = a; } printf("%lf\n", max - min); return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
0
71
2
#include <stdio.h> int main() { float max, min, m[10000]; int i, count = 0; while (scanf("%f", &m[i]) != EOF) { count++; } max = min = m[0]; for (i = 1; i < count; i++) { if (max < m[i]) max = m[i]; if (min > m[i]) min = m[i]; } printf("%g\n", max - min); return 0; }
#include <stdio.h> int main() { float max, min, m[10000]; int i, count = 0; while (scanf("%f", &m[count]) != EOF) { count++; } max = min = m[0]; for (i = 1; i < count; i++) { if (max < m[i]) max = m[i]; else if (min > m[i]) min = m[i]; } printf("%g\n", max - min); return 0; }
[["-", 31, 2, 3, 4, 0, 66, 28, 69, 71, 22], ["+", 31, 2, 3, 4, 0, 66, 28, 69, 71, 22], ["+", 0, 7, 8, 9, 0, 57, 75, 76, 0, 95]]
0
118
3
#include <stdio.h> int main(void) { float h, l, n; int y = 0; while (scanf("%f", &n) != EOF) { if (y = 0) { h = n; l = n; y = 1; } else { if (h < n) h = n; if (l > n) l = n; } } printf("%f\n", h - l); return 0; }
#include <stdio.h> int main(void) { float h, l, n; int y = 0; while (scanf("%f", &n) != EOF) { if (y == 0) { h = n; l = n; y = 1; } else { if (h < n) h = n; if (l > n) l = n; } } printf("%f\n", h - l); return 0; }
[["-", 8, 9, 0, 57, 15, 23, 0, 11, 17, 32], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 60]]
0
95
2
#include <stdio.h> int main() { int x, min, max; min = 10000000; max = 0; while (scanf("%lf", &x) != EOF) { if (max < x) max = x; if (min > x) min = x; } printf("%.2f\n", max - min); return 0; }
#include <stdio.h> int main() { double x, min, max; min = 10000000; max = 0; while (scanf("%lf", &x) != EOF) { if (max < x) max = x; if (min > x) min = x; } printf("%.2f\n", max - min); return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40]]
0
74
2
#include <stdio.h> int main(void) { double h[1000], Max, Min; int i = 1; scanf("%lf", &h[0]); Max = Min = h[0]; while (scanf("%lf", &h[i]) != EOF) { if (h[i] <= Max) Max = h[i]; if (h[i] >= Min) Min = h[i]; i++; } printf("%.1lf", Max - Min); return 0; }
#include <stdio.h> int main(void) { double h[1000], Max, Min; int i = 1; scanf("%lf", &h[0]); Max = Min = h[0]; while (scanf("%lf", &h[i]) != EOF) { if (h[i] >= Max) Max = h[i]; if (h[i] <= Min) Min = h[i]; i++; } printf("%.1lf", Max - Min); return 0; }
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 19]]
0
114
4
#include <stdio.h> int main(void) { double lo, hi, a; scanf("%f", &a); lo = hi = a; while (scanf("%f", &a) != EOF) { if (a > hi) hi = a; else if (a < lo) lo = a; } printf("%ld", hi - lo); return 0; }
#include <stdio.h> int main(void) { float lo, hi, a; scanf("%f", &a); lo = hi = a; while (scanf("%f", &a) != EOF) { if (a > hi) hi = a; else if (a < lo) lo = a; } printf("%.1f", hi - lo); return 0; }
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
83
4
#include <stdio.h> int main(void) { double t, ans, max, min; int i; max = -1.0; min = -1.0; while ((scanf("%lf", &t)) != EOF) { if (t > max || max < 0) max = t; if (t < min || max < 0) max = t; } printf("%lf\n", max - min); return 0; }
#include <stdio.h> int main(void) { double t, ans, max, min; int i; max = -1.0; min = -1.0; while ((scanf("%lf", &t)) != EOF) { if (t > max || max < 0) max = t; if (t < min || min < 0) min = t; } printf("%lf\n", max - min); return 0; }
[["-", 0, 57, 15, 23, 0, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 31, 22], ["-", 8, 9, 0, 57, 64, 1, 0, 11, 31, 22], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 31, 22]]
0
90
4
#include <stdio.h> int main(void) { int flag = 0; float max, min; float hill; while (scanf("%f", &hill) != EOF) { if (flag == 0) { max = min = hill; flag++; } if (max < hill) { max = hill; } else if (min > hill) { min = hill; } } printf("%1.f\n", max - min); ...
#include <stdio.h> int main(void) { int flag = 0; float max, min; float hill; while (scanf("%f", &hill) != EOF) { if (flag == 0) { max = min = hill; flag++; } if (max < hill) { max = hill; } else if (min > hill) { min = hill; } } printf("%f\n", max - min); ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
97
2
#include <stdio.h> int main() { double max, min; double n; scanf("%lf", &max); min = max; while (~scanf("%lf", &n)) { if (min < n) min = n; else if (max > n) max = n; } printf("%lf\n", max - min); return 0; }
#include <stdio.h> int main() { double max, min; double n; scanf("%lf", &max); min = max; while (~scanf("%lf", &n)) { if (min > n) min = n; else if (max < n) max = n; } printf("%lf\n", max - min); return 0; }
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["-", 75, 76, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 75, 76, 0, 57, 15, 23, 0, 16, 17, 18]]
0
81
4
#include <stdio.h> int main() { int counter = 0; double yama = 0; double max = 0; double low = 0; while (scanf("%lf", &yama) != EOF) { if (counter == 0) { max = yama; low = yama; } if (max < yama) { max = yama; } if (low > yama) { low = yama; } } printf("%f...
#include <stdio.h> int main() { int counter = 0; double yama = 0; double max = 0; double low = 0; while (scanf("%lf", &yama) != EOF) { if (counter == 0) { max = yama; low = yama; } if (max < yama) { max = yama; } if (low > yama) { low = yama; } counter++; ...
[["+", 0, 52, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
0
99
3
#include <stdio.h> int main() { long double n; long double high, low; long double ans; scanf("%lf", &n); high = n; low = n; while (scanf("%lf", &n) != EOF) { if (high < n) { high = n; } if (low > n) { low = n; } } ans = high - low; printf("%lf\n", ans); return 0; }
#include <stdio.h> int main() { double n; double high, low; double ans; scanf("%lf", &n); high = n; low = n; while (scanf("%lf", &n) != EOF) { if (high < n) { high = n; } if (low > n) { low = n; } } ans = high - low; printf("%f\n", ans); return 0; }
[["-", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
99
5
#include <algorithm> #include <iostream> using namespace std; int main(void) { ios::sync_with_stdio(false); double maxh = 114514810, minh = -1; double h; while (cin >> h) { maxh = max(maxh, h); minh = min(minh, h); } cout << maxh - minh << endl; return 0; }
#include <algorithm> #include <iostream> using namespace std; int main(void) { ios::sync_with_stdio(false); double maxh = -1, minh = 114514810; double h; while (cin >> h) { maxh = max(maxh, h); minh = min(minh, h); } cout << maxh - minh << endl; return 0; }
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
71
4
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> using namespace std; void Solution() { int n = 0; double a[n]; while (cin >> a[n]) { n++; } // for (int i = 0; i < n - 1; i++) // { // for (int j = i + 1; j < n; j++) // { // if (a[i] < a...
#include <algorithm> #include <cmath> #include <cstdio> #include <iostream> using namespace std; void Solution() { int n = 0; double a[100]; // notice the definition. while (cin >> a[n]) { n++; } // for (int i = 0; i < n - 1; i++) // { // for (int j = i + 1; j < n; j++) // { ...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 22], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
97
2
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <string> #include <vector> #define shosu(x) fixed << setprecision(x) using namespace std; typedef pair<int, int> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, P> pip; typedef long long ll; const i...
#include <algorithm> #include <cmath> #include <iomanip> #include <iostream> #include <map> #include <string> #include <vector> #define shosu(x) fixed << setprecision(x) using namespace std; typedef pair<int, int> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, P> pip; typedef long long ll; const i...
[["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 22]]
1
133
2
#include <iostream> using namespace std; int main() { float max = 0, min = 1000000, in; while (true) { cin >> in; if (cin.eof()) { break; } if (max < in) { max = in; } else if (min > in) { min = in; } cout << max - min << endl; } return 0; }
#include <iostream> using namespace std; int main() { float max = 0, min = 1000000, in; while (true) { cin >> in; if (cin.eof()) { break; } if (max < in) { max = in; } else if (min > in) { min = in; } } cout << max - min << endl; return 0; }
[["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
81
2
#include <algorithm> #include <iostream> using namespace std; int main() { double high[50] = {}; int i = 0; while (cin >> high[i]) { i++; } sort(high, high + i); cout << high[i] - high[0] << endl; return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { double high[50] = {}; int i = 0; while (cin >> high[i]) { i++; } sort(high, high + i); cout << high[i - 1] - high[0] << endl; return 0; }
[["+", 12, 16, 31, 69, 341, 342, 0, 16, 17, 33], ["+", 12, 16, 31, 69, 341, 342, 0, 16, 12, 13]]
1
68
2
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { double n, a, b; vector<double> v; while (cin >> n) { v.push_back(n); } a = v[0]; b = v[0]; for (int i = 0; i < n; i++) { a = max(a, v[i]); b = min(b, v[i]); } double ans = a - b; cout << a...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int main() { double n, a, b; vector<double> v; while (cin >> n) { v.push_back(n); } a = v[0]; b = v[0]; for (int i = 0; i < v.size(); i++) { a = max(a, v[i]); b = min(b, v[i]); } double ans = a - b; co...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 7, 15, 16, 12, 2, 63, 118, 28, 22], ["+", 0, 7, 15, 16, 12, 2, 63, 118, 17, 131], ["+", 0, 7, 15, 16, 12, 2, 63, 118, 119, 120], ["+", 0, 7, 15, 16, 12, 2, 3, 4, 0, 24], ["+", 0, 7, 15, 16, 12, 2, 3, 4, 0, 25]]
1
111
6
#include <iostream> using namespace std; int main() { double max = -1.0, min = 10000.0; double tmp; while (cin >> tmp) { if (max < tmp) max = tmp; if (min > tmp) min = tmp; } printf("%ld\n", max - min); return 0; }
#include <iostream> using namespace std; int main() { double max = -1.0, min = 10000.0; double tmp; while (cin >> tmp) { if (max < tmp) max = tmp; if (min > tmp) min = tmp; } printf("%lf\n", max - min); return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
67
2
#include <algorithm> #include <iostream> using namespace std; int main() { double x; cin >> x; double minimum = x, maximum = x; while (cin >> x) { minimum = min(minimum, x); maximum = max(maximum, x); } cout << maximum - maximum << endl; return 0; }
#include <algorithm> #include <iostream> using namespace std; int main() { double x; cin >> x; double minimum = x, maximum = x; while (cin >> x) { minimum = min(minimum, x); maximum = max(maximum, x); } cout << maximum - minimum << endl; return 0; }
[["-", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 16, 12, 22]]
1
67
2
from sys import * maxnum = 60000 primes = [True]*maxnum primes[0] = primes[1] = False for i in range(maxnum): if i >= maxnum**0.5 : break if not primes[i]: continue for j in range(i*2,maxnum,i): primes[j] = False for s in stdin: d = int(s) for i in reversed(range(2,d-1)): if primes[i]: pri...
from sys import * maxnum = 60000 primes = [True]*maxnum primes[0] = primes[1] = False for i in range(maxnum): if i >= maxnum**0.5 : break if not primes[i]: continue for j in range(i*2,maxnum,i): primes[j] = False for s in stdin: d = int(s) for i in reversed(range(2,d)): if primes[i]: print...
[["-", 3, 4, 0, 652, 3, 4, 0, 657, 17, 33], ["-", 3, 4, 0, 652, 3, 4, 0, 657, 12, 612]]
5
137
2
def sieve(n): p=[True]*(n+1) p[0]=p[1]=False for i in range(2,int((n+1)*0.5)+1): if p[i]==True: for j in range(i*i,n+1,i): p[j]=False prime=[] for i in range(n+1): if p[i]==True: prime.append(i) return prime def solve(n): i=0 while True: if n>prime[i]: a=prime[i] elif n==prime[i]: a=pri...
def sieve(n): p=[True]*(n+1) p[0]=p[1]=False for i in range(2,int((n+1)*0.5)+1): if p[i]==True: for j in range(i*i,n+1,i): p[j]=False prime=[] for i in range(n+1): if p[i]==True: prime.append(i) return prime def solve(n): i=0 while True: if n>prime[i]: a=prime[i] elif n==prime[i]: a=pri...
[["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612]]
5
196
2
import bisect MAX = 60000 #エラトステネスの篩 is_prime = [True for _ in range(MAX)] is_prime[0] = is_prime[1] = False for i in range(2, int(MAX ** (1 / 2)) + 1): if is_prime[i]: for j in range(i ** 2, MAX, i): is_prime[j] = False primes = [i for i in range(MAX) if is_prime[i]] while True: try: n = int(inpu...
import bisect MAX = 60000 #エラトステネスの篩 is_prime = [True for _ in range(MAX)] is_prime[0] = is_prime[1] = False for i in range(2, int(MAX ** (1 / 2)) + 1): if is_prime[i]: for j in range(i ** 2, MAX, i): is_prime[j] = False primes = [i for i in range(MAX) if is_prime[i]] while True: try: n = int(inpu...
[["+", 0, 652, 3, 4, 0, 206, 206, 657, 17, 33], ["+", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 17, 72], ["-", 0, 652, 3, 4, 0, 206, 206, 657, 12, 612]]
5
160
4