s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s119140980
p03695
u154904553
1497148555
Python
Python (3.4.3)
py
Runtime Error
17
3064
309
N=int(input()) a_n=[] a2_n=[] a_n = input().split(" ") count = 0 for i in range(N): if int(a_n[i])/400 < 8: a2_n.append(int(a_n[i])/400) else: count += 1 if len(a2_n) == 0: num = 0 n_min = 1 else: n_min = len(set(a2_n)) n_max = num+count print(str(n_min)+" "+str(n_max))
s818752590
p03695
u533084327
1497148373
Python
Python (3.4.3)
py
Runtime Error
17
3060
524
import numpy as np N = int(input()) a = [int(_) for _ in input().split()] a = np.array(a) a = np.sort(a) min = 0 max = 0 m = 0 for i in range(8): set_1 = set(np.where(i*400<=a)[0]) set_2 = set(np.where(a<(i+1)*400)[0]) match = list(set_1 & set_2) if len(match)>0: min+=1 if min=0: min=1 ...
s064869571
p03695
u768816323
1497148368
Python
Python (3.4.3)
py
Runtime Error
17
3064
303
N=int(input()) a=[int(i) for i in input(). split ()] b=[] for i in range(9): b.append(0) for i in range (N): if a[i]>=3200: b[8]+=1 else: j=a[i]//400 b[j]+=1 i=0 mi=0 while i<8: mi+=b[i] i+=1 ma=mi if b[8]>0: ma+=b[8] if b[8]>8: ma=8 print (mi+" "+ma)
s530489711
p03695
u533084327
1497148322
Python
Python (3.4.3)
py
Runtime Error
19
3064
525
import numpy as np N = int(input()) a = [int(_) for _ in input().split()] a = np.array(a) a = np.sort(a) min = 0 max = 0 m = 0 for i in range(8): set_1 = set(np.where(i*400<=a)[0]) set_2 = set(np.where(a<(i+1)*400)[0]) match = list(set_1 & set_2) if len(match)>0: min+=1 if min=0: min=1 ...
s586951717
p03695
u768816323
1497148207
Python
Python (3.4.3)
py
Runtime Error
17
3064
291
N=int(input()) a=[int(i) for i in input(). split ()] b=[] for i in range(9): b.append(0) for i in range (N): if a[i]>=3200: b[8]+=1 else: b[a[i]//400]+=1 i=0 mi=0 while i<8: mi+=b[i] i+=1 ma=mi if b[8]>0: ma+=b[8] if b[8]>8: ma=8 print (mi+" "+ma)
s617252290
p03695
u276192130
1497146915
Python
Python (3.4.3)
py
Runtime Error
17
3064
669
n = int(input()) a = list(map(int, input().split())) a.sort() color = [] other = 0 for i in a: if i < 400 * 1: color.append('1') elif i < 400 * 2: color.append('2') elif i < 400 * 3: color.append('3') elif i < 400 * 4: color.append('4') elif i < 400 * 5: colo...
s206363811
p03695
u846552659
1497146100
Python
Python (3.4.3)
py
Runtime Error
17
3064
968
# -*- coding:utf-8 -*- N = int(input()) a = list(map(int, input().split())) rate = [ 0 for tmp in range(9) ] factor = 0 empty = 0 for tmp in range(N): if 1 <= a[tmp] and a[tmp] <= 399: rate[0] += 1 elif 400 <= a[tmp] and a[tmp] <= 799: rate[1] += 1 elif 800 <= a[tmp] and a[tmp] <= 1199: ...
s657693846
p03695
u713627549
1497146041
Python
Python (3.4.3)
py
Runtime Error
17
3064
851
n = int(input()) a = list(int(i) for i in input().split()) hai = 0 tya = 0 midori = 0 mizu = 0 ao = 0 ki = 0 daigai = 0 aka = 0 niji = 0 mincolor = 0 maxcolor = 0 for i in range(n): if 1 <= a[i] and a[i] <=399: hai = 1 elif 400 <= a[i] and a[i] <= 799: tya = 1 elif 800 <= a[i] and a[i] <...
s899153408
p03695
u814762953
1497145555
Python
Python (3.4.3)
py
Runtime Error
17
3064
373
import math ranks = [False for i in range(8)] highs = 0 n = int(input()) inps = [int(i) for i in input().split()] highs = len([i for i in inps if i > 3199]) inps = [i for i in inps if i <= 3199] for i in inps: ranks[math.floor(i/399)] = True lows = min(len([i for i in ranks if i == True]), 8) minimum = max(lows...
s455010114
p03695
u744898490
1497145260
Python
Python (3.4.3)
py
Runtime Error
17
3064
380
w = int(input()) num = input().split(' ') b = [int(x) for x in num] a1 = [0, 399, 799, 1199, 1599, 1999, 2399, 2799, 3199] a2 = [0, 0 ,0, 0 ,0, 0 ,0, 0 ] a3 = 0 for e in range(1, 9): for i in range(len(b)): if b[i] <= a1[e] and b[i] > a1[e -1] : a2[e] = 1 elif b[i] > 3199: ...
s902317915
p03695
u814762953
1497145244
Python
Python (3.4.3)
py
Runtime Error
18
3064
365
import math ranks = [False for i in range(8)] highs = 0 n = int(input()) inps = [int(i) for i in input().split()] highs = len([i for i in inps if i > 3199]) inps = [i for i in inps if i <= 3199] for i in inps: ranks[math.floor(i/399)] = True lows = len([i for i in ranks if i == True]) minimum = max(lows, 1) max...
s640087587
p03695
u016620620
1497145228
Python
Python (3.4.3)
py
Runtime Error
17
2940
403
memTime = int(input()) memLate = input().split() memLate = [int(i) for i in memLate] colorList = [] memColor = 0 highLate = 0 for color in memLate: if color // 400 >= 8: highLate += 1 elif color // 400 in colorList == False colorList += color // 400 maxColor = len(colorList) + highLate if maxCol...
s216310816
p03695
u190525112
1497145210
Python
Python (3.4.3)
py
Runtime Error
18
3064
442
N = int(input()) x = list(map(int, input().split())) a=[0]*8 b=0 for i in range(0,N): if x[i]>=3200: b +=1 for j in range(0,8): for i in range(0,N): if x[i]<400: a[j] +=1 x[i] = inf x[i] -= 400 zerox=0 mincolar=0 for i in a: if i==0: zerox +=1 ...
s841127879
p03695
u154904553
1497144975
Python
Python (3.4.3)
py
Runtime Error
17
3064
254
N=int(input()) a_n=[] a_n = input().split(" ") a_n = x.split(" ") count = 0 a_n.sort() for i in range(N): if int(a_n[i])/400 < 8: a_n[i] = int(a_n[i])/400 else: count += 1 num = len(set(a_n)) print(str(num)+" "+str(num+count))
s730111378
p03695
u346308892
1497144844
Python
Python (3.4.3)
py
Runtime Error
17
2940
218
h=[0]*8 nu=0 #N=int(input()) #a=list(map(int,input().split(" "))) for sa in a: fsa=int(sa/400) if fsa<=7: h[fsa]=1 else: nu+=1 Min=sum(h) Max=min(8,Min+nu) print(str(Min)+" "+str(Max))
s722184103
p03695
u341926204
1497144788
Python
Python (3.4.3)
py
Runtime Error
17
3064
725
def c(): n = int(input()) a = list(map(int, input().split())) x = [] def set_col(rate): if rate <= 399: return '灰色' elif rate <= 799: return '茶色' elif rate <= 1199: return '緑色' elif rate <= 1599: return '水色' elif rat...
s909800660
p03695
u814762953
1497144675
Python
Python (3.4.3)
py
Runtime Error
18
3064
373
import math ranks = [False for i in range(8)] highs = 0 n = int(input()) inps = [int(i) for i in input().split()] highs = min(len([i for i in inps if i > 3199]), 8) inps = [i for i in inps if i <= 3199] for i in inps: ranks[math.floor(i/399)] = True lows = len([i for i in ranks if i == True]) minimum = max(lows...
s802407100
p03695
u341926204
1497144631
Python
Python (3.4.3)
py
Runtime Error
18
3064
812
def c(): n = int(input()) a = list(map(int, input().split())) x = [] def set_col(rate): if 1 <= rate <= 399: return '灰色' elif 400 <= rate <= 799: return '茶色' elif 800 <= rate <= 1199: return '緑色' elif 1200 <= rate <= 1599: ...
s435072407
p03695
u238510421
1497144521
Python
Python (3.4.3)
py
Runtime Error
17
3064
416
n = int(input()) a_str = input().split() a_num = [int(a) for a in a_str] a_array = np.array(a_num) rate_list = [1,400,800,1200,1600,2000,2400,2800,3200] count = 0 for i in range(8): if len(a_array[np.where((a_array>=rate_list[i])&(a_array<rate_list[i+1]))]): count += 1 min_count = count count += len(a_...
s613717033
p03695
u346308892
1497144272
Python
Python (3.4.3)
py
Runtime Error
17
3060
207
N=int(input()) a=list(map(int,input().split(" "))) for sa in a: fsa=int(sa/400) if fsa<=7: h[fsa]=1 else: nu+=1 Min=sum(h) Max=min(8,Min+(nu)) print(str(Min)+" "+str(Max))
s107845646
p03695
u346308892
1497144156
Python
Python (3.4.3)
py
Runtime Error
17
3060
218
N=int(input()) a=list(map(int,input().split(" "))) for sa in a: fsa=int(sa/400) print(fsa) if fsa<=7: h[fsa]=1 else: nu+=1 Min=sum(h) Max=min(8,Min+(nu)) print(str(Min)+" "+str(Max))
s835355845
p03695
u814762953
1497144003
Python
Python (3.4.3)
py
Runtime Error
17
3064
388
import math ranks = [False for i in range(8)] highs = 0 n = int(input()) inps = [int(i) for i in input().split()] highs = len([i for i in inps if i > 3199]) inps = [i for i in inps if i <= 3199] for i in inps: ranks[math.floor(i/399)] = True lows = len([i for i in ranks if i == True]) minimum = lows + (1 if ran...
s787371757
p03695
u500547581
1497143651
Python
Python (3.4.3)
py
Runtime Error
17
3064
678
n = int(input()) a = list(map(int, input().split())) d = {'gray': 0, 'green': 0, 'cyan': 0, 'red': 0, 'brown': 0, 'blue': 0, 'yellow': 0, 'orange': 0, 'above':0} for i in a: if i <= 399: d['gray'] += 1 elif i <=799: d['brown'] += 1 elif i <= 1199: d['green'] += 1 elif i <= 1599: ...
s633394277
p03696
u465101448
1600616959
Python
PyPy3 (7.3.0)
py
Runtime Error
106
74588
594
N = int(input()) S = list(input()) right = 0 left = 0 divid = [0] for s_1 in range(len(S)-1): s_2 = s_1+1 if S[s_1] == ')' and S[s_2] == '(': divid.append(s_2) divid.append(len(S)) for s1,s2 in zip(divid[:-1],divid[1:]): S_temp = S[s1:s2] right_temp = 0 left_temp = 0 for s in S_temp: ...
s089979318
p03696
u271064067
1599034477
Python
Python (3.8.2)
py
Runtime Error
24
9100
495
n = int(input()) s = str(input()) ans = "" index = 0 left = 0 right = 0 for i in range(n): if s[-i-1] == ")": index1 = n - i break for i in range(n): if s[i] == "(": index2 = i break #s = "(" * index2 + s lis = s[index2:index1] left = lis.count("(") right = lis.count(")"...
s178859899
p03696
u969708690
1597970160
Python
Python (3.8.2)
py
Runtime Error
29
9192
228
N=int(input()) S=input() i=0 hidari=str() migi=str() a=0 while S[i]==")": hidari+="(" i+=1 while i<N: if S[i]=="(": a+=1 else: a-=1 i+=1 if a<0: hidari+=abs(a)*"(" elif a>0: migi+=a*")" print(hidari+S+migi)
s670743912
p03696
u232873434
1596807220
Python
PyPy3 (7.3.0)
py
Runtime Error
99
74696
419
N = int(input()) s = input() for i in range(N): if s[i] == '(': ind1 = i break for i in range(N): if s[N-i-1] == ')': ind2 = N-i break left = s[:ind1].count(')') right = s[ind2:].count('(') mid_left = s[ind1:ind2].count(')') mid_right = s[ind1:ind2].count('(') left += max(0,...
s812616834
p03696
u871841829
1594185429
Python
Python (3.8.2)
py
Runtime Error
27
9064
271
_ = input() S = input() needs_right = 0, needs_left = 0 for c in S: if c == '(': needs_right += 1 else: if needs_right == 0: needs_left += 1 else: needs_right -= 1 print('(' * needs_left + S + ')' * needs_right)
s475939278
p03696
u127499732
1592283960
Python
Python (3.4.3)
py
Runtime Error
17
3064
387
def main(): n = int(input()) s = input() t = s.split(')(') if len(t) == 1: u = t[0].split('()') print(u) v = max(len(u[0]), len(u[1])) + 1 ans = v * '(' + v * ')' print(ans) exit() ans = '' for x in t: l = len(x) + 1 ans += l * '('...
s867061794
p03696
u496821919
1590945784
Python
Python (3.4.3)
py
Runtime Error
19
3064
581
import sys n = int(input()) s = input() ans = s while True: visited = [0]*(len(s)) t = "" for i in range(len(s)-1): if not visited[i]: if s[i:i+2] == "()": visited[i+1] = 1 else: t += s[i] if not visited[len(s)-1]: t += s[-1] s ...
s407084996
p03696
u496821919
1590945661
Python
Python (3.4.3)
py
Runtime Error
18
3064
518
n = int(input()) s = input() ans = s while True: visited = [0]*(len(s)) t = "" for i in range(len(s)-1): if not visited[i]: if s[i:i+2] == "()": visited[i+1] = 1 else: t += s[i] if not visited[len(s)-1]: t += s[-1] s = t if ...
s518281205
p03696
u043048943
1590636173
Python
PyPy3 (2.4.0)
py
Runtime Error
171
38256
869
def main(): from sys import setrecursionlimit, stdin from os import environ from collections import defaultdict, deque, Counter from math import ceil, floor, gcd from itertools import accumulate, combinations, combinations_with_replacement setrecursionlimit(10**6) dbg = (lambda *something: p...
s410891860
p03696
u969850098
1589126187
Python
Python (3.4.3)
py
Runtime Error
17
3064
581
import sys readline = sys.stdin.readline def main(): N = int(readline()) S = readline().rstrip() res = S[:] if '(' in S: idx = S.index('(') cnt = 1 for s in S[idx+1:]: if s == '(': cnt += 1 else: cnt -= 1 res += ')...
s331246594
p03696
u414458988
1588984572
Python
PyPy3 (2.4.0)
py
Runtime Error
176
38256
348
def main(): n = int(input()) s = list(input()) left = 0 right = 0 for i in range(n): if s[i] == '(': right += 1 else: if right == 0: left += 1 else: right -= 1 res = '' print('('*left+s+')'*right) if __name_...
s168584008
p03696
u219197917
1588813422
Python
Python (3.4.3)
py
Runtime Error
18
2940
205
n = int(input()) s = input() d = 0 x = n for si in s: if si == "(": d += 1 else: d -= 1 x = min(d, x) print("(" * -x + s + ")" * (d - x))
s174611422
p03696
u599114793
1587128435
Python
PyPy3 (2.4.0)
py
Runtime Error
178
38640
1195
n = int(input()) s = list(input()) leng = [] cnt = 1 for i in range(n-1): if s[i] == s[i+1]: cnt += 1 else: leng.append([s[i], cnt]) cnt = 1 if s[-1] == "(": leng.append(["(", cnt]) else: leng.append([")", cnt]) if s[0] == ")": leng.insert(0,["(", leng[0][1]]) if s[-1] == "("...
s895873162
p03696
u392319141
1587123741
Python
Python (3.4.3)
py
Runtime Error
17
3064
346
N = int(input()) S = list(input()) ans = [] while S and S[-1] == '(': ans.append(')') S.pop() ans = '(' * len(ans) + ''.join(ans) cnt = 0 for s in S[::-1]: if s == ')': cnt += 1 else: cnt -= 1 if cnt > 0: ans = '(' * cnt + ''.join(S) + ans if cnt < 0: ans = S + ''.join(S) + ')...
s010040722
p03696
u478266845
1586707271
Python
Python (3.4.3)
py
Runtime Error
17
2940
278
n = int(input()) s =str(input()) left_save = 0 dept=0 for i in range(len(s)): if s[i] ==')': if left_save = 0: dept +=1 else: left_save-=1 else: left_save+=1 ans = '('*dept + s + ')'*left_save print(ans)
s090174335
p03696
u652057333
1586364160
Python
PyPy3 (2.4.0)
py
Runtime Error
172
38384
491
n = int(input()) s = str(input()) ans_s = s ans_head = 0 ans_tail = 0 def remove(s): while True: if len(s) <= 0: break pre_len = len(s) s = s.replace("()", "") if len(s) == pre_len: break return s while len(s) > 0: s = remove(s) if s[0] == ')': ...
s274634289
p03696
u652057333
1586364097
Python
PyPy3 (2.4.0)
py
Runtime Error
167
38256
449
n = int(input()) s = str(input()) ans_s = s ans_head = 0 ans_tail = 0 def remove(s): while True: pre_len = len(s) s = s.replace("()", "") if len(s) == pre_len: break return s while len(s) > 0: s = remove(s) if s[0] == ')': ans_head += 1 s = remove('...
s313753943
p03696
u210827208
1585521146
Python
Python (3.4.3)
py
Runtime Error
18
3064
193
n=int(input()) s=input() if s[0]==')': cnt=1 else: cnt=0 for i in range(1,n): if s[i]==')' and s[i-1]!='(': cnt+=1 if s[i]==')': x=i print('('*cnt+s+')'*(n-x-1))
s265904135
p03696
u124498235
1584807834
Python
Python (3.4.3)
py
Runtime Error
18
3064
290
n = int(input()) s = input() lef2 = s.rindex(")") rit2 = s.index("(") ans = s ans += ")"*(n-(lef2+1)) ans = "("*rit2 + ans lef = ans.count("(") rit = ans.count(")") if lef > rit: ans += ")"*(lef-rit) print (ans) elif lef == rit: print (ans) else: ans = "("*(rit-lef) + ans print (ans)
s603292772
p03696
u644972721
1584064369
Python
Python (3.4.3)
py
Runtime Error
18
3064
367
n = int(input()) s = list(input()) m = 0 c1, c2 = 0, 0 for i in range(n): if s[i] == ")": m += 1 c2 = c1 else: c1 += 1 j = 0 while True: if s[j] == "(": break j += 1 l = max((m - c2), j) s1 = ["("] * l for i in s: if i == "(": l += 1 else: l -= 1 s...
s278198882
p03696
u644972721
1584063599
Python
Python (3.4.3)
py
Runtime Error
17
3064
319
n = int(input()) s = list(input()) m, l = 0, 0 c1, c2 = 0, 0 for i in range(n): if s[i] == ")": m += 1 c3 = c1 else: c1 += 1 if s[n - i - 1] == "(": l += 1 c4 = c2 else: c2 += 1 s1 = ["("] * (m - c3) s2 = [")"] * (l - c4) s = s1 + s + s2 print("".join(s))
s766905931
p03696
u097317219
1583615096
Python
PyPy3 (2.4.0)
py
Runtime Error
188
38640
298
n = int(input()) s = list(input()) r = 0 l = 0 i = 0 if s[0] == ")": while(s[i] == ")"): l += 1 i += 1 if s.count("(") > s.count(")")-l: r += s.count("(")-(s.count(")")-l) elif s.count("(") == s.count(")")-l: pass else: l += s.count(")")-l-s.count("(") print(l*"("+"".join(s)+r*")")
s600551712
p03696
u186838327
1583309126
Python
PyPy3 (2.4.0)
py
Runtime Error
169
38512
226
def power(a, n, mod): bi=str(format(n,"b")) #2進数 res=1 for i in range(len(bi)): res=(res*res) %mod if bi[i]=="1": res=(res*a) %mod return res n, m, p = map(int, input().split()) print(power(n, p, m))
s766195394
p03696
u094191970
1582592812
Python
Python (3.4.3)
py
Runtime Error
17
3064
297
n=int(input()) s=input() ans=s c=s.count('()') while c!=0: s=list(s) i=0 n_s='' while i<=len(s)-1: if s[i]=='(' and s[i+1]==')': i+=2 else: n_s+=s[i] i+=1 s=''.join(n_s) c=s.count('()') c_a=s.count('(') c_b=s.count(')') ans='('*c_b+ans+')'*c_a print(ans)
s146532253
p03696
u094191970
1582592013
Python
Python (3.4.3)
py
Runtime Error
18
3064
289
n=int(input()) s=input() ans=s c=s.count('()') while c!=0: s=list(s) i=0 while i<=len(s)-1: if s[i]=='(' and s[i+1]==')': del s[i] del s[i+1] else: i+=1 s=''.join(s) c=s.count('()') c_a=s.count('(') c_b=s.count(')') ans='('*c_b+ans+')'*c_a print(ans)
s827673030
p03696
u476604182
1582581391
Python
Python (3.4.3)
py
Runtime Error
17
3064
317
N, S = open('0').read().split() N = int(N) cnt = 0 l = 0 for i in range(N): if S[i]=='(': cnt += 1 else: if cnt==0: l += 1 else: cnt -= 1 cnt = 0 r = 0 for i in range(N-1,-1,-1): if S[i]==')': cnt += 1 else: if cnt==0: r += 1 else: cnt -= 1 print('('*l+S+')'*r)
s110646798
p03696
u791593901
1580437628
Python
PyPy3 (2.4.0)
py
Runtime Error
167
38256
669
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair<int,int> P; #define yn {puts("Yes");}else{puts("No");} #define MAX_N 200005 int main() { ...
s605826339
p03696
u377989038
1579429945
Python
Python (3.4.3)
py
Runtime Error
17
3060
247
n = int(input()) s = input() x = n - s[::-1].find(")") l = 0 r = 0 for i in range(x): if s[i] == "(": l += 1 else: r += 1 if l < r: ans = "(" * (r - l) + s print(ans + ")" * max(0, (ans.count("(") - ans.count(")"))))
s353723840
p03696
u442810826
1579151028
Python
Python (3.4.3)
py
Runtime Error
148
12504
883
import numpy as np import copy N= int(input()) S=input() SS= copy.copy(S) S = list(S) #N, A, B = map(int, input().split()) flag = 1 #print(len(S)) while flag == 1: flag = 0 flag2 = 1 i = 0 while flag2: # for i in range(len(S)-1): #print(S) #print(i) if S[i]=="(" and S[i+1] ...
s018016976
p03696
u442810826
1579150936
Python
Python (3.4.3)
py
Runtime Error
149
12504
892
import numpy as np import copy N= int(input()) S=input() SS= copy.copy(S) S = list(S) #N, A, B = map(int, input().split()) flag = 1 #print(len(S)) while flag == 1: flag = 0 flag2 = 1 i = 0 while flag2: # for i in range(len(S)-1): #print(S) #print(i) if S[i]=="(" and S[i+1] ...
s478117881
p03696
u442810826
1579149625
Python
Python (3.4.3)
py
Runtime Error
149
14292
833
import numpy as np import copy N= int(input()) S=input() SS= copy.copy(S) S = list(S) #N, A, B = map(int, input().split()) flag = 1 #print(len(S)) while flag == 1: flag = 0 flag2 = 1 i = 0 while flag2: # for i in range(len(S)-1): #print(S) #print(i) if S[i]=="(" and S[i+1] ...
s075317301
p03696
u442810826
1579139005
Python
Python (3.4.3)
py
Runtime Error
148
12504
786
import numpy as np import copy N= int(input()) S=input() SS= copy.copy(S) S = list(S) #N, A, B = map(int, input().split()) flag = 1 #print(len(S)) while flag == 1: flag = 0 flag2 = 1 i = 0 while flag2: # for i in range(len(S)-1): #print(i) if S[i]=="(" and S[i+1] ==")": ...
s744719195
p03696
u442810826
1579138761
Python
PyPy3 (2.4.0)
py
Runtime Error
163
38256
785
import numpy as np import copy N= int(input()) S=input() SS= copy.copy(S) S = list(S) #N, A, B = map(int, input().split()) flag = 1 #print(len(S)) while flag == 1: flag = 0 flag2 = 1 i = 0 while flag2: # for i in range(len(S)-1): #print(i) if S[i]=="(" and S[i+1] ==")": ...
s207079869
p03696
u442810826
1579132477
Python
Python (3.4.3)
py
Runtime Error
311
21764
782
import numpy as np import copy N= int(input()) S=input() SS= copy.copy(S) S = list(S) #N, A, B = map(int, input().split()) flag = 1 print(len(S)) while flag == 1: flag = 0 flag2 = 1 i = 0 while flag2: # for i in range(len(S)-1): print(i) if S[i]=="(" and S[i+1] ==")": f...
s907435400
p03696
u474423089
1578338498
Python
Python (3.4.3)
py
Runtime Error
17
3064
350
N=int(input()) s=input() ans = s flag_A = True r = 0 l = 0 while flag_A: flag_B =False for n,i in enumerate(s[:-2]): if i =="(" and s[n+1] ==")": s = s[:n]+s[n+2:] flag_B = True if not flag_B: flag_A = False for i in s: if i ==")": r += 1 else: ...
s804430616
p03696
u474423089
1578338288
Python
Python (3.4.3)
py
Runtime Error
17
3064
357
N=int(input()) s=input() ans = s flag_A = True r = 0 l = 0 while flag_A: flag_B =False for n,i in enumerate(s): if n!=N-1 and i =="(" and s[n+1] ==")": s = s[:n]+s[n+2:] flag_B = True if not flag_B: flag_A = False for i in s: if i ==")": r += 1 else: ...
s491802642
p03696
u688375653
1578032040
Python
PyPy3 (2.4.0)
py
Runtime Error
168
38640
681
def two_int(): N, K = map(int, input().split()) return N,K def one_int(): return int(input()) def one_str(): return input() def many_int(): return list(map(int, input().split())) # import sys # input = sys.stdin.readline N=one_int() S=one_str() first_start_index=S.index("(") count=0 for i in r...
s490594264
p03696
u838786721
1576901226
Python
Python (3.4.3)
py
Runtime Error
17
2940
118
N = int(input) S = input() d = S.replace('()','') l = d.count('(') r = d.count(')') z = '('*l + d + ')'*r print(z)
s173948754
p03696
u905582793
1576512871
Python
Python (3.4.3)
py
Runtime Error
27
4080
314
import queue n=int(input()) s=input() q=queue.Queue(s) def br(a): for i in range(1,len(a)+1): if a[:i].count("(")<a[:i].count(")"): return ")" if a.count("(")==a.count(")"): return "0" else: return "(" for i in range(1,len(s)+1): if s[:i].count("(")<s[:i].count(")"): s.append("(")
s622243473
p03696
u083190434
1576297919
Python
Python (3.4.3)
py
Runtime Error
17
2940
1089
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(long long i = 0; i < n; ++i) typedef long long ll; const ll MOD = 1e9+7; int main(){ int n; string s; cin >> n >> s; int lcnt = 0,rcnt = 0; int lnum = 0, rnum = 0; for(int i = 0; i < n; ){ // ( に対して) が少ない場合に付け足す lcnt = 0; ...
s041258004
p03696
u989345508
1576161649
Python
Python (3.4.3)
py
Runtime Error
18
3064
408
def groupby(a): a2=[[a[0],1]] for i in range(1,len(a)): if a2[-1][0]==a[i]: a2[-1][1]+=1 else: a2.append([a[i],1]) return a2 n=int(input()) s=input() t=groupby(s) c=s.count("(")-s.count(")") if c>0: s=s+c*")" else: s=(-c)*"("+s if t[0][0]==")": s=("("*t[0...
s440047093
p03696
u268554510
1575493321
Python
Python (3.4.3)
py
Runtime Error
17
3064
466
N=int(input()) S=input() sl=list(S) change=[0] for i in range(1,N): if (sl[i-1]==')')and(sl[i]=='('): change.append(i) change.append(N) r_add=0 l_add=0 for i in range(len(change)-1): A=sl[change[i]:change[i+1]] r=0 l=0 for a in A: if a=='(': l+=1 else: r+=1 if r==l: conti...
s903064565
p03696
u268554510
1575489935
Python
Python (3.4.3)
py
Runtime Error
18
3064
419
N=int(input()) S=input() sl=list(S) change=[0] ans='' for i in range(N+1): if (sl[i-1]==')')and(sl[i]=='('): change.append(i) change.append(N) for i in range(len(change)-1): A=sl[change[i]:change[i+1]] r=0 l=0 for a in A: if a=='(': l+=1 else: r+=1 if r==l: ans+=''.join(A...
s616574662
p03696
u266874640
1575168383
Python
Python (3.4.3)
py
Runtime Error
18
3064
541
import sys sys.setrecursionlimit(10**6) N = int(input()) edge = [[] for _ in range(N+1)] for _ in range(N-1): a,b,c = map(int,input().split()) edge[a].append((b,c)) edge[b].append((a,c)) Q,K = map(int,input().split()) distance = [None] * (N+1) def dfs(v1,d): distance[v1] = d for v2,dd in edge[v1]: ...
s185249462
p03696
u600195339
1575133244
Python
PyPy3 (2.4.0)
py
Runtime Error
168
38640
442
from collections import deque n = int(input()) s = input() lCnt = 0 rCnt = 0 stack = deque() stack.append(s[0]) for i in range(1, len(s)): prev = stack.pop() if prev == '(' and s[i] == ')': continue else: stack.append(prev) stack.append(s[i]) #print(stack) for i in range(len(sta...
s015786639
p03696
u708255304
1574872520
Python
Python (3.4.3)
py
Runtime Error
17
3064
478
N = int(input()) S = input() for i in reversed(range(N)): if S[i] == ")": tmp = i break left = "" for i in range(N-tmp-1): left += ")" migi_kakko = 0 hidari_kakko = 0 for i in range(tmp+1): if S[i] == ")": migi_kakko += 1 else: hidari_kakko += 1 right = "" for i in ran...
s695623364
p03696
u254871849
1574455135
Python
Python (3.4.3)
py
Runtime Error
17
3064
2032
import sys def main(): n, s = sys.stdin.read().split() n = int(n) for i in range(n): if s[i] == ')': continue else: i_l = i break for i in range(n, 0, -1): if s[i-1] == '(': continue else: i_r = i ...
s006345179
p03696
u625963200
1574078938
Python
Python (3.4.3)
py
Runtime Error
18
3192
649
n=int(input()) S=list(input()) i,cnt1=0,0 ins=[0]*(n+1) while i<len(S): if S[i]=='(': cnt1+=1 i+=1 else: j,cnt2=0,0 while i<len(S): if S[i]=='(': break else: cnt2+=1 i+=1 tmp='' if cnt2>cnt1: for _ in range(cnt2-cnt1): tmp+='(' in...
s780294657
p03696
u454524105
1573073198
Python
Python (3.4.3)
py
Runtime Error
18
3064
414
n = int(input()) s = str(input()) r = [i for i in range(n) if s[i] == "("] l = [i for i in range(n) if s[i] == ")"] if r == []: print(n*"(" + s) elif l == []: print(s + n*")") elif min(r) > max(l): print(len(l)*"(" + s + len(r)*")") else: cnt = 0 for i in reversed(range(len(r))): if r[i] < max(l): ...
s065745747
p03696
u454524105
1573072969
Python
Python (3.4.3)
py
Runtime Error
17
3064
342
n = int(input()) s = str(input()) r = [i for i in range(n) if s[i] == "("] l = [i for i in range(n) if s[i] == ")"] if min(r) > max(l): print(len(l)*"(" + s + len(r)*")") else: cnt = 0 for i in range(len(r)): if r[i] < max(l): cnt += 1 l.pop(-1) print((len(l)) * "(" + s +...
s773499333
p03696
u780962115
1572493161
Python
Python (3.4.3)
py
Runtime Error
17
3064
793
#insertion n=int(input()) s=input() count=1 countlist=[] s=s+"X" for i in range(n): if s[i]==s[i+1]: count+=1 else: if s[i]=="(": countlist.append((count,"L")) else: countlist.append((count,"R")) count=1 if len(countlist)%2==0 and countlist[0][1]=="L": ...
s561787911
p03696
u753803401
1571618146
Python
PyPy3 (2.4.0)
py
Runtime Error
178
38256
703
def slove(): import sys input = sys.stdin.readline n = int(input().rstrip('\n')) s = str(input().rstrip('\n')) t = s while True: l_len = len(s) while True s = s.replace("()", "") if len(s) == l_len: break else: l...
s299365648
p03696
u948524308
1569985328
Python
Python (3.4.3)
py
Runtime Error
17
3064
504
N=int(input()) S=input() temp=list(S) f=True while f: f=False L=len(temp) for i in range(L-2,-1,-1): if "".join(temp[i:i+2])=="()": temp.pop(i+1) temp.pop(i) f=True Ltemp=len(temp) if temp[0]=="(": add=")"*len(temp) ans=S+add else: cnt1=0 cnt2=...
s576840553
p03696
u921773161
1569711200
Python
Python (3.4.3)
py
Runtime Error
20
3064
472
#%% N = int(input()) S = list(input()) T = S.copy() flag = False #print(S) for i in range(N): flag = False i = 0 while True: if i > len(S) - 1: break if S[i] == '(': tmp = i flag = True if flag and S[i] == ')': S.pop(tmp) ...
s725266656
p03696
u672220554
1569435931
Python
Python (3.4.3)
py
Runtime Error
18
3064
303
n = int(input()) s = input() lcount = 0 rcount = 0 while s[lcount] == ")": lcount += 1 while s[n-1-rcount] == "(": rcount += 1 res = "(" * lcount + s + ")" * rcount l = s.count("(") r = s.count(")") if l > r: res = res + ")" * (l-r) elif r > l: res = "(" * (r-l) + res print(res)
s705488321
p03696
u155687575
1568397949
Python
Python (3.4.3)
py
Runtime Error
17
3064
450
n = int(input()) s = input() left = 0 leftplus = 0 for i in range(len(s)): if s[i] == '(': left += 1 else: if left == 0: leftplus += 1 else: left -= 1 right = 0 rightplus = 0 r = s[::-1] for i in range(len(reverse)): if r[i] == ')': right += 1 el...
s722047228
p03696
u865413330
1566780369
Python
Python (3.4.3)
py
Runtime Error
21
3316
321
from collections import deque N = int(input()) S = input() ans = deque(S) S += " " ind = 0 for _ in range(N): if S[ind] == "(" and S[ind+1] == ")": ind += 2 continue elif S[ind] == ")": ans.appendleft("(") elif S[ind] == "(": ans.append(")") ind += 1 print("".join(ans)...
s491070526
p03696
u865413330
1566780241
Python
Python (3.4.3)
py
Runtime Error
21
3316
315
from collections import deque N = int(input()) S = input() ans = deque(S) ind = 0 for _ in range(N-1): if S[ind] == "(" and S[ind+1] == ")": ind += 2 continue elif S[ind] == ")": ans.appendleft("(") elif S[ind] == "(": ans.append(")") ind += 1 print("".join(ans))
s948618966
p03696
u921773161
1566141525
Python
Python (3.4.3)
py
Runtime Error
18
3064
436
N = int(input()) S = list(input()) a = 0 b = 0 c = 0 d = 0 a = [i for i, x in enumerate(S) if x == '('][0] b = [i for i, x in enumerate(S) if x == ')'][-1] light_a = S[:b+1].count('(') light_b = S[:b+1].count(')') left_a = S[a:].count('(') legt_b = S[a:].count(')') #print(light_a, light_b, left_a, legt_b) c = max(0...
s909772774
p03696
u077291787
1565339162
Python
Python (3.4.3)
py
Runtime Error
18
3060
280
# ABC064D - Insertion def main(): # count shortages on both sides -> restore N = int(input()) S = input().rstrip() l, r = i.count("("), i.count(")") ans = "(" * max(0, r - l) + i + ")" * max(0, l - r) print(ans) if __name__ == "__main__": main()
s031579975
p03696
u665038048
1564369928
Python
Python (3.4.3)
py
Runtime Error
17
2940
163
n = int(input()) s - input() cnt = 0 m = 0 for i in s: if i == ')': cnt += 1 else: cnt -= 1 m = max(m, cnt) print('()'*m+s+')'*(m-cnt))
s311506170
p03696
u693953100
1563400617
Python
Python (3.4.3)
py
Runtime Error
18
3064
295
n = int(input()) s = input() t = s r = 0 l = 0 id=n-1 while t[id]=='(': r+=1 id-=1 t = t[:id+1] id = 0 while id<len(t) and t[id]==')': l+=1 id+=1 t = t[id:] if t.count('(')>t.count(')'): r+=t.count('(')-t.count(')') else: l+=t.count(')')-t.count('(') print('('*l+s+')'*r)
s722364612
p03696
u934868410
1559771408
Python
Python (3.4.3)
py
Runtime Error
17
2940
351
n = int(input()) s = input() num = 0 lmax = 0 rmax = 0 for i in range(n): if s[i] == ")": num += 1 else: num -= 1 if num == -1: lmax = max(lmax, num) num = 0 for i in range(n-1, -1, -1): if s[i] == "(": num += 1 else: num -= 1 rmax = max(rmax, num) ...
s612524988
p03696
u934868410
1559771111
Python
Python (3.4.3)
py
Runtime Error
17
2940
357
n = int(input()) s = input() num = 0 l = 0 r = 0 for i in range(n): if s[i] == ")": num += 1 else: num -= 1 if num == -1: l += 1 num = 0 num = 0 for i in range(n-1, 0, -1): if s[i] == "(": num += 1 else: num -= 1 if num == 01: r += 1 ...
s421950822
p03696
u143509139
1559659568
Python
Python (3.4.3)
py
Runtime Error
17
3064
205
n = int(input()) s = input() x = 0 xm = float('inf') for i in range(n): if s[i] == '(': x += 1 elif s[i] == ')': x -= 1 xm = min(xm, x) print('(' * -xm + s + ')' * (x - xm))
s652716558
p03696
u067729694
1558280929
Python
Python (3.4.3)
py
Runtime Error
18
3064
660
N = int(input()) S = input() pares = S[:] counter = 0 pares_num = [] for s in pares: if s == '(': counter += 1 pares_num.append(counter) else: counter -= 1 pares_num.append(counter) min_num = min(pares_num) if min_num < 0: pares = '(' * (-1*min_num) + pares c...
s173121980
p03696
u123756661
1553832645
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38384
386
n=int(input()) s=input() t=s[0] chk=0 d=[] for i in s: if i==")"==t: chk-=1 elif i=="("==t: chk+=1 else: d.append(chk) t=["(",")"][i==")"] chk=[1,-1][i==")"] d.append(chk) if d[0]<0: d=[0]+d if d[-1]>0: d.append(d[-1]*-1) p=sum(d) if p<0: ans[0]+=abs(p) if p>0: ans[-1...
s007614950
p03696
u690700473
1553606920
Python
Python (3.4.3)
py
Runtime Error
17
3064
538
def trim(S, N): a = 0 while S[a] == ")": a += 1 b = N-1 while S[b] == "(": b -= 1 return a, b def count(S, a, b): i = a c = 0 while i <= b: if S[i] == "(": c += 1 else: c -= 1 i += 1 return c N = int(input()) S = inp...
s054467144
p03696
u771876084
1552424360
Python
Python (3.4.3)
py
Runtime Error
19
2940
295
#coding:utf-8 N=input() S=raw_input() st=[] for s in S: if len(st) >= 1: a=st.pop() if a == '(' and s == ')': continue st.append(a) st.append(s) migi=0 hidari=0 for s in st: if s == ")":migi+=1 else: hidari+=1 print "("*migi + S + ")"*hidari
s337607984
p03696
u585482323
1552335029
Python
PyPy3 (2.4.0)
py
Runtime Error
185
38768
1802
#!usr/bin/env python3 from collections import defaultdict from heapq import heappush, heappop import sys import math import bisect import random def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, sys.stdin.readline().split())) def S(): ...
s079739012
p03696
u852038767
1550809876
Python
Python (3.4.3)
py
Runtime Error
17
3064
447
N = int(input()) S = list(input()) l_point = 0 left_first = S.index("(") for i in range(left_first, N): if S[i] == "(": l_point += 1 else: l_point -= 1 r_point = 0 T = S[::-1] right_first = T.index(")") for j in range(right_first, N): if T[j] == ")": r_point += 1 else: ...
s341765125
p03696
u812973725
1550094071
Python
Python (2.7.6)
py
Runtime Error
10
2568
250
N = input() S = raw_input() sample = [i for i in S] i = 0 while i < len(sample)-1: if sample[i] == '(' and sample[i+1] == ')': del sample[i],sample[i+1] i = 0 i += 1 S = '('*sample.count(')')+S+')'*sample.count('(') print S
s991105610
p03696
u738835924
1548281344
Python
Python (3.4.3)
py
Runtime Error
18
3064
366
N = int(input()) S = input() count = 0 for _ in range(N): if S[_] == ")": count += 1 else: index = _ break left = "(" * count count = 0 for _ in range(index, N): if S[_] == "(": count += 1 else: count -= 1 if count < 0: left += "(" * abs(count) right = "" else: ...
s857296565
p03696
u848647227
1541474902
Python
Python (3.4.3)
py
Runtime Error
19
3064
394
a = int(input()) ar = list(input()) b = 0 c = 0 t = 0 z = 0 while ar[t] == ")": if ar[t] == ")": z += 1 t += 1 for i in range(z): ar.insert(0,"(") for r in ar: if r == "(": b += 1 else: c += 1 if b > c: d = b - c for i in range(d): ar.append(")") else: d =...
s661515872
p03696
u232852711
1541269444
Python
Python (3.4.3)
py
Runtime Error
17
2940
236
n = int(input()) s = input() n_left = 0 ans = s for i in range(n): if s[i] == '(': n_left += 1 elif s[i] == ')': if n_left == 0: ans = '(' + ans else: n_left -= 1 for i in range(n_left): ans += ')' print(ans)
s789968511
p03696
u724892495
1541099217
Python
Python (3.4.3)
py
Runtime Error
18
3064
457
def insertion(S): Sc = S Scc = Sc.replace("()", "") while Scc != Sc: Sc = Scc Scc = Scc.replace("()", "") # Sc は ((((... or ))))... or ...))))((((... # print(Sc) if Sc[0] != Sc[-1]: pos = Sc.find(")(") S = insertion(S[:pos+1]) + insertion(S[pos+1:]) elif Sc[0...
s793648578
p03696
u505229551
1520923289
Python
Python (3.4.3)
py
Runtime Error
17
3064
403
N = int(input()) S = input() cnt = 0 max_neg = 0 left_add = 0 right_add = 0 for i in range(N): if S[i] == '(': cnt += 1 else: cnt -= 1 if cnt < 0: left_add = max(left_add, -cnt) for i in range(left_add): S.insert(0, '(') N += left_add cnt = 0 for i in range(N): if S[i]...