prompt string | response string |
|---|---|
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
signed main() {
ios::sync_with_stdio(0);
string seq;
cin >> seq;
vector<int> sfx(seq.size());
for (int i = 0; i + 5 <= seq.size(); ++i) {
sfx[i] = seq.substr(i, 5) == "metal";
}
for (int i = seq.size() - 1; i - 1 >= 0; --i) {
sfx[i - 1] += sfx[i];
}
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | ans = 0
s = raw_input()
heavy = 0
i = 0
while i < len(s) - 4:
if s[i : i + 5] == "heavy":
heavy += 1
i += 5
elif s[i : i + 5] == "metal":
ans += heavy
i += 5
else:
i += 1
print ans |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | s = raw_input().split("heavy")
print sum(s[i].count("metal")*i for i in xrange(len(s)))
|
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.*;
import java.util.*;
/**
*
* @author Rohan
*/
public class Main {
/**
* @param args the command line arguments
*/
static long[] num_of_Y=new long[1000010];
static boolean[] isX... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | s = input()+'#'
n = len(s)
ans=[0]*2
for i in range(4,n):
aa = s[i-4:i+1]
if aa=='heavy':
ans[0]+=1
elif aa=='metal':
ans[1]+=ans[0]
print(ans[1])
|
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import static java.lang.Math.*;
import static java.lang.System.out;
import java.util.*;
import java.io.PrintStream;
import java.io.PrintWriter;
public class A {
static final int mod = 1000000007;
static final long temp = 99... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | def count_metal(l,x,y):
new_line = l[x:y+1]
return new_line.count("metal")
def solver():
line = raw_input()
ans = 0
metal_num = line.count("metal")
pass_metal = 0
s = 0
l = line
while l != "":
x = l.find("heavy")
#print l,s,s+x,line[s:s+x],
if x == -1:
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class StringsPower {
public static void main(String[] args) throws Exception {
BufferedReader k = new BufferedReader(new InputStreamReader(System.in));
String s=k.readLine();
long count01=0,... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
long long ans = 0, m = 0;
cin >> s;
for (int i = s.size() - 5; i >= 0; i--) {
if (s.substr(i, 5) == "metal")
m++;
else if (s.substr(i, 5) == "heavy")
ans = ans + m;
else
continue;
}
cout << ans << endl;
retu... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.io.*;
public class B {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
long count = 0L;
long startCount = 0L;
int length = str.length();
f... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... |
import java.util.ArrayList;
import java.util.Scanner;
public class B318 {
public static void main(String []args){
Scanner in=new Scanner(System.in);
String s=in.next();
char ch[]=new char[s.length()];
ch=s.toCharArray();
ArrayList<Integer>h=new ArrayList<>();
ArrayList<Integer>m=new ArrayList<>();
int ... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.util.Scanner;
public class Problem2 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
while (in.hasNextLine()) {
String line = in.nextLine();
getNumberHeavies(line);
}
}
private s... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.util.Scanner;
public class B318 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String s = input.next();
long answer = 0;
long heavy = 0;
for (int i=0; i<=s.length()-5; i++) {
String part = s.substring(i,i+5);
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g;
vector<bool> used;
vector<int> lp;
queue<int> q;
int main() {
char met[5] = {'m', 'e', 't', 'a', 'l'};
char hev[5] = {'h', 'e', 'a', 'v', 'y'};
long long t = 1;
for (int i = 0; i < t; i++) {
string str;
cin >> str;
size_t found = s... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | s=input()
start=0
rs=0
for i in range(len(s)):
if s[i:i+5]=='heavy':
start+=1
if s[i:i+5]=='metal':
rs=rs+start
print(rs)
|
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
int n;
getline(cin, s);
n = s.size();
long long cnt = 0;
for (int i = 0; i < n - 4; i++) {
if (s.substr(i, 5) == "metal") cnt++;
}
long long ret = 0;
for (int i = 0; i < n - 4; i++) {
if (s.substr(i, 5) == "heavy") ret += cnt... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | /***
* βββββββ=====ββββββββ====ββββββββ====βββββββ=
* ββββββββ====ββββββββ====ββββββββ====ββββββββ
* βββ==βββ====ββββββ======ββββββ======ββββββββ
* βββ==βββ====ββββββ======ββββββ======βββββββ=
* ββββββββ====ββββββββ====ββββββββ====βββ=====
* βββββββ=====ββββββββ====ββββββββ====βββ=====
* ===... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
char a[maxn];
int main() {
scanf("%s", a);
int len = strlen(a);
long long ans = 0, sum = 0;
for (int i = 0; i < len - 4; i++) {
if (a[i] == 'h' && a[i + 1] == 'e' && a[i + 2] == 'a' && a[i + 3] == 'v' &&
a[i + 4] == 'y')
s... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #!/usr/bin/env python
def sol():
out = 0
s = raw_input()
for i, h in enumerate(s.split('heavy')):
out += h.count('metal') * i
print out
sol()
|
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
long long sum1 = 0;
long long sum2 = 0;
for (int i = 0; i < s.size(); ++i) {
if (s.substr(i, 5) == "heavy")
sum2++;
else if (s.substr(i, 5) == "metal")
sum1 = sum1 + sum2;
}
cout << sum1 << endl;
return 0;... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | aisa = input()
kyu = 0
channa = 0
for i in range(len(aisa)-4):
if aisa[i:i+5] == 'heavy':
kyu += 1
if aisa[i:i+5] == 'metal':
channa += kyu
print(channa) |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | //package codeforces;
import java.util.Scanner;
/**
* Created by nitin.s on 20/03/16.
*/
public class StringsOfPower {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String heavy = "heavy";
String metal = "metal";
String s = in.next();
int h... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
char s[1000005];
int main() {
long long int i, j, k = 1, l, m, n, c = 0, h = 0, ans = 0;
gets(s);
l = strlen(s);
for (i = 0; i < l;) {
if (!strncmp(s + i, "heavy", 5)) {
h++;
i += 5;
} else if (!strncmp(s + i, "metal", 5)) {
ans += h;
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
long long ans, heavy;
string s;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> s;
for (int i = 0; i <= (int)s.size() - 5; i++) {
if (s.substr(i, 5) == "heavy") {
heavy++;
} else if (s.substr(i, 5) == "metal") {
a... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:60000000")
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-12;
const int INF = (1 << 31) - 1;
const long long LLINF = ((long long)1 << 62) - 1;
const int maxn = 1000010;
vector<long long> v;
long long cnt[maxn];
int main() {
string s;
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
char s[1010010];
int a[1010010] = {0}, b[1010010] = {0};
int cura[1010010], curb[1010010];
char aa[] = "heavy", bb[] = "metal";
int main() {
int i, j, k;
long long ans;
int n;
cin >> s;
n = strlen(s);
for (i = 0; i < n - 4; i++) {
for (j = i; j < i + 5; j++)... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #!/usr/bin/env python3
def main():
line = input()
final = 0
count = 0
for i in range(len(line)-4):
if 'heavy' == line[i:i+5]:
count += 1
i += 5
elif 'metal' == line[i:i+5]:
final += count
i += 5
print(final)
if __name__ == '__main__':... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... |
import java.util.*;
import java.lang.*;
import java.io.*;
public class Codeforces {
public static void main (String[] args) throws IOException {
BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
String s = read.read... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String line = sc.next();
ArrayList<Integer> list1 = new ArrayList<Integer>(), list2 = new ArrayList<Integer>();
for (int i = 0; i + 5 <= line.length();... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import sys, re, string
S = sys.stdin.readline().strip()
T = [(m.start(0), "h") for m in re.finditer("heavy", S)] + [(m.start(0), "m") for m in re.finditer("metal", S)]
T.sort()
R = "".join(ch[1] for ch in T)
ans = 0
Ms = string.count(R, "m")
for x in xrange(len(R)):
if R[x] == "h":
ans += Ms
else:
Ms -= 1
pri... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
int main() {
string s, s1 = "";
cin >> s;
long long i = 0, j = s.length() - 1, c = 0, d = 0;
for (; i < s.length(); ++i) {
if (s[i] == 'h') {
s1 = s.substr(i, 5);
if (s1 == "heavy") {
while (j > i) {
if (j <= s.length() - 5 && s[j] ... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return (b == 0 ? a : gcd(b, a % b)); }
long long lcm(long long a, long long b) { return (a * (b / gcd(a, b))); }
int main() {
string s;
cin >> s;
int n = s.size();
long long cnt = 0;
vector<long long> _metal;
string meta... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.util.Scanner;
import java.util.ArrayList;
import java.util.regex.*;
public class B318
{
public static void main(String[] args)
{
Scanner cin = new Scanner (System.in);
while (cin.hasNext())
{
String str = cin.next();
String regex = "(heavy)|(metal)";
Pattern pat = Pattern.compile(regex);
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e6 + 10;
ll KMP[N];
ll sum1 = 0, z = 0;
void asd(ll* p, string s, string s1, ll a) {
ll len = s.size(), len1 = s1.size(), i, j, k;
j = 0, KMP[0] = KMP[1] = 0;
for (i = 1; i < len1; i++) {
while (j && s1[i] != s1[j]) j = KMP[j];
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | from sys import stdin, stdout
import math
import bisect
s = stdin.readline().strip()
heavy = []
metal = []
for i in range(len(s) - 5 + 1):
if s[i] not in ['m', 'h']:
continue
tmp = s[i:i + 5]
if tmp == 'heavy':
heavy.append(i)
elif tmp == 'metal':
metal.append(i)
ans = 0
for... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.math.BigInteger;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static void main(String[] args) {
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.util.*;
public class PowerString {
/**
* @param args
*/
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
long finalCounter=0;
boolean Heavy=false;
boolean Metal=false;
int counterForHeavy=0;
int counterForMetal=0; ... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class B318_CF {
public static long numberOfPowerfulStrings(String string) {
String heavy = "heavy";
String metal = "metal";
if (string.length() < 5) return 0;
long sum = 0;
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int SIZE = 1e5 + 10;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class StringOfPower3 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String in =sc.next();
System.out.println(process(in));
}
pub... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.util.ArrayList;
import java.util.Scanner;
import javax.swing.text.html.HTMLDocument.HTMLReader.ParagraphAction;
public class StringsOfPower {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
final String heavy = "heavy";
final String metal = "metal";
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | s = raw_input()
ans = 0
v = s.split('heavy')
for i, e in enumerate(v):
ans += i * e.count('metal')
print ans
|
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.io.BufferedReader;
import java.io.InputStreamReader;
/**
* @author grozhd
*/
public class P2 {
private static char[] s;
private static final String heavy = "heavy";
private static final String metal = "metal";
public static void main(String[] args) {
read();
i... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
string s;
long long ans, cnt;
int main() {
cin >> s;
for (int i = s.size() - 1; i >= 4; i--) {
if (s[i] == 'l' && s[i - 1] == 'a' && s[i - 2] == 't' && s[i - 3] == 'e' &&
s[i - 4] == 'm')
cnt++;
else if (s[i] == 'y' && s[i - 1] == 'v' && s[i - 2] =... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | h=input()
a,b=0,0
n=len(h)
for i in range(n):
if(h[i:i+5]=='heavy'):
a=a+1
elif(h[i:i+5]=='metal'):
b=b+a
print(b)
|
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | s = input()
n = len(s)
counter = 0
heavy = 0
i = 0
while i < n:
if s[i:i+5] == "heavy":
heavy += 1
i = i + 5
elif s[i:i+5] == "metal":
counter += heavy
i += 5
else:
i += 1
print(counter) |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | //package javaapplication1;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... |
import re
def main(data = None):
patt1 = re.compile('(heavy|metal)')
if data is None:
text = raw_input()
else:
text =data
heavymetals = [(m.group()) for m in re.finditer(patt1,text)]
heavys =0
hm=0
for t in heavymetals:
if t == 'heavy':
heavys ... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
string s;
cin >> s;
long long metals = 0, ans = 0;
for (int i = 0; i < s.size(); i++) {
if (s.substr(i, 5) == "heavy") v.push_back(metals);
if (s.substr(i, 5) == "metal") metals++;
}
for (int i = 0; i < v.size(); i++) ans += m... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import sys
def parse(txt, s):
i = 0
while True:
i = txt.find(s, i) + 1
if i == 0:
break
yield i - 1
def go():
#s = "heavymetalisheavymetal"
s = sys.stdin.readline()
left = [x for x in parse(s, "heavy") ]
right = [ _ for _ in parse(s, "metal")]
#print ... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
int modulo(int a, int b, int c) {
long long x = 1, y = a;
while (b > 0) {
if (b % 2 == 1) {
x = (x * y) % c;
}
y = (y * y) % c;
b /= 2;
}
return x % c;
}
int gcd(int a, int b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
int... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... |
import java.io.*;
import java.util.*;
public class B188
{
public B188()
{
Scanner in = new Scanner(System.in);
String input = in.nextLine();
int[] arr = new int[input.length()];
int index = input.indexOf("heavy");
while(index >= 0)
{
arr[index] = 1;
index = input.indexOf("heavy", index +... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | t = input()
t = t.replace('heavy', '0')
t = t.replace('metal', '1')
a, b, s = 0, t.count('1'), 0
for i in t:
if i == '0':
a += 1
s += b
if i == '1': b -= 1
print(s) |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | s = raw_input()
i = 0
h = 0
r = 0
while i < (len(s)-4):
if (s[i:i+5] == 'heavy'):
h += 1
i += 4
elif (s[i:i+5] == 'metal'):
r += h
i += 4
i += 1
print r
#s = raw_input()
#s1 = s.split()
#n = int(s1[0])
#k = int(s1[1])
#b = n/2 + (n%2)
#if k <= b:
# print k*2-1
#else:
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
const long long int INF = 1e18;
const long long int MAX_N = 1e6 + 4;
void solve() {
string s;
cin >> s;
int n = s.size();
string hs = "heavy";
string ms = "metal";
int h = 0;
long long int ans = 0;
for (int i = 0; i + 4 < n... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
;
const double PI = 2 * acos(0.0);
string s;
vector<int> heavy, metal;
int main() {
cin >> s;
for (int i = 0; i < s.size(); i++) {
string tmp = "", fmp;
for (int j = i, c = 0; j < s.size() && c < 5; j++, c++) {
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.io.*;
import java.util.*;
public class MainClass {
public static void main(String[] args) {
Locale.setDefault(Locale.US);
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
MainClass solution = new MainClass();
solution.run(in, out);
in.close();
out.close();... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.io.*;
import java.util.*;
public class cf318b {
public static void main(String args[]) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String s = in.readLine().trim();
char[] c = s.toCharArray();
int lastmetal = s.lastIndexOf("metal");
if(lastmetal <... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #import io,os
#input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline #deactivate when input contains string
from collections import deque as que, defaultdict as vector
from bisect import bisect as bsearch
from heapq import*
inin = lambda: int(input())
inar = lambda: list(map(int,input().split()))
#inst= lambda: inp... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | from collections import defaultdict
s=input()
d=defaultdict(list)
for x in range(len(s)-4):
if s[x]=="h" and s[x+1]=="e" and s[x+2]=="a" and s[x+3]=="v" and s[x+4]=="y":
d["h"].append(x)
elif s[x]=="m" and s[x+1]=="e" and s[x+2]=="t" and s[x+3]=="a" and s[x+4]=="l":
d["m"].append(x)
p=len(d["m"]... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Set;
public class Main
{
publi... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
const long long A = 100000000000000LL, N = 10000;
string a, b = "metal", c = "heavy";
long long t, o, i, j, n, m;
int main() {
cin >> a;
n = a.size();
for (i = 0; i + b.size() - 1 < n; i++) {
if (a.substr(i, 5) == b)
o += t;
else if (a.substr(i, 5) == c)... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | HEAVY = "heavy"
METAL = "metal"
s = raw_input()
res = 0
heavy_occurences, i = 0, 0
while i < len(s):
if s[i:i+5] == HEAVY:
heavy_occurences += 1
i = i+5
elif s[i:i+5] == METAL:
res += heavy_occurences
i = i+5
else:
i += 1
print(res)
|
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
int main() {
char a[1000100];
scanf("%s", a);
int len = strlen(a);
long long ans = 0, h = 0, i, j, k;
for (i = 0; i < len; i++) {
if (a[i] == 'h' && a[i + 1] == 'e' && a[i + 2] == 'a' && a[i + 3] == 'v' &&
a[i + 4] == 'y')
h++, i += 4;
else i... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;
public class Main2 {
static int lowerBound(int[] arr, int l, int r, int key)
{
int res = -1;
while(l <= r)
{
int mid = l + (r - l)/2;
if(arr[mid] <= key)
l = mid + 1;
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | def main():
from sys import stdin, stdout
#map(int, (x for x in stdin.readline().split())) for int input
#sort(key=lambda: tup= (TUPLE)) for TUPLE based sort. multiple times in place for mixed order
#start here
s=raw_input()
n=len(s)
t=0
c=0
for i in xrange(n-4):
if(s[i:i+5]=... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.io.*;
import java.math.BigInteger;
public class Main{
public static void main(String[] args) throws IOException {
BufferedReader Bf = new BufferedReader(new InputStreamReader(System.in));
String input = Bf.readLine();
BigInteger start = new BigInteger("0"), end = new BigInteger("0");
for (int i = 0... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.io.*;
import java.util.*;
public class B {
public static void main(String[] args) throws IOException {
BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
Scanner s = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
char[] a = f.readLine().toCharArray(... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
int main() {
string a;
cin >> a;
long long cot = 0;
long long sum = 0;
for (int i = a.length() - 5; i >= 0; i--) {
if (a[i] == 'm' && a[i + 1] == 'e' && a[i + 2] == 't' && a[i + 3] == 'a' &&
a[i + 4] == 'l') {
cot++;
}
if (a[i] == 'h' && ... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | line = raw_input().split("heavy")
#print line
ans = 0
c = 0
for s in line:
var = s.count("metal")
ans += var*c
c += 1
print ans |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #_________________ Mukul Mohan Varshney _______________#
#Template
import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt,floor,factorial,gcd,log,ceil
from collections import deque,Counter,defaultdict
from itertools import permut... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
char word[1000005];
bool cmp(int i, int j, char *c) {
int k = 0;
for (; i <= j && word[i] && c[k] && word[i] == c[k]; i++, k++)
;
if (i > j)
return true;
else
return false;
}
int main() {
scanf("%s", word);
int i;
int cnth = 0, cntm = 0;
long lon... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
char a[1000000];
int main() {
scanf("%s", a);
int len = strlen(a) - 4;
long long int ans = 0, h = 0, i, j, k;
for (i = 0; i < len; i++) {
if (a[i] == 'h' && a[i + 1] == 'e' && a[i + 2] == 'a' && a[i + 3] == 'v' &&
a[i + 4] == 'y') {
i += 4;
h... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.util.*;
import java.io.*;
public class aprail15
{
static class InputReader {
private InputStream stream;
private byte[] inbuf = new byte[1024];
private int start= 0;
private int end = 0;
public InputReader(InputStream stream) {
this.stream = stream;
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.util.*;
public class StringsOfPower {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
int l=s.length();
long c1=0,d=0;
for(int i=0;i<l;i++)
{
char c=s.charAt(i);
if(c=='h' && i<=(l-5))
{
String s1=s.substring(i, i+5);
if(s1... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... |
import java.util.Scanner;
public class StringsOfPower {
public static void main(String asd[])throws Exception
{
Scanner in=new Scanner(System.in);
String s=in.nextLine();
int a[]=new int[s.length()/5+1];
String b="heavy";
String c="metal";
int k=0;long m=0,q=0;
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.StringTokenizer;
@SuppressWarnings("unus... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | from re import findall
h, acc = 0, 0
for i in findall('heavy|metal', input()):
if i.startswith('h'): h += 1
else: acc += h
print(acc) |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | s = input()
p1 = 0
p2 = 0
hvy = []
mtl = []
p1 = s.find('heavy')
p2 = s.find('metal')
while p1>=0 or p2>=0:
if p1>=0:
hvy.append(p1)
p1 = s.find('heavy', p1 + 1)
if p2>=0:
mtl.append(p2)
p2 = s.find('metal',p2+1)
v = len(s)
d = [0]*v
for i in hvy:
d[i]+=1
for i in range(1,v):... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | print(sum(i*s.count("metal") for i, s in enumerate(input().split("heavy"))))
|
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
#pragma comment(linker, "/STACK:134217728")
using namespace std;
int n;
string s;
char a[1000007];
int main() {
int t;
scanf("%s", a);
s = a;
n = s.size();
int kh = 0;
long long sol = 0;
for (int i = (4); i < (n); ++i) {
if (s[i - 4] == 'h' && s[i - 3] == 'e' && s[i - 2] == 'a... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... |
#------------------------template--------------------------#
import os
import sys
from math import *
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
def array():
return [int(i) for i in input().split()]
BUFSIZE = 8192
class FastIO(IOBase... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | inp = input()
out = 0
heavys = 0
for i in range(len(inp)-4):
if inp[i:i+5] == "heavy":
heavys += 1
elif inp[i:i+5] == "metal":
out += heavys
print(out) |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.util.Scanner;
public class StringsOfPower {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String s = input.next();
long count = 0 , powerCount = 0;
for(int i = 0; i < s.length(); i++){
if(i+5 <= s.length()){
S... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1e8;
const int N = 100005;
const double PI = 4 * atan(1);
set<char> vowel = {'A', 'O', 'Y', 'E', 'U', 'I', 'a', 'o', 'y', 'e', 'u', 'i'};
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, 1, -1, -1};
long long gcd(long long a, long long b) ... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
int main() {
long long ret = 0, i, j, n, k, cnt = 0, x;
string s, sh, sm;
cin >> s;
n = s.length();
for (int i = 0; i < n; i++) {
if (s[i] == 'h' && i + 4 < n) sh = s.substr(i, 5);
if (sh == "heavy") {
cnt++;
sh = "";
}
if (s[i] == 'm' ... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
int main() {
string str;
string test;
long long h_cnt = 0;
long long num = 0;
cin >> str;
for (int i = 0; i < str.size(); i++) {
if (str[i] == 'h') {
test.assign(str, i, 5);
if (!test.compare("heavy")) {
h_cnt++;
i += 4;
}
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | # -*- coding: utf-8 -*-
"""
Spyder Editor
This temporary script file is located here:
/home/zangetsu/.spyder2/.temp.py
"""
from __future__ import division;
from bisect import *;
import sys;
from math import *;
from fractions import *;
from itertools import *;
import io;
import re;
INF = 987654321987654321987654321;... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... |
import java.util.Scanner;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Mr Dj Thuk
*/
public class NewClass {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s;
s=sc.nextLine();
long head=0;
... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | s = input()
i, heavy, count = 0, 0, 0
while i < len(s):
if s[i:i+5] == "heavy":
heavy += 1
i += 5
elif s[i:i+5] == "metal":
count += heavy
i += 5
else:
i = i + 1
print(count) |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #!/usr/bin/python
strList = map(str, raw_input().split('heavy'))
cntHeavy = 0
answer = 0
for i in strList:
answer += cntHeavy * i.count('metal')
cntHeavy += 1
print answer
|
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | s = input()
i, heavy, count = 0, 0, 0
while i < len(s) - 4:
if (s[i] == "h" and s[i+1] == "e" and s[i+2] == "a" and
s[i+3] == "v" and s[i+4] == "y"):
heavy += 1
i += 5
elif (s[i] == "m" and s[i+1] == "e" and s[i+2] == "t" and
s[i+3] == "a" and s[i+4] == "l"):
count += he... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import re
def binarySearch(a,x):
low = 0
n = len(a)
high = n-1
while(low <= high):
mid = (low+high)//2
if(a[mid] > x and mid == 0):
return n
elif(a[mid] > x and a[mid-1] < x):
return (n-mid)
else:
if x < a[mid]:
high = mid - 1
else:
low = mid + 1
return -1
s = input()
x = 'heavy'
y =... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | import java.util.Arrays;
import java.util.Scanner;
public class practice {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String a = sc.next();
a = a.replaceAll("heavy", "1");
a = a.replaceAll("metal", "0");
int [] amount = new int[a.length()];
Arrays.fill(amount,0);
i... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
const double PI = 2 * acos(0.0);
const int Mod = 1E9 + 7;
long long binpow(long long a, long long b, long long m = Mod) {
a %= m;
long long res = 1;
while (b > 0) {
if (b & 1) res = res * a % m;
a = a * a % m;
b >>= 1;
}
return res;
}
inline void yes()... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
int t(int a, int b) {
int s = 1;
for (int i = 0; i < b; i++) {
s *= a;
}
return s;
}
long long dp[1000000];
int main() {
string s;
cin >> s;
string j;
if (s.size() < 5) {
cout << 0;
return 0;
}
for (int i = 0; i < s.size() - 4; i++) {
str... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
T sqr(const T &x) {
return x * x;
}
const int INF = 1e9;
const long double EPS = 1e-9;
const long double PI = acos(-1.0);
const int N = 102;
const long long mod = 1000 * 1000 * 1000 + 7;
int main() {
string s;
getline(cin, s);
int n = s.size();... |
Problem: Volodya likes listening to heavy metal and (occasionally) reading. No wonder Volodya is especially interested in texts concerning his favourite music style.
Volodya calls a string powerful if it starts with "heavy" and ends with "metal". Finding all powerful substrings (by substring Volodya means a subsequenc... | #include <bits/stdc++.h>
using namespace std;
int mov[4][2] = {
-1, 0, 0, 1, 1, 0, 0, -1,
};
template <typename T>
struct number_iterator : std::iterator<random_access_iterator_tag, T> {
T v;
number_iterator(T _v) : v(_v) {}
operator T&() { return v; }
T operator*() const { return v; }
};
template <typename... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.