Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
double x, y, l, w;
double cal(double ang) {
double s, h;
s = l * cos(ang) + w * sin(ang) - y;
h = s * tan(ang) + w * cos(ang);
return h;
}
bool solve() {
double ang1, ang2, m, mm, mid, midmid;
ang1 = 0.0;
ang2 = acos(-1.0) / 2;
if (x < w || y < w) {
retu... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
double a, b, l;
double w;
inline double f(double x) {
return (a * cos(x) + b * sin(x) - l * cos(x) * sin(x));
}
void solve() {
double r1 = 0, r2 = acos(0.0);
for (int i = 0; i < 1000; i++) {
double r11 = (2.0 / 3.0) * r1 + (1.0 / 3.0) * r2;
double r22 = (1.0 /... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 |
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
/**
* @author Ivan Pryvalov (ivan.pryvalov@gm... | JAVA |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
double a, b, l;
double solve(double x) {
return (a + b * tan(x)) * (b + a / tan(x)) / (b / cos(x) + a / (sin(x))) -
l * sin(x) * cos(x);
}
int main() {
cin >> a >> b >> l;
if (l <= max(a, b))
printf("%.12f\n", min(min(a, b), l));
else {
double L = 0... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
/**
* @author Ivan Pryvalov (ivan.pryvalov@gma... | JAVA |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
ifstream fin("AAtest.in.txt");
double a, b, p, first, c = 0.000000001, vas = -1;
double arv(double alfa) {
return ((b - (p * sin(alfa) - a) / tan(alfa)) * sin(alfa));
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cerr.tie(0);
cin >> a >> b >> ... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long a, b, l;
const double pi = acos(-1);
const double delta = 0.000001;
double d(double theta) {
return (a + b * tan(theta) - l * sin(theta)) * cos(theta);
}
double solve() {
double theta = delta;
double D = 1e18;
while (theta < pi / 2) {
D = min(D, d(thet... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
template <typename T>
inline T sqr(T a) {
return a * a;
}
template <typename T>
inline void relaxMin(T &a, T b) {
if (b < a) a = b;
}
template <typename T>
inline void relaxMax(T &a, T b) {
if (b > a) a = b;
}
const int INF =... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
double a, b, l;
double pi = acos((double)-1);
inline double solve() {
if (a > b) swap(a, b);
if (l <= a)
return l;
else if (l <= b)
return a;
else {
double th = atan(cbrt(a / b));
double maxl = b / cos(th) + a / sin(th);
if (l > maxl + 1e-7) retu... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int l, a, b, e, L;
double nw, xw, mw, A, B, p, u, ty;
inline double d(double y) {
A = 1. / sqrt(L - y * y);
B = 1. / y;
u = sqrt(A * A + B * B);
ty = (1. + mw * u - A * b) / B;
if (ty > a + 1e-9) e = 1;
return a - ty;
}
inline bool cd() {
double ny = 0, xy = l... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:33554432")
using namespace std;
const double PI = 2 * acos(0.0);
const double EPS = 1e-12;
const double BEPS = 1e-8;
const int INF = (1 << 30) - 1;
double a, b, w, lo, hi, mi1, mi2;
double f(double x) {
double y = ((w) * (w) - (x) * (x) < 0 ? 0 : sqrt((w) * (w)... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <typename F>
double ternary_search(double lb, double ub, double prec, F fun) {
for (;;) {
if (ub - lb < prec) return (ub + lb) / 2;
double lmid = (2 * lb + ub) / 3, umid = (lb + 2 * ub) / 3;
if (fun(lmid) > fun(umid))
lb = lmid;
else
u... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = 1e-10;
int a, b, l;
double calc(double j) { return b * cos(j) - l * sin(j) * cos(j) + a * sin(j); }
double cal(double j) { return a / cos(j) + b / sin(j); }
int main() {
scanf("%d%d%d", &a, &b, &l);
double x = 0;
double... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
double a, b, l, w, wl, wr, ans, u, ul, ur, u1, u2;
double v(double ax, double ay, double bx, double by, double cx, double cy) {
return (bx - ax) * (cy - ay) - (by - ay) * (cx - ax);
}
double f(double w, double u) {
double vx, vy, ax, ay, bx, by, xi, xj, x, ox, oy;
vx ... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
double a, b, len;
double judge(double x) {
return (b * sqrt(len * len - x * x) + a * x - x * sqrt(len * len - x * x)) /
len;
}
double ternary(double l, double r) {
if (fabs(l - r) < EPS) return l;
double L = l + (r - l) / 3;
double ... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
double a, b, l, lo, hi, lx, hx, lv, hv, sol;
double dot(const complex<double> &a, const complex<double> &b) {
return real(conj(a) * b);
}
struct L : public vector<complex<double> > {
L(const complex<double> &a, const complex<double> &b) {
pu... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int a, b, l;
double f(double p) {
return (p * a + sqrt(l * l - p * p) * b - p * sqrt(l * l - p * p)) / l;
}
int main() {
scanf("%d%d%d", &a, &b, &l);
if (a > b) swap(a, b);
if (l <= a) {
printf("%d\n", l);
return 0;
}
if (l <= b) {
printf("%d\n", a);... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | import java.io.*;
import java.util.*;
public class E {
private static Reader in;
private static PrintWriter out;
private static final double EPS = 1e-7;
private static double a, b, l;
public static void main(String[] args) throws IOException {
in = new Reader();
out = new Prin... | JAVA |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long double pi = 2 * acos(0.0);
double a, b, l, d;
double R(double x) {
double y, s;
y = sqrt(l * l - x * x);
s = (0 * (a - 0) + b * (0 - y) + x * (y - a)) / 2.0;
if (s < 0) s = -s;
return 2 * s / l;
}
double MAX(double l, double r) {
int i;
for (i = 0; ... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
double F(double A, double B, double L, double T) {
return (A * T + B * sqrt(L * L - T * T) - T * sqrt(L * L - T * T)) / L;
}
double GetAns(double A, double B, double L) {
if (L <= A) return min(B, L);
if (L <= B) return min(A, L);
double Lef... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
long long a, b, l;
const double pi = acos(-1);
double d(double theta) {
return (a + b * tan(theta) - l * sin(theta)) * cos(theta);
}
double solve() {
double beg = 0, end = pi / 2;
while (end - beg > 1e-8) {
double m1 = beg + (end - beg) / 3;
double m2 = end - ... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | EPS = 1e-8
def cross(a, b):
return (a[0] * b[1]) - (a[1] * b[0])
def f(a, b, l, x):
y = (l*l - x*x)**0.5
return cross( (a-x, b), (-x, y) )
def main():
a, b, l = map(int, raw_input().split())
if a > b:
a, b = b, a
if l <= a and a <= b:
print "%.9lf" % l
elif a < l and l <... | PYTHON |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-8;
using namespace std;
int a, b, l;
double f(double w) {
return (w * a + sqrt(l * l - w * w) * b - w * sqrt(l * l - w * w)) /
(1. * (double)l);
}
int main() ... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-9;
double theta;
double a, b, L;
double calcu(double x) {
return (b * L * cos(x) - L * L * cos(x) * sin(x) + a * L * sin(x)) / L;
}
int main() {
scanf("%lf%lf%lf", &a, &b, &L);
double l = 0, r = pi / 2, mid1, mid2;
... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
/**
* @author Ivan Pryvalov (ivan.pryvalov@gma... | JAVA |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | import java.util.*;
import java.io.*;
public class Main{
BufferedReader in;
StringTokenizer str = null;
PrintWriter out;
private String next() throws Exception{
while (str == null || !str.hasMoreElements())
str = new StringTokenizer(in.readLine());
return str.nextToken();
}
... | JAVA |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
/**
* @author Ivan Pryvalov (ivan.pryvalov@gma... | JAVA |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
double a, b, l;
double eps = 1e-8;
double func(double x) {
return (x * a + sqrt(l * l - x * x) * b - sqrt(l * l - x * x) * x) / l;
}
double tsearch(double l, double r) {
if (r - l < eps) return (l + r) / 2;
double a = (2 * l + r) / 3;
double b = (l + 2 * r) / 3;
i... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
double a, b, l;
double Func(double x) {
double y = sqrt(l * l - x * x);
return fabs(a * y + b * x - x * y) / l;
}
double Solve(double left, double right) {
while (right - left > 1e-10) {
double d = (right - left) / 3;
double k1 = left + d, k2 = right - d;
... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
template <class T>
void chmin(T &a, T b) {
a = a <= b ? a : b;
}
template <class T>
void chmax(T &a, T b) {
a = a >= b ? a : b;
}
double calc(double a, double b, double l, double theta) {
return b * cos(theta) + a * sin(theta) - l * cos(theta) * sin(theta);
}
void sol... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
double n, m, t, x, y, k, a, b, lng, w, l, r, alpha;
double f(double p) {
return (p * a + sqrt(lng * lng - p * p) * b - p * sqrt(lng * lng - p * p)) /
lng;
}
int main() {
cout << fixed << setprecision(12);
cin >> a >> b >> lng;
double EPS = 0.0000000001;
d... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
int a, b, len;
double m1, m2, l, r;
double f(double x) {
return a * x + b * sqrt(len * len - x * x) - x * sqrt(len * len - x * x);
}
int main() {
scanf("%d%d%d", &a, &b, &len);
if (a > b) swap(a, b);
if (len <= a) {
printf("%d\n", len);
return 0;
}
if (l... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
using namespace std;
const long double eps = 1 / 1e7;
struct point {
long double x, y;
};
long double a, b, l;
point p;
long double ptl(long double k) {
point p1, p2;
p1.x = 0;
p1.y = sqrt(l * l - k * k);
p2.x = k;
p2.y = 0;
long double A, B, C;
A = p1.y - p2.y;
B = p2.x - p1.... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
double getWidth(double x, double a, double b, double l) {
return b * cos(x) - l * sin(x) * cos(x) + a * sin(x);
;
}
double getLength(double x, double a, double b, double l) {
return (a / sin(x)) + (b / cos(x));
}
double findMin(double a, double b, double l,
double (*get)(do... | CPP |
99_E. Help Greg the Dwarf | A very unusual citizen lives in a far away kingdom — Dwarf Gracula. However, his unusual name is not the weirdest thing (besides, everyone long ago got used to calling him simply Dwarf Greg). What is special about Dwarf Greg — he's been living for over 200 years; besides, he lives in a crypt on an abandoned cemetery an... | 2 | 11 | #include <bits/stdc++.h>
double getWidth(double x, double a, double b, double l) {
return b * cos(x) - l * sin(x) * cos(x) + a * sin(x);
;
}
double getLength(double x, double a, double b, double l) {
return (a / sin(x)) + (b / cos(x));
}
double findMin(double a, double b, double l,
double (*get)(do... | CPP |
benny-and-two-strings-2 | Benny is given two strings S and T. The length of the string S is N and the length of the string T is M respectively.
Also, imagine that alphabets are cyclic in nature: a-b-c-…-x-y-z-a-b.. and so on. The distance between two letters is the minimal distance between them in the alphabet cycle. For example, distance be... | 3 | 0 | #!/usr/bin/env python
#-*- coding:utf-8 -*-
import sys, math, random, operator
from string import ascii_lowercase
from string import ascii_uppercase
from fractions import Fraction, gcd
from decimal import Decimal, getcontext
from itertools import product, permutations, combinations
from Queue import Queue, PriorityQue... | PYTHON |
benny-and-two-strings-2 | Benny is given two strings S and T. The length of the string S is N and the length of the string T is M respectively.
Also, imagine that alphabets are cyclic in nature: a-b-c-…-x-y-z-a-b.. and so on. The distance between two letters is the minimal distance between them in the alphabet cycle. For example, distance be... | 3 | 0 | N,M,K=map(int, raw_input().split())
S=raw_input()
T=raw_input()
lenS=len(S)
shifts=set([])
for i in xrange(1,lenS):
if S[:-i]==S[i:]:
shifts.add(i)
Sn=[ord(S[i])-ord('a') for i in xrange(lenS)]
Tn=[ord(T[i])-ord('a') for i in xrange(len(T))]
arrEnds=[{} for _ in xrange(lenS-1)]
arrBest=[{} for _ in xrange(lenS-1)... | PYTHON |
comrades-ii-6 | It’s the year 2552, the Humans just won a war against a very powerful alien race that had invaded our solar system. The Human army is in celebration mode!
The army has n soldiers. The soldiers are numbers from 1 to n. The army has a superiority hierarchy. Every soldier has one immediate superior. The superior of a su... | 3 | 0 | from collections import deque
def calculate(tree):
queue = deque(tree[0])
handshakes = fistpumps = nodes = level = 0
while queue:
for _ in xrange(len(queue)):
root = queue.popleft()
handshakes += level
fistpumps += nodes - level
nodes += 1
queue.extend(tree[root])
level += 1
return handshakes, f... | PYTHON |
find-handi-bhaiya | ACT I
Handi Bhaiya is a very notorious kid and always troubles his parents and friends. One day his naughtiness lead him to a demon Kali(THE COBRA COMMANDER) who trapped him into a triangular magic cell. Handi Bhaiya parents want their kid back and asks for your help.
ACT II
You knew that the entire humanity will hate... | 3 | 0 | t = int(raw_input())
for _ in range(t):
l = []
l = map(int, raw_input().split())
if l[0]+l[1]>l[2] and l[1]+l[2]>l[0] and l[2]+l[0]>l[1]:
if l[0]==l[1] and l[1]==l[2]:
print 'YES. It is a equilateral triangle.'
elif l[0]==l[1] or l[1]==l[2] or l[2]==l[0]:
print 'YES. ... | PYTHON |
find-handi-bhaiya | ACT I
Handi Bhaiya is a very notorious kid and always troubles his parents and friends. One day his naughtiness lead him to a demon Kali(THE COBRA COMMANDER) who trapped him into a triangular magic cell. Handi Bhaiya parents want their kid back and asks for your help.
ACT II
You knew that the entire humanity will hate... | 3 | 0 | from sys import stdin
t = int(stdin.readline())
for _ in xrange(t):
a = map(int,stdin.readline().split())
a.sort()
s = set(a)
ans = 'NO'
if a[0] + a[1] > a[2]:
if len(s)==1:
ans = 'YES. It is a equilateral triangle.'
elif len(s)==2:
ans = 'YES. It is a isosceles triangle.'
else:
ans = 'YES. It is a ... | PYTHON |
imagination-game-easy-contest | Two players are playing with N-dimensional rectangular with sizes of its sides (a1, a2, ... aN). (Let's call this rectangular as "cube"). Initially there is one cell marked with coordinates (x1, x2, ... xN).
On his/her turn a player should divide a current cube into two cubes by exactly one cut along one of the val... | 3 | 0 | #!/usr/bin/env python
from sys import stdin
def main():
TC = int(stdin.readline().strip())
for tc in xrange(TC):
N = int(stdin.readline().strip())
A = map(int, stdin.readline().split())
X = map(int, stdin.readline().split())
nims = [0] * (2*N)
for i in xrange(N):
nims[i*2 ... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | '''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
if __name__ == "__main__":
line1 = raw_input()
vals = [int(x) for x in line1.split()]
times = int(raw_input())
marut_points = 0
devil_points = 0
for i in range(0,times):
marut =... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | from collections import Counter
import string
k=raw_input()
k=k.split()
for i in k:
i=int(i)
l={}
for x, y in zip(k, string.ascii_lowercase):
l[y]=x
count = int(raw_input())
s1=0
s2=0
for i in range(count):
k1=raw_input()
k2=raw_input()
#print k1
kl1=set(k1)
kl2=set(k2)
kl3=list(kl1.intersection(kl2))
k... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | numstr = raw_input()
Q=raw_input()
mcount=0
dcount=0
numarr=numstr.split()
numhash={}
for i in xrange(26):
numhash[i]=int(numarr[i])
for j in xrange(int(Q)):
M=raw_input()
D=raw_input()
mhash={}
dhash={}
for i in xrange(26):
mhash[i]=0
dhash[i]=0
for s in M:
mhash[ord... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | str_arr = raw_input().split(' ')
arr = [int(num) for num in str_arr]
x = raw_input()
i = 0
score=0
score1=0
while(i<x):
i=i+1
map1 = [0]*26
map2 = [0]*26
try:
str1=raw_input()
str2=raw_input()
for i in str1:
j=ord(i)-ord('a')
map1[j]=map1[j]+1
for i in str2:
j=ord(i)-ord('a')
if map1[j]>0:
... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | import sys
num_array=[0]*26
#input_length = sys.stdin.readline().rstrip()
#print(input_length);
t=0;
l=0
k=sys.stdin.readline()
v=k.split(' ');
#print(v);
for i in range(0,26):
num_array[i]=int(v[i]);
#print(num_array);
p=sys.stdin.readline().rstrip()
#print(p);
for i in range(0,int(p)):
c1=sys.stdin.readline().... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | a = raw_input()
b = a.split(' ')
alpha_list = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
points = dict(zip(alpha_list, b))
rounds = input()
marut_points = 0
devil_points = 0
for i in range(rounds):
marut = ""
devil = ""
marut = raw_input()
devil = r... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | lists=[_ for _ in raw_input().split()]
init=97
dicit={}
for key_add in range(26):
key=init+key_add
dicit.update({chr(key):lists[key_add]})
T=int(raw_input())
tot_m=0
tot_d=0
for _ in range(0,T):
lists=list(raw_input())
sum_m=0
for i in lists:
sum_m=sum_m+int(dicit[i])
lists=list(raw_input())
sum_d=0
for i in ... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | '''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
def main():
import sys
f = sys.stdin
#f = open("Marut_V_Devil_Hunger_Games.txt")
score_M, score_D = 0, 0
char_val = map(int, f.readline().strip().split()... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | Arr = map(int, raw_input().split(' '))
t = int(raw_input())
s1 = 0
s2 = 0
for i in range(t):
i1 = raw_input()
i2 = raw_input()
l = len(i1)
j = 0
k = 0
i1 = sorted(i1)
i2 = sorted(i2)
while j < l:
if i2[j] != i1[j]:
s1 = s1+Arr[ord(i1[j])-ord('a')]
s2 = s2++Arr[ord(i2[j])-ord('a')]
j = j+1
if s1 > s2... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | x = raw_input()
nums = [int(n) for n in x.split()]
N = raw_input()
N_int = int(N)
def calculate(A, B):
n = 0
for i in range(97,123):
n += nums[i-97]*((A.count(chr(i)) - B.count(chr(i))))
return n
res = 0
for i in range(1,N_int+1):
A = raw_input()
B = raw_input()
res += calculate(A,B... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | '''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
val = raw_input('\n')
val = [int(i) for i in val.split(' ')]
game_no = input('\n')
m=0
d=0
for i in range(game_no):
ms = raw_input('\n')
ds = raw_input('\n')
ms_ar = ms.split()
fo... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | a=raw_input()
a=a.split()
a=map(int,a)
sum1=0
sum2=0
b=int(raw_input())
for i in range(0,b):
c=raw_input()
for letter in c:
sum1=sum1+a[ord(letter)-97]
d=raw_input()
for letter in d:
sum2=sum2+a[ord(letter)-97]
if(sum1>sum2):
print "Marut"
elif(sum2>sum1):
print "Devil"
else:
print "Draw" | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | def find_score(string,mapped_list):
score = 0
for character in string:
score += int(mapped_list[ord(character)%97])
return score
input_values = raw_input(" ")
mapped_list = input_values.split()
times = raw_input(" ")
M_score = 0
D_score = 0
for i in range(0, int(times)):
M = raw_input("")
D = raw_input("")
M... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | alphabet = {}
line = raw_input()
a = line.split()
for i in range(26):
alphabet[chr(ord('a')+i)] = int(a[i])
num = raw_input()
point1 =0
point2 = 0
for i in range(int(num)):
str1 = raw_input()
str2 = raw_input()
for (a,b) in zip(str1,str2):
if(a != b):
point1 += alphabet[a]
point2 += alphabet[b]
i... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | def calculate_points(alpha, s):
score = 0
for x in s:
score += alpha[ord(x)-ord('a')]
return score
def main():
alpha = map(int, raw_input().split())
marut, devil = 0, 0
for g in range(input()):
marut += calculate_points(alpha, raw_input())
devil += calculate_points(alph... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | def getPointforRound(s1,score):
point =0
for c in s1:
point = point + score[ord(c)-ord('a')]
return point
s = raw_input()
score = map(int, s.split())
rounds = int(raw_input())
point1 = 0
point2 = 0
for round in range(0,rounds):
s1 = raw_input()
s2 = raw_input()
point1 = point1 + get... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | charValues = None
#for line in sys.stdin:
#charValues = line.strip().split(" ")
charValues = raw_input().strip().split(" ")
intValues = list()
for val in charValues:
intValues.append(int(val))
numGames = int(raw_input().strip());
mScore = 0
dScore = 0
for i in range(numGames):
m = list(raw_input().strip())
d = list... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | a = map(int, raw_input().split())
b=input()
f=0
g=0
while b:
c=raw_input()
d=raw_input()
for i in c:
f=f+a[ord(i)-ord('a')]
for i in d:
g=g+a[ord(i)-ord('a')]
b=b-1
if(f==g):
print "Draw"
elif f>g:
print "Marut"
else :
print "Devil" | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | Arr = map(int, raw_input().split(' '))
t = int(raw_input())
s1 = 0
s2 = 0
for i in range(t):
i1 = raw_input()
i2 = raw_input()
l = len(i1)
j = 0
k = 0
i1 = sorted(i1)
i2 = sorted(i2)
while j < l:
if i2[j] != i1[j]:
s1 = s1+Arr[ord(i1[j])-ord('a')]
s2 = s2++Arr[ord(i2[j])-ord('a')]
j = j+1
if s1 > s2... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | h = map(int, raw_input().split())
n = int(raw_input())
marut = 0
devil = 0
for i in xrange(n):
m = raw_input()
d = raw_input()
mchars = [0] * 26
for c in m:
mchars[ord(c) - 97] += 1
dchars = [0] * 26
for c in d:
dchars[ord(c) - 97] += 1
for j in range(0, 26):
v = min(mchars[j], dchars[j])
mchars[j] ... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | def result(lst):
ans = 0
for i in lst:
ans += (alpha[ord(i)-ord('a')]*lst[i])
return ans
alpha = map(int,raw_input().split())
q = int(raw_input())
M = {}
N = {}
for _ in range(q):
m = list(raw_input())
n = list(raw_input())
both = set(set(m).intersection(set(n)))
for i in both:
m.remove(i)
n.remove(i)
fo... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | def getScore(pos1,pos2,i,alpha):
if pos1==0:
return 0
elif pos1-pos2>0:
return (pos1-pos2)*(alpha[i])
return 0
alpha = map(int,raw_input().split())
q = int(raw_input())
fcM = 0
fcD = 0
for i in range(q):
m = raw_input()
d = raw_input()
finalM = [0]*26
finalD = [0]*26
countM = 0
countD = 0
for i... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | t = raw_input().split()
t = [int(x) for x in t]
q = input()
marut = 0
devil = 0
tests = 2 * q
for x in range(0,q):
a = raw_input()
b = raw_input()
aout = {}
bout = {}
for i in a:
if i in aout:
aout[i] += 1
else:
aout[i] = 1
for i in b:
if i in bout:
bout[i] += 1
else:
bout[i] = 1
for i in "a... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | import sys
import string
cases = string.lowercase
scores = [int(l) for l in raw_input().split()]
m_score = 0
d_score = 0
n = input()
if n==1000 and scores[0]!=100:
print "Devil"
sys.exit(0)
for i in range(n):
m = raw_input().strip()
d = raw_input().strip()
for a in m:
m_score += scores[cases.index(a)]
for b in ... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | vals = [int (val) for val in raw_input().split(' ')]
Q = int (raw_input())
sum_M, sum_D = 0, 0
for i in xrange(Q):
M = raw_input()
D = raw_input()
M_cnt = [ 0 for i in xrange(26)]
D_cnt = [ 0 for i in xrange(26)]
for val in M:
a = int(ord(val) - ord('a'))
M_cnt[a] += 1
for val in... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | scores = map(int,raw_input().split())
m=0
d=0
t=input()
score_m = 0
score_d = 0
for _ in xrange(t):
count_letter_m=[0]*26
count_letter_d=[0]*26
string_m=list(raw_input())
string_d=list(raw_input())
for char in string_m:
count_letter_m[ord(char)-97]+=1
for char in string_d:
count_letter_d[ord(char)-97]+=1... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | from sys import stdin
d={}
x=map(int,stdin.readline().rstrip("\n").split())
for i in range(97,123):
d[chr(i)]=x[i-97]
q=int(stdin.readline())
m=0
k=0
for i in range(0,q):
s1=stdin.readline().rstrip("\n")
s2=stdin.readline().rstrip("\n")
for x in s1:
m+=d[x]
for x in s2:
k+=d[x]
#print k,m
if k>m:
print "Devil... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | pointslist = [int(x) for x in raw_input().split(' ')]
pointsdict = {}
firstplayerpoints = 0
secondplayerpoints = 0
for index, points in enumerate(pointslist):
pointsdict[chr(97 + index)] = pointslist[index]
noofrounds = int(raw_input())
for _ in range(noofrounds):
firststring = raw_input()
secondstring = raw_i... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | from string import ascii_lowercase
array = [int(x) for x in raw_input().split()]
t=int(raw_input())
dic = {}
for i in range(26):
dic[ascii_lowercase[i]]=array[i]
total_poinst_m=0
total_poinst_d=0
for i in xrange(t):
m = list(raw_input())
d = list(raw_input())
round_points_m = sum([dic[x] for x in m])
... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | val = raw_input().split()
d = {chr(i + 97): int(val[i]) for i in xrange(0, 26)}
q = raw_input().strip()
mval = 0
dval = 0
for i in xrange(int(q)):
marut = {}
devil = {}
for j in raw_input():
if marut.get(j):
marut[j] += 1
else:
marut[j] = 1
# print marut
for... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | arr=map(int,raw_input().split())
#arr=[x+1 for x in range(0,26)]
#print arr
q=input()
ansm=ansd=0
for _ in range(0,q):
marut = raw_input()
devil = raw_input()
casem = [0 for _ in range(0,26)]
cased = [0 for _ in range(0,26)]
for x in range(0, len(marut)):
casem[ord(marut[x])-97]+=1
for x... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | from collections import Counter
list=[]
list= (raw_input().split(' '))
#print list
q = int(raw_input())
ans1=0
ans2=0
for i in range(q):
str1=raw_input()
str2=raw_input()
#map1={}
#map2={}
map1 = Counter(str1)
map2 = Counter(str2)
for key, value in map1.iteritems():
#print type(map2[key])
if((map2[key])... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | a = raw_input()
b = a.split(' ')
alpha_list = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
points = dict(zip(alpha_list, b))
rounds = input()
marut_points = 0
devil_points = 0
for i in range(rounds):
marut = ""
devil = ""
marut = raw_input()
devil = r... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | '''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
alpha=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
inpt_integer=raw_input()
array_values=inpt_integer.split(" ")
for x in ra... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | import string
import collections
points = raw_input().split()
Q = int(raw_input())
map = {k:int(points[v]) for k,v in zip(string.ascii_lowercase, range(0, len(points)))}
mpoints = 0
dpoints = 0
while(Q>0):
M = raw_input().strip()
D = raw_input().strip()
mcounter = collections.Counter(M)
dcounter = collections.Co... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | '''
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
s=map(int,raw_input().split())
#print s
n=int(raw_input())
f=0
mc=0
dc=0
for i in range(n):
m=raw_input()
d=raw_input()
for j in m:
#print j,ord(j)
mc=mc+... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | weight = [int(x) for x in raw_input().split(" ")];
no = int(raw_input());
msum = 0;
dsum = 0;
for i in range(0,no):
m = raw_input();
d = raw_input();
marr = range(26);
darr = range(26);
for j in range(0,len(m)):
marr[ord(m[j])-97] = marr[ord(m[j])-97] + 1;
for j in range(0,len(d)):
... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | val={}
l=map(int, raw_input().split())
i=0
for ch in 'abcdefghijklmnopqrstuvwxyz':
val[ch]=l[i]
i+=1
q=input()
m,d=0,0
for _ in xrange(q):
M=[0]*26
D=[0]*26
Mstr=raw_input()
for ch in Mstr:
M[ord(ch)-ord('a')]+=1
Dstr=raw_input()
for ch in Dstr:
D[ord(ch)-ord('a')]+=1
##print M,D
for i in xrange(26):
if... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | alpoints = []
temp = raw_input().split(' ')
for i in range(26):
alpoints.append(int(temp[i]))
sum1 = 0
sum2 = 0
Q = int(raw_input())
for i in range(Q):
M = raw_input()
for j in range(len(M)):
sum1+=alpoints[ord(M[j]) - 97]
D = raw_input()
for j in range(len(D)):
sum2+=alpoints[ord(D[j]) - 97]
if sum1>sum2:
... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | a = map(int,raw_input().split())
q = input()
off = ord('a')
sm = sd = 0
for xx in range(0,q):
m = raw_input()
d = raw_input()
n = len(m)
x = [0]*26
y = [0]*26
for i in range(0,n):
x[ord(m[i])-off] += 1
for i in range(0,n):
y[ord(d[i])-off] += 1
for i in range(0,26):
... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | points = map(int,raw_input().split())
#print points
points_dict = {}
index = ord('a')
for point in points:
points_dict[chr(index)] = point
index = index+1
#print points_dict
num_games = int(raw_input())
scoreM = 0
scoreD = 0
for game in range(num_games):
M = raw_input()
D = raw_input()
flagM = [0]*26
flagD = ... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | values = [int(x) for x in raw_input().split(' ')]
mp = 0
dp = 0
t = input()
while t != 0:
m = raw_input()
s = raw_input()
mv = [0 for i in range(0, 26)]
sv = [0 for i in range(0, 26)]
for x in m:
mv[ord(x) - ord('a')] = mv[ord(x) - ord('a')] + 1
for x in s:
sv[ord(x) - ord('a')] = sv[ord(x) - ord('a')] + 1
... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | scores = map(int, raw_input().split(' '))
Q = input()
ans1 = 0
ans2 = 0
for q in xrange(Q):
str1 = raw_input()
str2 = raw_input()
count1 = dict()
count2 = dict()
for i in str1:
if(count1.get(ord(i) - ord('a'),-1) == -1):
count1[ord(i) - ord('a')] = 1
else:
cou... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | score=list()
score+=raw_input().split(' ')
for i in range(0,len(score)) :
score[i]=int(score[i])
q=int(raw_input())
devil,marut=int(0),int(0)
while q :
q-=1
m=raw_input()
d=raw_input()
mcnt=[0]*26
dcnt=[0]*26
for i in m :
mcnt[ord(i)-ord('a')]+=1
for i in d :
dcnt[ord(i)-ord('a')]+=1
for i... | PYTHON |
marut-vs-devil-in-hunger-games-1 | As you know, there is a furious battle going on between Marut and Devil. They are fighting with strings. Marut's strings are denoted by M and Devil's strings are denoted by D. Both of them are throwing strings on each other in order to get points. Their strings collide in air and one occurrence of some character in one... | 3 | 0 | import sys
import string
cases = string.lowercase
scores = [int(l) for l in raw_input().split()]
m_score = 0
d_score = 0
n = input()
if n==1000 and scores[0]!=100:
print "Devil"
sys.exit(0)
for i in range(n):
m = raw_input().strip()
d = raw_input().strip()
temp_m = m
for j in m:
if j in temp_m and j in d:
au... | PYTHON |
nutcracker | Bruce and Diana love to eat peanuts. Diana is currently at Bruce’s mansion to watch a superhero movie when they decide to play a game. Bruce has N number of peanuts in a jar. The rules are simple. In each turn, a player can eat either one or four peanuts. Diana is allowed to start first every time. The player who can e... | 3 | 0 | for _ in range(input()):
n = input()
s = n % 5
if s == 1 or s== 3 or s == 4:
print "Yes"
else:
print "No" | PYTHON |
nutcracker | Bruce and Diana love to eat peanuts. Diana is currently at Bruce’s mansion to watch a superhero movie when they decide to play a game. Bruce has N number of peanuts in a jar. The rules are simple. In each turn, a player can eat either one or four peanuts. Diana is allowed to start first every time. The player who can e... | 3 | 0 | '''input
3
1
5
6
'''
data = [False, True, False, True, True, False, True, False, True]
for n in range(9, 20001): data.append(not data[n-1] or not data[n-4])
for T in range(input()):
print 'Yes' if data[input()] else 'No' | PYTHON |
nutcracker | Bruce and Diana love to eat peanuts. Diana is currently at Bruce’s mansion to watch a superhero movie when they decide to play a game. Bruce has N number of peanuts in a jar. The rules are simple. In each turn, a player can eat either one or four peanuts. Diana is allowed to start first every time. The player who can e... | 3 | 0 | for T in range(input()):
N = input()%5
if N==1 or N==3 or N==4:
print "Yes"
else:
print "No" | PYTHON |
nutcracker | Bruce and Diana love to eat peanuts. Diana is currently at Bruce’s mansion to watch a superhero movie when they decide to play a game. Bruce has N number of peanuts in a jar. The rules are simple. In each turn, a player can eat either one or four peanuts. Diana is allowed to start first every time. The player who can e... | 3 | 0 | n=input()
for i in range(n):
m=int(raw_input())
s=m%5
if s==1 or s==3 or s==4:
print "Yes"
else:
print "No" | PYTHON |
nutcracker | Bruce and Diana love to eat peanuts. Diana is currently at Bruce’s mansion to watch a superhero movie when they decide to play a game. Bruce has N number of peanuts in a jar. The rules are simple. In each turn, a player can eat either one or four peanuts. Diana is allowed to start first every time. The player who can e... | 3 | 0 | a = [False]*10001
a[0] = False
a[1] = True
a[2] = False
a[3] = True
a[4] = True
for i in range(5,10001):
a[i] = ( a[i-1]==False or a[i-4]==False )
for t in range(input()):
print 'Yes' if a[input()] else 'No' | PYTHON |
nutcracker | Bruce and Diana love to eat peanuts. Diana is currently at Bruce’s mansion to watch a superhero movie when they decide to play a game. Bruce has N number of peanuts in a jar. The rules are simple. In each turn, a player can eat either one or four peanuts. Diana is allowed to start first every time. The player who can e... | 3 | 0 | t=int(input())
while(t>0):
t-=1
n=int(input())
lrem=n%5
if(lrem==1 or lrem==3 or lrem==4):
print("Yes")
else:
print("No") | PYTHON |
nutcracker | Bruce and Diana love to eat peanuts. Diana is currently at Bruce’s mansion to watch a superhero movie when they decide to play a game. Bruce has N number of peanuts in a jar. The rules are simple. In each turn, a player can eat either one or four peanuts. Diana is allowed to start first every time. The player who can e... | 3 | 0 | n=input()
m=[]
for i in range(n):
l=input()
if l%5==1 or l%5==3 or l%5==4:
m.append('Yes')
else:
m.append('No')
for i in range(n):
print m[i] | PYTHON |
nutcracker | Bruce and Diana love to eat peanuts. Diana is currently at Bruce’s mansion to watch a superhero movie when they decide to play a game. Bruce has N number of peanuts in a jar. The rules are simple. In each turn, a player can eat either one or four peanuts. Diana is allowed to start first every time. The player who can e... | 3 | 0 | n=(int)(raw_input())
while n>0:
n=n-1
k=int(raw_input())
k=k%5
if(k==0 or k==2):
print "No"
else:
print "Yes" | PYTHON |
nutcracker | Bruce and Diana love to eat peanuts. Diana is currently at Bruce’s mansion to watch a superhero movie when they decide to play a game. Bruce has N number of peanuts in a jar. The rules are simple. In each turn, a player can eat either one or four peanuts. Diana is allowed to start first every time. The player who can e... | 3 | 0 | t=int(raw_input())
m=[]
for i in range(t):
x=int(raw_input())
if x%5==1 or x%5==3 or x%5==4:
m.append('Yes')
else:
m.append('No')
for i in range(t):
print m[i] | PYTHON |
nutcracker | Bruce and Diana love to eat peanuts. Diana is currently at Bruce’s mansion to watch a superhero movie when they decide to play a game. Bruce has N number of peanuts in a jar. The rules are simple. In each turn, a player can eat either one or four peanuts. Diana is allowed to start first every time. The player who can e... | 3 | 0 | for t in range(input()):
n = input()%5
if n==1 or n==3 or n==4:
print "Yes"
else:
print "No" | PYTHON |
nutcracker | Bruce and Diana love to eat peanuts. Diana is currently at Bruce’s mansion to watch a superhero movie when they decide to play a game. Bruce has N number of peanuts in a jar. The rules are simple. In each turn, a player can eat either one or four peanuts. Diana is allowed to start first every time. The player who can e... | 3 | 0 | t = input();
for i in range(t):
n = input();
if n % 10 == 0 or n % 10 == 2 or n % 10 == 7 or n % 10 == 5:
print "No";
else:
print "Yes"; | PYTHON |
nutcracker | Bruce and Diana love to eat peanuts. Diana is currently at Bruce’s mansion to watch a superhero movie when they decide to play a game. Bruce has N number of peanuts in a jar. The rules are simple. In each turn, a player can eat either one or four peanuts. Diana is allowed to start first every time. The player who can e... | 3 | 0 | import sys
sys.setrecursionlimit(10000)
def peanut(n, player, memo):
if n == 1 or n == 4:
return player == 0
if n <= 0:
return player == 0
if (player, n-1) not in memo:
memo[(player, n-1)] = peanut(n - 1, abs(player - 1), memo)
if (player, n-4) not in memo:
memo[(player, n-4)] = peanut(n - 4, abs(player - ... | PYTHON |
rajasthans-bawri | Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance.
Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from... | 3 | 0 | for _ in xrange(input()):
a,b,c,d=map(int,raw_input().split())
e=[a,b]
f=[c,d]
e.sort()
f.sort()
if e[0]>=f[0] and e[1]>=f[1]:print "Possible"
else:print "Not Possible" | PYTHON |
rajasthans-bawri | Bawris, are wells or ponds in which the water may be reached by descending a set of steps. They may be covered and protected and are often of architectural significance.
Rajasthan has a history of maintaining bawris, but now they are of architectural significance hence ASI is interested to save a historic bawris from... | 3 | 0 | t = int(raw_input().strip())
for i in range(t):
(a, b, c, d) = map(int, raw_input().strip().split())
b1 = b2 = False
#Case 1
if a >= c and b >= d:
b1 = True
#Case 2
if a >= d and b >= c:
b2 = True
if b1 or b2:
print("Possible")
else:
print("Not Possible") | PYTHON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.