source_code
stringlengths
26
62k
lang_cluster
stringclasses
11 values
src_uid
stringlengths
32
32
code_uid
stringlengths
32
32
difficulty
int32
-1
3.5k
โŒ€
exec_outcome
stringclasses
1 value
#include <string> #include <algorithm> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <map> #include <memory> #include <queue> #include <set> #include <sstream> #include <stack> #include ...
C++
0c9550a09f84de6bed529d007ccb4ae8
6e3b4b2d9190a7a1b2dbdaae0cbd3ecc
1,600
PASSED
#include <stdio.h> #include <string.h> char s[200000]; char t[200000]; int type[200000]; int gender[200000]; int no; int ends(char *t,char *u) { int l=strlen(t); int m=strlen(u); int i,j; if(m>l) return 0; for(j=0,i=l-m;i<l;i++,j++) if(t[i]!=u[j]) return 0; return 1; } int ismale(char *t) { if(ends(t,...
C
0c9550a09f84de6bed529d007ccb4ae8
4fa4ce70e6163139c6d707bf014d74c1
1,600
PASSED
#include <stdio.h> #include <string.h> int main() { char s[100005]; char c[100005]; char t[6][6] = {"lios", "liala", "etr", "etra", "initis", "inites"}; int x = 0, y = 0, z = 0, f = 0, i, j; int a[6] = {4, 5, 3, 4, 6, 6}; fgets(s, 100005, stdin); s[strlen(s) - 1] = '\0'; for ...
C
0c9550a09f84de6bed529d007ccb4ae8
985269844e29db9b97f6f8297dee2efa
1,600
PASSED
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #define MASCULINE 1 #define FEMININE 2 int check(char* input, char* s1, char *s2) { if (!strstr(input, s1) && !strstr(input, s2)) return 0; if (strstr(input, s1) != NULL) { if (strcmp(input + strlen(input) - strlen(s1), ...
C
0c9550a09f84de6bed529d007ccb4ae8
53a19ebf4935af4d0599748e696fe8e9
1,600
PASSED
#include <stdio.h> #include <string.h> // ๋‚จ์„ฑ / ์—ฌ์„ฑ // ํ˜•์šฉ์‚ฌ lios / liala // ๋ช…์‚ฌ etr / etra // ๋™์‚ฌ initis / inites // ??ํ˜•์šฉ์‚ฌ + 1๋ช…์‚ฌ + ??๋™์‚ฌ (๋™์‚ฌ๊ฐ€ ์—ฌ๋Ÿฌ๊ฐœ ์žˆ์œผ๋ฉด ์•ˆ๋œ๋‹ค.) // ํ•ญ์ƒ ๊ฐ™์€ gender๋ฅผ ๊ฐ€์ง // 1. ๋‹จ์–ด์ธ์ง€ ๋ฌธ์žฅ์ธ์ง€ ํŒ๋‹จํ•œ๋‹ค. // 2. ์–ด๋ฏธ๊ฐ€ ์ „๋ถ€ Petya์–ธ์–ด์— ๋งž๋Š”์ง€ ํ™•์ธํ•œ๋‹ค. // 3. ๋ฌธ์žฅ์ด๋ผ๋ฉด ๋ช…์‚ฌ๊ฐ€ ์ •ํ™•ํžˆ 1๊ฐœ์ธ์ง€ ํ™•์ธํ•œ๋‹ค. // 4. ํ˜•์šฉ์‚ฌ์™€ ๋™์‚ฌ๊ฐ€ ์ œ๋Œ€๋กœ๋œ ์œ„์น˜์— ์žˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค. // 5. ๋ชจ...
C
0c9550a09f84de6bed529d007ccb4ae8
d43fd127cd29d2fd12e285f2af3ef5e8
1,600
PASSED
#include <stdio.h> #include <string.h> // ๋‚จ์„ฑ / ์—ฌ์„ฑ // ํ˜•์šฉ์‚ฌ lios / liala // ๋ช…์‚ฌ etr / etra // ๋™์‚ฌ initis / inites // ??ํ˜•์šฉ์‚ฌ + 1๋ช…์‚ฌ + ??๋™์‚ฌ (๋™์‚ฌ๊ฐ€ ์—ฌ๋Ÿฌ๊ฐœ ์žˆ์œผ๋ฉด ์•ˆ๋œ๋‹ค.) // ํ•ญ์ƒ ๊ฐ™์€ gender๋ฅผ ๊ฐ€์ง // 1. ๋‹จ์–ด์ธ์ง€ ๋ฌธ์žฅ์ธ์ง€ ํŒ๋‹จํ•œ๋‹ค. // 2. ์–ด๋ฏธ๊ฐ€ ์ „๋ถ€ Petya์–ธ์–ด์— ๋งž๋Š”์ง€ ํ™•์ธํ•œ๋‹ค. // 3. ๋ฌธ์žฅ์ด๋ผ๋ฉด ๋ช…์‚ฌ๊ฐ€ ์ •ํ™•ํžˆ 1๊ฐœ์ธ์ง€ ํ™•์ธํ•œ๋‹ค. // 4. ํ˜•์šฉ์‚ฌ์™€ ๋™์‚ฌ๊ฐ€ ์ œ๋Œ€๋กœ๋œ ์œ„์น˜์— ์žˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค. // 5. ๋ชจ...
C
0c9550a09f84de6bed529d007ccb4ae8
bd9fba1dd852e3ad8c69dc106bf4b182
1,600
PASSED
#include <stdio.h> #include <string.h> char str[200005]={0}; int main() { long flag=0; long t=1; long s=0; long l; long temp=0; for(;;) { temp=0; if(scanf("%s",str)==EOF) break; l=strlen(str); if(l>=4) if(str[l-1]=='s'&&str[l-2]=='o'&&str[l-3]=='i'&&str[l-4]=='l') flag|...
C
0c9550a09f84de6bed529d007ccb4ae8
d01d2088a9583e7ae9bae6d263c55763
1,600
PASSED
#include <stdio.h> #include <string.h> char str[100005]; int main() { int i,l,s1=1,s2=1,f1=1,f2=1,f3=1,v,s=0; while (scanf("%s",str+1)!=EOF) { if (++s>1) f3=0; l=strlen(str+1); v=2; if (str[l-3]=='l'&&str[l-2]=='i'&&str[l-1]=='o'&&str[l]=='s') f1&=(s1==1); else...
C
0c9550a09f84de6bed529d007ccb4ae8
94abae6d11b76ddffbf13edccb9c71d6
1,600
PASSED
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.math.BigInteger; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author...
Java
0c9550a09f84de6bed529d007ccb4ae8
2997bc0592b229700d2cfb1894404277
1,600
PASSED
#include <cstdio> #include <algorithm> #include <vector> #include <cstring> #include <queue> using namespace std; const int N = 210; const int INF = 0x3f3f3f3f; struct Edge{ int from,to,cap,flow; }; struct Dinic{ int n,m,s,t; vector<Edge> edges; vector<int> g[N]; bool vis[N]; int d[N],cur[N]; ...
C++
3fba1fbbcb6ef38a446de1b0565dccc2
a5730b97e7ef24bb320041ba07ddb822
2,500
PASSED
#include <bits/stdc++.h> #define maxn 100010 #define maxe 500010 #define linf (1ll<<60) #define iinf 0x3f3f3f3f #define eps 1e-8 #define cl(x) memset(x,0,sizeof(x)) #define mod 998244353ll using namespace std; struct Graph2 { int head[maxn], next[maxe], to[maxe], w[maxe], c[maxe], tot; void clear(int N) { ...
C++
3fba1fbbcb6ef38a446de1b0565dccc2
265a2884971d8c267c104b7277cee611
2,500
PASSED
#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(auto i=(a);i<=(b);++i) #define dep(i,a,b) for(auto i=(a);i>=(b);--i) #define pb push_back typedef long long ll; const int maxn=(int)2e5+100; const int mod=(int)1e9+7; const int inf=(int)1e9; int n,m,vis[110][110],lx[110],ly[110],px,py; struct que{int x...
C++
3fba1fbbcb6ef38a446de1b0565dccc2
ab615baec2b530e7658a0b104e1502cf
2,500
PASSED
#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(auto i=(a);i<=(b);++i) #define dep(i,a,b) for(auto i=(a);i>=(b);--i) #define pb push_back typedef long long ll; const int maxn=(int)2e5+100; const int mod=(int)1e9+7; const int inf=(int)1e9; int n,m,S,T,vis[110][110],lx[110],ly[110],px,py; struct que{i...
C++
3fba1fbbcb6ef38a446de1b0565dccc2
963d31f937b66a98a1758be9e4508216
2,500
PASSED
#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(auto i=(a);i<=(b);++i) #define dep(i,a,b) for(auto i=(a);i>=(b);--i) #define pb push_back typedef long long ll; const int maxn=(int)2e5+100; const int mod=(int)1e9+7; const int inf=(int)1e9; int n,m,vis[110][110],lx[110],ly[110],px,py; struct que{int x...
C++
3fba1fbbcb6ef38a446de1b0565dccc2
0f6cce4742961e05e394ad9a702c32ce
2,500
PASSED
#include <bits/stdc++.h> using namespace std; struct Rect { int x1; int y1; int x2; int y2; friend istream& operator>>(istream& in, Rect& x) { in >> x.x1 >> x.y1 >> x.x2 >> x.y2; --x.x1; --x.y1; return in; } }; template <typename T> T load() { T r; cin >> r; return r; } template <typename T> vector<T> loadMany(i...
C++
3fba1fbbcb6ef38a446de1b0565dccc2
203b0c7c400f287f161c2e5bdee22124
2,500
PASSED
#pragma GCC optimize("O3") #pragma GCC target("tune=native") #pragma GCC optimize("fast-math,unroll-loops") #include <math.h> #include <algorithm> #include <set> #include <iostream> #include <vector> #include <queue> #include <map> #include <string> #include <time.h> #include <cassert> #include <functional> ...
C++
3fba1fbbcb6ef38a446de1b0565dccc2
9d3daa4051d90950155c9d656765be2d
2,500
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pl; typedef vector<ll> vl; typedef vector<int> vi; typedef vector<vi> vvi; const int MN = 222; const int MM = 105; ll res[MN][MN]; ll s,t,f,mf; const ll INF = 1e12; ll p[MN]; vi g[MN]; void aug(int u, ll fl) { if(u == s) { f = fl...
C++
3fba1fbbcb6ef38a446de1b0565dccc2
17f980958efeb2857d855ea06db97262
2,500
PASSED
#define make_pair mp #define emplace_back pb #include <bits/stdc++.h> using namespace std; mt19937 mt_rand(time(0)); const int N = 305; const long long INF2 = 2e18, INF = 2e9 + 5; const long long LOGQ = 30; class Graph { public: int n, t, s; map<int, long long> cap[N]; vector<int> NG[N]; int odl[N]; bool taken[...
C++
3fba1fbbcb6ef38a446de1b0565dccc2
c7738e523dcbec9cdee443f0b630428c
2,500
PASSED
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #include <chrono> ...
C++
3fba1fbbcb6ef38a446de1b0565dccc2
2c5245cb031aa3017df60b0b61a20da6
2,500
PASSED
#include <iostream> #include <cstdio> #include <cmath> #include <string> #include <cstring> #include <algorithm> #include <queue> #include <map> #include <set> #include <stack> #include <sstream> #define PI acos(-1.0) const int inf = (1<<30) - 10; using namespace std; const int maxx = 55; char kmap[maxx][maxx]; bool...
C++
73930603e440eef854da4ba51253a5a7
8b80e1148d8794b01d10ac4c8e21fc97
1,500
PASSED
#include<iostream> #include<iomanip> #include<string> using namespace std; int main() { char A[55][55]={}; int n,m,c=0; cin>>n>>m; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>A[i][j]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) { c=0; if(A[i]...
C++
73930603e440eef854da4ba51253a5a7
95ff739c4b8ce36ebcb6adaac3f4f12a
1,500
PASSED
#include<iostream> #include<iomanip> #include<string> using namespace std; int main() { char mp[60][60]={}; int n,m,s=0,ch[60][60]={},xp,yp; pair<int,int>A[3000]; cin>>n>>m; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) { cin>>mp[i][j]; ch[i][j]=-1; ...
C++
73930603e440eef854da4ba51253a5a7
fe45b4104077fd8f1378d0fa4429b864
1,500
PASSED
#include<iostream> using namespace std; int n,m; int dir[4][2]={0,1,1,0,0,-1,-1,0}; int vis[55][55]; char map[55][55]; int judge(int x,int y) { if(x>=0&&x<n&&y>=0&&y<m) { return 1; } return 0; } int DFS(int ex,int ey,int tx,int ty,int step) { int x,y,i; if(tx==ex&&ty==ey&&step>=4) { ...
C++
73930603e440eef854da4ba51253a5a7
50a6a252f8a5504916b7ae55cb0dd157
1,500
PASSED
#include<iostream> #include<algorithm> #include<map> #include<set> #include<vector> using namespace std; char a[1000][1000]; int n, m; bool used[3000]; vector < vector<int> >x(3000); bool dfs(int v,int k) { //cout <<endl<<"NEW "<< v<<" "<<k<<endl; if (used[v]) { return 1; } used[v] = true; //for (vector<i...
C++
73930603e440eef854da4ba51253a5a7
2c0d42af2cd83bfde5eeb618f9b7e353
1,500
PASSED
//#include<cstdio> //#include<cstring> //#include<iostream> //#include <algorithm> //#include <queue> //using namespace std; //char str[110]; //int ans[110]; //int len,vis[30],n; //void gao() //{ // for(int i=0;i<26;i++) // { // if(vis[i]==0) // printf("%c",'a'+i); // else if(ans[0]==i+'a...
C++
73930603e440eef854da4ba51253a5a7
90c4e5a6df694620d245a1c23fb797a0
1,500
PASSED
#include<iostream> #define white 0 #define gray 1 #define black 2 using namespace std; int n, m; bool test; char mat[55][55]; int vis[55][55]; bool isvalid(int i, int j) { return (i >= 1 && i <= n && j >= 1 && j <= m ); } void dfs(int a, int b,int i,int j) { if (!isvalid(a, b) || mat[a][b]!=mat[i][j] || vis[a][b] == ...
C++
73930603e440eef854da4ba51253a5a7
0e43aa8dade62678fc6b3821bdb4954e
1,500
PASSED
#include<stdio.h> #include<iostream> #include<math.h> #include<stdlib.h> #include<ctype.h> #include<algorithm> #include<vector> #include<string> #include<queue> #include<stack> #include<set> #include<map> #include<string> #include<sstream> using namespace std; int n, m, ok; char s[100][100]; int vis[100][100]; int di...
C++
73930603e440eef854da4ba51253a5a7
5e513d42666dcbab9cda9309f8cb70bc
1,500
PASSED
#include<iostream> #include<algorithm> using namespace std; int m,n; int desx,desy; int movet[4][2]={0, 1, 1, 0, 0, -1, -1, 0}; char map[51][51]; bool vis[51][51]; inline bool boundry(int x,int y) { if(x<1||y<1||x>n||y>m) return false; return true; } bool dfs(int x,int y,int k,char c) { int i,gx,gy;...
C++
73930603e440eef854da4ba51253a5a7
33ed981a83e384d688dbbc4330e31d0a
1,500
PASSED
#include <cstdio> #include <iostream> #include <vector> using namespace std; char h[55][55]; int h2[55][55]; int color[10005]; int when[10005]; int fail = 0; vector<int> adj[10005]; void dfs(int here, int t) { if(fail == 1) return; color[here] = 1; when[here] = t; for(int i = 0; i < adj[here].size...
C++
73930603e440eef854da4ba51253a5a7
3af6e44bb72149eced66a4a885face98
1,500
PASSED
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication5 { class Program { static void Main(string[] args) { List<int> chervi = new List<int>(); Console.ReadLine(); string input = Console.ReadLine();...
C#
10f4fc5cc2fcec02ebfb7f34d83debac
f603a8a472f286b0d0dac5c01f2436e6
1,200
PASSED
using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Threading; namespace Codeforces { class Program : IDisposable { private static readonly TextReader textReader = new StreamReader(Conso...
C#
10f4fc5cc2fcec02ebfb7f34d83debac
18f10982ae18ca0663aaa9d2b6c9f631
1,200
PASSED
using System; using System.Collections.Generic; using System.Text; public class Program { public static void Main(string[] args) { string [] input = Console.In.ReadToEnd().Split(new char[] {' ', '\n', '\r', '\t'}, StringSplitOptions.RemoveEmptyEntries); int kuchki = int.Pars...
C#
10f4fc5cc2fcec02ebfb7f34d83debac
a8338c80fc3156055a9ad6732dd24166
1,200
PASSED
using System; using System.Collections.Generic; using System.Text; public class Program { public static void Main(string[] args) { string [] input = Console.In.ReadToEnd().Split(new char[] {' ', '\n', '\r', '\t'}, StringSplitOptions.RemoveEmptyEntries); int kuchki = int.Pars...
C#
10f4fc5cc2fcec02ebfb7f34d83debac
0ef4bdcb1ab6eac31c0972398d8981c7
1,200
PASSED
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProblemSolving { //public class mycomparer : IComparer { // public int Compare(object x, object y) // { // if (x < y || x == y) return ...
C#
10f4fc5cc2fcec02ebfb7f34d83debac
0e8dd6ddbe35d7ce0dd1e02a4cfbca80
1,200
PASSED
๏ปฟusing System; using System.Linq; using System.Text; namespace Worms { partial class Worms { static void Main(string[] args) { int n, m, sum = 0, currentPile = 0; int[] piles, partials; JuicyWorm[] juicyWorms; StringBuilder answers = new StringBui...
C#
10f4fc5cc2fcec02ebfb7f34d83debac
babd58609dfbda86d2cd1c3706a648c2
1,200
PASSED
๏ปฟnamespace topCoder { using System; using System.Collections.Generic; class p2 { static void Main(string[] args) { //p1 o = new p1(); //o.foo(); p2 o = new p2(); o.foo(); Console.ReadLine(); } public void foo() { int n = int.Parse(Console.ReadLine()); int[] a = new int[n]; stri...
C#
10f4fc5cc2fcec02ebfb7f34d83debac
c57c7c74dc64044cf53161673de49abf
1,200
PASSED
๏ปฟusing System; using System.Collections.Generic; using System.IO; using System.Text; class B { private static string NextToken() { StringBuilder result = new StringBuilder(); while (true) { int c = Console.Read(); if (c == -1) return result.ToStri...
C#
10f4fc5cc2fcec02ebfb7f34d83debac
ac5bbb424f0369e19c867d0ab8535a46
1,200
PASSED
๏ปฟ๏ปฟusing System; using System.Collections.Generic; using System.Linq; class Solver { void Solve() { var n = sc.Integer(); var a = sc.LongArray(n); for (int i = 1; i < n; i++) a[i] += a[i - 1]; var m = sc.Integer(); var q = sc.LongArray(m); foreach (var ...
C#
10f4fc5cc2fcec02ebfb7f34d83debac
1b4c8f234e410d179a0976b6ba3687de
1,200
PASSED
๏ปฟusing System; using System.Collections.Generic; using System.Linq; using Solver.Ex; using Debug = System.Diagnostics.Debug; using Watch = System.Diagnostics.Stopwatch; using StringBuilder = System.Text.StringBuilder; namespace Solver { public class Solver { public void Solve() { var...
C#
10f4fc5cc2fcec02ebfb7f34d83debac
50ef481ccd3a649f18d29f727771c459
1,200
PASSED
import java.io.BufferedInputStream; import java.util.Scanner; public class _59B { public static void main(String[] args) { Scanner sc = new Scanner(new BufferedInputStream(System.in)); int n = sc.nextInt(); int k = sc.nextInt(); int[] a = new int[k+1]; for(int i=0;i<n;i++) { int x = sc.nextInt...
Java
3d6411d67c85f6293f1999ccff2cd8ba
f9f3cacf7cd58670f4e130ca8d00bde6
1,200
PASSED
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; /** * * @author mohamed elshenawy */ public class Main { public static void main(String...
Java
3d6411d67c85f6293f1999ccff2cd8ba
0e4a84355d18aa357c285baa26516f63
1,200
PASSED
//package Div2_59; import java.util.Arrays; import java.util.Scanner; public class B { /** * @param args */ public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int k = s.nextInt(); int [] a = new int [n]; int c = 0; for (int i = 0; i < a.length; i++) ...
Java
3d6411d67c85f6293f1999ccff2cd8ba
c62892ceeddf9004aab2b356795dc509
1,200
PASSED
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.StringTokenizer; /* * To change this template, choose Tools | Templates ...
Java
3d6411d67c85f6293f1999ccff2cd8ba
93df3f4c14d774f543371de2c11dd05e
1,200
PASSED
import java.util.*; import java.io.*; public class Main{ public static void main(String[] argv) throws IOException{ new Main().run(); } PrintWriter pw; Scanner sc; public void run() throws IOException{ boolean oj = true;//System.getProperty("ONLINE_JUDGE") != null; Reader reader = oj ? new InputS...
Java
3d6411d67c85f6293f1999ccff2cd8ba
842f1ed2f4cfb91848b8d3603421efb7
1,200
PASSED
import java.util.Scanner; /** * @author manu * */ public class SettlersTraining { /** * @param args */ public static void main(String[] args) { Scanner in = new Scanner(System.in); int N, K; N = in.nextInt(); K = in.nextInt(); int counter = 0; int...
Java
3d6411d67c85f6293f1999ccff2cd8ba
a3e791016ce4733debacea31d744f9c1
1,200
PASSED
import java.util.*; public class straining{ public static void main(String[] args){ Scanner br = new Scanner(System.in); int n = br.nextInt(); int k = br.nextInt(); int[] nums = new int[k]; int[] temp = new int[k]; for(int i = 0;i<n;i++){ int c = br.nextInt()-1; nums[c]++; temp[c]++; } int cou...
Java
3d6411d67c85f6293f1999ccff2cd8ba
aadf0ee0dc71c6ae406b4d9336304b03
1,200
PASSED
import java.util.Scanner; import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n,i,k,temp=0; n=in.nextInt(); k=in.nextInt(); int[] fl =new int[n+1]; for (i=0;i<n;i++) fl[i]=in...
Java
3d6411d67c85f6293f1999ccff2cd8ba
f6834b6ff31656e8b4d4b0ee4ec63177
1,200
PASSED
import java.io.*; import java.util.*; public class test { public static void main(String[] args) { new test().run(); } void run() { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int k = in.nextInt(); int[] count = new int[k]; int total ...
Java
3d6411d67c85f6293f1999ccff2cd8ba
66cd8b1b4d41d08fbd0e5a1768288acc
1,200
PASSED
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class Round_59 { /** * @param args * @throws Exception */ public static void main(String[] args) throws IOException { // TODO Auto-generated method stub BufferedReader r = new Buffe...
Java
3d6411d67c85f6293f1999ccff2cd8ba
4d5082f994d49d9bc858a2901d4067f2
1,200
PASSED
n, k = map(int, input().split()) ss = [] ks = [] kss = [] ka = 0 civ = ['1110111', '0010010', '1011101', '1011011', '0111010', '1101011', '1101111', '1010010', '1111111', '1111011'] civn = [6, 2, 5, 5, 4, 5, 6, 3, 7, 6] it = '' pref = [] for i in range(n): s = input() ss.append(s) maa = 10 kk = [] k...
Python
d7f73762ff7a01c33280257e556a9b36
e014c70f304c2beafcf4fb7d84fc8bb8
1,700
PASSED
numbers=["1110111", "0010010", "1011101", "1011011", "0111010", "1101011", "1101111", "1010010", "1111111", "1111011"] n,m = list(map(int,input().split())) changes = [[0]*(10) for i in range(n)] for i in range(n) : s = input() for j in range(10) : count = 0 for k in range(7) : if nu...
Python
d7f73762ff7a01c33280257e556a9b36
5cf244178c545e6913ea9bd03079acc7
1,700
PASSED
from sys import stdin,stdout from collections import defaultdict,Counter input=stdin.readline def check(d,arr): for x in arr: if x[0]==d: return True return False def valll(arr,d): for x in arr: if x[0]==d: return x[1] return -1 def poss(s): res=[] count=1...
Python
d7f73762ff7a01c33280257e556a9b36
cd8da5db2960700e6a3c9acbbc242076
1,700
PASSED
import sys stdin = sys.stdin ns = lambda: stdin.readline().rstrip() ni = lambda: int(stdin.readline().rstrip()) nm = lambda: map(int, stdin.readline().split()) nl = lambda: list(map(int, stdin.readline().split())) dig = [119, 18, 93, 91, 58, 107, 111, 82, 127, 123] pct = [0]*(1<<7) for bit in range(1<<7): for...
Python
d7f73762ff7a01c33280257e556a9b36
aeabe0a70e6089ec55a5403e172e9941
1,700
PASSED
import sys from typing import List input = sys.stdin.readline ############ ---- Input Functions ---- ############ def inp(): return(int(input())) def inlt(): return(list(map(int,input().split()))) def insr(): s = input() return(list(s[:len(s)])) def invr(): return(map(int,input().split())) def g...
Python
d7f73762ff7a01c33280257e556a9b36
a0a4be7b1ac38f465ac0d551484b6184
1,700
PASSED
from sys import stdin,stdout input = stdin.readline from math import * print = stdout.write def cst(s,d): res=0 for i in range(7): if(s[i]=='1' and d[i]=='0'): return -1 elif(s[i]=='0' and d[i]=='1'): res+=1 return res n,k=map(int,input().split()) d=["1110111", "0010010", "1011101", "1011011", "0111010",...
Python
d7f73762ff7a01c33280257e556a9b36
e6025413dee1ff357c27207dde3132a8
1,700
PASSED
import sys def I(): return sys.stdin.readline().rstrip() cds = ["1110111", "0010010", "1011101", "1011011", "0111010", "1101011", "1101111", "1010010", "1111111", "1111011" ] def dist(s, n): cs = cds[n] cost = 0 for c, cc in zip(s, cs): if c != cc: if c == '1': retu...
Python
d7f73762ff7a01c33280257e556a9b36
0eee356fb0b6992b78135c50cf177921
1,700
PASSED
from sys import stdin nums = [0b1110111, 0b0010010, 0b1011101, 0b1011011, 0b0111010, 0b1101011, 0b1101111, 0b1010010, 0b1111111, 0b1111011] def calc(a1, a2): if (a1 ^ a2) & a1 == 0: d = (a1 ^ a2) return sum([(d >> i) & 1 for i in range(7)]) else: return -1 n, k = list(map(int,...
Python
d7f73762ff7a01c33280257e556a9b36
7b99efd66b2a47c3d6556d9e7a3dc8b2
1,700
PASSED
def D(): numdict={ 0:"1110111", 1:"0010010", 2: "1011101", 3: "1011011", 4: "0111010", 5: "1101011", 6: "1101111", 7: "1010010", 8:"1111111", 9:"1111011"} n,k=map(int,input().split()) sb=list() for i in range(0,n): sb.append(str(input())) covb=list() sdict=dict() slis=[0]*(k+1) dp=[slis.copy() for i in range(...
Python
d7f73762ff7a01c33280257e556a9b36
567dbc210e2ce325b45ba1c50c61981b
1,700
PASSED
import sys def f(): n, k = map(int, input().split())#2000, 2000 ch = {0:'1110111',1:'0010010',2:'1011101',3:'1011011',4:'0111010',5:'1101011',6:'1101111',7:'1010010',8:'1111111',9:'1111011'} l = [] for _ in range(n): l.append(sys.stdin.readline().rstrip()) def tr(s1, s2): tot = 0 ...
Python
d7f73762ff7a01c33280257e556a9b36
956c91dc92d282783aa7a96f8c7e21f4
1,700
PASSED
#include <vector> #include <list> #include <map> #include <queue> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <math.h> #include <c...
C++
b0301a2d79a1ec126511ed769ec0b743
c51cac9137ccdd49d5063983c99bdb1c
1,500
PASSED
#include<stdio.h> #include<string.h> #include<stdlib.h> char strr[20][20]; int map[20][20]; int n,m; int match(char *str) { int i; for(i=0;i<n;i++) { if(strcmp(strr[i],str)==0) return i; } } int SUM(int x) { int sum=0; while(x!=0) { x=x&(x-1); sum++; } ...
C++
b0301a2d79a1ec126511ed769ec0b743
743c4613713e3a4b8fe9507459645552
1,500
PASSED
#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <map> #include <algorithm> using namespace std; int n, m; map < string, int > getnum; string name[17]; bool bad[17][17]; int getK(int mask) { int ans = 0; while (mask) { if (mask & 1) ans++; ma...
C++
b0301a2d79a1ec126511ed769ec0b743
271ee4b9bed899af340d6d27b7bb73b9
1,500
PASSED
#include "iostream" #include "cstdio" #include "memory.h" #include "algorithm" #include "vector" using namespace std; int n,m; int map[20][20]; string str[20]; int find(string s) { for(int i = 0;i < n;i++) { if(s==str[i]) return i; } } int check(int pos) { int ans = 0; vector<int>ss;...
C++
b0301a2d79a1ec126511ed769ec0b743
c59c687e6c7665d8c457b1353b88c59e
1,500
PASSED
#include<iostream> #include<vector> #include<cstdio> #include<algorithm> #include<cmath> using namespace std; int n,m,x,y; int cannot[16]; vector <string> N(16); string str1,str2; int cnt,ans=0,flag=0; int main(){ int i,j; scanf("%d%d",&n,&m); for (i=0;i<n;i++)cin>>N[i]; sort(N.begin(),N.begin()+n); for (i=0;i<...
C++
b0301a2d79a1ec126511ed769ec0b743
01439e7ea1c41ba799bb556de64a5350
1,500
PASSED
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <iostream> #include <algorithm> #include <queue> #include <map> using namespace std; #define INF 0x3fffffff #define LL long long map<string, int> idx; string name[16]; int g[16][16]; int bitCount(int mask) { int ret = 0; while(ma...
C++
b0301a2d79a1ec126511ed769ec0b743
8de8b1ec2d61b5c08162ea2d92055cca
1,500
PASSED
#include <iostream> #include <vector> #include <cstdlib> #include <set> #include <map> using namespace std; struct node { string myName; vector<string> hate; void init() { myName.clear(); hate.clear(); } }; const int MAX_SIZE = 20; const int STATE[] = {1,2,4,8,16,32,64,128,256,512,10...
C++
b0301a2d79a1ec126511ed769ec0b743
b08692ff7bf392709dac203761b94839
1,500
PASSED
#include <iostream> #include <string> #include <set> using namespace std; const int maxn = 16; string name[maxn]; set <string> sol; int mask[maxn]; int main () { int n, m; cin >> n >> m; for (int i = 0; i < n; i++) cin >> name[i]; for (int i = 0; i < m; i++) { string x, y; cin >> x >> y;...
C++
b0301a2d79a1ec126511ed769ec0b743
31ba4b7b2375b5ec3eb7fae4a9aa28ff
1,500
PASSED
#include <iostream> #include <string> #include <set> #include <limits.h> #include <algorithm> using namespace std; const int maxn = 17; string in[maxn]; int mask[maxn]; int main () { int n, m, x, y; cin >> n >> m; for (int i = 0; i < n; i++) cin >> in[i]; for (int i = 0; i < m; i++) { string a, ...
C++
b0301a2d79a1ec126511ed769ec0b743
80b089f5c0719b64775f2edd91a5199b
1,500
PASSED
#include <vector> #include <string> #include <algorithm> #include <iostream> using namespace std; int n, m; vector<string> myv, out; string in[1000], col[1000][2]; void solve(int num){ if(num == n){ for(int i = 0; i < myv.size(); i++) for(int j = i+1; j < myv.size(); j++) for(in...
C++
b0301a2d79a1ec126511ed769ec0b743
f95e5e468e4db4c2088862dfe1a0f96f
1,500
PASSED
import sys import math from collections import defaultdict,Counter # input=sys.stdin.readline # def print(x): # sys.stdout.write(str(x)+"\n") # sys.stdout=open("CP3/output.txt",'w') # sys.stdin=open("CP3/input.txt",'r') # m=pow(10,9)+7 t=int(input()) for i in range(t): n=int(input()) a=list(map(int,input...
Python
9d480b3979a7c9789fd8247120f31f03
37e3660155d285b5a55ed7c6978010cd
1,700
PASSED
from collections import * for _ in range(int(input())): n = int(input()) ai = list(map(int, input().split())) count = Counter(ai) mostc = count.most_common() num = mostc[0][0] numcount = mostc[0][1] ans = -1 for num in count: if count[num] == numcount: count[num] = ...
Python
9d480b3979a7c9789fd8247120f31f03
d75ab0626376695b336c3047c4860d56
1,700
PASSED
from sys import stdin def inp(): return stdin.buffer.readline().rstrip().decode('utf8') def itg(): return int(stdin.buffer.readline()) def mpint(): return map(int, stdin.buffer.readline().split()) # ############################## import # from ACgenerator import minimum_distance_for_same_value_maxim...
Python
9d480b3979a7c9789fd8247120f31f03
f18ca56c50ca187b1ac20560262280ca
1,700
PASSED
from sys import stdin def inp(): return stdin.buffer.readline().rstrip().decode('utf8') def itg(): return int(stdin.buffer.readline()) def mpint(): return map(int, stdin.buffer.readline().split()) # ############################## import # ############################## main # def main(): from collec...
Python
9d480b3979a7c9789fd8247120f31f03
12ef057213ec7f7a6ee34a2c7f10203e
1,700
PASSED
import sys from collections import Counter input = sys.stdin.readline def check(num): new = 0 temp = [] for i in arr: temp.append(i[0]) prev = 0 k = ones while True: count = 0 for i in range(len(arr)): if count<=num and temp[i]>0: new += 1 count += 1 temp[i] -= 1 else: break temp....
Python
9d480b3979a7c9789fd8247120f31f03
a9b8431b9bfc2d97c5922416f20784ac
1,700
PASSED
for _ in range(int(input())): n = int(input()) m = 0 mp = dict() arr = list(map(int, input().split())) for i in range(n): mp[arr[i]] = mp.get(arr[i],0)+1 if (mp[arr[i]] > m): m = mp[arr[i]] if (n%2==0): if (m > n//2): print(0) continue else: if (m > (n+1)//2): print(0) continue count = 0 ...
Python
9d480b3979a7c9789fd8247120f31f03
588d9306ba536f7e26afa6dfedde606d
1,700
PASSED
for _ in range(int(input())): n=int(input()) a=list(map(int,input().split())) c=[0]*(10**5+1) for i in a: c[i]+=1 k=max(c) x=0 for i in c: if i==k: x+=1 print(((n-x-1)-(k-2))//(k-1))
Python
9d480b3979a7c9789fd8247120f31f03
56312190ad776f9cb8cee07a1042aed5
1,700
PASSED
from __future__ import division, print_function def main(): for _ in range(int(input())): n = int(input()) cakes = list(map(int, input().split())) count = {} max_count = 0 for x in cakes: if x not in count: count[x] = 0 count[x] += 1 ...
Python
9d480b3979a7c9789fd8247120f31f03
c67e53d373e65629127fc407ebaba94a
1,700
PASSED
import sys input=sys.stdin.readline LI=lambda:list(map(int, input().strip('\n').split())) MI=lambda:map(int, input().strip('\n').split()) SI=lambda:input().strip('\n') II=lambda:int(input().strip('\n')) for _ in range(II()): n=II() a=LI() cnt={} for v in a: cnt[v]=cnt.get(v, 0)+1 m=max(cnt.values()) num=0 for...
Python
9d480b3979a7c9789fd8247120f31f03
91047dd7bb9c3a44a2dac10314570f6e
1,700
PASSED
import sys from collections import defaultdict as dd from collections import deque from functools import * from fractions import Fraction as f from copy import * from bisect import * from heapq import * from math import * from itertools import permutations def eprint(*args): print(*args, file=sys.stderr) zz=1 ...
Python
9d480b3979a7c9789fd8247120f31f03
4c4dcc05b9eec4eeaa80d6757797eeef
1,700
PASSED
n,m=map(int,input().split()) a=[] for i in range(n): a.append(list(input())) b=0 for i in a: b+=i.count('*') x=y=-1 for i in range(1,n-1): for j in range(1,m-1): if a[i][j]==a[i][j-1]==a[i][j+1]==a[i-1][j]==a[i+1][j]=='*': x=i y=j break if x==y==-1: exit(print...
Python
6405161be280fea943201fa00ef6f448
37ede566651e9e71eb35d9e137c401fa
1,300
PASSED
import math from collections import Counter #n=int(input()) n,m=map(int,input().split()) a=[] k=0 for i in range(n): a+=[list(input())] for i in range(1,n-1): for j in range(1,m-1): if a[i][j]=='*' and a[i][j+1]=="*" and a[i+1][j]=="*" and a[i-1][j]=="*" and a[i][j-1]=="*": c=j+1 ...
Python
6405161be280fea943201fa00ef6f448
09b6fd4f8350d40b5cdb851d838d8182
1,300
PASSED
H,W = gets.split.map(&:to_i) pic = [] cell = 0 H.times do s = gets.chomp cell += s.count("*") pic << s end flg = false ver = false (H-2).times do |i| 1.upto(W-2) do |j| if pic[i][j] == "*" pic[i][j] = "." k = i+1 while k < H && pic[k][j] == "*" pic[k][j] = "." if !ver && k...
Ruby
6405161be280fea943201fa00ef6f448
fac718fc30956734e5349ebdca44213b
1,300
PASSED
h, w = gets.split.map(&:to_i) f = h.times.map{gets.chomp} memo_left = (0..h).map{[0] * w}.to_a memo_up = (0..h).map{[0] * w}.to_a memo_right = (0..h).map{[0] * w}.to_a memo_down = (0..h).map{[0] * w}.to_a cnt = f.map{|s| s.count('*')}.inject(:+) h.times{|i| w.times{|j| next if f[i][j] != '*' memo_left[i][j] ...
Ruby
6405161be280fea943201fa00ef6f448
98336fd8bcd6c4359d1beb4c01b3994e
1,300
PASSED
def test(i,j): if inp[i+1][j] == '*' and inp[i-1][j] == '*' and inp[i][j-1] == '*' and inp[i][j+1] == '*': return True return False h,w = map(int,raw_input().split()) inp = [] for i in range(h): inp.append(raw_input()) flag,plus = 0,0 x,y = 0,0 vis = [] for i in range(h): vis.append([0]*w) for i in range(1,h-1): ...
Python
6405161be280fea943201fa00ef6f448
2684a638add6f191fcbf7950ab0d9b56
1,300
PASSED
import collections, heapq, math, sys h, w = map(int, sys.stdin.readline().rstrip().split(' ')) A = [] for _ in range(h): a = sys.stdin.readline().rstrip() A.append(a) # l = [[False for _ in range(w)] for _ in range(h)] # u = [[False for _ in range(w)] for _ in range(h)] # d = [[False for _ in range(w)] for _ ...
Python
6405161be280fea943201fa00ef6f448
5c86b32ac5406db64dbb14af7acec183
1,300
PASSED
import fileinput def D(a):print(a) def S(s,I):return int(s.split(" ")[I]) def main(): z=0 N=0 M=0 s=[0]*512 C=[0]*512 sx=[1,-1,0,0] sy=[0,0,1,-1] for l in fileinput.input(): z+=1 if(z<2): N=int(l.split(" ")[0]) M=int(l.split(" ")[1]) co...
Python
6405161be280fea943201fa00ef6f448
857f72f11a41d55b7e728ec3ab670823
1,300
PASSED
import sys h,w=map(int,raw_input().split()) m=[] for i in xrange(h): s=raw_input() l=list(s) m.append(l) cp=0 x,y=0,0 for i in xrange(1,h-1): for j in xrange(1,w-1): if m[i][j]=="*" and m[i-1][j]=="*" and m[i+1][j]=="*" and m[i][j-1]=="*" and m[i][j+1]=="*": x,y=i,j cp+=...
Python
6405161be280fea943201fa00ef6f448
30ef477f3a136152aec3448edf3ab27c
1,300
PASSED
h, w=map(int,raw_input().split()) a=[] s=f=p=x=y=0 for i in range(h): a.append(raw_input()) s+=a[i].count('*') for i in range(h): for j in range(w): if a[i][j]=='*': p=y=i x=j f=2 while a[p][j]=='*': s-=1 if p<h-1: p+=1 else: f=1 break if f: break if f: break p-=f f=0...
Python
6405161be280fea943201fa00ef6f448
5d0c148ce1ddc9e61bec6b383cec3041
1,300
PASSED
h,w= map(int,raw_input().split()) fig = [] for i in range(h): fig.append(raw_input()) row_no = -1 for i in range(len(fig)): if fig[i].count('*') > 1: if row_no == -1: row_no = i else: print "NO" exit() if row_no == -1: print "NO" exit() fig2 = [] for i in range(len(fig[0])): s = '' for j in range(le...
Python
6405161be280fea943201fa00ef6f448
648d19129306f0dcf8299aa1c0a31b42
1,300
PASSED
// In the name of * Krishna * :) #include <iostream> #include <iomanip> #include <string> #include <vector> #include <algorithm> #include <sstream> #include <queue> #include <deque> #include <bitset> #include <iterator> #include <list> #include <stack> #include <map> #include <unordered_map> #include <...
C++
2535fc09ce74b829c26e1ebfc1ee17c6
be0f1cd37a5e1380ed1adeb66e986def
1,500
PASSED
#include <iostream> #include <algorithm> #include <vector> #include <stack> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; cin.ignore(); stack<int> st; string cmd; int box, boxToBeRemoved = 0, answer = 0; for (int i = 1; i <= 2 *...
C++
2535fc09ce74b829c26e1ebfc1ee17c6
c51ec48c2848ec1eeea609ddd7b48d13
1,500
PASSED
#include <iostream> #include <vector> #include <string> using namespace std; int main() { int n; cin >> n; vector<int> arr; string type; int in; bool reorder = false; int current = 1, answer = 0; for (int i = 0; i < 2 * n; ++i) { cin >> type; if (type == "add") { cin >> in; arr.push_back(in); } ...
C++
2535fc09ce74b829c26e1ebfc1ee17c6
6bb8ed52bb091982ee8b8387dc89da4b
1,500
PASSED
#include<bits/stdc++.h> #include<stack> using namespace std; typedef long long lll; int main() { lll n; scanf("%lld",&n); lll k=1; lll flag=0; lll ans=0; stack<lll> st; for(lll i=0;i<2*n;i++) { char a[7]; string stq; scanf("%s",a); stq=a; if(stq=="add") { lll q; scanf("%lld",&q); st.push(q)...
C++
2535fc09ce74b829c26e1ebfc1ee17c6
f9813b1aac8d5395bb66bd9de87bc286
1,500
PASSED
//submitted by HimJ #include<bits/stdc++.h> #define ll long long #define mod 1000000007 #define pb push_back #define fi first #define se second #define fr(i,s,e) for(i=s;i<e;i++) #define be begin #define ms(arr,val) memset(arr,val,sizeof(arr)) using namespace std; int main(){ ios_base::sync_with_stdio(false); ...
C++
2535fc09ce74b829c26e1ebfc1ee17c6
63efea661edbb6dc0907ada6a67c6107
1,500
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long int typedef vector <int> vi; typedef pair<int,int> ii; typedef vector <vi> vvi; typedef vector <ll> vll; typedef vector <bool> vb; #define f(i,j,n) for(int i=j;i<n;i++) #define ff(i,j,n) for(int i=j;i>=n;i--) #define pb push_back #define mp make_pai...
C++
2535fc09ce74b829c26e1ebfc1ee17c6
9f23f1d1a5b23083a6adacec007b2c16
1,500
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long int typedef vector <int> vi; typedef pair<int,int> ii; typedef vector <vi> vvi; typedef vector <ll> vll; typedef vector <bool> vb; #define f(i,j,n) for(int i=j;i<n;i++) #define ff(i,j,n) for(int i=j;i>=n;i--) #define pb push_back #define mp make_pai...
C++
2535fc09ce74b829c26e1ebfc1ee17c6
21573147311c42fa1e137c0387fc2566
1,500
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long int typedef vector <int> vi; typedef pair<int,int> ii; typedef vector <vi> vvi; typedef vector <ll> vll; typedef vector <bool> vb; #define f(i,j,n) for(int i=j;i<n;i++) #define ff(i,j,n) for(int i=j;i>=n;i--) #define pb push_back #define mp make_pai...
C++
2535fc09ce74b829c26e1ebfc1ee17c6
c3fdaf15edf28c5bc09f5e17ae7fd9f9
1,500
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long int typedef vector <int> vi; typedef pair<int,int> ii; typedef vector <vi> vvi; typedef vector <ll> vll; typedef vector <bool> vb; #define f(i,j,n) for(int i=j;i<n;i++) #define ff(i,j,n) for(int i=j;i>=n;i--) #define pb push_back #define mp make_pai...
C++
2535fc09ce74b829c26e1ebfc1ee17c6
c987c1e21bda29b4331bfbe5a587d4aa
1,500
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long int typedef vector <int> vi; typedef pair<int,int> ii; typedef vector <vi> vvi; typedef vector <ll> vll; typedef vector <bool> vb; #define f(i,j,n) for(int i=j;i<n;i++) #define ff(i,j,n) for(int i=j;i>=n;i--) #define pb push_back #define mp make_pai...
C++
2535fc09ce74b829c26e1ebfc1ee17c6
8dd3054f4aef00078ec3ca5581dedc2c
1,500
PASSED
#include<bits/stdc++.h> using namespace std; int main(){ int i,min,max,t=0,n,a; cin>>n>>a; min=a,max=a; for(i=1;i<n;i++){ cin>>a; if(a>max){ max=a; t++; } if(a<min){ min=a; t++; } } cout<<t<<endl; return 0; }
C++
a61b96d4913b419f5715a53916c1ae93
1725fcfd3c2be99fd6c8d76f2e5bef14
800
PASSED