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 <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> constexpr int MOD = 1000000007; constexpr int INF = 2000000000; using namespace std; ...
#include <algorithm> #include <cmath> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <stack> #include <string> #include <utility> #include <vector> constexpr int MOD = 1000000007; constexpr int INF = 2000000000; using namespace std; ...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
395
10
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include <utility> #include <vector> using namespace std; #define ll long long #de...
#include <algorithm> #include <cmath> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string.h> #include <string> #include <utility> #include <vector> using namespace std; #define ll long long #de...
[["-", 0, 11, 31, 69, 341, 342, 0, 69, 28, 22], ["+", 0, 11, 31, 69, 341, 342, 0, 69, 28, 22]]
1
380
2
#include <algorithm> #include <iostream> #include <stdio.h> using namespace std; int main() { while (1) { int a, b, c, q, w, e[300], l[1000][4], n; cin >> a >> b >> c; if (a == 0 && b == 0 && c == 0) break; cin >> n; for (q = 0; q < a + b + c; q++) e[q] = 2; for (q = 0; q < n; q++)...
#include <algorithm> #include <iostream> #include <stdio.h> using namespace std; int main() { while (1) { int a, b, c, q, w, e[301], l[1000][4], n; cin >> a >> b >> c; if (a == 0 && b == 0 && c == 0) break; cin >> n; for (q = 1; q <= a + b + c; q++) e[q] = 2; for (q = 0; q < n; q++...
[["-", 0, 52, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 52, 8, 9, 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]]
1
414
10
def func(n,k): SUM = 0 ans = 0 A = [int(input()) for _ in range(n)] for i in range(k-1): SUM += A[i] for i in range(k,len(A)): ans = max(ans,SUM+A[i]-A[i-k]) SUM = SUM+A[i]-A[i-k] print(ans) for _ in range(10): n,k = [int(s) for s in input().split()] if n == 0 an...
def func(n,k): SUM = 0 ans = 0 A = [int(input()) for _ in range(n)] for i in range(k): SUM += A[i] for i in range(k,len(A)): ans = max(ans,SUM+A[i]-A[i-k]) SUM = SUM+A[i]-A[i-k] print(ans) for _ in range(10): n,k = [int(s) for s in input().split()] if n == 0 and ...
[["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612]]
5
145
2
def main(): while True: a = [] n, k = [int(x) for x in input().split()] if n == 0 and k == 0: break for i in range(n): a.append(int(input())) l = [0] for i in range(1, n - k + 1): l.append(a[i + k - 1] - a[i - 1]) maxsum = 0 maxi = 0 s = 0 for i, x in enumerate(l): s += x if s >= maxsum: ...
def main(): while True: a = [] n, k = [int(x) for x in input().split()] if n == 0 and k == 0: break for i in range(n): a.append(int(input())) l = [0] for i in range(1, n - k + 1): l.append(a[i + k - 1] - a[i - 1]) maxsum = 0 maxi = 0 s = 0 for i, x in enumerate(l): s += x if s >= maxsum: ...
[["-", 3, 4, 0, 206, 206, 663, 0, 657, 31, 22], ["-", 3, 4, 0, 206, 206, 663, 0, 657, 17, 33], ["-", 3, 4, 0, 206, 206, 663, 0, 657, 12, 612], ["+", 0, 652, 3, 4, 0, 206, 206, 663, 0, 22], ["-", 0, 206, 206, 663, 0, 657, 31, 657, 31, 22], ["+", 3, 4, 0, 206, 206, 663, 0, 657, 31, 22]]
5
154
8
#include <stdio.h> int smax(int *list, int n) { int max, sec, maxreal, i; max = sec = maxreal = 0; for (i = 0; i < n; i++) if (list[i] == 1) { max++; sec++; } else if (list[i] == 0) if (max > maxreal) { maxreal = max; max = sec + 1; sec = 0; } else { ...
#include <stdio.h> int smax(int *list, int n) { int max, sec, maxreal, i; // maxreal is output. max = sec = maxreal = 0; for (i = 0; i < n; i++) if (list[i] == 1) { max++; sec++; } else if (list[i] == 0) if (max >= maxreal) { maxreal = max; max = sec + 1; sec = 0;...
[["-", 0, 57, 64, 57, 15, 23, 0, 16, 17, 47], ["+", 0, 57, 64, 57, 15, 23, 0, 16, 17, 20], ["+", 0, 14, 8, 9, 0, 7, 8, 9, 0, 45], ["-", 75, 76, 0, 9, 0, 57, 64, 9, 0, 45]]
0
381
4
#include "bits/stdc++.h" //#define int long long using namespace std; #define REP(i, s, n) for (signed i = (s); i < signed(n); i++) #define rep(i, n) REP(i, 0, n) #define all(co) co.begin(), co.end() typedef pair<int, int> P; typedef unsigned long long LL; #ifdef int const long long INF = 1ll << 61ll; #else const s...
#include "bits/stdc++.h" //#define int long long using namespace std; #define REP(i, s, n) for (signed i = (s); i < signed(n); i++) #define rep(i, n) REP(i, 0, n) #define all(co) co.begin(), co.end() typedef pair<int, int> P; typedef unsigned long long LL; #ifdef int const long long INF = 1ll << 61ll; #else const s...
[["+", 3, 4, 0, 23, 0, 41, 64, 16, 17, 72], ["+", 3, 4, 0, 23, 0, 41, 64, 16, 12, 13]]
1
342
27
#include <bits/stdc++.h> using namespace std; #define FOR(i, s, n) for (int i = s; i < (int)n; i++) #define per(i, n) for (int i = n; i >= 0; i--) #define ROF(i, s, n) for (int i = s; i >= (int)n; i--) #define FORIT(i, A) for (auto i : A) #define PRINT(x) cout << (x) << "\n" #define ALL(a) (a).begin(), (a).end() #defin...
#include <bits/stdc++.h> using namespace std; #define FOR(i, s, n) for (int i = s; i < (int)n; i++) #define per(i, n) for (int i = n; i >= 0; i--) #define ROF(i, s, n) for (int i = s; i >= (int)n; i--) #define FORIT(i, A) for (auto i : A) #define PRINT(x) cout << (x) << "\n" #define ALL(a) (a).begin(), (a).end() #defin...
[["+", 8, 9, 0, 1, 0, 2, 63, 118, 28, 22], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 17, 131], ["+", 8, 9, 0, 1, 0, 2, 63, 118, 119, 120], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 24], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
622
6
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <sstream> #include <string> #include <vector> using namespace std; int main(void) { int n, k; while (cin >> n >> k, n) { bool a[100020]; for (int i =...
#include <algorithm> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <map> #include <sstream> #include <string> #include <vector> using namespace std; int main(void) { int n, k; while (cin >> n >> k, n) { bool a[100020] = {}; for (in...
[["+", 0, 52, 8, 9, 0, 43, 49, 50, 0, 32], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 45], ["+", 8, 9, 0, 43, 49, 50, 51, 83, 0, 46]]
1
255
3
#include <bits/stdc++.h> using namespace std; #define rep(i, x) for (int i = 0; i < x; ++i) #define all(a) begin(a), end(a) bool exist[100010]; int len[100010]; int Id[100010]; signed main() { int n, k; while (cin >> n >> k, n) { memset(exist, false, sizeof(exist)); memset(len, 0, sizeof(len)); mem...
#include <bits/stdc++.h> using namespace std; #define rep(i, x) for (int i = 0; i < x; ++i) #define all(a) begin(a), end(a) bool exist[100010]; int len[100010]; int Id[100010]; signed main() { int n, k; while (cin >> n >> k, n) { memset(exist, false, sizeof(exist)); memset(len, 0, sizeof(len)); mem...
[["+", 0, 14, 8, 9, 0, 57, 75, 76, 0, 95]]
1
400
1
#include <iostream> #include <string> using namespace std; int main() { int a; int b; int c; int h; int n; while (cin >> a >> b >> c) { if (a == 0 && b == 0 && c == 0) { break; } cin >> n; int d[n]; int e[n]; int f[n]; int g[n]; int i[a + b + c]; h = 0; while (h...
#include <iostream> #include <string> using namespace std; int main() { int a; int b; int c; int h; int n; while (cin >> a >> b >> c) { if (a == 0 && b == 0 && c == 0) { break; } cin >> n; int d[n]; int e[n]; int f[n]; int g[n]; int i[a + b + c]; h = 0; while (h...
[["-", 0, 57, 64, 9, 0, 1, 0, 16, 17, 60], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32]]
1
427
6
#include <algorithm> #include <cstdlib> #include <fstream> #include <iostream> #include <iterator> #include <map> #include <queue> #include <stack> #include <string> #include <vector> typedef long long int lli; using namespace std; int main() { int a, b, c, n; while (cin >> a >> b >> c && a != 0 && b != 0 && c != ...
#include <algorithm> #include <cstdlib> #include <fstream> #include <iostream> #include <iterator> #include <map> #include <queue> #include <stack> #include <string> #include <vector> typedef long long int lli; using namespace std; int main() { int a, b, c, n; while (cin >> a >> b >> c && a != 0 && b != 0 && c != ...
[["-", 0, 11, 31, 69, 341, 342, 0, 69, 28, 22], ["+", 0, 11, 31, 69, 341, 342, 0, 69, 28, 22]]
1
407
2
#include <algorithm> #include <iostream> using namespace std; int main() { int a, b, c, n, flag = 1; while (1) { cin >> a >> b >> c; if (a == 0 && b == 0 && c == 0) break; cin >> n; int p = 0, w[n], x[n], y[n], z[n], ans[a + b + c + 1]; for (int i = 0; i < a + b + c + 1; i++) ans[i] ...
#include <algorithm> #include <iostream> using namespace std; int main() { int a, b, c, n, flag = 1; while (1) { cin >> a >> b >> c; if (a == 0 && b == 0 && c == 0) break; cin >> n; int p = 0, w[n], x[n], y[n], z[n], ans[a + b + c + 1]; for (int i = 0; i < a + b + c + 1; i++) ans[i] ...
[["-", 0, 57, 64, 9, 0, 1, 0, 16, 17, 60], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32]]
1
386
6
for e in iter(input,'0 0 0'): d=[2]*-~sum(map(int,e.split())) f=[] for _ in[0]*int(input()): s,t,u,v=map(int,input().split()) if v:d[s]=d[t]=d[u]=1 else:f+=[(s,t,u)] for s,t,u in f: if d[t]*d[u]!=1:d[s]=0 if d[u]*d[s]!=1:d[t]=0 if d[s]*d[t]!=1:d[u]=0 print(d[1:],sep='\n')
for e in iter(input,'0 0 0'): d=[2]*-~sum(map(int,e.split())) f=[] for _ in[0]*int(input()): s,t,u,v=map(int,input().split()) if v:d[s]=d[t]=d[u]=1 else:f+=[(s,t,u)] for s,t,u in f: if d[t]*d[u]==1:d[s]=0 if d[u]*d[s]==1:d[t]=0 if d[s]*d[t]==1:d[u]=0 print(*d[1:],sep='\n')
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 79], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 60], ["+", 0, 652, 3, 4, 0, 206, 51, 661, 0, 48]]
5
183
21
#include <stdio.h> #include <string.h> int main() { // gp int a, b, n, x, y, i, j; // oHz int dp[17][17]; // while while (scanf("%d %d", &a, &b) != EOF && a && b) { // oH memset(dp, -1, sizeof(dp)); // ss_ scanf("%d", &n); // X^[guuoH0 for (i = 0; i <= a; i++) { dp[i][0] = ...
#include <stdio.h> #include <string.h> int main() { // gp int a, b, n, x, y, i, j; // oHz int dp[17][17]; // while while (scanf("%d %d", &a, &b) != EOF && a && b) { // oH memset(dp, -1, sizeof(dp)); // ss_ scanf("%d", &n); // X^[guuoH0 for (i = 0; i <= a; i++) { dp[i][0] = ...
[["+", 12, 16, 31, 69, 28, 69, 71, 16, 17, 33], ["+", 12, 16, 31, 69, 28, 69, 71, 16, 12, 13]]
0
280
2
#include <stdio.h> int main(void) { int a, b, x, y, n, i, j; while (1) { int map[17][17] = {0}; int dp[17][17] = {0}; dp[1][1] = 1; scanf("%d %d", &a, &b); if (a == 0 && b == 0) break; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d %d", &x, &y); map[x][y] = -1; ...
#include <stdio.h> int main(void) { int a, b, x, y, n, i, j; while (1) { int map[17][17] = {0}; int dp[17][17] = {0}; dp[1][1] = 1; scanf("%d %d", &a, &b); if (a == 0 && b == 0) break; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d %d", &x, &y); map[x][y] = -1; ...
[["-", 8, 9, 0, 57, 64, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 57, 64, 1, 0, 11, 17, 107]]
0
228
2
#include <stdio.h> int main() { int board[17][17] = {0}; int i, j, n, x, y, p, q; while (scanf("%d%d", &x, &y), x + y) { scanf("%d", &n); for (i = 0; i < 17 * 17; i++) board[i % 17][i / 17] = 1; for (i = 0; i < n; i++) { scanf("%d%d", &p, &q); board[p][q] = 0; } /* for...
#include <stdio.h> int main() { int board[17][17] = {0}; int i, j, n, x, y, p, q; while (scanf("%d%d", &x, &y), x + y) { scanf("%d", &n); for (i = 0; i < 17 * 17; i++) board[i % 17][i / 17] = -1; for (i = 0; i < n; i++) { scanf("%d%d", &p, &q); board[p][q] = 0; } /* fo...
[["-", 8, 9, 0, 7, 8, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 1, 0, 11, 12, 13]]
0
312
2
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int a, b; int n; int i, j; long long int **count; while (scanf("%d %d", &a, &b), a) { count = (long long int **)malloc(sizeof(long long int *) * a); for (i = 0; i < a; i++) { count[i] = (long long int *)malloc(sizeof(long l...
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int a, b; int n; int i, j; long long int **count; while (scanf("%d %d", &a, &b), a) { count = (long long int **)malloc(sizeof(long long int *) * a); for (i = 0; i < a; i++) { count[i] = (long long int *)malloc(sizeof(long l...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
403
1
#include <bits/stdc++.h> using namespace std; int area[18][18]; int a, b, n; int ans = 0; int saiki(int x, int y) { // cout << x << ' ' << y << endl; if (area[x][y] == -1) return 0; if (x == a && y == b) { // cout << 'z' << endl; return 1; } ans += saiki(x, y + 1); ans += saiki(x + 1, y); re...
#include <bits/stdc++.h> using namespace std; int area[18][18]; int a, b, n; int ans = 0; int saiki(int x, int y) { // cout << x << ' ' << y << endl; if (area[x][y] == -1) return 0; if (x == a && y == b) { // cout << 'z' << endl; return 1; } ans += saiki(x, y + 1); ans += saiki(x + 1, y); re...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
233
4
#include <cstdio> #include <iostream> using namespace std; const int N = 40; int main() { while (1) { int a, b, n, x, y; long f[17][17]; scanf(" %d %d", &a, &b); if (a == 0 && b == 0) break; scanf(" %d", &n); //入力なしは-1 for (int i = 1; i <= a; ++i) for (int j = 1; j <= b; ++...
#include <cstdio> #include <iostream> using namespace std; const int N = 40; int main() { while (1) { int a, b, n, x, y; long f[17][17]; scanf(" %d %d", &a, &b); if (a == 0 && b == 0) break; scanf(" %d", &n); //入力なしは-1 for (int i = 1; i <= a; ++i) for (int j = 1; j <= b; ++...
[["-", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13], ["+", 8, 9, 0, 7, 10, 43, 49, 50, 51, 13]]
1
378
2
#include <algorithm> #include <cstdio> #include <math.h> #include <string.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) const int INF = 1001001001; int A, B; int N; long long int DP[20][20]; int main() { while (1) { memset(DP, 0, sizeof(DP)); scanf("%d %d", &A, &B); if (A == 0 &&...
#include <algorithm> #include <cstdio> #include <math.h> #include <string.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) const int INF = 1001001001; int A, B; int N; long long int DP[20][20]; int main() { while (1) { memset(DP, 0, sizeof(DP)); scanf("%d %d", &A, &B); if (A == 0 &&...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
1
351
1
#include <iostream> #include <vector> int main(void) { // make street int num_row, num_col; while (std::cin >> num_row >> num_col, num_row == 0 && num_col == 0) { // std::cin >> num_row >> num_col; std::vector<int> street(num_row * num_col, 1); // make stop int stop_num, row, col; std::cin >...
#include <iostream> #include <vector> int main(void) { int num_row, num_col; while (std::cin >> num_row >> num_col, num_row != 0 && num_col != 0) { // make street std::vector<int> street(num_row * num_col, 1); // make stop int stop_num, row, col; std::cin >> stop_num; for (int i = 0; i < ...
[["-", 15, 339, 51, 34, 12, 16, 31, 16, 17, 60], ["+", 15, 339, 51, 34, 12, 16, 31, 16, 17, 79], ["-", 15, 339, 51, 34, 12, 16, 12, 16, 17, 60], ["+", 15, 339, 51, 34, 12, 16, 12, 16, 17, 79]]
1
244
4
#include <iostream> #include <vector> const int Max_a = 17; // 1 <= a <= 16 const int Max_b = 17; // 1 <= b <= 16 bool memo[Max_a][Max_b]; // memo for dp void format() { for (u_int i = 0; i < Max_a; ++i) { for (u_int j = 0; j < Max_b; ++j) { if (i == 0 || j == 0) { // not use memo[0][] and memo[][0]...
#include <iostream> #include <vector> const int Max_a = 17; // 1 <= a <= 16 const int Max_b = 17; // 1 <= b <= 16 bool memo[Max_a][Max_b]; // memo for dp void format() { for (u_int i = 0; i < Max_a; ++i) { for (u_int j = 0; j < Max_b; ++j) { if (i == 0 || j == 0) { // not use memo[0][] and memo[][0]...
[["-", 0, 57, 75, 76, 0, 9, 0, 1, 0, 35]]
1
376
1
#include <algorithm> #include <iostream> #include <vector> int main() { int a, b, x, y; while (std::cin >> a >> b) { if (a == 0 && b == 0) { break; } std::vector<std::vector<int>> road(a, std::vector<int>(b, 1)); int num = 0; std::cin >> num; for (int i = 0; i < num; ++i) { ...
#include <algorithm> #include <iostream> #include <vector> int main() { int a, b, x, y; while (std::cin >> a >> b) { if (a == 0 && b == 0) { break; } std::vector<std::vector<int>> road(a, std::vector<int>(b, 1)); int num = 0; std::cin >> num; for (int i = 0; i < num; ++i) { ...
[["+", 63, 118, 28, 2, 3, 4, 0, 16, 17, 33], ["+", 63, 118, 28, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 11, 31, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 11, 31, 2, 3, 4, 0, 16, 12, 13]]
1
393
4
#include <iostream> #include <stdlib.h> using namespace std; int main() { int a, b; while (cin >> a >> b, a | b) { int x, y, m = 0; int d[a * b] = {}; int k; cin >> k; for (int i = 0; i < k; ++i) { cin >> x >> y; x--; y--; d[x + y * a] = 1; } int dp[2][a * b]; ...
#include <iostream> #include <stdlib.h> using namespace std; int main() { int a, b; while (cin >> a >> b, a | b) { int x, y, m = 0; int d[a * b] = {}; int k; cin >> k; for (int i = 0; i < k; ++i) { cin >> x >> y; x--; y--; d[x + y * a] = 1; } int dp[2][a * b]; ...
[["-", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["-", 8, 9, 0, 57, 64, 9, 0, 37, 0, 13], ["+", 8, 9, 0, 57, 64, 9, 0, 93, 0, 94]]
1
402
3
#include <algorithm> #include <cstdio> #include <cstring> using namespace std; int zahyo[16][16]; int main() { int x, y, a, b, c; while (1) { memset(zahyo, -1, sizeof(int) * 16 * 16); for (int i = 0; i < 16; i++) { zahyo[i][0] = 1; zahyo[0][i] = 1; } scanf("%d%d", &x, &y); if (x ==...
#include <algorithm> #include <cstdio> #include <cstring> using namespace std; int zahyo[16][16]; int main() { int x, y, a, b, c; while (1) { memset(zahyo, -1, sizeof(int) * 16 * 16); for (int i = 0; i < 16; i++) { zahyo[i][0] = 1; zahyo[0][i] = 1; } scanf("%d%d", &x, &y); if (x ==...
[["-", 8, 9, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60]]
1
333
4
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define reep(n1, n2, n3) for (int n1 = n3; n1 < n2; n1++) #define rep(n1, n2) reep(n1, n2, 0) #define...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define reep(n1, n2, n3) for (int n1 = n3; n1 < n2; n1++) #define rep(n1, n2) reep(n1, n2, 0) #define...
[["-", 31, 69, 28, 69, 341, 342, 0, 16, 31, 22], ["+", 31, 69, 28, 69, 341, 342, 0, 16, 31, 22], ["-", 0, 11, 31, 69, 341, 342, 0, 16, 31, 22], ["+", 0, 11, 31, 69, 341, 342, 0, 16, 31, 22]]
1
359
4
while True: a, b = map(int, input().split()) if a == 0: break N = int(input()) memo = [[0 for i in range(a+1)] for j in range(b+1)] flag = [[False for i in range(a+1)] for j in range(b+1)] memo[1][1] = 1 flag[1][1] = True x = [0] * N y = [0] * N for i in range(N): ...
while True: a, b = map(int, input().split()) if a == 0: break N = int(input()) memo = [[0 for i in range(a+1)] for j in range(b+1)] flag = [[False for i in range(a+1)] for j in range(b+1)] memo[1][1] = 1 flag[1][1] = True x = [0] * N y = [0] * N for i in range(N): ...
[["-", 0, 52, 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
244
4
function maxSum(arr, len) { var sumArr = []; for (var i = 0; i < arr.length - len; i++) { var j = len; var sum = 0; if (i == 0) { while (j > 0) { sum += arr[i + j]; j--; } } else { sum = sumArr[i - 1] - arr[i - 1] + arr[i + j]; } sumArr.push(sum); } sumA...
function maxSum(arr, len) { var sumArr = []; for (var i = 0; i < arr.length - len; i++) { var j = len; var sum = 0; if (i == 0) { while (j >= 0) { sum += arr[i + j]; j--; } } else { sum = sumArr[i - 1] - arr[i - 1] + arr[i + j]; } sumArr.push(sum); } sum...
[["-", 64, 556, 0, 52, 15, 23, 0, 16, 17, 47], ["+", 64, 556, 0, 52, 15, 23, 0, 16, 17, 20], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 24], ["+", 0, 1, 0, 11, 12, 16, 31, 23, 0, 25], ["+", 64, 556, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 64, 556, 0, 1, 0, 11, 12, 16, 12, 555]]
2
289
6
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { // TODO ????????????????????????????????????????????? try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) { String lin...
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws Exception { // TODO ????????????????????????????????????????????? try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) { String lin...
[["+", 0, 57, 64, 196, 0, 1, 0, 11, 31, 22], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 196, 0, 1, 0, 11, 12, 499], ["+", 8, 196, 0, 57, 64, 196, 0, 1, 0, 35], ["-", 0, 7, 502, 503, 49, 200, 51, 16, 12, 499], ["+", 0, 7, 502, 503, 49, 200, 51, 16, 12, 22]]
3
275
6
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); int n = stdIn.nextInt(); int k = stdIn.nextInt(); int[] ans = new int[1000]; int index = 0; while (n != 0 || k != 0) { int sum = 0; int[] num = new int[n...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); int n = stdIn.nextInt(); int k = stdIn.nextInt(); int[] ans = new int[10]; int index = 0; while (n != 0 || k != 0) { int sum = 0; int[] num = new int[n];...
[["-", 0, 503, 49, 200, 51, 227, 497, 505, 0, 499], ["+", 0, 503, 49, 200, 51, 227, 497, 505, 0, 499], ["-", 0, 7, 8, 196, 0, 503, 39, 506, 0, 507], ["-", 0, 7, 8, 196, 0, 503, 49, 200, 141, 22], ["+", 0, 7, 8, 196, 0, 1, 0, 11, 31, 22], ["-", 8, 196, 0, 57, 15, 15, 0, 16, 31, 22], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 3...
3
264
9
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { int n = sc.nextInt(); int k = sc.nextInt(); if (n == 0 && k == 0) break; int[] a = new int[n]; int sum = 0, maxsum = 0; for (i...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { int n = sc.nextInt(); int k = sc.nextInt(); if (n == 0 && k == 0) break; int[] a = new int[n]; int sum = 0, maxsum = 0; for (i...
[["-", 8, 196, 0, 1, 0, 492, 3, 4, 0, 22], ["+", 8, 196, 0, 1, 0, 492, 3, 4, 0, 22]]
3
182
2
#include <algorithm> #include <iostream> #include <queue> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define MP make_pair using namespace std; typedef vector<int> vi; typedef pair<int, int> P; int gcd(int n, int m) { return m == 0 ? n : gcd(m, n % m); } int lcm(int n, int m) { int g = gcd(...
#include <algorithm> #include <iostream> #include <queue> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define MP make_pair using namespace std; typedef vector<int> vi; typedef pair<int, int> P; int gcd(int n, int m) { return m == 0 ? n : gcd(m, n % m); } int lcm(int n, int m) { int g = gcd(...
[["-", 0, 16, 12, 69, 341, 342, 0, 69, 28, 22], ["+", 0, 16, 12, 69, 341, 342, 0, 69, 28, 22]]
1
485
4
require 'rational' class AOJ0520 def initialize(n) @n = n @poles = [] end def solve @n.times{ @poles << gets.split.map(&:to_i) } top = ((1..@n).to_a - @poles.map{ |p| [p[2], p[3]] }.flatten)[0] weight(top-1) end def weight(id) r = (@poles[id][2] == 0 ? 1 : weight(@poles[id][2]-1))...
require 'rational' class AOJ0520 def initialize(n) @n = n @poles = [] end def solve @n.times{ @poles << gets.split.map(&:to_i) } top = ((1..@n).to_a - @poles.map{ |p| [p[2], p[3]] }.flatten)[0] weight(top-1) end def weight(id) r = (@poles[id][2] == 0 ? 1 : weight(@poles[id][2]-1))...
[["-", 12, 738, 31, 652, 486, 739, 0, 738, 12, 22], ["+", 12, 738, 31, 652, 486, 739, 0, 738, 12, 22], ["-", 12, 738, 31, 652, 3, 4, 0, 738, 12, 22], ["+", 12, 738, 31, 652, 3, 4, 0, 738, 12, 22]]
4
218
8
def gcd(a, b): r = a % b if r: return gcd(b, r) return b def lcm(a, b): if a < b: a, b = b, a return a * b // gcd(a, b) def min_weight(m): p, q, r, b = bars[m - 1] red = q * (min_weight(r) if r else 1) blue = p * (min_weight(b) if b else 1) equilibrium = lcm(red, ...
def gcd(a, b): r = a % b if r: return gcd(b, r) return b def lcm(a, b): if a < b: a, b = b, a return a * b // gcd(a, b) def min_weight(m): p, q, r, b = bars[m - 1] red = p * (min_weight(r) if r else 1) blue = q * (min_weight(b) if b else 1) equilibrium = lcm(red, ...
[["-", 8, 196, 0, 1, 0, 662, 12, 657, 31, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 31, 22]]
5
215
4
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = ""; int[] charge = new int[1000]; for ...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = ""; int[] charge = new int[1000]; for ...
[["-", 0, 195, 8, 196, 0, 1, 0, 492, 500, 22], ["-", 0, 195, 8, 196, 0, 1, 0, 492, 0, 131], ["-", 0, 195, 8, 196, 0, 1, 0, 492, 141, 22], ["-", 8, 196, 0, 1, 0, 492, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 492, 3, 4, 0, 25], ["-", 8, 498, 0, 195, 8, 196, 0, 1, 0, 35]]
3
230
6
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n; int sum; int m; while (true) { n = scan.nextInt(); m = 1000; sum = 0; if (n == 0) break; m -= n; sum += m / 500; m %=...
import java.util.Scanner; class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n; int sum; int m; while (true) { n = scan.nextInt(); m = 1000; sum = 0; if (n == 0) break; m -= n; sum += m / 500; m %=...
[["-", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46], ["+", 0, 195, 8, 196, 0, 52, 8, 196, 0, 46]]
3
140
2
#include <stdio.h> int main(void) { int paid; int change; int money; while (1) { scanf("%d", &paid); if (paid == 0) { break; } change = 1000 - paid; money = 0; if (change > 500) { money++; change -= 500; } if (change > 100) { money += change / 100; ...
#include <stdio.h> int main(void) { int paid; int change; int money; while (1) { scanf("%d", &paid); if (paid == 0) { break; } change = 1000 - paid; money = 0; if (change >= 500) { money++; change -= 500; } if (change >= 100) { money += change / 100; ...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20]]
0
192
12
#include <stdio.h> int main(void) { int n, cha, count = 0; while (1) { scanf("%d", &n); if (n == 0) break; cha = 1000 - n; if (cha >= 500) { cha -= 500; count++; } while (cha >= 100) { cha -= 100; count++; } if (cha >= 50) { cha -= 50; ...
#include <stdio.h> int main(void) { int n, cha, count = 0; while (1) { count = 0; scanf("%d", &n); if (n == 0) break; cha = 1000 - n; if (cha >= 500) { cha -= 500; count++; } while (cha >= 100) { cha -= 100; count++; } if (cha >= 50) { ...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
0
151
4
#include <stdio.h> int main() { int coin, money = 1000, num; while (1) { scanf("%d", &num); if (num == 0) break; money -= num; coin = money / 500; money %= 500; coin += money / 100; money %= 100; coin += money / 50; money %= 50; coin += money / 10; money %= 10; ...
#include <stdio.h> int main() { int coin, money, num; while (1) { scanf("%d", &num); if (num == 0) break; money = 1000 - num; coin = money / 500; money %= 500; coin += money / 100; money %= 100; coin += money / 50; money %= 50; coin += money / 10; money %= 10; ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 0, 32], ["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["-", 0, 52, 8, 9, 0, 1, 0, 11, 17, 110], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33]]
0
112
6
#include <stdio.h> int main() { int a, b, c, d, e, f, g, h, t; scanf("%d", &t); a = 1000 - t; b = a / 500; c = a % 500 / 100; d = a % 500 % 100 / 50; e = a % 500 % 100 % 50 / 10; f = a % 500 % 100 % 50 % 10 / 5; g = a % 500 % 100 % 50 % 10 % 5; h = b + c + d + e + f + g; if (t == 0) { return 0...
#include <stdio.h> int main() { int a, b, c, d, e, f, g, h, t; while (1) { scanf("%d", &t); a = 1000 - t; b = a / 500; c = a % 500 / 100; d = a % 500 % 100 / 50; e = a % 500 % 100 % 50 / 10; f = a % 500 % 100 % 50 % 10 / 5; g = a % 500 % 100 % 50 % 10 % 5; h = b + c + d + e + f +...
[["+", 0, 30, 0, 14, 8, 9, 0, 52, 0, 89], ["+", 0, 14, 8, 9, 0, 52, 15, 23, 0, 24], ["+", 0, 14, 8, 9, 0, 52, 15, 23, 0, 13], ["+", 0, 14, 8, 9, 0, 52, 15, 23, 0, 25], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 45], ["+", 8, 9, 0, 57, 75, 76, 0, 9, 0, 46]]
0
148
6
#include <stdio.h> int main() { int mon, a, b, c, d, e, f, y; while (1) { scanf("%d", &mon); y = 1000 - mon; if (mon <= 500) { a = (y - 500) / 100; b = (y - 500 - 100 * a) / 50; c = (y - 500 - 100 * a - 50 * b) / 10; d = (y - 500 - 100 * a - 50 * b - 10 * c) / 5; e = (y -...
#include <stdio.h> int main() { int mon, a, b, c, d, e, f, y; while (1) { scanf("%d", &mon); y = 1000 - mon; if (mon <= 500 && mon > 0) { a = (y - 500) / 100; b = (y - 500 - 100 * a) / 50; c = (y - 500 - 100 * a - 50 * b) / 10; d = (y - 500 - 100 * a - 50 * b - 10 * c) / 5; ...
[["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 98], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 17, 47], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 12, 13]]
0
287
4
#include <stdio.h> const int money[] = {500, 100, 50, 10, 5, 1}; const int size = sizeof(money) / sizeof(int); int main(void) { int x, i, answer = 0; while (1) { scanf("%d", &x); if (x == 0) { break; } x = 1000 - x; for (i = 0; i < size; ++i) { answer += x / money[i]; x %=...
#include <stdio.h> const int money[] = {500, 100, 50, 10, 5, 1}; const int size = sizeof(money) / sizeof(int); int main(void) { int x, i, answer = 0; while (1) { scanf("%d", &x); if (x == 0) { break; } x = 1000 - x; answer = 0; for (i = 0; i < size; ++i) { answer += x / mone...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
0
128
4
#include <stdio.h> int main() { int price, val = 0; while (1) { scanf("%d\n", &price); if (price == 0) break; price = 1000 - price; if (price / 500 == 1) { val++; price -= 500; } if (price / 100 > 0) { val = price / 100; price -= (price / 100) * 100; } i...
#include <stdio.h> int main() { int price, val = 0; while (1) { scanf("%d\n", &price); if (price == 0) break; price = 1000 - price; if (price / 500 == 1) { val++; price -= 500; } if (price / 100 > 0) { val += price / 100; price -= (price / 100) * 100; } ...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 107]]
0
190
6
#include <stdio.h> int main(void) { int n, i, cnt, x[] = {500, 100, 50, 10, 5, 1}; while (1) { scanf("%d", &n); if (n == 0) break; n = 1000 - n; cnt = 0; for (i = 0; i < 6; i++) { if (n > x[i]) { cnt += n / x[i]; n %= x[i]; } } printf("%d\n", cnt); } ...
#include <stdio.h> int main(void) { int n, i, cnt, x[] = {500, 100, 50, 10, 5, 1}; while (1) { scanf("%d", &n); if (n == 0) break; n = 1000 - n; cnt = 0; for (i = 0; i < 6; i++) { if (n >= x[i]) { cnt += n / x[i]; n %= x[i]; } } printf("%d\n", cnt); } ...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 20]]
0
123
2
b, s, k; main(c) { for (; scanf("%d", &c), c; s = !printf("%d\n", s)) { for (b = 1e3, c = b - c; b /= k++ % 2 ? 5 : 2; s += c / b, c %= b) ; } }
b, s, k; main(c) { for (; scanf("%d", &c), c; k = s = !printf("%d\n", s)) { for (b = 1e3, c = b - c; b /= k++ % 2 ? 5 : 2; s += c / b, c %= b) ; } }
[["+", 0, 14, 8, 9, 0, 7, 26, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 7, 26, 11, 17, 32]]
0
76
3
b, s, k; main(c) { for (; scanf("%d", &c), c; s = !printf("%d\n", s)) { for (b = 1e3, c = b - c; b /= k++ % 2 ? 5 : 2; s += c / b, c %= b) ; } }
b, s, k; main(c) { for (; scanf("%d", &c), c; s = !printf("%d\n", s)) { for (b = 1e3, c = b - c; b /= k % 2 ? 5 : 2; s += c / b, c %= b) k++; } }
[["-", 15, 11, 12, 41, 15, 16, 31, 27, 17, 29], ["+", 8, 9, 0, 7, 8, 1, 0, 27, 28, 22], ["+", 8, 9, 0, 7, 8, 1, 0, 27, 17, 29]]
0
76
3
#include <stdio.h> int main(void) { int a = 0, b = 0, c = 0, i, j; for (j = 0;; j++) { scanf("%d", &a); if (a == 0) { break; } b = 1000 - a; if (b >= 500) { b = b - 500; c = c + 1; } for (i = 0;; i++) { if (0 <= b && b < 100) { break; } b = b -...
#include <stdio.h> int main(void) { int a = 0, b = 0, c = 0, i, j; for (j = 0;; j++) { scanf("%d", &a); if (a == 0) { break; } b = 1000 - a; if (b >= 500) { b = b - 500; c = c + 1; } for (i = 0;; i++) { if (0 <= b && b < 100) { break; } b = b -...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
0
287
4
#include <stdio.h> int main() { int a; int b, c; int k; scanf("%d", &a); while (a != 0) { if (a == 0) break; k = 0; a = 1000 - a; for (b = 0; a != 0; b++) { if (a >= 500) { k += 1; a = a - 500; } else if (a >= 100 && a < 500) { k += 1; a = a...
#include <stdio.h> int main() { int a; int b, c; int k; scanf("%d", &a); while (a != 0) { if (a == 0) break; k = 0; a = 1000 - a; for (b = 0; a != 0; b++) { if (a >= 500) { k += 1; a = a - 500; } else if (a >= 100 && a < 500) { k += 1; a = a...
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 44]]
0
225
1
#include <algorithm> #include <iostream> using namespace std; int main() { int n, k; while (1) { cin >> k; if (k == 0) break; n = k / 500 + k % 500 / 100 + k % 500 % 100 / 50 + k % 500 % 100 % 50 / 10 + k % 500 % 100 % 50 % 10 / 5 + k % 500 % 100 % 50 % 10 % 5; cout << n << endl; } ...
#include <algorithm> #include <iostream> using namespace std; int main() { int n, k; while (1) { cin >> k; if (k == 0) break; k = 1000 - k; n = k / 500 + k % 500 / 100 + k % 500 % 100 / 50 + k % 500 % 100 % 50 / 10 + k % 500 % 100 % 50 % 10 / 5 + k % 500 % 100 % 50 % 10 % 5; cout <...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
100
6
#include <iostream> using namespace std; int main() { int C[6] = {500, 100, 50, 10, 5, 1}; // 0:500円 1:100円 2:50円 3:10円 4:5円 5:1円 int price; int change = 1000; int coin = 0; for (;;) { change = 1000; coin = 0; cin >> price; if (price == 0) break; change -= price; ...
#include <iostream> using namespace std; int main() { int C[6] = {500, 100, 50, 10, 5, 1}; // 0:500円 1:100円 2:50円 3:10円 4:5円 5:1円 int price; int change = 1000; int coin = 0; for (;;) { change = 1000; coin = 0; cin >> price; if (price == 0) break; change -= price; ...
[["+", 0, 7, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 7, 8, 9, 0, 1, 0, 16, 12, 22]]
1
116
2
#include <algorithm> #include <bitset> #include <cstdio> #include <cstdlib> #include <iostream> #include <iterator> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <string> #include <time.h> #include <vector> using namespace std; #define FOR(I, F, N) for (int I = F; I < (int...
#include <algorithm> #include <bitset> #include <cstdio> #include <cstdlib> #include <iostream> #include <iterator> #include <map> #include <math.h> #include <queue> #include <set> #include <sstream> #include <string> #include <time.h> #include <vector> using namespace std; #define FOR(I, F, N) for (int I = F; I < (int...
[["-", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
279
4
#include <stdio.h> int main(void) { int a, s, ss; while (1) { scanf("%d", &a); if (s == 0) break; s = 1000 - a; ss = s / 500; s = s % 500; ss += s / 100; s = s % 100; ss += s / 50; s = s % 50; ss += s / 10; s = s % 10; ss += s / 5; s = s % 5; ss += s / 1...
#include <stdio.h> int main(void) { int a, s, ss; while (1) { scanf("%d", &a); if (a == 0) break; s = 1000 - a; ss = s / 500; s = s % 500; ss += s / 100; s = s % 100; ss += s / 50; s = s % 50; ss += s / 10; s = s % 10; ss += s / 5; s = s % 5; ss += s / 1...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22]]
1
125
2
#include <algorithm> #include <bits/stdc++.h> #include <queue> #include <vector> using namespace std; typedef long long ll; int c[6] = {500, 100, 50, 10, 5, 1}; int main() { int n; while (scanf("%d", &n) && !n) { int m = 1000 - n; int res = 0; for (int i = 0; i < 6; i++) { res += m / c[i]; ...
#include <algorithm> #include <bits/stdc++.h> #include <queue> #include <vector> using namespace std; typedef long long ll; int c[6] = {500, 100, 50, 10, 5, 1}; int main() { int n; while (scanf("%d", &n) && n) { int m = 1000 - n; int res = 0; for (int i = 0; i < 6; i++) { res += m / c[i]; ...
[["-", 0, 52, 15, 339, 51, 16, 12, 91, 17, 111]]
1
117
1
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <iostream> #include <queue> #include <string> using namespace std; int main() { int m, o, ans; while (1) { o = 0; ans = 0; cin >> m; if (m == 0) break; o = 1000 - m; if (o > 500) { o -= 500; ...
#include <algorithm> #include <cctype> #include <cmath> #include <cstdio> #include <iostream> #include <queue> #include <string> using namespace std; int main() { int m, o, ans; while (1) { o = 0; ans = 0; cin >> m; if (m == 0) break; o = 1000 - m; if (o > 500) { o -= 500; ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
161
2
#include <iostream> using namespace std; int main() { while (true) { int a, b = 0; cin >> a; if (a == 0) break; a = 1000 - a; if (a > 500) { a = a - 500; b = b + 1; } b = b + a / 100; a = a % 100; if (a > 50) { a = a - 50; b = b + 1; } b = b + ...
#include <iostream> using namespace std; int main() { while (true) { int a, b = 0; cin >> a; if (a == 0) break; a = 1000 - a; if (a >= 500) { a = a - 500; b = b + 1; } b = b + a / 100; a = a % 100; if (a >= 50) { a = a - 50; b = b + 1; } b = b ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
146
6
#include <iostream> using namespace std; int main() { int a, b, c = 0; while (1) { cin >> a; if (a == 0) { break; } else { b = 1000 - a; c = b / 500; c = c + b % 500 / 100; c = c + b % 500 % 100 / 50; c = c + b % 500 % 100 % 50 / 10; c = c + b % 500 % 100 % 50 %...
#include <iostream> using namespace std; int main() { int a, b, c = 0; while (1) { cin >> a; if (a == 0) { break; } else { b = 1000 - a; c = b / 500; c = c + b % 500 / 100; c = c + b % 500 % 100 / 50; c = c + b % 500 % 100 % 50 / 10; c = c + b % 500 % 100 % 50 %...
[["-", 0, 9, 0, 1, 0, 11, 12, 16, 17, 67], ["+", 0, 11, 12, 16, 12, 16, 31, 16, 17, 109]]
1
139
2
#include <algorithm> #include <cstdlib> #include <iostream> using namespace std; int main() { while (true) { int coin = 0; int price = 0; cin >> price; if (price == 0) { break; } for (auto temp : {500, 100, 50, 10, 5, 1}) { const auto temp_div = div(price, temp); coin += ...
#include <algorithm> #include <cstdlib> #include <iostream> using namespace std; int main() { while (true) { int coin = 0; int price = 0; cin >> price; if (price == 0) { break; } price = 1000 - price; for (auto temp : {500, 100, 50, 10, 5, 1}) { const auto temp_div = div(p...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
99
6
#include <iostream> using namespace std; int main() { int coin[6] = {500, 100, 50, 10, 5, 1}; int cost; while (cin >> cost) { int count = 0; cost = 1000 - cost; for (int i = 0; i < 6; i++) { if (cost >= coin[i]) { count += cost / coin[i]; cost %= coin[i]; } } c...
#include <iostream> using namespace std; int main() { int coin[6] = {500, 100, 50, 10, 5, 1}; int cost; while (cin >> cost, cost) { int count = 0; cost = 1000 - cost; for (int i = 0; i < 6; i++) { if (cost >= coin[i]) { count += cost / coin[i]; cost %= coin[i]; } } ...
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22]]
1
108
2
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (n); i++) int main() { const int coin[] = {500, 100, 50, 10, 5, 1}; int n; while (cin >> n) { int cnt = 0; for (int i = 0; i < 6; i++) { while (n + coin[i] <= 1000) { n += coin[i]; cnt++; } ...
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for (int i = 0; i < (n); i++) int main() { const int coin[] = {500, 100, 50, 10, 5, 1}; int n; while (cin >> n, n) { int cnt = 0; for (int i = 0; i < 6; i++) { while (n + coin[i] <= 1000) { n += coin[i]; cnt++; ...
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22]]
1
101
2
#include <iostream> using namespace std; int main() { int value, coins = 0; while (true) { cin >> value; if (value == 0) break; value = 1000 - value; coins += value / 500; value %= 500; coins += value / 100; value %= 100; coins += value / 50; value %= 50; coins += valu...
#include <iostream> using namespace std; int main() { int value, coins = 0; while (true) { cin >> value; if (value == 0) break; value = 1000 - value; coins += value / 500; value %= 500; coins += value / 100; value %= 100; coins += value / 50; value %= 50; coins += valu...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
106
4
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" int m...
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; //// < "D:\D_Download\Visual Studio ///2015\Projects\programing_contest_c++\Debug\a.txt" int m...
[["-", 0, 52, 8, 9, 0, 43, 39, 344, 141, 78], ["+", 0, 52, 8, 9, 0, 43, 39, 344, 141, 78], ["-", 0, 338, 8, 9, 0, 1, 0, 11, 17, 90], ["+", 0, 338, 8, 9, 0, 1, 0, 11, 17, 132]]
1
131
4
#include <iostream> using namespace std; int main() { int money, count = 0, oturi[1000] = {}; int money2[6] = {500, 100, 50, 10, 5, 1}; for (int i = 0; i >= 0; i++) { cin >> money; count++; if (money == 0) break; oturi[i] = 1000 - money; } for (int j = 0; j < count; j++) { int mais...
#include <iostream> using namespace std; int main() { int money, count = 0, oturi[1000] = {}; int money2[6] = {500, 100, 50, 10, 5, 1}; for (int i = 0; i >= 0; i++) { cin >> money; count++; if (money == 0) break; oturi[i] = 1000 - money; } for (int j = 0; j < count; j++) { int mais...
[["+", 8, 9, 0, 7, 8, 9, 0, 57, 0, 121], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 7, 8, 9, 0, 57, 15, 339, 0, 25]]
1
155
6
#include <iostream> using namespace std; int main() { int a, b = 0; while (1) { cin >> a; if (a == 0) break; a = 1000 - a; if (a > 500) { a -= 500; b++; } while (1) { if (a < 100) break; a -= 100; b++; } if (a > 50) { a -= 50; ...
#include <iostream> using namespace std; int main() { int a, b = 0; while (1) { cin >> a; if (a == 0) break; a = 1000 - a; if (a >= 500) { a -= 500; b++; } while (1) { if (a < 100) break; a -= 100; b++; } if (a >= 50) { a -= 50; ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
164
6
#include <iostream> using namespace std; int main() { int yen; int ans = 0; while (cin >> yen) { if (yen == 0) break; ans = yen % 5; yen /= 5; ans += yen % 2; yen /= 2; ans += yen % 5; yen /= 5; ans += yen % 2; yen /= 2; ans += yen % 5; ans += yen / 5; cou...
#include <iostream> using namespace std; int main() { int yen; int ans = 0; while (cin >> yen) { if (yen == 0) break; yen = 1000 - yen; ans = yen % 5; yen /= 5; ans += yen % 2; yen /= 2; ans += yen % 5; yen /= 5; ans += yen % 2; yen /= 2; ans += yen % 5; a...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 31, 13], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 33], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 12, 22], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
94
6
#include <iostream> using namespace std; int main(void) { // Here your code ! int n = 1; int pay; while (n) { int cent = 0; cin >> n; if (n == 0) { break; } pay = 1000 - n; if (pay >= 500) { pay -= 500; cent++; } while (pay >= 100) { pay -= 100; ...
#include <iostream> using namespace std; int main(void) { // Here your code ! int n = 1; int pay; while (n) { int cent = 0; cin >> n; if (n == 0) { break; } pay = 1000 - n; if (pay >= 500) { pay -= 500; cent++; } while (pay >= 100) { pay -= 100; ...
[["-", 8, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 12, 5, 0, 44]]
1
154
2
#include <stdio.h> int N; int coin[6] = {500, 100, 50, 10, 5, 1}; int ans = 0; int main(void) { while (true) { scanf("%d", &N); if (N == 0) { break; } int res = 1000 - N; while (res != 0) { if (res >= 500) { ans += res / 500; res -= 500 * (res / 500); } else if...
#include <stdio.h> int N; int coin[6] = {500, 100, 50, 10, 5, 1}; int ans = 0; int main(void) { while (true) { scanf("%d", &N); if (N == 0) { break; } ans = 0; int res = 1000 - N; while (res != 0) { if (res >= 500) { ans += res / 500; res -= 500 * (res / 500); ...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
226
4
#include <iostream> using namespace std; int main() { int cut = 0; int a; int b; while (1) { cin >> a; if (a == 0) break; b = 1000 - a; cut += b / 500; b = b % 500; cut += b / 100; b = b % 100; cut += b / 50; b = b % 50; cut += b / 10; b = b % 10; cut += b /...
#include <iostream> using namespace std; int main() { int cut = 0; int a; int b; while (1) { cin >> a; cut = 0; if (a == 0) { break; } b = 1000 - a; cut += b / 500; b = b % 500; cut += b / 100; b = b % 100; cut += b / 50; b = b % 50; cut += b / 10; b = b...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 52, 8, 9, 0, 57, 64, 9, 0, 46]]
1
120
6
#include <algorithm> #include <chrono> #include <cmath> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; int main() { int...
#include <algorithm> #include <chrono> #include <cmath> #include <cstdio> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <vector> using namespace std; typedef long long ll; int main() { int...
[["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 0, 52, 15, 339, 51, 16, 12, 16, 12, 13]]
1
128
4
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <un...
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <iterator> #include <map> #include <memory> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <tuple> #include <un...
[["+", 0, 52, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
317
4
#include <iostream> using namespace std; int main() { ios::sync_with_stdio(false); int n[6], count = 0, coin[] = {500, 100, 50, 10, 5}; for (int i = 0; i < 6; i++) { cin >> n[i]; if (!n[i]) break; } for (int i = 0; i < 6; i++) { if (n[i] == 0) break; int s = 1000 - n[i]; ...
#include <iostream> using namespace std; int main() { ios::sync_with_stdio(false); int n[6], count = 0, coin[] = {500, 100, 50, 10, 5}; for (int i = 0; i < 6; i++) { cin >> n[i]; if (!n[i]) break; } for (int i = 0; i < 6; i++) { if (n[i] == 0) break; int s = 1000 - n[i]; ...
[["+", 0, 7, 8, 9, 0, 1, 0, 11, 31, 22], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 7, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 8, 9, 0, 7, 8, 9, 0, 1, 0, 35]]
1
167
4
#include <iostream> using namespace std; int main() { int x; int ans; cin >> x; while (x != 0) { x = 1000 - x; ans = 0; ans += x / 500; x = x % 500; ans += x / 100; x = x % 100; ans += x / 50; x = x % 50; ans += x / 10; x = x % 10; ans += x / 5; x = x % 5; a...
#include <iostream> using namespace std; int main() { int x; int ans; cin >> x; while (x != 0) { x = 1000 - x; ans = 0; ans += x / 500; x = x % 500; ans += x / 100; x = x % 100; ans += x / 50; x = x % 50; ans += x / 10; x = x % 10; ans += x / 5; x = x % 5; a...
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
1
115
2
#include <bits/stdc++.h> using namespace std; #define llong long long #define inf 999999999 #define mp make_pair #define pb push_back #define fn fill_n typedef pair<int, int> P; typedef pair<P, int> PP; typedef pair<PP, int> PPP; typedef struct data { int now; int cost; } data; int nh[4] = {1, 0, -1, 0}; int nw[4]...
#include <bits/stdc++.h> using namespace std; #define llong long long #define inf 999999999 #define mp make_pair #define pb push_back #define fn fill_n typedef pair<int, int> P; typedef pair<P, int> PP; typedef pair<PP, int> PPP; typedef struct data { int now; int cost; } data; int nh[4] = {1, 0, -1, 0}; int nw[4]...
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22]]
1
245
2
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <iostream> #include <map> #include <set> #include <string> #include <utility> #include <vector> int main() { int a[5], sum[5] = {0}; int i = 0; while (a[i]) { std::cin >> a[i]; if (a[i] == 0) { break; } i++; ...
#include <algorithm> #include <array> #include <cmath> #include <complex> #include <iostream> #include <map> #include <set> #include <string> #include <utility> #include <vector> int main() { int a[6], sum[5] = {0}; int i = 0; while (1) { std::cin >> a[i]; if (a[i] == 0) { break; } i++; }...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 8, 9, 0, 52, 15, 339, 51, 69, 28, 22], ["-", 0, 52, 15, 339, 51, 69, 341, 342, 0, 70], ["-", 0, 52, 15, 339, 51, 69, 341, 342, 0, 22], ["-", 0, 52, 15, 339, 51, 69, 341, 342, 0, 73], ["+", 0, 14, 8, 9, 0, 52, 15, 339, 51, 13]]
1
268
7
#include <iostream> using namespace std; int main() { int value, change; int coins; while (1) { cin >> value; if (value == 0) break; coins = 0; change = 1000 - value; coins += change / 500; change %= 500; coins += change / 100; change %= 100; coins += change / 5...
#include <iostream> using namespace std; int main() { int value, change; int coins; while (1) { cin >> value; if (value == 0) break; coins = 0; change = 1000 - value; coins += change / 500; change %= 500; coins += change / 100; change %= 100; coins += change / 5...
[["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]]
1
115
2
#include <iostream> using namespace std; int main() { int money; while (cin >> money && money != 0) { int count = 0; int res = 1000 - money; for (int i = 0; i < 3; i++) { // cout << res << endl; count += res % 10; if (res % 10 > 5) { count -= 4; } res /= 10; ...
#include <iostream> using namespace std; int main() { int money; while (cin >> money && money != 0) { int count = 0; int res = 1000 - money; for (int i = 0; i < 3; i++) { // cout << res << endl; count += res % 10; if (res % 10 > 4) { count -= 4; } res /= 10; ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
86
2
#include <cstdio> int main() { while (1) { int num, n = 0, i = 0, a = 0, b = 0; scanf("%d", &num); if (num == 0) break; n = 1000 - num; if (n >= 500) { i++; n = (n - 500); } if (n >= 100) { a = n / 100; i = a + i; n = n % 100; } if (n >= 51) {...
#include <cstdio> int main() { while (1) { int num, n = 0, i = 0, a = 0, b = 0; scanf("%d", &num); if (num == 0) break; n = 1000 - num; if (n >= 500) { i++; n = (n - 500); } if (n >= 100) { a = n / 100; i = a + i; n = n % 100; } if (n >= 50) {...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
187
6
#include <algorithm> #include <cctype> #include <iostream> #include <map> #include <queue> #include <stdio.h> #include <string.h> using namespace std; int main(int argc, char const *argv[]) { int money; while (cin >> money) { int coin_count = 0; int rest = 1000; rest -= money; int tmp = 0; ...
#include <algorithm> #include <cctype> #include <iostream> #include <map> #include <queue> #include <stdio.h> #include <string.h> using namespace std; int main(int argc, char const *argv[]) { int money; while (cin >> money, money) { int coin_count = 0; int rest = 1000; rest -= money; int tmp = 0...
[["+", 8, 9, 0, 52, 15, 339, 51, 34, 0, 21], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22]]
1
138
2
#include <iostream> using namespace std; int coins[] = {500, 100, 50, 10, 5, 1}; int main() { int n; while (cin >> n && n) { cin >> n; int remaind = 1000 - n; int ans = 0; for (int i = 0; i < 6; i++) { ans += remaind / coins[i]; remaind %= coins[i]; } cout << ans << endl; } ...
#include <iostream> using namespace std; int coins[] = {500, 100, 50, 10, 5, 1}; int main() { int n; while (cin >> n && n) { int remaind = 1000 - n; int ans = 0; for (int i = 0; i < 6; i++) { ans += remaind / coins[i]; remaind %= coins[i]; } cout << ans << endl; } return 0; }
[["-", 0, 52, 8, 9, 0, 1, 0, 16, 31, 22], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 17, 152], ["-", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22], ["-", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35]]
1
101
4
#include <algorithm> #include <array> #include <cstdio> #include <iostream> #include <vector> using namespace std; int main() { const array<int, 6> coins = {500, 100, 50, 10, 5, 1}; while (true) { int n; cin >> n; if (n == 0) break; n = 1000 - n; int count = 0; for (auto coin : co...
#include <algorithm> #include <array> #include <cstdio> #include <iostream> #include <vector> using namespace std; int main() { const array<int, 6> coins = {500, 100, 50, 10, 5, 1}; while (true) { int n; cin >> n; if (n == 0) break; n = 1000 - n; int count = 0; for (auto coin : co...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]]
1
113
2
O=[500,100,50,10,1] while (i=gets.to_i)!=0 sum = 0 i = 1000 - i O.each do |o| sum += i/o i %= o end puts sum end
O=[500,100,50,10,5,1] while (i=gets.to_i)!=0 sum = 0 i = 1000 - i O.each do |o| sum += i/o i %= o end puts sum end
[["+", 36, 36, 0, 493, 0, 662, 12, 516, 0, 612], ["+", 36, 36, 0, 493, 0, 662, 12, 516, 0, 21]]
4
50
2
import sys x=sys.stdin.read().split() def otsuri(x): a=0 y=1000-x if y==1000: return'' else: while y>=0: if y-500<0: break else: y=y-500 a=a+1 while y>=0: if y-100<0: b...
import sys x=sys.stdin.read().split() def otsuri(x): a=0 y=1000-x if y==1000: sys.exit(0) else: while y>=0: if y-500<0: break else: y=y-500 a=a+1 while y>=0: if y-100<0: ...
[["-", 8, 196, 0, 57, 64, 196, 0, 37, 0, 38], ["-", 0, 57, 64, 196, 0, 37, 0, 557, 0, 654], ["-", 0, 57, 64, 196, 0, 37, 0, 557, 0, 655], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 500, 22], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 0, 131], ["+", 64, 196, 0, 1, 0, 652, 63, 319, 319, 22], ["+", 64, 196, 0, 1, 0, 652, 3, 4, 0, 2...
5
214
9
taro_spend = [] spend_num = 0 for i in range(5): taro_spend.append(int(input())) if taro_spend[i] == 0: taro_spend.pop() break spend_num += 1 changes = [1000 - taro_spend[i] for i in range(spend_num)] print(changes) for change in changes: change_coin = 0 if change >= 500: ...
taro_spend = [] spend_num = 0 for i in range(5): taro_spend.append(int(input())) if taro_spend[i] == 0: taro_spend.pop() break spend_num += 1 changes = [1000 - taro_spend[i] for i in range(spend_num)] for change in changes: change_coin = 0 if change >= 500: change -= 500 ...
[["-", 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
157
4
coins = [500, 100, 50, 10, 5, 1] def count(x, y): ret = 0 while x >= y: x -= y ret += 1 return ret while True: n = eval(input()) if n == 0: break ans = 0 n = 1000 - n for val in coins: n, t = count(n, val) ans += t print(ans)
coins = (500, 100, 50, 10, 5, 1) def count(x, y): ret = 0 while x >= y: x -= y ret += 1 return x, ret while True: n = eval(input()) if n == 0: break ans = 0 n = 1000 - n for val in coins: n, t = count(n, val) ans += t print(ans)
[["-", 0, 656, 0, 1, 0, 662, 12, 634, 0, 70], ["+", 0, 656, 0, 1, 0, 662, 12, 660, 0, 24], ["-", 0, 656, 0, 1, 0, 662, 12, 634, 0, 73], ["+", 0, 656, 0, 1, 0, 662, 12, 660, 0, 25], ["+", 0, 14, 8, 196, 0, 37, 0, 432, 0, 22], ["+", 0, 14, 8, 196, 0, 37, 0, 432, 0, 21]]
5
86
6
c = [500,100,50,10,5,1] while True: e = int(input()) if e == 0: break i,m = 0,0 while e > 0: if e >= c[i]: e -= c[i] m += 1 else: i += 1 print(m)
c = [500,100,50,10,5,1] while True: e = int(input()) if e == 0: break e = 1000-e i,m = 0,0 while e > 0: if e >= c[i]: e -= c[i] m += 1 else: i += 1 print(m)
[["+", 0, 52, 8, 196, 0, 1, 0, 662, 31, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 662, 0, 32], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 31, 612], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 33], ["+", 8, 196, 0, 1, 0, 662, 12, 657, 12, 22]]
5
70
5
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner in = new Scanner(System.in); while (true) { if (in.hasNext() == false) { break; } String text = in.next(); char[] s = text.toCharArray(); int joi = 0; int ioi = 0; ...
import java.util.Scanner; public class Main { public static void main(String args[]) { Scanner in = new Scanner(System.in); while (true) { if (in.hasNext() == false) { break; } String text = in.next(); char[] s = text.toCharArray(); int joi = 0; int ioi = 0; ...
[["-", 0, 52, 8, 196, 0, 1, 0, 492, 141, 22], ["+", 0, 52, 8, 196, 0, 1, 0, 492, 141, 22]]
3
190
2
#include <stdio.h> #include <string.h> char str[10001]; int main(void) { while (scanf("%s", str) != EOF) { int joi = 0; int ioi = 0; int i; for (i = 0; i < strlen(str) - 2; i++) { if (strncmp(str, "JOI", 3) == 0) { joi++; } if (strncmp(str, "IOI", 3) == 0) { ioi++;...
#include <stdio.h> #include <string.h> char str[10001]; int main(void) { while (scanf("%s", str) != EOF) { int joi = 0; int ioi = 0; int i; for (i = 0; i < strlen(str) - 2; i++) { if (strncmp(str + i, "JOI", 3) == 0) { joi++; } if (strncmp(str + i, "IOI", 3) == 0) { ...
[["+", 0, 16, 31, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 16, 31, 2, 3, 4, 0, 16, 12, 22]]
0
128
4
#include <stdio.h> int main(void) { int i; int counti, countj; char a[10000]; while (scanf("%s", a) != EOF) { counti = 0; countj = 0; for (i = 0; a[i] != '\0'; i++) { if (a[i + 1] == 'O' && a[i + 2] == 'I') { if (a[i] == 'I') counti++; if (a[i] == 'J') coun...
#include <stdio.h> int main(void) { int i; int counti, countj; char a[10000]; while (scanf("%s", a) != EOF) { counti = 0; countj = 0; for (i = 0; a[i] != '\0'; i++) { if (a[i + 1] == 'O' && a[i + 2] == 'I') { if (a[i] == 'I') counti++; if (a[i] == 'J') coun...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
0
137
4
#include <stdio.h> int main() { char ch[10001]; int i = 0, joi = 0, ioi = 0; while (scanf("%s\n", &ch) != EOF) { while (1) { if (ch[i] == '\0') break; if (ch[i] == 'J' && ch[i + 1] == 'O' && ch[i + 2] == 'I') joi++; if (ch[i] == 'I' && ch[i + 1] == 'O' && ch[i + 2] == 'I') ...
#include <stdio.h> int main() { char ch[10001]; int i = 0, joi = 0, ioi = 0; while (scanf("%s\n", &ch) != EOF) { while (1) { if (ch[i] == '\0') break; if (ch[i] == 'J' && ch[i + 1] == 'O' && ch[i + 2] == 'I') joi++; if (ch[i] == 'I' && ch[i + 1] == 'O' && ch[i + 2] == 'I') ...
[["-", 8, 9, 0, 57, 64, 1, 0, 27, 28, 22], ["+", 8, 9, 0, 57, 64, 1, 0, 27, 28, 22]]
0
167
2
#include <stdio.h> #include <string.h> #define S_MAX 10000 char s[S_MAX + 1]; void solve(const int l) { int j = 0, i = 0; int n = 1; while (n + 1 < l) { if (s[n] == 'O' || s[n + 1] == 'I') { switch (s[n - 1]) { case 'J': j++; break; case 'I': i++; break; ...
#include <stdio.h> #include <string.h> #define S_MAX 10000 char s[S_MAX + 1]; void solve(const int l) { int j = 0, i = 0; int n = 1; while (n + 1 < l) { if (s[n] == 'O' && s[n + 1] == 'I') { switch (s[n - 1]) { case 'J': j++; break; case 'I': i++; break; ...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 106], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 98]]
0
155
2
#include <stdio.h> #include <string.h> int main() { char string[10000]; int i, JOIcount, IOIcount, strlong; while (scanf("%s", &string) != EOF) { JOIcount = 0; IOIcount = 0; strlong = strlen(string); for (i = 0; i < strlong - 2; i++) { if (string[i] == 'J') { if (string[i + 1] == 'O...
#include <stdio.h> #include <string.h> int main() { char string[10000]; int i, JOIcount, IOIcount, strlong; while (scanf("%s", &string) != EOF) { JOIcount = 0; IOIcount = 0; strlong = strlen(string); for (i = 0; i < strlong - 2; i++) { if (string[i] == 'J') { if (string[i + 1] == 'O...
[["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
0
185
2
#include <stdio.h> int main() { char a[1001]; int i = 0; int b; int c = 0, c1 = 0; while (scanf("%s", &a) != EOF) { c = 0; c1 = 0; i = 0; while (a[i + 2] != EOF) { if (a[i] == 'J' && a[i + 1] == 'O' && a[i + 2] == 'I') { c++; } if (a[i] == 'I' && a[i + 1] == 'O' && a[...
#include <stdio.h> int main() { char a[10001]; int i = 0; int b; int c = 0, c1 = 0; while (scanf("%s", &a) != EOF) { c = 0; c1 = 0; i = 0; while (a[i + 2] != EOF) { if (a[i] == 'J' && a[i + 1] == 'O' && a[i + 2] == 'I') { c++; } if (a[i] == 'I' && a[i + 1] == 'O' && a...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
0
190
2
#include <iostream> #include <string> using namespace std; int main() { string ss; cin >> ss; int j = 0, k = 0; for (int i = 1; i < ss.length() - 1; i++) { if (ss[i] == 'O') { if (ss[i + 1] == 'I') { if (ss[i - 1] == 'J') j++; if (ss[i - 1] == 'I') k++; } ...
#include <iostream> #include <string> using namespace std; int main() { string ss; while (cin >> ss) { int j = 0, k = 0; for (int i = 1; i < ss.length() - 1; i++) { if (ss[i] == 'O') { if (ss[i + 1] == 'I') { if (ss[i - 1] == 'J') j++; if (ss[i - 1] == 'I') ...
[["+", 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, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
129
6
#include <cstdio> #include <cstring> using namespace std; int main() { char str[100000]; while (scanf("%s", str) != EOF) { int joi = 0; int ioi = 0; for (int i = 0; i < strlen(str) - 2; i++) { if (str[i] == 'J' && str[i + 1] == 'O' && str[i + 2] == 'I') { joi++; } if (str[i...
#include <cstdio> #include <cstring> using namespace std; int main() { char str[100000]; while (scanf("%s", str) != EOF) { int joi = 0; int ioi = 0; for (int i = 0; i < strlen(str) - 2; i++) { if (str[i] == 'J' && str[i + 1] == 'O' && str[i + 2] == 'I') { joi++; } if (str[i...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 98], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 17, 60]]
1
167
2
#include <iostream> #include <string> using namespace std; int main() { string s; int i, joi, ioi; while (cin >> s, !cin.eof()) { joi = 0; ioi = 0; for (i = 0; i < s.size(); i++) { if (s[i] == 'J') { if (s[i + 1] == 'O') { if (s[i + 2] == 'I') { joi++; ...
#include <iostream> #include <string> using namespace std; int main() { string s; int i, joi, ioi; while (cin >> s, !cin.eof()) { joi = 0; ioi = 0; for (i = 0; i < s.size() - 2; i++) { if (s[i] == 'J') { if (s[i + 1] == 'O') { if (s[i + 2] == 'I') { joi++; ...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["-", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46], ["+", 8, 9, 0, 52, 8, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
176
6
#include <iostream> #include <string> using namespace std; int main() { string a; while (cin >> a) { int joi = 0, ioi = 0; a += "XX"; for (int i = 0; i < a.size(); i++) { if (a[i] == 'X') break; if (a[i] == 'J' && a[i + 1] == 'O' && a[i + 2] == 'I') joi++; if (a[i] == '...
#include <iostream> #include <string> using namespace std; int main() { string a; while (cin >> a) { int joi = 0, ioi = 0; a += "xx"; for (int i = 0; i < a.size(); i++) { if (a[i] == 'x') break; if (a[i] == 'J' && a[i + 1] == 'O' && a[i + 2] == 'I') joi++; if (a[i] == '...
[["-", 8, 9, 0, 1, 0, 11, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 11, 12, 5, 0, 6], ["-", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125], ["+", 0, 57, 15, 339, 51, 16, 12, 103, 0, 125]]
1
158
4
#include <cstdio> #include <cstring> #include <iostream> using namespace std; int main() { char c[10001]; while (scanf("%s", c) != EOF) { int ioi_cnt = 0, joi_cnt = 0; for (int i = 0; i < strlen(c) - 2; i++) { if (c[i + 1] == 'O' && c[i + 2] == 'I') { if (c[i] == 'I') ioi_cnt++; ...
#include <cstdio> #include <cstring> #include <iostream> using namespace std; int main() { char c[10001]; while (scanf("%s", c) != EOF) { int ioi_cnt = 0, joi_cnt = 0; for (int i = 0; i < strlen(c) - 2; i++) { if (c[i + 1] == 'O' && c[i + 2] == 'I') { if (c[i] == 'I') ioi_cnt++; ...
[["-", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 31, 16, 12, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 12, 22]]
1
131
4
#include <iostream> #include <string> int main() { std::string s; std::cin >> s; int JOI = 0, IOI = 0; for (int i = 0; i < s.size() - 2; ++i) { if (s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I') JOI++; if (s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I') IOI++; } std::cout << JOI ...
#include <iostream> #include <string> int main() { std::string s; while (std::cin >> s) { int JOI = 0, IOI = 0; for (int i = 0; i < s.size() - 2; ++i) { if (s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I') JOI++; if (s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I') IOI++; ...
[["+", 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, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
140
6
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <util...
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <util...
[["+", 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, 14, 8, 9, 0, 52, 8, 9, 0, 46]]
1
178
6
#include <iostream> using namespace std; int main() { char s[10001] = {}; while (1) { s[0] = ' '; cin >> s; if (s[0] == ' ') { return 0; } int i = 0, ioi = 0, j = 0, joi = 0; for (int k = 0; s[k] != '\0'; k++) { switch (j) { case 1: if (s[k] == 'O') { j =...
#include <iostream> using namespace std; int main() { char s[10001] = {}; while (1) { s[0] = ' '; cin >> s; if (s[0] == ' ') { return 0; } int i = 0, ioi = 0, j = 0, joi = 0; for (int k = 0; s[k] != '\0'; k++) { switch (j) { case 1: if (s[k] == 'O') { j =...
[["-", 0, 100, 0, 57, 15, 339, 51, 11, 17, 32], ["+", 0, 100, 0, 57, 15, 339, 51, 16, 17, 60]]
1
266
4