prompt
string
response
string
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; vector<pair<int, int> > v(n); for (long long int i = 0; i < n; i++) { cin >> v[i].first; v[i].second = i + 1; } sort(v.begin(), v.end()); for (long long int i = 0; i < n / 2; i++) { cout << v[i].second << " "...
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
n = int(input()) a = list(map(int, input().split())) pos = [] for i in range(n): pos.append(i+1) x = list(sorted(zip(a, pos))) x = [j for i, j in x] for i in range(n//2): print("%d %d" % (x[i], x[n-i-1]))
Problem: There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At the beginning of the game each player gets two cards, each card is given to exactly one player. Find the way to distribute cards such that the sum of values written of the cards...
import sys if __name__ == "__main__": n = int(sys.stdin.readline().strip()) cards = [int(i) for i in sys.stdin.readline().strip().split()] total = sum(cards) x = 2 * total / n m = {} pairs = [] for i, c in enumerate(cards, 1): if x - c in m and m[x-c]: print i, m[x - 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...
def solution(): m = raw_input() line = raw_input().split(')') if len(line) == 1: print max(len(o) for o in line[0].split('_')), 0 return max_len = 0 number_in = 0 for l in line: splitted = l.split('(') if len(splitted) == 1: # we are in the 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...
length = int(input()) string = input() outer = "" inner = "" i = 0 while i < length: if string[i] == '(': i += 1 inner += " " while string[i] != ')': if string[i] != '_' and string[i] != '&': inner += string[i] else: inner += " " ...
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 itertools import chain n = int(input()) s = input() s = s.split('(') for i in range(len(s)): s[i] = s[i].split(')') s = list(chain(*s)) outs = [] ins = [] c = 0 for c in range(len(s)): if c % 2 == 0: outs.append(s[c]) else: ins.append(s[c]) for i in range(len(outs)): outs[i] = o...
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 Solution{ public static void main(String[] args) { Scanner in = new Scanner(System.in); int n,i,count=0,max=0,answer=0,length=0; boolean open=false,word=false; String w; n=in.nextInt()+2; w=in.next(); 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 java.io.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); String s=sc.next(); int flag1=0; int flag2=0; int flag3=0; int max=-1; int cur=0; int cur2=0; int number=0; boolean start=false; for(int 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.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.io.*; import java.math.BigDecimal; import java.math.BigInteger; import java.math.MathContext; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; public class Main { 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 = int(input()) lst = input() flag = 0; len = 0 num = 0; max = 0 for i in range(0,n+1): if i == n : if max < len: max = len break if lst[i] == '_'or lst[i] == '('or lst[i] == ')': if flag == 0 and max < len: max = len else: if flag == 1 and 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...
largo = int(input()) oracion = str(input()) contador = 0 verdadero = True palabraLarga = 0 palabraMAsLarga = 0 dentroParentesis = False for i in oracion: if i == "(": dentroParentesis = True if i == ")": dentroParentesis = False if i == "_" or i == "(" or i == ")": verdadero = True ...
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.List; import java.io.BufferedReader; import java.lang.StringBuilder; import java.math.BigInteger; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.EmptyStackException; import java.util.Enumer...
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 par(phrase): ic, oc, max_oc = 0,0,0 maxoc = 0 inside = False found = False for i, x in enumerate(phrase): if x == '(': if found: oc += 1 found = False inside = True elif x == ')': if found: p = 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...
import sys, math n = int(input()) s = input() fl = 1 sk = 0 a = [0, 0] gg = ['(', '_', ')'] i = 0 while i < n: #print(i) if s[i] not in gg: y = 0 while (i < n and (s[i] not in gg)): y += 1 i += 1 if sk == 0: a[0] = max(a[0], y) 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> int main() { int n, i, number, count_out, counter; scanf("%d", &n); char s[n]; int flag = 0, max = 0, waiter = 0, cautious = 0; number = count_out = 0; for (i = 0; i < n; i++) { scanf(" %c", &s[i]); if (s[i] == '(') { flag = 1; counter = 0; waiter = 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 = int(input()) s = input() in_ = "" out_ = "" o = False for x in s: if x == "(": o = True in_ += "_" out_ += "_" elif x == ")": o = False in_ += "_" out_ += "_" else: if o: in_ += x else: out_ += x a = [] b = [] #in_ = in_.strip("_") #out_ = out_.strip("_") in_ += "_" out_ += "_" 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() s = input() ss = "" for x in s: if x == '(' or x == ')': ss += f'_{x}_' else: ss += x s = ss.split('_') t = [] for i in s: if i != '': t.append(i) p = False mx = 0 c = 0 for i in t: if i == '(': p = True continue if i == ')': p = 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...
#include <bits/stdc++.h> using namespace std; int n, nr = 0, maxy = 0, len = 0; char s[1000]; int main() { scanf("%d\n", &n); gets(s + 1); bool cuvant = false; int unde = 0, deschise = 0; int i = 1; while (i <= n) { if (s[i] == '(') { if (cuvant == true) { cuvant = false; if (desch...
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 scan = new Scanner(System.in); char c; boolean bracket = false, brackword = false; int prevWord = 0, inBrackets = 0, word = 0; int n = scan.nextInt(); scan.nextLine(); String in = scan.nextLine(); for(int i = 0; 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.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class TextDocAnalysis { public static void main(String[] args) throws IOException { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); char[]s=sc...
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=str(input()) a=list(s.split("_")) d="" while '' in a: a.remove('') while '_' in a: a.remove('_') for _ in range(len(a)): d+=a[_] d+="," b="" while "(" in d: b+=d[d.index("("):d.index(")")+1] d=d[:d.index("(")]+","+d[d.index(")")+1:] d=list(d.split(",")) while '' in d: d.remo...
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() words_count = 0 max_len = 0 word = False word_len = 0 inside = False for i in range(len(s)): if s[i] == "(": if word: if word_len > max_len: max_len = word_len word = False word_len = 0 inside = True elif s[i] == ")": if word: words_count = words_count + 1 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...
import java.io.*; import java.math.*; import java.util.*; public class R375_2 { static long mod=(long) (1e9+7); public static void main(String args[]){ FasterScanner s=new FasterScanner(); PrintWriter out =new PrintWriter(System.out); int n = s.nextInt()+1; String s1= s.nextLine(); s1="_"+s1; char a[]=s1...
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]; int main() { scanf("%d", &n); scanf("%s", s); int len = strlen(s); int flag = 0; int a = 0, b = 0; int m = 0, l = 0; for (int i = 0; i < len; i++) { if (s[i] == '(') { if (m != 0) a = max(a, m); m = 0; i++; 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...
#!/usr/local/bin/python3.5 -tt import random import re import sys if __name__ == '__main__': RE_PARENTHESIS = re.compile(r'(\([^)]*\))') RE_UNDERSCORE = re.compile(r'_+') n, s = (input(), input(), ) c0, c1 = 0, 0 for i in RE_PARENTHESIS.split(s): if i.startswith('('): ...
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; /** * * @author aboragab */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); in.nextLine(); String str = in.nextLine();...
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() ib = 0; mx = 0; foo = 0 for i in range(n): if s[i]=='(': k = i while s[k]!=')': if (s[k]=='(' or s[k]=='_') and (s[k+1]!=')' and s[k+1]!='_'): ib += 1 k += 1 for i in range(n): if s[i]=='(': k=i+1 while s[k]!=')': 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.util.*; import java.io.*; public class Main extends Reader { public static void main(String[] args) throws IOException { int n = ni(), ml = 0, maxl = 0, ans = 0, p = 0; char s[] = ns().toCharArray(); for (int l=0; l<n; l++) { switch (s[l]) { case '_': ml = 0; break; case '(': ml =...
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 INF = 0x3f3f3f3f; const int MAXN = 300 + 10; int n; char str[MAXN]; int main() { while (~scanf("%d", &n)) { scanf("%s", str); bool inner = false; int maxlen = 0, cnt = 0; for (int i = 0; i < strlen(str); i++) { if (str[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() out="" ins="" i=0 while i<n: if s[i]=="(": i+=1 ins+="_" out+="_" while s[i]!=")": ins+=s[i] i+=1 else: out+=s[i] i+=1 a=out.split("_") x=0 for c in a: x=max(x,len(c)) y=0 b=ins.split("_") for c in b: if 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...
#include <bits/stdc++.h> using namespace std; const double eps = 1e-10; const long long mod = 1e9 + 7; const unsigned long long INF = 1e18; const int N = 2001; string s; int res, len, n, cnt1, cnt2; bool is = false; int main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); cin >> n >> s; for (int i = 0; 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.*; import static java.lang.Math.*; public class Main{ public static void main(String[]args){ Scanner x = new Scanner (System.in); int y = x.nextInt(),r=0,k=0,l=0; char [] z = x.next().toCharArray(); for(int i=0;i<y;i++) { if (z[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 long long int MOD = 1e9 + 7; long long int dx4[] = {-1, 1, 0, 0}; long long int dy4[] = {0, 0, -1, 1}; long long int dx8[] = {-1, -1, -1, 0, 1, 1, 1, 0}; long long int dy8[] = {-1, 0, 1, 1, 1, 0, -1, -1}; bool isvalid(long long int x, long long int y, long long int 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...
#include <bits/stdc++.h> using namespace std; const int MAXN = 255 + 5; int n; char word[MAXN]; int khw_len; int khn_cnt; bool inkh; int tmp; int main() { scanf("%d\n", &n); while (!word[1] || (strlen(word + 1) != n)) gets(word + 1); for (int i = 1; i <= n; i++) { if (!isalpha(word[i]) && !inkh) { khw_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=input() l=(raw_input()) i=0 c=0 lw=0 done=False while i<len(l): tl=0 while i<n and (l[i]!="_" and l[i]!="("): i=i+1 tl=tl+1 if tl>lw: lw=tl if i>n-1: break if l[i]=="(": t=i while i<n and l[i]!=")": i=i+1 r="".join(l[t+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...
n = int(input()) s = input() wl = 0 max_wl = 0 ignore = False ignore2 = True substr = "" num = 0 for l in s: # for word lenght if not ignore: if l != '_' and l != '(' and l != ')': wl += 1 if l == '_': if max_wl < wl: max_wl = wl 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...
from string import ascii_lowercase n = int(input()) s = input() wordsLen = 0 wordsInside = 0 flagInside = False currWord = "" for i in range(n): if(s[i]=='_'): currWord = "" continue elif(s[i]=='('): currWord = "" flagInside = True elif(s[i]==')'): currWord = "" flagInside = False eli...
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 regex = r"\((\w+)\)" regex2 = r"([a-zA-Z]+)" n = input() test_str = input() matches = re.finditer(regex, test_str, re.MULTILINE) # print(re.compile(regex).split(test_str)) test_str_no_parenthesis = test_str number_of_words = 0 for matchNum, match in enumerate(matches, start=1): string = match.group()...
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 re import findall, split, sub string_length = input() string = input() brackets_pattern, sep, replacement, empty_bracket = "\(.*?\)", "\_+", "_", "()" max_length, number_of_words_in_brackets = 0, 0 for bracket in findall(pattern=brackets_pattern, string=string): if bracket != empty_bracket: for 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; bool is(char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); } int main() { int n; scanf("%d", &n); string str; cin >> str; int temp = 0; bool word = false; bool ok = true; int mx = -1; int qwe = 0; for (int i = 0; i < n; ++i) { if (is(...
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 YES_NO(bool ok) { if (ok) cout << "YES" << endl; else cout << "NO" << endl; exit(0); } int maxlen = 0, cnt = 0; void work(int len) { if (len != 0) ++cnt; } void work2(int len) { maxlen = max(maxlen, len); } int main() { int n; cin >> n; string 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() l = input().replace(')', '(').split('(') print(max(len(w) for s in l[::2] for w in s.split('_')), len([w for s in l[1::2] for w in s.split('_') if 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...
n, s = input(), raw_input() cnt, cur, pos, res = 0, 0, 0, 0 for i in range(n): if s[i] == '(': cur, pos = cur + 1, 0 elif s[i] == ')': cur, pos = cur - 1, 0 else: if 'A' <= s[i] <= 'Z' or 'a' <= s[i] <= 'z': if cur == 0: res, pos = max(res, pos + 1), pos + 1 elif pos == 0: cnt, pos = cnt + 1, 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...
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; import java.util.StringTokenizer; public class TextDocument { public static void main(String[] args) { // TODO Auto-generated method stub Sca...
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 -*- input() m=n=0 for i,z in enumerate(input().replace(')','(').split('(')): if 1&i: for z in z.split('_'):n+=''!=z else: for z in z.split('_'):m=max(m,len(z)) print(m,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.util.Scanner; public class textDocAnalysis { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); sc.nextLine(); int count=0; int flag=0; int max=0; int len=0; String str=sc.nextLine(); ...
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() st = input() a = b = 0 flag = False for sl in st.replace(')', '(').split('('): for i in sl.split('_'): if flag: b += len(i) != 0 else: a = max(a, len(i)) flag = not flag 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; string s; vector<int> x[2]; int out_max, d_in; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> s; string tmp = ""; int flag = 0; for (int i = 0; i < n; i++) { if (s[i] == '(') { if (tmp.size()) { x[flag].push_back(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...
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; public class TextRed { public static void main(String[] args) { try { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); int len = 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 collections import defaultdict import sys, os, math if __name__ == "__main__": #n, m = list(map(int, input().split())) #sys.stdout.flush() n = int(input()) s = input() par = False lon, cnt = 0, 0 s1, s2 = "", "" for i in range(n): if s[i] == '(': par = True ...
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()) str = input() str += '_' word_out = [] word_in = [] inpar = 0 counter = 0 for c in str: if c == '(': inpar = 1 if counter > 0: word_out.append(counter) counter = 0 elif c == ')': inpar = 0 if counter > 0: word_in.append(counter) counter = 0 elif c == '_': if inpar == 0 and coun...
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 JavaApplication4 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); String l=sc.next(); char a[]=new char[n]; for(int i=0;i<n;i++) a[i]=l.charAt(i); int i=0,c=0,max=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.*; import java.io.*; public class B { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int chars = Integer.valueOf(br.readLine()); char[] line = br.readLine().toCharArray(); int count = 0; boolean 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...
import java.io.*; import java.util.*; public class tmp1 { public static InputReader in; public static PrintWriter out; public static final int MOD = (int) (1e9 + 7); public static void main(String[] args) { in = new InputReader(System.in); out = new PrintWriter(System.out); ...
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() max_word = 0 word_len = 0 in_br = 0 bracket = False last = '' for i in range(n): if s[i] == '_' and last.isalpha(): if not bracket and max_word < word_len: max_word = word_len word_len = 0 if bracket: in_br += 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...
n = input() s = raw_input() words = s.split('(') ans1 = 0 ans2 = 0 for w in words: words2 = w.split(')') if (len(words2) == 1): #out for wz in words2[0].split('_'): if len(wz) > ans1: ans1 = len(wz) else: #in for wz in words2[0].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() line = input().replace(')', '(').split('(') print(max([len(word) for subw in line[::2] for word in subw.split('_') ]), len([ word for subw in line[1::2] for word in subw.split('_') if 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...
input() s = input() + "_" cnt = 0 in_parentheses = False lw = 0 nw = 0 for c in s: if c is '_': if in_parentheses: nw += cnt > 0 else: lw = max(lw, cnt) cnt = 0 elif c is '(': in_parentheses = True lw = max(lw, cnt) cnt = 0 elif c is ...
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() out = [] inn = [] p = '' for x in s: if(x=='('): out.append(p) p = '' elif(x==')'): inn.append(p) p = '' else: p += x out.append(p) oouut = [] for x in out: for y in x.split('_'): if(len(y)): oouut.append(y) ii...
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()) s1 = input().rstrip() s = (')'.join(s1.split('('))).split(')') fl = 0 ans = 0 k = 0 for i in range(len(s)): if i % 2 == 0: for j in s[i].split('_'): if len(j) > ans: ans = len(j) else: for j in s[i].split('_'): if len(j) > 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 n; cin >> n; char x; bool parenthesis = 0; int word = 0, mxsize = 0, cntp = 0; for (int i = 0; i < n; i++) { cin >> x; if (isalpha(x)) { word++; } if (parenthesis && isalpha(x) == 0 && word) { cntp++; } if (pa...
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...
# https://codeforces.com/problemset/problem/723/B n = int(input()) words = input() start = 0 outside = [] inside = [] for ind,c in enumerate(words): if c=='(': outside += words[start:ind].split('_') start = ind if c==')': inside += words[start+1:ind].split('_') start = ind + 1 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...
n = input() a = raw_input() a = [i for i in a.split('_') if i] b = [] for i in a: curr = "" for c in i: if c == '(': if curr: b.append(curr) b.append('(') curr = "" elif c == ')': if curr: b.append(curr) b.append(')') curr = "" else: curr += c if curr: b.append(curr) fl = 0 ans1 = 0 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...
#include <bits/stdc++.h> using namespace std; int bigPWord(string inP) { int size = 0, cur = 0, ans = 0; while (cur < inP.size()) { int cSize = 0; bool flag = false; while (cur < inP.size() and inP[cur] != '_' and inP[cur] != '(' and inP[cur] != ')') { cur++; cSize++; 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...
input() s=input() a, b=0, 0 while s.find('(')>=0: l, r=s.find('('), s.find(')') a=max(a, *map(len, s[:l].split('_'))) b+=sum(1 for t in s[l+1:r].split('_') if t!='') s=s[r+1:] a=max(a, *map(len, s.split('_'))) 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...
import java.util.*; import java.io.*; import java.math.*; public class Solution{ /*public static String(int n) throws java.lang.Exception { BigInteger fact= BigInteger.ONE; for (int i = 2; i <=n; i++) { fact = fact.multiply(new BigInteger(Strin...
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, i, stat, l0, ans0, ans1; string s; bool islet(int k) { if (s[k] >= 'A' && s[k] <= 'Z' || s[k] >= 'a' && s[k] <= 'z') return true; else return false; } int main() { cin >> n; cin >> s; s = "_" + s + "_"; n++; for (i = 1; i < n; i++) { if (isl...
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().strip() A = A.strip('_') A = A.replace('()','_') while "__" in A: A = A.replace("__","_") A = A.split('(') P = [] NP = [] while '' in A: A.remove('') for i in range(len(A)): if ')' in A[i]: NP.append(A[i].split(')')[1]) P.append(A[i].split(')')[0]) else: NP.append(A[i]) wh...
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 read(t=None): string = raw_input() return string if t is None else [t(x) for x in string.split()] if __name__ == "__main__": n = int(read()) s = read() i, o = "_", "_" embraced = False for x in s: if x == "(" or x == ")": i += "_" o += "_" embraced = not embraced continue if embraced: 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 n = input() new = input() out = [len(x) for x in re.sub(r'\(.*?\)', '_', new).split('_')] sec = '' for i in re.findall(r'\(\w+\)?', new): for j in i: if j == '(' or j == ')': sec += '_' else: sec += j ans = 0 for i in re.split(r'_+', sec): if i != '': ans += 1 if out == []: print(0, ans) 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...
l = raw_input() s = raw_input() count1 = 0 count2 = 0 paren = False count = 0 for i in xrange(len(s)): if s[i] == '(': count2 = max(count2, count) count = 0 paren = True elif s[i] == ')': count2 = max(count2, count) count = 0 paren = False elif paren: if i and s[i] != '_' and s[i-1] == '_': 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...
l = input() s = raw_input() ins = '' outs = '' cur = 0 while cur < l: if s[cur] == '(': outs += "_" cur += 1 while s[cur] != ')': ins += s[cur] cur += 1 if s[cur] == ')': ins += '_' else: outs += s[cur] cur += 1 maxl = max(map(len, outs.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() { char s; int n, m = 0, m1 = 0, c = 0, k = 0, l = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> s; if (s == '(') { if (l > m) { m = l; l = 0; }; l = 0; c++; }; if (s == ')') { if (k > 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 n, l = 0, max = 0, j, r = 0; cin >> n; string s; cin >> s; bool f = false, g = false; for (int i = 0; i < s.size(); i++) { if (s[i] == '(') { j = i + 1; f = false; while (s[j] != ')') { if ((s[j] == '_' || s[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...
#include <bits/stdc++.h> using namespace std; int main() { int n; scanf("%d", &n); char s[260]; scanf("%s", s); bool flag = 1; int ans, maxsans = -1, out = 0; for (int i = 0; i < n; i++) { ans = 0; while (flag and (s[i] >= 'a' and s[i] <= 'z') or (s[i] >= 'A' and s[i] <= 'Z')) { 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...
#include <bits/stdc++.h> using namespace std; int main() { int n, flag = 0, j, m = -1, ans = 0, count = 0; cin >> n; string s, str = "_", str2, str3; cin >> s; for (long long i = 0; i < n; ++i) { if (s[i] == '(') flag = 1; if (s[i] == ')') flag = 0; if (flag == 0) { if (s[i] == ')') str2 += ...
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() brk_start = False word_len,word_cnt,word_max_len=0,0,0 for i in s: if i == "(": word_max_len = max(word_max_len,word_len) brk_start = True word_len = 0 elif i == ")": if word_len > 0: word_cnt +=1 brk_start = False word_len = 0 eli...
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.*; /** * * @author Loay mansour */ public class CodeForces { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String s = sc.next(); int wordCount = 0; int maxLenAns = Integer.MIN_VALUE; int nu...
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...
# Main maut ko takiya, aur kafan ko chaadar banakar audhta hoon! n=int(input()) s=input() noof=0 while(s.find("__")!=-1): s=s.replace("__","_") while(s.find("(")!=-1): start=s.find("(") end=s.find(")") l=s[start+1:end] while(l[:1]=='_'): l=l[1:] while(l[-1:]=='_'): l=l[:-1] if(l==''): pass 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 i, n, cnt = 0, flag = 0, word = 0, ans1 = 0, ans2 = 0; int k = 0, key = 0, x = 0; string s; cin >> n; cin >> s; for (int i = 0; i < n; i++) { if (s[i] == '(') { ans1 = max(k, ans1); k = 0; x = 1; } else 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...
def mainB(): n = input() palabra = raw_input() pFuera = ['_'] cf = 0 pDentro = ['_'] cd = 0 dentro = False for i in range(n): if palabra[i] == '(': dentro = True elif palabra[i] == ')': pDentro.append('_') pFuera.append("_") dentro = False else: if not(dentro) : if pFuera[-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 re n = input() s = raw_input() i = 0 mxp = 0 cp = 0 while s.find('(',i)!=-1: z = s.find('(',i) q = s.find(')',z) inp = s[z:q+1] inp = inp[1:-1] #print inp inp = re.sub( '_+', '_', inp ).strip() #print inp u = len(inp.split('_')) #cp+=u i = z+1 for j in inp.spl...
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() { char a[300]; int n, wordnum = 0, begin, wordlen = 0, max = 0; int i; scanf("%d", &n); scanf("%s", a); for (i = 0, begin = 0; i <= n - 1; i++) { if (a[i] == '(') { begin = 1; } if (begin == 1 && ((a[i] >= 'a' && a[i] <= 'z') || (a[i] >= 'A' && 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...
n = int(input()) s = input() f = False a = b = 0 for s1 in s.replace('(',')').split(')'): for i in s1.split('_'): if f: b += len(i) != 0 else: a = max(a,len(i)) f = not f 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...
import re string_length = input() string = input() brackets_pattern, sep, replacement, empty_bracket = "\(.*?\)", "\_+", "_", "()" max_length, number_of_words_in_brackets = 0, 0 brackets = re.findall(pattern=brackets_pattern, string=string) for bracket in brackets: if bracket != empty_bracket: words_in_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...
import java.io.*; //PrintWriter import java.math.*; //BigInteger, BigDecimal import java.util.*; //StringTokenizer, ArrayList public class R375_Div2_B { FastReader in; PrintWriter out; public static void main(String[] args) { new R375_Div2_B().run(); } void run() { in = new FastReader(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...
n = int(input()) a = input() + ' ' count = 0 counts = a.count("(") for x in range(counts): try: start = a.index("(") stop = a.index(")") b = a[start:stop + 1].strip("()").split("_") for x in b: if len(x) > 0: count += 1 a = a[:start]+"_" + a[stop +...
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 def some_func(): """ """ cache_lit1 = [] cache_lit2 = [] n = input() #n_num = map(int,sys.stdin.readline().split()) n_str = sys.stdin.readline() flag1 = 0 flag2 = 0 for i in range(n): if n_str[i]=='(': flag1 = 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...
import java.io.*; import java.nio.Buffer; import java.util.*; import java.util.concurrent.atomic.AtomicReferenceArray; public class codeforces { // public static long fact[]; // public static int mod=1000000007; public static long []st; public static void main(String[] args) throws IOException { ...
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.PrintWriter; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int length = in.nextInt(); in.nextLine(); String line = in.nextLine(); ...
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 python3 import re def main(): try: while True: n = int(input()) s = input() max_len = inner_count = 0 inside = False for m in re.finditer(r"[()]|[A-Za-z]+", s): t = m.group()[0] if t.isalpha(): ...
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.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class Main{ private void solve() throws Exception{ int n = ri(); String s = rs(); ...
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() inp = False st, A, B = 0, 0, 0 for c in s: if c == '_': if st: if inp: B += 1 else: A = max(A, st) st = 0 elif c == '(': assert(not inp) if st: A = max(A, st) st = 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() { short s_len, cur_len = 0, max_len = 0, in_par_count = 0; bool flag = false; string s; cin >> s_len >> s; s_len--; for (int i = 0; i <= s_len;) { flag = false; cur_len = 0; if (s[i] == ')') i++; else if (s[i] == '_') { max...
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()) data = list(input()) res1 = 0 res2 = 0 inpair = False count = 0 for i in range (n): if data[i] == '(': if count > 0: res1 = max(res1, count) count = 0 inpair = True elif data[i] == ')': if count > 0: res2 += 1 count = 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,word = input(),input() # simplify open-closing pairs word = word.replace('(','|').replace(')','|').split('|') # check whether the first item in word is within parenthesis flag = word[0]=='(' a,b = 0,0 # the length of the longest word outside the parentheses for foo in word[[0,1][flag]::2]: a = max(a,*[len(w) for ...
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 analyze(s): m1, m2 = 0, 0 m, l = 0, 0 for i in range(len(s)): if ord('A') <= ord(s[i]) <= ord('Z') or ord('a') <= ord(s[i]) <= ord('z'): m += 1 continue if l > 0 and m > 0: m2 += 1 if l == 0: m1 = max(m1, m) 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...
#include <bits/stdc++.h> using namespace std; string str; int main() { long long t, i, j, n, m, len, lgword, curLen, noWords, bracInLen; bool flag = true; scanf("%lld", &len); cin >> str; lgword = curLen = bracInLen = 0; noWords = 0; for (i = 0; i < len; ++i) { if (str[i] == '(' || 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...
input() s = input() ml = 0 count = 0 wordl = 0 word_co = 0 b = False word = False for i in s: if b: if i != "_" and i != ")" and not word: word = True word_co += 1 elif i == "_": word = False if i == ")": count += word_co word_co =...
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() text = raw_input() longest_out = 0 current_count = 0 in_paren = False words_in_paren = 0 paren_count = 0 for c in text: if current_count > longest_out: longest_out = current_count if c == '(': in_paren = True current_count = 0 paren_count = 0 continue if...