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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s620272760 | p03975 | u005260772 | 1525656940 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 124 | a, b, c = map(int, input().split())
ans = 0
for i in range(a):
n = int(input())
if n < b:
ans += 1
print ans |
s816724807 | p03975 | u283229916 | 1475858860 | Python | Python (2.7.6) | py | Runtime Error | 17 | 2580 | 153 | n=int(input())
a=int(input())
b=int(input())
cnt=0
for i in range(n):
t=int(input())
if t<a || b<=t:
cnt=cnt+1
print cnt
|
s214357330 | p03975 | u283229916 | 1475858800 | Python | Python (2.7.6) | py | Runtime Error | 17 | 2696 | 150 | n=int(input())
a=int(input())
b=int(input())
cnt=0
for i in range(n):
t=int(input())
if t<a or b<=t:
cnt+=1
print cnt
|
s934405161 | p03975 | u283229916 | 1475858732 | Python | Python (2.7.6) | py | Runtime Error | 17 | 2568 | 149 | n=int(input())
a=int(input())
b=int(input())
cnt=0
for i in range(n):
t=int(input())
if t<a or b<=t:
cnt++
print cnt
|
s121324722 | p03975 | u283229916 | 1475858665 | Python | Python (2.7.6) | py | Runtime Error | 17 | 2568 | 149 | n=int(input())
a=int(input())
b=int(input())
cnt=0
for i in range(n):
t=int(input())
if t<a || b<=t:
cnt++
print cnt
|
s521703902 | p03975 | u950384958 | 1475842668 | Python | Python (2.7.6) | py | Runtime Error | 256 | 18904 | 2619 | import numpy as np
H, W = map(int, raw_input().split())
S_list = list()
for i in range(H):
S_list.append(raw_input())
X_mat = np.zeros((H, W), dtype='int')
S_mat_extend = np.zeros((H+2, W+2), dtype='int')
# input
for h in range(H):
for w in range(W):
if S_list[h][w] == 'X':
X_mat[h, w] +=... |
s660264875 | p03975 | u352021237 | 1475827309 | Python | PyPy2 (5.6.0) | py | Runtime Error | 40 | 8944 | 227 | n,k=map(int,raw_input().split())
a=[0]*25
b=[]
count=0
for i in range(n):
b.append(raw_input())
b=list(set(b))
for i in b:
a[ord(i[0])-65]+=1
for i in a:
if i>0:
count+=i
if len(set(a))==2:
print 0
else:
print count/k |
s557971993 | p03975 | u830390742 | 1475593870 | Python | Python (2.7.6) | py | Runtime Error | 17 | 2808 | 249 | from collections import Counter
N, K = map(int, raw_input().split())
C = sorted(Counter(raw_input()[0] for _ in xrange(N)).values())
a = C.pop()
b = sum(C)
for i in xrange(a, 0, -1):
if b/i >= K-1:
print i
break
else:
print 0 |
s326924528 | p03975 | u765237551 | 1475429299 | Python | Python (3.4.3) | py | Runtime Error | 27 | 3316 | 311 | from collections import Counter
n, k = map(int, input().split())
ps = [input() for _ in range(n)]
heads = Counter((p[0] for p in ps))
ans = 0
while len(heads) >= k:
ans += 1
for h, c in heads.most_common()[:k]:
if c==1:
heads.pop(h)
else:
heads[h] -= 1
print(ans) |
s995794040 | p03975 | u725608977 | 1475428331 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2572 | 175 | N, A, B = map(int, raw_input().split())
#t_li = []
cnt = 0
for i in range(len(N)):
if A <= int(raw_input()) < B:
cnt +=1
# t_li.append(raw_input())
print N-cnt |
s482962584 | p03976 | u620480037 | 1597011634 | Python | PyPy3 (7.3.0) | py | Runtime Error | 114 | 76264 | 261 | N,K=map(int,input().split())
D={}
for i in range(N):
s=input()
if s[0] not in D:
D[s[0]]=1
else:
D[s[0]]+=1
#print(D)
MAX=0
for k,v in D.items():
if MAX < v:
MAX = v
#print(MAX)
NOTM = N - MAX
print(min(MAX,NOTM//(K-1))) |
s358563373 | p03976 | u145950990 | 1586314256 | Python | PyPy3 (2.4.0) | py | Runtime Error | 258 | 44632 | 323 | n,k = map(int,input().split())
p = [input()[0] for i in range(n)]
from collections import Counter
c = Counter(p)
v = list(c.values())
ans = 0
while len(v)>=k:
c = 0
while c<k and len(v)!=0:
if v[c]==0:
v.pop(c)
else:
v[c] -= 1
c+=1
if c==k:ans += 1
print(a... |
s277907603 | p03976 | u145950990 | 1586313974 | Python | PyPy3 (2.4.0) | py | Runtime Error | 262 | 43864 | 324 | n,k = map(int,input().split())
p = [input()[0] for i in range(n)]
from collections import Counter
c = Counter(p)
v = list(c.values())
ans = 0
while len(v)>=k:
c = 0
while c<3 and len(v)!=0:
if v[c]==0:
v.pop(c)
else:
v[c] -= 1
c+=1
if c==3:ans += 1
print(a... |
s720886690 | p03976 | u356832650 | 1505271286 | Python | Python (3.4.3) | py | Runtime Error | 78 | 3064 | 377 | N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
S = str(input())[0]
if S in d:
d[S] += 1
else:
d[S] = 1
p = list(d.values())
if len(p) < K:
print(0)
sys.exit()
c = 0
while(len(p) >= K):
c += 1
sq = sorted(p, reverse=True)
for i in range(K):
sq[i... |
s342951462 | p03976 | u356832650 | 1505186246 | Python | Python (3.4.3) | py | Runtime Error | 40 | 3060 | 264 | from heapq import heappush, heappop
import sys
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
S = str(input())[0]
if S in d:
d[S] += 1
else:
d[S] = 1
p = list(d.values())
if len(p) < K:
print(0)
sys.exit(1)
|
s303037442 | p03976 | u356832650 | 1505183981 | Python | Python (3.4.3) | py | Runtime Error | 37 | 3064 | 433 | from heapq import heappush, heappop
import sys
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
S = str(input())[0]
if S in d:
d[S] += 1
else:
d[S] = 1
p = list(d.values())
if len(p) < K:
print(0)
sys.exit(1)
h = []
for i in p:
heappush(h, i)
#while(len(h) > ... |
s064170117 | p03976 | u356832650 | 1505179730 | Python | Python (3.4.3) | py | Runtime Error | 36 | 3064 | 389 | from heapq import heappush, heappop
import sys
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
S = str(input())[0]
if S in d:
d[S] += 1
else:
d[S] = 1
p = list(d.values())
if len(p) < K:
print(0)
sys.exit(1)
h = []
for i in p:
heappush(h, i)
while(len(h) > K... |
s980835808 | p03976 | u356832650 | 1505179337 | Python | Python (3.4.3) | py | Runtime Error | 35 | 3188 | 407 | from heapq import heappush, heappop
import sys
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
S = str(input())[0]
if S in d:
d[S] += 1
else:
d[S] = 1
p = list(d.values())
if len(p) < K:
print(0)
sys.exit(1)
h = []
for i in p:
heappush(h, i)
while(len(h) > K... |
s754665906 | p03976 | u356832650 | 1505168778 | Python | Python (3.4.3) | py | Runtime Error | 36 | 3064 | 388 | from heapq import heappush, heappop
import sys
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
S = str(input())[0]
if S in d:
d[S] += 1
else:
d[S] = 1
p = list(d.values())
if len(p) < K:
print(0)
sys.exit(1)
h = []
for i in p:
heappush(h, i)
while(len(h) > K... |
s459818539 | p03976 | u356832650 | 1505168629 | Python | Python (3.4.3) | py | Runtime Error | 37 | 3064 | 389 | from heapq import heappush, heappop
import sys
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
S = str(input())[0]
if S in d:
d[S] += 1
else:
d[S] = 1
p = list(d.values())
if len(p) < K:
print(0)
sys.exit(1)
h = []
for i in p:
heappush(h, i)
while(len(h) > K... |
s473328368 | p03976 | u356832650 | 1505168512 | Python | Python (3.4.3) | py | Runtime Error | 35 | 3188 | 390 | from heapq import heappush, heappop
import sys
N,K = list(map(int, input().split(' ')))
d = {}
for i in range(N):
S = str(input())[0]
if S in d:
d[S] += 1
else:
d[S] = 1
p = list(d.values())
if len(p) < K:
print(0)
sys.exit(1)
h = []
for i in p:
heappush(h, i)
while(len(h) != ... |
s209405596 | p03976 | u296290704 | 1476466017 | Python | Python (2.7.6) | py | Runtime Error | 32 | 2948 | 180 | n,k=map(int,raw_input().split())
c=[0]*200
r=range(n)
for i in r:c[ord(raw_input()[0])]+=1
c.sort()
p=a=0
while p<1:
p=k;a+=1
for i in r:
if p*c[-i-1]:p-=1;c[-i-1]-=1
print a-1 |
s370431936 | p03976 | u805593120 | 1475825554 | Python | PyPy2 (5.6.0) | py | Runtime Error | 203 | 19868 | 430 | #!/usr/bin/python
from collections import defaultdict
from heapq import *
import sys
d=defaultdict(int)
n,k=map(int,sys.stdin.readline().split())
for _ in range(n):
s=sys.stdin.readline().strip()
d[s[0]]-=1
if len(d)<k:
print(0)
else:
q=[]
for khi in d:
heappush(q,[d[khi],khi])
r=0
while 1:
a=[heappop(q) for... |
s812637670 | p03976 | u805593120 | 1475824972 | Python | PyPy2 (5.6.0) | py | Runtime Error | 206 | 19868 | 430 | #!/usr/bin/python
from collections import defaultdict
from heapq import *
import sys
d=defaultdict(int)
n,k=map(int,sys.stdin.readline().split())
for _ in range(n):
s=sys.stdin.readline().strip()
d[s[0]]-=1
if len(d)<k:
print(0)
else:
q=[]
for khi in d:
heappush(q,[d[khi],khi])
r=0
while 1:
a=[heappop(q) for... |
s560463178 | p03976 | u732391415 | 1475429549 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 583 | n, k = map(lambda x: int(x), input().split())
p = []
for i in range(n):
p.append(input())
count = 0
while True:
if len(p) == 0:
break
head = []
dummy = p[:]
for item in dummy:
if not item[0] in head:
head.append(item[0])
... |
s970689352 | p03976 | u765237551 | 1475429135 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 312 | afrom collections import Counter
n, k = map(int, input().split())
ps = [input() for _ in range(n)]
heads = Counter((p[0] for p in ps))
ans = 0
while len(heads) >= k:
ans += 1
for h, c in heads.most_common()[:k]:
if c==1:
heads.pop(h)
else:
heads[h] -= 1
print(ans) |
s722725651 | p03979 | u844789719 | 1594800001 | Python | Python (3.8.2) | py | Runtime Error | 477 | 44920 | 874 | import sys
import itertools
from scipy.sparse import csr_matrix, lil_matrix
from scipy.sparse.csgraph import maximum_flow
H, W = map(int, sys.stdin.buffer.readline().split())
S = b''.join(sys.stdin.buffer.read().split())
source = 2 * H * W
sink = source + 1
INF = source * 2
graph = lil_matrix((sink + 1, sink + 1), ... |
s969996173 | p03979 | u844789719 | 1594799169 | Python | Python (3.8.2) | py | Runtime Error | 2211 | 164948 | 836 | import sys
import itertools
import networkx as nx
H, W = map(int, sys.stdin.buffer.readline().split())
S = b''.join(sys.stdin.buffer.read().split())
source = 2 * H * W
sink = source + 1
INF = 10**12
graph = nx.DiGraph()
graph.add_nodes_from(range(sink))
def add(start, end, cap):
graph.add_edge(start, end, capac... |
s411033106 | p03979 | u844789719 | 1594799078 | Python | Python (3.8.2) | py | Runtime Error | 2210 | 165408 | 849 | import sys
import itertools
import networkx as nx
H, W = map(int, sys.stdin.buffer.readline().split())
S = b''.join(sys.stdin.buffer.read().split())
source = 2 * H * W
sink = source + 1
INF = source * 2
graph = nx.DiGraph()
graph.add_nodes_from(range(sink))
for i in range(H * W):
x, y = divmod(i, W)
if S[i]... |
s518999936 | p03979 | u844789719 | 1594798744 | Python | Python (3.8.2) | py | Runtime Error | 2209 | 164692 | 815 | import sys
import itertools
import networkx as nx
H, W = map(int, sys.stdin.buffer.readline().split())
S = b''.join(sys.stdin.buffer.read().split())
source = 2 * H * W
sink = source + 1
INF = source * 2
graph = nx.DiGraph()
for i in range(H * W):
x, y = divmod(i, W)
if S[i] == ord('.'):
graph.add_ed... |
s391211627 | p03979 | u844789719 | 1594798625 | Python | Python (3.8.2) | py | Runtime Error | 2209 | 164628 | 809 | import sys
import itertools
import networkx as nx
H, W = map(int, sys.stdin.buffer.readline().split())
S = b''.join(sys.stdin.buffer.read().split())
source = 2 * H * W
sink = source + 1
INF = source * 2
graph = nx.DiGraph()
def add(start, end, cap):
graph.add_edge(start, end, capacity=cap)
for i in range(H *... |
s453241842 | p03979 | u844789719 | 1594798607 | Python | Python (3.8.2) | py | Runtime Error | 339 | 59188 | 775 | import sys
import itertools
import networkx as nx
H, W = [int(_) for _ in input().split()]
S = b''.join(sys.stdin.buffer.read().split())
source = 2 * H * W
sink = source + 1
INF = H * W * 3
graph = nx.DiGraph()
def add(start, end, cap):
graph.add_edge(start, end, capacity=cap)
for i in range(H * W):
x, y... |
s355286817 | p03979 | u844789719 | 1594798394 | Python | Python (3.8.2) | py | Runtime Error | 2209 | 164716 | 805 | import sys
import itertools
import networkx as nx
H, W = map(int, sys.stdin.buffer.readline().split())
S = b''.join(sys.stdin.buffer.read().split())
source = 2 * H * W
sink = source + 1
INF = 10**12
graph = nx.DiGraph()
def add(start, end, cap):
graph.add_edge(start, end, capacity=cap)
for i in range(H * W):... |
s018607820 | p03979 | u844789719 | 1594798372 | Python | Python (3.8.2) | py | Runtime Error | 341 | 58892 | 772 | import sys
import itertools
import networkx as nx
H, W = [int(_) for _ in input().split()]
S = b''.join(sys.stdin.buffer.read().split())
source = 2 * H * W
sink = source + 1
INF = 10**12
graph = nx.DiGraph()
def add(start, end, cap):
graph.add_edge(start, end, capacity=cap)
for i in range(H * W):
x, y = ... |
s069664262 | p03979 | u844789719 | 1594797574 | Python | Python (3.8.2) | py | Runtime Error | 2210 | 164820 | 803 | import sys
import itertools
import networkx as nx
H, W = map(int, sys.stdin.buffer.readline().split())
S = b''.join(sys.stdin.buffer.read().split())
source = 2 * H * W
sink = source + 1
INF = 10**12
graph = nx.DiGraph()
def add(start, end, cap):
graph.add_edge(start, end, capacity=cap)
for i in range(H * W):... |
s532351225 | p03979 | u844789719 | 1594797258 | Python | Python (3.8.2) | py | Runtime Error | 336 | 58896 | 791 | import sys
import itertools
import networkx as nx
H, W = [int(_) for _ in input().split()]
S = b''.join(sys.stdin.buffer.read().split())
source = 2 * H * W
sink = source + 1
INF = 10**12
graph = nx.DiGraph()
def add(start, end, cap):
graph.add_edge(start, end, capacity=cap)
for i in range(H * W):
x, y = ... |
s797154725 | p03979 | u950384958 | 1475967441 | Python | PyPy2 (5.6.0) | py | Runtime Error | 39 | 9200 | 4663 |
H, W = map(int, raw_input().split())
S_list = list()
for i in range(H):
S_list.append(raw_input())
# large_const
large_const = 100000
# X_mat = np.zeros((H, W), dtype='int')
X_mat = [[0]*W]*H
# input
for h in range(H):
for w in range(W):
if S_list[h][w] == 'X':
X_mat[h, w] += 1
# make g... |
s544191437 | p03979 | u950384958 | 1475966894 | Python | PyPy2 (5.6.0) | py | Runtime Error | 39 | 9072 | 4711 | import numpy as np
H, W = map(int, raw_input().split())
S_list = list()
for i in range(H):
S_list.append(raw_input())
# large_const
large_const = 100000
X_mat = np.zeros((H, W), dtype='int')
S_mat_extend = np.zeros((H+2, W+2), dtype='int')
# input
for h in range(H):
for w in range(W):
if S_list[h][w... |
s850564736 | p03979 | u950384958 | 1475649022 | Python | Python (2.7.6) | py | Runtime Error | 18 | 2948 | 2684 |
X_mat = np.zeros((H, W), dtype='int')
S_mat_extend = np.zeros((H+2, W+2), dtype='int')
# input
for h in range(H):
for w in range(W):
if S_list[h][w] == 'X':
X_mat[h, w] += 1
# make graph
G = dict()
def add_node(s, Graph=G):
Graph[s] = {'edges':dict()}
def add_edge(s, t, weight=1, Gra... |
s308192847 | p03986 | u023229441 | 1599891042 | Python | PyPy3 (7.3.0) | py | Runtime Error | 92 | 74900 | 131 | s=input() ; n=len(s)
for i in range(10000):
s=s.replace("ST","")
if a==s:
print(len(s));exit()
a=s
print(len(s))
|
s253091876 | p03986 | u375695365 | 1599615507 | Python | PyPy3 (7.3.0) | py | Runtime Error | 94 | 74576 | 175 | x=list(input())
s=0
t=0
ans=0
for i in range(len(x)):
if x[i]="S":
s+=1
else:
if s==0:
ans+=1
else:
s-=1
print(ans+s) |
s237478086 | p03986 | u375695365 | 1599615343 | Python | PyPy3 (7.3.0) | py | Runtime Error | 89 | 74564 | 179 | x=input()
x=list(x)
s=0
t=0
ans=0
for i in range(len(x)):
if x[i]="S":
s+=1
else:
if s==0:
ans+=1
else:
s-=1
print(ans+s) |
s730412279 | p03986 | u629454253 | 1598113502 | Python | PyPy3 (7.3.0) | py | Runtime Error | 445 | 314276 | 225 | X = input()
idx = 0
while idx < len(X):
print(idx, X)
if X[idx] == 'S':
if idx+1 < len(X) and X[idx+1] == 'T':
X = X[:idx] + X[idx+2:]
idx = max(-1, idx-2)
idx += 1
print(len(X)) |
s231587318 | p03986 | u062691227 | 1596920701 | Python | PyPy3 (7.3.0) | py | Runtime Error | 109 | 74736 | 207 | ans = 0
cnt_s = cnt_t = 0
for c in s:
if c == 'S':
cnt_s += 1
else:
cnt_t += 1
if cnt_t > cnt_s:
ans += cnt_s
cnt_s = cnt_t = 0
ans += cnt_s
print(len(s) - ans*2) |
s974952176 | p03986 | u871841829 | 1595656078 | Python | Python (3.8.2) | py | Runtime Error | 24 | 8920 | 171 | X = input()
cache = 0
ans = len(X)
for c in X:
if c == 'S'
cache += 1
else:
if cache > 0:
cache -= 1
ans -= 2
print(ans) |
s185198142 | p03986 | u747703115 | 1594688573 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9224 | 77 | X = input()
while X!=X_:
X_ = X
X = X.replace('ST', '')
print(len(X)) |
s459104289 | p03986 | u941438707 | 1594164780 | Python | Python (3.8.2) | py | Runtime Error | 69 | 10452 | 573 | x=input()
a=[1]
for i in range(1,len(x)):
if x[i]==x[i-1]:
a[-1]+=1
else:a+=[1]
ans=0
if x[0]=="T":
ans+=a.pop(0)
if x[-1]=="S":
ans+=a.pop(-1)
while len(a)>1:
a=[i-j for i,j in zip(a[::2],a[1::2]) if i!=j]
while a and a[0]<0:
ans+=abs(a.pop(0))
while a and a[-1]>0:
... |
s363244615 | p03986 | u941438707 | 1594164718 | Python | Python (3.8.2) | py | Runtime Error | 68 | 10616 | 572 | x=input()
a=[1]
for i in range(1,len(x)):
if x[i]==x[i-1]:
a[-1]+=1
else:a+=[1]
ans=0
if x[0]=="T":
ans+=a.pop(0)
if x[-1]=="S":
ans+=a.pop(-1)
while len(a)>1:
a=[i-j for i,j in zip(a[::2],a[1::2]) if i!=j]
while a and a[0]<0:
ans+=abs(a.pop(0))
while a and a[-1]>0:
... |
s672175138 | p03986 | u941438707 | 1594164117 | Python | Python (3.8.2) | py | Runtime Error | 72 | 10512 | 407 | x=input()
a=[1]
for i in range(1,len(x)):
if x[i]==x[i-1]:
a[-1]+=1
else:a+=[1]
ans=0
if x[0]=="T":
ans+=a.pop(0)
if x[-1]=="S":
ans+=a.pop(-1)
while len(a)>1:
a=[i-j for i,j in zip(a[::2],a[1::2]) if i!=j]
if a and a[0]<0:
ans-=a.pop(0)
if a and [-1]>0:
... |
s408886875 | p03986 | u941438707 | 1594163945 | Python | Python (3.8.2) | py | Runtime Error | 82 | 10288 | 449 | x=input()
a=[1]
for i in range(1,len(x)):
if x[i]==x[i-1]:
a[-1]+=1
else:a+=[1]
ans=0
if x[0]=="T":
ans+=a.pop(0)
if x[-1]=="S":
ans+=a.pop(-1)
while len(a)>1:
a=[a[i]-a[i+1] for i in range(0,len(a),2)]
a=[i for i in a if i!=0]
if a:
if a[0]<0:
ans-=a.pop... |
s520035829 | p03986 | u941438707 | 1594163869 | Python | Python (3.8.2) | py | Runtime Error | 83 | 10164 | 420 | x=input()
a=[1]
for i in range(1,len(x)):
if x[i]==x[i-1]:
a[-1]+=1
else:a+=[1]
ans=0
if x[0]=="T":
ans+=a.pop(0)
if x[-1]=="S":
ans+=a.pop(-1)
while len(a)>1:
a=[a[i]-a[i+1] for i in range(0,len(a),2)]
if a:
if a[0]<0:
ans-=a.pop(0)
if a:
if a[-1... |
s361070311 | p03986 | u941438707 | 1594163779 | Python | Python (3.8.2) | py | Runtime Error | 80 | 10392 | 412 | x=input()
a=[1]
for i in range(1,len(x)):
if x[i]==x[i-1]:
a[-1]+=1
else:a+=[1]
ans=0
if x[0]=="T":
ans+=a.pop(0)
if x[-1]=="S":
ans+=a.pop(-1)
while len(a)>1:
a=[a[i]-a[i+1] for i in range(0,len(a),2)]
if a:
if a[0]<0:
ans-=a.pop(0)
if a:
if a[-1... |
s665003904 | p03986 | u941438707 | 1594163607 | Python | Python (3.8.2) | py | Runtime Error | 80 | 10260 | 388 | x=input()
a=[1]
for i in range(1,len(x)):
if x[i]==x[i-1]:
a[-1]+=1
else:a+=[1]
ans=0
if x[0]=="T":
ans+=a.pop(0)
if x[-1]=="S":
ans+=a.pop(-1)
while len(a)>1:
a=[a[i]-a[i+1] for i in range(0,len(a),2)]
if a:
if a[0]<0:
ans-=a.pop(0)
if a:
if a[-1... |
s746581216 | p03986 | u941438707 | 1594163555 | Python | Python (3.8.2) | py | Runtime Error | 81 | 10316 | 364 | x=input()
a=[1]
for i in range(1,len(x)):
if x[i]==x[i-1]:
a[-1]+=1
else:a+=[1]
ans=0
if x[0]=="T":
ans+=a.pop(0)
if x[-1]=="S":
ans+=a.pop(-1)
while len(a)>1:
a=[a[i]-a[i+1] for i in range(0,len(a),2)]
if a and a[0]<0:
ans-=a.pop(0)
if a and a[-1]>0:
ans+=a.... |
s940777278 | p03986 | u594803920 | 1594124177 | Python | PyPy3 (7.3.0) | py | Runtime Error | 105 | 82092 | 156 | x = list(input())
cnt = 0
for i in x:
if x == 'S':
cnt += 1
elif y == 'T':
if cnt > 0:
cnt -= 1
else:
continue
print(len(x)-cnt) |
s721998750 | p03986 | u437215432 | 1593984426 | Python | PyPy2 (7.3.0) | py | Runtime Error | 331 | 86452 | 96 | # AGC005A
# TLE 2/13
x = input()
while 'ST' in x:
x = x.replace('ST', '', 1)
print(len(x))
|
s527386021 | p03986 | u793868662 | 1593314968 | Python | Python (3.8.2) | py | Runtime Error | 62 | 10516 | 411 | def resolve():
from collections import deque
x = input()
final = deque([])
final.append(x[0])
for i in range(1, len(x)):
if x[i] == "S":
final.append("S")
else:
last = final.pop()
if last == "S":
continue
else:
... |
s079101559 | p03986 | u780475861 | 1591916671 | Python | Python (3.4.3) | py | Runtime Error | 72 | 4992 | 161 | x = input()
res = [x[0]]
for i in x[1:]:
if i == 'S':
res += [i]
else:
if res[-1] == 'S':
res.pop()
else:
res += [i]
print(len(res))
|
s060375222 | p03986 | u923270446 | 1591487451 | Python | Python (3.4.3) | py | Runtime Error | 43 | 3500 | 96 | x=input()
s,a=0,0
for i in x:
if i=="S":
s+=1
elif s==0:
ans+=1
else:
s-=1
print(ans+s) |
s230499317 | p03986 | u897328029 | 1589751704 | Python | Python (3.4.3) | py | Runtime Error | 164 | 150120 | 1671 | #!/usr/bin/env python3
X = input()
N = len(X)
after_x = ""
next_i = 0
# 連続する箇所で部分文字列を作りたい
if X[0] == "T":
# Tから始まる場合、最初の連続するTは確定で残る
for i, x in enumerate(X):
if x == "T":
after_x += x
else:
break
next_i = i
if next_i < N - 1:
# 残りの文字列について操作する(最初のTは処理したので、必ずSから始ま... |
s024182117 | p03986 | u223504018 | 1588812082 | Python | PyPy3 (2.4.0) | py | Runtime Error | 167 | 38384 | 313 | #include <bits/stdc++.h>
using namespace std;
int main(){
string x;cin>>x;
int i=0;
int k=x.size();
while(i<k){
if(i>=0&&i<k-1){
if(x.substr(i,2)=="ST"){
x.replace(i,2,"");
i=i-2;
k=x.size();
}
}
i++;
}
cout<<x.size()<<endl;
} |
s906872095 | p03986 | u026788530 | 1588691976 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 124 | s=input()
c=0
ans=0
for i in range(len(s)):
if s[i]=='T':
c+=1
if s[i]='S':
c-=1
ans = max(ans,c)
print(ans*2) |
s215998805 | p03986 | u026788530 | 1588691951 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 119 | s=input()
c=0
ans=0
for i in range(n):
if s[i]=='T':
c+=1
if s[i]='S':
c-=1
ans = max(ans,c)
print(ans*2) |
s886277453 | p03986 | u345966487 | 1587119801 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3500 | 88 | X=input()
t,s=0,0
for x in X:
if x=='S':ns+=1
elif ns>0:ns-=1
else:nt+=1
print(nt+ns) |
s111676506 | p03986 | u345966487 | 1587116177 | Python | PyPy3 (2.4.0) | py | Runtime Error | 1058 | 61552 | 391 | import sys
X = list(sys.stdin.readline().strip())
N = len(X)
def solve():
cnt = 0
i = 0
while True:
while i < N and X[i] != 'S':
i += 1
j = i + 1
while j < N and X[j] != 'T':
j += 1
if j == N:
return N - 2*cnt
cnt += 1
X[i]... |
s453951949 | p03986 | u102242691 | 1586142637 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 305 | X = input()
ans = []
for x in X:
if x == "S":
ans.append(x)
else:
if len(ans) != 0:
if ans [-1] == "S":
ans.pop()
else:
ans.append(x)
else:
ans.append(x)
print(len(ans))
|
s754170333 | p03986 | u521518741 | 1585830169 | Python | PyPy3 (2.4.0) | py | Runtime Error | 175 | 38384 | 247 | X = input()
stack = []
for s in X:
if not stack:
stack.append(s)
continue
if s == 'T' and stack[-1] == 'S':
stack.pop()
else:
stack.append(s)
print(len(stack)) |
s835449664 | p03986 | u521518741 | 1585829849 | Python | PyPy3 (2.4.0) | py | Runtime Error | 165 | 38256 | 180 | X = input()
stack = []
for s in X:
if not stack:
stack.append(s)
continue
if s == 'T' and stack[-1] == 'S':
stack.pop()
else:
stack.append(s)
print(len(stack)) |
s670062610 | p03986 | u521518741 | 1585829775 | Python | PyPy3 (2.4.0) | py | Runtime Error | 173 | 38468 | 152 | X = input()
stack = []
for s in X:
if not stack:
stack.append(s)
continue
if s == 'T' and stack[-1] == 'S':
stack.pop()
print(len(stack)) |
s747639117 | p03986 | u152891327 | 1584815633 | Python | Python (3.4.3) | py | Runtime Error | 1056 | 3804 | 292 | X = input()
mLoop = 10 ** 1000
i = 0
while i < mLoop:
p = X.find('ST')
if p == -1:
break
q = p + 2
p -= 1
while p >= 0 and i < mLoop:
if not(X[p] == 'S' and X[q] == 'T'):
break
p -= 1
q += 1
i += 1
X = ''.join([X[:p + 1],X[q:]])
i += 1
print(len(X)) |
s350283125 | p03986 | u287500079 | 1583755246 | Python | Python (3.4.3) | py | Runtime Error | 39 | 5716 | 1183 | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_upper... |
s130332102 | p03986 | u287500079 | 1583754983 | Python | Python (3.4.3) | py | Runtime Error | 39 | 5712 | 1114 | import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_upper... |
s953439580 | p03986 | u835924161 | 1583739390 | Python | Python (3.4.3) | py | Runtime Error | 96 | 4328 | 331 | s=str(input())
co=int(1)
n=len(s)
A=[]
for i in range(1,n):
if s[i]!=s[i-1]:
A.append(co)
co=1
else:
co+=1
A.append(co)
m=len(A)
how=0
if s[0]=='T':
how=1
for i in range(how,m-how):
if i%2!=how:
continue
if A[i]<A[i+1]:
n-=2*A[i]
else:
n-=2*A[i+1... |
s715532970 | p03986 | u287500079 | 1582397023 | Python | Python (3.4.3) | py | Runtime Error | 107 | 4328 | 299 | x = str(input())
n = len(x)
stack = []
for i in range(n):
if x[i] == 'S':
stack.append('S')
elif x[i] == 'T' and (len(stack) == 0 or stack[len(stack) - 1]) == 'T':
stack.append('T')
elif x[i] == 'T' and stack[len(stack) - 1] == 'S':
stack.pop()
print(len(stack))
|
s242239370 | p03986 | u561231954 | 1581178909 | Python | Python (3.4.3) | py | Runtime Error | 61 | 6204 | 198 | x=list(input())
n=len(x)
stack=[x[0]]
for i in range(1,n):
if x[i]=='S':
stack.append('S')
else:
if stack[-1]=='S':
stack.pop()
else:
stack.append('T')
print(len(stack)) |
s909635895 | p03986 | u513434790 | 1579561934 | Python | Python (3.4.3) | py | Runtime Error | 88 | 13928 | 201 | from itertools import groupby
x = [[i,len(list(j))] for i,j in groupby(input())]
ans = []
if x[0][0] == "T":
ans.append(x[0][1])
if x[-1][0] == "S":
ans.append(x[-1][1])
print(max(ans)*2) |
s658962144 | p03986 | u472216275 | 1579459942 | Python | PyPy3 (2.4.0) | py | Runtime Error | 163 | 38256 | 199 | s_list = list(input())
seizon_t = 0
s_amari = 0
for char in s_list:
if char == "T":
if s_amari == 0:
seizon_t += 1:
else:
s_amari -= 1
else:
s_amari += 1
print(2*seizon_t) |
s354479051 | p03986 | u838644735 | 1579395730 | Python | PyPy3 (2.4.0) | py | Runtime Error | 184 | 47840 | 258 | from collections import deque
X = input()
ret = deque([X[0]])
for i in range(1, len(X)):
x = X[i]
if x == 'S':
ret.append(x)
else:
if ret[-1] == 'S':
ret.pop()
else:
ret.append(x)
print(len(ret))
|
s964203029 | p03986 | u317713173 | 1577453623 | Python | Python (3.4.3) | py | Runtime Error | 80 | 3500 | 135 | x = input()
s = t = 0
for i in range(200000):
if x[i] == "T":
t += 1
if x[-i-1] == "S":
s += 1
print(max(s, t)) |
s225259923 | p03986 | u317713173 | 1577453531 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 133 | x = input()
s = t = 0
for i in range(200000):
if x[i] = "T":
t += 1
if x[-i-1] = "S":
s += 1
print(max(s, t)) |
s156593474 | p03986 | u317713173 | 1577453474 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 124 | x = input()
for i in range(200000):
if x[i] = "T":
t += 1
if x[-i-1] = "S":
s += 1
print(max(s, t)) |
s409276312 | p03986 | u557494880 | 1576709049 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3500 | 311 | S = input()
n = len(S)
ans = 0
s = 0
t = 0
for i in range(N):
x = S[i]
if x == 'S':
s += 1
if t > 0:
if s > t:
s -= t
else:
t = t-s
ans += t
s = 0
else:
t += 1
ans += s
print(ans) |
s458345328 | p03986 | u593934357 | 1576365864 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 367 | x = input()
i = len(x)
cnt = 0
while True:
if cnt >
p = x.find('ST')
if p != -1:
cnt += 1
else:
break
n = p
while True:
if len(x) -1 > 0:
if x[n-1] == 'S':
cnt += 1
n -= 1
else:
... |
s230478774 | p03986 | u673361376 | 1576207899 | Python | PyPy3 (2.4.0) | py | Runtime Error | 198 | 51292 | 304 | def sol():
ti = 0
ans = lenX
for i in range(lenX//2):
while S[i]>=T[ti]:
ti += 1
if ti>=lenX//2:
return ans
ans -= 2
ti += 1
return ans
X = input()
lenX = len(X)
S = []
T = []
for i,x in enumerate(X):
if x == 'S':S.append(i)
else:T.append(i)
print(sol()) |
s482391659 | p03986 | u374802266 | 1575886825 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3500 | 162 | s=input()
a,b,n=0,0,len(s)
for i in range(n):
if s[i]==T:
if a==0:
b+=1
else:
a-=1
else:
a+=1
print(n-2*a) |
s487938127 | p03986 | u826771152 | 1575567641 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 130 | x = "TSTSTSTS"
n = 0
filter = [n:n+1]
for i in range(10**1000):
if x[i:i+1] == "ST":
x.pop(i)
x.pop(i+1)
print(len(x)) |
s296237086 | p03986 | u905203728 | 1575063614 | Python | Python (3.4.3) | py | Runtime Error | 147 | 6308 | 325 | s=list(input())
word,cnt=s[0],0
n=len(s)
S=""
for i in range(n):
if word!=s[i]:
S +=word+str(cnt)
cnt=1
word=s[i]
else:
cnt +=1
S +=word+str(cnt)
S +="G"
S=list(S)
cnt=0
for i in range(0,len(S)-1,2):
if S[i]+S[i+2]=="ST":
cnt +=(min(int(S[i+1]),int(S[i+3])))*2
print(n... |
s835456732 | p03986 | u094191970 | 1574309957 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3500 | 81 | h,w=map(int,input().split())
for i in range(h):
s=input()
print(s+'\n'+s) |
s411131979 | p03986 | u256464928 | 1569466633 | Python | Python (3.4.3) | py | Runtime Error | 1056 | 4840 | 237 | S = list(input())
cnt = len(S)
while len(S) > 0:
i = 0
while i < len(S)-1:
if S[i] == "S" and S[i+1] == "T":
S.pop(i)
S.pop(i+1)
i += 1
if cnt == len(S):
print(len(S))
exit()
cnt = len(S)
print(len(S)) |
s335802274 | p03986 | u948524308 | 1569279441 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3500 | 107 | X=input()
S=0
for i in range(L):
if X[-(1+i)]=="S":
S+=1
else:
break
print(2*S)
|
s799756285 | p03986 | u993622994 | 1568127857 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3500 | 118 | X = input()
for j in range(len(X//2)):
X = X.replace('ST', '')
if 'ST' not in X:
break
print(len(X)) |
s903248441 | p03986 | u993622994 | 1568127804 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3500 | 113 | X = input()
for j in range(X//2):
X = X.replace('ST', '')
if 'ST' not in X:
break
print(len(X)) |
s000942539 | p03986 | u814986259 | 1567213129 | Python | Python (3.4.3) | py | Runtime Error | 22 | 6304 | 263 | X = input()
X = list(X)
prev = ""
for i in range(len(X) - 1):
if X[i] + X[i + 1] == "ST":
a = X.pop(i + 1)
b = X.pop(i)
X = [b,a].extend(X)
for i in range(0, len(X)):
if X[len(X) - (i+1)] == "T":
print(i * 2)
break |
s295609109 | p03986 | u703890795 | 1567069354 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 106 | X = input()
l = len(X)
while(True):
l = len(X)
X.replace("ST", "")
if l = len(X):
break
print(X) |
s461492079 | p03986 | u007550226 | 1566594380 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 259 | #include<iostream>
#include<algorithm>
using namespace std;
int main() {
string s;
cin >> s;
int k=0,sn;
for (auto c:s) {
if (c=='S') {++sn;}
else {if (sn>0){--sn;k+=2;}}
}
cout << s.length()-k << endl;
return 0;
} |
s087133213 | p03986 | u532966492 | 1563026549 | Python | Python (3.4.3) | py | Runtime Error | 30 | 3560 | 217 | s=input()
l=s.find("S")
r=s.rfind("T")
if l==-1 or r==-1:
print(len(s))
else:
rest=l+len(s)-r-1
s=s[l:r+1]
from collections import Counter
s=list(Counter(s).values())
print(rest+abs(s[0]-s[1])) |
s039045934 | p03986 | u942915776 | 1562879044 | Python | Python (3.4.3) | py | Runtime Error | 76 | 4252 | 252 | x = input()
ans = len(x)
def do(i, j):
global ans
if x[i] == 'S' and x[j] == 'T':
ans -= 2
if i > 0 and j < len(x) - 1:
do(i-1, j+1)
if j - i == 1 and j < len(x) - 1:
do(i+1, j+1)
do(0, 1)
print(ans)
|
s803491766 | p03986 | u671252250 | 1562771361 | Python | Python (3.4.3) | py | Runtime Error | 58 | 5668 | 272 | # coding: utf-8
# Your code here!
X = list(input())
num = len(X)
stack = []
for i in X:
if i == "S":
stack.append(i)
else:
if stack[-1] == "T" or stack[0] == "":
stack.append(i)
else:
stack.pop()
print(len(stack))
|
s092025403 | p03986 | u671252250 | 1562770965 | Python | Python (3.4.3) | py | Runtime Error | 71 | 6200 | 297 | # coding: utf-8
# Your code here!
X = list(input())
num = len(X)
stack = [X[0]]
for i in range(1, num):
if X[i] == "S":
stack.append("S")
else:
if stack[-1] == "T" or stack[0] == "":
stack.append("T")
else:
stack.pop(-1)
print(len(stack))
|
s833247009 | p03986 | u026155812 | 1562300695 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3500 | 177 | s = input()
cnt = 0
cnt_set = 0
for x in S:
if x == 'S':
cnt += 1
else:
if cnt > 0:
cnt_set += 1
cnt -= 1
print(len(s)-2*cnt_set) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.