prompt
string
response
string
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n = int(input()) s = input() inside = [] insideIndex = [] outside = [] numInside = 0 def countInside(string): words = string.split("_") count = 0 for word in words: if len(word) > 0: count += 1 return count popen = -1 pclose = -1 while True: try: popen = s.find("(", pc...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.io.*; import java.lang.reflect.Array; import java.util.*; import java.math.*; public class Main { public static void main(String[] args) throws IOException { // StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); PrintWriter out = new Pr...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
length=raw_input() strInp=raw_input() strlist=strInp.split('_') maxx=[0,0] index=0 #print strlist for partlist in strlist: length=len(partlist) if(length==0): continue temp=0 for alpha in partlist: if alpha=='(': temp=0 index=1 elif alpha==')': ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException; import java.io.IOException;import java.io.InputStream;import java.io.PrintStream; import java.io.PrintWriter;import java.security.AccessControlException;import java.util.Arrays; import java.util.Collection;import java.util.Comparat...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n = int(raw_input()) s = raw_input() start=-1 inparenCnt = 0 ret = 0 inParen = False for i in xrange(n): if s[i] == '(': inParen = True if start != -1: ret = max(ret, i - start) start = -1 elif s[i] == ')': inParen = False if start != -1: inparenCn...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.io.*; import java.util.*; public class Main { static int mod = (int) (1e9+7); static InputReader in; static PrintWriter out; public static void main(String args[] ) { in = new InputReader(System.in); out = new PrintWriter(System.out); Scanner in = new Scanner ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; inline int getint() { int res = 0; char c = getchar(); bool mi = false; while (c < '0' || c > '9') mi = (c == '-'), c = getchar(); while ('0' <= c && c <= '9') res = res * 10 + c - '0', c = getchar(); return mi ? -res : res; } inline long long int getll() { lo...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n = int(input()) s = input() + "_" last = "_" counter_len = 0 counter_word = 0 max_len = 0 max_counter = 0 open_c = False for i in range(len(s)): if s[i] == "(": if counter_len > max_len: max_len = counter_len counter_len = 0 open_c = True last = "(" elif s[i] == "...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import re a = input() a = input() org = a inclam = re.findall("\(.*?\)", a) for i in inclam: a = a.replace(i, "_") words = a.split('_') c = max(map(len, words)) count = 0 for i in inclam: count += len(list(filter(None, i.replace("(", "_").replace(")", "_").split("_")))) print(c, count)
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; int n; char s[1000]; inline bool abc(char c) { return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'); } int main(void) { scanf("%d\n%s", &n, s); int l = 0, count = 0; bool in = false; int ma = 0; for (int i = 0; i < n; i++) { char c = s[i]; if (abc(c))...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.Queu...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.util.Scanner; public class two { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s = new Scanner(System.in); int n = s.nextInt(); String str = s.next(); boolean inside = false; int wordlen = 0; int maxnow = 0; int nowords = 0; int i = 0; for(i = 0; ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import jav...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
//package Mura; /***** BY MURAD ******/ import java.io.*; import java.util.*; import java.util.ArrayList; import java.util.StringTokenizer; public class Code { public static int c=0; public static int ind1=0,ind2=0; static class DPS { public static int []ar={1,2,4,7,9,12,18,20,21,22,23,24,25,26,...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; int n, t, t1, a1, a2; string s; char c[256]; int main() { cin >> n; cin >> c; for (int i = 0; i < n; i++) { if (c[i] == '(') { t = 1; t1 = 0; continue; } if (c[i] == ')') { t = 0; t1 = 0; continue; } if (c[i] == ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import re from collections import defaultdict num_letters = int(input()) text = str(input()) word_dict = defaultdict(bool) inside_cnt = 0 words = list(filter(None, re.split("[\s_()]", text))) for w in words: word_dict[w] = True inside_brackets = list(filter(None, re.findall("\(([\w_]*)\)", text))) for seq in inside...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.io.*; import java.util.*; public class textdocumentanalysis { static int count_inside_braces = 0, longest_word = 0; public static int remove_underscore(String str) { str = str.replaceAll("_", " "); str = str.trim().replaceAll(" +", " "); String s[] = str.split(" "); if (s.length == 1 && s[0].equ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<char> arr; arr.resize(n); for (int i = 0; i < n; i++) { cin >> arr[i]; } bool major = false; int last_loc = 0; int par_loc = 0; vector<int> sizes; int words = 0; int s = 0; if (arr[0] != '_' && arr[0] != '('...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.Closeable; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; i...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
from sys import stdin,stdout import re n = int(stdin.readline()) inp = stdin.readline()[:n] words = re.findall(r"[^\W_]+|[()]",inp) op=False high,word=0,0 for i in words: if i == '(' or i == ')': op = not op elif op == True: word+=1 else: high=max(high,len(i)) stdout.write(str(hi...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.awt.Point; import java.io.*; import java.lang.Integer; import java.math.BigInteger; import java.util.*; public class Task { final boolean ONLINE_JUDGE = !new File("input.txt").exists(); BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void init() thr...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import re n = input() s = raw_input() arr = filter(lambda x: x != "" and x != "_", re.split(r"(\(|_|\))", s)) inbracket = 0 a = 0 b = 0 for i in arr: if i == "(": inbracket = 1 elif i == ")": inbracket = 0 else: if inbracket: b += 1 else: a = max(a, le...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; const short Nmax = 260; char a[Nmax]; int n; inline bool Lit(char ch) { return (('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z')); } int main() { int nrc, cuvmax, s; bool ok = false; cin >> n; cin >> (a + 1); nrc = cuvmax = 0; for (int i = 1; i <= n;) { ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Round375B { public static void main(String[] args) throws NumberFormatException, IOException { Scanner sc = new Scanner(S...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n = input() text = input() bracket = False bracket_word_count = 0 max_length = 0 bracket_s = "" non_bracket_s = "" for ch in text: if bracket: if ch == ')': bracket = False bracket_word_count += sum(1 for s in bracket_s.split('_') if s) bracket_s = "" else: bracket_s += ch else: if ch == '(': bra...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n = input() s = raw_input().strip() while len(s) > 0 and s[0] == "_": s = s[1:] while len(s) > 0 and s[len(s)-1] == "_": s = s[:len(s)-1] while len(s) > 1 and "__" in s: s = s.replace("__","_") # print s s = s.replace("(","_(_") s = s.replace(")","_)_") while len(s) > 1 and "(__" in s: s = s.replace("(__","(_") #...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
''' def main(): from sys import stdin,stdout n=int(stdin.readline()) if __name__=='__main__': main() ''' #372 #1 ''' def main(): from sys import stdin,stdout n,c=map(int,stdin.readline().split()) tup=tuple(map(int,stdin.readline().split())) counter=1 for i in range(1,n): if tup[i...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.io.*; import java.lang.*; import java.util.*; public class BasicJava { public static void main (String[] args) { Task Main = new Task(); Main.solve(); } static class Task { public InputReader in = new InputReader(System.in); public PrintWriter out = ne...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
## necessary imports import sys input = sys.stdin.readline # from math import * # swap_array function def swaparr(arr, a,b): temp = arr[a]; arr[a] = arr[b]; arr[b] = temp ## gcd function def gcd(a,b): if a == 0: return b return gcd(b%a, a) ## nCr function efficient using Binomial Cofficie...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
if __name__ == '__main__': n = int(input()) line = str(input()) + '_' temp_len = max_len = word_count = 0 f_flag = True u_flag = False for it in line: if it in ('(', ')', '_'): if it == '(': f_flag = False if u_flag: u_flag ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n=int(raw_input()) s=str(raw_input()) s=s.lower() c=0 a=ord('a') z=ord('z') A=ord('A') Z=ord('Z') def inside(s,ind): i=ind global c #print 'hii' l=len(s) while i<l and s[i]!=')': char=ord(s[i]) if (char>=a and char<=z) or (char>=A and char<=Z): c+=1 while i<l and (char>=a and char<=z) or (char>=A and char...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
//Author: Mo Abjal, MJP Rohilkhand University Bareilly, UP, India 2018. /////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////********************////////////////////////////////////////////// ////////////////////////////////...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Locale; import java.util.StringTokenizer; import java.util.stream.Stream; import java.util.Scanner; public class problem { public static void main(String[] args) throws Exceptio...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
/* IMPORTANT: Multiple classes and nested static classes are supported */ /* * uncomment this if you want to read input. import java.io.BufferedReader; import java.io.InputStreamReader; */ import java.util.*; import java.io.*; public class TestClass { static PrintWriter out = new PrintWriter(System.out); publi...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n = input() s = raw_input() longest_outside = 0 num_inside = 0 i = 0 while 1: j = i left = False for j in xrange(i, n): if s[j] == '(': left = True break outside = s[i:j].split('_') if left else s[i:j + 1].split('_') longest_outside = max(longest_outside, max(len(t) f...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; int n; string s; int main() { cin >> n >> s; int num = 0, MAX = 0; bool f = 0, g = 0; int ans = 0; for (long long i = 0; i < (n); i++) { if (s[i] >= 'A' && s[i] <= 'Z') { s[i] -= 'A'; s[i] += 'a'; } } for (long long i = 0; i < (n); i++) { ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; int main() { int n, len = 0, num = 0, left = 0, now = 0; scanf("%d", &n); string s; cin >> s; for (int i = 0; i < s.length(); i++) { char ch; ch = s[i]; if (ch == '(' || ch == ')' || ch == '_') { if (left > 0 && now != 0) { num++; }...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n = int(input()) s = input() a, b = 0, 0 par = [] word = [] last = 0 i = 0 while i < n: if s[i] != '_': j = i if s[i] == '(': while j < n and s[j] != ')': j += 1 par.append(s[i+1:j]) else: j = i while j < n and s[j] != '(' and s...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; int main() { int n; char s[255]; cin >> n; for (int i = 0; i < n; i++) cin >> s[i]; int max_length = 0; int num = 0; bool in = false; int word_length = 0; for (int i = 0; i < n; i++) { if (s[i] == '(') { in = true; if (word_length > max_len...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; bool l(char c) { if (c >= 'a' && c <= 'z') return 1; if (c >= 'A' && c <= 'Z') return 1; return 0; } int main() { int s1 = 0, s2, m1 = 0, m2 = 0, h = 0, n; char c = 0; scanf("%d", &n); while (!(c == '(' || c == ')' || c == '_' || (l(c)))) c = getchar(); whil...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
_, string = input(), input().replace("(", ")").split(")") string_out, string_in = list(), list() for i in range(len(string)): if i % 2 == 0: string_out.extend(string[i].split("_")) else: string_in.extend(string[i].split("_")) string_out = [len(i) for i in string_out if len(i) > 0] string_in = [l...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#F nb = int(input()) roo = input() liste=[] liste2 =[] liste3=[str(x) for x in roo.split("_")] liste8 = [] for loop in range(nb): if roo[loop] == '(': liste.append(loop) if roo[loop] == ')': liste.append(loop) roo = [x for x in roo] o = 0 orr = 0 for i in range(len(liste)//2): roo.insert(lis...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.io.*; import java.util.*; import com.sun.org.apache.bcel.internal.generic.IFLE; public class B { public static void main(String[] args) { MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int n = sc.nextInt(); Stri...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n, s = int(input()), input() max_len, in_par = 0, 0 while s.find('(') != -1: i, j = s.find('('), s.find(')') in_par += len([t for t in s[i+1:j].split('_') if t]) s = s[:i] + "_" + s[j+1:] max_len = max([len(t) for t in s.split('_')]) print(max_len, in_par)
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; int dx[8] = {0, 0, 1, 1, 1, -1, -1, -1}; int dy[8] = {1, -1, 0, -1, 1, 1, 0, -1}; int main() { ios::sync_with_stdio(false); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ; int n; string s, in = "", out = ""; int cnt = 0, mx = 0; cin >> n >> s;...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> double EPS = 1e-9; using namespace std; template <typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; } template <typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; } int n, k; int main() { cin >> n; string str; cin >> str; bool flag = false;...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
def DocAnalysis(): n = int(raw_input()) s = raw_input() inside = 0 parenthisis = 0 words = [] word = 0 words.append(0) i = 0 while i < len(s): if s[i] == '(': if parenthisis == 0: words.append(word) word = 0 parenthisis...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n=int(input()) s=input() L=0 ind=0 res="_" #for example 2 () maxx=0 maxx1=0 for i in range(len(s)): if s[i]=="(": if maxx>maxx1: maxx1=maxx maxx=0 ind=1 continue if ind==1: if s[i]==")": if res[len(res)-1]!="_": #res.append("_") res+="_" ind=0 continue else: res+=s[i] else...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int i; int prev = -1, len = 0, word = 0; for (i = 0; i < n;) { if (s[i] == '(') { len = max(len, i - prev - 1); prev = i; i++; while (s[i] != ')') { if (s[i] == '_') { ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.io.*; import java.util.*; public class A1008 { public static void main(String [] args) /*throws Exception*/ { InputStream inputReader = System.in; OutputStream outputReader = System.out; InputReader in = new InputReader(inputReader);//new InputReader(new FileInputStream(new File...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
from sys import stdin def solve(word): max_chars = 0 word_count = 0 char_count = 0 inside = False for char in word: if char in '()_': if not inside: max_chars = max(max_chars, char_count) char_count = 0 else: char_count += 1 ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n = input() string = input() outside_parens = '_'.join([x.split(')')[-1] for x in string.split('(')]) words = sorted(outside_parens.split('_'), key=len) longestWord = len(words[-1]) inside_parens = '_'.join([x.split(')')[0] for x in string.split('(')][1:]) word_count = len([x for x in inside_parens.split('_') if x]) ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
'''input 27 (LoooonG)__shOrt__(LoooonG) ''' n = input() s = raw_input() para = [] non_para = [0] x = 0 t = '' coord = [(-1, -1)] for i in xrange(n): if s[i] == '(': x = i if s[i] == ')': coord.append((x, i)) coord.append((len(s), len(s))) for i in xrange(1, len(coord)): non_para += [len(temp) for temp in s[coord[...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n=int(input()) a=list(input()) x=[0] y=[0] flag=0 cnt1=0 cnt2=0 for i in range(n): if (ord(a[i])>=65 and ord(a[i])<=90) or (ord(a[i])>=97 and ord(a[i])<=122): if flag==0: cnt1+=1 elif flag==1: cnt2=1 elif a[i]=="(": flag=1 x.append(cnt1) cnt1 = 0 ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; int main() { int a; cin >> a; char c; bool flag = false, inWord = false; int wordCnt = 0, ltr = 0, maxLtr = 0; for (int i = 1; i <= a; i++) { cin >> c; if (flag) { if (c == '_') { if (inWord) { wordCnt++; inWord = false;...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import sys num, content = sys.stdin.readlines() max_len = 0 started = False words_inside = 0 inside = False current_len = 0 for i, c in enumerate(content.strip()): if c == '_': if started: if inside: words_inside += 1 else: max_len = max(max_len, cu...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
# -*- coding: utf-8 -*- import sys import math import os import itertools import string import heapq import _collections from collections import Counter from collections import defaultdict from functools import lru_cache import bisect import re import queue from decimal import * class Scanner(): @staticmethod ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.io.*; import java.util.*; import static java.lang.Character.isLetter; public class Test { public static void main(String[] args) throws IOException { Scanner in = new Scanner(System.in); // PrintWriter out = new PrintWriter(new File("output.txt")); int count=0,max=0,vskobke=0,ma...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; char s[300]; int isTu, dangMoNgoac; int vitri; int sizeMax, demTu; int n; void solve() { int i, size; size = strlen(s); isTu = 0; vitri = 0; sizeMax = 0; dangMoNgoac = 0; demTu = 0; for (i = 0; i < size; i++) { if (s[i] != '_' && s[i] != '(' && s[i] != '...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n = int(input()) s = input() ans1 , ans2 = [] , [] st = -1 while True : st = s.find('(' , st + 1) if st == -1: break e = s.find(')' , st) ans1 += s[st+1 : e].split('_') s = s[:st] + '_' + s[e+1: ] ans2 = s.split('_') #print(ans1) #print(ans2) r1 , r2 = 0 , 0 for i in ans1: if i != ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n = input() a = b = x = 0 f = False for c in raw_input(): if c == '_': if x > 0: if f: b += 1 else: a = max(x, a) x = 0 elif c == '(': if x > 0...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; int main() { long long int i = 0, n, f = 0, c = 0, a = 0, m = 0, k = 0; string s; cin >> n >> s; while (i < n) { if (f) { if ((s[i] > 64 && s[i] < 92) || (s[i] < 124 && s[i] > 96)) a++; else if (a) k++, a = 0; } else { if ((...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n = input() s = raw_input() outsideCount = 0 parentCount = 0 ep = -1 i = 0 walker = -1 while i < n: if s[i].isalpha(): walker = i+1 while walker < n and s[walker] != '_' and s[walker] != '(' and s[walker] != ')': walker += 1 outsideCount = max(outsideCount, walker-i) i = walker elif s[i] == '(': walk...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
while True: try: n = int(input()) str = input() maxn1 = -1 maxn2 = 0 cnt1 = 0 cnt2 = 0 flag = False for i,ch in enumerate(str): if flag==False and ch not in ['(',')','_']: cnt1 += 1 if i == n-1 and cnt1 != 0:...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import re l = int(input()) s = str(input()) flag = 0 stack = [] outside_words = [] count_inside = 0 def process(flag): global stack, count_inside, outside_words if flag == 1: if len(stack) > 0: count_inside += 1 stack = [] elif flag == 0: outside_words.append(le...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n = input() s1 = list(raw_input().strip()) # outside paran outside = 0 inside = 0 tmp = 0 while s1: char = s1.pop(0) if char == "(": tmp2 = 0 while s1[0] != ")": char2 = s1.pop(0) if char2.isalpha(): tmp2 += 1 else: if tmp2: ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.util.*; public class MyAnswer { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); String unuse = in.nextLine(); String a = in.nextLine(); char[] b = a.toCharArray(); int maxletter = 0; int nowletter = 0; int[] c = new int[3]; ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; string s, d; int main() { int t; cin >> t; string s; cin >> s; bool ff = 0; for (int i = 0; i < t; i++) if (s[i] == '_' || s[i] == '(') ff = 1; bool f = 0; if (!ff) return cout << t << " " << 0, 0; long long maxx = -9999999999999, k = 0, w = 0; int s...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
input() X = input() Parentheses, Outside, i = "", "", 0 while i < len(X): if X[i] == "(": i, Parentheses = i + 1, Parentheses + "_" while X[i] != ")": Parentheses, i = Parentheses + X[i], i + 1 Outside += "_" else: Outside += X[i] i += 1 Outside = Outside.split("_...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n=int(input()) a=input() x=[] c=0 d=0 e=0 for i in a: if d==0 and i!='_' and i!='(': c+=1 elif i== '(': d=1 x.append(c) c=0 elif i==')': d=0 elif i=="_": x.append(c) c=0 x.append(c) e=0 f=0 y=[] for j in a: if f==1 and j!='_' and j!=")": ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n = int(input()) s = input() bw = 0 bwl = 0 w = 0 mw = 0 open = False for i in s: if i == '(': open = True if w != 0 and w > mw: mw = w w = 0 continue elif i == ')': open = False if bw > 0: bwl += 1 bw = 0 continue if open: if i == '_': if bw > 0: bwl += 1 bw = 0 else: bw +...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); in.nextLine(); String s = in.nextLine(); int m =0; ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n=int(input()) s=raw_input() S="" wc=0 mwl=0 l=-1 r=-1 for i in range(n): if s[i]=='(': l=i elif s[i]==')': r=i if(l!=-1 and r!=-1): tmp=s[l+1:r] s=s[:l]+("_"*(r-l+1))+s[r+1:] x=tmp.split('_') for ele in x: if len(ele)!=0: wc+=1 l=-1 r=-1 s=s.split('_') for i in s: mwl=max(mwl,len(i)) print ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#ROUNIAUDI i=input() string1=input() b=False q="" for u in string1: if u=='(' or b==True: q+=str(u) b=True if u==')': b=False #print(q) str23=q.replace('(','_').replace(')','_') #print(str23) list33=str23.split('_') t=list33.count('') ans1=len(list33)-t f=True q1="" for u in stri...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Deque; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.ut...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.util.*; public class B { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); String lol = sc.nextLine(); int words=0; int wordsize = 0; int p=0; int maxword = 0; for (int i = 0;i<n;i++) { //System.out.print(p); switch (l...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
N = int(input()) s = input() s += '$' paren = [] i = 0 while i >= 0 and s[i] != '$': if s[i] == '(': j = i + 1 bw = '' while s[j] != ')': bw += s[j] j += 1 paren.append(bw) s = s[0:i] + '_' + s[j + 1:] # print(s) i += 1 # print(i) s ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
// -*- coding: utf-8 -*- //import java.awt.*; import java.io.*; import java.math.*; import java.text.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream; if (args.length > 0 && args[0].equals("devTesting")) { try { inputStream = new FileIn...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n=int(input()) s=input() flag=0 br=[] xs=[] i=0 while(True): end=s.find('(',i) if(end==-1): ne=s[i:] xs.extend(ne.split('_')) break #print(type(i),type(end)) ne=s[i:end] xs.extend(ne.split('_')) i=end+1 end=s.find(')',i) ne=s[i:end] br.extend(ne.split('_')) i=end+1 xs.sort(key = lambda s: len(s),reverse...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; string s; cin >> s; int maxw = 0; int wct = 0; int kct = 0; for (int i = 0; i < (s.size()); i++) { if (s[i] == '_') { w...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import re n = input() str = raw_input() sents = re.findall(r'\(([A-Za-z_]*)\)', str) words = 0 for sent in sents: a=sent.split('_') for i in a: if len(i)>0: words += 1 print max([len(i) for i in re.sub(r'\([A-Za-z_]*\)','_',str).split('_')]), words
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; int main() { int n, m = 0, j = 0; string a; cin >> n >> a; set<int> t; for (int i = 0; i < n; i++) { while (a[i] != '_' && a[i] != '(' && i < n) { m++; i++; } t.insert(m); m = 0; if (a[i] == '(') { i++; for (int k = i; k...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.io.*; import java.math.BigInteger; import java.util.*; public class JavaApplication7 { static int doit(String s ) { StringTokenizer st = new StringTokenizer(s); return st.countTokens() ; } public static void main(String[] args) throws Exception { Reader.init(System.in); Reader.next...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; int c, q, e, e1; vector<int> v; string s, s1; int ma = 0; bool w = true, w1; int main() { cin >> c; cin >> s; for (int i = 0; i < c; i++) { if (s[i] == '(') { w = false; } if (w == false) { if (((65 <= (int)s[i] && (int)s[i] <= 90) || ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n = int(input()) s = list(input()) in_p = 0 while True: try: tmp = s[s.index("(")+1:s.index(")")] del s[s.index("("):s.index(")")] s[s.index(')')] = '_' s_tmp = ("".join(tmp)).split('_') for i in s_tmp: if len(i) > 0: in_p+=1 except ValueError:...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; int MAX = numeric_limits<int>::max(); int main() { int n; cin >> n; string s; cin >> s; n = s.length(); int f = 0; int n2 = 0, ma = 0, p = 0; for (int i = 0; i < n; i++) { if (s[i] == '(') { f = 1; p = 0; } else if (s[i] == ')') { f...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; int main() { int cntkuo = 0, cnt = 0, maxn = 0; int i, j, k, m, n; char s[400]; scanf("%d", &n); getchar(); gets(s); int l = strlen(s); for (int i = 0; i < l; i++) { if (s[i] == '(') { cntkuo++; } else if (s[i] == ')') { cntkuo--; } e...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; char s[256]; int main() { int n; while (~scanf("%d", &n)) { getchar(); bool flag = false; int maxn = 0, tot = 0, sum = 0; for (int i = 1; i <= n; i++) { scanf("%c", &s[i]); if (s[i] == '(') { flag = true; maxn = max(maxn, tot)...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
_, s, x = input(), list(input()), 0 while '(' in s: x += len([i for i in ''.join(s[s.index('(') + 1 : s.index(')')]).split('_') if i]) s[s.index('('): s.index(')') + 1] = '_' print(max([len(i) if i else 0 for i in ''.join(s).split('_')]), x)
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; char st[333]; int main() { int n; while (~scanf("%d", &n)) { scanf("%s", st); int res = 0; int ans = 0; int temp = 0; int flag = 0; for (int i = 0; i < n; i++) { if ((st[i] >= 'a' && st[i] <= 'z') || (st[i] >= 'A' && st[i] <= 'Z')) { ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
import java.util.*; import java.io.*; /** * * @author umang */ public class B723 { public static int mod = 1000000007; public static long gcd(long x,long y){ if(x%y==0) return y; else return gcd(y,x%y); } public static int gcd(int x,int y){ if(x%y==0) return y; else ret...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
a = raw_input() pro_str = raw_input().strip() len_outside_str = 0 num_words_inside = 0 len_str = 0 is_outside = 1 for x in pro_str: if x == '_': if is_outside: if len_str > len_outside_str: len_outside_str = len_str len_str = 0 elif x == '(': if len_str > len_outside_str: len_outside_str = l...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n = int(input()) s = input() maxlen = 0 cntret = 0 slen = 0 cnt = 0 flag = 0 k = 0 j = 0 passcnt = 1 global i for i in range(n): #print(i,k) if i < k: continue if i < j: continue if s[i] == '_': #print("cjc1") pass elif s[i].isalpha and s[i] != '(' and s[i] != ')': ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int k = 0, l = 0, m = 0, ans = 0; for (int i = 0; i <= n; i++) { if (i != n && ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z'))) { k++; } else { if (!m) l = max(k, l); ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; const int MAXN = 260; char s[MAXN]; bool inPar[MAXN]; int main() { int n; scanf("%d", &n); scanf("%s", s); int open = 0; for (int i = 0; i < n; i++) { if (s[i] == '(') open++; else if (s[i] == ')') open--; inPar[i] = open > 0; } int ans...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
n=int(input()) s=input() l1=0 l2=0 m=0 skob=False slovo=False for i in s: if i!='(' and i!=')' and i!='_' and skob==False: l1=l1+1 if i=='_' and skob==False: if l1>l2: l2=l1 l1=0 if i=='(' and skob==False: if l1>l2: l2=l1 l1=0 skob=True if skob==True: if i!='(' and i!=')' and i!='_':...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
#include <bits/stdc++.h> using namespace std; int main() { int n; char str[1000]; while (scanf("%d", &n) != EOF) { scanf("%s", str); int ans1 = 0, ans2 = 0, temp = 0, flag = 0; int len = strlen(str); for (int i = 0; i < len; i++) { if (str[i] != '_' && str[i] != '(' && str[i] != ')' && flag ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
def flatt(z): return [x for y in z for x in y] n = int(input()) s = input() ss = flatt(map(lambda x: x.split(")"), s.split("("))) s_in = flatt(map(lambda x: x.split("_"), ss[1::2])) s_out = flatt(map(lambda x: x.split("_"), ss[0::2])) n1 = max(map(len, s_out)) n2 = sum(map(lambda x: x != "", s_in)) print(n1, end ...
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
'''input 5 (___) ''' n = int(input()) t = input() t = t.replace("_", " ") t = t.replace("(", " ( ") t = t.replace(")", " ) ") m, p = 0, 0 f = False for w in t.split(): if w == "(": f = True elif w == ")": f = False elif f == True: p += 1 elif f == False: m = max(m, len(w)) print(m, p)
Problem: Modern text editors usually show some information regarding the document being edited. For example, the number of words, the number of pages, or the number of characters. In this problem you should implement the similar functionality. You are given a string which only consists of: * uppercase and lowercas...
l = raw_input() word = raw_input() inParen = False wordLen = 0 numIn = 0 maxOut = 0 for x in range(0, len(word)): #print word[x] if word[x] == '_': if inParen is False: if (wordLen > maxOut): maxOut = wordLen else: if(word[x-1].isalpha()): ...