Datasets:

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> int main() { int hcell, wcell, hpaint, wpaint, nblack, nwhite; scanf("%d %d", &hcell, &wcell); scanf("%d %d", &hpaint, &wpaint); nblack = (wcell * hpaint) + (hcell * wpaint) - (hpaint * wpaint); nwhite = (hcell * wcell) - nblack; printf("%d\n", nwhite); return 0; }
s722111534
[ { "input": "3 2\n2 1\n", "output": "1\n" } ]
C
codenet
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int n, i; int h[100001]; int max = -1; int flag = 0; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &h[i]); if (max < h[i]) max = h[i]; if (max - h[i] >= 2) flag = 1; } if (flag =...
s628392045
[ { "input": "5\n1 2 1 1 3\n", "output": "Yes\n" } ]
C
codenet
#include <stdio.h> int main() { int a, b; scanf("%d %d", &a, &b); printf("%d\n", ((b - 1) + (a - 2)) / (a - 1)); return 0; }
s784438440
[ { "input": "4 10\n", "output": "3\n" } ]
C
codenet
#include <stdio.h> int main(void) { int A, B, C; scanf("%d %d %d", &A, &B, &C); if (A < C && C < B) { printf("Yes\n"); } else if (A > C && C > B) { printf("Yes\n"); } else { printf("No\n"); } }
s423495369
[ { "input": "3 8 5\n", "output": "Yes\n" } ]
C
codenet
#include <stdio.h> int main() { const int MAX_V = 999999; int prime[MAX_V + 1]; int i, k, n; for (i = 2; i <= MAX_V; i++) { prime[i] = 1; } for (i = 2; i * i <= MAX_V; i++) { if (prime[i]) { for (k = 2 * i; k <= MAX_V; k += i) { prime[k] = 0; ...
s764427553
[ { "input": "10\n3\n11\n", "output": "4\n2\n5\n" } ]
C
codenet
#include <stdio.h> int main(void) { int v[10]; int sum = 0; int i; for (i = 0; i < 10; i++) scanf("%d", &v[i]); for (i = 0; i < 10; i++) sum += v[i]; printf("%d\n", sum); return 0; }
s639919182
[ { "input": "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", "output": "55\n" } ]
C
codenet
#include <stdio.h> #include <stdlib.h> #define unko 1e12 long int sort(long int *a, int left, int middle, int right) { long int l_arr[middle - left + 1], r_arr[right - middle + 1]; long int cnt = 0; for (int i = 0; i < middle - left; i++) l_arr[i] = a[i + left]; for (int i = 0; i < right - middle; i++) ...
s619964871
[ { "input": "5\n3 5 2 1 4\n", "output": "6\n" } ]
C
codenet
#include <stdio.h> int main(void) { int a, b; scanf("%d", &a); scanf("%d", &b); if ((a * b) % 2 == 0) { printf("Even\n"); } else { printf("Odd\n"); } return 0; }
s797932052
[ { "input": "3 4\n", "output": "Even\n" } ]
C
codenet
#include <stdio.h> void white(int n, int A[]) { int i; for (i = 0; i < n - 1; i++) { printf("%d ", A[i]); } printf("%d\n", A[i]); } void insertionsort(int n, int A[]) { int i, j, a; for (i = 0; i < n; i++) { for (j = 0; j < i; j++) { if (A[i] < A[j]) { ...
s606068991
[ { "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
#if 0 cat <<EOF >mistaken-paste #endif #pragma GCC diagnostic ignored "-Wincompatible-pointer-types" #define _USE_MATH_DEFINES #include <math.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #define BIG 2000000007 #define VERYBIG 200000000000000...
s327468529
[ { "input": "3\nRRRGGGBBB\n", "output": "216\n" } ]
C
codenet
#include <stdio.h> int main() { int a, b, c; scanf("%d%d%d", &a, &b, &c); if (a < b && b < c) { printf("Yes\n"); } else { printf("No\n"); } return 0; }
s701648392
[ { "input": "1 3 8\n", "output": "Yes\n" } ]
C
codenet
#include <stdio.h> #include <string.h> int main(int argc, char *argv[]) { char buf[512]; int len; fgets(buf, sizeof(buf), stdin); len = strlen(buf); printf("%c%d%c\n", buf[0], len - 3, buf[len - 2]); return 0; }
s343830814
[ { "input": "internationalization\n", "output": "i18n\n" } ]
C
codenet
#include <stdio.h> int main() { int i = 1, Input; while (1) { scanf("%d", &Input); if (Input == 0) { break; } printf("Case %d: %d\n", i, Input); i++; } return 0; }
s858832157
[ { "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 <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int i_min, min; int i, j, k; int X, N; scanf("%d %d", &X, &N); if (N == 0) { printf("%d\n", X); exit(0); } int plus[256]; int minus[256]; for (i = 0; i < 256; i++) { pl...
s735953430
[ { "input": "6 5\n4 7 10 6 5\n", "output": "8\n" } ]
C
codenet
#include <stdio.h> #include <string.h> int calc_score() { int out = 0; char str[100]; int score = 0; int base = 0; while (out < 3) { scanf("%s", str); if (strcmp(str, "OUT") == 0) { out++; } else if (strcmp(str, "HIT") == 0) { if (base == 3) { ...
s435885409
[ { "input": "2\nHIT\nOUT\nHOMERUN\nHIT\nHIT\nHOMERUN\nHIT\nOUT\nHIT\nHIT\nHIT\nHIT\nOUT\nHIT\nHIT\nOUT\nHIT\nOUT\nOUT\n", "output": "7\n0\n" } ]
C
codenet
#include <assert.h> #include <ctype.h> #include <math.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> typedef long long ll; typedef long double ld; #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 rrep(i, l, r) fo...
s325320702
[ { "input": "5 10 2\n", "output": "3\n" } ]
C
codenet
#include <stdio.h> int main() { char m; int a, b, c[256], i, j; for (i = 0; i > -1; i++) { scanf("%d %c %d", &a, &m, &b); if (m == '?') { break; } if (m == '+') { c[i] = a + b; } if (m == '-') { c[i] = a - b; } ...
s647939399
[ { "input": "1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0\n", "output": "3\n38\n26\n10\n108\n" } ]
C
codenet
#include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define max(a, b) ((a) > (b) ? (a) : (b)) #define min(a, b) ((a) > (b) ? (b) : (a)) int get_int4(int *a1, int *a2, int *a3, int *a4) { scanf("%d %d %d %d", a1, a2, a3, a4); return 0; } int fget_array(int64_t *arr, int size) { ...
s171933389
[ { "input": "2 2 2 8\n4 6\n1 5\n3 8\n", "output": "19\n17\n15\n14\n13\n12\n10\n8\n" } ]
C
codenet
#include <stdio.h> int main() { int a, b, c; char op; scanf("%d %c %d", &a, &op, &b); while (1) { if (op == '+') { c = a + b; printf("%d\n", c); } else if (op == '-') { c = a - b; printf("%d\n", c); } else if (op == '*') { ...
s910176756
[ { "input": "1 + 2\n56 - 18\n13 * 2\n100 / 10\n27 + 81\n0 ? 0\n", "output": "3\n38\n26\n10\n108\n" } ]
C
codenet
#include <stdio.h> #define N 4 typedef struct { int P[N][N]; } Pazz; Pazz Q; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; int Heu(Pazz Q) { int i, j; int hx, hy, sum = 0; for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { if (Q.P[i][j] == 0) continue; hx = (...
s858559569
[ { "input": "1 2 3 4\n6 7 8 0\n5 10 11 12\n9 13 14 15\n", "output": "8\n" } ]
C
codenet
#include <stdio.h> int main() { int n, fd[6] = {}, i, j; double height; scanf("%d", &n); while (n--) { scanf("%lf", &height); if (height >= 185.0) fd[5]++; else if (height >= 180.0) fd[4]++; else if (height >= 175.0) fd[3]++; ...
s866461201
[ { "input": "4\n180.3\n168.2\n165.5\n175.3\n", "output": "1:\n2:**\n3:\n4:*\n5:*\n6:\n" } ]
C
codenet
#include <math.h> #include <stdio.h> #include <stdlib.h> typedef long long int int64; #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define ABS(a) ((a) > (0) ? (a) : -(a)) int digit(int64 n) { int res = 0; while (n > 0) { res++; n /= 10; } return ...
s105551633
[ { "input": "10000\n", "output": "3\n" } ]
C
codenet
#include <stdio.h> int main() { int n; scanf("%d", &n); if (n % 1000 == 0) printf("%d\n", 0); else printf("%d\n", (n / 1000 + 1) * 1000 - n); }
s572139754
[ { "input": "1900\n", "output": "100\n" } ]
C
codenet
#include <stdio.h> int main() { int a[1000], n, i, j, d = 0; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &a[i]); for (i = 0; i < n; i++) { for (j = n - 1; j >= i + 1; j--) { if (a[j] < a[j - 1]) { int temp = a[j]; a[j] = a[j - 1]; ...
s772119380
[ { "input": "5\n5 3 2 4 1\n", "output": "1 2 3 4 5\n8\n" } ]
C
codenet
#include <stdio.h> #include <string.h> int data[111111]; int seq[222222]; int max(int a, int b); int main(void) { int n, k, t, i, p, ret = 0; while (1) { scanf("%d %d", &n, &k); if (!n && !k) break; memset(data, 0, sizeof(data)); memset(seq, 0, sizeof(seq)); for (i ...
s286163362
[ { "input": "7 5\n6\n2\n4\n7\n1\n7 5\n6\n2\n0\n4\n7\n0 0\n", "output": "2\n4\n" } ]
C
codenet
#include <stdio.h> #define N 200 #define SHIRO 0 #define HAI 1 #define KURO 2 void aaaaa(); void bbbbb(int); int n, A[N][N]; int color[N], d[N], f[N]; int TT; int main() { int u, k, v; int i, j; scanf("%d", &n); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { A[i][j] = 0; ...
s419237275
[ { "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(void) { int n; unsigned long long int m; scanf("%d", &n); m = n; n--; for (; n > 1; n--) { m *= n; } printf("%lld\n", m); return 0; }
s792612560
[ { "input": "5\n", "output": "120\n" } ]
C
codenet
#include <stdio.h> int main(void) { int S; scanf("%d", &S); if (S < 60) { printf("0:0:%d\n", S); } else if (S < 3600) { printf("0:%d:%d\n", (int)S / 60, S % 60); } else { printf("%d:%d:%d\n", (int)S / 3600, (int)(S % 3600) / 60, (S % 60) % 60); ...
s891514124
[ { "input": "46979\n", "output": "13:2:59\n" } ]
C
codenet
#include <stdio.h> int main() { int N = 0; int R = 0; scanf("%d %d", &N, &R); if (N >= 10) { printf("%d\n", R); } else { printf("%d\n", R + 100 * (10 - N)); } return 0; }
s541856674
[ { "input": "2 2919\n", "output": "3719\n" } ]
C
codenet
#include <stdio.h> #include <stdlib.h> int top, S[10000]; void push(int x) { S[++top] = x; } int pop() { return S[top--]; } int main() { int a, b; char s[200]; top = 0; while (scanf("%s", s) != EOF) { if (s[0] == '+') { b = pop(); a = pop(); push(a + b); ...
s646324174
[ { "input": "1 2 +\n", "output": "3\n" } ]
C
codenet
#include <stdio.h> int main(void) { int i, a, b, s; int count[4]; for (i = 0; i < 4; i++) count[i] = 0; for (i = 0; i < 3; i++) { scanf("%d %d", &a, &b); count[a - 1]++; count[b - 1]++; } s = 1; for (i = 0; i < 4; i++) s *= count[i]; if (s == 4) printf("Y...
s224842101
[ { "input": "4 2\n1 3\n2 3\n", "output": "YES\n" } ]
C
codenet
#include <stdio.h> int main(void) { int a, b, c; scanf("%d %d %d", &a, &b, &c); if (b > a * c) { printf("%d\n", c); } else { printf("%d\n", b / a); } return 0; }
s811544640
[ { "input": "2 11 4\n", "output": "4\n" } ]
C
codenet
#include <stdio.h> int main(void) { int n, k; scanf("%d%d", &n, &k); if (n % k == 0) printf("0\n"); else printf("1\n"); return 0; }
s536445669
[ { "input": "7 3\n", "output": "1\n" } ]
C
codenet
#include <stdio.h> int main() { int m, n; int i, j; int A[100][100]; int B[100]; int S[100] = {0}; scanf("%d %d", &m, &n); for (i = 0; i < m; i++) { for (j = 0; j < n - 1; j++) { scanf("%d ", &A[i][j]); } scanf("%d\n", &A[i][n - 1]); } for (i = ...
s327850243
[ { "input": "3 4\n1 2 0 1\n0 3 0 1\n4 1 1 0\n1\n2\n3\n0\n", "output": "5\n6\n9\n" } ]
C
codenet
#include <stdio.h> int A[1000000], n; int binarySearch(int key) { int left = 0; int right = n; int mid; while (left < right) { mid = (left + right) / 2; if (key == A[mid]) return 1; if (key > A[mid]) left = mid + 1; else if (key < A[mid]) right =...
s784517449
[ { "input": "5\n1 2 3 4 5\n3\n3 4 1\n", "output": "3\n" } ]
C
codenet
#include <stdio.h> int main() { int in; int h, m, s; scanf("%d", &in); h = in / 3600; in %= 3600; m = in / 60; in %= 60; s = in; printf("%d:%d:%d\n", h, m, s); }
s821904390
[ { "input": "46979\n", "output": "13:2:59\n" } ]
C
codenet
#include <stdio.h> #include <stdlib.h> #define NIL NULL typedef struct node { int key; int priority; struct node *right, *left; } Node; Node *Delete(Node **, int); Node *delete(Node **, int); int find(Node *p, int x) { while (p != NIL) { if (p->key == x) return 1; else if ...
s654514838
[ { "input": "16\ninsert 35 99\ninsert 3 80\ninsert 1 53\ninsert 14 25\ninsert 80 76\ninsert 42 3\ninsert 86 47\ninsert 21 12\ninsert 7 10\ninsert 6 90\nprint\nfind 21\nfind 22\ndelete 35\ndelete 99\nprint\n", "output": " 1 3 6 7 14 21 35 42 80 86\n 35 6 3 1 14 7 21 80 42 86\nyes\nno\n 1 3 6 7 14 21 42 80 86\...
C
codenet
#include <stdio.h> int main(void) { char s[4], t[4]; scanf("%s", s); scanf("%s", t); int hit = 0; for (int i = 0; i < 3; i++) { if (s[i] == t[i]) hit++; } printf("%d\n", hit); return 0; }
s878644875
[ { "input": "CSS\nCSR\n", "output": "2\n" } ]
C
codenet
#include <stdio.h> int main() { int r, c, n, flag, cnt; int arr[16][16] = {0}; while (1) { scanf("%d", &n); if (n == 0) { break; } flag = 1; r = (n + 1) / 2 + 1; c = (n + 1) / 2; arr[r][c] = cnt = 1; while (cnt != n * n + 1) { ...
s310320755
[ { "input": "3\n5\n0\n", "output": " 4 9 2\n 3 5 7\n 8 1 6\n 11 24 7 20 3\n 4 12 25 8 16\n 17 5 13 21 9\n 10 18 1 14 22\n 23 6 19 2 15\n" } ]
C
codenet
#include <stdio.h> int main(void) { int n, sum; scanf("%d", &n); sum = (n * (n + 1)) / 2; printf("%d\n", sum); return 0; }
s972081311
[ { "input": "3\n", "output": "6\n" } ]
C
codenet
#include <stdio.h> int c[26]; int main(void) { char str[1200]; for (; scanf("%s", str) > 0;) { for (char *p = str; *p; p++) { if ('a' <= *p && *p <= 'z') { c[*p - 'a']++; } else if ('A' <= *p && *p <= 'Z') { c[*p - 'A']++; } }...
s387232787
[ { "input": "This is a pen.\n", "output": "a : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0\n" } ]
C
codenet
#include <stdio.h> #define PutChar(c) \ ; \ *p = (char)(c); \ ++p; #define MAX_N (2000001) #define MAX_Ai (10001) #define STR_SIZE (10000010) int getNum(void); void putNum(int n); void CountingSort(int A[], int B[], int k, int len); int A[MAX_N]; int B[MAX_N]; char str[STR_SIZE]; char *p ...
s776764195
[ { "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 M 100 #define whi 0 #define gra 1 #define bla 2 int n; int T[M][M]; int color[M], d[M]; int Q[M], head = 0, tail = 0; void enqueue(int x) { Q[tail] = x; tail = (tail + 1) % M; } int dequeue(void) { int x; x = Q[head]; head = (head + 1) % M; return x; } void bfs(in...
s869953757
[ { "input": "4\n1 2 2 4\n2 1 4\n3 0\n4 1 3\n", "output": "1 0\n2 1\n3 2\n4 1\n" } ]
C
codenet
#pragma warning(disable : 4996) #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_STRING 30 #define MAX_LINE 2000000 #define MAX_HUMAN 200000 char sLongInputLine[MAX_LINE + 1] = ""; int anComingSec[MAX_HUMAN]; int main() { char sInput[MAX_STRING + 1] = ""; char* psWord =...
s418782460
[ { "input": "2 4\n0 3\n", "output": "7\n" } ]
C
codenet
#include <float.h> #include <inttypes.h> #include <limits.h> #include <math.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #ifdef __cplusplus #include <bits/stdc++.h> #endif int32_t nextint(void) { char c = getchar_unlock...
s977214798
[ { "input": "3\n2 3\n1 3\n1 2\n", "output": "3\n" } ]
C
codenet
#include <stdio.h> #define NIL -1 struct Node { int parent, left, right; }; struct Node R[10000]; int n; void preorder(int); void inorder(int); void postorder(int); void preorder(int x) { if (x == NIL) return; printf(" %d", x); preorder(R[x].left); preorder(R[x].right); } void inorder(int x) { ...
s167283321
[ { "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> main() { int a, b, mawari, menseki; scanf("%d %d", &a, &b); mawari = a + a + b + b; menseki = a * b; printf("%d %d\n", menseki, mawari); return 0; }
s033933040
[ { "input": "3 5\n", "output": "15 16\n" } ]
C
codenet
#include <stdio.h> int main() { long int n, k, q; scanf("%ld%ld%ld", &n, &k, &q); int arr[n]; for (long int i = 0; i <= n; i++) { arr[i] = 0; } for (long int i = 0; i < q; i++) { long int temp; scanf("%ld", &temp); arr[temp] += 1; } for (long int i = ...
s648501684
[ { "input": "6 3 4\n3\n1\n3\n2\n", "output": "No\nNo\nYes\nNo\nNo\nNo\n" } ]
C
codenet
#include <stdio.h> int main() { int a, b, c, x, y; scanf("%d%d%d%d%d", &a, &b, &c, &x, &y); c *= 2; if (a + b <= c) printf("%d\n", a * x + b * y); else { if (x <= y) { if (b <= c) printf("%d\n", c * x + (y - x) * b); else printf...
s999424066
[ { "input": "1500 2000 1600 3 2\n", "output": "7900\n" } ]
C
codenet
#include <stdio.h> #include <stdlib.h> struct node { int key; struct node *p; struct node *l; struct node *r; }; typedef struct node *NodePointer; NodePointer r, NIL; NodePointer find(NodePointer x, int k) { while (x != NIL && k != x->key) { if (k < x->key) { x = x->l; ...
s108384974
[ { "input": "10\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\nfind 12\ninsert 17\ninsert 25\nfind 16\nprint\n", "output": "yes\nno\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n" } ]
C
codenet
#include <ctype.h> #include <stdio.h> int main() { int i, alpha[26]; char ch; for (i = 0; i < 26; i++) alpha[i] = 0; while (1) { ch = getchar(); if (ch == EOF) break; if (isalpha(ch)) { if (isupper(ch)) alpha[ch - 65]++; else ...
s476941540
[ { "input": "This is a pen.\n", "output": "a : 1\nb : 0\nc : 0\nd : 0\ne : 1\nf : 0\ng : 0\nh : 1\ni : 2\nj : 0\nk : 0\nl : 0\nm : 0\nn : 1\no : 0\np : 1\nq : 0\nr : 0\ns : 2\nt : 1\nu : 0\nv : 0\nw : 0\nx : 0\ny : 0\nz : 0\n" } ]
C
codenet
#include <stdio.h> int linersearch(int[], int, int); int main() { int i, n, s[100000], q, t, count = 0; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &s[i]); } scanf("%d", &q); for (i = 0; i < q; i++) { scanf("%d", &t); if (linersearch(s, n, t)) count++; ...
s846328722
[ { "input": "5\n1 2 3 4 5\n3\n3 4 1\n", "output": "3\n" } ]
C
codenet
#include <ctype.h> #include <inttypes.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <wchar.h> #define N_MAX (100) #define P_MAX (100) #define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ...
s484809551
[ { "input": "keyofscience\n", "output": "YES\n" } ]
C
codenet
#include <stdbool.h> #include <stdio.h> int main() { int n, a[100000], cnt = 1; bool isup; bool issame = false; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } if (a[0] < a[1]) isup = true; else if (a[0] > a[1]) isup = false; else ...
s990550009
[ { "input": "6\n1 2 3 2 2 1\n", "output": "2\n" } ]
C
codenet
#include <stdio.h> #include <stdlib.h> int main() { int n; int *data; scanf("%d\n", &n); data = (int *)malloc(sizeof(int) * n); for (int i = 0; i < n; i++) scanf("%d", &data[i]); int max = 0, index; for (int i = 0; i < n; i++) if (data[i] > max) { max = data[i]; ...
s030068105
[ { "input": "4\n3 8 5 1\n", "output": "Yes\n" } ]
C
codenet
#include <stdio.h> int main() { int i, j, max, max_j, buf; int io[5]; scanf("%d %d %d %d %d", &io[0], &io[1], &io[2], &io[3], &io[4]); for (i = 0; i < 5; i++) { max = io[i]; max_j = i; for (j = i + 1; j < 5; j++) { if (max < io[j]) { max = io[j]; ...
s764482816
[ { "input": "3 6 9 7 5\n", "output": "9 7 6 5 3\n" } ]
C
codenet
#include <stdio.h> int main() { int a[3], b[3]; int c[3][3]; int i, j; for (i = 0; i < 3; i++) { scanf("%d%d%d", &c[i][0], &c[i][1], &c[i][2]); } a[0] = 0; for (i = 0; i < 3; i++) { b[i] = c[0][i]; } for (i = 1; i < 3; i++) { a[i] = c[i][0] - b[0]; } f...
s616182260
[ { "input": "1 0 1\n2 1 2\n1 0 1\n", "output": "Yes\n" } ]
C
codenet
#include <stdio.h> #include <string.h> char str1[100], str2[100], temp[100]; int main() { int i, j = 0, t; scanf("%s[^\n]", str1); scanf("%s[^\n]", str2); i = strlen(str1); t = i - 1; if (strlen(str1) != strlen(str2)) { printf("NO\n"); } else { while (str1[j] != '\0') { ...
s670350109
[ { "input": "pot\ntop\n", "output": "YES\n" } ]
C
codenet
#include <stdbool.h> #include <stdio.h> int a[200000], tmpa[200000], light[200010] = {0}; typedef long long ll; int main() { int n, k; scanf("%d%d", &n, &k); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } for (int i = 0; i < n; i++) { int r, l; r = i - a[i]; l =...
s500706216
[ { "input": "5 1\n1 0 0 1 0\n", "output": "1 2 2 1 2\n" } ]
C
codenet
#include <stdio.h> int main() { int n, k, cnt; scanf("%d%d", &n, &k); cnt = 0; while (n--) { int h; scanf("%d", &h); if (h >= k) cnt++; } printf("%d\n", cnt); return 0; }
s992866158
[ { "input": "4 150\n150 140 100 200\n", "output": "2\n" } ]
C
codenet
#include <limits.h> #include <math.h> #include <memory.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]) { int a, b; int ans; scanf("%d %d", &a, &b); ans = 0; if (a >= 13) { ans = b; } else if (a >= 6) { ans = b / 2; } prin...
s305455869
[ { "input": "30 100\n", "output": "100\n" } ]
C
codenet
#include <stdio.h> typedef struct { char s; int v; } card; card L[100000 / 2 + 2], R[100000 / 2 + 2]; void me(card *a, int n, int l, int m, int r) { int i, j, k; int n1 = m - l; int n2 = r - m; for (i = 0; i < n1; i++) L[i] = a[l + i]; for (i = 0; i < n2; i++) R[i] = a[m + i]; L[n1]....
s427349585
[ { "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 a, b, x, y; scanf("%d%d", &a, &b); x = 2 * a + 2 * b; y = a * b; printf("%d %d\n", y, x); return 0; }
s008026706
[ { "input": "3 5\n", "output": "15 16\n" } ]
C
codenet
#include <stdio.h> int you(int, int); int main() { int x, y, z; scanf("%d %d", &x, &y); if (x >= y) z = you(x, y); else z = you(y, x); printf("%d\n", z); return 0; } int you(int x, int y) { int z; while (1) { z = x % y; x = y; y = z; if (y...
s400285050
[ { "input": "54 20\n", "output": "2\n" } ]
C
codenet
#include <stdio.h> int main() { int n, l[2001], i, j, k, cnt = 0, tmp = 0; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%d", &l[i]); } for (i = 0; i < n - 1; i++) { for (j = i + 1; j < n; j++) { if (l[j] < l[i]) { tmp = l[i]; l[i] = l[...
s401511324
[ { "input": "4\n3 4 2 1\n", "output": "1\n" } ]
C
codenet
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX(X, Y) (((X) > (Y)) ? (X) : (Y)) #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) int compare_int(const void *a, const void *b) { return *(long int *)b - *(long int *)a; } long int gcd(long int a, long int b) { if (b == 0) { ...
s497487985
[ { "input": "6 3 4\n3\n1\n3\n2\n", "output": "No\nNo\nYes\nNo\nNo\nNo\n" } ]
C
codenet
#include <stdio.h> int main() { int K, X; scanf("%d %d", &K, &X); for (int i = X - K + 1; i <= X + K - 1; i++) { printf("%d", i); if (i < X + K - 1) printf(" "); } printf("\n"); return 0; }
s844088973
[ { "input": "3 7\n", "output": "5 6 7 8 9\n" } ]
C
codenet
#include <stdio.h> int main(void) { int sheep; int wolf; scanf("%d %d", &sheep, &wolf); if (wolf >= sheep) { printf("unsafe\n"); } else { printf("safe\n"); } return 0; }
s736909850
[ { "input": "4 5\n", "output": "unsafe\n" } ]
C
codenet
#include <stdio.h> int main(void) { int i, N, x; x = 0; scanf("%d", &N); for (i = 1; i <= N; i++) x += i; printf("%d\n", x); return 0; }
s982114524
[ { "input": "3\n", "output": "6\n" } ]
C
codenet
#include <stdio.h> #define MAX 100005 #define N 100 typedef struct { char name[N]; int t; } P; P Q[MAX + 1]; int head, tail; void Enqueue(P x) { if (MAX == tail) tail = 0; Q[tail] = x; tail++; } P Dequeue(void) { if (head == MAX) head = 0; return Q[head++]; } int main() { int i, q,...
s805240083
[ { "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> signed main() { int n, k, p[99999], i, j, l, m, o = 0; scanf("%d %d", &n, &k); for (i = 0; i < n; i++) { scanf("%d", &p[i]); } for (i = 0; i < n; i++) { l = i; for (j = i + 1; j < n; j++) { if (p[j] < p[l]) { l = j; }...
s180134172
[ { "input": "5 3\n50 100 80 120 80\n", "output": "210\n" } ]
C
codenet
#include <stdio.h> int main(void) { long sum = 0; int m, n, i, min, max; scanf("%d\n", &n); for (i = 0; i < n; i++) { scanf("%d", &m); sum += m; if (i == 0) { min = m; max = m; } if (min > m) { min = m; } if (ma...
s859058692
[ { "input": "5\n10 1 5 4 17\n", "output": "1 17 37\n" } ]
C
codenet
#include <stdio.h> int main(void) { int c[3]; while (scanf("%d %d %d", &c[0], &c[1], &c[2]) != EOF) { char card[10] = {0}; int i; int count = 0; int sum = c[0] + c[1]; for (i = 0; i < 3; i++) { card[c[i] - 1] = 1; } for (i = 0; i < 10; i++) ...
s405782513
[ { "input": "1 2 3\n5 6 9\n8 9 10\n", "output": "YES\nYES\nNO\n" } ]
C
codenet
#include <stdio.h> int main(void) { int a, b, c, i, count; scanf("%d%d%d", &a, &b, &c); count = 0; for (i = a; i <= b; i++) { if (c % i == 0) count++; } printf("%d\n", count); return 0; }
s201325376
[ { "input": "5 14 80\n", "output": "3\n" } ]
C
codenet
#include <stdio.h> int main() { int a, b, x, y; scanf("%d%d", &a, &b); x = a * b; y = (a + b) * 2; printf("%d %d\n", x, y); return 0; }
s912810100
[ { "input": "3 5\n", "output": "15 16\n" } ]
C
codenet
#include <stdio.h> int compare(int *a, int *b) { return (*b - *a); } int main(void) { int array[10], i; for (i = 0; i != 10; i++) scanf("%d", array + i); qsort(array, 10, sizeof(int), compare); for (i = 0; i != 3; i++) printf("%d\n", array[i]); return 0; }
s044733418
[ { "input": "1819\n2003\n876\n2840\n1723\n1673\n3776\n2848\n1592\n922\n", "output": "3776\n2848\n2840\n" } ]
C
codenet
#include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define ll long long void swap(int *x, int *y) { int temp; temp = *x; *x = *y; *y = temp; return; } long int gcd(long int a, long int b) { long int c; while (b > 0) { c = a % b; a = b; ...
s874174693
[ { "input": "12\n", "output": "Yes\n" } ]
C
codenet
#include <stdio.h> int main() { int a, b, ar, le; scanf("%d %d", &a, &b); ar = a * b; le = 2 * (a + b); printf("%d %d\n", ar, le); return 0; }
s746638117
[ { "input": "3 5\n", "output": "15 16\n" } ]
C
codenet
#include <stdio.h> #include <stdlib.h> int chmin(int a, int b) { if (a > b) return b; else return a; } int main(int argc, char const *argv[]) { int n; scanf("%d", &n); int dp[n]; int h[n]; for (int i = 0; i < n; ++i) dp[i] = 10000; for (int i = 0; i < n; ++i) scanf("%d...
s762058481
[ { "input": "4\n10 30 40 20\n", "output": "30\n" } ]
C
codenet
#include <stdio.h> int main() { int a, b; scanf("%d %d", &a, &b); printf("%d %d\n", a * b, 2 * (a + b)); return 0; }
s012871529
[ { "input": "3 5\n", "output": "15 16\n" } ]
C
codenet
#include <stdio.h> #include <string.h> int main() { char mes[101]; scanf("%s", mes); printf("%c%lu%c\n", mes[0], strlen(mes) - 2, mes[strlen(mes) - 1]); return 0; }
s116510273
[ { "input": "internationalization\n", "output": "i18n\n" } ]
C
codenet
#include <stdio.h> int main() { unsigned long long int n, a, b = 0, i, j; scanf("%llu", &n); b = (n * (n - 1)) / 2; printf("%llu\n", b); return 0; }
s497921090
[ { "input": "2\n", "output": "1\n" } ]
C
codenet
#include <stdio.h> int main(void) { int n, r, p, c; int i, j, k, l; int a[51], b[51]; while (1) { scanf("%d %d ", &n, &r); if (!n && !r) break; for (i = 0; i < n; i++) a[i] = i + 1; for (i = 0; i < r; i++) { scanf("%d %d ", &p, &c); for (j = 0;...
s403900151
[ { "input": "5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n", "output": "4\n4\n" } ]
C
codenet
#include <stdio.h> int main(void) { int x; scanf("%d", &x); if (x == 0) printf("1\n"); if (x == 1) printf("0\n"); return 0; }
s113351650
[ { "input": "1\n", "output": "0\n" } ]
C
codenet
#include <stdio.h> int main(void) { int x; scanf("%d", &x); printf("%d\n", x * x * x); return 0; }
s132873327
[ { "input": "2\n", "output": "8\n" } ]
C
codenet
#include <stdio.h> #include <stdlib.h> int main() { int a, c, k, b; while (~scanf("%d", &a)) { c = 0, k = 0; if (a < 3) printf("0\n"); else { b = a; while (a--) { b--; c++; if (c == 3) { ...
s326049239
[ { "input": "8\n", "output": "2\n" } ]
C
codenet
#include <stdio.h> int main() { int n; long sum = 0; scanf("%d", &n); int a[n]; for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } for (int i = 1; i < n; i++) { if (a[i - 1] > a[i]) { sum += a[i - 1] - a[i]; a[i] = a[i - 1]; } } printf...
s986241762
[ { "input": "5\n2 1 5 4 3\n", "output": "4\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 key) { NodePointer cur = nil->next; while (cur != nil) { if (cur->key == key) ...
s858205159
[ { "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> #include <stdlib.h> int *flag; void prime(int num) { int i, j; flag = (int *)calloc(sizeof(int), num + 1); for (i = 2; i * i <= num; i++) { if (flag[i] == 0) { for (j = 2; i * j <= num; j++) { flag[i * j] = 1; } } } } int ma...
s501370664
[ { "input": "10\n11\n0\n", "output": "2\n0\n" } ]
C
codenet
#include <stdio.h> int main() { int m1, d1, m2, d2; scanf("%d%d%d%d", &m1, &d1, &m2, &d2); if (m1 != m2) printf("1\n"); else printf("0\n"); }
s669832162
[ { "input": "11 16\n11 17\n", "output": "0\n" } ]
C
codenet
#include <stdio.h> #define LEN 300 #define TRUE 1 #define FALSE -1 int solve(int, int); int n, A[LEN]; int flag; int main() { int q, M; int i, j, k; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &A[i]); scanf("%d", &q); for (i = 0; i < q; i++) { scanf("%d", &M); flag =...
s157790373
[ { "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> int n, r, i, j, p, c; int a[100], b[100]; int main() { while (1) { scanf("%d %d", &n, &r); if (n == 0 && r == 0) break; for (i = 0; i < n; i++) { a[i] = n - i; } for (i = 0; i < r; i++) { for (j = 0; j < n; j++) { ...
s622875333
[ { "input": "5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n", "output": "4\n4\n" } ]
C
codenet
#include <stdio.h> int main(void) { long int n; scanf("%ld", &n); long int a[n]; long int count[n]; for (long int i = 1; i < n; i++) scanf("%ld", &a[i]); for (long int i = 0; i < n; i++) count[i] = 0; for (long int i = 1; i < n; i++) count[a[i] - 1]++; for (long int i = 0; i < n; i...
s044095882
[ { "input": "5\n1 1 2 2\n", "output": "2\n2\n0\n0\n0\n" } ]
C
codenet
#include <stdio.h> int main(void) { int N; scanf("%d", &N); int A[N + 1]; int B[N]; int i; for (i = 0; i < N + 1; i++) { scanf("%d", &A[i]); } for (i = 0; i < N; i++) { scanf("%d", &B[i]); } long ans = 0; for (i = 0; i < N; i++) { if (A[i] >= B[i...
s540088752
[ { "input": "2\n3 5 2\n4 5\n", "output": "9\n" } ]
C
codenet
#include <stdio.h> int main() { int a, b, c; scanf("%d %d %d", &a, &b, &c); if (a < b && b < c) { printf("Yes\n"); } else { printf("No\n"); } return 0; }
s120311699
[ { "input": "1 3 8\n", "output": "Yes\n" } ]
C
codenet
#include <stdio.h> int main() { int i, j, N, A[100], tmp, count = 0; scanf("%d", &N); for (i = 0; i < N; i++) { scanf("%d", &A[i]); } for (i = 0; i < N - 1; i++) { for (j = N - 1; j > i; j--) { if (A[j] < A[j - 1]) { tmp = A[j]; A[j] = ...
s977107185
[ { "input": "5\n5 3 2 4 1\n", "output": "1 2 3 4 5\n8\n" } ]
C
codenet
#include <stdio.h> int search(int A[], int n, int key) { int i = 0; A[n] = key; while (A[i] != key) i++; return i != n; } int main(void) { int n, A[10000 + 1], q, key, sum = 0; int i; scanf("%d", &n); for (i = 0; i < n; i++) scanf("%d", &A[i]); scanf("%d", &q); for (i = 0; i < ...
s858795471
[ { "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 c[11], ans[11] = {'\0'}; scanf("%s", c); for (int i = 0; c[i] != '\0'; i++) { if (c[i] != 'B') ans[strlen(ans)] = c[i]; else ans[strlen(ans) - 1] = '\0'; } printf("%s\n", ans); }
s352097291
[ { "input": "01B0\n", "output": "00\n" } ]
C
codenet
#include <stdio.h> int main() { int S; scanf("%d", &S); printf("%d:%d:%d\n", (int)(S / 3600), (int)((S % 3600) / 60), S % 60); return 0; }
s575722828
[ { "input": "46979\n", "output": "13:2:59\n" } ]
C
codenet
#include <stdio.h> #include <stdlib.h> void run(void) { int n, k; scanf("%d%d", &n, &k); int a[100]; int i, j; for (i = 0; i < n; i++) scanf("%d", a + i); int *dp = (int *)calloc(k + 1, sizeof(int)); for (i = 1; i <= k; i++) { int win = 0; for (j = 0; j < n && a[j] <= i; j++...
s436432602
[ { "input": "2 4\n2 3\n", "output": "First\n" } ]