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 |
|---|---|---|---|---|---|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args)
throws NumberFormatException, IOException {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
while (input.ready()) {
... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args)
throws NumberFormatException, IOException {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
while (input.ready()) {
... | [["+", 0, 57, 15, 15, 0, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 15, 0, 16, 31, 16, 17, 60], ["+", 0, 57, 15, 15, 0, 16, 31, 16, 12, 499], ["+", 8, 196, 0, 57, 15, 15, 0, 16, 17, 98]] | 3 | 266 | 4 |
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 s = sc.nextInt();
if (n == 0 && s == 0)
break;
int ans = solve(n, s, 0);
System.out.println(ans);
}
... | 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 s = sc.nextInt();
if (n == 0 && s == 0)
break;
int ans = solve(n, s, 0);
System.out.println(ans);
}
... | [["-", 0, 11, 12, 492, 3, 4, 0, 16, 12, 499], ["+", 0, 11, 12, 492, 3, 4, 0, 16, 12, 22]] | 3 | 179 | 2 |
import java.io.*;
import java.util.StringTokenizer;
public class Main {
public static int rec(int n, int k) {
int r = 0;
for (int i = 1; i < (1 << 10); i++) {
int c = Integer.bitCount(i);
int sum = 0;
if (c == n)
for (int j = 0; j < 10; j++)
if ((i & (1 << j)) != 0)
... | import java.io.*;
import java.util.StringTokenizer;
public class Main {
public static int rec(int n, int k) {
int r = 0;
for (int i = 1; i < (1 << 10); i++) {
int c = Integer.bitCount(i);
int sum = 0;
if (c == n) {
for (int j = 0; j < 10; j++)
if ((i & (1 << j)) != 0)
... | [["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]] | 3 | 226 | 2 |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (true) {
int n = input.nextInt();
int s = input.nextInt();
if (n == 0 && s == 0)
break;
System.out.println(count(n, s, 0, 0));
}
}
publ... | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (true) {
int n = input.nextInt();
int s = input.nextInt();
if (n == 0 && s == 0)
break;
System.out.println(count(n, s, 0, 0));
}
}
publ... | [["-", 15, 15, 0, 16, 31, 16, 12, 16, 17, 20], ["+", 15, 15, 0, 16, 31, 16, 12, 16, 17, 47]] | 3 | 169 | 2 |
import java.io.*;
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner stdin = new Scanner(System.in);
while (true) {
final int n = stdin.nextInt();
final int sum = stdin.nextInt();
if (n == 0 && sum == 0) {
break;
}
System.out.println(d... | import java.io.*;
import java.util.*;
class Main {
public static void main(String[] args) {
Scanner stdin = new Scanner(System.in);
while (true) {
final int n = stdin.nextInt();
final int sum = stdin.nextInt();
if (n == 0 && sum == 0) {
break;
}
System.out.println(d... | [["-", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22], ["+", 8, 196, 0, 503, 49, 200, 51, 492, 141, 22]] | 3 | 207 | 2 |
import java.util.*;
public class Main {
public static void main(String[] args) { new Main().run(); }
Scanner sc = new Scanner(System.in);
int n, s;
int ans;
void run() {
while (sc.hasNext()) {
n = sc.nextInt();
s = sc.nextInt();
if (n != 0) {
ans = 0;
solve(0, 0, 0);
... | import java.util.*;
public class Main {
public static void main(String[] args) { new Main().run(); }
Scanner sc = new Scanner(System.in);
int n, s;
int ans;
void run() {
while (sc.hasNext()) {
n = sc.nextInt();
s = sc.nextInt();
if (n != 0) {
ans = 0;
solve(0, 0, 0);
... | [["-", 15, 15, 0, 16, 31, 16, 31, 16, 17, 47], ["+", 15, 15, 0, 16, 31, 16, 31, 16, 17, 20]] | 3 | 189 | 2 |
#include <stdio.h>
int n, s, count = 0, digits[10];
void dfs(int cur, int start) {
if (cur == n) {
int sum = 0;
for (int i = 0; i < n; i++) {
sum += digits[i];
}
if (sum == s) {
count++;
}
return;
}
for (int i = start; i < 10; i++) {
digits[cur] = i;
dfs(cur + 1, i + 1)... | #include <stdio.h>
int n, s, count = 0, digits[10];
void dfs(int cur, int start) {
if (cur == n) {
int sum = 0;
for (int i = 0; i < n; i++) {
sum += digits[i];
}
if (sum == s) {
count++;
}
return;
}
for (int i = start; i < 10; i++) {
digits[cur] = i;
dfs(cur + 1, i + 1)... | [["-", 0, 16, 31, 2, 3, 4, 0, 66, 28, 22], ["+", 0, 16, 31, 2, 3, 4, 0, 66, 28, 22]] | 0 | 174 | 2 |
#include <stdio.h>
int a, n, s;
void k(int sum, int c, int j) {
int i;
for (i = 1; i + j < 10; i++) {
sum += (i * c);
c--;
if (c == 0) {
if (sum == s) {
a++;
break;
}
} else
k(sum, c, i + j);
c++;
sum -= i * c;
}
}
int main() {
int i, c, sum = 0;
while... | #include <stdio.h>
int a, n, s;
void k(int sum, int c, int j) {
int i;
for (i = 1; i + j < 10; i++) {
sum += (i * c);
c--;
if (c <= 0) {
if (sum == s) {
a++;
break;
}
} else
k(sum, c, i + j);
c++;
sum -= i * c;
}
}
int main() {
int i, c, sum = 0;
while... | [["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 19], ["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]] | 0 | 195 | 4 |
#include <stdio.h>
int ans;
int solve(int i, int sum, int n, int s) {
if (sum == s && n == 0) {
ans++;
return 0;
} else if (i == 10 || n == 0) {
return 0;
} else {
solve(i + 1, sum + i, n - 1, s);
solve(i + 1, sum, n, s);
}
return 0;
}
int main() {
int n, s;
while (scanf("%... | #include <stdio.h>
int ans;
int solve(int i, int sum, int n, int s) {
if (sum == s && n == 0) {
ans++;
return 0;
} else if (i == 10 || n == 0) {
return 0;
} else {
solve(i + 1, sum + i, n - 1, s);
solve(i + 1, sum, n, s);
}
return 0;
}
int main() {
int n, s;
while (scanf("%... | [["+", 0, 52, 15, 23, 0, 16, 12, 23, 0, 24], ["-", 8, 9, 0, 52, 15, 23, 0, 16, 17, 98], ["+", 15, 23, 0, 16, 12, 23, 0, 16, 17, 106], ["+", 0, 52, 15, 23, 0, 16, 12, 23, 0, 25]] | 0 | 156 | 4 |
#include <stdio.h>
int n, s;
int rec(int sum, int dig, int cnt);
int main() {
while (1) {
scanf("%d %d", &n, &s);
if (n == 0 && s == 0)
break;
printf("%d\n", rec(0, 0, 0));
}
return 0;
}
int rec(int sum, int dig, int cnt) {
if (cnt > n || sum > s)
return 0;
if (cnt == n && sum == s)
... | #include <stdio.h>
int n, s;
int rec(int sum, int dig, int cnt);
int main() {
while (1) {
scanf("%d %d", &n, &s);
if (n == 0 && s == 0)
break;
printf("%d\n", rec(0, 0, 0));
}
return 0;
}
int rec(int sum, int dig, int cnt) {
if (cnt > n || sum > s)
return 0;
if (cnt == n && sum == s)
... | [["+", 0, 11, 12, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 11, 12, 2, 3, 4, 0, 16, 12, 13]] | 0 | 160 | 4 |
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
int f(int n, int s, int a) {
int r, i;
if (n == 1)
if (a <= s && s <= 9)
return 1;
else
return 0;
r = 0;
for (i = a; i <= 9 && i < s; i++)
r += f(n - 1, s - i, i + 1);
return r;
}
int main() {
FILE *fp = std... | #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
int f(int n, int s, int a) {
int r, i;
if (n == 1)
if (a <= s && s <= 9)
return 1;
else
return 0;
r = 0;
for (i = a; i <= 9 && i < s; i++)
r += f(n - 1, s - i, i + 1);
return r;
}
int main() {
FILE *fp = std... | [["+", 0, 52, 15, 23, 0, 16, 12, 23, 0, 24], ["-", 8, 9, 0, 52, 15, 23, 0, 16, 17, 98], ["+", 15, 23, 0, 16, 12, 23, 0, 16, 17, 106], ["+", 0, 52, 15, 23, 0, 16, 12, 23, 0, 25], ["-", 0, 52, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 52, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, ... | 0 | 149 | 8 |
#include <stdio.h>
int i, n, s;
void part(int cal, int index, int sum) {
if (index == 9 && cal == n && sum == s) {
i++;
return;
}
if (index > 9 || cal > n || sum > s)
return;
part(cal, index + 1, sum);
part(cal + 1, index + 1, sum + index);
}
main() {
while (1) {
scanf("%d %d", &n, &s);... | #include <stdio.h>
int i, n, s;
void part(int cal, int index, int sum) {
if (index == 10 && cal == n && sum == s) {
i++;
return;
}
if (index > 9 || cal > n || sum > s)
return;
part(cal, index + 1, sum);
part(cal + 1, index + 1, sum + index);
}
main() {
while (1) {
scanf("%d %d", &n, &s)... | [["-", 15, 23, 0, 16, 31, 16, 31, 16, 12, 13], ["+", 15, 23, 0, 16, 31, 16, 31, 16, 12, 13]] | 0 | 150 | 2 |
#include <stdio.h>
int count;
int sumofintegers(int N, int S, int I) {
/*printf("N%d S%d I%d\n", N, S, I);*/
if (N == 0 && S == 0)
count++;
else if (N > 0 && S >= 0 && I < 9) {
sumofintegers(N, S, I + 1);
if (S - I >= 0)
sumofintegers(N - 1, S - I, I + 1);
}
return count;
}
int main(void) {
... | #include <stdio.h>
int count;
int sumofintegers(int N, int S, int I) {
/*printf("N%d S%d I%d\n", N, S, I);*/
if (N == 0 && S == 0)
count++;
else if (N > 0 && S >= 0 && I <= 9) {
sumofintegers(N, S, I + 1);
if (S - I >= 0)
sumofintegers(N - 1, S - I, I + 1);
}
return count;
}
int main(void) {... | [["-", 0, 57, 15, 23, 0, 16, 12, 16, 17, 18], ["+", 0, 57, 15, 23, 0, 16, 12, 16, 17, 19]] | 0 | 175 | 2 |
#include <stdio.h>
int n, s, count = 0;
int digits[10];
void dfs(int cur, int start) {
if (cur == n) {
int sum = 0;
for (int i = 0; i < n; i++) {
sum += digits[i];
}
if (sum == s) {
count++;
}
return;
}
for (int i = start; i < 10; i++) {
digits[cur] = i;
dfs(cur + 1... | #include <stdio.h>
int n, s, count = 0;
int digits[10];
void dfs(int cur, int start) {
if (cur == n) {
int sum = 0;
for (int i = 0; i < n; i++) {
sum += digits[i];
}
if (sum == s) {
count++;
}
return;
}
for (int i = start; i < 10; i++) {
digits[cur] = i;
dfs(cur + 1, ... | [["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 106], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 98]] | 0 | 177 | 2 |
#include <stdio.h>
int n, s;
int sum, count, ans, data[10];
void rec(int);
void rec(int p) {
if (p > 9) {
return;
}
if (count == n) {
if (s == sum)
ans++;
return;
}
data[p] = 1;
sum += p;
count++;
rec(p + 1);
sum -= p;
count--;
data[p] = 0;
rec(p + 1);
}
main() {
while ... | #include <stdio.h>
int n, s;
int sum, count, ans, data[11];
void rec(int);
void rec(int p) {
if (p > 10) {
return;
}
if (count == n) {
if (s == sum)
ans++;
return;
}
data[p] = 1;
sum += p;
count++;
rec(p + 1);
sum -= p;
count--;
data[p] = 0;
rec(p + 1);
}
main() {
while ... | [["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13]] | 0 | 167 | 4 |
m;
f(r, n, i, t) {
for (; i++ < 9;)
t += f(r - i, n - 1, i, 0);
return n - 1 ? t : !r;
}
main(s) {
for (; scanf("%d%d", &m, &s), m; printf("%d\n", f(s, m, -1, 0)))
;
} | m;
f(r, n, i, t) {
for (; i++ < 9;)
t += f(r - i, n - 1, i, 0);
return n ? t : !r;
}
main(s) {
for (; scanf("%d%d", &m, &s), m; printf("%d\n", f(s, m, -1, 0)))
;
} | [["-", 0, 9, 0, 37, 0, 41, 15, 16, 17, 33], ["-", 0, 9, 0, 37, 0, 41, 15, 16, 12, 13]] | 0 | 95 | 2 |
#include <stdio.h>
int func(int, int, int);
int s;
int main(void) {
int n, i;
while (scanf("%d %d", &n, &s), n, s) {
printf("%d\n", func(0, 0, n));
}
return 0;
}
int func(int now, int sum, int num) {
int count = 0;
if (!num)
return s == sum ? 1 : 0;
if (now == 10 || !num || sum > s)
r... | #include <stdio.h>
int func(int, int, int);
int s;
int main(void) {
int n, i;
while (scanf("%d %d", &n, &s), n) {
printf("%d\n", func(0, 0, n));
}
return 0;
}
int func(int now, int sum, int num) {
int count = 0;
if (!num)
return s == sum ? 1 : 0;
if (now == 10 || !num || sum > s)
retu... | [["-", 0, 52, 15, 23, 0, 34, 12, 34, 0, 21], ["-", 0, 52, 15, 23, 0, 34, 12, 34, 12, 22]] | 0 | 150 | 2 |
#include <stdio.h>
void plus(int start, int end, int sum, int np, int sp);
int count;
int main() {
int i, n, s;
while (scanf("%d %d", &n, &s) != EOF) {
if (n && s)
break;
count = 0;
for (i = 0; i < 11 - n; i++) {
if (n == 1) {
if (i == s) {
count++;
break;
... | #include <stdio.h>
void plus(int start, int end, int sum, int np, int sp);
int count;
int main() {
int i, n, s;
while (scanf("%d %d", &n, &s) != EOF) {
if (!n && !s)
break;
count = 0;
for (i = 0; i < 11 - n; i++) {
if (n == 1) {
if (i == s) {
count++;
break;
... | [["+", 0, 57, 15, 23, 0, 16, 31, 91, 17, 111], ["+", 0, 57, 15, 23, 0, 16, 12, 91, 17, 111]] | 0 | 220 | 2 |
#include <stdio.h>
int cnt = 0, n, s;
void func(int sum, int depth, int x) {
int i;
if (depth > n) {
if (sum == s) {
cnt++;
}
return;
}
for (i = x; i < s; i++) {
func(sum + i, depth + 1, i + 1);
}
}
int main(void) {
while (scanf("%d %d", &n, &s), n || s) {
cnt = 0;
func(0, 1, 0... | #include <stdio.h>
int cnt = 0, n, s;
void func(int sum, int depth, int x) {
int i;
if (depth > n) {
if (sum == s) {
cnt++;
}
return;
}
for (i = x; i < 10; i++) {
// if(sum+i>s)return;
func(sum + i, depth + 1, i + 1);
}
}
int main(void) {
while (scanf("%d %d", &n, &s), n || s) {
... | [["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 13]] | 0 | 133 | 2 |
// 2019/05/02 Tazoe
#include <iostream>
using namespace std;
int cnt;
void DFS(int n, int s, int m) {
if (n == 0 && s == 0) {
cnt++;
return;
}
if (n <= 0)
return;
if (s <= 0)
return;
if (m > 9)
return;
DFS(n - 1, s - m, m + 1);
DFS(n, s, m + 1);
return;
}
int main() {
while ... | // 2019/05/02 Tazoe
#include <iostream>
using namespace std;
int cnt;
void DFS(int n, int s, int m) {
if (n == 0 && s == 0) {
cnt++;
return;
}
if (n <= 0)
return;
if (s < 0)
return;
if (m > 9)
return;
DFS(n - 1, s - m, m + 1);
DFS(n, s, m + 1);
return;
}
int main() {
while (... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]] | 1 | 150 | 2 |
#include <iostream>
using namespace std;
int n, s;
int dfs(int a, int m, int c) {
if (a == s && c == n)
return 1;
if (a >= s || c >= n)
return 0;
if (m > 9)
return 0;
int t = 0;
for (int i = m; a + i <= s && i < 10; i++) {
t += dfs(a + i, i + 1, c + 1);
}
return t;
}
int main() {
whil... | #include <iostream>
using namespace std;
int n, s;
int dfs(int a, int m, int c) {
if (a == s && c == n)
return 1;
if (a > s || c > n)
return 0;
if (m > 9)
return 0;
int t = 0;
for (int i = m; a + i <= s && i < 10; i++) {
t += dfs(a + i, i + 1, c + 1);
}
return t;
}
int main() {
while ... | [["-", 0, 57, 15, 339, 51, 16, 31, 16, 17, 20], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 47], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 20], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 47]] | 1 | 153 | 4 |
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int test(int n, int s, int i) { // n個でsを作る
// cout << n <<" "<<s<<" "<<i<<endl;
if (n == 0) {
if (s == 0) {
return 1; //作れた
} else {
r... | #define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int test(int n, int s, int i) { // n個でsを作る
// cout << n <<" "<<s<<" "<<i<<endl;
if (n == 0) {
if (s == 0) {
return 1; //作れた
} else {
r... | [["+", 0, 57, 15, 339, 51, 16, 31, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 20], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106]] | 1 | 192 | 4 |
#define _CRT_SECURE_NO_WARNINGS
#include <iomanip>
#include <iostream>
#include <list>
#include <math.h>
#include <stack>
#include <string>
using namespace std;
int n = 0;
int s = 0;
static int ans;
void check(int atai, int num, int count) {
if (num > 9) {
if (atai == s && count == n) {
ans++;
}
... | #define _CRT_SECURE_NO_WARNINGS
#include <iomanip>
#include <iostream>
#include <list>
#include <math.h>
#include <stack>
#include <string>
using namespace std;
int n = 0;
int s = 0;
static int ans;
void check(int atai, int num, int count) {
if (num > 9) {
if (atai == s && count == n) {
ans++;
}
... | [["+", 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 | 149 | 4 |
#include <cstdio>
#include <iostream>
using namespace std;
int n, s, count;
int solve(int i, int sum, int used) {
if (i == 10) {
if (s == sum && used == n) {
return count + 1;
}
return count;
}
solve(i + 1, sum + i, used + 1);
solve(i + 1, sum, used);
return count;
}
int main() {
wh... | #include <cstdio>
#include <iostream>
using namespace std;
int n, s, count;
int solve(int i, int sum, int used) {
if (i == 10) {
if (s == sum && used == n) {
count++;
}
return count;
}
solve(i + 1, sum + i, used + 1);
solve(i + 1, sum, used);
return count;
}
int main() {
while (cin >... | [["-", 64, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["-", 0, 57, 64, 9, 0, 37, 0, 16, 17, 72], ["-", 0, 57, 64, 9, 0, 37, 0, 16, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 106], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 12, 22]] | 1 | 124 | 6 |
#include <iostream>
using namespace std;
int n, s, cnt;
void dfs(int m, int num, int sum);
int main() {
while (cin >> n >> s, n && s) {
cnt = 0;
dfs(1, 0, 0);
cout << cnt << endl;
}
return 0;
}
void dfs(int m, int num, int sum) {
if (m > 9 && (num == n || num == n - 1) && sum == s)
cnt++;
if ... | #include <iostream>
using namespace std;
int n, s, cnt;
void dfs(int m, int num, int sum);
int main() {
while (cin >> n >> s, n || s) {
cnt = 0;
dfs(1, 0, 0);
cout << cnt << endl;
}
return 0;
}
void dfs(int m, int num, int sum) {
if (m > 9 && (num == n || num == n - 1) && sum == s)
cnt++;
if ... | [["-", 0, 52, 15, 339, 51, 34, 12, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 106]] | 1 | 141 | 2 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
int n, s;
vector<int> fla... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
int n, s;
vector<int> fla... | [["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]] | 1 | 208 | 2 |
#include <iostream>
#include <vector>
using namespace std;
int t;
int num[10];
void sousa(int a, int b) {
for (num[a - 1] = num[a] - 1; num[a - 1] >= 0; num[a - 1]--) {
if (a - 1 < 0 || b < 0) {
break;
} else if (a - 1 == 0 && b - num[a - 1] == 0) {
t++;
break;
} else {
sousa(a -... | #include <iostream>
#include <vector>
using namespace std;
int t;
int num[10];
void sousa(int a, int b) {
for (num[a - 1] = num[a] - 1; num[a - 1] >= 0; num[a - 1]--) {
if (a - 1 < 0 || b < 0) {
break;
} else if (a - 1 == 0 && b - num[a - 1] == 0) {
t++;
break;
} else {
sousa(a -... | [["-", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 52, 8, 9, 0, 1, 0, 11, 12, 13]] | 1 | 237 | 2 |
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>
//#define PI 3.141592653589
using namespace std;
int ans;
int n, s;
/*
iはこれまでに足し合わせた数字の数
*/
void dfs(int i, int kazu, int sum) {
if (i == n && sum == s) {
ans++;
return;
} els... | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>
//#define PI 3.141592653589
using namespace std;
int ans;
int n, s;
/*
iはこれまでに足し合わせた数字の数
*/
void dfs(int i, int kazu, int sum) {
if (i == n && sum == s) {
ans++;
return;
} els... | [["-", 75, 76, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 12, 13]] | 1 | 159 | 2 |
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
typedef long long Int;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPS(a, i, n) for (int i = a; i < n; ++i)
... | #include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
typedef long long Int;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPS(a, i, n) for (int i = a; i < n; ++i)
... | [["-", 0, 52, 15, 339, 51, 34, 12, 16, 17, 98], ["+", 0, 52, 15, 339, 51, 34, 12, 16, 17, 106]] | 1 | 174 | 2 |
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordere... | #define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordere... | [["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 12, 22]] | 1 | 253 | 2 |
#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define vvi vector<vector<int>>
#define vi vector<int>
#define All(X) X.begin... | #include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define vvi vector<vector<int>>
#define vi vector<int>
#define All(X) X.begin... | [["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 255 | 2 |
#include <algorithm>
#include <iostream>
using namespace std;
int func(int num, int rest, int before) {
// if(before + 1 < 0) return 0;
if (num == 0) {
if (rest == 0) {
// cout << before << endl;
return 1;
}
return 0;
}
int res = 0;
for (int i = 0; i <= rest && i <= before; ++i) {
... | #include <algorithm>
#include <iostream>
using namespace std;
int func(int num, int rest, int before) {
// if(before + 1 < 0) return 0;
if (num == 0) {
if (rest == 0) {
// cout << before << endl;
return 1;
}
return 0;
}
int res = 0;
for (int i = 0; i <= rest && i <= before; ++i) {
... | [["+", 0, 52, 15, 339, 51, 16, 12, 23, 0, 24], ["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 98], ["+", 15, 339, 51, 16, 12, 23, 0, 16, 17, 106], ["+", 0, 52, 15, 339, 51, 16, 12, 23, 0, 25]] | 1 | 150 | 4 |
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#includ... | #ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#includ... | [["+", 0, 57, 64, 9, 0, 37, 0, 16, 17, 98], ["+", 64, 9, 0, 37, 0, 16, 12, 16, 31, 22], ["+", 64, 9, 0, 37, 0, 16, 12, 16, 17, 19], ["+", 64, 9, 0, 37, 0, 16, 12, 16, 12, 13]] | 1 | 276 | 4 |
#include <algorithm>
#include <iostream>
#include <map>
#include <string.h>
#include <vector>
using namespace std;
int n, s;
int solve(int now, int last, int count) {
if (count == n && now == s) {
return 1;
}
if (count == n || now > s) {
return 0;
}
int co = 0;
for (int i = last + 1; i < 10; i++) ... | #include <algorithm>
#include <iostream>
#include <map>
#include <string.h>
#include <vector>
using namespace std;
int n, s;
int solve(int now, int last, int count) {
if (count == n && now == s) {
return 1;
}
if (count == n || now > s) {
return 0;
}
int co = 0;
for (int i = last + 1; i < 10; i++) ... | [["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]] | 1 | 173 | 2 |
#include <iostream>
#define N 9
using namespace std;
int solver(int n, int s,
int t) { // t??\????????°n?????§s?????????????????????????????°
if (n == 0 || s < 0 || t > N)
return 0;
if (n == 1 && s == t)
return 1;
return solver(n - 1, s - t, t + 1) + solver(n, s, t + 1);
}
int main() {
int n,... | #include <iostream>
#define N 9
using namespace std;
int solver(int n, int s,
int t) { // t??\????????°n?????§s?????????????????????????????°
if (n == 0 || s < 0 || t > N)
return 0;
if (n == 1 && s == t)
return 1;
return solver(n - 1, s - t, t + 1) + solver(n, s, t + 1);
}
int main() {
int n,... | [["+", 0, 52, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 52, 8, 9, 0, 1, 0, 16, 12, 22]] | 1 | 118 | 2 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, l, n) for (lint i = l; i < n; i++)
#define rer(i, l, n) for (lint i = l; i <= n; i++)
#define alint(a) a.begin(), a.end()
#define o(a) cout << a... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, l, n) for (lint i = l; i < n; i++)
#define rer(i, l, n) for (lint i = l; i <= n; i++)
#define alint(a) a.begin(), a.end()
#define o(a) cout << a... | [["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 228 | 2 |
#include <bits/stdc++.h>
using namespace std;
int dfs(int n, int s, int i) {
if (n == 0) {
if (s == 0)
return 1;
else
return 0;
}
if (s <= 0)
return 0;
if (i > 9)
return 0;
return dfs(n, s, i + 1) + dfs(n - 1, s - i, i + 1);
}
int main() {
int n, s;
while (cin >> n >> s, n ... | #include <bits/stdc++.h>
using namespace std;
int dfs(int n, int s, int i) {
if (n == 0) {
if (s == 0)
return 1;
else
return 0;
}
if (s - i < 0)
return 0;
if (i > 9)
return 0;
return dfs(n, s, i + 1) + dfs(n - 1, s - i, i + 1);
}
int main() {
int n, s;
while (cin >> n >> s,... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 17, 33], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18]] | 1 | 124 | 4 |
#include <iostream>
using namespace std;
int n, s;
int dfs(int i, int sum, int N) {
if (N == 0 && sum == 0)
return 1; // yes
if (N == 0 || i == 10)
return 0; // no
return dfs(i + 1, sum, N) + dfs(i + 1, sum - i, N - 1);
}
int main() {
while (cin >> n >> s, s) {
cout << dfs(0, s, n) << endl;
... | #include <iostream>
using namespace std;
int n, s;
int dfs(int i, int sum, int N) {
if (N == 0 && sum == 0)
return 1; // yes
if (N == 0 || i == 10)
return 0; // no
return dfs(i + 1, sum, N) + dfs(i + 1, sum - i, N - 1);
}
int main() {
while (cin >> n >> s, n) {
cout << dfs(0, s, n) << endl;
... | [["-", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22], ["+", 8, 9, 0, 52, 15, 339, 51, 34, 12, 22]] | 1 | 114 | 16 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
long long int fie[110][11][1100];
int main() {
while (1) {
memset(fie, 0, sizeof(fie));
int N, S;
cin >> N >> S;
if (N == 0 && S == 0)
break;
fie[1][0][0] = 1;
fie[1][1][1]... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
long long int fie[110][11][1100];
int main() {
while (1) {
memset(fie, 0, sizeof(fie));
int N, S;
cin >> N >> S;
if (N == 0 && S == 0)
break;
fie[1][0][0] = 1;
fie[1][1][1]... | [["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 31, 69, 28, 69, 28, 69, 341, 342, 0, 13], ["+", 31, 69, 28, 69, 28, 69, 341, 342, 0, 13], ["-", 12, 69, 28, 69, 28, 69, 341, 342, 0, 13], ["+", 12, 69, 28, 69, 28, 69, 341, 342, 0, 13]] | 1 | 234 | 6 |
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
/*
0 1 ... | #define _USE_MATH_DEFINES
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int a, ... | [["-", 36, 36, 0, 30, 0, 43, 49, 50, 0, 32], ["-", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["+", 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 | 175 | 6 |
#include <iostream>
using namespace std;
int ans = 0;
void dfs(int n, int s, int d) {
if (s < 0)
return;
if (s == 0 and n == 0) {
ans++;
return;
}
if (n == 0)
return;
d++;
if (d == 10)
return;
// cout << "n=" << n;
// cout << " s=" << s;
// cout << " d=" << d << endl;
//??????... | #include <iostream>
using namespace std;
int ans = 0;
void dfs(int n, int s, int d) {
if (s < 0)
return;
if (s == 0 and n == 0) {
ans++;
return;
}
if (n == 0)
return;
d++;
if (d == 10)
return;
//???????????´???
dfs(n - 1, s - d, d);
//?????°????????£?????´???
dfs(n, s, d);
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 | 154 | 4 |
#include <bits/stdc++.h>
using namespace std;
int dfs(int x, int y, int k) {
if (y == 0)
return x == 0 ? 1 : 0;
if (x < 0)
return 0;
int ans = 0;
for (int i = k + 1; i < 10; i++)
ans += dfs(x - i, y - 1, i);
return ans;
}
signed main(void) {
ios::sync_with_stdio(false);
int x, y;
while (cin ... | #include <bits/stdc++.h>
using namespace std;
int dfs(int x, int y, int k) {
if (y == 0)
return x == 0 ? 1 : 0;
if (x < 0)
return 0;
int ans = 0;
for (int i = k + 1; i < 10; i++)
ans += dfs(x - i, y - 1, i);
return ans;
}
signed main(void) {
ios::sync_with_stdio(false);
int x, y;
while (cin ... | [["+", 8, 9, 0, 52, 8, 1, 0, 16, 17, 151], ["+", 8, 9, 0, 52, 8, 1, 0, 16, 12, 22]] | 1 | 127 | 2 |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int A[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int cunt = 0;
void depth(int n, int s, int i) {
if (n == 0 && s == 0) {
cunt++;
return;
} else if ... | #include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int A[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
int cunt = 0;
void depth(int n, int s, int i) {
if (n == 0 && s == 0) {
cunt++;
return;
} else if ... | [["-", 75, 76, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 75, 76, 0, 57, 15, 339, 51, 16, 17, 18], ["-", 0, 1, 0, 2, 3, 4, 0, 27, 17, 29], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]] | 1 | 193 | 8 |
#include <iostream>
using namespace std;
int n, s, ans;
void solve(int v, int sum, int num) {
if (sum == s && num == n) {
ans++;
return;
}
if (v >= 10 || sum >= s)
return;
solve(v + 1, sum + v, num + 1);
solve(v + 1, sum, num);
}
int main() {
while (1) {
cin >> n >> s;
if (n == 0 && ... | #include <iostream>
using namespace std;
int n, s, ans;
void solve(int v, int sum, int num) {
if (sum == s && num == n) {
ans++;
return;
}
if (v >= 10 || num >= n)
return;
solve(v + 1, sum + v, num + 1);
solve(v + 1, sum, num);
}
int main() {
while (1) {
cin >> n >> s;
if (n == 0 && ... | [["-", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 22]] | 1 | 134 | 4 |
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define shosu(x) fixed << setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi... | #include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define shosu(x) fixed << setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi... | [["-", 15, 339, 51, 16, 31, 16, 12, 16, 17, 19], ["+", 15, 339, 51, 16, 31, 16, 12, 16, 17, 18]] | 1 | 230 | 2 |
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
int c = 0;
string s, large = "", max;
map<string, int> wordbox;
while (cin >> s) {
wordbox[s]++;
if (s.length() > large.length())
large = s;
}
map<string, int>::iterator it = wordbox.begin();
while (it != ... | #include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
int c = 0;
string s, large = "", max;
map<string, int> wordbox;
while (cin >> s) {
wordbox[s]++;
if (s.length() > large.length())
large = s;
}
map<string, int>::iterator it = wordbox.begin();
while (it != ... | [["-", 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 | 146 | 4 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
map<string, int> count;
int m = 0;
string first;
string second("");
while (!cin.eof()) {
str... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
int main() {
map<string, int> count;
int m = 0;
string first;
string second("");
while (!cin.eof()) {
str... | [["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]] | 1 | 164 | 4 |
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
string s, max("");
map<string, int> w;
map<int, string> x;
while (cin >> s) {
if (s.size() > max.size())
max = s;
w[s]++;
}
for (map<string, int>::iterator it = w.begin(); it != w.end(); it++)
x[(*it... | #include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
string s, max("");
map<string, int> w;
map<int, string> x;
while (cin >> s) {
if (s.size() > max.size())
max = s;
w[s]++;
}
for (map<string, int>::iterator it = w.begin(); it != w.end(); it++)
x[(*it... | [["-", 31, 16, 31, 16, 12, 61, 0, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 144 | 3 |
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
string str, s, mls, mcs, input[32];
map<string, int> dic;
int n, c, a, ml, mc;
getline(cin, str);
c = a = mc = ml = 0;
str += ' ';
while (str.length()) {
n = str.find(' ');
s = str[c];
++c;
for (; c < n;... | #include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
string str, s, mls, mcs, input[100];
map<string, int> dic;
int n, c, a, ml, mc;
getline(cin, str);
c = a = mc = ml = 0;
str += ' ';
while (str.length()) {
n = str.find(' ');
s = str[c];
++c;
for (; c < n... | [["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 7, 8, 9, 0, 46]] | 1 | 239 | 4 |
#include <iostream>
#include <map>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
string sp, st, hw, ew;
map<string, int> sd;
int s = 0, e = 0, k = 0, h = 0, m = 0;
getline(cin, st);
st = st + " ";
while (e != st.size()) {
for (e; st[e] != ' '; e++)
;
sp.append(st, s,... | #include <iostream>
#include <map>
#include <stdio.h>
#include <string>
using namespace std;
int main() {
string sp, st, hw, ew;
map<string, int> sd;
int s = 0, e = 0, k = 0, h = 0, m = 0;
getline(cin, st);
st = st + " ";
while (e != st.size()) {
for (e; st[e] != ' '; e++)
;
sp.append(st, s,... | [["-", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 285 | 4 |
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
string s;
map<string, int> m;
map<string, int> m2;
int maxlen = -1;
pair<string, int> max_pair;
pair<string, int> max2_pair;
while (cin >> s) {
if (m.count(s) == 0) {
m.insert(pair<strin... | #include <algorithm>
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
string s;
map<string, int> m;
map<string, int> m2;
int maxlen = -1;
pair<string, int> max_pair;
pair<string, int> max2_pair;
while (cin >> s) {
if (m.count(s) == 0) {
m.insert(pair<strin... | [["-", 0, 1, 0, 16, 31, 16, 31, 16, 12, 22], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6]] | 1 | 228 | 4 |
strings = gets.split(" ")
hash = Hash.new(0)
longest_size = strings.max_by{ |(elm1)| elm1.length}
strings.each {|e| hash[e] += 1}
freq_num = hash.max_by{|_,len_i| len_i }[1]
puts "#{freq_num} #{longest_size}"
| strings = gets.split(" ")
hash = Hash.new(0)
longest_size = strings.max_by{ |(elm1)| elm1.length}
strings.each {|e| hash[e] += 1}
freq_num = hash.max_by{|_,len_i| len_i }[0]
puts "#{freq_num} #{longest_size}"
| [["-", 36, 36, 0, 493, 0, 662, 12, 742, 0, 612], ["+", 36, 36, 0, 493, 0, 662, 12, 742, 0, 612]] | 4 | 73 | 2 |
words = gets.split.group_by{|i| i}
puts "#{words.max_by{|k,v| v}.first} #{words.keys.max_by{|i| i.size}}" | words = gets.split.group_by{|i| i}
puts "#{words.max_by{|k,v| v.size}.first} #{words.keys.max_by{|i| i.size}}" | [["+", 486, 652, 196, 196, 8, 734, 0, 652, 17, 131], ["+", 486, 652, 196, 196, 8, 734, 0, 652, 735, 22]] | 4 | 47 | 2 |
count = Hash.new(0)
longest = ''
$<.each_line do |line|
line.split.each do |word|
count[word] += 1
longest = word if longest.size < word.size
end
end
puts count.max_by(&:last).first
puts longest | count = Hash.new(0)
longest = ''
$<.each_line do |line|
line.split.each do |word|
count[word] += 1
longest = word if longest.size < word.size
end
end
puts count.max_by(&:last).first + ' ' << longest | [["-", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["+", 0, 652, 3, 4, 0, 738, 31, 738, 17, 72], ["+", 3, 4, 0, 738, 31, 738, 12, 557, 0, 62], ["+", 3, 4, 0, 738, 31, 738, 12, 557, 0, 6], ["+", 0, 493, 0, 652, 3, 4, 0, 738, 17, 151]] | 4 | 59 | 6 |
while True:
try:
ls = input().split()
dic = {}
for word in ls:
dic[word] = dic.get(word,0) + 1
max1 = sorted(list(dic.items()), key=lambda x:x[1], reverse=True)
max2 = ""
for i in ls:
if len(max2) < i:
max2 = i
print(max1[0][0] + " " + max2)
except:
exit() |
while True:
try:
ls = input().split()
dic = {}
for word in ls:
dic[word] = dic.get(word,0) + 1
max1 = sorted(list(dic.items()), key=lambda x:x[1], reverse=True)
max2 = ""
for i in ls:
if len(max2) < len(i):
max2 = i
print(max1[0][0] + " " + max2)
except:
exit() | [["+", 8, 196, 0, 57, 15, 666, 0, 652, 63, 22], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25]] | 5 | 106 | 3 |
import sys
import math
from collections import Counter
l = input().split()
print(l)
c = Counter()
for i in l:
c[i] += 1
cc = c.most_common(1)
ans = l[0]
for i in range(len(l)):
if len(l[i]) > len(ans):
ans = l[i]
print("{0} {1}".format(cc[0][0], ans)) | import sys
import math
from collections import Counter
l = input().split()
c = Counter()
for i in l:
c[i] += 1
cc = c.most_common(1)
ans = l[0]
for i in range(len(l)):
if len(l[i]) > len(ans):
ans = l[i]
print("{0} {1}".format(cc[0][0], ans)) | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 101 | 4 |
S = input().split()
maxi = 0
for s in S:
length = len(s)
if (length > maxi):
maxi = length
maxs = s
S.sort()
i = 0
maxm = 0
mode = 0
while (i < len(S) - 1):
cnt = 1
while True:
if (S[i] == S[i + 1]):
i += 1
cnt += 1
if (i >= len(S) - 1):
... | S = input().split()
maxi = 0
for s in S:
length = len(s)
if (length > maxi):
maxi = length
maxs = s
S.sort()
i = 0
maxm = 0
mode = 0
while (i < len(S) - 1):
cnt = 1
while True:
if (S[i] == S[i + 1]):
i += 1
cnt += 1
if (i >= len(S) - 1):
... | [["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 21], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 21], ["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22]] | 5 | 130 | 4 |
targ = input().split(' ')
mostfre = {}
ansfre = ""
longest = [0,""]
for t in targ:
if len(t) > longest[0]:
longest[0],longest[1] = len(t),t
mostfre[t] = mostfre.get(t,0) + 1
temp = 0
print(mostfre)
for k,v in mostfre.items():
if v > temp:
temp = v
ansfre = k
print(ansfre + ' ' + long... | targ = input().split(' ')
mostfre = {}
ansfre = ""
longest = [0,""]
for t in targ:
if len(t) > longest[0]:
longest[0],longest[1] = len(t),t
mostfre[t] = mostfre.get(t,0) + 1
temp = 0
for k,v in mostfre.items():
if v > temp:
temp = v
ansfre = k
print(ansfre + ' ' + longest[1]) | [["-", 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 | 117 | 4 |
s = list(input().split())
maxLen = 0
maxNum = 0
dic = {}
for word in s:
if not (word in dic):
dic[word] = 1
else:
dic[word] += 1
if maxNum < dic[word]:
maxNum = dic[word]
ansNum = word
if maxLen < len(word):
maxLen = len(word)
ansLen = word
print(ansNum, a... | s = list(input().split())
maxLen = 0
maxNum = 0
dic = {}
for word in s:
if not (word in dic):
dic[word] = 1
else:
dic[word] += 1
if maxNum < dic[word]:
maxNum = dic[word]
ansNum = word
if maxLen < len(word):
maxLen = len(word)
ansLen = word
print(ansNum, a... | [["-", 36, 36, 0, 656, 0, 1, 0, 652, 63, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 0, 656, 0, 1, 0, 652, 3, 4, 0, 25]] | 5 | 93 | 4 |
dic={}
for word in input().split():
if word not in dic:
dic[word]=0
dic[word]+=1
print(max(iter(dic.keys()),key=lambda k:dic[k]))
print(max(iter(dic.keys()),key= lambda k:len(k))) | dic={}
for word in input().split():
if word not in dic:
dic[word]=0
dic[word]+=1
print(max(iter(dic.keys()),key=lambda k:dic[k]), end=' ')
print(max(iter(dic.keys()),key= lambda k:len(k))) | [["+", 0, 656, 0, 1, 0, 652, 3, 4, 0, 21], ["+", 0, 1, 0, 652, 3, 4, 0, 653, 141, 22], ["+", 0, 1, 0, 652, 3, 4, 0, 653, 0, 32], ["+", 0, 652, 3, 4, 0, 653, 51, 557, 0, 654], ["+", 0, 652, 3, 4, 0, 653, 51, 557, 0, 6], ["+", 0, 652, 3, 4, 0, 653, 51, 557, 0, 655]] | 5 | 81 | 6 |
word_d={}
for word in input().split():
word_d[word]=word_d.get(word,0)+1
print(max(iter(word_d.keys()), key=lambda i: [i]),max(iter(word_d.keys()),key=lambda i:len(i))) | word_d={}
for word in input().split():
word_d[word]=word_d.get(word,0)+1
print(max(iter(word_d.keys()), key=lambda i: word_d[i]),max(iter(word_d.keys()),key=lambda i:len(i))) | [["+", 3, 4, 0, 653, 51, 670, 8, 206, 51, 22]] | 5 | 75 | 1 |
dic={}
s=input().lower().split()
print(s)
for word in s:
try:
dic[word]+=1
except:
dic[word]=1
m=0
l=0
for word, e in list(dic.items()):
if e>m:
m=e
w1=word
if len(word)>l:
l=len(word)
w2=word
print(w1, w2) | dic={}
s=input().lower().split()
for word in s:
try:
dic[word]+=1
except:
dic[word]=1
m=0
l=0
for word, e in list(dic.items()):
if e>m:
m=e
w1=word
if len(word)>l:
l=len(word)
w2=word
print(w1, w2) | [["-", 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 | 96 | 4 |
data = input().strip().split()
stat = {}
for w in data:
if w in stat:
stat[w][0] += 1
else:
stat[w] = [1, len(w)]
count_list = sorted(list(stat.items()), key=lambda x: x[1][0], reverse=True)
length_list = sorted(list(stat.items()), key=lambda x: x[1][1], reverse=True)
print(count_list[0][0])... | data = input().strip().split()
stat = {}
for w in data:
if w in stat:
stat[w][0] += 1
else:
stat[w] = [1, len(w)]
count_list = sorted(list(stat.items()), key=lambda x: x[1][0], reverse=True)
length_list = sorted(list(stat.items()), key=lambda x: x[1][1], reverse=True)
print(count_list[0][0] ... | [["-", 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], ["+", 0, 652, 3, 4, 0, 657, 31, 657, 17, 72], ["+", 3, 4, 0, 657, 31, 657, 12, 557, 0, 654], ["+", 3, 4, 0, 657, 31, 657, 12, 557, 0, 6], ["+", 3, 4, 0, 657, 31, 657, 12, 557, 0, 655], ["+",... | 5 | 131 | 8 |
(function(input) {
var p = input.replace(/\n$/, '').split('\n');
while (true) {
var a = p.shift().split(' ').map(Number);
var n = a.shift();
var s = a.shift();
if (n === 0 && s === 0) {
return;
}
console.log(count(n, s));
}
})(require('fs').readFileSync('/dev/stdin', 'utf8'));
function count(n, s) { re... | (function(input) {
var p = input.replace(/\n$/, '').split('\n');
while (true) {
var a = p.shift().split(' ').map(Number);
var n = a.shift();
var s = a.shift();
if (n === 0 && s === 0) {
return;
}
console.log(count(n, s));
}
})(require('fs').readFileSync('/dev/stdin', 'utf8'));
function count(n, s) { re... | [["-", 0, 7, 8, 556, 0, 1, 0, 11, 31, 22], ["+", 8, 556, 0, 7, 8, 556, 0, 198, 0, 217], ["+", 0, 7, 8, 556, 0, 198, 0, 200, 141, 22], ["-", 64, 556, 0, 57, 15, 23, 0, 16, 31, 22], ["+", 64, 556, 0, 57, 15, 23, 0, 16, 31, 22], ["-", 0, 1, 0, 564, 12, 2, 3, 3, 0, 22], ["+", 0, 1, 0, 564, 12, 2, 3, 3, 0, 22]] | 2 | 218 | 7 |
var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) { input += chunk; });
process.stdin.on('end', function() { main(input) });
function main(input) {
var args = input.trim().split('\n');
for (var i = 0; i < args.length; i += 1) {
var set = args[i... | var input = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) { input += chunk; });
process.stdin.on('end', function() { main(input) });
function main(input) {
var args = input.trim().split('\n');
for (var i = 0; i < args.length; i += 1) {
var set = args[i... | [["-", 0, 37, 0, 2, 3, 3, 0, 16, 17, 33], ["-", 0, 37, 0, 2, 3, 3, 0, 16, 12, 555]] | 2 | 274 | 2 |
<?php
while (TRUE) {
fscanf(STDIN, '%d %d', $n, $s);
if ($n === 0 && $s === 0) {
break;
}
$stack = array(0, 0, -1);
$c = 0;
while (count($stack)) {
$node = array_pop($stack);
if ($node[1] === $n) {
if ($node[0] === $s) {
$c++;
}
... | <?php
while (TRUE) {
fscanf(STDIN, '%d %d', $n, $s);
if ($n === 0 && $s === 0) {
break;
}
$stack = array(array(0, 0, -1));
$c = 0;
while (count($stack)) {
$node = array_pop($stack);
if ($node[1] === $n) {
if ($node[0] === $s) {
$c++;
... | [["+", 0, 11, 12, 227, 0, 618, 0, 227, 0, 516], ["+", 0, 11, 12, 227, 0, 618, 0, 227, 0, 24], ["+", 0, 11, 12, 227, 0, 618, 0, 227, 0, 25]] | 6 | 165 | 3 |
import sys
from itertools import combinations as c
for line in sys.stdin:
count = 0
k, v = map(int, line.split())
if k and v:
for i in c(range(10), k):
if sum(i) == v:
count += 1
else:
break
print(count) | import sys
from itertools import combinations as c
for line in sys.stdin:
count = 0
k, v = map(int, line.split())
if k or v:
for i in c(range(10), k):
if sum(i) == v:
count += 1
else:
break
print(count) | [["-", 0, 7, 8, 196, 0, 57, 15, 679, 17, 355], ["+", 0, 7, 8, 196, 0, 57, 15, 679, 17, 354]] | 5 | 68 | 2 |
def calc_combination(n, s, max_digit):
if n == 1:
if max_digit > s:
return 0
else:
return 1
if n * (n - 1) / 2 > s:
return 0
total = 0
max_digit = min(s, max_digit)
for i in range(n-1, max_digit):
total += calc_combination(n-1, s-i, max_digit-1... | def calc_combination(n, s, max_digit):
if n == 1:
if max_digit < s:
return 0
else:
return 1
if n * (n - 1) / 2 > s:
return 0
total = 0
max_digit = min(s, max_digit)
for i in range(n-1, max_digit+1):
total += calc_combination(n-1, s-i, i-1)
... | [["-", 0, 57, 64, 196, 0, 57, 15, 666, 667, 47], ["+", 0, 57, 64, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 17, 72], ["+", 0, 7, 12, 652, 3, 4, 0, 657, 12, 612], ["-", 0, 677, 12, 652, 3, 4, 0, 657, 31, 22], ["+", 0, 677, 12, 652, 3, 4, 0, 657, 31, 22]] | 5 | 120 | 6 |
from itertools import combinations
while 1:
n,s=map(int,input().split())
if n+x==0:break
print(sum(1 for p in combinations(range(10),n)if sum(p)==s))
| from itertools import combinations
while 1:
n,s=map(int,input().split())
if n==0:break
print(sum(1 for p in combinations(range(10),n)if sum(p)==s))
| [["-", 8, 196, 0, 57, 15, 666, 0, 657, 17, 72], ["-", 8, 196, 0, 57, 15, 666, 0, 657, 12, 22]] | 5 | 57 | 8 |
import sys
import itertools
def solve(x,n,s):
t=[c for c in itertools.combinations(x,n) if sum(c)==s]
return len(t)
x=[i for i in range(10)]
for line in sys.stdin.readlines():
n,s=list(map(int, line.rstrip().split()))
if s==0: break
print(solve(x,n,s)) | import sys
import itertools
def solve(x,n,s):
t=[c for c in itertools.combinations(x,n) if sum(c)==s]
return len(t)
x=[i for i in range(10)]
for line in sys.stdin.readlines():
n,s=list(map(int, line.rstrip().split()))
if s|n==0: break
print(solve(x,n,s)) | [["+", 8, 196, 0, 57, 15, 666, 0, 657, 17, 139], ["+", 8, 196, 0, 57, 15, 666, 0, 657, 12, 22]] | 5 | 103 | 2 |
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from sys import stdin
from itertools import combinations
for line in stdin:
if line.startswith('0 0'):
break
num, ans = (int(s) for s in line.split())
print(sum(sum(t) == ans for t in combin... | from __future__ import (absolute_import, division, print_function,
unicode_literals)
from sys import stdin
from itertools import combinations
for line in stdin:
if line.startswith('0 0'):
break
num, ans = (int(s) for s in line.split())
print(sum(sum(t) == ans for t in combin... | [["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 612], ["+", 12, 652, 3, 4, 0, 652, 3, 4, 0, 612]] | 5 | 78 | 2 |
# -*- coding: utf-8 -*-
import sys
n = 0
s = 0
def combination(n, k):
max = 2 ** n
for i in range(max):
result = [0] * n
for j in range(n):
result[j] = i >> j & 1
cnt = 0
for b in result:
if b == 1:
cnt += 1
if cnt == k:
... | # -*- coding: utf-8 -*-
import sys
n = 0
s = 0
def combination(n, k):
max = 2 ** n
for i in range(max):
result = [0] * n
for j in range(n):
result[j] = i >> j & 1
cnt = 0
for b in result:
if b == 1:
cnt += 1
if cnt == k:
... | [["-", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612]] | 5 | 176 | 2 |
def dfs(n, m, s):
if n == N:
return 1 if s == S else 0
ans = 0
for i in range(m, 11 - n):
ans += dfs(n + 1, i + 1, s + i)
return ans;
while True:
N, S = list(map(int, input().split()))
if not N:
break
print(dfs(0, 0, 0)) |
def dfs(n, m, s):
if n == N:
return 1 if s == S else 0
ans = 0
for i in range(m, 10):
ans += dfs(n + 1, i + 1, s + i)
return ans;
while True:
N, S = list(map(int, input().split()))
if not N:
break
print(dfs(0, 0, 0)) | [["-", 0, 7, 12, 652, 3, 4, 0, 657, 31, 612], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 17, 33], ["-", 0, 7, 12, 652, 3, 4, 0, 657, 12, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 612]] | 5 | 95 | 4 |
def f(mn, n, sm):
if n == 0 and sm == 0:
return 1
if mn == 10 or n == 0 or sm == 0:
return 0
ct = 0
for i in range(mn, min(10, sm + 1)):
ct += f(i + 1, n - 1, sm - i)
return ct
while True:
n, sm = list(map(int, input().split()))
if n == 0 and sm == 0:
break
... | def f(mn, n, sm):
if n == 0 and sm == 0:
return 1
if mn == 10 or n == 0:
return 0
ct = 0
for i in range(mn, min(10, sm + 1)):
ct += f(i + 1, n - 1, sm - i)
return ct
while True:
n, sm = list(map(int, input().split()))
if n == 0 and sm == 0:
break
print(f(... | [["-", 0, 14, 8, 196, 0, 57, 15, 679, 17, 354], ["-", 8, 196, 0, 57, 15, 679, 12, 666, 0, 22], ["-", 8, 196, 0, 57, 15, 679, 12, 666, 667, 60], ["-", 8, 196, 0, 57, 15, 679, 12, 666, 0, 612]] | 5 | 117 | 4 |
def count(target, max_size, c_size, c_num, sum):
if max_size == c_size:
return 1 if sum == target else 0
ans = 0
for i in range(c_num, 10):
ans += count(target, max_size, c_size+1, i+1, sum+i)
return ans
import sys
for s in sys.stdin:
max_size, target = list(map(int, s.split()))
if target == 0 or ... | def count(target, max_size, c_size, c_num, sum):
if max_size == c_size:
return 1 if sum == target else 0
ans = 0
for i in range(c_num, 10):
ans += count(target, max_size, c_size+1, i+1, sum+i)
return ans
import sys
for s in sys.stdin:
max_size, target = list(map(int, s.split()))
if target == 0 and... | [["-", 0, 7, 8, 196, 0, 57, 15, 679, 17, 354], ["+", 0, 7, 8, 196, 0, 57, 15, 679, 17, 355]] | 5 | 116 | 2 |
require("fs").readFileSync("/dev/stdin", "utf8").split('\n').map(function(i) {
for (a = [], j = 0; j < 9; j++)
if ((n = 1 << j) & i)
a.push(n);
if (a[0])
console.log(a.join(' '))
}) | require("fs").readFileSync("/dev/stdin", "utf8").split('\n').map(function(i) {
for (a = [], j = 0; j <= 9; j++)
if ((n = 1 << j) & i)
a.push(n);
if (a[0])
console.log(a.join(' '))
}) | [["-", 8, 556, 0, 7, 15, 1, 0, 16, 17, 18], ["+", 8, 556, 0, 7, 15, 1, 0, 16, 17, 19]] | 2 | 91 | 13 |
var g = [ 1, 2, 4, 8, 16, 32, 64, 128, 512 ];
process.stdin
.on("data",
function(c) {
(c + "").trim().split("\n").some(function(n) {
var a = [], l = 10;
while (l--) {
(n >= g[l]) && (n -= g[l], a.unshift(g[l]));
}
console.log(a.join(" "... | var g = [ 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 ];
process.stdin
.on("data",
function(c) {
(c + "").trim().split("\n").some(function(n) {
var a = [], l = 10;
while (l--) {
(n >= g[l]) && (n -= g[l], a.unshift(g[l]));
}
console.log(a.joi... | [["+", 0, 493, 0, 198, 0, 200, 51, 516, 0, 555], ["+", 0, 493, 0, 198, 0, 200, 51, 516, 0, 21]] | 2 | 132 | 2 |
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
import java.util.stream.IntStream;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] weight =
IntStream.rangeClosed(1, 10).map(e -> (int)Math.pow(2, e)).toArray();
while (... | import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
import java.util.stream.IntStream;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] weight =
IntStream.range(0, 10).map(e -> (int)Math.pow(2, e)).toArray();
while (sc.has... | [["-", 49, 200, 51, 492, 500, 492, 500, 492, 141, 22], ["+", 49, 200, 51, 492, 500, 492, 500, 492, 141, 22], ["-", 51, 492, 500, 492, 500, 492, 3, 4, 0, 499], ["+", 51, 492, 500, 492, 500, 492, 3, 4, 0, 499]] | 3 | 221 | 4 |
import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String t;
int w, f;
while ((t = bf.readLine()) != null) {
w = Integer.parseInt(t);
f = 0;
for (int i = 0; i < 9; ... | import java.io.*;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String t;
int w, f;
while ((t = bf.readLine()) != null) {
w = Integer.parseInt(t);
f = 0;
for (int i = 0; i < 10;... | [["-", 0, 52, 8, 196, 0, 7, 15, 16, 12, 499], ["+", 0, 52, 8, 196, 0, 7, 15, 16, 12, 499]] | 3 | 151 | 2 |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
while (s.hasNext()) {
boolean flag[] = new boolean[10];
int in = s.nextInt();
int a = 1024;
int n = 0;
for (int i = 9; i >= 0; i--) {
a /= 2;
... | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
while (s.hasNext()) {
boolean flag[] = new boolean[10];
int in = s.nextInt();
int a = 1024;
int n = 0;
for (int i = 9; i >= 0; i--) {
a /= 2;
... | [["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 45], ["+", 0, 7, 8, 196, 0, 57, 64, 196, 0, 46]] | 3 | 188 | 2 |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
while (stdIn.hasNext()) {
boolean[] answerWeight = {false, false, false, false, false,
false, false, false, false};
int questionWeight = ... | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
while (stdIn.hasNext()) {
boolean[] answerWeight = {false, false, false, false, false,
false, false, false, false, false};
int questionWe... | [["+", 8, 196, 0, 503, 49, 200, 51, 518, 0, 21], ["+", 8, 196, 0, 503, 49, 200, 51, 518, 0, 147]] | 3 | 380 | 2 |
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while (scan.hasNext()) {
int n = scan.nextInt();
int count = 0;
int[] w = new int[10];
do {
w[count] = n % 2;
n /= 2;
count++;
} while (n... | import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while (scan.hasNext()) {
int n = scan.nextInt();
int count = 0;
int[] w = new int[10];
do {
w[count] = n % 2;
n /= 2;
count++;
} while (n... | [["-", 0, 52, 8, 196, 0, 7, 15, 16, 12, 499], ["+", 0, 52, 8, 196, 0, 7, 15, 16, 12, 22], ["-", 64, 196, 0, 57, 15, 15, 0, 16, 12, 499], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 17, 33], ["+", 0, 57, 15, 15, 0, 16, 12, 16, 12, 499]] | 3 | 175 | 6 |
import java.util.*;
public class Main {
static int Sum(List<Integer> a) {
int result = 0;
for (int i = 0; i < a.size(); i++)
result += a.get(i);
return result;
}
static void print(List<Integer> a) {
Collections.sort(a);
for (int i = 0; i < a.size() - 1; i++) {
System.out.print(a.ge... | import java.util.*;
public class Main {
static int Sum(List<Integer> a) {
int result = 0;
for (int i = 0; i < a.size(); i++)
result += a.get(i);
return result;
}
static void print(List<Integer> a) {
Collections.sort(a);
for (int i = 0; i < a.size() - 1; i++) {
System.out.print(a.ge... | [["-", 0, 195, 8, 196, 0, 1, 0, 492, 141, 22], ["+", 0, 195, 8, 196, 0, 1, 0, 492, 141, 22]] | 3 | 258 | 2 |
#include <stdio.h>
int main() {
int i, j, n;
while (scanf("%d", &n) != EOF) {
for (j = 0; j < 10; j++) {
if (n & 1 << j) {
printf("%d", 1 << j);
break;
}
}
for (i = j; i < 10; i++) {
if (n & 1 << i)
printf(" %d", 1 << i);
}
printf("\n");
}
return 0;
... | #include <stdio.h>
int main() {
int i, j, n;
while (scanf("%d", &n) != EOF) {
for (j = 0; j < 10; j++) {
if (n & 1 << j) {
printf("%d", 1 << j);
break;
}
}
for (i = j + 1; i < 10; i++) {
if (n & 1 << i)
printf(" %d", 1 << i);
}
printf("\n");
}
return... | [["+", 8, 9, 0, 7, 10, 11, 12, 16, 17, 72], ["+", 8, 9, 0, 7, 10, 11, 12, 16, 12, 13]] | 0 | 113 | 2 |
#include <stdio.h>
int main() {
int w, i;
int m[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512}, u[10];
while (scanf("%d", &w) != EOF) {
for (i = 0; i < 9; i++)
u[i] = 0;
for (i = 9; i >= 0; i--)
if (w >= m[i]) {
w -= m[i];
u[i] = 1;
}
for (i = 0, w = 0; i < 9; i++)... | #include <stdio.h>
int main() {
int w, i;
int m[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512}, u[10];
while (scanf("%d", &w) != EOF) {
for (i = 0; i < 9; i++)
u[i] = 0;
for (i = 9; i >= 0; i--)
if (w >= m[i]) {
w -= m[i];
u[i] = 1;
}
for (i = 0, w = 0; i < 10; i++... | [["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]] | 0 | 189 | 2 |
#include <stdio.h>
int map[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
int main(void) {
int num, i, o, line[10];
for (; o = 0, scanf("%d", &num) != EOF;) {
for (i = 9; i >= 0; i--) {
if (num / map[i]) {
line[o++] = map[i];
num -= map[i];
}
}
for (i = o - 1; i >= 0; i--)
... | #include <stdio.h>
int map[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
int main(void) {
int num, i, o, line[10];
for (; o = 0, scanf("%d", &num) != EOF;) {
for (i = 9; i >= 0; i--) {
if (num / map[i]) {
line[o++] = map[i];
num -= map[i];
}
}
for (i = o - 1; i >= 0; i--)
... | [["+", 0, 2, 3, 4, 0, 41, 64, 5, 0, 44]] | 0 | 156 | 1 |
#include <stdio.h>
int main() {
int input;
int weight;
int need[10];
int i, max;
while (scanf("%d", &input) != EOF) {
weight = 512;
max = 0;
for (i = 0; i < 10; i++) {
need[i] = 0;
}
for (i = 9; i >= 0; i--) {
if (weight <= input) {
input -= weight;
need[i] = w... | #include <stdio.h>
int main() {
int input;
int weight;
int need[10];
int i, max;
while (scanf("%d", &input) != EOF) {
weight = 512;
max = 0;
for (i = 0; i < 10; i++) {
need[i] = 0;
}
for (i = 9; i >= 0; i--) {
if (weight <= input) {
input -= weight;
need[i] = w... | [["-", 8, 9, 0, 7, 15, 16, 12, 16, 31, 22], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 17, 72], ["-", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 103, 0, 125], ["+", 0, 1, 0, 2, 3, 4, 0, 103, 0, 44]] | 0 | 184 | 6 |
#include <stdio.h>
int main() {
int g[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
int a, n;
for (;;) {
int low[10] = {0}, f = 0;
if (scanf("%d", &n) == EOF) {
break;
}
for (a = 0; a < 10; a++) {
if (n % 2 == 1) {
low[a] = 1;
}
n = n / 2;
}
for (a = 0; a <... | #include <stdio.h>
int main() {
int g[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
int a, n;
for (;;) {
int low[10] = {0}, f = 0;
if (scanf("%d", &n) == EOF) {
break;
}
for (a = 0; a < 10; a++) {
if (n % 2 == 1) {
low[a] = 1;
}
n = n / 2;
}
for (a = 0; a <... | [["+", 0, 57, 64, 9, 0, 57, 75, 76, 0, 95]] | 0 | 198 | 1 |
#include <stdio.h>
int main(void) {
int w;
int i;
int f;
while (scanf("%d", &w) != EOF) {
f = 0;
for (i = 0; i < 8; i++) {
if ((w & 1 << i) == 1 << i) {
if (f)
printf(" ");
printf("%d", 1 << i);
f = 1;
}
}
printf("\n");
}
return 0;
} | #include <stdio.h>
int main(void) {
int w;
int i;
int f;
while (scanf("%d", &w) != EOF) {
f = 0;
for (i = 0; i < 10; i++) {
if ((w & 1 << i) == 1 << i) {
if (f)
printf(" ");
printf("%d", 1 << i);
f = 1;
}
}
printf("\n");
}
return 0;
} | [["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]] | 0 | 105 | 2 |
#include <stdio.h>
int main() {
int i, j, x;
int a = 1;
int counter = 0;
int array[9] = {0};
while (scanf("%d", &x) != EOF) {
for (i = 9; i >= 0; i--) {
a = 1;
for (j = 0; j < i; j++) {
a = a * 2;
}
if (x >= a) {
x = x - a;
counter++;
array[counter]... | #include <stdio.h>
int main() {
int i, j, x;
int a = 1;
int counter = 0;
int array[9] = {0};
while (scanf("%d", &x) != EOF) {
counter = 0;
for (i = 9; i >= 0; i--) {
a = 1;
for (j = 0; j < i; j++) {
a = a * 2;
}
if (x >= a) {
x = x - a;
counter++;
... | [["+", 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 | 169 | 4 |
#include <iostream>
using namespace std;
int main() {
int w;
while (cin >> w) {
int i = 0;
bool f = 0;
while ((1 << i) < w) {
if ((1 << i) & w) {
if (f)
cout << " ";
else
f = 1;
cout << (1 << i);
}
i++;
}
cout << endl;
}
ret... | #include <iostream>
using namespace std;
int main() {
int w;
while (cin >> w) {
int i = 0;
bool f = 0;
while ((1 << i) <= w) {
if ((1 << i) & w) {
if (f)
cout << " ";
else
f = 1;
cout << (1 << i);
}
i++;
}
cout << endl;
}
re... | [["-", 8, 9, 0, 52, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 52, 15, 339, 51, 16, 17, 19]] | 1 | 90 | 2 |
#include <iostream>
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int w;
while (std::cin >> w) {
for (int i = 0; i < 9; ++i) {
int num = 1 << i;
if (w & num) {
w -= num;
std::cout << num;
if (w) {
std::cout << " ";
}
}
}
... | #include <iostream>
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int w;
while (std::cin >> w) {
for (int i = 0; i < 10; ++i) {
int num = 1 << i;
if (w & num) {
w -= num;
std::cout << num;
if (w) {
std::cout << " ";
}
}
}
... | [["-", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 12, 13]] | 1 | 105 | 2 |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int w;
while (cin >> w) {
int bit = pow(2, 9);
vector<int> a;
for (int i = 0; i < 10; i++) {
if (w / bit)
a.push_back(bit);
w = w % bit;
bit /= 2;
}
reverse(a.... | #include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;
int main() {
int w;
while (cin >> w) {
int bit = pow(2, 9);
vector<int> a;
for (int i = 0; i < 10; i++) {
if (w / bit)
a.push_back(bit);
w = w % bit;
bit /= 2;
}
reverse(a.... | [["+", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46], ["-", 0, 14, 8, 9, 0, 52, 8, 9, 0, 46]] | 1 | 152 | 2 |
#include <iostream>
#include <vector>
using namespace std;
int main() {
int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
int gram;
vector<int> ans;
while (cin >> gram) {
for (int i = 9; i >= 0; i--) {
if (gram >= weight[i]) {
ans.push_back(i);
gram -= weight[i];
}
}
... | #include <iostream>
#include <vector>
using namespace std;
int main() {
int weight[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
int gram;
vector<int> ans;
while (cin >> gram) {
for (int i = 9; i >= 0; i--) {
if (gram >= weight[i]) {
ans.push_back(i);
gram -= weight[i];
}
}
... | [["-", 0, 52, 8, 9, 0, 7, 10, 43, 39, 40], ["+", 0, 52, 8, 9, 0, 7, 10, 43, 39, 40]] | 1 | 156 | 2 |
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define PI 3.14159265359
#define INF 1000000;
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(n) rep(i, n)
t... | #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#define PI 3.14159265359
#define INF 1000000;
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(n) rep(i, n)
t... | [["+", 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 | 214 | 6 |
// include
//------------------------------------------
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#i... | // include
//------------------------------------------
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#i... | [["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 13]] | 1 | 418 | 4 |
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define PI 3.141592653
bool cross(double x1, double y1, double x2, double y2, double x3, double y3,
... | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define PI 3.141592653
bool cross(double x1, double y1, double x2, double y2, double x3, double y3,
... | [["-", 0, 52, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 52, 8, 9, 0, 7, 15, 16, 17, 19]] | 1 | 288 | 2 |
#include <stdio.h>
#include <string.h>
int main(void) {
char line[80];
int w;
int f[10];
int u[10];
int k = 512;
for (int &d : f) {
d = k;
k >>= 1;
}
while (true) {
if (fgets(line, sizeof line, stdin) == NULL) {
break;
}
if (sscanf(line, "%d", &w) != 1) {
break;
... | #include <stdio.h>
#include <string.h>
int main(void) {
char line[80];
int w;
int f[10];
int u[10];
int k = 512;
for (int &d : f) {
d = k;
k >>= 1;
}
while (true) {
if (fgets(line, sizeof line, stdin) == NULL) {
break;
}
if (sscanf(line, "%d", &w) != 1) {
break;
... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20]] | 1 | 290 | 2 |
#include <bits/stdc++.h>
using namespace std;
int N, S;
int dfs(int n, int t, int sum) {
if (n == 10)
return 0;
if (t == N) {
if (sum == S)
return 1;
else
return 0;
}
return dfs(n + 1, t, sum) + dfs(n + 1, t + 1, sum + n);
}
int main() {
while (cin >> N >> S, N || S)
cout << dfs(0... | #include <bits/stdc++.h>
using namespace std;
int N, S;
int dfs(int n, int t, int sum) {
if (n > 10)
return 0;
if (t == N) {
if (sum == S)
return 1;
else
return 0;
}
return dfs(n + 1, t, sum) + dfs(n + 1, t + 1, sum + n);
}
int main() {
while (cin >> N >> S, N || S)
cout << dfs(0,... | [["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]] | 1 | 116 | 2 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios ::sync_with_stdio(false);
for (int n, s; cin >> n >> s;)
if (n && s) {
int p[10];
iota(p, p + 10, 0);
int ans = 0;
do {
if (accumulate(p, p + n, 0) == s)
ans++;
} while (next_permutation(p, p + 10));
... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios ::sync_with_stdio(false);
for (int n, s; cin >> n >> s;)
if (n || s) {
int p[10];
iota(p, p + 10, 0);
int ans = 0;
do {
if (accumulate(p, p + n, 0) == s)
ans++;
} while (next_permutation(p, p + 10));
... | [["-", 0, 7, 8, 57, 15, 339, 51, 16, 17, 98], ["+", 0, 7, 8, 57, 15, 339, 51, 16, 17, 106]] | 1 | 145 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.