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...
import java.util.*; import java.io.*; import java.math.*; public class Main { public static void main(String[] args) { Scanner input = new Scanner(System.in); int x = input.nextInt(); ArrayList<String> inl = new ArrayList<>(); ArrayList<String> outl = new ArrayList<>(); ...
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 = raw_input() s = raw_input() bat = [] for i in re.findall('\((.*?)\)', s): bat.extend([j for j in i.split('_') if j != '']) cat = [len(i )for i in re.sub('\((.*?)\)','_', s).split('_')] print max(cat), len(bat)
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; bool open = false; int out = 0; int max = 0; int count = 0; int num = 0; for (int counter = 0; counter < n; counter++) { if (s[counter] == '(') { open = true; if (count > max) max = 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...
import re def count_words(s: str, balance: int): if balance == 0: return 0 s = list(filter(lambda x: x != '', s.split('_'))) return len(s) def get_len(s: str, balance: int): if balance == 1: return 0 s = list(filter(lambda x: x != '', s.split('_'))) if len(s) == 0: 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...
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; s += "_"; char p = ')'; int bw = 0, wc = 0, tw = 0; for (int i = 0; i <= n; i++) { if (s[i] == '(') { p = '('; if (wc > 0) { bw = max(bw, wc); wc = 0; } } 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...
raw_input() number_in = 0 length_out = 0 in_, out_ = False, True data = raw_input() current_length = 0 for s in data: if s == '(': in_, out_ = True, False length_out = max(length_out, current_length) current_length = 0 elif s == ')': in_, out_ = False, True if current_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...
n = input() s = input() op = False out = 0 max_out = 0 ins = 0 seen = False for c in s: if c == '(': op = True seen = False max_out = max(out, max_out) out = 0 elif c == ')': op = False if seen: ins += 1 seen = False elif c == '_': if seen: if op: ins += 1 else: max_out = max(ou...
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.PrintWriter; import java.util.stream.IntStream; import java.util.Arrays; import java.util.Collection; import java.io.IOException; import java.util.OptionalInt; import java.io.InputStreamReader; import java.util.ArrayList...
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()) b=input() k=b.split('(') l=0 m=-1 for x in k: if (')' in x)and x[0]!=')': z=x.split(')') while('' in z): z.remove('') if len(z)>0: y=z[0].split('_') for h in y: if h!=''and h!=')': l+=1 if 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...
#!/usr/bin/env python # coding: utf-8 if __name__ == '__main__': import sys f = sys.stdin n = int(f.readline()) line = f.readline()[:n] #print line class stat: max_out = 0 in_words = 0 cur_word_len = 0 in_par = False def flush_word(): if 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...
n = int(input()) s = input() ans1 = 0 ans2 = 0 num1 = 0 num2 = 0 i = 0 while i < n: if s[i] == '(': num1 = 0 j = i+1 while s[j] != ')': j += 1 temp = s[i+1:j] t = temp.split("_") while '' in t: t.remove('') ans2 += len(t) i = 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(raw_input())+1 s = raw_input() + "_" is_inside = False count_inside = 0 out_length = 0 out_max_length = 0 for i in xrange(n): if s[i] == "(": if s[i-1] != "_": out_max_length = max(out_max_length, out_length) out_length = 0 is_inside = True continue if s[i] == ")": if s[i-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...
#include <bits/stdc++.h> using namespace std; int main() { int n; int ma = 0; cin >> n; int pos; string s, words; cin >> s; while ((pos = s.find_first_of("(")) != -1) { int pos1 = s.find_first_of(")", pos); words += '_' + s.substr(pos + 1, pos1 - 1 - pos); s = ((pos >= 0) ? s.substr(0, pos) : ...
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(map(int, input().split())) ##print(" ".join(map(str, res))) def get(s): n = len(s) res = [] i = 0 while i < n: while i < n and s[i] == '_': i += 1 j = i while j < n and s[j] != '_': j += 1 if j != i: res....
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; double pi = 4 * atan(1.0); int main() { int n; string s; cin >> n >> s; int ans1 = 0, ans2 = 0; int f_word = 0, f2 = 0; int len = 0; for (auto i : s) { if (((i >= 'a' && i <= 'z') || (i >= 'A') && (i <= 'Z'))) { if (!f_word) { len = 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...
#include <bits/stdc++.h> using namespace std; int main() { int n, r1 = 0, r2 = 0; cin >> n; string str; cin >> str; for (int i = 0, wl = 0, ib = 0; i < n; i++) { if ((str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'Z')) { wl++; if (!ib) { r1 = max(r1, wl); } }...
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;input();s=[[w for w in p.split('_')if w]for p in re.split('\((.*?)\)',raw_input())];print max(max(len(w)for w in p+[''])for p in s[::2]),sum(len(p)for p in s[1::2]+[[]])
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 B723 { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int a=sc.nextInt(); String s=sc.next(); int sum=0; int tmp=0; int su=0; String temp=""; for(int i=0;i<a;i++) { if(s.charAt(i)=='(') { i++; if(tmp>sum) sum=tmp; tm...
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 LAVLESH */ import java.util.*; import java.io.*; public class solution { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st=new StringTokenizer(""); static public String next() { while (st == null || !st.hasMoreTokens()) { try ...
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()) k=raw_input() a=[] an=[] b=[] s1='' s2='' s='' j=0 k1='' k2='' for i in k: if i=='(': s1=s1+'_' k1=k1+s1 s1='' j=1 continue elif i==')': s2=s2+'_' k2=k2+s2 s2='' j=0 continue if j==1: s2=s2+i elif ...
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...
// Code Author: Rutul Patel import java.io.*; import java.math.BigInteger; import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.*; public class Main { static double eps=(double)1e-6; static long mod=(int)1e9+6; public static void main(String args[]){ InputReader sc = new InputReader(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; const int N = 1e5 + 10; const int mod = 1e9 + 7; const long long int INF = 1LL << 62; long long int power(long long int x, long long int y) { long long int t = 1; while (y > 0) { if (y % 2) y -= 1, t = t * x % mod; else y /= 2, x = x * x % mod; } ...
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 a[100010], b[100010]; map<string, bool> mark; bool word(char a) { if (a >= 'a' and a <= 'z') return true; if (a >= 'A' and a <= 'Z') return true; return false; } int main() { int n; cin >> n; string a; cin >> a; int ind = 0; int inside = 0; int ans1 ...
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()) word = raw_input() a1 = word.replace('(','1') a2= a1.replace(')','1') first = a2.split('1') counts = [len(filter(bool,j.split('_'))) for j in first] length = [[len(k) for k in filter(bool,l.split('_'))] for l in first] #print a1, a2, first #print counts, length l1 = [0] l2 = [] for i in range(len(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...
import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner s = new Scanner(System.in); while (s.hasNextLine()) { s.nextLine(); System.out.println(TextDocumentAnalysis.input(s.nextLine())); } s.close(); } } class TextDocumentAnalysis { pu...
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() in_text=raw_input() word="" par=[] nopar=[] i=0 while i<n: if in_text[i]!="(": if in_text[i]=="_": if word!="": nopar.append(word) word="" else: word+=in_text[i] else: if word!="": nopar.append(word) ...
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; int main() { cin >> n; string s; cin >> s; bool bracket = false; int outside = 0, inside = 0; int cur = 0; for (int i = 0; i < n; i++) { if (s[i] == '(') bracket = true, cur = 0; else if (s[i] == ')') bracket = false, cur = 0; el...
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, cnt = 0, word = 0; cin >> n; cin.ignore(); vector<int> v; bool flag_par = false, flag_word = false; for (int i = 0; i < n; i++) { char x; cin >> x; if (x == '(') { flag_par = true; } if (x == ')') { flag_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...
import re if __name__ == "__main__": n=input() strr=raw_input(); temp=re.findall('\(.*?\)',strr) gather=set() glist=[] for i in temp: y=i.replace('(','') y=y.replace(')','') for j in y.split('_'): if j: gather.add(j) glist.append(j) strr=strr.replace('(','|') strr=strr.replace(')','|') str...
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()) st = input() n += 1 st += '_' v_sk = [] bz_sk = [] dd = 0 dd1 = 0 sw = False ct = 0 long = [] for e in range(n): if st[e] == '(': bz_sk.append(st[dd1:e]) dd = e + 1 elif st[e] == ')': v_sk.append(st[dd:e]) dd1 = e + 1 bz_sk.append(st[dd1:]) for e in v_sk: rem...
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() S = input() inP = 0 longest = 0 numbIns = 0 curL = 0 for s in S: if s == "_": if inP == 0: longest = max(longest, curL) else: if curL != 0: numbIns += 1 curL = 0 elif s == "(": longest = max(longest, curL) inP ^= 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...
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.io.BufferedReader; import java.util.regex.Pattern; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author...
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.FileInputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; /** * Oct 3, 2016 | 12:28:10 PM * <pre> * <u>Description</u> * * </pre> * * @author Essiennta Emmanuel (colourfulemmanuel...
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 string_length = input() string = input() brackets_pattern, sep, replacement, empty_bracket = "\(.*?\)", "\_+", "_", "()" max_length, number_of_words_in_brackets = 0, 0 for bracket in re.findall(pattern=brackets_pattern, string=string): if bracket != empty_bracket: for word in re.split(pattern=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=int(raw_input()) s=raw_input() mx=0 inp=0 l=0 b=0 w=0 for i in range(len(s)): if s[i]!="_" and b==0 and s[i]!="(": l+=1 if s[i]=="(": b=1 if s[i]==")": b=0 w=0 if s[i]=="_" or s[i]=="(" and l!=0: mx=max(mx,l) l=0 if b==1 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...
length = int(input()) stringArray = str(input()) i = 0 outCount = 0 inCount = 0 maxout = 0 while i<length: flag = 0 outCount = 0 if stringArray[i] == '_': outCount = 0 elif stringArray[i] == '(': outCount = 0 while stringArray[i] != ')' and i<length: i += 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() STR = input() insc = False maxl = 0 ksl = 0 curl = 0 for ch in STR: if ch in ['(',')','_']: if insc: if curl != 0: ksl+=1 #print(ch) else: if curl > maxl: maxl = curl curl = 0 if ch == '(': ...
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...
t = input() t = '_' +input()+'_' res = '' for i in range(1,len(t)): if (not((t[i] == '_')and(t[i-1] == '_'))and((t[i] != '(')and(t[i] != ')'))): res+=t[i] if ((t[i] == '(')or(t[i] == ')')): if (t[i-1] != '_'): res += '_' res += t[i] if (i != len(t)-1): 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...
#include <bits/stdc++.h> int main() { int sum, n, i, t, p, sum1; char z[260]; scanf("%d", &n); getchar(); for (i = 0; i < n; i++) { scanf("%c", &z[i]); } getchar(); sum = 0; sum1 = 0; p = 0; t = 0; for (i = 0; i < n; i++) { if (z[i] >= 'a' && z[i] <= 'z') { sum++; if (sum >= ...
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; public class B { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub BufferedReader buffer=new BufferedReader(new InputStreamReader(System.in)); String line=buffer.readLine();...
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 argc, char const *argv[]) { string s; int len; cin >> len; cin >> s; int r1 = 0; bool in = false; int cnt = 0; int cnt2 = 0; for (int i = 0; i < len; ++i) { switch (s[i]) { case '_': { if (in) { if (cnt) cnt2++; ...
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> const long long oo = 1e9; const long long mod = 95542721; const long long MAX = 1e9; const long long ARR = 300000; using namespace std; int main() { ios_base::sync_with_stdio(false); int a = 0, b = 0, n, len = 0, flag = 0; string s; cin >> n; cin >> s; for (long long i = (0); i < (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...
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time sys.setrecursionlimit(10**7) inf = 10**10 mod = 10**9 + 7 def f(): n = int(input()) s = input() f = False r = 0 r2 = 0 sc = '' for c in s: if c == '(': for ss in sc.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()) s = raw_input() brac = False longest, words_brac = 0, 0 cur_word = 0 for i in xrange(n): if s[i] == '(' or s[i] == ')' or s[i] == '_': if s[i] == '(': if not brac: longest = max(longest, cur_word) #if brac and cur_word>0: words_brac+=1 brac = True cur_word=0 if s[i] == ')': if no...
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, i, total = 0, Max = 0, total1 = 0, flag = 0; string s; cin >> n >> s; for (i = 0; i < s.size(); i++) { if (isalpha(s[i])) total++; else { if (Max < total && flag == 0) Max = total; if (flag == 1 && total != 0) total1++; ...
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 = list(raw_input()) outsideCount = 0 parentCount = 0 # ep = -1 # i = 0 # walker = -1 inParenthesis = False # nList = list(n) # nList.append('_') s.append('_') word = [] for i in range(len(s)): if s[i].isalpha(): word.append(s[i]) else: if not inParenthesis: outsideCount = max(outsideCount, ...
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...
litter=input();inside=outside=0 s=input() i=s.find('(') while i != -1 : last = s.find(')') for j in s[i+1 : last].split('_') : if j != '': inside+=1 if i==0: s=s[last+1:] else: s = s[:i]+'_'+s[last+1:] i=s.find('(') for i in s.split('_'): 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...
#include <bits/stdc++.h> using namespace std; vector<long long> v; vector<long long> vv; set<long long> st; long long x, y, z; string s, s1, s2, s3, s4, s5; void memset_ll(long long a[], long long v, long long n) { for (long long i = 0; i < n; i++) a[i] = v; } void memset_s(char a[], char v, long long n) { for (lon...
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('_') ans1 = len([x for x in ans1 if x != '']) ans2 = max([len(x) for x in ans2]) ...
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; void Read(int &n) { int sign = 1; n = 0; char c; do { c = getchar(); } while (!isdigit(c) && c != '-'); if (c == '-') { c = getchar(); sign = -1; } do { n = n * 10 + c - 48; c = getchar(); } while (isdigit(c)); n *= sign; } void Read(...
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; long long mod = 1e9 + 7; int main() { int N, i; string s; cin >> N >> s; int bracket = 0, max1 = 0, max2 = 0, cur = 0; for (i = 0; i < N; i++) { if (s[i] == '_' || s[i] == ')' || s[i] == '(') { if (bracket) max2 += (cur) ? 1 : 0; 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...
#in the name of god #Mr_Rubik #''.join(sorted(a)) sort string n=int(input()) s=input() out,ln,ans1,ans2=1,0,0,0 for i in s: if i=='_': if out: ans1=max(ans1,ln) else: if ln>0: ans2+=1 ln=0 elif i in '()': if out: ans1=max(ans1, ln) else: if ln>0: ans2+=1 ln=0 out=not out else: ln+=1 if out: ans1=...
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...
#!/usr/bin/python import os import sys import itertools def solve(f): n = f.read_int() s = f.read_str() depth = 0 ans1 = 0 cons = 0 ans2 = 0 for si in s: if si == '_': if depth > 0 and cons > 0: ans2 += 1 cons = 0 elif si == '(': 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...
import re length = int(input()) s = input() no_par = re.findall(r'([^()]*)(?:\([^)]*\))?', s) no_par = '_'.join(no_par) no_par = no_par.split('_') if not no_par: no_par = [''] print(max(map(len, no_par)), end=' ') with_par = re.findall(r'\(([^)]*)\)', s) with_par = '_'.join(with_par) with_par = with_par.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...
# cook your code here n = int(raw_input()) stri = raw_input() temp1 = 0 temp2 = 0 ans1 = 0 ans2 = 0 count=0 for i in stri: if(i=='('): temp1=0 temp2=0 count+=1 continue elif(i==')'): temp1=0 temp2=0 count-=1 continue elif(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; const int N = 100010; int n; char s[N]; void init() { cin >> n; for (int i = 0; i < n; ++i) cin >> s[i]; } void solve() { int ans1 = 0, ans2 = 0; bool flag = false; int tmp = 0; for (int i = 0; i < n; ++i) { if (s[i] == ')') { flag = false; conti...
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 = input() s = raw_input() s = s.replace("()","(_)") s = s.replace(")(",")_(") f1 = 0 if s[0]=="(": f1 = 1 s = s.replace(')','(') x = s.split('(') x = filter(None,x) out = 0 ins = 0 for i in range(len(x)): if i%2 == f1: temp = [len(t.replace("_","")) for t in x[i].split("_")] out = max(max(temp),out) 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; long long MOD_EXPO(long long b, long long p, long long m) { if (p == 0) return 1; long long ret = MOD_EXPO(b, p / 2, m) % m; ret = (ret * ret) % m; return ((p & 1) ? (ret * b) % m : ret % m); } long long POWER(long long N, long long K) { long long i, ans = 1; fo...
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() t = input() brackets = 0 while '(' in t: s,e = t.index('('), t.index(')') brackets += len([x for x in t[s+1:e].split('_') if x]) t = t[:s] + '_'+ t[e+1:] print (max(len(x) for x in t.split('_')), brackets)
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.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.InputMismatchException; public class Solution1 implements Runnable ...
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...
x=int(input()) s=input() count=0 count1=[] count2=[] m=0 i=0 while(i<len(s)): if s[i].isalpha(): j=i while(s[j]!="_" and s[j]!='(' ): count+=1 j+=1 if j>=len(s): break count1.append(count) i=j count=0 if i<len(s) 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...
import java.util.Scanner; /** * Created by Sersh on 03.10.2016. */ public class lilu { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int max_size = 0; int num_words = 0; int max_size1 = 0; int k = -1; 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...
## 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...
n = raw_input() a = raw_input() b = a.split('(') maxa = 0 outside = 0 for x in b: if ')' in x: cc = x.split(')') outside += len(filter(None, cc[0].split('_'))) for thing in cc[1].split('_'): if(len(thing) > maxa): maxa = len(thing) else: xxxx = x.split('_') for thing in xxxx: if(len(thing) > maxa)...
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=s a=0 k=0 b=0 i=0 while (i<len(s)): if s[i]=='(': a=0 while s[i]!=')': if (s[i]=='_') and (s[i-1]!='(') and (s[i-1]!='_'): b+=1 i+=1 if (s[i-1]!='(') and (s[i-1]!='_'): b+=1 i+=1 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...
def inp(): return int(raw_input()) def linp(): return map(int, raw_input().split()) n = inp() s = raw_input() open = [] close = [] for i in xrange(n): if s[i]=='(': open.append(i) if s[i]==')': close.append(i) li = [] for i in xrange(len(open)): li.append(s[open[i]+1:close[i]]) 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 re def main(): n = input() s = input() k = re.findall('\((.*?)\)', s) m = re.sub(r'\(.*?\)', '_', s) # print(m) # print(k) a = list(m.split("_")) r1 = 0 for x in a: r1 = max(r1, len(x)) r2 = 0 for x in k: p = list(x.split('_')) for y in p: if y != "": r2 += 1 print(r1, r2) if __name__...
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 string n = int(input()) s = input() s += "_" s = "_" + s ans1, ans2 = 0, 0 count_br = 0 count_w = 0 for ch in s: if ch == '(': if count_w != 0: if count_br == 0: ans1 = max(ans1, count_w) else: ans2 += 1 count_w = 0 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...
import java.util.*; import java.io.*; import static java.lang.Math.*; public class B { public static void solve(Scanner fs, PrintWriter pw) { int n = fs.nextInt(); int a = 0, b = 0; char[] cc = fs.next().toCharArray(); boolean in = false; int k = 0, l = 0; for (int...
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 n = sys.stdin.readline() line = sys.stdin.readline() words_out = line.strip().split('(') words1 = filter(lambda w: ')' not in w, words_out) words2 = filter(lambda w: ')' in w, words_out) words_in = map(lambda x: x.split(')')[0], words2) res2 = 0 for word in words_in: res2 += len(filter(lambda x: 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...
import java.io.*; import java.util.*; public class HackerCup1 { public static void main(String[] args) throws Throwable { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br.readLine(); String s = br.readLine(); int count = 0,max = 0,cur = 0; boolean out = true; for (int 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...
#include <bits/stdc++.h> using namespace std; const long long MXN = 1e6 + 1; const long long MNN = 1e3 + 1; const long long MOD = 1e9 + 7; const long long INF = 1e18; const long double EPS = 1e-9; long long n, mx, w, q, sz; string s; int main() { ios_base::sync_with_stdio(0); cin >> n; cin >> s; for (long long ...
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...
''' usage: python prob2.py ''' import sys import os def main(argv=None): line=raw_input() nChars=int(line.strip()) parts=line.split() line=raw_input() line=line.strip() out_maxlen=0 in_nwords=0 st_inword=0 # if word start, let 1 len_outword=0 # if word start, let1 flag=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...
import java.util.*; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int N = Integer.parseInt(scanner.nextLine()); String line = scanner.nextLine() + "_"; int max = 0; int wordsInBraces = 0; boolean inBraces = fa...
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 >> ws; string ss; getline(cin, ss); int longestWord = 0, noOfWord = 0, currentLen = 0; bool inBracket = false, preLetter = false; for (int i = 0; i < n; i++) { if (ss[i] == 95 && !inBracket) { if (preLetter) { 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...
#include <bits/stdc++.h> using namespace std; inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } inline int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } template <typename T> string to_str(T str) { stringstream stream; stream << str; return stream.str(); } template <typenam...
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...
trash = raw_input("") words = raw_input("") longestWord = 0 wordsInParen = 0 candidate = 0 inParens = False for c in words: if not (c in "_()"): if inParens: continue candidate += 1 else: if c == "(": inParens = True elif c == ")": inParens...
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 mas[2020]; map<int, int> st; int main() { int n; scanf("%d", &n); string s; cin >> s; s = "_" + s + "_"; bool insk = false; string tmp; int maxlen = 0; int cnt = 0; for (int i = 0; i < (int)(s).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...
import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; import java.util.TreeSet; public class tmp { public static void main(String[] Args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String s = sc.next(); int len = 0; int count = 0; int inWord = 0; int inParen = 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.util.ArrayList; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; public class TextDoc { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); scan.nextLine(); String s = scan.nextLine(); String[] p = s.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...
input() i = input() l1 = [] l2 = [] while len(i.split('(')) > 1: l1.append(i.split('(')[0]) i = '('.join(i.split('(')[1:]) l2.append(i.split(')')[0]) i = ')'.join(i.split(')')[1:]) l1.append(i) l1 = ('_'.join(l1)).split('_') l2 = ('_'.join(l2)).split('_') for i in range(len(l2)-1,-1,-1): if l2[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.util.Scanner; public class WordsFinder { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String s = sc.next(); int parenthesisCnt = 0; int startIndex = s.indexOf('('); int endIndex = s.indexOf(')'); while (startIndex >= 0 || endIndex >= 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 def text_parser(): no_character = int(input()) text = input()[:no_character] l = [x.strip('_') for x in re.findall(r'_*\(*_*[A-Za-z]+_*\)*_*', text)] # p = [x for x in l if x[0] == '(' or x[-1] == ')'] # print (p) open = False max_len = 0 no_par_words = 0 for item in l: if item[-1] == ')': ope...
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 = int(input()) s = input() insideBrackets = False l = 0 w = 0 count = 0 for i in s: if(i == '_') or (i == '('): if(count > l): l = count count = 0 else: if(insideBrackets == False): count += 1 if(i == '('): insideBrackets = True 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...
input() inp=0 lst='*' siz=0 long=0 num=0 for c in input()+'_': if c=='_': if lst.isalpha(): if inp==1: num=num+1 else: long=max(long,siz) siz=0 elif c=='(': if lst.isalpha(): if inp==1: num=num+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...
input() t = input() brackets = 0 while '(' in t: s,e = t.index('('), t.index(')') #print (t[s+1:e].split('_')) brackets += len([x for x in t[s+1:e].split('_') if x]) t = t[:s] + '_'+ t[e+1:] #print (t) print (max(len(x) for x in t.split('_')), brackets)
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() ) x = input() par = False l = 0 out = 0 num = 0 found_word = False for i in range( 0, n ): if x[i] == '_': if found_word: if par: num += 1 else: out = max( out, l ) found_word, l = False, 0 elif x[i] == '(': if found_word: if par: num += 1 else: out = max( ou...
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 codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner kbd = new Scanner(System.in...
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 def mean(numbers): return float(sum(numbers)) / max(len(numbers), 1) def solve(): _, words = raw_input(), raw_input() P_PAT = "\(([^)]*)\)" clean = lambda txt: list(filter(lambda x: x != "", txt.split("_"))) parents = re.findall(P_PAT, words) no_parents_res = re.sub(P_PAT, "_", 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...
opn, in_br = False, False c, mod, count, mx = 0, 0, 0, 0 def fun(): global count, mx, c if in_br: count += 1 else: mx = max(c, mx) c = 0 n = int(input()) s = input() s += '_' for i in range(len(s)): if s[i] == '_': opn = not(opn) if opn == False and c != 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...
I=input I() s=I()+'()' R=str.replace a=b=0 t=-1 for i in filter(lambda x:x,R(R(s,'(',')'),')','_').split('_')): t=s.find(i,t+1) if s.find('(',t)<s.find(')',t):a=max(a,len(i)) else:b+=1 print(a,b)
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, ans1, ans2, now, ins; char str[1111]; int main() { cin >> n; cin >> str; for (int i = 0; i < n; i++) { if (str[i] == '(') ins = 1, now = 0; else if (str[i] == ')') ins = 0, now = 0; else if (ins) { if (str[i] == '_') now = ...
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 main() { int n; scanf("%d", &n); char str[n]; scanf("%s", str); int longestWordOutsideTheParentheses = 0; int numberOfWordsInsideTheParentheses = 0; int currentWordLength = 0; int i = 0; int arr[n + 1]; while (i < n) { if (str[i] == '(') { i++; while (str...
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 n; cin >> n; string s; cin >> s; string r1 = "", r2 = ""; long long int ans1 = 0, ans2 = 0, fl = 0; for (long long int i = 0; i < n; i++) { if (s[i] == '_') { if (r1 != "") { long long int j = r1.length(); a...
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.Arrays; import java.util.HashMap; import java.util.Scanner; public class Driver { public static Scanner scanner; public static void main(String[] args) { scanner = new Scanner(System.in); int n = scanner.nextInt(); String inputString = scanner.next(); char[] s = inputString.toCharArray(...
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 xrange(5): # print "Trolling CodeForces #StopStalk" pass for i in arr: if i == "(": inbracket = 1 elif i == ")": inbracket = 0 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() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int len; cin >> len; string str; cin >> str; int longestOut = 0; int inside = 0; bool outside = true; int length = 0; for (int i = 0; i < len; ++i) { if (str[i] == '(' || st...
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 = input()+'_' l = 0 p = 0 br = False le = 0 pos=0 j = 0 for i in s: if i in '_()': if not br: l = max(l, le) le = 0 if i == '(': pos = j br = True if i == ')': p += len([i for i in s[pos+1:j].split('_') if len(i) > 0]) br = False if i not in '_()': le += 1 j += 1 print(l,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...
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; n = s.size(); int cnt = 0, maxi = 0; int i = 0; while (i < n) { while (i < n && s[i] == '_') i++; if (i < n && s[i] == '(') { int a = 0; while (i < n && s[i] != ')') { i++; while ...
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...
#!/usr/bin/env python # coding: utf-8 if __name__ == '__main__': import sys f = sys.stdin #f = open('/home/ilya/opt/programming/tasks/723B.txt') n = int(f.readline()) line = f.readline()[:n] #print line class stat: max_out = 0 in_words = 0 cur_word_len = 0...