language stringclasses 5
values | dataset stringclasses 1
value | code stringlengths 26 25k | id stringlengths 10 10 | test_IO listlengths 1 1 |
|---|---|---|---|---|
C | codenet | #include <stdio.h>
#include <stdlib.h>
typedef struct {
int parent;
int right;
int left;
} BT;
BT bt[26];
int n;
void Preorder(int a) {
if (a == -1) return;
printf(" %d", a);
Preorder(bt[a].left);
Preorder(bt[a].right);
}
void Inorder(int a) {
if (a == -1) return;
Inorder(bt[a]... | s805561051 | [
{
"input": "9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n",
"output": "Preorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n"
}
] |
C | codenet | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node {
unsigned int key;
struct node *next;
struct node *prev;
};
typedef struct node *NodePointer;
NodePointer nil;
NodePointer listSearch(int);
void init(void);
void printList(void);
void deleteNode(NodePointer);
void deleteFirst(void);... | s719593355 | [
{
"input": "7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n",
"output": "6 1 2\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int height, width, i;
scanf("%d %d", &height, &width);
char input_str[width + 1];
for (i = 0; i < width + 2; i++) {
printf("#");
}
printf("\n");
for (i = 0; i < height; i++) {
scanf("%s", input_str);
printf("#%s#\n", input_str);
}
... | s383338432 | [
{
"input": "2 3\nabc\narc\n",
"output": "#####\n#abc#\n#arc#\n#####\n"
}
] |
C | codenet | #include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i, l, r) for (ll i = (l); i < (r); i++)
#define max(p, q) ((p) > (q) ? (p) : (q))
typedef struct edge {
ll s, g, c;
} E;
typedef struct graph {
int vcnt, ecnt;
E e[200010];
int id[100010];
} G;
int esort(const void* a, const void*... | s073208348 | [
{
"input": "4\n0 1 2\n1 2 1\n1 3 3\n",
"output": "5\n"
}
] |
C | codenet | #include <stdio.h>
#include <string.h>
#define MAX 21
void init(int);
void move(int);
int n, x, y;
char fld[MAX][MAX];
int main(void) {
int m;
while (~scanf("%d", &n), n) {
init(n);
scanf("%d", &m);
move(m);
printf("%s\n", n ? "No" : "Yes");
}
return 0;
}
void init(in... | s065149518 | [
{
"input": "2\n10 11\n11 12\n2\nN 2\nE 1\n2\n10 11\n11 12\n2\nN 2\nW 1\n3\n0 15\n5 10\n5 15\n5\nW 10\nS 10\nN 20\nE 10\nS 10\n0\n",
"output": "Yes\nNo\nNo\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int key, i, j, len, a[101];
scanf("%d", &len);
for (i = 0; i < len; i++) scanf("%d", a + i);
for (j = 1; j < len; j++) {
for (i = 0; i < len; i++) printf(i != 0 ? " %d" : "%d", a[i]);
puts("");
key = a[j];
for (i = j - 1; i >= 0 && a[i] >... | s555338838 | [
{
"input": "6\n5 2 4 6 1 3\n",
"output": "5 2 4 6 1 3\n2 5 4 6 1 3\n2 4 5 6 1 3\n2 4 5 6 1 3\n1 2 4 5 6 3\n1 2 3 4 5 6\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int x;
scanf("%d", &x);
printf("%d\n", x * x * x);
return 0;
} | s746512291 | [
{
"input": "2\n",
"output": "8\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int n, i, j, q, x[10000], y[500], sum = 0;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &x[i]);
}
scanf("%d", &q);
for (i = 0; i < q; i++) {
scanf("%d", &y[i]);
}
for (i = 0; i < q; i++) {
for (j = 0; j < n; j++) {
... | s574777006 | [
{
"input": "5\n1 2 3 4 5\n3\n3 4 1\n",
"output": "3\n"
}
] |
C | codenet | #include <stdio.h>
#include <string.h>
int main() {
char A[20], B[20], C[20];
scanf("%s %s %s", A, B, C);
int la = strlen(A), lb = strlen(B);
if (A[la - 1] == B[0] && B[lb - 1] == C[0]) {
printf("YES\n");
} else {
printf("NO\n");
}
return 0;
} | s479404625 | [
{
"input": "rng gorilla apple\n",
"output": "YES\n"
}
] |
C | codenet | #include <stdio.h>
#include <stdlib.h>
struct node {
struct node *right;
struct node *left;
struct node *parent;
int key;
};
typedef struct node *Node;
#define NIL NULL
Node root;
Node treeMinimum(Node x) {
while (x->left != NIL) x = x->left;
return x;
}
Node treeMaximum(Node x) {
while ... | s957555615 | [
{
"input": "18\ninsert 8\ninsert 2\ninsert 3\ninsert 7\ninsert 22\ninsert 1\nfind 1\nfind 2\nfind 3\nfind 4\nfind 5\nfind 6\nfind 7\nfind 8\nprint\ndelete 3\ndelete 7\nprint\n",
"output": "yes\nyes\nyes\nno\nno\nno\nyes\nyes\n 1 2 3 7 8 22\n 8 2 1 3 7 22\n 1 2 8 22\n 8 2 1 22\n"
}
] |
C | codenet | #include <math.h>
#include <stdio.h>
#include <string.h>
#define MAX 707106
char tbl[MAX + 1];
int sz;
int prime[57100] = {
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47,
53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
127, 131, 137, 139, 149, 151, 157... | s019421829 | [
{
"input": "18 2\n",
"output": "4\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int a, b, c, d, i, j;
scanf("%d %d %d %d", &a, &b, &c, &d);
i = a * b;
j = c * d;
if (i > j) {
printf("%d\n", i);
} else {
printf("%d\n", j);
}
return 0;
} | s062562864 | [
{
"input": "3 5 2 7\n",
"output": "15\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int i, j, k, L, tmp, d, def, end, aj, max, min;
for (;;) {
int an[20], a1[6], a2[6];
scanf("%d %d", &an[0], &L);
if (!L) break;
aj = an[0];
end = 0;
for (k = 1; k < 21; k++) {
for (i = L - 1; i >= 0; i--, aj /= 10... | s110919613 | [
{
"input": "2012 4\n83268 6\n1112 4\n0 1\n99 2\n0 0\n",
"output": "3 6174 1\n1 862632 7\n5 6174 1\n0 0 1\n1 0 1\n"
}
] |
C | codenet | #include <stdbool.h>
#include <stdio.h>
#include <string.h>
int main() {
int n, m;
scanf("%d%d", &n, &m);
bool r0[n];
memset(r0, 0x00, n);
int r1[n];
int nr1 = 0;
for (int i = 0; i < m; i++) {
int a, b;
scanf("%d%d", &a, &b);
if (a > b) {
int t = a;
... | s090095029 | [
{
"input": "3 2\n1 2\n2 3\n",
"output": "POSSIBLE\n"
}
] |
C | codenet | #include <stdio.h>
int linearsearch(int S[], int n, int key) {
int i = 0;
int count = 0;
while (S[i] != key) {
i++;
if (i >= n) {
count = 1;
return count;
}
}
return count;
}
int main() {
int i, j, n, q, S[10000], T[10000];
int count = 0, key... | s400146413 | [
{
"input": "5\n1 2 3 4 5\n3\n3 4 1\n",
"output": "3\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int a, b;
scanf("%d %d", &a, &b);
if (500 * a >= b)
printf("Yes\n");
else
printf("No\n");
return 0;
} | s329517742 | [
{
"input": "2 900\n",
"output": "Yes\n"
}
] |
C | codenet | #include <stdio.h>
#define gc() getchar_unlocked()
int in() {
int n = 0, c = gc();
do n = 10 * n + (c & 0xf);
while ((c = gc()) >= '0');
return n;
}
int f1[100], f2[100];
void calc(int n) {
int k = n % 10;
while (n >= 10) n /= 10;
++f1[10 * k + n], ++f2[n * 10 + k];
}
int main() {
i... | s445709355 | [
{
"input": "25\n",
"output": "17\n"
}
] |
C | codenet | #include <stdio.h>
int x, y;
int main() {
scanf("%d %d", &x, &y);
printf("%d %d\n", x * y, 2 * x + 2 * y);
return 0;
} | s957824161 | [
{
"input": "3 5\n",
"output": "15 16\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int A, B;
scanf("%d %d", &A, &B);
if (A < 10 && B < 10)
printf("%d\n", A * B);
else
printf("-1\n");
return 0;
} | s744346876 | [
{
"input": "2 5\n",
"output": "10\n"
}
] |
C | codenet | #include <stdio.h>
#define N 2000
int num1, math[N + 1];
int main() {
int a, num2, ans, sum = 0, math[N + 1];
int i, j;
math[0] = 1;
scanf("%d", &num1);
for (i = 0; i < num1; i++) {
scanf("%d", &a);
sum += a;
for (j = sum - a; j >= 0; j--) {
if (math[j] == 1) ma... | s340712303 | [
{
"input": "5\n1 5 7 10 21\n8\n2 4 17 8 22 21 100 35\n",
"output": "no\nno\nyes\nyes\nyes\nyes\nno\nno\n"
}
] |
C | codenet | #include <stdio.h>
#include <string.h>
#define LEN 100005
typedef struct pp {
char name[100];
int t;
} P;
P Q[LEN];
int head, tail, n;
void enqueue(P x) {
Q[tail] = x;
tail = (tail + 1) % LEN;
}
P dequeue() {
P x = Q[head];
head = (head + 1) % LEN;
return x;
}
int min(int a, int b) { r... | s266720248 | [
{
"input": "5 100\np1 150\np2 80\np3 200\np4 350\np5 20\n",
"output": "p2 180\np5 400\np1 450\np3 550\np4 800\n"
}
] |
C | codenet | #include <stdio.h>
#define N 1000
int main(void) {
char su[N] = {'0'};
int susum = 0;
int j = 0;
while (1) {
for (j = 0; j <= N; j++) {
scanf("%c", &su[j]);
if (su[j] == '\n') break;
susum = susum + (su[j] - '0');
}
if (su[0] == '0') break;
... | s050123290 | [
{
"input": "123\n55\n1000\n0\n",
"output": "6\n10\n1\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int a, b, n;
int sum;
int i, j;
while (1) {
if (scanf("%d %d %d", &a, &b, &n) == -1) break;
a -= a / b * b;
sum = 0;
for (i = 1; i <= n; i++) {
a *= 10;
for (j = 9; j >= 0; j--) {
if (b * j <= a)... | s000061454 | [
{
"input": "1 2 3\n2 3 4\n5 4 3\n4 3 2\n",
"output": "5\n24\n7\n6\n"
}
] |
C | codenet | #include <stdio.h>
#include <stdlib.h>
int main() {
int i;
char S[6];
scanf("%s", S);
for (i = 0; S[i] != '\0'; i++) {
if (S[i] == 'A' && S[i + 1] == 'C') {
printf("Yes\n");
return 0;
}
}
printf("No\n");
return 0;
} | s681783549 | [
{
"input": "BACD\n",
"output": "Yes\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int a, b, c, d, e, i;
scanf("%d%d%d", &a, &b, &c);
if (b <= c) {
printf("NO\n");
return 0;
} else {
d = a;
e = d % b;
for (i = 0; i < b; i++) {
d = d % b;
if (d == c) {
printf("YES\n");
... | s989417036 | [
{
"input": "7 5 1\n",
"output": "YES\n"
}
] |
C | codenet | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i, l, r) for (ll i = (l); i < (r); i++)
#define repp(i, l, r, k) for (ll i = (l); i < (r); i += (k))
#define INF ((1LL << 62) - (1LL << 31))
#define max(p, q) ((p) > (q) ? (p) : (q))
#define min(p, q) ((p) < (q) ? (p) : (q))
#de... | s582614433 | [
{
"input": "6\nkhabarovsk 20\nmoscow 10\nkazan 50\nkazan 35\nmoscow 60\nkhabarovsk 40\n",
"output": "3\n4\n6\n1\n5\n2\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int input[4][4], tc;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
scanf("%d", &input[i][j]);
}
}
scanf("%d", &tc);
int testcase;
for (int i = 0; i < tc; i++) {
scanf("%d", &testcase);
for (int i = 0; i < 3... | s467564704 | [
{
"input": "84 97 66\n79 89 11\n61 59 7\n7\n89\n7\n87\n79\n24\n84\n30\n",
"output": "Yes\n"
}
] |
C | codenet | #include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
int X, A, B, C;
int i = 0;
int j = 0;
int k = 0;
int kosu = 0;
scanf("%d", &A);
scanf("%d", &B);
scanf("%d", &C);
scanf("%d", &X);
X = X / 50;
for (i = 0; i <= A; i++) {
for ... | s205656765 | [
{
"input": "2\n2\n2\n100\n",
"output": "2\n"
}
] |
C | codenet | #include <stdio.h>
#include <string.h>
int main(void) {
int i, sum = 0;
int flag = 0;
char x[1002];
scanf("%s", x);
do {
for (i = 0; i < 1002; i++) {
if (x[i] == 0) {
printf("%d\n", sum);
break;
} else {
sum += x[i] - 0x... | s218426876 | [
{
"input": "123\n55\n1000\n0\n",
"output": "6\n10\n1\n"
}
] |
C | codenet | #include <stdio.h>
#include <stdlib.h>
int main() {
char inputNumbers[5];
char temp[2];
int a, b, c, d;
int sum;
char symbols[3];
scanf("%s", &inputNumbers);
temp[1] = '\0';
temp[0] = inputNumbers[0];
a = atoi(temp);
temp[0] = inputNumbers[1];
b = atoi(temp);
temp[0] ... | s302860389 | [
{
"input": "1222\n",
"output": "1+2+2+2=7\n"
}
] |
C | codenet | #include <math.h>
#include <stdio.h>
void main() {
int n, d;
scanf("%d%d", &n, &d);
int point[n + 1][d + 1];
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= d; j++) {
scanf("%d", &point[i][j]);
}
}
int count = 0;
for (int i = 1; i <= n - 1; i++) {
f... | s993124238 | [
{
"input": "3 2\n1 2\n5 5\n-2 8\n",
"output": "1\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
char n[10];
scanf("%s", n);
if (((n[0] == n[1]) && (n[1] == n[2])) ||
((n[1] == n[2]) && (n[2] == n[3]))) {
printf("Yes\n");
} else {
printf("No\n");
}
return 0;
} | s175895052 | [
{
"input": "1118\n",
"output": "Yes\n"
}
] |
C | codenet | #include <stdio.h>
#include <string.h>
int main() {
char str[21];
int i, len;
scanf("%s", str);
len = strlen(str);
for (i = len - 1; i >= 0; i--) {
putchar(str[i]);
}
printf("\n");
return 0;
} | s494952667 | [
{
"input": "w32nimda\n",
"output": "admin23w\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int n, i, a;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
a = i;
if ((a % 3) == 0) {
printf(" %d", i);
} else {
for (; a;) {
if ((a % 10) == 3) {
printf(" %d", i);
a = 0... | s375200717 | [
{
"input": "30\n",
"output": " 3 6 9 12 13 15 18 21 23 24 27 30\n"
}
] |
C | codenet | #include <stdio.h>
#define DAYS 365
int main(void) {
int n, i;
int nyuyoku_ticket[DAYS], pool_ticket[DAYS];
int nyuyoku_member[DAYS], pool_member[DAYS];
int seiki_ryoukin[DAYS], waribiki_ryoukin[DAYS], saiyasune[DAYS];
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d %d %d %d", &ny... | s867013108 | [
{
"input": "2\n100 100 1 1\n1000 500 5 2\n",
"output": "200\n4800\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int i, n, tmp;
long long int min = 1000000, max = -1000000, sum = 0;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &tmp);
if (min > tmp) min = tmp;
if (max < tmp) max = tmp;
sum += tmp;
}
printf("%ld %ld %ld\n", min... | s552669377 | [
{
"input": "5\n10 1 5 4 17\n",
"output": "1 17 37\n"
}
] |
C | codenet | #include <stdio.h>
int min(int a, int b) {
if (a <= b) {
return (a);
}
return (b);
}
int Chain(int b[10000], int n) {
int i, j;
int count;
int color;
int a[10000];
for (i = 0; i < n; i++) {
a[i] = b[i];
}
for (i = 0; i < n - 4; i++) {
if (a[i] != 0 && ... | s905557267 | [
{
"input": "12\n3\n2\n1\n1\n2\n3\n2\n2\n2\n1\n1\n3\n12\n3\n2\n1\n1\n2\n3\n2\n1\n3\n2\n1\n3\n0\n",
"output": "3\n12\n"
}
] |
C | codenet | #include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int x;
scanf("%d", &x);
if (x == 1)
printf("0\n");
else
printf("1\n");
return 0;
} | s845656342 | [
{
"input": "1\n",
"output": "0\n"
}
] |
C | codenet | #include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct binaryHeap {
void *array;
size_t heap_size;
size_t max_size;
size_t val_size;
int (*cmp)(const void *, const void *);
} heap;
heap *new_binary_heap(const size_t val_size,
int (*cmp... | s305090452 | [
{
"input": "3 1\n1 100 1\n",
"output": "106\n"
}
] |
C | codenet | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct _node {
int key;
struct _node *next;
struct _node *prev;
} node;
node *head;
node *makenode(int);
void insert(int);
void delete(int);
void deleteFirst();
void deleteLast();
int main() {
int i, n, a;
char op[16];
node *... | s907732757 | [
{
"input": "7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n",
"output": "6 1 2\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int a, b, c, i, j, k;
int max;
scanf("%d", &j);
for (i = 0; i < j; i++) {
scanf("%d", &a);
scanf("%d", &b);
scanf("%d", &c);
max = a;
k = 0;
if (max <= b) {
max = b;
k = 1;
}
i... | s791230408 | [
{
"input": "3\n4 3 5\n4 3 6\n8 8 8\n",
"output": "YES\nNO\nNO\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int x, y;
scanf("%d", &x);
y = x * x * x;
printf("%d\n", y);
return 0;
} | s154738543 | [
{
"input": "2\n",
"output": "8\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
if (a < b && b < c)
puts("Yes");
else
puts("No");
return 0;
} | s168792702 | [
{
"input": "1 3 8\n",
"output": "Yes\n"
}
] |
C | codenet | #include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int low[200000];
int high[200000];
int a[200000];
int part(int a[], int b[], int l, int r) {
int i, j, x, t;
i = l - 1;
j = r;
x = b[r];
while (1) {
while (b[++i] < x)
;
while (i < --j && x ... | s660035552 | [
{
"input": "5 2\n1 4\n2 5\n",
"output": "1\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int n, m;
scanf("%d %d", &n, &m);
printf("%d\n", (n - 1) * (m - 1));
fflush(stdout);
return 0;
} | s235028939 | [
{
"input": "3 4\n",
"output": "6\n"
}
] |
C | codenet | #include <stdio.h>
#define MAX 25
typedef struct {
int l, r, par;
} node;
node N[MAX];
void init(int);
void Preorder(int);
void Inorder(int);
void Postorder(int);
int main() {
int n, i, id, l, r;
int p;
scanf("%d", &n);
init(n);
for (i = 0; i < n; i++) {
scanf("%d%d%d", &id, &l, &... | s120278714 | [
{
"input": "9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n",
"output": "Preorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int x, y;
x = 0;
y = 0;
scanf("%d", &x);
scanf("%d", &y);
printf("%d %d\n", x * y, (2 * x) + (2 * y));
return 0;
} | s470461127 | [
{
"input": "3 5\n",
"output": "15 16\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int n, x, min, m, i;
scanf("%d %d %d", &n, &x, &min);
x -= min;
for (i = 1; i < n; i++) {
scanf("%d", &m);
x -= m;
if (min > m) {
min = m;
}
}
printf("%d\n", n + x / min);
return 0;
} | s539307012 | [
{
"input": "3 1000\n120\n100\n140\n",
"output": "9\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int a, b, x, w;
while (scanf("%d %d", &a, &b) != EOF) {
x = a + b;
w = 0;
while (x) {
w++;
x /= 10;
}
printf("%d\n", w);
}
return 0;
} | s906878895 | [
{
"input": "5 7\n1 99\n1000 999\n",
"output": "2\n3\n4\n"
}
] |
C | codenet | #include <stdio.h>
#include <stdlib.h>
#define I 10000
void CountingSort(int *, int *, int);
int main() {
int *a, *b, i, max = 0, n;
scanf("%d", &n);
a = (int *)malloc((n + 1) * sizeof(int));
b = (int *)malloc((n + 1) * sizeof(int));
for (i = 0; i < n; i++) {
scanf("%d", &a[i + 1]);
}
... | s787964396 | [
{
"input": "7\n2 5 1 3 2 3 0\n",
"output": "0 1 2 2 3 3 5\n"
}
] |
C | codenet | #include <stdio.h>
#define ABS(x) (((x) < (0)) ? (-(x)) : (x))
int main(void) {
int N, t, x, y, nx = 0, ny = 0, nt = 0;
int i, j, k, tmp;
scanf("%d", &N);
for (i = 0; i < N; i++) {
scanf("%d%d%d", &t, &x, &y);
tmp = t - nt - (ABS(x - nx) + ABS(y - ny));
if (tmp < 0 || tmp % 2) ... | s198852827 | [
{
"input": "2\n3 1 2\n6 1 1\n",
"output": "Yes\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if (n % 2 == 0) {
printf("%d\n", n / 2);
} else {
printf("%d\n", (n / 2) + 1);
}
return 0;
} | s410235811 | [
{
"input": "5\n",
"output": "3\n"
}
] |
C | codenet | #include <stdio.h>
int main(void)
{
int x, kotae;
scanf("%d", &x);
kotae = x * x * x;
printf("%d\n", kotae);
return 0;
} | s389564195 | [
{
"input": "2\n",
"output": "8\n"
}
] |
C | codenet | #include <stdio.h>
#include <string.h>
int main() {
int n;
char s[10010], *c;
scanf("%d%*c", &n);
while (n--) {
fgets(s, 1010, stdin);
while (c = strstr(s, "Hoshino")) *(c + 6) = 'a';
printf("%s", s);
}
return 0;
} | s683308527 | [
{
"input": "3\nHoshino\nHashino\nMasayuki Hoshino was the grandson of Ieyasu Tokugawa.\n",
"output": "Hoshina\nHashino\nMasayuki Hoshina was the grandson of Ieyasu Tokugawa.\n"
}
] |
C | codenet | #include <stdio.h>
#define MAX 100
#define INF 999999
#define NIL -1
#define WHITE 0
#define BLACK 2
int prim();
int n, G[MAX][MAX];
int main() {
int i, j;
scanf("%d", &n);
for (i = 0; i < n; i++) {
for (j = 0; j < n; j++) {
scanf("%d", &G[i][j]);
}
}
printf("%d\n", ... | s263479532 | [
{
"input": "5\n -1 2 3 1 -1\n 2 -1 -1 4 -1\n 3 -1 -1 1 1\n 1 4 1 -1 3\n -1 -1 1 3 -1\n",
"output": "5\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int N, D;
int ans, rem;
scanf("%d%d", &N, &D);
ans = N / (D * 2 + 1);
rem = N % (D * 2 + 1);
if (rem != 0) {
ans = ans + 1;
}
printf("%d\n", ans);
return 0;
} | s753632359 | [
{
"input": "6 2\n",
"output": "2\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int A, B, flag = 0;
scanf("%d %d", &A, &B);
for (int i = 1; i <= 3; ++i) {
if ((A * B * i) % 2 == 1) {
flag = 1;
break;
}
}
if (flag)
printf("Yes\n");
else
printf("No\n");
return 0;
} | s426986656 | [
{
"input": "3 1\n",
"output": "Yes\n"
}
] |
C | codenet | #include <math.h>
#include <stdio.h>
int main() {
double r;
scanf("%lf", &r);
printf("%lf %lf\n", r * r * M_PI, 2 * M_PI * r);
return 0;
} | s388748526 | [
{
"input": "2\n",
"output": "12.566371 12.566371\n"
}
] |
C | codenet | #include <stdio.h>
#include <string.h>
int main(void) {
char str[201], tmp[101];
char p[101];
int slen, plen;
int i, j, flag;
scanf("%s %s", str, p);
strcpy(tmp, str);
strcat(str, tmp);
slen = strlen(str);
plen = strlen(p);
flag = 0;
for (i = 0; i < slen - plen; i++) {
... | s387404795 | [
{
"input": "vanceknowledgetoad\nadvance\n",
"output": "Yes\n"
}
] |
C | codenet | #include <stdio.h>
#define N 1000000
#define Q 50000
int n, S[N], T[Q];
int binarySearch(int key) {
int left = 0, right = n, mid;
while (left < right) {
mid = (left + right) / 2;
if (S[mid] == key)
return 1;
else if (key < S[mid])
right = mid;
else
... | s190193281 | [
{
"input": "5\n1 2 3 4 5\n3\n3 4 1\n",
"output": "3\n"
}
] |
C | codenet | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
void push(int);
int pop();
int top, kinbo[1000];
int main() {
int chonda, yamagami;
top = 0;
char null[100];
while (scanf("%s", null) != EOF) {
if (null[0] == '+') {
chonda = pop();
yamagami = pop();
... | s141680236 | [
{
"input": "1 2 +\n",
"output": "3\n"
}
] |
C | codenet | #include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
char s[26];
scanf("%s", s);
for (int j = 0; j < strlen(s); j++) {
for (int i = 0; i < strlen(s); i++) {
if ((i != j) && (s[i] == s[j])) {
puts("no");
return 0;
}
... | s882312203 | [
{
"input": "uncopyrightable\n",
"output": "yes\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int x, a;
scanf("%d %d", &x, &a);
printf("%d\n", (x >= a) * 10);
return 0;
} | s372829880 | [
{
"input": "3 5\n",
"output": "0\n"
}
] |
C | codenet | #include <stdio.h>
#include <stdlib.h>
#define MAX 100000
int Partition(char[], int[], int, int);
void Quicksort(char[], int[], int, int);
void Merge(char[], int[], int, int, int);
void Merge_Sort(char[], int[], int, int);
int q;
int main(void) {
int A[MAX + 1];
char C[MAX + 1];
char MC[MAX + 1];
in... | s451461278 | [
{
"input": "6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n",
"output": "Not stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int cnt4 = 0, cnt2 = 0;
for (int i = 0; i < n; i++) {
int wk;
scanf("%d", &wk);
if (wk % 4 == 0)
cnt4++;
else if (wk % 2 == 0)
cnt2++;
}
if (cnt4 + cnt2 / 2 >= n / 2)
print... | s237922865 | [
{
"input": "3\n1 10 100\n",
"output": "Yes\n"
}
] |
C | codenet | #include <stdio.h>
#include <stdlib.h>
#define N 100000
#define INF 1000000
typedef struct {
int go, back, cost;
} Date;
int n, d[N];
Date a[500000];
void root(int);
int main() {
int i, j, k, u, count = 0;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d%d", &u, &k);
for (j = 0; ... | s808208135 | [
{
"input": "5\n0 3 2 3 3 1 1 2\n1 2 0 2 3 4\n2 3 0 3 3 1 4 1\n3 4 2 1 0 1 1 4 4 3\n4 2 2 1 3 3\n",
"output": "0 0\n1 2\n2 2\n3 1\n4 3\n"
}
] |
C | codenet | #include <stdio.h>
#include <stdlib.h>
#define INF 0x5fffffff
int a[100002];
int b[100002];
char buf[700002], *p;
int getint() {
int n = 0;
if (*p == '-') {
p++;
while (*p >= '0') n = (n << 3) + (n << 1) + (*p++ & 0xf);
return -n;
}
while (*p >= '0') n = (n << 3) + (n << 1) + (... | s817872520 | [
{
"input": "7\n2 0 -2 3 2 -2 0\n",
"output": "4\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int A, B, C, D, E, max;
scanf("%d %d", &A, &B);
C = A + B;
D = A - B;
E = A * B;
max = C;
if (max < D) {
max = D;
}
if (max < E) {
max = E;
}
printf("%d\n", max);
return 0;
} | s128781606 | [
{
"input": "-13 3\n",
"output": "-10\n"
}
] |
C | codenet | #include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
int i, j, k, n;
scanf("%d", &n);
printf("%d\n", 24 + (24 - n));
return 0;
} | s730748220 | [
{
"input": "21\n",
"output": "27\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
char str[30];
gets(str);
str[5] = ' ';
str[13] = ' ';
printf("%s\n", str);
return 0;
} | s264533675 | [
{
"input": "happy,newyear,enjoy\n",
"output": "happy newyear enjoy\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int a, b;
scanf("%d %d", &a, &b);
if (a == 1) a = 14;
if (b == 1) b = 14;
if (a < b)
printf("Bob\n");
else if (a > b)
printf("Alice\n");
else
printf("Draw\n");
return 0;
} | s961413659 | [
{
"input": "8 6\n",
"output": "Alice\n"
}
] |
C | codenet | #include <stdio.h>
#define INF 100000
#define MAX 101
#define NIL -6
#define WHITE 0
#define GRAY 1
#define BLACK 2
int G[MAX][MAX];
int n;
void prim() {
int i, j;
int d[MAX];
int pi[MAX];
int color[MAX];
int min, u, v, sum = 0;
for (i = 0; i < n; i++) {
d[i] = INF;
pi[i] = NI... | s069149000 | [
{
"input": "5\n -1 2 3 1 -1\n 2 -1 -1 4 -1\n 3 -1 -1 1 1\n 1 4 1 -1 3\n -1 -1 1 3 -1\n",
"output": "5\n"
}
] |
C | codenet | #include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
typedef int32_t i32;
typedef int64_t i64;
typedef struct directed_edge {
int32_t vertex;
int32_t next;
} graph_edge;
typedef struct directedGraph {
graph_edge *edge;
int32_t *start;
int32_t pointer;
int32_t verte... | s132677252 | [
{
"input": "2\n0 0\n",
"output": "8\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int a[10000], min, max, n, i;
long long sum = 0;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
sum += a[i];
}
max = min = a[0];
for (i = 1; i < n; i++) {
if (a[i] > max) max = a[i];
if (a[i] < min) min = a[i];
... | s762168196 | [
{
"input": "5\n10 1 5 4 17\n",
"output": "1 17 37\n"
}
] |
C | codenet | #include <stdio.h>
long long heap[100000], sz = 0;
void push(int x) {
int i = sz++;
while (i > 0) {
int p = (i - 1) / 2;
if (heap[p] >= x) break;
heap[i] = heap[p];
i = p;
}
heap[i] = x;
}
int pop() {
int ret = heap[0];
int x = heap[--sz];
int i = 0;
whil... | s176519935 | [
{
"input": "3 3\n2 13 8\n",
"output": "9\n"
}
] |
C | codenet | #include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int N, D, i, j, k = 0, n = 0;
double l;
int** matrix;
scanf("%d%d", &N, &D);
matrix = (int**)malloc(sizeof(int*) * N);
for (i = 0; i < N; i++) {
matrix[i] = (int*)malloc(sizeof(int) * D);
}
for (i = 0; i <... | s517438056 | [
{
"input": "3 2\n1 2\n5 5\n-2 8\n",
"output": "1\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int h, r;
scanf("%d%d", &h, &r);
if (r > -h) {
printf("1\n");
} else if (r == -h) {
printf("0\n");
} else {
printf("-1\n");
}
return 0;
} | s585881557 | [
{
"input": "-3 3\n",
"output": "0\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int N;
scanf("%d", &N);
int i;
long long sum = 0;
long long wa = 0;
int A[N];
int sa[N];
int ans;
int shou;
long long min = 1123456789;
for (i = 0; i < N; i++) {
scanf("%d", A + i);
sum += A[i];
wa += i + 1;
}... | s072370813 | [
{
"input": "5\n4 5 1 2 3\n",
"output": "YES\n"
}
] |
C | codenet | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
char **t, **h;
int n, taro = 0, hanako = 0, i;
scanf("%d", &n);
t = malloc(n * sizeof(char *));
h = malloc(n * sizeof(char *));
for (i = 0; i < n; i++) {
t[i] = malloc(100 * sizeof(char));
h[i] = malloc(100 ... | s898107093 | [
{
"input": "3\ncat dog\nfish fish\nlion tiger\n",
"output": "1 7\n"
}
] |
C | codenet | #include <stdio.h>
#include <string.h>
#define M 1046527
#define L 14
char H[M][L];
int getChar(char ch) {
if (ch == 'A')
return 1;
else if (ch == 'C')
return 2;
else if (ch == 'G')
return 3;
else if (ch == 'T')
return 4;
return 0;
}
long long getKey(char str[]) {... | s164093814 | [
{
"input": "5\ninsert A\ninsert T\ninsert C\nfind G\nfind A\n",
"output": "no\nyes\n"
}
] |
C | codenet | #include <stdio.h>
int main()
{
int a, b, s;
scanf("%d %d", &a, &b);
s = (a * b) - (a + b) + 1;
printf("%d\n", s);
} | s215012367 | [
{
"input": "2 2\n",
"output": "1\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int a, b, c, d;
scanf("%d%d%d%d", &a, &b, &c, &d);
if (a + b > c + d)
printf("Left\n");
else if (a + b < c + d)
printf("Right\n");
else
printf("Balanced\n");
return 0;
} | s826185217 | [
{
"input": "3 8 7 1\n",
"output": "Left\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int a, b, n;
scanf("%d %d", &a, &b);
n = (a + b) / 2;
printf("%d\n", n);
return 0;
} | s534239171 | [
{
"input": "1000 3000\n",
"output": "2000\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int a, b, h;
scanf("%d%d%d", &a, &b, &h);
printf("%d\n", (a + b) * h / 2);
return 0;
} | s381222101 | [
{
"input": "3\n4\n2\n",
"output": "7\n"
}
] |
C | codenet | #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define U1 unsigned char
#define S1 char
#define S4 int
#define DU double
#define VD void
#define COMMAND_LENGTH (10)
typedef struct st_node ST_NODE;
typedef struct st_node {
ST_NODE* st_parent;
ST_NODE* st_left;
S... | s701716787 | [
{
"input": "8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n",
"output": " 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
long long int a, b, c;
scanf("%lld %lld %lld", &a, &b, &c);
long long int d = c - a - b;
if ((d > 0) && ((4 * a * b) < d * d))
printf("Yes\n");
else
printf("No\n");
return 0;
} | s860117222 | [
{
"input": "2 3 9\n",
"output": "No\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int a, b, c, d, e, f;
double x, y;
while (scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f) != -1) {
y = (double)(c * d - f * a) / (b * d - e * a);
x = (double)(c * e - f * b) / (a * e - d * b);
if (y <= 0 && y > -0.0005) y = 0;
if (x <= 0 &&... | s414827596 | [
{
"input": "1 2 3 4 5 6\n2 -1 -2 -1 -1 -5\n",
"output": "-1.000 2.000\n1.000 4.000\n"
}
] |
C | codenet | #include <stdio.h>
#include <stdlib.h>
int miyukiti(const void* asumisu, const void* mizuhasu) {
int isihasu = *(const int*)asumisu, matukisu = *(const int*)mizuhasu;
return isihasu < matukisu ? -1 : isihasu > matukisu;
}
int N;
int A[114514];
int yukinnko;
int tomatu[114514];
int mikakosi[114514];
int sum... | s814977152 | [
{
"input": "3\n6\n2\n6\n",
"output": "1\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
int i, j, x[10000];
for (i = 0; i < 10000; i++) {
x[i] = 0;
}
i = 0;
scanf("%d", &x[i]);
while (x[i] != 0) {
i++;
scanf("%d", &x[i]);
}
for (j = 0; j < i; j++) {
printf("Case %d: %d\n", j + 1, x[j]);
}
retur... | s344526598 | [
{
"input": "3\n5\n11\n7\n8\n19\n0\n",
"output": "Case 1: 3\nCase 2: 5\nCase 3: 11\nCase 4: 7\nCase 5: 8\nCase 6: 19\n"
}
] |
C | codenet | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node {
int key;
struct node *next;
struct node *prev;
};
typedef struct node *NodePointer;
NodePointer N;
void init() {
N = malloc(sizeof(struct node));
N->next = N;
N->prev = N;
}
void printList() {
NodePointer cur = N->n... | s997849905 | [
{
"input": "7\ninsert 5\ninsert 2\ninsert 3\ninsert 1\ndelete 3\ninsert 6\ndelete 5\n",
"output": "6 1 2\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int a, b, c, d;
scanf("%d %d", &a, &b);
c = a * b;
d = 2 * a + 2 * b;
printf("%d %d\n", c, d);
return 0;
} | s502470583 | [
{
"input": "3 5\n",
"output": "15 16\n"
}
] |
C | codenet | #include <stdio.h>
void kansu(int, int);
int main(void) {
int a, b;
scanf("%d %d", &a, &b);
while (a != 0 && b != 0) {
kansu(a, b);
scanf("%d %d", &a, &b);
}
return 0;
}
void kansu(int a, int b) {
int i, j, x, y, n;
int suu[17][17];
int kouji[17][17];
scanf("%d", ... | s962042834 | [
{
"input": "5 4\n3\n2 2\n2 3\n4 2\n5 4\n3\n2 2\n2 3\n4 2\n0 0\n",
"output": "5\n5\n"
}
] |
C | codenet | #include <stdio.h>
int main(void) {
double a;
double ave = 0;
int i;
for (i = 0; i < 5; i++) {
scanf("%lf", &a);
if (a <= 40) {
ave += 40;
} else {
ave += a;
}
}
ave /= 5.0;
printf("%.0f\n", ave);
return (0);
} | s933220798 | [
{
"input": "10\n65\n100\n30\n95\n",
"output": "68\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int n, i, j, m, s, t;
scanf("%d", &n);
int a[n];
for (i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
t = 0;
for (i = 0; i < n; i++) {
s = 0;
for (j = 1; j < n; j++) {
if (j <= i) {
continue;
}
... | s608809394 | [
{
"input": "3\n3 1 2\n",
"output": "11\n"
}
] |
C | codenet | #include <stdio.h>
int W, N;
int input[1024][2];
int main() {
int i, j;
int ans[1024][2];
int t;
for (t = 0;; t++) {
for (i = 0; i < 1024; i++) {
ans[i][0] = 0;
ans[i][1] = 0;
input[i][0] = 0;
input[i][1] = 0;
}
scanf("%d%d", &W... | s001352307 | [
{
"input": "50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n0\n",
"output": "Case 1:\n220\n49\nCase 2:\n220\n49\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
long long n, a, m, M, c, b, i;
c = 0;
m = 100000000;
M = -100000000;
scanf("%lld", &n);
for (i = 1; i <= n; i++) {
scanf("%lld", &a);
if (a > M) {
M = a;
}
if (a < m) {
m = a;
}
c = c + a;
... | s105543399 | [
{
"input": "5\n10 1 5 4 17\n",
"output": "1 17 37\n"
}
] |
C | codenet | #include <stdio.h>
void swap(int *a, int *b) {
int tmp;
tmp = *a;
*a = *b;
*b = tmp;
}
int main() {
int a, b;
while (1) {
scanf("%d %d", &a, &b);
if (a == 0 && b == 0) break;
if (b < a) swap(&a, &b);
printf("%d %d\n", a, b);
}
return 0;
} | s123216992 | [
{
"input": "3 2\n2 2\n5 3\n0 0\n",
"output": "2 3\n2 2\n3 5\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
double r;
double s, l;
double p = 3.141592653589;
scanf("%lf", &r);
s = r * r * p;
l = 2 * p * r;
printf("%f %f\n", s, l);
return 0;
} | s264203612 | [
{
"input": "2\n",
"output": "12.566371 12.566371\n"
}
] |
C | codenet | #include <stdio.h>
#define MAX 101
#define WHITE 0
#define BLACK 2
#define GRAY 1
int time, n, g[MAX][MAX] = {0};
int d[MAX], f[MAX], color[MAX] = {WHITE};
void visit(int u) {
int i;
color[u] = GRAY;
d[u] = ++time;
for (i = 0; i < n; i++) {
if (g[u][i] == 0) continue;
if (color[i] == ... | s375567191 | [
{
"input": "4\n1 1 2\n2 1 4\n3 0\n4 1 3\n",
"output": "1 1 8\n2 2 7\n3 4 5\n4 3 6\n"
}
] |
C | codenet | #include <stdio.h>
int main() {
int x;
scanf("%d", &x);
x = x * x * x;
printf("%d\n", x);
return 0;
} | s764865959 | [
{
"input": "2\n",
"output": "8\n"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.