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... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class HeavyMetal {
public static void main (String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String input = br.readLine();
... |
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 N = 2e5 + 1;
const long long mod = 1e9 + 7;
const long long INF = 1e10;
const long long M = (1 << 17) + 1;
const long long LL = 1;
string second;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
cin >> second;
long long int 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... | #include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
const char sx[] = "heavy", sy[] = "metal";
char a[N];
int l, x, y;
long long cnt, ans;
inline bool check1(int pos) {
for (int i = pos, j = 0; j < 5; i++, j++)
if (a[i] != sx[j]) return false;
return true;
}
inline bool check2(int pos) {
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... | sentence = raw_input()
sentence = sentence.replace('heavy','+')
sentence = sentence.replace('metal','-')
num = 0
result = 0
for char in sentence:
if char=='+':
num = num + 1
if char=='-':
result+=num
print result |
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()
c=ans=0
for i in range(len(s)-4):
if s[i:i+5] == 'heavy':
c+=1
elif s[i:i+5] == 'metal':
ans+=c
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
string a;
vector<long long int> x, y;
cin >> a;
long long int n = a.size();
for (long long int i = 0; i < n - 4; i++) {
if (a[i] == 'h' && a[i + 1] == 'e' && a[i + 2] == 'a' && a[i + 3] == 'v' &&
a[i + 4] == 'y')
x.push_back(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... | 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 += 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... | #include <bits/stdc++.h>
using namespace std;
string s;
bool is_heavy(int i) {
if (s[i] == 'h' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'v' &&
s[i + 4] == 'y')
return 1;
return 0;
}
bool is_metal(int i) {
if (s[i] == 'm' && s[i + 1] == 'e' && s[i + 2] == 't' && s[i + 3] == 'a' &&
s[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... | s=input()
h=[]
m=[]
for i in range(len(s)-4):
if(s[i:i+5]=='heavy'):
h.append(i)
for i in range(len(s)-4):
if(s[i:i+5]=='metal'):
m.append(i)
l=0
r=0
total=0
while(l<len(h) and r<len(m)):
if(m[r]>h[l]):
total+=len(m)-r
l+=1
else:
r+=1
print(total)
|
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
s = raw_input()
n = len(s)
c = [0] * n
for m in re.finditer("heavy", s):
c[m.start()] += 1
for i in xrange(n - 1):
c[i + 1] += c[i]
res = 0
for m in re.finditer("metal", s):
res += c[m.start()]
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... | /**
* Created with IntelliJ IDEA.
* User: akashm
* Date: 6/15/13
* Time: 12:08 AM
* To change this template use File | Settings | File Templates.
*/
import java.util.*;
public class B318 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s = in.nextLine();... |
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;
import java.lang.String;
import java.lang.reflect.Array;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s = in.nextLine();
char[] p = s.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... | s=input()
ans=0
s=s.replace("heavy","1")
s=s.replace("metal","2")
heavy=[]
metal=[]
n=len(s)
for i in range(n):
if(s[i]=="1"):
heavy.append(i)
elif(s[i]=="2"):
metal.append(i)
n=len(heavy)
nn=len(metal)
x=0
l=nn
for item in heavy:
for i in range(x,nn):
if(metal[i]>item):
... |
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... | str1 = input()
heavycount = 0
sol = 0
i = 0
while i < len(str1)-4:
if str1[i] == 'h':
if str1[i:i+5] == 'heavy':
heavycount += 1
if str1[i] == 'm':
if str1[i:i+5] == 'metal':
sol += heavycount
i+=1
print(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... | import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class B138 {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
String s = in.nextLine();
ArrayList<Integer> a = new ArrayList<>();
ArrayList<Integer> b = new ArrayList<>()... |
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... | import java.io.InputStreamReader;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner r=new Scanner(new InputStreamReader(System.in));
String a=r.nextLine();
long l=a.length()-4,h=0,o=0;
for(int j=0;j<l;j++){
String t=a.substri... |
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... | #kisi "metal" substring ke pehle jitne bhi "heavy" substring aayenge
#wo utna count badhayega... nd so on...
#
s=raw_input()
sub="aaaaa"
count=a=0
for x in s:
sub=sub[1:]+x
if sub=="heavy":
a+=1
if sub=="metal":
count+=a
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... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
// String of Power : Codeforces
// status : WA
public class StringPower {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
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... | 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>
using namespace std;
vector<int> heavies;
vector<int> metals;
int Greaters(int left, int right, int input) {
int ans = 0;
if (left == right - 1) {
if (input <= metals[left]) {
ans++;
}
return ans;
}
int mid = (left + right) / 2;
if (metals[mid] >= input) {
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 sys
def solve(string):
str1 = 'heavy'
str2 = 'metal'
start = string.find(str1)
end = string.rfind(str2)
if start == -1 or end == -1:
return 0
string = string[start+len(str1):end]
data = {-1:True, len(string): False}
pos = -1
cnt1 = 1
while True:
pos = 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... | st=input()
l=len(st)
h=0
c=0
for i in range(0,l):
if((i+5)<=l):
if(st[i:i+5]=="heavy"):
h=h+1
elif(st[i:i+5]=="metal"):
c=c+h
print(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... | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
//package pkg188;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
/**
*
* @author Alik
*/
public class B {
static String line;
static int cur = 0;
public static... |
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... | L = "heavy"
R = "metal"
D = 0
AL = 0
# drop until first L
# if no L then return D = 0
# split rest by L
# set some AL to 0
# in [1, ..] pieces each
# x = count R
# add x to D
# multiply x and AL and add to D
# increment AL
# return D
s = raw_input()
drop_index = s.find(L)
if drop_index != -1:
rest = s[drop_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... | z=r=0
for w in input().split("heavy"):
r+=w.count("metal")*z
z+=1
print(r) |
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... | st = input()
p = 0
ans = 0
for i in range(len(st) - 4):
if st[i:i+5] == 'heavy':
p += 1
if st[i:i+5] == 'metal':
ans += p
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 = input().strip()
ans = 0
head = 0
for i in range(4, len(s)):
if s[i - 4: i + 1] == "heavy":
head += 1
if s[i - 4: i + 1] == 'metal':
ans += head
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
string s1;
cin >> s1;
long long heavy_count = 0, ans = 0;
if (s1.size() > 5) {
for (int i = 0; i < s1.size() - 5 + 1; i++) {
if (s1[i] == 'h' && s1[i + 1] == 'e' && s1[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... |
import java.util.Scanner;
public class B {
/**
* @param args
*/
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
char[]s = sc.next().toCharArray();
long ans=0;
long heavy=0;
for(int i=0;i<s.length;i++){
if(isHeavy(s,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;
int main() {
string str;
while (cin >> str) {
long long int sum, i, temp;
sum = temp = 0;
for (i = 0; i < str.size(); i++) {
if (str[i] == 'h' && str[i + 1] == 'e' && str[i + 2] == 'a' &&
str[i + 3] == 'v' && str[i + 4] == 'y') {
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.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Trung Pham
*/
public class B {
public 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.*;
public class cf318B{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
String inp = sc.next();
int startIndx = 0;
long count=0,heavy_cnt =0;
int heavy_index = 0;
int metal_index = 0;
int heavy_index_o... |
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... | a=input()
b=0
c=0
for i in range(len(a)-4):
if a[i:i+5]=='heavy':b+=1
if a[i:i+5]=='metal':c+=b
print(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.util.*;
import java.io.*;
public class metalheavy{
public static void main(String args[]) throws IOException{
BufferedReader lector = new BufferedReader(new InputStreamReader(System.in));
String tmp = lector.readLine();
long a = 0;
long b = 0;
for(int n =0;n<=tmp.length()-5;n+=5){
if(tmp.substring(n,n+5).eq... |
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[1000000];
cin >> a;
if (strlen(a) < 5) {
cout << 0 << endl;
return (0);
}
long long i, j = 0, l, ans = 0;
for (i = 0; i < strlen(a) - 4; i++) {
if (a[i] == 'h' && a[i + 1] == 'e' && a[i + 2] == 'a' && a[i + 3] == 'v' &&
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>
using namespace std;
int main() {
string s;
cin >> s;
int N = s.size();
long long heavy = 0, sum = 0;
for (int i = 0; i < N - 4; i++) {
if (s[i] == 'h' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'v' &&
s[i + 4] == 'y')
heavy++;
else if (heavy > 0 && s[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;
int main() {
string a;
cin >> a;
long long int i, length, cnt = 0, res = 0;
length = a.size();
for (i = 0; i < length; i++) {
if (a[i] == 'h' && a[i + 1] == 'e' && a[i + 2] == 'a' && a[i + 3] == 'v' &&
a[i + 4] == 'y')
cnt++;
else if (a[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;
int main() {
string str;
while (cin >> str) {
long long sum = 0, heavy = 0;
string temp;
for (int i = 0; i < str.size(); i++) {
temp = str.substr(i, 5);
if (temp == "heavy")
heavy++, i += 4;
else if (temp == "metal")
sum += ... |
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
{
static char[] arr;
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
// arr = sc.nextLine().toCharArray();
String s = sc.nextLine();
s = s.replaceAll("metal", ",");
s = s.replaceAll("heavy", ".");
long add = 0;
long 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(int argc, char** argv) {
string s;
unsigned long long n = 0;
cin >> s;
unsigned long long cnt = 0;
size_t pos = 0;
while (pos < s.size()) {
if (s.compare(pos, 5, "heavy") == 0) {
cnt++;
pos += 5;
} else if (s.compare(pos, 5, "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()
n=len(s)
looper=0
ans=0
for i in range(n-4):
if s[i:i+5]=="heavy":
looper+=1
elif s[i:i+5]=="metal":
ans+=looper
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... | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.*;
import java.math.*;
import java.io.*;
/**
*
* @author magzhan
*/
public class Cf {
public final stati... |
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.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class test {
static int MAX = 1000001;
public static void main(String[] argvs) throws Exception{
FastScanner scan = new FastScanner(System.in);
String in = scan.... |
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 Str[1000005] = {};
cin >> Str;
long long len = strlen(Str);
long long Total = 0;
long long Count = 0;
for (long long i = 0; i < len;) {
if ((Str[i] == 'h') && (Str[i + 1] == 'e') && (Str[i + 2] == 'a') &&
(Str[i + 3] == 'v') && (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... | # coding=utf-8
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>
using namespace std;
string s;
long long ans, numo;
int main() {
cin >> s;
if (s.length() < 10) {
cout << 0;
return 0;
}
for (int i = 0; i < s.length() - 4; ++i) {
if (s[i] == 'h' && s[i + 1] == 'e' && s[i + 2] == 'a' && s[i + 3] == 'v' &&
s[i + 4] == '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... | def main():
l = []
for s in input().split('heavy')[1:]:
l.append(0)
for ss in s.split('metal'):
l.append(1)
del l[-1]
res = a = 0
for t in l:
if t:
res += a
else:
a += 1
print(res)
if __name__ == '__main__':
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... | #include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
string s, s1;
int p[1100000];
int e1[200010], e2[200010], l1, l2;
long long r;
int n;
void sub() {
int k = 0;
p[0] = 0;
for (int i = 1; i < n; i++) {
while (k > 0 && s[i] != s[k]) k = p[k - 1];
if (s[i] == s[k]) k++;
p[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 sys
import fractions
import string
a = raw_input()
a = a.replace('heavy', '0')
a = a.replace('metal', '1')
current = a.count('1')
ret = 0
for c in a:
if c == '0':
ret += current
elif c == '1':
current -= 1
print ret |
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[1000010];
int ss[1000010];
int main() {
int u = 0, v = 4, k = 0, l = 0, r = 0;
int c = 0, d = 0;
long long sum = 0;
char s1[] = {"heavy"};
char s2[] = {"metal"};
scanf("%s", s);
int p = strlen(s);
while (v <= p - 1) {
for (int i = u, j = 0; i <= 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... | st=raw_input()
heavy=0
count=0
for i in range(len(st)-4):
if st[i:i+5] == 'heavy':
heavy+=1
if st[i:i+5] == 'metal':
count+=heavy
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... | import java.util.Scanner;
public class Codeforce {
public static void main(String [] args){
Scanner in = new Scanner(System.in);
String s = in.nextLine();
String temp;
long ans=0, k=0;
for(int i=0; i<s.length()-4; i++){
temp = s.substring(i,i+5);
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.util.*;
import java.io.*;
public class b188
{
public static void main(String args[])
{
String text;
Scanner sc = new Scanner(System.in);
text= sc.next();
int number=0;
int heavyindex=0;
int metalindex=0;
int totalheavy=0;
long totalmetal=0;
int lastheavy = text.indexOf("heavy");
if(t... |
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 = 1000010;
int a[N], b[N];
char s[N];
int main() {
scanf("%s", s + 1);
int n = strlen(s + 1);
memset(a, 0, sizeof(a));
for (int i = 1; i <= n; i++) {
if (s[i] == 'm' && s[i + 1] == 'e' && s[i + 2] == 't' && s[i + 3] == 'a' &&
s[i + 4] == 'l')... |
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()
t,r=0,0
for i in range(5,len(s)+1):
t+=(s[i-5:i]=='heavy')
r+=t*(s[i-5:i]=='metal')
print r
|
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 cnt, ans, i, j, temp, flag;
string s, heavy = "heavy", metal = "metal";
int main() {
cin >> s;
for (i = 0; i < s.length(); i++) {
temp = i;
flag = 0;
for (j = 0; j < 5; j++) {
if (s[temp] == heavy[j])
++temp;
else
break;... |
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 h[1001000];
int m[1001000];
string s;
int main() {
cin >> s;
int t1 = 0;
int t2 = 0;
for (int i = 0; i < (signed)s.length() - 4; i++) {
if (s.substr(i, 5) == "heavy") h[t1++] = i;
if (s.substr(i, 5) == "metal") m[t2++] = i;
}
long long resp = 0;
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... | import java.io.*;
import java.util.*;
public class Woodcutters
{
static class Reader
{
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader()
{
din = new Data... |
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
if len(s) >= 5:
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... | z=r=0
for w in input().split("heavy"):r+=w.count("metal")*z;z+=1
print(r)
|
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... | string = input()
n = len(string)
havyMetals = []
for i in range(n):
if i < n - 4:
if string[i:i+5] in ["heavy", "metal"]:
havyMetals.append(string[i:i+5])
counts = [[0, 0]]
for i in range(len(havyMetals)):
if havyMetals[i] == "heavy":
counts.append([counts[-1][0] + 1, counts[-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 re
line = raw_input().strip()
heavy = [(m.start(), 'h') for m in re.finditer('heavy', line)]
metal = [(m.start(), 'm') for m in re.finditer('metal', line)]
ls = heavy + metal
ls.sort(key=lambda x: x[0])
metal_count = len(metal)
cur_metal_count = metal_count
ans = 0
for x in ls:
if x[1] == 'h':
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.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;
public class ProblemB {
public static void main(String[] args) {
ProblemB problem = new ProblemB();
try {
problem.solve(System.in, System.out);
} catch (IOException e) {
// TODO Auto-generated ca... |
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 x = -5;
long long sum = 0;
long long a = 0;
long long INF = s.length() + 5;
long long z = -1, y = -1;
while (x + 5 < s.length()) {
long long z1 = z, y1 = y;
if (z1 <= y1) z = s.find("heavy", x + 5);
if... |
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.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.InputMismatchException;
public class StringPower {
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
string a;
cin >> a;
long long f = 0, p = 0;
for (int i = 0; i < a.length(); i++) {
string s = "";
if (i + 5 <= a.length())
s += a[i], s += a[i + 1], s += a[i + 2], s += a[i + 3], s += a[i + 4];
if (s == "heavy")
p++;
else if ... |
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 = str(input())
n = len(s)
hcount = 0
count=0
for i in range(n-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':
hcount+=1
if s[i] == 'm' and s[i+1] == 'e' and s[i+2] == 't' and s[i+3] == 'a' and s[i+4] == 'l':
count = count + hcount
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... | s=raw_input()
ans=0
a=s.split('heavy')
for i,b in enumerate(a):
ans+=b.count('metal')*i
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()
t=s.split("metal")
S=0
for i,j in enumerate(t):
a=j.count("heavy")
S+=a*(len(t)-1-i)
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()
count = 0
ans = 0
for i in range(len(s)):
if s[i:i + 5] == 'heavy':
count += 1
elif s[i:i + 5] == 'metal':
ans += count
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... | //package codeforces;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import... |
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, total, heavy = input(), 0, []
for i in range(len(s)-4):
if s[i : i + 5] == 'heavy' :
heavy.append(i)
if s[i : i + 5] == 'metal' :
total += len(heavy)
print(total) |
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 javafx.beans.NamedArg;
import java.io.*;
import java.net.Inet4Address;
import java.util.Comparator;
import java.util.*;
/**
* @author Yuxuan Wu
*/
public class Main {
public static final int RANGE = 1000000;
static int MAX = Integer.MAX_VALUE;
static int MIN = Integer.MIN_VALUE;
static int MODU... |
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 prob{
public static void main(String args[]) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer(br.readLine());
char[] a=st.nextToken().toCharArray();
int currentHeavy=0;
int l=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>
using namespace std;
int main() {
char arr[1000001];
cin >> arr;
long long int len = strlen(arr);
long long int cnt = 0;
long long int inc = 0;
long long int m = 4;
for (long long int i = m; i < len; i++) {
if (arr[i - 4] == 'h' && arr[i - 3] == 'e' && arr[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... | s = list(input())
ans, cnt = 0, 0
for i in range(1, len(s) - 3):
if s[-i] == 'l' and s[-i - 1] == 'a' and s[-i - 2] == 't' and s[-i - 3] == 'e' and s[-i - 4] == 'm':
cnt += 1
elif s[-i] == 'y' and s[-i - 1] == 'v' and s[-i - 2] == 'a' and s[-i - 3] == 'e' and s[-i - 4] == 'h':
ans += cnt
print(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>
using namespace std;
const long long INF = 1e9;
const long long N = 1e6 + 1;
const long long mod = 1e9 + 7;
const long double eps = 1E-7;
long long n;
string s;
long long x, a[N];
int main() {
ios_base::sync_with_stdio(0);
cin >> s;
n = s.size();
for (int i = n - 5; i >= 0; i--) {
l... |
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 static java.lang.Math.*;
import java.io.*;
public class SolutionB {
public static void main(String args[])throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine();
TreeMap<Integer, Long... |
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 int modular_pow(long long int base, long long int exponent) {
long long int result = 1;
while (exponent > 0) {
if (exponent % 2 == 1) result = (result * base) % 1000003;
exponent = exponent >> 1;
base = (base * base) % 1000003;
}
return result;... |
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()
heavy = 0
total = 0
i = 0
while i < len(s) - 4:
if s[i:i + 5] == 'heavy':
i += 5
heavy += 1
elif s[i:i + 5] == 'metal':
i += 5
total += heavy
else:
i += 1
print("%d" % total)
|
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().strip().split("metal")
l = len(s)-1
found = 0
head = 'heavy'
for i in range(l):
mt = s[i].count(head)
found += mt*(l-i)
print(found) |
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 Main
{
public static void main(String[] args)
throws Exception
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String line = reader.readLine();
int len = line.length();
line = line.replace("heavy", "*");
int lenH = line.l... |
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()
tmp = line
result = 0
n = line.count("heavy")
m = line.count("metal")
arr = []
for i in range(len(line)):
if line[i:i+5] == "heavy":
result += m
elif line[i:i+5] == "metal":
m = m-1
print result |
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 ans = 0, m = 0, h = 0;
vector<char> v;
string s;
cin >> s;
for (int i = 0; i < s.size(); i++) {
if (i < s.size() - 4 && s[i] == 'h' && s[i + 1] == 'e' && s[i + 2] == 'a' &&
s[i + 3] == 'v' && s[i + 4] == 'y') {
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... | #include <bits/stdc++.h>
using namespace std;
template <typename T>
string toString(T x) {
if (x == 0) return "0";
bool negative = x < 0;
string res;
while (x) {
res.push_back('0' + x % 10);
x /= 10;
}
if (negative) res.push_back('-');
reverse(res.begin(), res.end());
return res;
}
template <typ... |
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 f(a):
return a*(a+1)//2
x=input()
if "heavy" in x:
x=x.replace("heavy","@")
if "metal" in x:
x=x.replace("metal","#")
c=0
n=len(x)
res=0
for i in range(n):
if x[i]=="@":
c+=1
if x[i]=="#":
res+=c
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() {
string s;
cin >> s;
long long i = 0, a = 0, b = 0;
while (i < s.length()) {
if (s.substr(i, 5) == "heavy") {
a++;
i += 5;
} else if (s.substr(i, 5) == "metal") {
b += a;
i += 5;
} else
++i;
}
cout << b;
re... |
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()
total = 0
heavy = []
for i in range(len(s)-4):
if s[i:i+5] == 'heavy':
heavy.append(i)
if s[i:i+5] == 'metal':
total += len(heavy)
print(total)
|
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... | #include <bits/stdc++.h>
using namespace std;
string s;
long long cnt[1000007], n, res = 0;
int main() {
cin >> s;
n = (long long)s.size();
cnt[0] = 0;
for (long long i = 0; i <= (n - 5); ++i) {
if (i > 0) cnt[i] = cnt[i - 1];
string t = s.substr(i, 5);
if (t == "heavy") ++cnt[i];
}
for (long lo... |
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()
h = 0
ans = 0
i = 0
for i in range(len(s)):
if s[i] == "h" and s[i:i+5] == "heavy":
h += 1
if s[i] == "m" and s[i:i+5] == "metal":
if h >= 1:
ans += h
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... | #include <bits/stdc++.h>
using namespace std;
int main() {
char c[1000000];
long long int heavy_count = 0, result = 0;
gets(c);
int i = 0;
while (i < strlen(c)) {
if (c[i] == 'h') {
i++;
if (c[i] == 'e') {
i++;
if (c[i] == 'a') {
i++;
if (c[i] == '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... |
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;
import java.util.regex.Matche... |
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.util.StringTokenizer;
import java.util.TreeSet;
import java.util.*;
public class StringsOfPower {
BufferedReader reader;
StringTokenizer tokenizer;
PrintWriter writer;
... |
Problem: Xenia the vigorous detective faced n (n ≥ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can ... | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m, s, f;
cin >> n >> m >> s >> f;
map<long long int, pair<long long int, long long int> > hash;
int i;
long long int mx = INT_MIN;
for (i = 0; i < m; i++) {
long long int x, y, z;
c... |
Problem: Xenia the vigorous detective faced n (n ≥ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can ... | import java.io.*;
import java.util.*;
import java.*;
import java.math.BigInteger;
public class zad {
private static BufferedReader in;
private static StringTokenizer tok;
private static PrintWriter out;
private static String readToken() throws IOException {
while (tok == null || !tok.hasMoreTo... |
Problem: Xenia the vigorous detective faced n (n ≥ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can ... | R=lambda:map(int,raw_input().split())
n,m,s,f=R()
t=[R() for _ in range(m)]+[[10**9+9,0,0]]
a,d=('R',1) if s<f else ('L',-1)
i,j,v=1,0,''
while s!=f:
b=s+d
while t[j][0]<i:j+=1
if t[j][0]==i and ((s>=t[j][1] and s<=t[j][2]) or (b>=t[j][1] and b<=t[j][2])):
v+='X'
else:
v+=a
s=b
#print i,s,b,f,t[j]... |
Problem: Xenia the vigorous detective faced n (n ≥ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can ... | #include <bits/stdc++.h>
using namespace std;
int dir;
int n, m, s, f;
int tcurr = 1;
string ret;
int getNext() {
if (dir == 0)
return s + 1;
else
return s - 1;
}
char getNextMove() {
if (dir == 0)
return 'R';
else
return 'L';
}
int main() {
cin >> n >> m >> s >> f;
ret = "";
if (s <= f)
... |
Problem: Xenia the vigorous detective faced n (n ≥ 2) foreign spies lined up in a row. We'll consider the spies numbered from 1 to n from left to right.
Spy s has an important note. He has to pass the note to spy f. Xenia interrogates the spies in several steps. During one step the spy keeping the important note can ... | def kansi(t,tim,x):
if tim in t:
z = t[tim]
if z[0] <= x <= z[1]:
return True
else:
return False
else:
return False
def solver():
n,m,s,f = map(int, raw_input().split())
t = {}
for _ in xrange(m):
line = map(int,raw_input().split(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.