buggy
stringlengths
1
618k
fixed
stringlengths
16
618k
buggy_submission_id
stringlengths
10
10
fixed_submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
lang
stringclasses
1 value
buggy_verdict
stringclasses
2 values
import math r = input() S = r * r * math.pi l = 2 * math.pi * r print("{0:.5f}".format(S),"{0:.5f}".format(l))
import math r = float(input("")) S = r * r * math.pi l = 2 * math.pi * r print("{0:.5f} {1:.5f}".format(S, l))
s552335137
s313225617
p02400
python
Runtime Error
import math r = input() S = r * r * math.pi l = 2 * math.pi * r print("{0:.5f}".format(S, l))
import math r = float(input("")) S = r * r * math.pi l = 2 * math.pi * r print("{0:.5f} {1:.5f}".format(S, l))
s795760162
s313225617
p02400
python
Runtime Error
import math r = int(input("")) S = r * r * math.pi l = 2 * math.pi * r print("{0:.5f}".format(S, l))
import math r = float(input("")) S = r * r * math.pi l = 2 * math.pi * r print("{0:.5f} {1:.5f}".format(S, l))
s955326257
s313225617
p02400
python
Runtime Error
from math import pi r=int(input()) print(r*r*pi,2*r*pi)
import math r = float(input("")) S = r * r * math.pi l = 2 * math.pi * r print("{0:.5f} {1:.5f}".format(S, l))
s698707330
s313225617
p02400
python
Runtime Error
a, op, b = map(int, input().split()) if op == "+": print(a + b) elif op == "-": print(a - b) elif op == "*": print(a * b) else: print(a / b)
while True: a, op, b = map(str, input("").split()) a = int(a) b = int(b) if op == "+": print(a + b) elif op == "-": print(a - b) elif op == "*": print(a * b) elif op == "/": print(a // b) elif op == "?": break
s520192103
s646817287
p02401
python
Runtime Error
a, op, b = map(int, input().split()) if op == "+": print(a + b) elif op == "-": print(a - b) elif op == "*": print(a * b) else: print(a / b)
while True: a, op, b = map(str, input("").split()) a = int(a) b = int(b) if op == "+": print(a + b) elif op == "-": print(a - b) elif op == "*": print(a * b) elif op == "/": print(a // b) elif op == "?": break
s023077395
s646817287
p02401
python
Runtime Error
a, op, b = map(int, input().split()) while True: if op == "+": print(a + b) elif op == "-": print(a - b) elif op == "*": print(a * b) elif: print(a / b) else: break
while True: a, op, b = map(str, input("").split()) a = int(a) b = int(b) if op == "+": print(a + b) elif op == "-": print(a - b) elif op == "*": print(a * b) elif op == "/": print(a // b) elif op == "?": break
s277522071
s646817287
p02401
python
Runtime Error
while True: a, op, b = map(int, input().split()) if op == "+": print(a + b) elif op == "-": print(a - b) elif op == "*": print(a * b) elif: print(a / b) else: break
while True: a, op, b = map(str, input("").split()) a = int(a) b = int(b) if op == "+": print(a + b) elif op == "-": print(a - b) elif op == "*": print(a * b) elif op == "/": print(a // b) elif op == "?": break
s758141857
s646817287
p02401
python
Runtime Error
while True: a, op, b =input().split()) int(a) int(b) if op == "+": print(a + b) elif op == "-": print(a - b) elif op == "*": print(a * b) elif op == "/": print(a / b) else: break
while True: a, op, b = map(str, input("").split()) a = int(a) b = int(b) if op == "+": print(a + b) elif op == "-": print(a - b) elif op == "*": print(a * b) elif op == "/": print(a // b) elif op == "?": break
s870423105
s646817287
p02401
python
Runtime Error
while True: a, op, b =input().split()) int(a) int(b) if op == "+": print(a + b) elif op == "-": print(a - b) elif op == "*": print(a * b) elif op == "/": print(a / b) elif op == "?": break
while True: a, op, b = map(str, input("").split()) a = int(a) b = int(b) if op == "+": print(a + b) elif op == "-": print(a - b) elif op == "*": print(a * b) elif op == "/": print(a // b) elif op == "?": break
s387606733
s646817287
p02401
python
Runtime Error
input() x = [map(int, input().split(' '))] print(min(x)),max(x),sum(x))
input() x = list(map(int,input().split())) print(min(x),max(x),sum(x))
s609337842
s308864597
p02402
python
Runtime Error
input() x = [map(int, input().split(''))] print(min(x),max(x),sum(x))
input() x = list(map(int,input().split())) print(min(x),max(x),sum(x))
s489769045
s308864597
p02402
python
Runtime Error
input("") print(3 6 9 12 13 15 18 21 23 24 27 30)
n = int(input()) result = "" for s in range(1, n+1): if s % 3 == 0: result += " "+str(s) else: for i in str(s): if i == "3": result += " "+str(s) break print(result)
s159121723
s334042244
p02406
python
Runtime Error
count = int(input()) S=H=C=D=S2=H2=C2=D2 =[] while True: if count == 0: break count -= 1 x, y = map(str,input().split()) if x == "S": S.append(y) elif x == "H": H.append(y) elif x == "C": C.append(y) elif x == "D": D.append(y) for i in range(0,13): ...
r=range v=input l=[i+" "+str(j)for i in"SHCD" for j in r(1,14)] for i in r(int(v())):l.remove(v()) for i in l:print(i)
s801980198
s890490126
p02408
python
Runtime Error
cardlist = [[i for i in range(1,13)] for j in range(4)] n = int(input()) for s in range(0, n): x, y = map(str,input().split()) int(y) if x == "S": cardlist[0].remove(y) elif x == "H": cardlist[1].remove(y) elif x == "C": cardlist[2].remove(y) else: cardlist[3].rem...
r=range v=input l=[i+" "+str(j)for i in"SHCD" for j in r(1,14)] for i in r(int(v())):l.remove(v()) for i in l:print(i)
s665446055
s890490126
p02408
python
Runtime Error
cardlist = [[i for i in range(1,13)] for j in range(4)] n = int(input()) for s in range(0, n): x,y = map(str,input().split()) y = int(y) if x == "S": cardlist[0].remove(y) elif x == "H": cardlist[1].remove(y) elif x == "C": cardlist[2].remove(y) else: cardlist[3]....
r=range v=input l=[i+" "+str(j)for i in"SHCD" for j in r(1,14)] for i in r(int(v())):l.remove(v()) for i in l:print(i)
s092605060
s890490126
p02408
python
Runtime Error
r=range v=input l = [[i for i in r(1,14)] for j in r(4)] d={"S":0,"H":1,"C":2,"D":3} n={0:"S",1:"H",2:"C",3:"D"} for i in r(int(v())): x,y = v().split() l[d[x]].remove(int(y)) for i in l: for k in i: print(n[i],k)
r=range v=input l=[i+" "+str(j)for i in"SHCD" for j in r(1,14)] for i in r(int(v())):l.remove(v()) for i in l:print(i)
s564469828
s890490126
p02408
python
Runtime Error
r=range v=input l = [[i for i in r(1,14)] for j in r(4)] d={"S":0,"H":1,"C":2,"D":3} n={0:"S",1:"H",2:"C",3:"D"} for i in r(int(v())): x,y = v().split() l[d[x]].remove(int(y)) for i in l: for k in i: print(n[index(i)],k)
r=range v=input l=[i+" "+str(j)for i in"SHCD" for j in r(1,14)] for i in r(int(v())):l.remove(v()) for i in l:print(i)
s681551203
s890490126
p02408
python
Runtime Error
r=range v=input() l=[i+" "+str(j)for i in"SHCD" for j in r(1,14)] for i in r(int(v):l.remove(v) for i in l:print(i)
r=range v=input l=[i+" "+str(j)for i in"SHCD" for j in r(1,14)] for i in r(int(v())):l.remove(v()) for i in l:print(i)
s108853388
s890490126
p02408
python
Runtime Error
r=range v=input() l=[i+" "+str(j)for i in"SHCD" for j in r(1,14)] for i in r(int(v):l.remove(v)) for i in l:print(i)
r=range v=input l=[i+" "+str(j)for i in"SHCD" for j in r(1,14)] for i in r(int(v())):l.remove(v()) for i in l:print(i)
s393496263
s890490126
p02408
python
Runtime Error
swapcase(input())
print(input().swapcase())
s294199142
s826889276
p02415
python
Runtime Error
list1 = [] while True: x = str(input()) if x == '0': break else: for i in x: result += int(x[i]) list1.append(result) sum(list1)
list1 = [] while True: x = str(input()) if x == '0': break else: result=0 for i in x: result += int(i) list1.append(result) for i in list1: print(i)
s092556015
s908986952
p02416
python
Runtime Error
list1 = [] while True: x = str(input()) if x == '0': break else: for i in x: result += int(i) list1.append(result) sum(list1)
list1 = [] while True: x = str(input()) if x == '0': break else: result=0 for i in x: result += int(i) list1.append(result) for i in list1: print(i)
s057608722
s908986952
p02416
python
Runtime Error
isPrime = [] def init(): for i in range(50000 + 1): isPrime.append(True) def eratos(): isPrime[0] = False isPrime[1] = False for i in range(2, 50000 + 1): for j in range(i * 2, 50000 + 1, i): isPrime[j] = False init() eratos() while True: n = int(input()) if n == 0...
isPrime = [] prime = [] count = [] def init(): for i in range(50000 + 1): isPrime.append(True) count.append(0) def eratos(): isPrime[0] = False isPrime[1] = False for i in range(2, int((50000 ** (1 / 2))) + 1): if (isPrime[i]): for j in range(i * 2, 50000 + 1, i): ...
s913097391
s507386617
p00056
python
Time Limit Exceeded
isPrime = [] prime = [] import math def init(): for i in range(50000 + 1): isPrime.append(True) def eratos(): isPrime[0] = False isPrime[1] = False for i in range(2, int(math.sqrt(50000)) + 1): if (isPrime[i]): for j in range(i * 2, 50000 + 1, i): isPrime[j...
isPrime = [] prime = [] count = [] def init(): for i in range(50000 + 1): isPrime.append(True) count.append(0) def eratos(): isPrime[0] = False isPrime[1] = False for i in range(2, int((50000 ** (1 / 2))) + 1): if (isPrime[i]): for j in range(i * 2, 50000 + 1, i): ...
s572516626
s507386617
p00056
python
Time Limit Exceeded
x = raw_input() x = x**3 print x
x=input() x=x**3 print x
s330352146
s764634792
p02388
python
Runtime Error
function Main(input) { for(i=1;i<10;i++){ for(j=1;j<10;j++){ console.log("%dx%d=%d",i,j,i*j); } } } //input Main(require("fs").readFileSync("/dev/stdin", "utf8"));
for i in xrange(81):print "{}x{}={}".format(i/9+1,i%9+1,(i/9+1)*(i%9+1))
s058367766
s392045293
p00000
python
Runtime Error
for(i=1;i<10;i++){ for(j=1;j<10;j++){ console.log("%dx%d=%d",i,j,i*j); } }
for i in xrange(81):print "{}x{}={}".format(i/9+1,i%9+1,(i/9+1)*(i%9+1))
s208475567
s392045293
p00000
python
Runtime Error
import sys n=10**5 s=[True]*n s[0]=False s[1]=False for x in xrange(2, int(n**0.5)+1): if s[x]: for i in xrange(x+x,n,x): s[i]=False for x in sys.stdin.readlines(): x=int(x) cnt=0 for i in xrange(x): if s[i]: cnt=cnt+1 print cnt
import sys n=10**6 p=[1]*n p[0],p[1]=0,0 for i in xrange(2,int(n**0.5)+1): if p[i]==1: for j in xrange(i**2,n,i): p[j]=0 for i in xrange(2,n): p[i]+=p[i-1] for line in sys.stdin.readlines(): print p[int(line)]
s991199099
s554388598
p00009
python
Runtime Error
import sys n=10**5 s=[True]*n s[0]=False s[1]=False for x in xrange(2, int(n**0.5)+1): if s[x]: for i in xrange(x+x,n,x): s[i]=False for x in sys.stdin.readlines(): a=int(x) cnt=0 for i in xrange(a): if s[i]: cnt=cnt+1 print cnt
import sys n=10**6 p=[1]*n p[0],p[1]=0,0 for i in xrange(2,int(n**0.5)+1): if p[i]==1: for j in xrange(i**2,n,i): p[j]=0 for i in xrange(2,n): p[i]+=p[i-1] for line in sys.stdin.readlines(): print p[int(line)]
s477330240
s554388598
p00009
python
Runtime Error
import sys n=10**5+1 s=[True]*n s[0]=False s[1]=False for x in xrange(2, int(n**0.5)+1): if s[x]: for i in xrange(x+x,n,x): s[i]=False for x in sys.stdin.readlines(): a=int(x) cnt=0 for i in xrange(a): if s[i]: cnt=cnt+1 print cnt
import sys n=10**6 p=[1]*n p[0],p[1]=0,0 for i in xrange(2,int(n**0.5)+1): if p[i]==1: for j in xrange(i**2,n,i): p[j]=0 for i in xrange(2,n): p[i]+=p[i-1] for line in sys.stdin.readlines(): print p[int(line)]
s417080556
s554388598
p00009
python
Runtime Error
import sys n=10**5 p=[1]*n p[0],p[1]=0,0 for i in xrange(2,int(n**0.5)+1): if p[i]==1: for j in xrange(i**2,n,i): p[j]=0 for i in xrange(2,n): p[i]+=p[i-1] for line in sys.stdin.readlines(): print p[int(line)]
import sys n=10**6 p=[1]*n p[0],p[1]=0,0 for i in xrange(2,int(n**0.5)+1): if p[i]==1: for j in xrange(i**2,n,i): p[j]=0 for i in xrange(2,n): p[i]+=p[i-1] for line in sys.stdin.readlines(): print p[int(line)]
s273490293
s554388598
p00009
python
Runtime Error
import sys for line in sys.stdin: list=map(float,line.split()) x=list[0:6:2] y=list[1:6:2] xp=list[6] yp=list[7] xv=[x[a%3]-x[(a+1)%3] for a in xrange(4)] yv=[y[a%3]-y[(a+1)%3] for a in xrange(4)] xpv=[xp-x[a] for a in xrange(3)] ypv=[yp-y[a] for a in xrange(3)] cross=[xv[i]*ypv[...
import sys for line in sys.stdin.readlines(): try: list=map(float,line.split()) x=list[0:6:2] y=list[1:6:2] xp=list[6] yp=list[7] xv=[x[a%3]-x[(a+1)%3] for a in xrange(4)] yv=[y[a%3]-y[(a+1)%3] for a in xrange(4)] xpv=[xp-x[a] for a in xrange(3)] ...
s012715801
s397190043
p00012
python
Runtime Error
import sys for line in sys.stdin.readlines(): list=map(float,line.split()) x=list[0:6:2] y=list[1:6:2] xp=list[6] yp=list[7] xv=[x[a%3]-x[(a+1)%3] for a in xrange(4)] yv=[y[a%3]-y[(a+1)%3] for a in xrange(4)] xpv=[xp-x[a] for a in xrange(3)] ypv=[yp-y[a] for a in xrange(3)] cross...
import sys for line in sys.stdin.readlines(): try: list=map(float,line.split()) x=list[0:6:2] y=list[1:6:2] xp=list[6] yp=list[7] xv=[x[a%3]-x[(a+1)%3] for a in xrange(4)] yv=[y[a%3]-y[(a+1)%3] for a in xrange(4)] xpv=[xp-x[a] for a in xrange(3)] ...
s079557232
s397190043
p00012
python
Runtime Error
import sys for line in sys.stdin.readlines(): list=map(float,line.split(" ")) x=list[0:6:2] y=list[1:6:2] xp=list[6] yp=list[7] xv=[x[a%3]-x[(a+1)%3] for a in xrange(4)] yv=[y[a%3]-y[(a+1)%3] for a in xrange(4)] xpv=[xp-x[a] for a in xrange(3)] ypv=[yp-y[a] for a in xrange(3)] cr...
import sys for line in sys.stdin.readlines(): try: list=map(float,line.split()) x=list[0:6:2] y=list[1:6:2] xp=list[6] yp=list[7] xv=[x[a%3]-x[(a+1)%3] for a in xrange(4)] yv=[y[a%3]-y[(a+1)%3] for a in xrange(4)] xpv=[xp-x[a] for a in xrange(3)] ...
s055599028
s397190043
p00012
python
Runtime Error
import sys stack=[] for i in sys.stdin: a=int(i) if a >0 : stack.append(a) else : print stack.pop()
import sys stack=[] for i in sys.stdin: try: a=int(i) if a >0 : stack.append(a) else : print stack.pop() except: pass
s174292492
s685765914
p00013
python
Runtime Error
# -*- coding: utf-8 -*- import sys stack=[] for i in sys.stdin: a=int(i.split('\n')[0]) if a >0 : stack.append(a) else : print stack.pop()
import sys stack=[] for i in sys.stdin: try: a=int(i) if a >0 : stack.append(a) else : print stack.pop() except: pass
s551204634
s685765914
p00013
python
Runtime Error
while True: a=map(int,raw_input().split()) if not a:break b=map(int,raw_input().split()) hit,blow=0,0 for i in range(4): if a[i]==b[i]:hit+=1 if a[i] in b :blow+=1 print hit,blow-hit
import sys line=sys.stdin.readlines() for A,B in zip(line[0::2],line[1::2]): a=map(int,A.strip().split()) b=map(int,B.strip().split()) hit,blow=0,0 for i in xrange(4): if a[i]==b[i]:hit+=1 elif a[i] in b : blow+=1 print hit,blow
s016175755
s975239913
p00025
python
Runtime Error
case=0 while True: case+=1 W=input() if W==0:break print "Case {}:".format(case) dp=[0]*1000 w=[0]*1000 v=[0]*1000 n=input() for i in xrange(n): v[i],w[i]=map(int,raw_input().strip().split(",")) for i in xrange(n): for j in xrange(W,-1,-1): if j+w[i]<=...
case=0 while True: case+=1 W=input() if W==0:break print "Case {}:".format(case) dp=[0]*1001 w=[0]*1001 v=[0]*1001 n=input() for i in xrange(n): v[i],w[i]=map(int,raw_input().strip().split(",")) for i in xrange(n): for j in xrange(W,-1,-1): if j+w[i]<=...
s909005656
s350144300
p00042
python
Runtime Error
n=5*10**4 p=[True]*n p[0],p[1]=False,False for i in xrange(2,int(n**0.5)+1): if p[i]==True: for j in xrange(i**2,n,i): p[j]=False while True: n=input() if n==0:break for i in xrange(n/2+1): if p[i] and p[n-i]:c+=1 print c
import itertools N=50000+1 p=[True]*N p[0],p[1]=False,False for i in xrange(2,int(N**0.5)+1): if p[i]==True: for j in xrange(i**2,N,i): p[j]=False plist=[i for i in xrange(N) if p[i]] c=[0]*N*2 for i,j in itertools.combinations(plist,2): c[i+j]+=1 for i in xrange(N): if p[i]:c[i+i]+=1 wh...
s131703709
s224446895
p00056
python
Runtime Error
n=5*10**4 p=[True]*n p[0],p[1]=False,False for i in xrange(2,int(n**0.5)+1): if p[i]==True: for j in xrange(i**2,n,i): p[j]=False while True: n=input() if n==0:break c=0 for i in xrange(n/2+1): if p[i] and p[n-i]:c+=1 print c
import itertools N=50000+1 p=[True]*N p[0],p[1]=False,False for i in xrange(2,int(N**0.5)+1): if p[i]==True: for j in xrange(i**2,N,i): p[j]=False plist=[i for i in xrange(N) if p[i]] c=[0]*N*2 for i,j in itertools.combinations(plist,2): c[i+j]+=1 for i in xrange(N): if p[i]:c[i+i]+=1 wh...
s828391027
s224446895
p00056
python
Time Limit Exceeded
N=5000+1 p=[True]*N p[0],p[1]=False,False for i in xrange(2,int(N**0.5)+1): if p[i]==True: for j in xrange(i**2,N,i): p[j]=False c=[0]*N for i in xrange(N): for j in xrange(i/2+1): if p[j] and p[i-j]:c[i]+=1 while True: n=input() if n==0:break print c[n]
import itertools N=50000+1 p=[True]*N p[0],p[1]=False,False for i in xrange(2,int(N**0.5)+1): if p[i]==True: for j in xrange(i**2,N,i): p[j]=False plist=[i for i in xrange(N) if p[i]] c=[0]*N*2 for i,j in itertools.combinations(plist,2): c[i+j]+=1 for i in xrange(N): if p[i]:c[i+i]+=1 wh...
s137158815
s224446895
p00056
python
Runtime Error
N=50000+1 p=[True]*N p[0],p[1]=False,False for i in xrange(2,int(N**0.5)+1): if p[i]==True: for j in xrange(i**2,N,i): p[j]=False while True: n=input() if n==0:break c=0 for i in xrange(n/2+1): if p[i] and p[n-i]:c+=1 print c
import itertools N=50000+1 p=[True]*N p[0],p[1]=False,False for i in xrange(2,int(N**0.5)+1): if p[i]==True: for j in xrange(i**2,N,i): p[j]=False plist=[i for i in xrange(N) if p[i]] c=[0]*N*2 for i,j in itertools.combinations(plist,2): c[i+j]+=1 for i in xrange(N): if p[i]:c[i+i]+=1 wh...
s000433688
s224446895
p00056
python
Time Limit Exceeded
while True: n=input() if n==0: break m,goal,d=input(),input(),input() step=[""]*d for i in xrange(d): step[i]=raw_input() raw=range(1,n+1) for i in xrange(d): for j in xrange(n-1): if step[i][j]=="1": raw[j],raw[j+1]=raw[j+1],raw[j] ans...
while True: n=input() if n==0: break m,goal,d=input(),input(),input() step=[""]*d for i in xrange(d): step[i]="0"+raw_input()+"0" raw=range(n+2) for i in xrange(d): for j in xrange(1,n+1): if step[i][j]=="1": raw[j],raw[j+1]=raw[j+1],raw[j]...
s117478207
s296062933
p00069
python
Runtime Error
while True: n=input() if n==0: break m,goal,d=input(),input(),input() step=[""]*d for i in xrange(d): step[i]="0"+raw_input()+"0" raw=range(n+2) for i in xrange(d): for j in xrange(1,n+1): if step[i][j]=="1": raw[j],raw[j+1]=raw[j+1],raw[j]...
while True: n=input() if n==0: break m,goal,d=input(),input(),input() step=[""]*d for i in xrange(d): step[i]="0"+raw_input()+"0" raw=range(n+2) for i in xrange(d): for j in xrange(1,n+1): if step[i][j]=="1": raw[j],raw[j+1]=raw[j+1],raw[j]...
s801120737
s296062933
p00069
python
Runtime Error
import sys,itertools for line in sys.stdin.readlines(): n,s=map(int,line.strip().split()) count=0 for c in itertools.permutations(xrange(10),n): total=0 for i in xrange(1,n+1): total+=i*c[i-1] if total==s: count+=1 print count
import sys dp=[[[0]*331 for i in xrange((1<<10)+1)] for j in xrange(12)] #dp[12][1025][331] dp[0][0][0]=1 for i in xrange(10): for j in xrange(1<<10): for c in xrange(331): if dp[i][j][c]==0: continue for k in xrange(10): if (j>>k&1)==0: ...
s166323477
s148194763
p00070
python
Time Limit Exceeded
import sys,itertools for line in sys.stdin.readlines(): n,s=map(int,line.strip().split()) count=0 for c in itertools.permutations(xrange(10),n): total=0 for i in xrange(1,n+1): if total>s:break total+=i*c[i-1] if total==s: count+=1 print count
import sys dp=[[[0]*331 for i in xrange((1<<10)+1)] for j in xrange(12)] #dp[12][1025][331] dp[0][0][0]=1 for i in xrange(10): for j in xrange(1<<10): for c in xrange(331): if dp[i][j][c]==0: continue for k in xrange(10): if (j>>k&1)==0: ...
s948202248
s148194763
p00070
python
Time Limit Exceeded
import sys dp=[[[0]*341 for i in xrange((1<<10)+1)] for j in xrange(12)] #dp[12][1025][340] dp[0][0][0]=1 for i in xrange(10): for j in xrange(1<<10): for c in xrange(331): if dp[i][j][c]==0: continue for k in xrange(10): if (j>>k&1)==0: ...
import sys dp=[[[0]*331 for i in xrange((1<<10)+1)] for j in xrange(12)] #dp[12][1025][331] dp[0][0][0]=1 for i in xrange(10): for j in xrange(1<<10): for c in xrange(331): if dp[i][j][c]==0: continue for k in xrange(10): if (j>>k&1)==0: ...
s300743153
s148194763
p00070
python
Runtime Error
import sys,math for line in sys.stdin.readlines(): line=raw_input() x1,y1,x2,y2,xq,yq=map(float,line.strip().split(",")) L=((x1-x2)**2+(y1-y2)**2)**0.5 t=math.atan2(y2-y1,x2-x1) R1=((x1-xq)**2+(y1-yq)**2)**0.5 R2=((x2-xq)**2+(y2-yq)**2)**0.5 a=math.acos((L*L+R1*R1-R2*R2)/(2*L*R1)) x,y=x1...
import sys for line in sys.stdin.readlines(): x1,y1,x2,y2,xq,yq=map(float,line.strip().split(",")) if x1==x2: x,y=-xq+2*x1,yq elif y1==y2: x,y=xq,-yq+2*y1 else: m=(y1-y2)/(x1-x2) n=-m*x1+y1 x=(2*yq*m-2*m*n+xq-m*m*xq)/(m*m+1) y=(xq-x)/m+yq print "{:.6f}...
s320726807
s245022706
p00081
python
Runtime Error
import sys for line in sys.stdin.readlines(): x1,y1,x2,y2,xq,yq=map(float,line.strip().split(",")) if x1==x2: x,y=-xq+2*x1,yq elif y1==y2: x,y=xq,-yq+2*y1 else: m=(y1-y2)/(x1-x2) n=-m*x1+y1 x,y= (2*yq*m-2*m*n+xq-m*m*xq)/(m*m+1),(xq-x)/m+yq; print "{:.6f} {:.6f...
import sys for line in sys.stdin.readlines(): x1,y1,x2,y2,xq,yq=map(float,line.strip().split(",")) if x1==x2: x,y=-xq+2*x1,yq elif y1==y2: x,y=xq,-yq+2*y1 else: m=(y1-y2)/(x1-x2) n=-m*x1+y1 x=(2*yq*m-2*m*n+xq-m*m*xq)/(m*m+1) y=(xq-x)/m+yq print "{:.6f}...
s274250418
s245022706
p00081
python
Runtime Error
def f(n,k): return 0 if n==0 else (f(n-1,k)+k)%n while True: n,k=map(int,raw_input().strip().split()) if (n,k)==(0,0): break print f(n,k)+1
def f(n,k): return 0 if n==1 else (f(n-1,k)+k)%n while True: n,k=map(int,raw_input().strip().split()) if (n,k)==(0,0): break print f(n,k)+1
s617405635
s866212470
p00085
python
Runtime Error
from calendar import isleap f = lambda x: map(str, x) if x else ["NA"] ans = [] while True: a, b = map(int, raw_input().split()) if b == 0: break ans += f(filter(isleap, xrange(a, b+1))) + [""] print("\n".join(ans).strip())
ans=[] while True: a,b=map(int,raw_input().split()) if (a,b)==(0,0): break t=[y for y in xrange(a,b+1) if (y%4==0 and not y%100==0) or y%400==0] if not t: ans.append("NA") else: ans.append("\n".join(map(str,t))) print "\n\n".join(ans).strip()
s788163978
s228665655
p00093
python
Runtime Error
from calendar import isleap f = lambda x: map(str, x) if x else ["NA"] ans = [] while True: a, b = map(int, input().split()) if b == 0: break ans += f(filter(isleap, range(a, b+1))) + [""] print("\n".join(ans).strip())
ans=[] while True: a,b=map(int,raw_input().split()) if (a,b)==(0,0): break t=[y for y in xrange(a,b+1) if (y%4==0 and not y%100==0) or y%400==0] if not t: ans.append("NA") else: ans.append("\n".join(map(str,t))) print "\n\n".join(ans).strip()
s890180512
s228665655
p00093
python
Runtime Error
T = 1000 memo = [[0] * (2 * T + 1) for _ in range(3)] #Java: int[][] memo = new int[3][2*T+1]; memo[0][0] = 1 for i in range(1,3): for j in range(i*T+1): memo[i][j] = sum([memo[i-1][k] for k in range(max(0,j-T),j+1)]) while True: try: n = input() except EOFError: break cnt = 0...
T = 1000 def f(x): return max(0, T + 1 - abs(T - x)) while True: try: n = input() except EOFError: break cnt = 0 for i in range(n+1): cnt += f(i) * f(n-i) print cnt #O(n),
s901074949
s146798690
p00096
python
Time Limit Exceeded
from itertools import combinations_with_replacement n = input() sq = [map(int,raw_input().split()) for u in xrange(n)] s_sq =[[0]*(n+1) for u in xrange(n+1)] ma = sq[0][0] for i in xrange(n): for ii in xrange(n): s_sq[i][ii] = sq[i][ii] + s_sq[i][ii-1] + s_sq[i-1][ii] - s_sq[i-1][ii-1] for tx,bx in combinat...
n = input() sq = [map(int,raw_input().split()) for u in xrange(n)] s_sq = [[[0]*n for u in xrange(n)] for uu in xrange(n)] #s_sq[lower_end][left_end][right_end] ma = -1000 * 100 * 100 for y in xrange(n): temp = [0] * (n+1) for x in xrange(n): #make sum of the sequence left_end == 0, right_end == n ...
s713366115
s138870706
p00098
python
Time Limit Exceeded
import sys for line in sys.stdin.readlines(): a="NA" for i in xrange(10): exp,ans=line.strip().replace("X",str(i)).split("=") if eval(exp)==int(ans): a=i print a
import sys for line in sys.stdin.readlines(): exp = line.strip() ans = "NA" # 1<=X<10 for i in xrange(1,10): filled_exp = exp.replace("X",str(i)) left,right = filled_exp.split("=") a,b = left.split("+") if int(a)+int(b) == int(right): ans = i # X==0 fi...
s766732677
s708955988
p00110
python
Runtime Error
while True: H,W = map(int, raw_input().split(" ")) if (H,W) == (0,0): break field = [raw_input() for _ in xrange(H)] space = [[0]*(W+1) for _ in xrange(H)] for x in xrange(W-1,-1,-1): for y in xrange(H): if field[y][x]==".": space[y][x] = space[y][x+1]+1 ...
def re_push(stack,num):#re_push and return max count = 0 pre = num ma = 0 while True: count += 1 cur = stack.pop() if cur <= num: ma = max(ma,(count-1) * pre) stack += [cur] stack += [num]*(count-1) break if cur < pre: ...
s880770232
s637300944
p00116
python
Time Limit Exceeded
while True: H,W = map(int, raw_input().split(" ")) if (H,W) == (0,0): break field = [raw_input() for _ in xrange(H)] space = [[0]*(W+1) for _ in xrange(H)] for x in xrange(W-1,-1,-1): for y in xrange(H): if field[y][x]==".": space[y][x] = space[y][x+1]+1 ...
def re_push(stack,num):#re_push and return max count = 0 pre = num ma = 0 while True: count += 1 cur = stack.pop() if cur <= num: ma = max(ma,(count-1) * pre) stack += [cur] stack += [num]*(count-1) break if cur < pre: ...
s387046497
s637300944
p00116
python
Time Limit Exceeded
def solve(field,H,W): space = [[0]*(W+1) for _ in xrange(H)] for x in xrange(W-1,-1,-1): for y in xrange(H): if field[y][x]==".": space[y][x] = space[y][x+1]+1 ans = 0 for x in xrange(W): for y in (yy for yy in xrange(H) if field[y][x] == "."): fo...
def re_push(stack,num):#re_push and return max count = 0 pre = num ma = 0 while True: count += 1 cur = stack.pop() if cur <= num: ma = max(ma,(count-1) * pre) stack += [cur] stack += [num]*(count-1) break if cur < pre: ...
s577279190
s637300944
p00116
python
Time Limit Exceeded
class Rect(): def __init__(self, x_range, y_range): self.x_range = x_range self.y_range = y_range @property def w(self): return len(self.x_range) @property def h(self): return len(self.y_range) def __str__(self): return "Rect({},{})".format...
def re_push(stack,num):#re_push and return max count = 0 pre = num ma = 0 while True: count += 1 cur = stack.pop() if cur <= num: ma = max(ma,(count-1) * pre) stack += [cur] stack += [num]*(count-1) break if cur < pre: ...
s062615462
s637300944
p00116
python
Time Limit Exceeded
from collections import deque def ge(H,W): q = deque([(0,0)]) while q: x,y = q.popleft() yield (x,y) if y == 0 and x+1 < W: q.append([x+1,y]) if y+1 < H: q.append([x,y+1]) def solve(field,H,W): space = [[0]*(W+1) for _ in xrange(H)] for x in xrang...
def re_push(stack,num):#re_push and return max count = 0 pre = num ma = 0 while True: count += 1 cur = stack.pop() if cur <= num: ma = max(ma,(count-1) * pre) stack += [cur] stack += [num]*(count-1) break if cur < pre: ...
s459150755
s637300944
p00116
python
Time Limit Exceeded
class Rect(): def __init__(self, x_range, y_range): self.x_range = x_range self.y_range = y_range @property def w(self): return len(self.x_range) @property def h(self): return len(self.y_range) def __str__(self): return "Rect({},{})".format...
def re_push(stack,num):#re_push and return max count = 0 pre = num ma = 0 while True: count += 1 cur = stack.pop() if cur <= num: ma = max(ma,(count-1) * pre) stack += [cur] stack += [num]*(count-1) break if cur < pre: ...
s365961694
s637300944
p00116
python
Runtime Error
def cut(squares): ret = [] for s in squares: for i,r in enumerate(ret): if s[0] >= r[0] and s[1] >= r[1]:#replace ret[i] = s break if s[0] <= r[0] and s[1] <= r[1]:#remove break else: ret.append(s)#append ret...
def re_push(stack,num):#re_push and return max count = 0 pre = num ma = 0 while True: count += 1 cur = stack.pop() if cur <= num: ma = max(ma,(count-1) * pre) stack += [cur] stack += [num]*(count-1) break if cur < pre: ...
s968727413
s637300944
p00116
python
Time Limit Exceeded
from heapq import heappush,heappop MOVE = [[1,4],[0,2,5],[1,3,6],[2,7],[0,5],[1,4,6],[2,5,7],[3,6]] GOAL = "01234567" def h(field): ret = 0 for p,n in enumerate(map(int,field)): ret += dist(p,n) return ret def dist(num,place): return abs(num%4-place%4)+(num/5+place/5)%2 #width+height def swa...
# -*- coding: utf-8 -*- #与えられるパズルの数は1000以下です MOVE = [[1,4],[0,2,5],[1,3,6],[2,7],[0,5],[1,4,6],[2,5,7],[3,6]] ans = {"01234567":0} def swap(field,a,b): tmp = list(field) tmp[a],tmp[b] = tmp[b],tmp[a] return "".join(tmp) def BFS(): global ans q = [[0,"01234567"]] while len(q) != 0: g, fi...
s777173556
s064394584
p00121
python
Time Limit Exceeded
decode = ["afkpuz", "bglqv.", "chmrw?", "dinsx!", "ejoty "] while True: try: line = raw_input() except EOFError: break if len(line)%2 == 1: print "NA" continue try: print "".join(decode[j-1][i-1] for i,...
decode = ["afkpuz", "bglqv.", "chmrw?", "dinsx!", "ejoty "] while True: try: line = map(int,list(raw_input())) except EOFError: break if len(line)%2 == 1 or 0 in line: print "NA" continue try: print "".join(decode[j-1][i-1] ...
s585654578
s708596216
p00127
python
Runtime Error
def dfs(l, r): if (l, r) in cache: return cache[(l, r)] if l == r: return 0 return min(dfs(l, m) + dfs(m + 1, r) + L[l][1] * L[m][0] * L[m + 1][1] * L[m + 1][0] for m in xrange(l, r)) cache = {} L = [map(int, raw_input().split()) for _ in xrange(input())] print dfs(0, len(L) - 1)
def dfs(l, r): if l == r: return 0 if (l, r) in cache: return cache[(l, r)] cache[(l, r)] = min(dfs(l, m) + dfs(m + 1, r) + L[l][0] * L[m][1] * L[m + 1][0] * L[r][1] for m in xrange(l, r)) return cache[(l, r)] cache = {} L = [map(int, raw_input().split()) for _ in xrange(input())] print...
s958155305
s882690687
p00145
python
Time Limit Exceeded
#Lupin The 4th: O(2^n) def f(a, b, visited): w = W[visited] * 20 return abs(lengths[a] - lengths[b]) * (70 + w) def solve(): cache = dict([((i, 0), (0, [i])) for i in xrange(n)]) def dfs(top, visited): if (top, visited) in cache: return cache[(top, visited)] ret = (1 << 30, ...
#Lupin The 4th: O(2^n) def f(a, b, visited): w = W[visited] * 20 return float(abs(lengths[a] - lengths[b])) / (2000. / (70 + w)) def solve(): cache = dict([((i, 0), (0., [i])) for i in xrange(n)]) def dfs(top, visited): if (top, visited) in cache: return cache[(top, visited)] ...
s912087491
s239687577
p00146
python
Runtime Error
from bisect import bisect,bisect_left from fractions import gcd MAXN = 1000002 T = 2**20*3**14*5**9 H = filter(lambda i:gcd(T,i)==i,xrange(MAXN)) while True: line = raw_input() if line == "0": break m,n = map(int,line.split()) print bisect(H,n)-bisect_left(H,m)
from bisect import bisect_left S = [60,80,100,120,140,160] W = [2,5,10,15,20,25] F = [600,800,1000,1200,1400,1600,0] def func(x,y,h,w): return F[max(bisect_left(S,x+y+h),bisect_left(W,w))] while True: n = input() if n == 0: break print sum(func(*map(int,raw_input().split())) for _ in xrange(n))
s285140021
s435436274
p00160
python
Runtime Error
from bisect import bisect D = range(10,61,10) while True: n = input() if n == 0: break A = [0]*7 for _ in xrange(n): A[bisect(D,input())] += 1 print "\n".join(map(str,A))
while True: n = input() if n == 0: break A = [0]*7 for _ in xrange(n): A[min(int(raw_input())/10,6)] += 1 print "\n".join(map(str,A))
s656770846
s607510865
p00184
python
Time Limit Exceeded
while True: n = input() if n == 0: break A = [0]*7 for _ in xrange(n): A[min(input()/10,6)] += 1 print "\n".join(map(str,A))
while True: n = input() if n == 0: break A = [0]*7 for _ in xrange(n): A[min(int(raw_input())/10,6)] += 1 print "\n".join(map(str,A))
s737033619
s607510865
p00184
python
Time Limit Exceeded
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
s842612108
s730717083
p00193
python
Runtime Error
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
s280286225
s730717083
p00193
python
Runtime Error
D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue cover[y][x] = step...
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
s831656792
s730717083
p00193
python
Runtime Error
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
s213547597
s730717083
p00193
python
Runtime Error
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
s663745440
s730717083
p00193
python
Runtime Error
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0 and len(q) <= (10 ** 5): y, x, step = q.pop(0) if cover[y][x] >= 0: ...
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
s465131873
s730717083
p00193
python
Runtime Error
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0 and len(q) <= (10 ** 3): y, x, step = q.pop(0) if cover[y][x] >= 0: ...
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
s938521084
s730717083
p00193
python
Runtime Error
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] return cover while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: ...
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
s430958620
s730717083
p00193
python
Runtime Error
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] return cover while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: ...
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
s111522687
s730717083
p00193
python
Runtime Error
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] return cover while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: ...
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
s633746211
s730717083
p00193
python
Runtime Error
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
s340393940
s730717083
p00193
python
Runtime Error
#Deven-Eleven: import re p = re.compile("\d+\s\d+") D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y]...
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
s897709501
s730717083
p00193
python
Runtime Error
#Deven-Eleven: import re D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: conti...
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
s070521774
s730717083
p00193
python
Runtime Error
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
s500031220
s730717083
p00193
python
Runtime Error
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
#Deven-Eleven: D = (((-1, -1), (0, -1), (1, 0), (0, 1), (-1, 1), (-1, 0)), ((0, -1), (1, -1), (1, 0), (1, 1), (0, 1), (-1, 0))) def func(y, x): q = [(y, x, 0)] cover = [[-1] * m for _ in xrange(n)] while len(q) != 0: y, x, step = q.pop(0) if cover[y][x] >= 0: continue ...
s120287770
s730717083
p00193
python
Runtime Error
while True: n = input() if n == 0: break dic = {} for _ in xrange(n): name, cost = raw_input().split() dic[name] = int(cost) for _ in xrange(input()): items = raw_input().split() dic[items[0]] = min(dic[items[0]], sum(map(lambda x:dic[x], items[2:]))) prin...
INF = 1 << 29 while True: n = input() if n == 0: break dic = {} for _ in xrange(n): name, cost = raw_input().split() dic[name] = int(cost) m = input() recipe = [] for _ in xrange(m): data = raw_input().split() if data[1] <= 0: m -= 1 ...
s699171988
s191860445
p00201
python
Runtime Error
while True: n = input() if n == 0: break dic = {} for _ in xrange(n): name, cost = raw_input().split() dic[name] = int(cost) for _ in xrange(input()): items = raw_input().split() if items[1] == 0: continue dic[items[0]] = min(dic[items[0]],...
INF = 1 << 29 while True: n = input() if n == 0: break dic = {} for _ in xrange(n): name, cost = raw_input().split() dic[name] = int(cost) m = input() recipe = [] for _ in xrange(m): data = raw_input().split() if data[1] <= 0: m -= 1 ...
s480452056
s191860445
p00201
python
Runtime Error
while True: n = input() if n == 0: break dic = {} for _ in xrange(n): name, cost = raw_input().split() dic[name] = int(cost) for _ in xrange(input()): items = raw_input().split() if items[1] == 0: continue if items[0] not in dic: ...
INF = 1 << 29 while True: n = input() if n == 0: break dic = {} for _ in xrange(n): name, cost = raw_input().split() dic[name] = int(cost) m = input() recipe = [] for _ in xrange(m): data = raw_input().split() if data[1] <= 0: m -= 1 ...
s730113808
s191860445
p00201
python
Runtime Error
while True: n = input() if n == 0: break dic = {} for _ in xrange(n): name, cost = raw_input().split() dic[name] = int(cost) m = input() recipe = [] for _ in xrange(m): data = raw_input().split() recipe.append([data[0]]+data[2:]) for _ in xrange(m)...
INF = 1 << 29 while True: n = input() if n == 0: break dic = {} for _ in xrange(n): name, cost = raw_input().split() dic[name] = int(cost) m = input() recipe = [] for _ in xrange(m): data = raw_input().split() if data[1] <= 0: m -= 1 ...
s148616566
s191860445
p00201
python
Runtime Error
while True: n = input() if n == 0: break dic = {} for _ in xrange(n): name, cost = raw_input().split() dic[name] = int(cost) m = input() recipe = [] for _ in xrange(m): data = raw_input().split() if data[1] <= 0: m -= 1 continue...
INF = 1 << 29 while True: n = input() if n == 0: break dic = {} for _ in xrange(n): name, cost = raw_input().split() dic[name] = int(cost) m = input() recipe = [] for _ in xrange(m): data = raw_input().split() if data[1] <= 0: m -= 1 ...
s305973862
s191860445
p00201
python
Runtime Error
def main(): while True: line = raw_input().split() if line[0] == "0": break N = int(line[0]) s = line[1:] while len(s) < N: s += raw_input().split() original = make_graph(s) line = raw_input().split() M = int(line[0]) t ...
def main(): while True: line = raw_input().split() while line == []: line = raw_input().split() if line[0] == "0": break N = int(line[0]) s = line[1:] while len(s) < N: s += raw_input().split() original = make_graph(s) ...
s756727005
s492192491
p00694
python
Time Limit Exceeded
from copy import deepcopy answer = "" while True: line = raw_input() while line.isspace() or not line: #!?!?!!! line = raw_input() if line == "0": break P, S = map(int, line.split()) def check(data): return reduce(lambda a, b: a+b, data).count("?") def calc(seq): ...
import sys from copy import deepcopy def check(data): return reduce(lambda a, b: a+b, data).count("?") def calc(seq): if "?" not in seq or not(0 <= seq.count("?") <= 1) : return seq if seq[-1] == "?": return seq[:-1] + sum(seq[:-1]) a = seq[-1] - sum(s for s in seq[:-1] if s != "?") ...
s112134907
s794791239
p00698
python
Runtime Error
from fractions import Fraction def solve(p, q, a, n): def _solve(f, n, m, s): if f < 0 or m > a or n < 0: return 0 if f == 0: return 1 return sum((_solve(f-Fraction(1, i), n-1, m*i, i) for i in range(s, a//m+1)), 0) return _solve(Fraction(p, q), n, 1, 1) ...
from functools import lru_cache @lru_cache(maxsize=1<<10) def solve(p, q, a, n): def _solve(num, dem, d, m, s): if num == 0: return 1 if d == 0: return 0 if num * a // m < dem: return 0 return sum((_solve(num*i-dem, dem*i, d-1, m*i, i) ...
s076287601
s987005429
p00712
python
Time Limit Exceeded
def solve(p, q, a, n): def _solve(num, dem, d, m, s): if p * dem == q * num: return 1 if p * dem < q * num or d == 0 or dem * s ** d > a: return 0 if p * dem * s - num * q * s > d * q * dem: return 0 return sum((_solve(num*i+dem, dem*i, d-1, m*i, i...
from functools import lru_cache @lru_cache(maxsize=1<<10) def solve(p, q, a, n): def _solve(num, dem, d, m, s): if num == 0: return 1 if d == 0: return 0 if num * a // m < dem: return 0 return sum((_solve(num*i-dem, dem*i, d-1, m*i, i) ...
s363675384
s987005429
p00712
python
Time Limit Exceeded
from functools import lru_cache from fractions import Fraction @lru_cache(maxsize=1<<10) def solve(p, q, a, n): def _solve(f, d, m, s): if f == 0: return 1 if d == 0: return 0 if f < Fraction(1, a//m): return 0 return sum((_solve(f-Fraction(1, i),...
from functools import lru_cache @lru_cache(maxsize=1<<10) def solve(p, q, a, n): def _solve(num, dem, d, m, s): if num == 0: return 1 if d == 0: return 0 if num * a // m < dem: return 0 return sum((_solve(num*i-dem, dem*i, d-1, m*i, i) ...
s643340096
s987005429
p00712
python
Time Limit Exceeded
from collections import defaultdict from fractions import gcd INF = 2 << 30 MAX_V = 1002 G = [[] for _ in xrange(MAX_V)] visited = [False]*MAX_V def add_edge(fro, to, cap): G[fro].append([to,cap,len(G[to])]) G[to].append([fro,0,len(G[fro])-1]) def dfs(v,t,f): global visited if v == t: return ...
from fractions import gcd V = 1001 G = [] visited = [] match = [] def add_edge(u,v): G[u].append(v) G[v].append(u) def dfs(v): visited[v] = True for u in G[v]: w = match[u] if w < 0 or not visited[w] and dfs(w): match[v] = u match[u] = v return True...
s536641198
s879503584
p00744
python
Runtime Error
from collections import defaultdict from fractions import gcd INF = 2 << 30 MAX_V = 1003 G = [[] for _ in xrange(MAX_V)] visited = [False]*MAX_V def add_edge(fro, to, cap): G[fro].append([to,cap,len(G[to])]) G[to].append([fro,0,len(G[fro])-1]) def dfs(v,t,f): global visited if v == t: return ...
from fractions import gcd V = 1001 G = [] visited = [] match = [] def add_edge(u,v): G[u].append(v) G[v].append(u) def dfs(v): visited[v] = True for u in G[v]: w = match[u] if w < 0 or not visited[w] and dfs(w): match[v] = u match[u] = v return True...
s197023854
s879503584
p00744
python
Runtime Error
from collections import defaultdict from fractions import gcd INF = 2 << 30 MAX_V = 1002 G = [[] for _ in xrange(MAX_V)] visited = [False]*MAX_V def add_edge(fro, to, cap): G[fro].append([to,cap,len(G[to])]) G[to].append([fro,0,len(G[fro])-1]) def dfs(v,t,f): global visited if v == t: return ...
from fractions import gcd V = 1001 G = [] visited = [] match = [] def add_edge(u,v): G[u].append(v) G[v].append(u) def dfs(v): visited[v] = True for u in G[v]: w = match[u] if w < 0 or not visited[w] and dfs(w): match[v] = u match[u] = v return True...
s432972109
s879503584
p00744
python
Runtime Error
from collections import defaultdict from fractions import gcd INF = 2 << 30 MAX_V = 1002 G = [[] for _ in xrange(MAX_V)] visited = [False]*MAX_V def add_edge(fro, to, cap): G[fro].append([to,cap,len(G[to])]) G[to].append([fro,0,len(G[fro])-1]) def dfs(v,t,f): global visited if v == t: return ...
from fractions import gcd V = 1001 G = [] visited = [] match = [] def add_edge(u,v): G[u].append(v) G[v].append(u) def dfs(v): visited[v] = True for u in G[v]: w = match[u] if w < 0 or not visited[w] and dfs(w): match[v] = u match[u] = v return True...
s347629347
s879503584
p00744
python
Runtime Error
from fractions import gcd INF = 2 << 30 V = 1003 G = [[] for _ in xrange(V)] visited = [False]*V def add_edge(fro, to, cap): G[fro].append([to,cap,len(G[to])]) G[to].append([fro,0,len(G[fro])-1]) def dfs(v,t,f): if v == t: return f visited[v] = True for i,(to,cap,rev) in enumerate((G[v]))...
from fractions import gcd V = 1001 G = [] visited = [] match = [] def add_edge(u,v): G[u].append(v) G[v].append(u) def dfs(v): visited[v] = True for u in G[v]: w = match[u] if w < 0 or not visited[w] and dfs(w): match[v] = u match[u] = v return True...
s577296836
s879503584
p00744
python
Runtime Error