s_id string | p_id string | u_id string | date string | language string | original_language string | filename_ext string | status string | cpu_time string | memory string | code_size string | code string | error string | stdout string |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s822774265 | p01554 | u922450532 | 1529210998 | Python | Python3 | py | Runtime Error | 0 | 0 | 627 | while True:
a = input()
# if a == "0 0 0 0 0":
# break
a = a.split(" ")
b = []
sum = 0
for i in a:
b.append(int(i))
sum += int(i)
if sum == 0:
break
c = input()
c = c.split(" ")
d = []
for i in c:
d.append(int(i))
if b[4] == d[0]:
print(0)
continue
ans = 0
x = b[4]
for i in d:
for e in range(10001):
x = (b[1] * x + b[2]) % b[3]
print("x: " ,x)
ans = ans + 1
if x == i:
break
if ans >= 10001:
ans = -1
print(ans)
quit()
| Traceback (most recent call last):
File "/tmp/tmp9fe2b0v4/tmpt6yz2dgn.py", line 3, in <module>
a = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s525095709 | p01558 | u352394527 | 1546325674 | Python | Python3 | py | Runtime Error | 1940 | 404800 | 346 | def main():
n, m = map(int, input().split())
s = input()
left = right = 0
mem = set()
for _ in range(m):
com = input()
if com == "L++":
left += 1
elif com == "L--":
left -= 1
elif com == "R++":
right += 1
elif com == "R--":
right -= 1
mem.add(s[left:right + 1])
print(len(mem))
main()
| Traceback (most recent call last):
File "/tmp/tmpstojmntq/tmphmi_9c09.py", line 19, in <module>
main()
File "/tmp/tmpstojmntq/tmphmi_9c09.py", line 2, in main
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s251949316 | p01564 | u116766943 | 1422522709 | Python | Python3 | py | Runtime Error | 0 | 0 | 13788 | /*
まだ途中セーヴ
ci is ignored for output queries.
このインプットは無視しろってこと?kamo
*/
#include<bits/stdc++.h>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
typedef long long ll;
// -- segment tree with lazy propagation ---
const int IINF = INT_MAX;
const char EMPTY = 'X';
struct Node{
ll value,left,right,maxi;
char lazy;
ll lazy_coef;
Node(ll value=0,ll left=-INT_MAX,ll right=-INT_MAX,ll maxi=-INT_MAX,char lazy=EMPTY,ll lazy_coef=0):value(value),left(left),right(right),maxi(maxi),lazy(lazy),lazy_coef(lazy_coef){}
};
class SegmentTree{
public:
vector<Node> RMQ;
int limit,N; // N は要素数
void init(int tmp){
N = tmp;
int N_N = 1;
while(N_N < N)N_N *= 2;
limit = N_N;
RMQ.resize(3*limit);
rep(i,3*limit-1) RMQ[i] = Node();
}
Node _build(int cur,int L,int R,const vector<int> &buf){
if( !( 0 <= cur && cur < 2*limit-1 ) ) return Node();
if( L == R-1 ){
if( L >= N ) return Node();
RMQ[cur].value = buf[L];
RMQ[cur].left = buf[L];
RMQ[cur].right = buf[L];
RMQ[cur].maxi = buf[L];
} else {
Node vl = _build(cur*2+1,L,(L+R)/2,buf);
Node vr = _build(cur*2+2,(L+R)/2,R,buf);
RMQ[cur].value = vl.value + vr.value;
RMQ[cur].left = max(vl.left,vl.value+vr.left);
RMQ[cur].right = max(vr.right,vr.value+vl.right);
RMQ[cur].maxi = max(vl.maxi,max(vr.maxi,vl.right+vr.left));
}
return RMQ[cur];
}
void build(const vector<int> &buf) { _build(0,0,limit,buf); }
inline void value_evaluate(int index,int L,int R){
if( RMQ[index].lazy == 'S' ){
RMQ[index].value = ( R - L ) * RMQ[index].lazy_coef;
RMQ[index].left = max(RMQ[index].lazy_coef,(R-L)*RMQ[index].lazy_coef);
RMQ[index].right = max(RMQ[index].lazy_coef,(R-L)*RMQ[index].lazy_coef);
RMQ[index].maxi = max(RMQ[index].lazy_coef,(R-L)*RMQ[index].lazy_coef);
}
}
inline void lazy_evaluate(int index,int L,int R){
value_evaluate(index,L,R);
if( index < limit && RMQ[index].lazy != EMPTY ) {
if( RMQ[index].lazy == 'S') {
RMQ[index*2+1].lazy = RMQ[index*2+2].lazy = 'S';
RMQ[index*2+1].lazy_coef = RMQ[index].lazy_coef;
RMQ[index*2+2].lazy_coef = RMQ[index].lazy_coef;
}
}
RMQ[index].lazy = EMPTY;
RMQ[index].lazy_coef = 0;
}
inline void value_update(int index){
RMQ[index].value = RMQ[index*2+1].value + RMQ[index*2+2].value;
RMQ[index].left = max(RMQ[index*2+1].left,RMQ[index*2+1].value+RMQ[index*2+2].left);
RMQ[index].right = max(RMQ[index*2+2].right,RMQ[index*2+2].value+RMQ[index*2+1].right);
RMQ[index].maxi = max(RMQ[index*2+1].maxi,max(RMQ[index*2+2].maxi,RMQ[index*2+1].right+RMQ[index*2+2].left));
}
void _update(int a,int b,char opr,ll v,int index,int L,int R){
lazy_evaluate(index,L,R);
if( b <= L || R <= a )return;
if( a <= L && R <= b ){
RMQ[index].lazy = opr;
if( opr == 'S' ) RMQ[index].lazy_coef = v;
lazy_evaluate(index,L,R);
return;
}
_update(a,b,opr,v,index*2+1,L,(L+R)/2);
_update(a,b,opr,v,index*2+2,(L+R)/2,R);
value_update(index);
}
void update(int a,int b,char opr,ll v){ _update(a,b,opr,v,0,0,limit); }
Node _query(int a,int b,int index,int L,int R){
lazy_evaluate(index,L,R);
if( b <= L || R <= a ) return Node();
if( a <= L && R <= b ) return RMQ[index];
Node tmp1 = _query(a,b,index*2+1,L,(L+R)/2);
Node tmp2 = _query(a,b,index*2+2,(L+R)/2,R);
Node ret = Node();
ret.value = tmp1.value + tmp2.value;
ret.left = max(tmp1.left,tmp1.value+tmp2.left);
ret.right = max(tmp2.right,tmp2.value+tmp1.right);
ret.maxi = max(tmp1.maxi,max(tmp2.maxi,tmp1.right+tmp2.left));
value_update(index);
return ret;
}
Node query(int a,int b) { return _query(a,b,0,0,limit); }
};
// -- segment tree with lazy propagation ---
const int MAX_V = 201000;
struct Edge { int to,weight;};
int V;
vector<Edge> G[MAX_V];
vector<int> costs;
typedef pair<int,int> ii;
//RMQ LCA ------------------------------- begin
class LCA_RMQ{
private:
int limit,N;
vector<ii> dat;
public:
void init(int n_){
N = n_;
dat.clear();
limit = 1;
while(limit<n_)limit*=2;
dat.resize(2*limit);
for(int i=0;i<2*limit-1;i++) dat[i] = ii(IINF,IINF);//ii(depth,index)
}
ii _build(int cur,int L,int R,const vector<ii> &buf){
if( !( 0 <= cur && cur < 2*limit ) ) return ii(IINF,IINF);
if( L == R-1 ) {
if( L >= N ) return ii(IINF,IINF);
dat[cur] = buf[L];
} else {
ii vl = _build(cur*2+1,L,(L+R)/2,buf);
ii vr = _build(cur*2+2,(L+R)/2,R,buf);
dat[cur] = min(vl,vr);
}
return dat[cur];
}
void build(const vector<ii> &buf){ _build(0,0,limit,buf); };
// k番めの値(0-indexed)をaに変更
void update(int k,ii a){
k += limit-1;
dat[k] = a;
while(k > 0){
k = (k-1)/2;
dat[k] = (dat[k*2+1].first>dat[k*2+2].first?dat[k*2+2]:dat[k*2+1]);
}
}
ii _query(int a,int b,int k,int l,int r){
if(r<=a || b<=l)return ii(IINF,-1);
else if(a<=l && r<=b)return dat[k];
ii vl = _query(a,b,k*2+1,l,(l+r)/2);
ii vr = _query(a,b,k*2+2,(l+r)/2,r);
return min(vl,vr);
}
ii query(int a,int b){ return _query(a,b,0,0,limit); }
};
int root;
vector<int> id,vs,depth;
void LCA_dfs(int v,int p,int d,int &k){
id[v] = k;
vs[k] = v;
depth[k++] = d;
for(int i=0;i<(int)G[v].size();i++){
if(G[v][i].to != p){
LCA_dfs(G[v][i].to,v,d+1,k);
vs[k] = v;
depth[k++] = d;
}
}
}
void LCA_init(int V,LCA_RMQ &rmq){
root = 0;
vs.clear();
vs.resize(V*2,0);
depth.clear();
depth.resize(V*2,0);
id.clear();
id.resize(V);
int k = 0;
LCA_dfs(root,-1,0,k);
rmq.init(k+1);
vector<ii> tmp;
rep(i,k) tmp.push_back(ii(depth[i],vs[i]));
rmq.build(tmp);
}
int lca(int u,int v,LCA_RMQ &rmq){ return rmq.query(min(id[u],id[v]),max(id[u],id[v])+1).second; }
//RMQ LCA ------------------------------- end
// Heavy Light Decomposition - begin
int chainNumber;
vector<int> subsize,chainID,headID,baseArray,posInBase,parent;
void HLD_dfs(int cur,int prev){
parent[cur] = prev;
rep(i,(int)G[cur].size()){
int to = G[cur][i].to;
if( to == prev ) continue;
HLD_dfs(to,cur);
subsize[cur] += subsize[to];
}
}
void HLD(int cur,int prev,int &ptr){
if( headID[chainNumber] == -1 ) headID[chainNumber] = cur;
chainID[cur] = chainNumber;
baseArray[ptr] = costs[cur];
posInBase[cur] = ptr++;
int maxi = -1;
rep(i,(int)G[cur].size()) {
int to = G[cur][i].to;
if( to == prev ) continue;
if( maxi == -1 || subsize[to] > subsize[maxi] ) maxi = to;
}
if( maxi != -1 ) HLD(maxi,cur,ptr);
rep(i,(int)G[cur].size()){
int to = G[cur][i].to;
if( to == prev || to == maxi ) continue;
++chainNumber;
HLD(to,cur,ptr);
}
}
void HLD_init(){
chainNumber = 0;
subsize.clear();
chainID.clear();
headID.clear();
baseArray.clear();
posInBase.clear();
parent.clear();
subsize.resize(V,1);
chainID.resize(V,-1);
headID.resize(V,-1);
baseArray.resize(V,-IINF);
posInBase.resize(V,-1);
parent.resize(V,-1);
HLD_dfs(0,-1);
int ptr = 0;
HLD(0,-1,ptr);
}
// Heavy Light Decomposition - end
ll LLINF = LLONG_MAX;
bool DEBUG = false;
void print(Node a){
puts("---");
cout << "sum = " << a.value << endl;
cout << "left = " << a.left << endl;
cout << "right = " << a.right << endl;
cout << "maxi = " << a.maxi << endl;
}
ll special;
Node _Query(int s,int t,SegmentTree &seg,int f){
if( !f && s == t ) {
int ps = posInBase[s], pt = posInBase[t];
if( ps > pt ) swap(ps,pt);
Node node = seg.query(ps,pt+1);
if( t == pt ) special = node.right;
else special = node.left;
return node;
}
if( f && s == t ) {
special = 0;
return Node();
}
int chain_s,chain_t=chainID[t];
Node ret = Node();
while(1){
chain_s = chainID[s];
if( chain_s == chain_t ) {
int ps = posInBase[s], pt = posInBase[t];
int t_pos = pt;
if( f && s == t ) {
return ret;
}
if( ps > pt ) swap(ps,pt);
if( f && t_pos == pt ) --pt;
if( f && t_pos == ps ) ++ps;
if( ps > pt ) swap(ps,pt);
Node temp = seg.query(ps,pt+1);
/*
if( DEBUG ){
cout << "$$$$$$$$$$$$$$$" << endl;
print(temp);
print(ret);
cout << "XXXXXXXXXXXXXXX" << endl;
}
*/
/*
if( t_pos == pt ) {
swap(ret.left,ret.right);
} else {
swap(temp.left,temp.right);
}
*/
ret.maxi = max(ret.maxi,max(temp.maxi,ret.right+temp.left));
ret.left = max(ret.left,ret.value+temp.left);
ret.right = max(temp.right,temp.value+ret.right);
ret.value += temp.value;
if( t_pos == pt ) {
special = ret.left;
} else {
special = ret.right;
}
/*
if( DEBUG ) {
cout << "!!!!!!!!!!" << endl;
print(ret);
cout << "??????????" << endl;
}
*/
return ret;
} else {
int head = headID[chain_s];
int ps = posInBase[s], ph = posInBase[head];
Node temp = seg.query(min(ps,ph),max(ps,ph)+1);
ret.maxi = max(ret.maxi,max(temp.maxi,ret.right+temp.left));
ret.left = max(ret.left,ret.value+temp.left);
ret.right = max(temp.right,temp.value+ret.right);
ret.value += temp.value;
if( f && parent[head] == t ) {
if( ps < ph ) special = ret.right;
else special = ret.left;
}
s = parent[head];
}
}
return ret;
}
ll Query(int s,int t,SegmentTree &seg,LCA_RMQ &lca_rmq){
if( s == t ) {
int ps = posInBase[s], pt = posInBase[t];
if( ps > pt ) swap(ps,pt);
return seg.query(ps,pt+1).maxi;
}
int ancestor = lca(s,t,lca_rmq);
ll temp_maxi = 0;
DEBUG = true;
Node a = _Query(s,ancestor,seg,0);
DEBUG = false;
temp_maxi += special;
Node b = _Query(t,ancestor,seg,1);
temp_maxi += special;
/*
cout << "[" << s << "," << ancestor << "," << t << "]" << endl;
cout << posInBase[s] << " and " << posInBase[t] << endl;
cout << "special = " << special << endl;
print(a);
print(b);
puts("");
*/
return max(a.maxi,max(b.maxi,temp_maxi));
/*
int ps = posInBase[s], pt = posInBase[t], pa = posInBase[ancestor];
if( ps <= pa && pa <= pt ) {
return max(a.maxi,max(b.maxi,a.right+b.left));
} else if( ps <= pt && pt <= pa ) {
return max(a.maxi,max(b.maxi,a.right+b.right));
} else if( pa <= ps && ps <= pt ) {
return max(a.maxi,max(b.maxi,a.left+b.left));//
} else if( pa <= pt && pt <= ps ) {
return max(a.maxi,max(b.maxi,a.right+b.left));
} else if( pt <= ps && ps <= pa ) {
return max(a.maxi,max(b.maxi,a.right+b.right));
} else if( pt <= pa && pa <= ps ) {
return max(a.maxi,max(b.maxi,a.left+b.right));
} else assert(false);
*/
}
void _Update(int s,int t,SegmentTree &seg,int c){
if( s == t ) return seg.update(posInBase[s],posInBase[s]+1,'S',c);
int chain_s,chain_t=chainID[t];
while(1){
chain_s = chainID[s];
if( chain_s == chain_t ) {
int ps = posInBase[s], pt = posInBase[t];
if( ps > pt ) swap(ps,pt);
seg.update(ps,pt+1,'S',c);
return;
} else {
int head = headID[chain_s];
int ps = posInBase[s], ph = posInBase[head];
seg.update(min(ps,ph),max(ps,ph)+1,'S',c);
s = parent[head];
}
}
}
void Update(int s,int t,int c,SegmentTree &seg,LCA_RMQ &lca_rmq){
if( s == t ) {
int ps = posInBase[s], pt = posInBase[t];
if( ps > pt ) swap(ps,pt);
seg.update(ps,pt+1,'S',c);
return;
}
int ancestor = lca(s,t,lca_rmq);
_Update(s,ancestor,seg,c);
_Update(t,ancestor,seg,c);
}
int main(){
/*
int N;
cin >> N;
vector<int> vec(N);
rep(i,N) cin >> vec[i];
SegmentTree seg;
seg.init(N);
seg.build(vec);
while( 1 ){
int opr,s,t,c;
cin >> opr >> s >> t;
if( opr == 0 ) { // set [s,t)
cin >> c;
seg.update(s,t,'S',c);
} else {
Node node = seg.query(s,t);
cout << "maxi = " << node.maxi << endl;
cout << "sum = " << node.value << endl;
}
}
*/
int Q;
scanf("%d %d",&V,&Q);
costs.clear();
costs.resize(V);
rep(i,V) scanf("%d",&costs[i]);
rep(i,V-1) {
int s,t;
scanf("%d %d",&s,&t);
--s, --t;
G[s].push_back((Edge){t,0});
G[t].push_back((Edge){s,0});
}
HLD_init();
SegmentTree seg;
seg.init(V);
seg.build(baseArray);
LCA_RMQ lca_rmq;
LCA_init(V,lca_rmq);
cout << "baseArray = " << endl;
rep(i,baseArray.size()) cout << baseArray[i] << " "; cout << endl;
cout << "chainID = " << endl;
rep(i,(int)chainID.size()) cout << chainID[i] << " "; cout << endl;
cout << "headID = " << endl;
rep(i,(int)headID.size()) cout << headID[i] << " "; cout << endl;
cout << "parent = " << endl;
rep(i,(int)parent.size()) cout << parent[i] << " "; cout << endl;
cout << "posInBase = " << endl;
rep(i,posInBase.size()) cout << "[" << i << "," << posInBase[i] << "] "; cout << endl;
while(1){
int L,R;
cin >> L >> R;
//print(seg.query(min(posInBase[R],posInBase[L]),max(posInBase[L],posInBase[R])+1));
print(seg.query(L,R+1));
}
return 0;
rep(i,Q){
int t,a,b,c;
scanf("%d %d %d %d",&t,&a,&b,&c);
--a, --b;
if( t == 1 ) {
Update(a,b,c,seg,lca_rmq);
} else if( t == 2 ) {
printf("%lld\n",Query(a,b,seg,lca_rmq));
} else assert(false);
/*
cout << endl << endl;
print(seg.query(posInBase[9],posInBase[3]+1));
cout << endl;
print(seg.query(posInBase[8],posInBase[8]+1));
*/
}
return 0;
} | File "/tmp/tmpch0a81de/tmpy4i_x5ef.py", line 6
このインプットは無視しろってこと?kamo
^
SyntaxError: invalid character '?' (U+FF1F)
| |
s721728822 | p01581 | u104911888 | 1375191200 | Python | Python | py | Runtime Error | 20 | 4204 | 100 | N,M=map(int,raw_input().split())
L=[input() for i in range(N)]
for i in range(M):
print L[N-i-1] | File "/tmp/tmpc52w0rbv/tmpxouh9o9u.py", line 4
print L[N-i-1]
^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s456169827 | p01581 | u834962510 | 1378950558 | Python | Python | py | Runtime Error | 0 | 0 | 199 | from collections import deque
N, M = map(int, input().split(' '))
q = deque()
for _ in range(N):
c = int(input())
if len(q) == M:
q.popleft()
q.append(c)
for _ in reversed(q):
print(_) | Traceback (most recent call last):
File "/tmp/tmpjtiwsmio/tmps9s6utua.py", line 3, in <module>
N, M = map(int, input().split(' '))
^^^^^^^
EOFError: EOF when reading a line
| |
s531081024 | p01581 | u834962510 | 1378951460 | Python | Python | py | Runtime Error | 0 | 0 | 212 | N, M = map(int, input().split(' '))
q = []
for _ in range(N):
c = int(input())
if c in q:
q.remove(c)
q.append(c)
else:
if len(q) == M:
q.pop(0)
q.append(c)
for _ in reversed(q):
print(_) | Traceback (most recent call last):
File "/tmp/tmp6ky75eoo/tmpjug4yj6h.py", line 1, in <module>
N, M = map(int, input().split(' '))
^^^^^^^
EOFError: EOF when reading a line
| |
s636999308 | p01581 | u834962510 | 1378951474 | Python | Python | py | Runtime Error | 20000 | 7556 | 216 | N, M = map(int, raw_input().split(' '))
q = []
for _ in range(N):
c = int(input())
if c in q:
q.remove(c)
q.append(c)
else:
if len(q) == M:
q.pop(0)
q.append(c)
for _ in reversed(q):
print(_) | Traceback (most recent call last):
File "/tmp/tmpqruxhm_5/tmpxu_5psj_.py", line 1, in <module>
N, M = map(int, raw_input().split(' '))
^^^^^^^^^
NameError: name 'raw_input' is not defined
| |
s454729609 | p01581 | u834962510 | 1378952145 | Python | Python | py | Runtime Error | 0 | 0 | 217 | N, M = map(int, input().split(' '))
q = [ int(input()) for _ in range(N) ]
poll = []
cnt = 0
for _ in reversed(q):
if not _ in poll:
print(_)
cnt = cnt + 1
if cnt == M:
break
poll.append(_)
| Traceback (most recent call last):
File "/tmp/tmpc6be1a_6/tmp30hkl9w7.py", line 1, in <module>
N, M = map(int, input().split(' '))
^^^^^^^
EOFError: EOF when reading a line
| |
s092562864 | p01581 | u834962510 | 1378952163 | Python | Python | py | Runtime Error | 20000 | 9340 | 221 | N, M = map(int, raw_input().split(' '))
q = [ int(input()) for _ in range(N) ]
poll = []
cnt = 0
for _ in reversed(q):
if not _ in poll:
print(_)
cnt = cnt + 1
if cnt == M:
break
poll.append(_)
| Traceback (most recent call last):
File "/tmp/tmpw420yqht/tmp8smnm5ew.py", line 1, in <module>
N, M = map(int, raw_input().split(' '))
^^^^^^^^^
NameError: name 'raw_input' is not defined
| |
s353151467 | p01581 | u834962510 | 1378952322 | Python | Python | py | Runtime Error | 0 | 0 | 224 | N, M = map(int, raw_input().split(' '))
q = [ int(input()) for _ in range(N) ]
poll = set()
cnt = 0
for _ in reversed(q):
if not _ in poll:
print(_)
cnt = cnt + 1
if cnt == M:
break
poll.append(_)
| Traceback (most recent call last):
File "/tmp/tmpy0i7qvq0/tmpt_ifu2th.py", line 1, in <module>
N, M = map(int, raw_input().split(' '))
^^^^^^^^^
NameError: name 'raw_input' is not defined
| |
s406350447 | p01601 | u633068244 | 1398502860 | Python | Python | py | Runtime Error | 20 | 4204 | 155 | n = input()
mind = n
for i in range(max(0,n-20),min(10001,n+20)):
if i == int(str(i)[::-1]) and abs(n - i) < mind:
mind = abs(n - i)
ans = i
print ans | File "/tmp/tmp8ywqyrhs/tmpo4to75jh.py", line 7
print ans
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s595540550 | p01602 | u104911888 | 1373197872 | Python | Python | py | Runtime Error | 0 | 0 | 317 | s=""
for i in range(input()):
p,x=raw_input().split()
s+=p*int(x)
st=[]
for i in range(len(s)):
if s[i]=="(":
st.append(s[i])
else:
if st==[] or st[-1]!="(":
print "NO"
break
st.pop()
else:
if st==[]:
print "YES"
else:
print "NO" | File "/tmp/tmp4_m0xplu/tmp5ndxtd_u.py", line 11
print "NO"
^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s396501438 | p01605 | u104911888 | 1367457068 | Python | Python | py | Runtime Error | 0 | 0 | 178 | S=raw_input()
Q,A,B=map(int,raw_input().split())
for i in range(Q):
c,p=raw_input().split()
p="" if p=="." else p
S=S.replace(c,p)
print S[A-1:B] if len(S)<B else "." | File "/tmp/tmp1hoas1gg/tmp0g3ejw0k.py", line 7
print S[A-1:B] if len(S)<B else "."
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s212982905 | p01605 | u104911888 | 1367457542 | Python | Python | py | Runtime Error | 0 | 0 | 181 | S=raw_input()
Q,A,B=map(int,raw_input().split())
for i in range(Q):
c,p=raw_input().split()
p="" if p=="." else p
S=S.replace(c,p)
print "." if len(S)<=B-A else S[A-1:B] | File "/tmp/tmpjeijkex6/tmps84laypy.py", line 7
print "." if len(S)<=B-A else S[A-1:B]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s357949757 | p01605 | u104911888 | 1367458782 | Python | Python | py | Runtime Error | 0 | 0 | 155 | S=raw_input()
Q,A,B=map(int,raw_input().split())
for i in range(Q):
c,p=raw_input().split()
p="" if p=="." else p
S=S.replace(c,p)
print S[A:B] | File "/tmp/tmpvmi0glpk/tmp62662qaf.py", line 7
print S[A:B]
^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s846855087 | p01605 | u104911888 | 1367459109 | Python | Python | py | Runtime Error | 0 | 0 | 182 | S=raw_input()
Q,A,B=map(int,raw_input().split())
for i in range(Q):
c,p=raw_input().split()
# p="" if p=="." else p
S=S.replace(c,p)
print "." if len(S)<=B-A else S[A-1:B] | File "/tmp/tmpd7aavovh/tmp82rpwvnj.py", line 7
print "." if len(S)<=B-A else S[A-1:B]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s621042363 | p01609 | u506537276 | 1558936129 | Python | Python | py | Runtime Error | 0 | 0 | 483 | import math
deltax = 0.0000001
w, h, n = map(int, input().split())
high = [0 for i in range(int(w / deltax))]
for i in range(n):
a, p, q = map(int, input().split())
for i in range(int(w / deltax)):
j = i * deltax
f = a * (j - p)**2 + q
if(f <= h):
high[i] = max(high[i], f)
# print(*high)
ans = 0
for i in range(0, int(w / deltax) - 2, 2):
j = i * deltax
s = (deltax / 6) * (high[i] + 4 * high[i + 1] + high[i + 2])
ans += s
print(ans)
| Traceback (most recent call last):
File "/tmp/tmp18dp8op1/tmpghnyv9wk.py", line 4, in <module>
w, h, n = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s107249603 | p01612 | u797673668 | 1470116469 | Python | Python3 | py | Runtime Error | 700 | 40216 | 1120 | def memoize(f):
cache = {}
def helper(arg):
if arg not in cache:
cache[arg] = f(arg)
return cache[arg]
return helper
def solve(edges):
@memoize
def tree_height(node):
en = edges[node]
if not en:
return 0, set()
max_depth = -1
max_bridges = None
for edge in en:
depth, bridges = tree_height(edge[0])
if depth > max_depth:
max_depth = depth
max_bridges = bridges.copy()
max_bridges.add(edge[1])
elif depth == max_depth:
max_bridges.intersection_update(bridges)
return max_depth + 1, max_bridges
removable = tree_height(0)[1]
print('\n'.join(map(str, sorted(removable)[1:])) if len(removable) > 1 else -1)
n, m = map(int, input().split())
root_flags = [False] + [True] * n
edges = [set() for _ in range(n + 1)]
for i in range(m):
a, b = map(int, input().split())
edges[a].add((b, i + 1))
root_flags[b] = False
edges[0] = set((i, -1) for i, f in enumerate(root_flags) if f)
solve(edges) | Traceback (most recent call last):
File "/tmp/tmppab3x1ef/tmpsut84r9c.py", line 34, in <module>
n, m = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s849862987 | p01614 | u134812425 | 1541126661 | Python | Python3 | py | Runtime Error | 0 | 0 | 1276 | import bisect
import collections
import heapq
import itertools
import math
import string
import sys
from itertools import chain, takewhile
def read(
f, *shape, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
def read_word():
return f("".join(takewhile(lambda c: c not in whitespaces, it)).strip())
if not shape:
return read_word()
elif len(shape) == 1:
return [read_word() for _ in range(shape[0])]
elif len(shape) == 2:
return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]
def debug(**kwargs):
print(
", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
file=sys.stderr,
)
def main():
n = read(int)
weights = []
values = []
for i in range(n):
s, l, p = read(int, 3)
for j in range(s, l + 1):
weights.append(j)
values.append(p)
debug(weights=weights, values=values)
m = read(int)
for _ in range(m):
W = read(int)
dp = [0] * 400
for i in range(len(weights)):
for w in range(weights[i], W + 1):
dp[w] = max(dp[w], dp[w - weights[i]] + values[i])
print(max(dp[0:W+1]))
if __name__ == "__main__":
main()
| Traceback (most recent call last):
File "/tmp/tmpive_a34d/tmpwxchrqen.py", line 51, in <module>
main()
File "/tmp/tmpive_a34d/tmpwxchrqen.py", line 32, in main
n = read(int)
^^^^^^^^^
File "/tmp/tmpive_a34d/tmpwxchrqen.py", line 18, in read
return read_word()
^^^^^^^^^^^
File "/tmp/tmpive_a34d/tmpwxchrqen.py", line 15, in read_word
return f("".join(takewhile(lambda c: c not in whitespaces, it)).strip())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s489163022 | p01615 | u633068244 | 1399654398 | Python | Python | py | Runtime Error | 10 | 4252 | 322 | inf = 1e10
n,m = map(int,raw_input().split())
edge = [map(int,raw_input().split()) for i in range(m)]
d = [[inf]*n for i in range(n)]
for i in range(m):
d[0] = 0
while 1:
update = False
a,b,c = edge[i]
if d[a] != inf and d[b] > d[a] - c:
d[b] = d[a] - c
update = True
if not update: break
print abs(d[n-1]) | File "/tmp/tmp00p2htbs/tmp_oil02q7.py", line 14
print abs(d[n-1])
^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s677055051 | p01620 | u617183767 | 1421566643 | Python | Python | py | Runtime Error | 0 | 0 | 923 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import itertools
import math
from collections import Counter, defaultdict
class Main(object):
def __init__(self):
self.chars = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
def solve(self):
'''
insert your code
'''
while True:
n = input()
if n == 0:
break
k = map(int, raw_input().split())
s = raw_input()
ans = ''
for i in range(len(s)):
ans += self.chars[self.chars.index(s[i]) - k[i % len(k)]]
print ans
return None
if __name__ == '__main__':
m = Main()
m.solve() | File "/tmp/tmp__7pdi5i/tmp0ks62c0d.py", line 28
print ans
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s412340822 | p01620 | u233891002 | 1430541254 | Python | Python | py | Runtime Error | 0 | 0 | 803 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
station = ""
for c in range(ord('a'), ord('z') + 1):
station += chr(c)
for c in range(ord('A'), ord('Z') + 1):
station += chr(c)
while True:
n = int(sys.stdin.readline())
if n == 0:
break
l = sys.stdin.readline()
l = map(lambda x: int(x), l.split())
s = sys.stdin.readline().rstrip()
res = ""
for i, x in enumerate(s):
index = ord(x) - (ord('a') if x.islower() else ord('A') + 26) - l[i % len(l)]
res += station[index]
print res | File "/tmp/tmp1f37lg9o/tmpgdob32ma.py", line 26
print res
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s875213413 | p01620 | u233891002 | 1430541473 | Python | Python | py | Runtime Error | 0 | 0 | 922 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
def main():
station = ""
for c in range(ord('a'), ord('z') + 1):
station += chr(c)
for c in range(ord('A'), ord('Z') + 1):
station += chr(c)
while True:
n = int(sys.stdin.readline())
if n == 0:
break
l = sys.stdin.readline()
l = map(lambda x: int(x), l.split())
s = sys.stdin.readline().rstrip()
res = ""
for i, x in enumerate(s):
index = ord(x) - (ord('a') if x.islower() else ord('A') + 26) - l[i % len(l)]
res += station[index]
print res
if __name__ == '__main__':
main() | File "/tmp/tmp6dypm2lu/tmpi9nutdif.py", line 27
print res
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s488141573 | p01620 | u233891002 | 1430541569 | Python | Python | py | Runtime Error | 0 | 0 | 923 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
def main():
station = ""
for c in range(ord('a'), ord('z') + 1):
station += chr(c)
for c in range(ord('A'), ord('Z') + 1):
station += chr(c)
while True:
n = int(sys.stdin.readline())
if n == 0:
return
l = sys.stdin.readline()
l = map(lambda x: int(x), l.split())
s = sys.stdin.readline().rstrip()
res = ""
for i, x in enumerate(s):
index = ord(x) - (ord('a') if x.islower() else ord('A') + 26) - l[i % len(l)]
res += station[index]
print res
if __name__ == '__main__':
main() | File "/tmp/tmpfmfys2z_/tmpq16j2y7g.py", line 27
print res
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s824926121 | p01620 | u233891002 | 1430548737 | Python | Python | py | Runtime Error | 0 | 0 | 925 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
def main():
station = ""
for c in range(ord('a'), ord('z') + 1):
station += chr(c)
for c in range(ord('A'), ord('Z') + 1):
station += chr(c)
while True:
n = int(sys.stdin.readline())
if n == 0:
return 0
l = sys.stdin.readline()
l = map(lambda x: int(x), l.split())
s = sys.stdin.readline().rstrip()
res = ""
for i, x in enumerate(s):
index = ord(x) - (ord('a') if x.islower() else ord('A') + 26) - l[i % len(l)]
res += station[index]
print res
if __name__ == '__main__':
main() | File "/tmp/tmp92grn32x/tmpfza9zhzw.py", line 27
print res
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s643491132 | p01620 | u766926358 | 1526633367 | Python | Python3 | py | Runtime Error | 0 | 0 | 316 | while 1:
n = int(input())
k_line = list(map(int, input().split()))
s = input()
if (n == 0):
break;
alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
k_line *= (-(-len(s)//len(k_line)))
for num, c in enumerate(s):
index = alpha.index(c) - k_line[num]
print(alpha[index], end='')
print('')
| File "/tmp/tmp4y2msxp0/tmprmfqhpqa.py", line 1
while 1:
IndentationError: unexpected indent
| |
s593132280 | p01620 | u929568713 | 1526642837 | Python | Python3 | py | Runtime Error | 0 | 0 | 342 | while 1:
n = int(input())
k_line = list(map(int, input().split()))
s = input()
if (n == 0):
break;
alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
k_line *= (-(-len(s) // len(k_line)))
s = [alpha[(alpha.index(c) + 52*10 - k_line[num])%52] for num, c in enumerate(s)]
print("".join(s))
| Traceback (most recent call last):
File "/tmp/tmpbuc23pz9/tmpe84ewnx3.py", line 2, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s599505675 | p01620 | u260980560 | 1403673746 | Python | Python | py | Runtime Error | 0 | 0 | 580 | ef suber(c, k):
if ord('a')<=ord(c):
w = ord(c) - ord('a')
if w < k:
return chr(ord('Z') - (k - w - 1)) if k<=26 else chr(ord('z') - (k - w - 27))
return chr(ord('a') + (w - k))
else:
w = ord(c) - ord('A')
if w < k:
return chr(ord('z') - (k - w - 1)) if k<=26 else chr(ord('Z') - (k - w - 27))
return chr(ord('A') + (w - k))
while True:
n = input()
if n==0:
break
k = map(int, raw_input().split())
s = raw_input()
print "".join(suber(s[i], k[i%n]) for i in xrange(len(s))) | File "/tmp/tmpvif1n7sz/tmpt1ok5nx7.py", line 1
ef suber(c, k):
^^^^^
SyntaxError: invalid syntax
| |
s841971067 | p01620 | u260980560 | 1403674150 | Python | Python | py | Runtime Error | 0 | 0 | 255 | station = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQESTUVWXYZ"
while True:
n = input()
if n==0:
break
k = map(int, raw_input().split())
s = raw_input()
print "".join(station[station.find(s[i])-k[i%n]] for i in xrange(len(s))) | File "/tmp/tmp0p2vj586/tmpkljwktx1.py", line 8
print "".join(station[station.find(s[i])-k[i%n]] for i in xrange(len(s)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s707458074 | p01623 | u072053884 | 1523123672 | Python | Python3 | py | Runtime Error | 0 | 0 | 1934 | class UnionFind:
def __init__(self, size):
self.table = [-1] * size
def find(self, x):
while self.table[x] >= 0:
x = self.table[x]
return x
def union(self, x, y):
x_root = self.find(x)
y_root = self.find(y)
if x_root != y_root:
if self.table[x_root] < self.table[y_root]:
self.table[x_root] += self.table[y_root]
self.table[y_root] = x_root
else:
self.table[y_root] += self.table[x_root]
self.table[x_root] = y_root
def isDisjoint(self, x, y):
return self.find(x) != self.find(y)
def solve():
import sys
input_lines = sys.stdin.readlines()
while True:
N, M = map(int, input_lines[0].split())
if N == 0 and M == 0:
break
h = map(int, input_lines[1:1+N])
h = list(zip(h, range(1, 1 + N)))
h.sort()
rm_days, islands = zip(*h)
bridges = [tuple(map(int, l.split())) for l in input_lines[1+N:1+N+M]]
bridges.sort(key=lambda x: x[2])
from bisect import bisect_left
S = UnionFind(N + 1)
cost = 0
i = N
while i > 0:
i -= 1
i = bisect_left(rm_days, rm_days[i])
unsunk_islands = islands[i:]
# Kruskal's algorithm
for bridge in bridges:
a, b, c = bridge
if a in unsunk_islands and b in unsunk_islands:
if S.isDisjoint(a, b):
S.union(a, b)
cost += c
if -len(unsunk_islands) not in S.table:
S = UnionFind(N + 1)
cost = 0
if -N in S.table:
print(cost)
else:
print(0)
del input_lines[:N+1+M]
solve()
| Traceback (most recent call last):
File "/tmp/tmpyw4owjur/tmpqee72cgq.py", line 70, in <module>
solve()
File "/tmp/tmpyw4owjur/tmpqee72cgq.py", line 30, in solve
N, M = map(int, input_lines[0].split())
~~~~~~~~~~~^^^
IndexError: list index out of range
| |
s229685119 | p01623 | u072053884 | 1523154932 | Python | Python3 | py | Runtime Error | 0 | 0 | 1934 | class UnionFind:
def __init__(self, size):
self.table = [-1] * size
def find(self, x):
while self.table[x] >= 0:
x = self.table[x]
return x
def union(self, x, y):
x_root = self.find(x)
y_root = self.find(y)
if x_root != y_root:
if self.table[x_root] < self.table[y_root]:
self.table[x_root] += self.table[y_root]
self.table[y_root] = x_root
else:
self.table[y_root] += self.table[x_root]
self.table[x_root] = y_root
def isDisjoint(self, x, y):
return self.find(x) != self.find(y)
def solve():
import sys
input_lines = sys.stdin.readlines()
while True:
N, M = map(int, input_lines[0].split())
if N == 0 and M == 0:
break
h = map(int, input_lines[1:1+N])
h = list(zip(h, range(1, 1 + N)))
h.sort()
rm_days, islands = zip(*h)
bridges = [tuple(map(int, l.split())) for l in input_lines[1+N:1+N+M]]
bridges.sort(key=lambda x: x[2])
from bisect import bisect_left
S = UnionFind(N + 1)
cost = 0
i = N
while i > 0:
i -= 1
i = bisect_left(rm_days, rm_days[i])
unsunk_islands = islands[i:]
# Kruskal's algorithm
for bridge in bridges:
a, b, c = bridge
if a in unsunk_islands and b in unsunk_islands:
if S.isDisjoint(a, b):
S.union(a, b)
cost += c
if -len(unsunk_islands) not in S.table:
S = UnionFind(N + 1)
cost = 0
if -N in S.table:
print(cost)
else:
print(0)
del input_lines[:N+1+M]
solve()
| Traceback (most recent call last):
File "/tmp/tmp7m4rionn/tmpsiv6tfzy.py", line 70, in <module>
solve()
File "/tmp/tmp7m4rionn/tmpsiv6tfzy.py", line 30, in solve
N, M = map(int, input_lines[0].split())
~~~~~~~~~~~^^^
IndexError: list index out of range
| |
s663262004 | p01623 | u072053884 | 1523155968 | Python | Python3 | py | Runtime Error | 0 | 0 | 1930 | class UnionFind:
def __init__(self, size):
self.table = [-1] * size
def find(self, x):
while self.table[x] >= 0:
x = self.table[x]
return x
def union(self, x, y):
x_root = self.find(x)
y_root = self.find(y)
if x_root != y_root:
if self.table[x_root] < self.table[y_root]:
self.table[x_root] += self.table[y_root]
self.table[y_root] = x_root
else:
self.table[y_root] += self.table[x_root]
self.table[x_root] = y_root
def isDisjoint(self, x, y):
return self.find(x) != self.find(y)
def solve():
import sys
input_lines = sys.stdin.readlines()
from bisect import bisect_left
while True:
N, M = map(int, input_lines[0].split())
if N == 0 and M == 0:
break
h = map(int, input_lines[1:1+N])
h = list(zip(h, range(1, 1 + N)))
h.sort()
rm_days, islands = zip(*h)
bridges = [tuple(map(int, l.split())) for l in input_lines[1+N:1+N+M]]
bridges.sort(key=lambda x: x[2])
S = UnionFind(N + 1)
cost = 0
i = N
while i > 0:
i -= 1
i = bisect_left(rm_days, rm_days[i])
unsunk_islands = islands[i:]
# Kruskal's algorithm
for bridge in bridges:
a, b, c = bridge
if a in unsunk_islands and b in unsunk_islands:
if S.isDisjoint(a, b):
S.union(a, b)
cost += c
if -len(unsunk_islands) not in S.table:
S = UnionFind(N + 1)
cost = 0
if -N in S.table:
print(cost)
else:
print(0)
del input_lines[:N+1+M]
solve()
| Traceback (most recent call last):
File "/tmp/tmpswgr0_2y/tmpi0k2utnv.py", line 70, in <module>
solve()
File "/tmp/tmpswgr0_2y/tmpi0k2utnv.py", line 31, in solve
N, M = map(int, input_lines[0].split())
~~~~~~~~~~~^^^
IndexError: list index out of range
| |
s398468464 | p01624 | u118766929 | 1530824127 | Python | Python3 | py | Runtime Error | 0 | 0 | 1969 | # undo が出来るゲームは全て2手だけ見ればよい
ops = ["+", "*", "-", "&", "^", "|"]
numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]
def check(x):
# +*
op = 0
for c in x:
if c in ops:
op += 1
if op >= 2:
return False
else:
op = 0
# +...
for op in ops:
if x.startswith(op):
return False
if ("(" + op) in x:
return False
# 0がないか
zero_ok = False
for c in x:
if not zero_ok and c == "0":
return False
if c in ops:
zero_ok = False
elif c in numbers:
zero_ok = True
else: # ( )
zero_ok = False
try:
val = eval(x)
return val
except:
return False
def get_nexts(x):
# 削除
result = []
for i in range(len(x)):
y = x[:i] + x[i + 1:]
val = check(y)
if val != False:
result.append((val, y))
# 追加
for i in range(len(x) + 1):
add_list = numbers + ops
for s in add_list:
y = x[:i] + s + x[i:]
val = check(y)
if val != False:
result.append((val, y))
return result
while True:
n, x = input().split(" ")
n = int(n)
if n == 0:
quit()
nexts = get_nexts(x)
if n == 1:
nexts.sort(key=lambda a: - a[0])
print(nexts[0][0])
continue
maxval = eval(x)
tele = x
minvals = []
for (val, y) in nexts:
nextss = get_nexts(y)
nextss.sort(key=lambda a: a[0])
minvals.append(nextss[0][0])
if maxval < nextss[0][0]:
maxval = nextss[0][0]
tele = nextss[0][1]
if n % 2 == 0:
print(max(minvals))
continue
nexts = get_nexts(tele)
if n % 2 == 1:
nexts.sort(key=lambda a: -a[0])
print(nexts[0][0])
continue
| Traceback (most recent call last):
File "/tmp/tmpk7xw8kvw/tmp1di710uj.py", line 60, in <module>
n, x = input().split(" ")
^^^^^^^
EOFError: EOF when reading a line
| |
s647909936 | p01634 | u633068244 | 1396608486 | Python | Python | py | Runtime Error | 0 | 0 | 106 | p=raw_input()
if len(p)<6 or islower(p) or isupper(p) or isdigit(p):
print "INVARID"
else:
print "VARID" | File "/tmp/tmpry0238nh/tmpcfmisngw.py", line 3
print "INVARID"
^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s085781689 | p01646 | u352394527 | 1529469105 | Python | Python3 | py | Runtime Error | 0 | 0 | 1233 | def add_edge(node, adj_lst, adj_rev, s1, s2):
ind = 0
max_len = min(len(s1), len(s2))
while ind < max_len and s1[ind] == s2[ind]:
ind += 1
if ind == max_len:
if max_len < len(s1):
return True
return False
c1 = ord(s1[ind]) - ord("a")
c2 = ord(s2[ind]) - ord("a")
adj_lst[c1].add(c2)
adj_rev[c2].add(c1)
node.add(c1)
node.add(c2)
return False
def main():
while True:
n = int(input())
if n == 0:
break
lst = [input() for _ in range(n)]
node = set()
adj_lst = [set() for _ in range(26)]
adj_rev = [set() for _ in range(26)]
blank_flag = False
for i in range(n):
for j in range(i + 1, n):
blank_flag = blank_flag or add_edge(node, adj_lst, adj_rev, lst[i], lst[j])
L = []
visited = [False] * 26
cycle_flag = False
def visit(n):
global cycle_flag
if cycle_flag: return
if visited[n] == 2:
cycle_flag = True
elif visited[n] == 0:
visited[n] = 2
for to in adj_lst[n]:
visit(to)
visited[n] = 1
L.append(n)
L = []
for n in node:
visit(n)
if cycle_flag or blank_flag:
print("no")
else:
print("yes")
main()
| Traceback (most recent call last):
File "/tmp/tmpnmcvjvv0/tmpgtnbd9wk.py", line 56, in <module>
main()
File "/tmp/tmpnmcvjvv0/tmpgtnbd9wk.py", line 19, in main
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s369005925 | p01646 | u647766105 | 1392007367 | Python | Python | py | Runtime Error | 39860 | 88204 | 1229 | graph = []
def init():
global graph
graph = [[False] * 26 + [True] for _ in xrange(27)]
graph[26][26] = False
def atoi(c):#index
if c == "#":
return 26
return ord(c) - ord("a")
def make_graph(L):
global graph
tmp = []
while "" in L:
L.remove("")
for s1, s2 in zip(L, L[1:]):
if s1[0] == s2[0]:
tmp += [s1[1:], s2[1:]]
else:
if not tmp == [] and not make_graph(tmp):
return False
tmp = []
graph[atoi(s2[0])][atoi(s1[0])] = True
if not tmp == [] and not make_graph(tmp):
return False
return True
def check(start):
stack = set([start])
visited = [False] * 27
while len(stack) != 0:
cur = stack.pop()
visited[cur] = True
if graph[cur][start]:
return False
for i in xrange(27):
if graph[cur][i] and not visited[i]:
stack.add(i)
return True
while True:
n = input()
if n == 0:
break
L = [raw_input() + "#" for _ in xrange(n)]
init()
make_graph(L)
for i in xrange(27):
if not check(i):
print "no"
break
else:
print "yes" | File "/tmp/tmp1v3rggf3/tmpunofss8z.py", line 52
print "no"
^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s439086253 | p01646 | u647766105 | 1392008164 | Python | Python | py | Runtime Error | 39870 | 88192 | 1171 | graph = []
def init():
global graph
graph = [[False] * 26 + [True] for _ in xrange(27)]
graph[26][26] = False
def atoi(c):#index
if c == "#":
return 26
return ord(c) - ord("a")
def make_graph(L):
global graph
tmp = []
while "" in L:
L.remove("")
for s1, s2 in zip(L, L[1:]):
if s1[0] == s2[0]:
tmp += [s1[1:], s2[1:]]
else:
if not tmp == []:
make_graph(tmp)
tmp = []
graph[atoi(s2[0])][atoi(s1[0])] = True
if not tmp == []:
make_graph(tmp)
def check(start):
stack = set([start])
visited = [False] * 27
while len(stack) != 0:
cur = stack.pop()
visited[cur] = True
if graph[cur][start]:
return False
for i in xrange(27):
if graph[cur][i] and not visited[i]:
stack.add(i)
return True
while True:
n = input()
if n == 0:
break
L = [raw_input() + "#" for _ in xrange(n)]
init()
make_graph(L)
for i in xrange(27):
if not check(i):
print "no"
break
else:
print "yes" | File "/tmp/tmp5un4353l/tmpu0rg4tgm.py", line 51
print "no"
^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s284283068 | p01656 | u633068244 | 1393702019 | Python | Python | py | Runtime Error | 0 | 0 | 201 | data = [[1, "kogaku10gokan"]
n, q = map(int, raw_input().split())
for i in range(n):
a, b = map(int, raw_input().split())
data.append([a,b])
for i in data:
if i[0] > q:
print i[1] | File "/tmp/tmpi0xd1yao/tmp9wyxy3pw.py", line 1
data = [[1, "kogaku10gokan"]
^
SyntaxError: '[' was never closed
| |
s379166016 | p01656 | u772196646 | 1400302739 | Python | Python | py | Runtime Error | 10 | 4212 | 218 | nq = map(int, raw_input().split())
n = nq[0]
q = nq[1]
yn = [[1, 'kogakubu10gokan']]
for i in range(n):
yn.append(raw_input().split())
y = 1
k = 0
while y <= q:
k += 1
y = int(yn[k][0])
print yn[k-1][1] | File "/tmp/tmpqbyszx7p/tmp0mglz351.py", line 16
print yn[k-1][1]
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s670346902 | p01672 | u248404432 | 1520404865 | Python | Python3 | py | Runtime Error | 0 | 0 | 860 | import numpy as np
from scipy.signal import correlate
n = int( input() ) # Get grid width
c = []
for i in range(n):
c.append( input().split() ) # Get line info
c = np.array(c, dtype=np.double)
R = np.int32(np.round(correlate(c,c, method='fft'))) # Autocorrelation w/ FFT
center = np.array([1, 1]) * (n-1)
histogram = {}
for y in range(R.shape[0]):
for x in range(R.shape[1]):
d = np.array([y, x])-center
d2 = d@d
v = R[y, x]
if np.round(v) != 0:
if((d2 in histogram.keys()) == False):
histogram[d2] = v
else:
histogram[d2] += v
histogram[0] = (c*(c-1)).sum() #
histogram = sorted( histogram.items() )
sum = 0
mean = 0
for d2, v in histogram: # \sum_n d_n V_n / \sum_n V_n
sum += v
mean += v * d2**.5
print(mean / sum)
for d2, v in histogram:
if np.round(v) != 0:
print(d2, int(np.round(v/2))) # Divide out double counting
| Traceback (most recent call last):
File "/tmp/tmpl1rro8ef/tmpjsk8m4_d.py", line 4, in <module>
n = int( input() ) # Get grid width
^^^^^^^
EOFError: EOF when reading a line
| |
s281879693 | p01682 | u144532944 | 1530522437 | Python | Python3 | py | Runtime Error | 0 | 0 | 217 | import re
S = lambda x: x*x%int(1e9+7)
s = input()
while s != '#':
s = s.replace(' ', '')
s = re.sub(r'>>(\d+)', r'XX\1', s)
s = s.translate(str.maketrans('<>X', '()>'))
print(eval(s))
s = input()
| Traceback (most recent call last):
File "/tmp/tmpp0uwv2g6/tmpxl_s__xh.py", line 3, in <module>
s = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s626415562 | p01682 | u260980560 | 1400182196 | Python | Python | py | Runtime Error | 0 | 0 | 994 | MOD = 10**9 + 7
s = ""; l = 0; pos = 0;
def number():
global pos
x = pos
while pos<l and s[pos].isdigit():
pos += 1
return int(s[x:pos]) if x!=pos else -1
def sp():
global pos
while pos<l and s[pos]==' ':
pos += 1
return 0
def term():
global pos
if pos>=l:
return -1
ret = 0
if s[pos]=='S':
pos += 1 # 'S'
sp()
pos += 1 # '<'
sp()
ret = (expr() ** 2) % MOD
sp()
pos += 1 # '>'
else:
ret = number()
return ret
def expr():
global pos
ret = term()
while pos<l:
x = pos
sp()
if s[pos:pos+2]==">>":
pos += 2
sp()
r = term()
if r==-1:
pos = x
break
ret = int( ret / (2 ** r) )
else:
break
return ret
while True:
s = raw_input();
if s=="#":
break
l = len(s); pos = 0;
print expr() | File "/tmp/tmp5jd8y5mm/tmp309s5a43.py", line 57
print expr()
^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s702370876 | p01682 | u260980560 | 1400182421 | Python | Python | py | Runtime Error | 0 | 0 | 1026 | MOD = 10**9 + 7
s = ""; l = 0; pos = 0;
def number():
global pos
x = pos
while pos<l and s[pos].isdigit():
pos += 1
return int(s[x:pos]) if x!=pos else -1
def sp():
global pos
while pos<l and s[pos]==' ':
pos += 1
return 0
def term():
global pos
if pos>=l:
return -1
ret = 0
if s[pos]=='S':
pos += 1 # 'S'
sp()
pos += 1 # '<'
sp()
ret = (expr() ** 2) % MOD
sp()
pos += 1 # '>'
else:
ret = number()
return ret
def expr():
global pos
ret = term()
while pos<l:
x = pos
sp()
if pos<l-1 and s[pos:pos+2]==">>":
pos += 2
sp()
r = term()
if r==-1:
pos = x
break
ret = int( ret / (2 ** r) )
else:
pos = x
break
return ret
while True:
s = raw_input();
if s=="#":
break
l = len(s); pos = 0;
print expr() | File "/tmp/tmpvohzw6se/tmpnilpfcrs.py", line 58
print expr()
^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s076011468 | p01682 | u260980560 | 1400182897 | Python | Python | py | Runtime Error | 0 | 0 | 1063 | MOD = 10**9 + 7
s = ""; l = 0; pos = 0;
def number():
global pos
ret = 0
x = pos
while pos<l and s[pos].isdigit():
ret = 10*ret + int(s[pos])
pos += 1
return ret if x!=pos else -1
def sp():
global pos
while pos<l and s[pos]==' ':
pos += 1
return 0
def term():
global pos
if pos>=l:
return -1
ret = 0
if s[pos]=='S':
pos += 1 # 'S'
sp()
pos += 1 # '<'
sp()
ret = (expr() ** 2) % MOD
sp()
pos += 1 # '>'
else:
ret = number()
return ret
def expr():
global pos
ret = term()
while pos<l:
x = pos
sp()
if pos<l-1 and s[pos:pos+2]==">>":
pos += 2
sp()
r = term()
if r==-1:
pos = x
break
ret = int( ret / (2 ** r) )
else:
pos = x
break
return ret
while True:
s = raw_input();
if s=="#":
break
l = len(s); pos = 0;
print expr() | File "/tmp/tmp2_smyq0_/tmpgfhrgwi3.py", line 60
print expr()
^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s813566108 | p01694 | u609255173 | 1416727659 | Python | Python | py | Runtime Error | 0 | 0 | 575 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
def main():
while True:
n = input()
if not n: break
w = 0
a = [0, 0]
ans = 0
for s in raw_input().split():
f = 0 if s[0] == "l" else 1
u = 0 if s[1] == "d" else 1
a[f] = u
if w == 0 and a[0] == 1 and a[1] == 1:
w = 1
ans += 1
elif w == 1 and a[0] == 0 and a[1] == 0:
w = 0
ans += 1
print ans
return 0
## -------------------------------------------
## TEMPLATE
if __name__ == "__main__":
setrecursionlimit(1024 * 1024)
main() | File "/tmp/tmpdrzza5zz/tmphu208977.py", line 23
print ans
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s026394802 | p01694 | u966364923 | 1436627431 | Python | Python3 | py | Runtime Error | 0 | 0 | 311 | def main():
while True:
n = int(input())
if n == 0:
exit()
f = [s for input().split()]
pm = 'd'
cnt = 0
for m in f:
if m[1] == pm:
cnt += 1
pm = m[1]
print(cnt)
if __name__ == '__main__':
main() | File "/tmp/tmpprl1efi_/tmpkmty1brz.py", line 6
f = [s for input().split()]
^^^^^^^^^^^^^^^
SyntaxError: cannot assign to function call
| |
s597515499 | p01694 | u052632641 | 1528468832 | Python | Python | py | Runtime Error | 0 | 0 | 489 | import sys,os
k = int(raw_input())
al = raw_input().split()
up = 0
sup = 0
cnt = 0
lu = False
ru = False
for a in al:
if a == "lu":
lu = True
elif a == "ld":
lu = False
elif a == "ru":
ru = True
elif a == "rd":
ru = False
if lu and ru:
up = 2
elif ld and rd:
up = 0
else:
up = 1
if sup <> up and sup <> 1 and up <> 1:
if sup <> up:
cnt = cnt + 1
sup = up
print cnt
| File "/tmp/tmpryw4br2k/tmppafkeqmy.py", line 29
if sup <> up and sup <> 1 and up <> 1:
^^
SyntaxError: invalid syntax
| |
s994442310 | p01695 | u467175809 | 1530976766 | Python | Python | py | Runtime Error | 0 | 0 | 629 | while True:
N = input()
if N == 0:
break
lst = []
for i in range(N):
lst.append(list(raw_input()))
for i in range(N):
for j in range(len(lst[i]) - 1):
if lst[i][j] == '.' and lst[i][j + 1] != '.':
pos = j
for k in range(i, 0, -1):
if lst[k][pos] == '.':
lst[k][pos] = '|'
for i in range(N):
for j in range(len(lst[i]) - 1):
if lst[i][j] == '|' and lst[i][j + 1] != '|':
lst[i][j] = '+'
for i in range(N):
print ''.join(lst[i]).replace('.', ' ')
| File "/tmp/tmpj3llq0c1/tmpjmog3zac.py", line 20
print ''.join(lst[i]).replace('.', ' ')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s536841100 | p01695 | u467175809 | 1530979233 | Python | Python | py | Runtime Error | 0 | 0 | 629 | while True:
N = input()
if N == 0:
break
lst = []
for i in range(N):
lst.append(list(raw_input()))
for i in range(N):
for j in range(len(lst[i]) - 1):
if lst[i][j] == '.' and lst[i][j + 1] != '.':
pos = j
for k in range(i, 0, -1):
if lst[k][pos] == '.':
lst[k][pos] = '|'
for i in range(N):
for j in range(len(lst[i]) - 1):
if lst[i][j] == '|' and lst[i][j + 1] != '|':
lst[i][j] = '+'
for i in range(N):
print ''.join(lst[i]).replace('.', ' ')
| File "/tmp/tmpmseqftou/tmpco7f7ubd.py", line 20
print ''.join(lst[i]).replace('.', ' ')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s662264863 | p01695 | u467175809 | 1530979631 | Python | Python | py | Runtime Error | 0 | 0 | 794 | #!/usr/bin/env python
import sys
import math
import itertools as it
from collections import deque
sys.setrecursionlimit(10000000)
while True:
N = input()
if N == 0:
break
lst = []
for i in range(N):
lst.append(list(raw_input()))
for i in range(N):
for j in range(len(lst[i]) - 1):
if lst[i][j] == '.' and lst[i][j + 1] != '.':
for k in range(i, 0, -1):
if lst[k][pos] == '.':
lst[k][pos] = '|'
else:
break
for i in range(N):
for j in range(len(lst[i]) - 1):
if lst[i][j] == '|' and lst[i][j + 1] != '|':
lst[i][j] = '+'
for i in range(N):
print ''.join(lst[i]).replace('.', ' ')
| File "/tmp/tmp6cgnc38m/tmpcs337dkm.py", line 30
print ''.join(lst[i]).replace('.', ' ')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s183256857 | p01695 | u591052358 | 1529630483 | Python | Python3 | py | Runtime Error | 0 | 0 | 758 | def count_dot(lis):
c=0
for i in lis:
if not(i=='.'):
return c
c+=1
def solve(N):
a=[]
dot =[]
for i in range(N):
a.append([char for char in input()])
dot.append(count_dot(a[i]))
for i in range(N):
for j in range(len(a[i])):
if a[i][j]=='.':
a[i][j]=' '
for i in range(1,N):
#print(type(dot[i]))
a[i][dot[i-1]]='+'
k=1
while True:
if not(a[i-k][dot[i]] == ' '):
break
a[i-k][dot[i]]='|'
k += 1
for i in range(N):
for char in a[i]:
print(char,end='')
print()
while True:
N=int(input())
if N==0:
break
solve(N)
| Traceback (most recent call last):
File "/tmp/tmp_rrgud2b/tmpwnds3f5h.py", line 35, in <module>
N=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s649358189 | p01695 | u591052358 | 1529630570 | Python | Python3 | py | Runtime Error | 0 | 0 | 758 | def count_dot(lis):
c=0
for i in lis:
if not(i=='.'):
return c
c+=1
def solve(N):
a=[]
dot =[]
for i in range(N):
a.append([char for char in input()])
dot.append(count_dot(a[i]))
for i in range(N):
for j in range(len(a[i])):
if a[i][j]=='.':
a[i][j]=' '
for i in range(1,N):
#print(type(dot[i]))
a[i][dot[i-1]]='+'
k=1
while True:
if not(a[i-k][dot[i]] == ' '):
break
a[i-k][dot[i]]='|'
k += 1
for i in range(N):
for char in a[i]:
print(char,end='')
print()
while True:
N=int(input())
if N==0:
break
solve(N)
| Traceback (most recent call last):
File "/tmp/tmp_04byv64/tmp6lofslba.py", line 35, in <module>
N=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s984387166 | p01696 | u731941832 | 1530590379 | Python | Python3 | py | Runtime Error | 0 | 0 | 752 | while True:
s = input()
if s == '.':break
while True:
index = min(max(0, s.find('+')), max(0, s.find('-')))
if index == 0 and s[0] != '+' and s[0] != '-':
index = s.rfind('[')
if index == -1:
break
e = s[index:].find(']')
s = s[:index] + s[index + 1:e][::-1] + s[e + 1:]
else:
e = index
f = 0
while s[e] == '+' or s[e] == '-':
e += 1
if s[e] == '+':
f += 1
else:
f -= 1
r = s[e]
if s[e] != '?':
r = chr(ord(r) += f)
s = s[:index] + r + s[e + 1:]
print(s.replace('?','A'))
| File "/tmp/tmpl3d2nr0a/tmpl9pi6h4u.py", line 23
r = chr(ord(r) += f)
^^
SyntaxError: invalid syntax
| |
s950168623 | p01696 | u731941832 | 1530590531 | Python | Python3 | py | Runtime Error | 0 | 0 | 749 | while True:
s = input()
if s == '.':break
while True:
index = min(max(0, s.find('+')), max(0, s.find('-')))
if index == 0 and s[0] != '+' and s[0] != '-':
index = s.rfind('[')
if index == -1:
break
e = s[index:].find(']')
s = s[:index] + s[index + 1:e][::-1] + s[e + 1:]
else:
e = index
f = 0
while s[e] == '+' or s[e] == '-':
e += 1
if s[e] == '+':
f += 1
else:
f -= 1
r = s[e]
if r != '?':
r = chr(ord(r) += f)
s = s[:index] + r + s[e + 1:]
print(s.replace('?','A'))
| File "/tmp/tmp170k1yuu/tmp3bnvl6mz.py", line 23
r = chr(ord(r) += f)
^^
SyntaxError: invalid syntax
| |
s453400008 | p01696 | u731941832 | 1530590552 | Python | Python3 | py | Runtime Error | 0 | 0 | 748 | while True:
s = input()
if s == '.':break
while True:
index = min(max(0, s.find('+')), max(0, s.find('-')))
if index == 0 and s[0] != '+' and s[0] != '-':
index = s.rfind('[')
if index == -1:
break
e = s[index:].find(']')
s = s[:index] + s[index + 1:e][::-1] + s[e + 1:]
else:
e = index
f = 0
while s[e] == '+' or s[e] == '-':
e += 1
if s[e] == '+':
f += 1
else:
f -= 1
r = s[e]
if r != '?':
r = chr(ord(r) + f)
s = s[:index] + r + s[e + 1:]
print(s.replace('?','A'))
| Traceback (most recent call last):
File "/tmp/tmplk9h_8ws/tmp9_vtr6_t.py", line 2, in <module>
s = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s371003155 | p01696 | u731941832 | 1530590662 | Python | Python3 | py | Runtime Error | 0 | 0 | 764 | while True:
s = input()
if s == '.':break
while True:
index = min(max(0, s.find('+')), max(0, s.find('-')))
if index == 0 and s[0] != '+' and s[0] != '-':
index = s.rfind('[')
if index == -1:
break
e = s[index:].find(']')
s = s[:index] + s[index + 1:index + e][::-1] + s[index + e + 1:]
else:
e = index
f = 0
while s[e] == '+' or s[e] == '-':
e += 1
if s[e] == '+':
f += 1
else:
f -= 1
r = s[e]
if r != '?':
r = chr(ord(r) + f)
s = s[:index] + r + s[e + 1:]
print(s.replace('?','A'))
| Traceback (most recent call last):
File "/tmp/tmpn031e_a1/tmphxz_g92a.py", line 2, in <module>
s = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s047912802 | p01696 | u731941832 | 1530591096 | Python | Python3 | py | Runtime Error | 0 | 0 | 765 | while True:
s = input()
if s == '.':break
while True:
index = min(max(0, s.find('+')), max(0, s.find('-')))
if index == 0 and s[0] != '+' and s[0] != '-':
index = s.rfind('[')
if index == -1:
break
e = s[index:].find(']')
s = s[:index] + s[index + 1:index + e][::-1] + s[index + e + 1:]
else:
e = index
f = 0
while s[e] == '+' or s[e] == '-':
if s[e] == '+':
f += 1
else:
f -= 1
e += 1
r = s[e]
if r != '?':
r = chr(ord(r) + f)
s = s[:index] + r + s[e + 1:]
print(s.replace('?', 'A'))
| Traceback (most recent call last):
File "/tmp/tmp0j9ewemp/tmpc04t2ljp.py", line 2, in <module>
s = input()
^^^^^^^
EOFError: EOF when reading a line
| |
s304635391 | p01696 | u731941832 | 1530612084 | Python | Python3 | py | Runtime Error | 0 | 0 | 806 | while True:
s = input()
if s == '.':break
while True:
if s.find('+') == -1 and s.find('-') == -1:
index = s.rfind('[')
if index == -1:break
e = s.find(']', index)
s = s[:index] + s[index + 1:e][::-1] + s[e + 1:]
else:
index = s.find('+')
if index == -1:
index = s.find('-')
if s.find('-') != -1
index = min(index, s.find('-'))
e = index
f = 0
while s[e] == '+' or s[e] == '-':
f += [-1, 1][s[e] == '+']
e += 1
r = s[e]
if r != '?':
r = chr((ord(r) - ord('A') + f) % 26 + ord('A'))
s = s[:index] + r + s[e + 1:]
print(s.replace('?', 'A'))
| File "/tmp/tmp3w3kfjom/tmptci_pdft.py", line 14
if s.find('-') != -1
^
SyntaxError: expected ':'
| |
s594176656 | p01696 | u731941832 | 1530612234 | Python | Python3 | py | Runtime Error | 0 | 0 | 814 | while True:
s = input()
if s == '.':break
while True:
if s.find('+') == -1 and s.find('-') == -1:
index = s.rfind('[')
if index == -1:break
e = s.find(']', index, len(s))
s = s[:index] + s[index + 1:e][::-1] + s[e + 1:]
else:
index = s.find('+')
if index == -1:
index = s.find('-')
if s.find('-') != -1
index = min(index, s.find('-'))
e = index
f = 0
while s[e] == '+' or s[e] == '-':
f += [-1, 1][s[e] == '+']
e += 1
r = s[e]
if r != '?':
r = chr((ord(r) - ord('A') + f) % 26 + ord('A'))
s = s[:index] + r + s[e + 1:]
print(s.replace('?', 'A'))
| File "/tmp/tmpr7ot9q8k/tmpf9l85xom.py", line 14
if s.find('-') != -1
^
SyntaxError: expected ':'
| |
s367691272 | p01702 | u827448139 | 1418360848 | Python | Python3 | py | Runtime Error | 19930 | 7516 | 600 | while 1:
n,m,q=map(int,input().split())
if (n|m|q)==0: break
p=[]
res=[[_ for _ in range(n)] for _ in range(m)]
for i in range(q):
s,b=[[int(c) for c in s] for s in input().split()]
if i>0:
for j in range(n):
s[j]^=p[j]
for j in range(n):
for k in range(m):
if s[j]!=b[k] and j in res[k]:
res[k].remove(j)
p=s
table="".join([str(i) for i in range(10)]+[chr(ord("A")+i) for i in range(26)])
for i in range(m):
if len(res[i])==1:
print(table[res[i][0]],sep="",end="")
else:
print("?",sep="",end="")
print() | Traceback (most recent call last):
File "/tmp/tmp4naheacs/tmpznr91dzl.py", line 2, in <module>
n,m,q=map(int,input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s267091660 | p01702 | u633068244 | 1423509183 | Python | Python | py | Runtime Error | 0 | 0 | 622 | ref = "0123456789ACDEFGHIJKLMNOPQRSTUVWXYZ"
while 1:
N,M,Q = map(int,raw_input().split())
if N == 0: break
corr = [set(range(N)) for _ in range(M)]
s = ["0"]*N
for loop in xrange(Q):
S,B = raw_input().split()
for i in range(N):
if S[i] == "1": s[i] = {"0":"1","1":"0"}[s[i]]
on = set([i for i in range(N) if s[i] == "1"])
off = set(range(N))-on
for i in range(M):
if B[i] == "1": corr[i] &= on
else: corr[i] &= off
ans = [ref[list(i)[0]] if len(i) == 1 else "?" for i in corr]
print "".join(ans) | File "/tmp/tmpb8yh4_5r/tmp_dssm33_.py", line 18
print "".join(ans)
^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s173141626 | p01702 | u633068244 | 1423509878 | Python | Python | py | Runtime Error | 0 | 0 | 556 | ref = "0123456789ACDEFGHIJKLMNOPQRSTUVWXYZ"
while 1:
N,M,Q = map(int,raw_input().split())
if N == 0: break
sn = set(range(N))
corr = [set(range(N)) for _ in range(M)]
s = [0]*N
for loop in xrange(Q):
S,B = raw_input().split()
s = [1-s[i] if S[i] == "1" else s[i] for i in range(N)]
on = set([i for i in range(N) if s[i]])
off = sn-on
for i in range(M):
corr[i] &= on if B[i] == "1" else off
ans = [ref[list(i)[0]] if len(i) == 1 else "?" for i in corr]
print "".join(ans) | File "/tmp/tmpu3ufbig6/tmpcops8uwx.py", line 16
print "".join(ans)
^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s771507084 | p01702 | u509278866 | 1529231463 | Python | Python3 | py | Runtime Error | 0 | 0 | 1923 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def main():
rr = []
st = string.digits + string.ascii_uppercase
while True:
n,m,q = LI()
if n == 0:
break
a = [LS() for _ in range(q)]
if n == 1:
rr.append('0'*m)
continue
u = [set() for _ in range(m)]
v = [set() for _ in range(m)]
ms = '0' * m
for t,s in a:
ts = []
ns = []
for i in range(n):
if t[i] == '1':
ts.append(i)
else:
ns.append(i)
us = set()
vs = set()
for i in range(m):
for ti in ts:
if s[i] != ms[i]:
u[i].add(ti)
else:
v[i].add(ti)
for ni in ns:
if s[i] != ms[i]:
v[i].add(ni)
else:
u[i].add(ni)
ms = s
r = ''
for i in range(m):
t = u[i] - v[i]
if len(t) == 1:
r += st[list(t)[0]]
else:
r += '?'
rr.append(r)
return '\n'.join(map(str, rr))
print(main())
| Traceback (most recent call last):
File "/tmp/tmp5st0yc_p/tmp8m5dc4ae.py", line 73, in <module>
print(main())
^^^^^^
File "/tmp/tmp5st0yc_p/tmp8m5dc4ae.py", line 26, in main
n,m,q = LI()
^^^^^
ValueError: not enough values to unpack (expected 3, got 0)
| |
s467787917 | p01712 | u273756488 | 1559290225 | Python | Python3 | py | Runtime Error | 20 | 5612 | 554 | n, W, H = [int(i) for i in input().split()]
X = [[int(i) for i in input().split()] for j in range(n)]
imos_h = [0] * (H + 2)
imos_w = [0] * (W + 2)
for x, y, w in X:
imos_h[max(0, y - w)] += 1
imos_h[min(W + 1, y + w + 1)] -= 1
imos_w[max(0, x - w)] += 1
imos_w[min(H + 1, x + w + 1)] -= 1
for h in range(H):
imos_h[h + 1] += imos_h[h]
for w in range(W):
imos_w[w + 1] += imos_w[w]
is_w = all(imos_w[w] >= 1 for w in range(W + 1))
is_h = all(imos_h[h] >= 1 for h in range(H + 1))
if is_h or is_w:
print('Yes')
else:
print('No')
| Traceback (most recent call last):
File "/tmp/tmp8fixjy__/tmp7w2oyt5_.py", line 1, in <module>
n, W, H = [int(i) for i in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s937756726 | p01712 | u273756488 | 1559290300 | Python | Python3 | py | Runtime Error | 20 | 5616 | 554 | n, W, H = [int(i) for i in input().split()]
X = [[int(i) for i in input().split()] for j in range(n)]
imos_h = [0] * (H + 2)
imos_w = [0] * (W + 2)
for x, y, w in X:
imos_h[max(0, y - w)] += 1
imos_h[min(W + 1, y + w + 1)] -= 1
imos_w[max(0, x - w)] += 1
imos_w[min(H + 1, x + w + 1)] -= 1
for h in range(H):
imos_h[h + 1] += imos_h[h]
for w in range(W):
imos_w[w + 1] += imos_w[w]
is_w = all(imos_w[w] >= 1 for w in range(W + 1))
is_h = all(imos_h[h] >= 1 for h in range(H + 1))
if is_h or is_w:
print('Yes')
else:
print('No')
| Traceback (most recent call last):
File "/tmp/tmpfzhl_3t1/tmp0mibmwko.py", line 1, in <module>
n, W, H = [int(i) for i in input().split()]
^^^^^^^
EOFError: EOF when reading a line
| |
s335970129 | p01712 | u296492699 | 1422625489 | Python | Python | py | Runtime Error | 0 | 0 | 502 | input_lines = raw_input()
n,w,h = map(int, input_lines.split())
wifi_list=[]
x_list = [False for i in range(w+1)]
y_list = [False for i in range(h+1)]
for i in range(n):
input_lines = raw_input()
xi,yi,wi = map(int, input_lines.split()))
xs=xi-wi if xi-wi>=0 else 0
xe=xi+wi if xi+wi<=w else w
ys=yi-wi if yi-wi>=0 else 0
ye=yi+wi if yi+wi<=h else h
x_list[xs:xe+1]=True
y_list[ys:ye+1]=True
if False in x_list or False in y_list:
print 'No'
else:
print 'Yes' | File "/tmp/tmprcbthqu3/tmp_yx89j9k.py", line 10
xi,yi,wi = map(int, input_lines.split()))
^
SyntaxError: unmatched ')'
| |
s391045986 | p01712 | u296492699 | 1422626407 | Python | Python | py | Runtime Error | 0 | 0 | 491 | import sys
in_txt=sys.stdin.read().splitlines()
n,w,h = map(int, in_txt[0].split())
wifi_list=[]
x_list = [False for i in range(w+1)]
y_list = [False for i in range(h+1)]
for i in in_txt[1:]:
xi,yi,wi = map(int, i.split())
xs=xi-wi if xi-wi>=0 else 0
xe=xi+wi if xi+wi<=w else w
ys=yi-wi if yi-wi>=0 else 0
ye=yi+wi if yi+wi<=h else h
x_list[xs:xe+1]=True
y_list[ys:ye+1]=True
if False in x_list or False in y_list:
print 'No'
else:
print 'Yes' | File "/tmp/tmpkg8h7k2q/tmp5vqi3p_z.py", line 23
print 'No'
^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s507979866 | p01712 | u296492699 | 1422635350 | Python | Python | py | Runtime Error | 0 | 0 | 578 | mport sys
in_txt=sys.stdin.read().splitlines()
n,w,h = map(int, in_txt[0].split())
wifi_list=[]
area = [[False for i in range(w+1)] for j in range(h+1)]
for i in in_txt[1:]:
xi,yi,wi = map(int, i.split())
xs=xi-wi if xi-wi>=0 else 0
xe=xi+wi if xi+wi<=w else w
ys=yi-wi if yi-wi>=0 else 0
ye=yi+wi if yi+wi<=h else h
for j in range(h+1):
area[j][xs:xe+1]=[True]*(xe-xs+1)
area[ys:ye+1]=[[True]*(w+1)]*(ye-ys+1)
flag=False
for i in area:
if False in i:
flag=True
break
if flag:
print 'No'
else:
print 'Yes' | File "/tmp/tmp_xfscgap/tmpvrco1gmq.py", line 1
mport sys
^^^
SyntaxError: invalid syntax
| |
s396647562 | p01712 | u753085696 | 1425897669 | Python | Python | py | Runtime Error | 0 | 0 | 374 | # your code goes here
import numpy as np
buf = raw_input()
buf = buf.split(" ")
n = int(buf[0])
w = int(buf[1])
h = int(buf[2])
array = np.zeros((h, w))
for i in xrange(n):
buf = raw_input()
buf = buf.split(" ")
x = int(buf[0])
y = int(buf[1])
w = int(buf[2])
array[(y-w):(y+w),:]=True
array[:,(x-w):(x+w)]=True
if array.all():
print "Yes"
else:
print "No"
| File "/tmp/tmp5k4oom33/tmpytlci6g_.py", line 24
print "Yes"
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s390973156 | p01712 | u474983612 | 1463255984 | Python | Python3 | py | Runtime Error | 0 | 0 | 936 | test_file = open('C:\\Users\\nanashi\Downloads\\2600-in21.txt')
input = lambda: test_file.readline().rstrip()
N, W, H = [int(x) for x in input().split()]
map_x = [False] * W
count_x = 0
map_y = [False] * H
count_y = 0
wifi_x = []
wifi_y = []
for _ in range(N):
x, y, w = [int(x) for x in input().split()]
wifi_x.append((x - w, x + w))
wifi_y.append((y - w, y + w))
wifi_x.sort(key=lambda a: a[1], reverse=True)
wifi_y.sort(key=lambda a: a[1], reverse=True)
def check_wifi(wifi, l):
for x1, x2 in wifi:
if x1 <= l < x2:
return x2
return None
ans_x = True
b = 0
for x in range(W):
if x < b:
continue
b = check_wifi(wifi_x, x)
if not b:
ans_x = False
break
if not ans_x:
b = 0
for y in range(H):
if y < b:
continue
b = check_wifi(wifi_y, y)
if not b:
print('No')
exit()
print('Yes') | Traceback (most recent call last):
File "/tmp/tmp2zhgvfw5/tmpk2kzncxj.py", line 1, in <module>
test_file = open('C:\\Users\\nanashi\Downloads\\2600-in21.txt')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\nanashi\\Downloads\\2600-in21.txt'
| |
s825141223 | p01713 | u352394527 | 1530436469 | Python | Python3 | py | Runtime Error | 0 | 0 | 781 | def search_left(ind):
doors = []
for j in range(ind - 1, -1, -1):
if alst[j] < 0:
doors.append((j, -alst[j]))
if alst[j] == 0:
ret = alst[ind]
for pos, lim in doors:
ret = min(ret, lim - (ind - pos))
ret = max(0, ret)
return ret
return 0
def search_right(ind):
doors = []
for j in range(ind + 1, w):
if alst[j] < 0:
doors.append((j, -alst[j]))
if alst[j] == 0:
ret = alst[ind]
for pos, lim in doors:
ret = min(ret, lim - (pos - ind))
ret = max(0, ret)
return ret
return 0
def main():
w = int(input())
alst = list(map(int, input().split()))
ans = 0
for ind, a in enumerate(alst):
if a > 0:
ans += max(search_left(ind), search_right(ind))
print(ans)
main()
| Traceback (most recent call last):
File "/tmp/tmp8teaf2cy/tmpfv992bub.py", line 35, in <module>
main()
^^^^^^
File "/tmp/tmp8teaf2cy/tmpfv992bub.py", line 28, in main
w = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s962645052 | p01714 | u567380442 | 1426078153 | Python | Python3 | py | Runtime Error | 19930 | 6988 | 2910 | from itertools import combinations
from itertools import groupby
def solve(xyuv):
if len(xyuv) <= 2 or is_all_same(xyuv) or is_all_same_attime(xyuv):
return len(xyuv)
max_ij = 0
for i, j in combinations(range(len(xyuv)), 2):
if xyuv[i] == xyuv[j]:
continue
xyi,uvi = xyuv[i]
xyj,uvj = xyuv[j]
always_lined_point = 0
t = []
for k in range(len(xyuv)):
if i == k or j == k:
continue
xyk,uvk = xyuv[k]
ans, flg = get_t(xyi - xyk, uvi - uvk, xyj - xyk, uvj - uvk)
t.extend(ans)
if flg:
always_lined_point += 1
t = [round(ti, 10) for ti in t] #?????????
t = [ti for ti in t if 0 <= ti] #t<0?????????
t.sort()
xyi -= xyj
uvi -= uvj
max_group_length = 0
for k, g in groupby(t):
group_length = 1 if eq(xyi + uvi * k, 0) else sum(1 for _ in g)
max_group_length = max(max_group_length, group_length)
max_ij = max(max_ij, max_group_length + always_lined_point + 2)
return max_ij
def get_t(xy1,uv1,xy2,uv2):
a = cross(uv1, uv2)
b = cross(xy1, uv2) + cross(uv1, xy2)
c = cross(xy1, xy2)
ans, flg = quadratic_equation(a, b, c)
return ans, flg
def is_all_same_attime(xyuv):
xy0, uv0 = xyuv[0]
for i in range(len(xyuv)):
if xyuv[0] == xyuv[i]:
continue
xyi,uvi = xyuv[i]
t = get_cross_time(xy0,xyi,xy0 + uv0,xyi + uvi)
if t is None or t < 0:
return False
p0 = xy0 + uv0 * t
for j in range(i + 1,len(xyuv)):
xyj, uvj = xyuv[j]
pj = xyj + uvj * t
if eq(pj, p0):
continue
return False
break
return True
def get_cross_time(p1,p2,p3,p4):
s1 = cross(p4-p2,p1-p2)
s2 = cross(p4-p2,p2-p3)
if s1 + s2 == 0:
return None
return s1 / (s1 + s2)
def take2(i):
while True:
yield next(i),next(i)
def main(f):
_ = int(f.readline())
xyuv = [[x+y*1j for x,y in take2(map(int, line.split()))] for line in f]
print(solve(xyuv))
def is_all_same(xyuv):
for xyuvi in xyuv:
if xyuvi != xyuv[0]:
return False
return True
def cross(v1,v2):
return v1.real * v2.imag - v1.imag * v2.real
def eq(a, b):
return abs(a - b) <= 10 ** -9
# return [2?¬?????¨????????§£],0==a==b==c
def quadratic_equation(a,b,c):
if a:
d = b * b - 4 * a * c
if d < 0:
ans = []
elif d == 0:
ans = [-b / (2 * a)]
else:
d **= 0.5
d /= 2 * a
b /= 2 * a
ans = [-b + d, -b - d]
elif b:
ans = [-c / b]
else:
ans = []
return ans, 0 == a == b == c
import sys
f = sys.stdin
main(f) | Traceback (most recent call last):
File "/tmp/tmp9gzgxhje/tmptdrd3g8v.py", line 114, in <module>
main(f)
File "/tmp/tmp9gzgxhje/tmptdrd3g8v.py", line 78, in main
_ = int(f.readline())
^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s353683596 | p01714 | u567380442 | 1426144397 | Python | Python3 | py | Runtime Error | 30 | 6920 | 2732 | def take2(i):
while True:
yield next(i),next(i)
def main(f):
_ = int(f.readline())
xyuv = [[x+y*1j for x,y in take2(map(int, line.split()))] for line in f]
print(solve(xyuv))
def is_all_same_attime(xyuv):
xy0, uv0 = xyuv[0]
for i in range(len(xyuv)):
if xyuv[0] == xyuv[i]:
continue
xyi,uvi = xyuv[i]
t = get_cross_time(xy0 - xyi, uv0 - uvi)
if t is None or t < 0:
return False
p0 = xy0 + uv0 * t
for j in range(i + 1,len(xyuv)):
xyj, uvj = xyuv[j]
pj = xyj + uvj * t
if is_zero(pj - p0):
continue
return False
break
return True
def get_cross_time(xy,uv):
denominator = uv.real - uv.imag
return (xy.imag - xy.real) / denominator if denominator else None
def is_all_same(xyuv):
for xyuvi in xyuv:
if xyuvi != xyuv[0]:
return False
return True
def is_zero(a):
return abs(a) < 0.00001
def get_t(xy1,uv1,xy2,uv2):
a = uv1.real * uv2.imag - uv1.imag * uv2.real
b = xy1.real * uv2.imag - xy1.imag * uv2.real + uv1.real * xy2.imag - uv1.imag * xy2.real
c = xy1.real * xy2.imag - xy1.imag * xy2.real
if a:
d = b * b - 4 * a * c
if d < 0:
return []
elif d == 0:
return [-b / (2 * a)]
else:
d = d ** 0.5 / (2 * a)
b /= 2 * a
return [-b + d, -b - d]
if b:
return [-c / b]
if not c:
global always_lined_point
always_lined_point += 1
return []
from itertools import combinations
from itertools import groupby
from collections import Counter
def solve(xyuv):
global always_lined_point
if len(xyuv) <= 2 or is_all_same(xyuv) or is_all_same_attime(xyuv):
return len(xyuv)
max_ij = 0
for i, j in combinations(range(len(xyuv)), 2):
if xyuv[i] == xyuv[j]:
continue
xyi,uvi = xyuv[i]
xyj,uvj = xyuv[j]
always_lined_point = 0
t = []
for indeces in (range(i),range(i + 1,j),range(j + 1,len(xyuv))):
for k in indeces:
xyk,uvk = xyuv[k]
t.extend(get_t(xyi - xyk, uvi - uvk, xyj - xyk, uvj - uvk))
t = [ti for ti in t if 0 <= ti] #t<0?????????
t = [round(ti, 10) for ti in t] #?????????
t = Counter(t)
group_lengths = []
for k, c in t.most_common(2):
group_length = 1 if is_zero(xyi + uvi * k) else c
group_lengths.append(group_length)
max_ij = max(max_ij, max(group_lengths) + always_lined_point + 2)
return max_ij
import sys
f = sys.stdin
main(f) | Traceback (most recent call last):
File "/tmp/tmpgejishzm/tmpnd8g6esi.py", line 100, in <module>
main(f)
File "/tmp/tmpgejishzm/tmpnd8g6esi.py", line 5, in main
_ = int(f.readline())
^^^^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s126505987 | p01714 | u083285064 | 1426956447 | Python | Python3 | py | Runtime Error | 19930 | 6768 | 849 | import itertools
N = int(input())
km = []
for i in range(N):
km.append(input().split(' '))
nmax = 0
try:
for i in range(1000):
ks = []
for j in range(N):
x, y, u, v = list(map(int, list(km[j])))
ks.append((x + u * i, y + v * i))
for k in list(itertools.combinations(ks, 2)):
(x1, y1), (x2, y2) = k
xd = x1 - x2
yd = y1 - y2
t = 0
for j in ks:
(x3, y3) = j
#for di in range(-20, 20):
if ((xd == 0 and yd == 0 and x3 == x1 and y1 == y3) or
((xd != 0 or yd != 0) and (x1 - x3) * yd == (y1 - y3) * xd)):
t += 1
nmax = max(nmax, t)
if nmax == N:
raise Exception
except Exception:
pass
print(nmax) | Traceback (most recent call last):
File "/tmp/tmpqjneb1_w/tmpidy4zwzf.py", line 3, in <module>
N = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s878641653 | p01715 | u567380442 | 1426301410 | Python | Python3 | py | Runtime Error | 150 | 12856 | 948 | from operator import itemgetter
#@profile
def calc(w,pdp,pl,pr,dp,l,r):
if l >= r:
return
m = (l + r) // 2
dp[m], i = min([(pdp[i] + w[i+1][m],i) for i in range(pl,min(pr,m))], key=itemgetter(0))
calc(w,pdp,pl,i,dp,l,m-1)
calc(w,pdp,i,pr,dp,m+1,r)
return dp
import sys
f = sys.stdin
s,n,m = map(int, f.readline().split())
x = list(map(int, f.readline().split()))
tp = [list(map(int, line.split())) for line in f]
c = [ti - x[pi - 1] for ti, pi in tp]
c.sort()
min_c = c[0]
c = [ci - min_c for ci in c]
d = c[:]
for i in range(1,len(d)):
d[i] += d[i - 1]
w = [[0 for j in range(n)] for i in range(n)]
for j in range(1, n):
for i in range(j):
w[i][j] = c[j] * (j - i + 1) - (d[j] - d[i] + c[i])
dp = w[0][:]
for bus in range(2,m + 1):
pdp = dp
dp = [0] * len(pdp)
pl = bus - 2
pr = n-m+bus
if pl > pr:
continue
dp = calc(w,pdp,pl,pr,dp,bus,n)
print(dp[-1]) | Traceback (most recent call last):
File "/tmp/tmpbtrusc3_/tmpoy0t2cfr.py", line 15, in <module>
s,n,m = map(int, f.readline().split())
^^^^^
ValueError: not enough values to unpack (expected 3, got 0)
| |
s987405682 | p01716 | u567380442 | 1426381406 | Python | Python3 | py | Runtime Error | 19930 | 6876 | 1829 | def dfs(p,s,c,cmin,cmax):
if len(p) == 0:
return solve(s,c,cmin,cmax)
lower, u = p[0]
c += lower
if u <= 9:
cmin[lower] = 0
cmax[lower] = u
return dfs(p[1:],s,c,cmin,cmax)
cmin[lower] = 0
cmax[lower] = 9
ret = dfs(p[1:],s,c,cmin,cmax)
upper = lower.upper()
s = s.translate(str.maketrans({lower:upper + lower}))
c += upper
if u % 10 == 9:
cmin[upper] = 1
cmax[upper] = u // 10
return ret + dfs(p[1:],s,c,cmin,cmax)
if 20 <= u:
cmin[upper] = 1
cmax[upper] = u // 10 - 1
ret += dfs(p[1:],s,c,cmin,cmax)
cmin[lower] = 0
cmax[lower] = u % 10
cmin[upper] = u // 10
cmax[upper] = u // 10
return ret + dfs(p[1:],s,c,cmin,cmax)
def solve(s,c,cmin,cmax):
uf = {ci:-1 for ci in c}
for i in range(len(s) // 2):
join(uf,s[i],s[-i-1])
nmin,nmax = {},{}
for ci in c:
p = root(uf,ci)
try:
nmax[p] = min(nmax[p],cmax[ci])
nmin[p] = max(nmin[p],cmin[ci])
except KeyError:
nmax[p] = cmax[ci]
nmin[p] = cmin[ci]
ret = 1
for p in nmax.keys():
if nmax[p] < nmin[p]:
return 0
ret *= nmax[p] - nmin[p] + 1
return ret
def join(uf,p,q):
p = root(uf,p)
q = root(uf,q)
if p == q:
return
uf[p] += uf[q]
uf[q] = p
def root(uf,p):
if isinstance(uf[p], int):
return p
uf[p] = root(uf,uf[p])
return uf[p]
import sys
f = sys.stdin
_, _ = map(int, f.readline().split())
s = f.readline().strip()
p = [line.split() for line in f]
for pi in p:
pi[1] = int(pi[1])
cmin,cmax = {str(i):i for i in range(10)},{str(i):i for i in range(10)}
characters = '0123456789'
print(dfs(p,s,characters,cmin,cmax) % (10 ** 9 + 7)) | Traceback (most recent call last):
File "/tmp/tmpttp3i7r9/tmpqbclxuq7.py", line 68, in <module>
_, _ = map(int, f.readline().split())
^^^^
ValueError: not enough values to unpack (expected 2, got 0)
| |
s456113901 | p01722 | u939118618 | 1429524150 | Python | Python | py | Runtime Error | 20 | 4384 | 425 | import math
def sieve (n):
prime = [0,0]
prime += [1 for i in range(n-1)]
ub = math.sqrt(n) + 1
d = 2
while d <= ub:
if prime[d] == 0:
d += 1
continue
prod = 2
while d * prod <= n:
prime[d*prod] = 0
prod += 1
d += 1
return prime
n = int(raw_input())
pn = 1
for i in range(n):
pn *= 2
prime = sieve(pn*2)
pn += 1
while 1:
if prime[pn] == 1:
break
pn += 1
print int(format(2**(pn-1)-1, "b")) % pn | File "/tmp/tmpnd5p13z2/tmp48a4wflt.py", line 27
print int(format(2**(pn-1)-1, "b")) % pn
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s416302687 | p01722 | u939118618 | 1429524241 | Python | Python | py | Runtime Error | 20 | 4380 | 425 | import math
def sieve (n):
prime = [0,0]
prime += [1 for i in range(n-1)]
ub = math.sqrt(n) + 1
d = 2
while d <= ub:
if prime[d] == 0:
d += 1
continue
prod = 2
while d * prod <= n:
prime[d*prod] = 0
prod += 1
d += 1
return prime
n = int(raw_input())
pn = 1
for i in range(n):
pn *= 2
prime = sieve(pn*2)
pn += 1
while 1:
if prime[pn] == 1:
break
pn += 1
print int(format(2**(pn-1)-1, "b")) % pn | File "/tmp/tmpz259ozrj/tmpfj4vuo2y.py", line 27
print int(format(2**(pn-1)-1, "b")) % pn
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s562740857 | p01722 | u939118618 | 1429524373 | Python | Python | py | Runtime Error | 10 | 4392 | 427 | import math
def sieve (n):
prime = [0,0]
prime += [1 for i in range(n-1)]
ub = math.sqrt(n) + 1
d = 2
while d <= ub:
if prime[d] == 0:
d += 1
continue
prod = 2
while d * prod <= n:
prime[d*prod] = 0
prod += 1
d += 1
return prime
n = int(raw_input())
pn = 1
for i in range(n):
pn *= 2
prime = sieve(pn*100)
pn += 1
while 1:
if prime[pn] == 1:
break
pn += 1
print int(format(2**(pn-1)-1, "b")) % pn | File "/tmp/tmpo2py8ffx/tmpdy5d3o96.py", line 27
print int(format(2**(pn-1)-1, "b")) % pn
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s400623501 | p01722 | u939118618 | 1429524451 | Python | Python | py | Runtime Error | 10 | 4384 | 426 | import math
def sieve (n):
prime = [0,0]
prime += [1 for i in range(n-1)]
ub = math.sqrt(n) + 1
d = 2
while d <= ub:
if prime[d] == 0:
d += 1
continue
prod = 2
while d * prod <= n:
prime[d*prod] = 0
prod += 1
d += 1
return prime
n = int(raw_input())
pn = 1
for i in range(n):
pn *= 2
prime = sieve(pn*10)
pn += 1
while 1:
if prime[pn] == 1:
break
pn += 1
print int(format(2**(pn-1)-1, "b")) % pn | File "/tmp/tmpbo_5s3qk/tmpmpop8x_f.py", line 27
print int(format(2**(pn-1)-1, "b")) % pn
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s572779317 | p01722 | u823513038 | 1448250506 | Python | Python3 | py | Runtime Error | 0 | 0 | 35 | n=int(input())
print(n?n>3?0:3-n:1) | File "/tmp/tmp9muewrmj/tmpeow_c1c9.py", line 2
print(n?n>3?0:3-n:1)
^
SyntaxError: invalid syntax
| |
s397176132 | p01731 | u633068244 | 1433095836 | Python | Python | py | Runtime Error | 20 | 4356 | 297 | def dfs(i, z):
print "." * z + name[i]
for j in child[i]:
dfs(j, z + 1)
n = int(raw_input())
name = []
child = [[] for i in xrange(n)]
for i in xrange(n):
k = int(raw_input())
m = raw_input()
name.append(m)
if k == 0: continue
child[k - 1].append(i)
dfs(0, 0) | File "/tmp/tmpwnaa5nwk/tmpj_0s3ryu.py", line 2
print "." * z + name[i]
^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s952328585 | p01731 | u633068244 | 1433095879 | Python | Python | py | Runtime Error | 0 | 0 | 335 | import sys
sys.setrecursionlimi(9999)
def dfs(i, z):
print "." * z + name[i]
for j in child[i]:
dfs(j, z + 1)
n = int(raw_input())
name = []
child = [[] for i in xrange(n)]
for i in xrange(n):
k = int(raw_input())
m = raw_input()
name.append(m)
if k == 0: continue
child[k - 1].append(i)
dfs(0, 0) | File "/tmp/tmpolpzxn2i/tmpt7cao2qt.py", line 4
print "." * z + name[i]
^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s291640217 | p01731 | u506554532 | 1514360375 | Python | Python3 | py | Runtime Error | 40 | 5856 | 266 | N = int(input())
src = []
for i in range(N):
k = int(input())
s = input()
src.append((s,[]))
if i == 0: continue
src[k-1][1].append(i)
def dfs(i,depth):
s,ch = src[i]
print('.'*depth + s)
for c in ch:
dfs(c,depth+1)
dfs(0,0) | Traceback (most recent call last):
File "/tmp/tmp5nsyum8_/tmpaxv15hk4.py", line 1, in <module>
N = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s238629497 | p01741 | u633068244 | 1433319737 | Python | Python | py | Runtime Error | 0 | 0 | 169 | import math
d = float(raw_input())
res = math.sqrt(2) * d
for x in xrange(1, 11):
if x * x <= d * d <= x * 2 + 1:
ans = max(ans, d + 1.0)
print "%.10f" % ans | File "/tmp/tmp03z0phtb/tmppi_fss7c.py", line 7
print "%.10f" % ans
^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s927772015 | p01751 | u979136186 | 1478763489 | Python | Python | py | Runtime Error | 0 | 0 | 393 | while True:
a, b, c = map(int, raw_input().split())
if(a | b | c == 0):break
i = 0
canArrive = False
now = 0
while True:
if now <= c and c <= now + b:
canArrive = True
break
now += (a + b)
now %= 60
if now == 0 : break
i += 1
if canArrive:
print c + 60 * i
else:
print -1 | File "/tmp/tmpln_baqbl/tmppy8_ztzs.py", line 22
print c + 60 * i
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s045262134 | p01751 | u136916346 | 1530512185 | Python | Python3 | py | Runtime Error | 0 | 0 | 412 | from itertools import count
a,b,c=map(int,raw_input().split())
g=set()
for n in count(0):
p=(c+60*n)//(a+b)
print (a+b)*p,c+60*n,(a+b)*p+a
if ((a+b)*p-(c+60*n),(c+60*n)-((a+b)*p+a)) in g:
n=-1
break
if (a+b)*p<=c+60*n<=(a+b)*p+a:
break
else:
d=(a+b)*p-(c+60*n)
e=(c+60*n)-((a+b)*p+a)
g.add((d,e))
if n>=0:
print(c+60*n)
else:
print(n)
| Traceback (most recent call last):
File "/tmp/tmp0wyylirb/tmph54x22fx.py", line 2, in <module>
a,b,c=map(int,raw_input().split())
^^^^^^^^^
NameError: name 'raw_input' is not defined
| |
s118525931 | p01755 | u352394527 | 1546560053 | Python | Python3 | py | Runtime Error | 30 | 5792 | 3711 | def parse_prog(prog, pointer, level, code):
while True:
pointer, code = parse_sent(prog, pointer, level, code)
if pointer == len(prog):break
if prog[pointer] in ("]", "}"):break
return pointer + 1, code
def parse_sent(prog, pointer, level, code):
head = prog[pointer]
if head == "[":
pointer, code = parse_if(prog, pointer, level, code)
elif head == "{":
pointer, code = parse_while(prog, pointer, level, code)
else:
pointer, code = parse_behave(prog, pointer, level, code)
return pointer, code
def parse_if(prog, pointer, level, code):
pointer += 1
head = prog[pointer]
cond, pointer = parse_cond(prog, pointer)
code += (" " * level + "if ({}):\n").format(cond)
pointer, code = parse_prog(prog, pointer, level + 1, code)
return pointer, code
def parse_cond(prog, pointer):
head = prog[pointer]
if head == "~":
cond = prog[pointer:pointer+2]
pointer += 2
else:
cond = prog[pointer:pointer+1]
pointer += 1
cond = cond_convert(cond)
return cond, pointer
def parse_while(prog, pointer, level, code):
pointer += 1
cond, pointer = parse_cond(prog, pointer)
tab0 = " " * level
tab1 = tab0 + " "
tab2 = tab1 + " "
code += tab0 + "STATUS += 1\n"
code += tab0 + "while ({}):\n".format(cond)
code += tab1 + "if (STATUS, DIRECT, X, Y) in DIC:\n"
code += tab2 + "print(-1)\n"
code += tab2 + "return -1\n"
code += tab1 + "else:\n"
code += tab2 + "DIC[(STATUS, DIRECT, X, Y)] = True\n"
pointer, code = parse_prog(prog, pointer, level + 1, code)
code += (" " * level + "STATUS -= 1" + "\n")
return pointer, code
def parse_behave(prog, pointer, level, code):
behave = prog[pointer]
behave = convert_behave(behave, level)
code += behave
return pointer + 1, code
def cond_convert(cond):
if cond == "~T":return "False"
if cond == "T": return "True"
ret = ""
if cond[0] == "~":ret += "not "
if cond[-1] in ("N", "E", "S", "W"):
return ret + ("DIRECT == {}").format(cond[-1])
if cond[-1] == "C":
return ret + "FRONT == \"#\""
if cond[-1] == "T":
return ret + "True"
def convert_behave(behave, level):
tab = " " * level
tab2 = tab + " "
ret = ""
ret += tab + "if (X, Y) == (GX, GY):"
ret += "\n" + tab2 + "print(CNT)"
ret += "\n" + tab2 + "return CNT"
if behave == "^":
ret += "\n" + tab + "DX, DY = VEC[DIRECT]"
ret += "\n" + tab + "NX, NY = X + DX, Y + DY"
ret += "\n" + tab + "if MP[NY][NX] != \"#\":"
ret += "\n" + tab2 + "X, Y = NX, NY"
ret += "\n" + tab2 + "FRONT = MP[NY + DY][NX + DX]"
if behave == "v":
ret += "\n" + tab + "DX, DY = VEC[DIRECT]"
ret += "\n" + tab + "NX, NY = X - DX, Y - DY"
ret += "\n" + tab + "if MP[NY][NX] != \"#\":"
ret += "\n" + tab2 + "X, Y = NX, NY"
ret += "\n" + tab2 + "FRONT = MP[NY + DY][NX + DX]"
if behave == ">":
ret += "\n" + tab + "DIRECT = (DIRECT + 1) % 4"
ret += "\n" + tab + "DX, DY = VEC[DIRECT]"
ret += "\n" + tab + "FRONT = MP[Y + DY][X + DX]"
if behave == "<":
ret += "\n" + tab + "DIRECT = (DIRECT - 1) % 4"
ret += "\n" + tab + "DX, DY = VEC[DIRECT]"
ret += "\n" + tab + "FRONT = MP[Y + DY][X + DX]"
ret += "\n" + tab + "CNT += 1\n"
return ret
h, w = map(int, input().split())
MP = [input() for _ in range(h)]
for y in range(h):
for x in range(w):
if MP[y][x] == "s":
X, Y = x, y
FRONT = MP[y - 1][x]
if MP[y][x] == "g":
GX, GY = x, y
DIC = {}
VEC = ((0, -1), (1, 0), (0, 1), (-1, 0))
DIRECT = 0
STATUS = 0
CNT = 0
PROGRAM = "def main(MP, X, Y, GX, GY, FRONT, DIC, VEC, DIRECT, STATUS, CNT):\n" + parse_prog(input(), 0, 1, "")[1] + "main(MP, X, Y, GX, GY, FRONT, DIC, VEC, DIRECT, STATUS, CNT)"
exec(PROGRAM)
| Traceback (most recent call last):
File "/tmp/tmpah1xepag/tmp8kzl7f32.py", line 102, in <module>
h, w = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s018493194 | p01772 | u359169485 | 1434762671 | Python | Python | py | Runtime Error | 0 | 0 | 120 | while True:
d = filter(lambda x:x in "AZ", raw_input())
if len(d)<1:
print "-1"
elif d[-1] == "Z":
print d | File "/tmp/tmp0grwgy5w/tmpudh77sda.py", line 4
print "-1"
^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s955177492 | p01803 | u898097781 | 1467377837 | Python | Python | py | Runtime Error | 0 | 0 | 496 |
def a2c(name):
c = name[0]
boin=['a','i','u','e','o']
for b in name:
if i, b in enumerate(boin[:-1]):
c += name[i+1]
return c
while True:
n = int(raw_input())
if n == 0:
break
names = []
length = -1
for i in xrange(n):
tmp = a2c(raw_input())
names.append(tmp)
length = max(length, len(tmp))
names = set(names)
if len(names) != n:
print -1
continue
for i in xrange(1, length):
s = set([name[:i] for name in names])
if len(set) == n:
print i
break | File "/tmp/tmpcjoobulc/tmpz3umf7w9.py", line 6
if i, b in enumerate(boin[:-1]):
^
SyntaxError: invalid syntax
| |
s582083298 | p01803 | u260980560 | 1501602422 | Python | Python3 | py | Runtime Error | 0 | 0 | 559 | while 1:
n = int(input())
S = []
for i in range(n):
s = input()
b = []
for j in range(len(s)):
if j < 1 or s[j-1] in "aiueo":
b.append(s[j])
S.append(b)
ans = 0
S.sort()
for i in range(n-1):
A = S[i]; B = S[i+1]
if A == B:
print(-1)
break
res = min(len(A), len(B))
for j in range(res):
if A[j] != B[j]:
res = j
break
ans = max(ans, res+1)
else:
print(ans) | Traceback (most recent call last):
File "/tmp/tmpp32t71a3/tmp998unw7l.py", line 2, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s122934191 | p01809 | u606573458 | 1499748826 | Python | Python3 | py | Runtime Error | 0 | 0 | 212 | # -*- coding: utf-8 -*-
import math
p, q = map(int, input().split())
g = math.gcd(p, q)
p, q = p // g, q // g;
ret = q
for b in range(1, 40000):
if b ** 1000 * p % q == 0:
ret = min(ret, b)
print(ret) | Traceback (most recent call last):
File "/tmp/tmp7drlvxfi/tmpgihmdn6x.py", line 3, in <module>
p, q = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s782897080 | p01809 | u606573458 | 1499748847 | Python | Python3 | py | Runtime Error | 0 | 0 | 212 | # -*- coding: utf-8 -*-
import math
p, q = map(int, input().split())
g = math.gcd(p, q)
p, q = p // g, q // g;
ret = q
for b in range(1, 40000):
if b ** 1000 * p % q == 0:
ret = min(ret, b)
print(ret) | Traceback (most recent call last):
File "/tmp/tmp5wiecrzf/tmpu27cgdr1.py", line 3, in <module>
p, q = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s901410179 | p01809 | u606573458 | 1499748906 | Python | Python3 | py | Runtime Error | 0 | 0 | 212 | # -*- coding: utf-8 -*-
import math
p, q = map(int, input().split())
g = math.gcd(p, q)
p, q = p // g, q // g;
ret = q
for b in range(1, 40000):
if b ** 1000 * p % q == 0:
ret = min(ret, b)
print(ret) | Traceback (most recent call last):
File "/tmp/tmpy3lo_gjg/tmpysfaq6z7.py", line 3, in <module>
p, q = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s874413830 | p01809 | u606573458 | 1499748918 | Python | Python | py | Runtime Error | 0 | 0 | 212 | # -*- coding: utf-8 -*-
import math
p, q = map(int, input().split())
g = math.gcd(p, q)
p, q = p // g, q // g;
ret = q
for b in range(1, 40000):
if b ** 1000 * p % q == 0:
ret = min(ret, b)
print(ret) | Traceback (most recent call last):
File "/tmp/tmp65bt4p6s/tmp7hy3tq3b.py", line 3, in <module>
p, q = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s307616922 | p01809 | u606573458 | 1499748991 | Python | Python3 | py | Runtime Error | 0 | 0 | 212 | # -*- coding: utf-8 -*-
import math
p, q = map(int, input().split())
g = math.gcd(p, q)
p, q = p // g, q // g;
ret = q
for b in range(1, 40000):
if b ** 1000 * p % q == 0:
ret = min(ret, b)
print(ret) | Traceback (most recent call last):
File "/tmp/tmpvsllj4t0/tmp_3ar7_1c.py", line 3, in <module>
p, q = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s966096455 | p01809 | u606573458 | 1499749073 | Python | Python3 | py | Runtime Error | 0 | 0 | 181 | import math
p, q = map(int, input().split())
g = math.gcd(p, q)
p //= g
q //= g
ret = q
for b in range(1, 40000):
if b ** 1000 * p % q == 0:
ret = min(ret, b)
print(ret) | Traceback (most recent call last):
File "/tmp/tmpl9xq2yhy/tmpltqhntmo.py", line 2, in <module>
p, q = map(int, input().split())
^^^^^^^
EOFError: EOF when reading a line
| |
s932566079 | p01809 | u314932236 | 1529464707 | Python | Python3 | py | Runtime Error | 0 | 0 | 73 | import math
p = int(input())
q = int(input())
print(b/(math.gcd(p,q)))
| Traceback (most recent call last):
File "/tmp/tmphhibj3sa/tmpcnowwtca.py", line 3, in <module>
p = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s655992491 | p01809 | u314932236 | 1529464757 | Python | Python3 | py | Runtime Error | 0 | 0 | 73 | import math
p = int(input())
q = int(input())
print(q/(math.gcd(p,q)))
| Traceback (most recent call last):
File "/tmp/tmpscktlwmv/tmpst4i7fiu.py", line 3, in <module>
p = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s902350403 | p01809 | u314932236 | 1529465008 | Python | Python3 | py | Runtime Error | 0 | 0 | 78 | import math
p = int(input())
q = int(input())
print(int(q/(math.gcd(p,q))))
| Traceback (most recent call last):
File "/tmp/tmp_frrfv0h/tmpmhdih1pd.py", line 3, in <module>
p = int(input())
^^^^^^^
EOFError: EOF when reading a line
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.