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 |
|---|---|---|---|---|---|---|
input()
n = map(int,input().split())
print(min(n),max(n),sum(n)) | input()
n = list(map(int,input().split()))
print(min(n),max(n),sum(n)) | s915422691 | s072494273 | p02402 | python | Runtime Error |
def factorize(n):
p = n
while True:
if p % 2 == 0:
p //= 2
yield 2
else:
break
for i in range(3,n+1,2):
while True:
if p % i == 0:
p //= i
yield i
else:
break
n = int(input()... | import math
def factorize(p):
l = []
while p % 2 == 0:
p //= 2
l.append(2)
r = 3
while r < int(math.sqrt(p)+1):
if p % r == 0:
p //= r
l.append(r)
else:
r += 2
if p != 1:
l.append(p)
return l
n = int(input())
l = fa... | s179767593 | s631404736 | p02467 | python | Time Limit Exceeded |
def factorize(n):
p = n
while True:
if p % 2 == 0:
p //= 2
yield 2
else:
break
r = 3
while p != 1:
if p % i == 0:
p //= i
yield i
else:
r += 2
n = int(input())
l = factorize(n)
print(str(n)+":",*li... | import math
def factorize(p):
l = []
while p % 2 == 0:
p //= 2
l.append(2)
r = 3
while r < int(math.sqrt(p)+1):
if p % r == 0:
p //= r
l.append(r)
else:
r += 2
if p != 1:
l.append(p)
return l
n = int(input())
l = fa... | s574592047 | s631404736 | p02467 | python | Runtime Error |
def factorize(n):
p = n
while True:
if p % 2 == 0:
p //= 2
yield 2
else:
break
r = 3
while p != 1:
if p % r == 0:
p //= r
yield r
else:
r += 2
n = int(input())
l = factorize(n)
print(str(n)+":",*li... | import math
def factorize(p):
l = []
while p % 2 == 0:
p //= 2
l.append(2)
r = 3
while r < int(math.sqrt(p)+1):
if p % r == 0:
p //= r
l.append(r)
else:
r += 2
if p != 1:
l.append(p)
return l
n = int(input())
l = fa... | s437989197 | s631404736 | p02467 | python | Time Limit Exceeded |
def factorize(n):
p = n
while True:
if p % 2 == 0:
p //= 2
yield 2
else:
break
r = 3
while p >= r:
if p % r == 0:
p //= r
yield r
else:
r += 2
n = int(input())
l = factorize(n)
print(str(n)+":",*li... | import math
def factorize(p):
l = []
while p % 2 == 0:
p //= 2
l.append(2)
r = 3
while r < int(math.sqrt(p)+1):
if p % r == 0:
p //= r
l.append(r)
else:
r += 2
if p != 1:
l.append(p)
return l
n = int(input())
l = fa... | s689372199 | s631404736 | p02467 | python | Time Limit Exceeded |
import scala.io.StdIn.readInt
import scala.collection.mutable.ArrayBuffer
object Main {
def factorize(p:Int,d:Int,l:List[Int]):List[Int] = {
if(d >= Math.sqrt(p)+1) {
if(p != 1) p::l else l
} else {
if(p%d == 0)
factorize(p,d,d::l)
else if(d==2)
factorize(p,d+1,l)
els... | import math
def factorize(p):
l = []
while p % 2 == 0:
p //= 2
l.append(2)
r = 3
while r < int(math.sqrt(p)+1):
if p % r == 0:
p //= r
l.append(r)
else:
r += 2
if p != 1:
l.append(p)
return l
n = int(input())
l = fa... | s504563320 | s631404736 | p02467 | python | Runtime Error |
while True:
n,x = map(int,input().split())
if n==0 and x==0:
break
print( sum( len( range(max(i+1,x-i-n),min(n,(x-i+1)//2)) ) ) for i in range(1,min(n-1,x//3)) ) | import math
def factorize(p):
l = []
while p % 2 == 0:
p //= 2
l.append(2)
r = 3
while r < int(math.sqrt(p)+1):
if p % r == 0:
p //= r
l.append(r)
else:
r += 2
if p != 1:
l.append(p)
return l
n = int(input())
l = fa... | s397005027 | s631404736 | p02467 | python | Runtime Error |
while True:
n,x = map(int,input().split())
if n==0 and x==0:
break
print(sum( [ len(range(max(i+1,x-i-n),min(n,(x-i+1)//2))) for i in range(1,min(n-1,x//3)) ])) | import math
def factorize(p):
l = []
while p % 2 == 0:
p //= 2
l.append(2)
r = 3
while r < int(math.sqrt(p)+1):
if p % r == 0:
p //= r
l.append(r)
else:
r += 2
if p != 1:
l.append(p)
return l
n = int(input())
l = fa... | s091400301 | s631404736 | p02467 | python | Runtime Error |
while True:
n,x = map(int,input().split())
if n==0 and x==0:
break
print(sum( [ len(range(max(i+1,x-i-n),min(n,(x-i+1)//2))) for i in range(1,min(n-1,x//3)) ])) | import math
def factorize(p):
l = []
while p % 2 == 0:
p //= 2
l.append(2)
r = 3
while r < int(math.sqrt(p)+1):
if p % r == 0:
p //= r
l.append(r)
else:
r += 2
if p != 1:
l.append(p)
return l
n = int(input())
l = fa... | s260594481 | s631404736 | p02467 | python | Runtime Error |
n = int(input())
strs = []
for i in range(n):
s = input().split()
if(s[0] == 'insert'):
if(s[1] not in strs):
strs.append(s[1])
else:
if(s[1] in strs):
print('yes')
else:
print('no')
| n = int(input())
strs = {}
for i in range(n):
s = input().split()
if(s[0] == 'insert'):
if(s[1] not in strs):
strs[s[1]] = ''
else:
if(s[1] in strs):
print('yes')
else:
print('no')
| s934874033 | s937299784 | p02269 | python | Time Limit Exceeded |
import math
a = int(input())
print(str("{0:.6f}".format((a * a) * math.pi)) + " " + str("{0:.5f}".format((a + a) * math.pi)))
| import math
a = float(input())
print(str("{0:.6f}".format((a * a) * math.pi)) + " " + str("{0:.5f}".format((a + a) * math.pi)))
| s933999917 | s056239217 | p02400 | python | Runtime Error |
import math
a = int(input())
print(str("{0:.6f}".format((a * a) * math.pi)) + " " + str("{0:.5f}".format((a + a) * math.pi)))
| import math
a = float(input())
print(str("{0:.6f}".format((a * a) * math.pi)) + " " + str("{0:.5f}".format((a + a) * math.pi)))
| s046545002 | s056239217 | p02400 | python | Runtime Error |
#!/usr/bin/python
from fractions import Fraction
import sys
if sys.version_info[0]>=3: raw_input=input
def gauss(a):
if not a or len(a)==0: return None
n=len(a)
for i in range(n):
if a[i][i]==0:
for j in range(i+1,n):
if a[j][i]!=0:
for k in range(i,n+1): a[i][k]+=a[j][k]
break
for j in range(n... | #!/usr/bin/python
from fractions import Fraction
import sys
if sys.version_info[0]>=3: raw_input=input
def gauss(a):
if not a or len(a)==0: return None
n=len(a)
for i in range(n):
if a[i][i]==0:
for j in range(i+1,n):
if a[j][i]!=0:
for k in range(i,n+1): a[i][k]+=a[j][k]
break
else:
retur... | s944689187 | s210168187 | p00115 | python | Runtime Error |
#!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input
n=int(raw_input())
for i in range(0,n):
y,m,d=[int(e) for e in raw_input().split()]
y-=1;m-=1
print(196471-y*195-y//3*5-m*20+(m//2 if y%3!=2 else 0)-a[2]) | import sys
if sys.version_info[0]>=3: raw_input=input
n=int(raw_input())
for i in range(0,n):
a=[int(e) for e in raw_input().split()]
a[0]-=1;a[1]-=1
print(196471-a[0]*195-a[0]//3*5-a[1]*20+(a[1]//2 if a[0]%3!=2 else 0)-a[2]) | s496744180 | s802308022 | p00760 | python | Runtime Error |
import sys
n=int(sys.stdin.readline())
for i in range(0,n):
a=map(int,sys.stdin.readline().split())
a[0]-=1;a[1]-=1
print(196471-a[0]*195-a[0]/3*5-a[1]*20+(a[1]/2 if a[0]%3!=2 else 0)-a[2]) | import sys
if sys.version_info[0]>=3: raw_input=input
n=int(raw_input())
for i in range(0,n):
a=[int(e) for e in raw_input().split()]
a[0]-=1;a[1]-=1
print(196471-a[0]*195-a[0]//3*5-a[1]*20+(a[1]//2 if a[0]%3!=2 else 0)-a[2]) | s759239118 | s802308022 | p00760 | python | Runtime Error |
import sys
if sys.version_info[0]>=3: raw_input=input
n=int(raw_input())
for i in range(0,n):
a=map(int,raw_input())
a[0]-=1;a[1]-=1
print(196471-a[0]*195-a[0]/3*5-a[1]*20+(a[1]/2 if a[0]%3!=2 else 0)-a[2]) | import sys
if sys.version_info[0]>=3: raw_input=input
n=int(raw_input())
for i in range(0,n):
a=[int(e) for e in raw_input().split()]
a[0]-=1;a[1]-=1
print(196471-a[0]*195-a[0]//3*5-a[1]*20+(a[1]//2 if a[0]%3!=2 else 0)-a[2]) | s881294116 | s802308022 | p00760 | python | Runtime Error |
import sys
if sys.version_info[0]>=3: raw_input=input
n=int(raw_input())
for i in range(0,n):
a=map(int,raw_input().split())
a[0]-=1;a[1]-=1
print(196471-a[0]*195-a[0]/3*5-a[1]*20+(a[1]/2 if a[0]%3!=2 else 0)-a[2]) | import sys
if sys.version_info[0]>=3: raw_input=input
n=int(raw_input())
for i in range(0,n):
a=[int(e) for e in raw_input().split()]
a[0]-=1;a[1]-=1
print(196471-a[0]*195-a[0]//3*5-a[1]*20+(a[1]//2 if a[0]%3!=2 else 0)-a[2]) | s521102209 | s802308022 | p00760 | python | Runtime Error |
#!/usr/bin/ruby
from __future__ import print_function
import sys
if sys.version_info[0]>=3: raw_input=input
def insertionSort(a, n, g):
global cnt
for i in range(g,n):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j - g
cnt+=1
a[j+g] = v
def shellSort(a, n):
global cnt
cnt = 0
... | #!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input
def insertionSort(a,g):
global cnt
for i in range(g,len(a)):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j - g
cnt+=1
a[j+g] = v
def shellSort(a):
global cnt
cnt = 0
g = []
h = 1
while h <= len(a):
g... | s264497186 | s118486216 | p02262 | python | Time Limit Exceeded |
#!/usr/bin/ruby
import sys
if sys.version_info[0]>=3: raw_input=input
def insertionSort(a, n, g):
global cnt
for i in range(g,n):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j - g
cnt+=1
a[j+g] = v
def shellSort(a, n):
global cnt
cnt = 0
g = []
h = 1
while h <= n:
g.appe... | #!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input
def insertionSort(a,g):
global cnt
for i in range(g,len(a)):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j - g
cnt+=1
a[j+g] = v
def shellSort(a):
global cnt
cnt = 0
g = []
h = 1
while h <= len(a):
g... | s652277173 | s118486216 | p02262 | python | Time Limit Exceeded |
#!/usr/bin/ruby
import sys
if sys.version_info[0]>=3: raw_input=input
def insertionSort(a, n, g):
global cnt
for i in range(g,n):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j - g
cnt+=1
a[j+g] = v
def shellSort(a, n):
global cnt
cnt = 0
g = []
h = 1
while h <= n:
g.appe... | #!/usr/bin/python
import sys
if sys.version_info[0]>=3: raw_input=input
def insertionSort(a,g):
global cnt
for i in range(g,len(a)):
v = a[i]
j = i - g
while j >= 0 and a[j] > v:
a[j+g] = a[j]
j = j - g
cnt+=1
a[j+g] = v
def shellSort(a):
global cnt
cnt = 0
g = []
h = 1
while h <= len(a):
g... | s041778942 | s118486216 | p02262 | python | Time Limit Exceeded |
for i in range(1,10):$
^Ifor j in range(1,10):$
^I^Iprint i,"*",j,"=",i*j$ | for i in range(1,10):
for j in range(1,10):
print "%dx%d=%d" %(i,j,i*j) | s498572853 | s014793434 | p00000 | python | Runtime Error |
for i in range(1,10):$
for j in range(1,10):$
print i,"*",j,"=",i*j$ | for i in range(1,10):
for j in range(1,10):
print "%dx%d=%d" %(i,j,i*j) | s066607598 | s014793434 | p00000 | python | Runtime Error |
for i in range(1,10):
for j in range(1,10):
print i,"*",j,"=",i*j | for i in range(1,10):
for j in range(1,10):
print "%dx%d=%d" %(i,j,i*j) | s458800281 | s014793434 | p00000 | python | Runtime Error |
import sys
from Config import DB
def add(lis,check_list):
for index in range(len(lis)):
if lis[index][0]==check_list[0]:
lis[index][1]+=int(check_list[1])*int(check_list[2])
return
lis.append([check_list[0],int(check_list[1])*int(check_list[2])])
while True:
num=int(raw_inpu... |
def add(lis,check_list):
for index in range(len(lis)):
if lis[index][0]==check_list[0]:
lis[index][1]+=int(check_list[1])*int(check_list[2])
return
lis.append([check_list[0],int(check_list[1])*int(check_list[2])])
while True:
num=int(raw_input())
if num==0: break
li... | s376558969 | s584543711 | p00100 | python | Runtime Error |
while True:
try:
a, b, c = map(int, input().split(","))
rect_cnt += (a ** 2 + b ** 2 == c ** 2)
dia_cnt += (a == b)
except EOFError:
break
print(rect_cnt)
print(dia_cnt)
| rect_cnt = dia_cnt = 0
while True:
try:
a, b, c = map(int, input().split(","))
rect_cnt += (a ** 2 + b ** 2 == c ** 2)
dia_cnt += (a == b)
except EOFError:
break
print(rect_cnt)
print(dia_cnt)
| s602946666 | s788597542 | p00032 | python | Runtime Error |
#数列に対しy/nの判定をする
def solve(balls):
#B, Cの一番上の数(ただし常にB <= Cを保つ)
last_b = last_c = 0
while balls:
new = balls.pop(0)
#new <= last_b <= last_c --> 不可能
if new <= last_b:
print("NO")
break
#last_b < new <= last_c --> Bを更新
elif new <= last_c:
last_b = new
#la... | #数列に対しy/nの判定をする
def solve(balls):
#B, Cの一番上の数(ただし常にB <= Cを保つ)
last_b = last_c = 0
while balls:
new = balls.pop(0)
#new <= last_b <= last_c --> 不可能
if new <= last_b:
print("NO")
return
#last_b < new <= last_c --> Bを更新
elif new <= last_c:
last_b = new
#l... | s819776589 | s316937564 | p00033 | python | Runtime Error |
MAX = 50001
is_prime = [True for _ in range(MAX)]
is_prime[0] = is_prime[1] = False
for i in range(2, int(MAX ** (1 / 2)) + 1):
if is_prime[i]:
for j in range(i ** 2, MAX, i):
is_prime[j] = False
primes = [i for i in range(MAX) if is_prime[i]]
def main():
while True:
n = int(input())
if not n:
... | MAX = 50001
is_prime = [True for _ in range(MAX)]
is_prime[0] = is_prime[1] = False
for i in range(2, int(MAX ** (1 / 2)) + 1):
if is_prime[i]:
for j in range(i ** 2, MAX, i):
is_prime[j] = False
primes = [i for i in range(MAX) if is_prime[i]]
def main():
while True:
n = int(input())
if not n:
... | s389176751 | s205676037 | p00056 | python | Time Limit Exceeded |
MAX = 50001
is_prime = [True for _ in range(MAX)]
is_prime[0] = is_prime[1] = False
for i in range(2, int(MAX ** (1 / 2)) + 1):
if is_prime[i]:
for j in range(i ** 2, MAX, i):
is_prime[j] = False
primes = [i for i in range(MAX) if is_prime[i]]
def main():
while True:
n = int(input())
if not n:
... | MAX = 50001
is_prime = [True for _ in range(MAX)]
is_prime[0] = is_prime[1] = False
for i in range(2, int(MAX ** (1 / 2)) + 1):
if is_prime[i]:
for j in range(i ** 2, MAX, i):
is_prime[j] = False
primes = [i for i in range(MAX) if is_prime[i]]
def main():
while True:
n = int(input())
if not n:
... | s832880195 | s205676037 | p00056 | python | Runtime Error |
while True:
n = int(input())
if not n:
break
start = int(input()) - 1 #開始の位置
goal = int(input()) - 1 #あたりの位置
d = int(input())
nums = [[i for i in range(n)]] #各段での数字の並び
bars = [] #横棒リスト
for i in range(d):
s = input()
bars.append(s)
new = nums[-1][:]
for j in range(n - 1):
... | while True:
n = int(input())
if not n:
break
start = int(input()) - 1 #開始の位置
goal = int(input()) - 1 #あたりの位置
d = int(input())
nums = [[i for i in range(n)]] #各段での数字の並び
bars = [] #横棒リスト
for i in range(d):
s = input()
bars.append(s)
new = nums[-1][:]
for j in range(n - 1):
... | s789352828 | s701649998 | p00069 | python | Runtime Error |
dic1 = {" ":"101", "'":"000000", ",":"000011", "-":"10010001", "?":"000001",
"A":"100101", "B":"10011010", "C":"0101", "D":"0101", "E":"110",
"F":"01001", "G":"10011011", "H":"010000", "I":"0111", "J":"10011000",
"K":"0110", "L":"00100", "M":"10011001", "N":"10011110", "O":"00101",
"P":"... | dic1 = {" ":"101", "'":"000000", ",":"000011", "-":"10010001", ".":"010001", "?":"000001",
"A":"100101", "B":"10011010", "C":"0101", "D":"0001", "E":"110",
"F":"01001", "G":"10011011", "H":"010000", "I":"0111", "J":"10011000",
"K":"0110", "L":"00100", "M":"10011001", "N":"10011110", "O":"00101",... | s104646328 | s207001136 | p00088 | python | Runtime Error |
dic1 = {" ":"101", "'":"000000", ",":"000011", "-":"10010001", "?":"000001",
"A":"100101", "B":"10011010", "C":"0101", "D":"0101", "E":"110",
"F":"01001", "G":"10011011", "H":"010000", "I":"0111", "J":"10011000",
"K":"0110", "L":"00100", "M":"10011001", "N":"10011110", "O":"00101",
"P":"... | dic1 = {" ":"101", "'":"000000", ",":"000011", "-":"10010001", ".":"010001", "?":"000001",
"A":"100101", "B":"10011010", "C":"0101", "D":"0001", "E":"110",
"F":"01001", "G":"10011011", "H":"010000", "I":"0111", "J":"10011000",
"K":"0110", "L":"00100", "M":"10011001", "N":"10011110", "O":"00101",... | s637385468 | s207001136 | p00088 | python | Runtime Error |
two_dict = {}
for i in range(2001):
two_dict[i] = min(i, 2000 - i) + 1
while True:
try:
n = int(input())
ans = 0
for i in range(n + 1):
ans += two_dict[i] * two_dict[n - i]
print(ans)
except EOFError:
break
| from collections import Counter
pair_dict = Counter()
for i in range(2001):
pair_dict[i] = min(i, 2000 - i) + 1
while True:
try:
n = int(input())
ans = 0
for i in range(n + 1):
ans += pair_dict[i] * pair_dict[n - i]
print(ans)
except EOFError:
break
| s425358622 | s643971612 | p00096 | python | Runtime Error |
from math import gcd
def get_loop(a, m):
count = 1
while a ** count % m != 1:
count += 1
return count
while True:
a1, m1, a2, m2, a3, m3 = map(int, input().split())
if not a1:
break
loop_a = get_loop(a1, m1)
loop_b = get_loop(a2, m2)
loop_c = get_loop(a3, m3)
loop_ab = loop_a * loop_b // gcd... | from math import gcd
def get_loop(a, m):
count = 1
acc = a
while acc != 1:
count += 1
acc *= a
acc %= m
return count
while True:
a1, m1, a2, m2, a3, m3 = map(int, input().split())
if not a1:
break
loop_a = get_loop(a1, m1)
loop_b = get_loop(a2, m2)
loop_c = get_loop(a3, m3)
loop_ab... | s490104695 | s899097678 | p00114 | python | Time Limit Exceeded |
from math import gcd
def get_loop(a, m):
count = 1
acc = a
while acc % m != 1:
count += 1
acc *= a
return count
while True:
a1, m1, a2, m2, a3, m3 = map(int, input().split())
if not a1:
break
loop_a = get_loop(a1, m1)
loop_b = get_loop(a2, m2)
loop_c = get_loop(a3, m3)
loop_ab = loop_a... | from math import gcd
def get_loop(a, m):
count = 1
acc = a
while acc != 1:
count += 1
acc *= a
acc %= m
return count
while True:
a1, m1, a2, m2, a3, m3 = map(int, input().split())
if not a1:
break
loop_a = get_loop(a1, m1)
loop_b = get_loop(a2, m2)
loop_c = get_loop(a3, m3)
loop_ab... | s278318883 | s899097678 | p00114 | python | Time Limit Exceeded |
while True:
h, w = map(int, input().split())
if not h:
break
mp = [list("X" + input() + "X") for _ in range(h)]
mp.insert(0, ["X"] * (w + 2))
mp.append(["X"] * (w + 2))
direct = ((0, 1), (0, -1), (1, 0), (-1, 0))
def search(x, y, target):
mp[y][x] = "X"
for dx, dy in direct:
nx, ny ... | import sys
sys.setrecursionlimit(100000)
while True:
h, w = map(int, input().split())
if not h:
break
mp = [list("X" + input() + "X") for _ in range(h)]
mp.insert(0, ["X"] * (w + 2))
mp.append(["X"] * (w + 2))
direct = ((0, 1), (0, -1), (1, 0), (-1, 0))
def search(x, y, target):
mp[y][x] = ... | s267399255 | s070871703 | p00118 | python | Runtime Error |
from collections import Counter
def func(n):
dic = Counter()
rest = []
for i in range(1, n):
rest.append(i ** 2 % n)
rest = list(set(rest))
rest.sort()
lenr = len(rest)
for i in range(lenr):
for j in range(i + 1, lenr):
x, y = rest[i], rest[j]
if y - x > n // 2:
dic[n - (y ... | import itertools
def func(n):
rest = {i ** 2 % n for i in range(1, n)}
count = [0] * n
for x, y in itertools.combinations(rest, 2):
count[x - y] += 2
for i in range(n // 2):
print(count[i + 1] + count[n - i - 1])
def main():
while True:
n = int(input())
if n == 0:
break
func(n)
... | s391914975 | s961375123 | p00142 | python | Time Limit Exceeded |
from collections import Counter
def func(n):
dic = Counter()
rest = list({i ** 2 % n for i in range(1, n)})
lenr = len(rest)
rest.sort()
half = n // 2
for i in range(lenr):
resti = rest[i]
for j in range(i + 1, lenr):
dff = rest[j] - resti
if dff > half:
dic[n - dff] += 2
... | import itertools
def func(n):
rest = {i ** 2 % n for i in range(1, n)}
count = [0] * n
for x, y in itertools.combinations(rest, 2):
count[x - y] += 2
for i in range(n // 2):
print(count[i + 1] + count[n - i - 1])
def main():
while True:
n = int(input())
if n == 0:
break
func(n)
... | s889143881 | s961375123 | p00142 | python | Time Limit Exceeded |
def primes(n):
tf = [True] * (n + 1)
tf[0] = tf[1] = False
for i in range(2, int(n ** (1 / 2)) + 1):
if tf[i]:
for j in range(i ** 2, n + 1, i):
tf[j] = False
return [i for i in range(n, -1, -1) if tf[i]]
def search_twin(prime_lst):
prime_lst2 = prime_lst[1:]
for x, y in zip(prime_lst, pr... | def primes(n):
tf = [True] * (n + 1)
tf[0] = tf[1] = False
for i in range(2, int(n ** (1 / 2)) + 1):
if tf[i]:
for j in range(i ** 2, n + 1, i):
tf[j] = False
return [i for i in range(n + 1) if tf[i]]
def add_twin(prime_lst, twin_lst):
prime_lst2 = prime_lst[1:]
for x, y in zip(prime_lst,... | s890274653 | s072826237 | p00150 | python | Time Limit Exceeded |
def get_point(info):
info.reverse()
acc = 0
NORMAL, SPARE, STRIKE, DOUBLE = 0, 1, 2, 3
flag = NORMAL
game_num = 0
while info:
if game_num != 9:
down_num1 = info.pop()
if down_num1 != 10:
down_num2 = info.pop()
if flag == SPARE:
acc += down_num1 * 2 + down_num2
... | def get_point(info):
info.reverse()
acc = 0
NORMAL, SPARE, STRIKE, DOUBLE = 0, 1, 2, 3
flag = NORMAL
game_num = 0
while info:
if game_num != 9:
down_num1 = info.pop()
if down_num1 != 10:
down_num2 = info.pop()
if flag == SPARE:
acc += down_num1 * 2 + down_num2
... | s587292230 | s259351046 | p00152 | python | Runtime Error |
end = [1,1,1,1,1]
while True:
n = int(input())
if n == 0:
break
mp = [[0] * 5 for _ in range(4000)]
height = [0] * 5
cnt = 0
for i in range(n):
d, p, q = map(int, input().split())
q -= 1
cnt += p
if d == 1:
pos = max(height[q:q + p])
mp[pos][q:q + p] = [1] * p
if mp[pos... | end = [1,1,1,1,1]
while True:
n = int(input())
if n == 0:
break
mp = [[0] * 5 for _ in range(6000)]
height = [0] * 5
cnt = 0
for i in range(n):
d, p, q = map(int, input().split())
q -= 1
cnt += p
if d == 1:
pos = max(height[q:q + p])
mp[pos][q:q + p] = [1] * p
if mp[pos... | s330881806 | s879726683 | p00178 | python | Runtime Error |
from bisect import bisect_left as bl
def primes(n):
tf = [True] * (n + 1)
tf[0] = tf[1] = False
for i in range(2, int(n ** (1 / 2) + 1)):
if tf[i]:
for j in range(i ** 2, n + 1, i):
tf[j] = False
return [i for i in range(n + 1) if tf[i]]
def search_pair(x, prime_lst):
cnt = 0
for prime in... | from bisect import bisect_left as bl
def primes(n):
tf = [True] * (n + 1)
tf[0] = tf[1] = False
for i in range(2, int(n ** (1 / 2) + 1)):
if tf[i]:
for j in range(i ** 2, n + 1, i):
tf[j] = False
return [i for i in range(n + 1) if tf[i]]
def search_pair(x, prime_lst, len_prime):
cnt = 0
f... | s786495184 | s680162379 | p00185 | python | Runtime Error |
from collections import deque
def out(time, parking):
x = len(parking)
outs1 = []
outs2 = []
for i in range(x):
for j in range(2):
if parking[i][j] != None:
parking[i][j][0] -= time
for i in range(x):
c1 = parking[i][0]
c2 = parking[i][1]
if c1 != None and c2 != None:
i... | from collections import deque
def out(time, parking):
x = len(parking)
outs = []
for i in range(x):
for j in range(2):
if parking[i][j] != None:
parking[i][j][0] -= time
for i in range(x):
c1 = parking[i][0]
c2 = parking[i][1]
if c1 != None and c2 != None:
if c1[0] <= 0 a... | s076779886 | s735225170 | p00192 | python | Runtime Error |
from heapq import heappop as hpop
from heapq import heappush as hpush
while True:
n, m = map(int, input().split())
if not n:
break
cost_edges = [[] for _ in range(m)]
time_edges = [[] for _ in range(m)]
for _ in range(n):
a, b, c, t = map(int, input().split())
cost_edges[a - 1].append((c, ... | from heapq import heappop as hpop
from heapq import heappush as hpush
def main():
while True:
n, m = map(int, input().split())
if not n:
break
cost_edges = [[] for _ in range(m)]
time_edges = [[] for _ in range(m)]
for _ in range(n):
a, b, c, t = map(int, input().split... | s586907530 | s564217775 | p00200 | python | Time Limit Exceeded |
from itertools import combinations
from heapq import heappop, heappush
INF = 10 ** 20
def convert(s, m, n):
if s == "H":
return 0
if s == "D":
return 1
if s[0] == "C":
return int(s[1]) + 1
if s[0] == "L":
return int(s[1]) + m + 1
def get_cost(start, m, n, edges):
cost = [INF] * (m + n + 2)
... | from itertools import combinations
from heapq import heappop, heappush
INF = 10 ** 20
def convert(s, m, n):
if s == "H":
return 0
if s == "D":
return 1
if s[0] == "C":
return int(s[1:]) + 1
if s[0] == "L":
return int(s[1:]) + m + 1
def get_cost(start, m, n, edges):
cost = [INF] * (m + n + 2)... | s247479102 | s508867246 | p00224 | python | Runtime Error |
from itertools import combinations
from heapq import heappop, heappush
import sys
sys.setrecursionlimit(1000000)
INF = 10 ** 20
def convert(s, m, n):
if s == "H":
return 0
if s == "D":
return 1
if s[0] == "C":
return int(s[1]) + 1
if s[0] == "L":
return int(s[1]) + m + 1
def get_cost(start, m,... | from itertools import combinations
from heapq import heappop, heappush
INF = 10 ** 20
def convert(s, m, n):
if s == "H":
return 0
if s == "D":
return 1
if s[0] == "C":
return int(s[1:]) + 1
if s[0] == "L":
return int(s[1:]) + m + 1
def get_cost(start, m, n, edges):
cost = [INF] * (m + n + 2)... | s746751127 | s508867246 | p00224 | python | Runtime Error |
from itertools import combinations
from heapq import heappop, heappush
import sys
sys.setrecursionlimit(1000000)
INF = 10 ** 20
def convert(s, m, n):
if s == "H":
return 0
if s == "D":
return 1
if s[0] == "C":
return int(s[1]) + 1
if s[0] == "L":
return int(s[1]) + m + 1
def get_cost(start, m,... | from itertools import combinations
from heapq import heappop, heappush
INF = 10 ** 20
def convert(s, m, n):
if s == "H":
return 0
if s == "D":
return 1
if s[0] == "C":
return int(s[1:]) + 1
if s[0] == "L":
return int(s[1:]) + m + 1
def get_cost(start, m, n, edges):
cost = [INF] * (m + n + 2)... | s063425437 | s508867246 | p00224 | python | Runtime Error |
from itertools import combinations
from heapq import heappop, heappush
import sys
sys.setrecursionlimit(1000000)
INF = 10 ** 20
def convert(s, m, n):
if s == "H":
return 0
if s == "D":
return 1
if s[0] == "C":
return int(s[1]) + 1
if s[0] == "L":
return int(s[1]) + m + 1
def get_cost(start, m,... | from itertools import combinations
from heapq import heappop, heappush
INF = 10 ** 20
def convert(s, m, n):
if s == "H":
return 0
if s == "D":
return 1
if s[0] == "C":
return int(s[1:]) + 1
if s[0] == "L":
return int(s[1:]) + m + 1
def get_cost(start, m, n, edges):
cost = [INF] * (m + n + 2)... | s615590780 | s508867246 | p00224 | python | Runtime Error |
INF = 10 ** 20
def update_state(state, newx):
tmp = list(state)
tmp[newx] = 1
return tuple(tmp)
def get_co(x, y):
dc = do = 0
score = mp[y][x]
if score < 0:
dc = -score
else:
do = score
return dc, do
def minimum_cost(nowx, nowy, state, ox, goal, dic, w, m):
if (nowx, nowy, state, ox) in dic... | INF = 10 ** 20
def update_state(state, newx):
tmp = list(state)
tmp[newx] = 1
return tuple(tmp)
def get_co(x, y):
dc = do = 0
score = mp[y][x]
if score < 0:
dc = -score
else:
do = score
return dc, do
def minimum_cost(x, y, state, ox, goal, dic, w, m):
if (x, y, state, ox) in dic:
return... | s153451656 | s876661057 | p00234 | python | Runtime Error |
import sys
sys.setrecursionlimit(1000000)
INF = 10 ** 20
def update_state(state, newx):
tmp = list(state)
tmp[newx] = 1
return tuple(tmp)
def get_co(x, y):
dc = do = 0
score = mp[y][x]
if score < 0:
dc = -score
else:
do = score
return dc, do
def minimum_cost(nowx, nowy, state, ox, goal, dic, ... | INF = 10 ** 20
def update_state(state, newx):
tmp = list(state)
tmp[newx] = 1
return tuple(tmp)
def get_co(x, y):
dc = do = 0
score = mp[y][x]
if score < 0:
dc = -score
else:
do = score
return dc, do
def minimum_cost(x, y, state, ox, goal, dic, w, m):
if (x, y, state, ox) in dic:
return... | s888516978 | s876661057 | p00234 | python | Runtime Error |
import sys
sys.setrecursionlimit(1000000)
INF = 10 ** 20
def update_state(state, newx):
tmp = list(state)
tmp[newx] = 1
return tuple(tmp)
def get_co(x, y):
dc = do = 0
score = mp[y][x]
if score < 0:
dc = -score
else:
do = score
return dc, do
def minimum_cost(x, y, state, ox, goal, dic, w, m):... | INF = 10 ** 20
def update_state(state, newx):
tmp = list(state)
tmp[newx] = 1
return tuple(tmp)
def get_co(x, y):
dc = do = 0
score = mp[y][x]
if score < 0:
dc = -score
else:
do = score
return dc, do
def minimum_cost(x, y, state, ox, goal, dic, w, m):
if (x, y, state, ox) in dic:
return... | s168761870 | s876661057 | p00234 | python | Runtime Error |
import sys
sys.setrecursionlimit(1000000)
INF = 10 ** 20
def update_state(state, newx):
tmp = list(state)
tmp[newx] = 1
return tuple(tmp)
def get_co(x, y):
dc = do = 0
score = mp[y][x]
if score < 0:
dc = -score
else:
do = score
return dc, do
def minimum_cost(x, y, state, ox, goal, dic, w, m):... | INF = 10 ** 20
def update_state(state, newx):
tmp = list(state)
tmp[newx] = 1
return tuple(tmp)
def get_co(x, y):
dc = do = 0
score = mp[y][x]
if score < 0:
dc = -score
else:
do = score
return dc, do
def minimum_cost(x, y, state, ox, goal, dic, w, m):
if (x, y, state, ox) in dic:
return... | s596874287 | s876661057 | p00234 | python | Runtime Error |
from collections import Counter
def get_par(x, par_lst):
if x == par_lst[x]:
return x
ret = get_par(par_lst[x], par_lst)
#par_lst[x] = ret
return ret
def main():
while True:
n, m = map(int, input().split())
if n == 0:
break
par_lst = [i for i in range(n)]
counter = Counter()
fla... | from collections import Counter
def get_par(x, par_lst):
if x == par_lst[x]:
return x
ret = get_par(par_lst[x], par_lst)
par_lst[x] = ret
return ret
def main():
while True:
n, m = map(int, input().split())
if n == 0:
break
par_lst = [i for i in range(n)]
counter = [0] * n
flag =... | s654971855 | s312963653 | p00248 | python | Time Limit Exceeded |
while True:
n = input()
if n == "0000":
break
if n.count(n[0]) == 4:
print("NA")
continue
cnt = 0
while n != "6174":
cnt += 1
l = int("".join(sorted(list(str(n)), reverse=True)))
s = int("".join(sorted(list(str(n)))))
n = str(l - s)
print(cnt)
| while True:
n = input()
if n == "0000":
break
if n.count(n[0]) == 4:
print("NA")
continue
cnt = 0
while n != "6174":
cnt += 1
l = "".join(sorted(list(n), reverse=True))
s = "".join(sorted(list(n)))
n = str(int(l) - int(s)).zfill(4)
print(cnt)
| s553938976 | s255348035 | p00254 | python | Time Limit Exceeded |
from heapq import heappush, heappop
INF = 10 ** 20
def search(item_lst):
dp = [[INF] * 101 for _ in range(101)]
dp[0][0] = 0
que = []
heappush(que, (0, 0, 0))
while que:
score, a, e = heappop(que)
for da, de in item_lst[e]:
na, ne = min(d, a + da), min(100, e + de)
if na == d:
prin... | from heapq import heappush, heappop
INF = 10 ** 20
def search(item_lst, d):
visited = {}
visited[(0, 0)] = True
que = []
heappush(que, (0, 0, 0))
while que:
score, a, e = heappop(que)
for da, de in item_lst[e]:
na = a + da
if na >= d:
print(score + 1)
return True
ne ... | s562209480 | s364256115 | p00283 | python | Time Limit Exceeded |
from heapq import heappush, heappop
INF = 10 ** 20
def search(item_lst):
visited = {}
visited[(0, 0)] = True
que = []
heappush(que, (0, 0, 0))
while que:
score, a, e = heappop(que)
for da, de in item_lst[e]:
na, ne = min(d, a + da), min(100, e + de)
if na == d:
print(score + 1)
... | from heapq import heappush, heappop
INF = 10 ** 20
def search(item_lst, d):
visited = {}
visited[(0, 0)] = True
que = []
heappush(que, (0, 0, 0))
while que:
score, a, e = heappop(que)
for da, de in item_lst[e]:
na = a + da
if na >= d:
print(score + 1)
return True
ne ... | s211823513 | s364256115 | p00283 | python | Time Limit Exceeded |
from bisect import bisect_left as bl
n, m, q = map(int, input().split())
lst = [i for i in range(n)]
alst = list(map(int, input().split()))
ind = 0
for a in alst:
if a % 2 == 0:
ind += a
else:
ind -= a
ind = ind % len(lst)
lst.pop(ind)
ind = ind % len(lst)
qlst = list(map(int, input().split()))
for ... | from bisect import bisect_left as bl
n, m, q = map(int, input().split())
lst = [i for i in range(n)]
alst = list(map(int, input().split()))
ind = 0
for a in alst:
if a % 2 == 0:
ind += a
else:
ind -= a
ind = ind % len(lst)
lst.pop(ind)
ind = ind % len(lst)
qlst = list(map(int, input().split()))
for ... | s967423596 | s813805014 | p00296 | python | Runtime Error |
C, n = map(int, input().split())
mp = [input() for _ in range(n)]
diff_dic = set()
def change(x, y):
global diff_dic
if (x, y) in diff_dic:
diff_dic = diff_dic - {(x, y)}
else:
diff_dic = diff_dic | {(x, y)}
for y in range(n // 2):
for x in range(n // 2):
base = mp[y][x]
if mp[y][n - 1 - x] != ... | def main():
C, n = map(int, input().split())
mp = [input() for _ in range(n)]
diff_dic = {}
def change(x, y):
if (x, y) in diff_dic:
diff_dic.pop((x, y))
else:
diff_dic[(x, y)] = True
for y in range(n // 2):
for x in range(n // 2):
base = mp[y][x]
if mp[y][n - 1 - x] != b... | s791700911 | s169097657 | p00315 | python | Time Limit Exceeded |
n = int(input())
alst = list(map(int, input().split()))
edges = [[] for _ in range(n)]
rev_edges = [[] for _ in range(n)]
for i in range(n):
edges[i].append((i + alst[i]) % n)
rev_edges[(i + alst[i]) % n].append(i)
def dfs(x, ret, edges, visited):
visited[x] = True
for e in edges[x]:
if not visited[e]:
... | import sys
sys.setrecursionlimit(1000000)
def dfs(x, order, edges, visited):
visited[x] = True
for e in edges[x]:
if not visited[e]:
dfs(e, order, edges, visited)
order.append(x)
def dfs_rev(x, rev_edges, visited):
visited[x] = True
ret = 0
for e in rev_edges[x]:
if not visited[e]:
ret... | s611200991 | s645560520 | p00344 | python | Runtime Error |
n = int(input())
trs = [int(input()) for _ in range(n)]
cannot = False
visited = [False] * n
visited[0] = True
for i in range(n):
if not visited[i]:
cannot = True
else:
x = min(i + trs[i] // 10, n - 1)
if not visited[x]:
for j in range(i + 1, x + 1):
visited[j] = True
visited = [False] *... | n = int(input())
trs = [int(input()) for _ in range(n)]
cum = []
cannot = False
acc = 0
for i in range(n):
acc = max(acc, i + trs[i] // 10)
acc = min(acc, n - 1)
cum.append(acc)
rev = []
acc = 0
for i in range(n):
acc = max(acc, i + trs[n - 1 - i] // 10)
acc = min(acc, n - 1)
rev.append(acc)
ind = 0
tmp... | s884260770 | s565681486 | p00357 | python | Time Limit Exceeded |
points = [[False for i in range(5001)] for j in range(5001)]
ps = []
for i in range(n):
x, y = map(int,input().split())
points[x][y] = True
ps.append((x,y))
ans = 0
for i in range(n):
for j in range(n):
p1 = ps[i]
p2 = ps[j]
vx = p2[0] - p1[0]
vy = p2[1] - p1[1]
... | def main():
while True:
n = int(input())
if not n:
break
ps = [tuple(map(int,input().split())) for i in range(n)]
dic = set()
for t in ps:
dic.add(t)
ans = 0
for i in range(n):
p1 = ps[i]
p1x = p1[0]
p1y = p1[1]
for j in range(n):
p2 = ps[j]
... | s752628273 | s559988317 | p00441 | python | Runtime Error |
def main():
while True:
n = int(input())
if not n:
break
points = [[False for i in range(5001)] for j in range(5001)]
ps = []
for i in range(n):
x, y = map(int,input().split())
points[x][y] = True
ps.append((x,y))
ans = 0
for i in range(n):
for j in r... | def main():
while True:
n = int(input())
if not n:
break
ps = [tuple(map(int,input().split())) for i in range(n)]
dic = set()
for t in ps:
dic.add(t)
ans = 0
for i in range(n):
p1 = ps[i]
p1x = p1[0]
p1y = p1[1]
for j in range(n):
p2 = ps[j]
... | s649994467 | s559988317 | p00441 | python | Runtime Error |
def main():
while True:
n = int(input())
if not n:
break
points = [[False for i in range(5001)] for j in range(5001)]
ps = []
for i in range(n):
x, y = map(int,input().split())
points[x][y] = True
ps.append((x,y))
ans = 0
for i in range(n):
for j in r... | def main():
while True:
n = int(input())
if not n:
break
ps = [tuple(map(int,input().split())) for i in range(n)]
dic = set()
for t in ps:
dic.add(t)
ans = 0
for i in range(n):
p1 = ps[i]
p1x = p1[0]
p1y = p1[1]
for j in range(n):
p2 = ps[j]
... | s275835153 | s559988317 | p00441 | python | Runtime Error |
def main():
while True:
n = int(input())
if not n:
break
points = [[False for i in range(5001)] for j in range(5001)]
ps = []
for i in range(n):
x, y = map(int,input().split())
points[x][y] = True
ps.append((x,y))
ans = 0
for i in range(n):
for j in r... | def main():
while True:
n = int(input())
if not n:
break
ps = [tuple(map(int,input().split())) for i in range(n)]
dic = set()
for t in ps:
dic.add(t)
ans = 0
for i in range(n):
p1 = ps[i]
p1x = p1[0]
p1y = p1[1]
for j in range(n):
p2 = ps[j]
... | s137514954 | s559988317 | p00441 | python | Runtime Error |
def main():
points = [[False for i in range(5001)] for j in range(5001)]
while True:
n = int(input())
if not n:
break
ps = []
for i in range(n):
x, y = map(int,input().split())
points[x][y] = True
ps.append((x,y))
ans = 0
for i in range(n):
for j in range... | def main():
while True:
n = int(input())
if not n:
break
ps = [tuple(map(int,input().split())) for i in range(n)]
dic = set()
for t in ps:
dic.add(t)
ans = 0
for i in range(n):
p1 = ps[i]
p1x = p1[0]
p1y = p1[1]
for j in range(n):
p2 = ps[j]
... | s620747055 | s559988317 | p00441 | python | Runtime Error |
V, E = int(input()), int(input())
L = []
visited = [0 for i in range(V)]
edges = [[] for i in range(V)]
#flag = 0
def visit(x):
# if visited[x] == 1:
# flag = 1
if not visited[x]:
visited[x] = 1
for e in edges[x]:
visit(e)
L.insert(0,x)
for i in range(E):
s, t = map(int,input().split())
ed... | import sys
sys.setrecursionlimit(100000)
def main():
V, E = int(input()), int(input())
L = []
app = L.append
visited = [0 for i in range(V)]
edges = [[] for i in range(V)]
def visit(x):
if not visited[x]:
visited[x] = 1
for e in edges[x]:
visit(e)
app(x)
for i in range... | s681167086 | s302957812 | p00442 | python | Runtime Error |
sys.setrecursionlimit(100000)
V, E = int(input()), int(input())
L = []
visited = [0 for i in range(V)]
edges = [[] for i in range(V)]
#flag = 0
def visit(x):
# if visited[x] == 1:
# flag = 1
if not visited[x]:
visited[x] = 1
for e in edges[x]:
visit(e)
L.insert(0,x)
for i in range(E):
s, t =... | import sys
sys.setrecursionlimit(100000)
def main():
V, E = int(input()), int(input())
L = []
app = L.append
visited = [0 for i in range(V)]
edges = [[] for i in range(V)]
def visit(x):
if not visited[x]:
visited[x] = 1
for e in edges[x]:
visit(e)
app(x)
for i in range... | s617355658 | s302957812 | p00442 | python | Runtime Error |
from math import gcd
def lcm(i,j):
return i * j // gcd(i,j)
def main():
while True:
n = int(input())
if not n: break
lst = [[]]
weight = [-1 for i in range(n + 1)]
def setWeight(n):
p,q,r,b = lst[n]
if weight[n] != -1:pass
elif r == 0 and b == 0:
weight[n] = (p + q) // ... |
from math import gcd
def lcm(i, j):
return i * j // gcd(i, j)
def main():
while True:
n = int(input())
if not n: break
lst = [[]]
weight = [-1 for i in range(n + 1)]
def setWeight(n):
p, q, r, b = lst[n]
if weight[n] != -1: pass
elif r == 0 and b == 0:
weight[n] = (p +... | s434241720 | s146465314 | p00443 | python | Runtime Error |
from math import gcd
def lcm(i,j):
return i * j // gcd(i,j)
def main():
while True:
n = int(input())
if not n: break
lst = [[]]
weight = [-1 for i in range(n + 1)]
def setWeight(n):
p,q,r,b = lst[n]
if weight[n] != -1:pass
elif r == 0 and b == 0:
weight[n] = (p + q) // ... |
from math import gcd
def lcm(i, j):
return i * j // gcd(i, j)
def main():
while True:
n = int(input())
if not n: break
lst = [[]]
weight = [-1 for i in range(n + 1)]
def setWeight(n):
p, q, r, b = lst[n]
if weight[n] != -1: pass
elif r == 0 and b == 0:
weight[n] = (p +... | s530764103 | s146465314 | p00443 | python | Runtime Error |
from math import gcd
def lcm(i, j):
return i * j // gcd(i, j)
def main():
while True:
n = int(input())
if not n: break
lst = [[]]
weight = [-1 for i in range(n + 1)]
def setWeight(n):
p, q, r, b = lst[n]
if weight[n] != -1: pass
elif r == 0 and b == 0:
weight[n] = (p +... |
from math import gcd
def lcm(i, j):
return i * j // gcd(i, j)
def main():
while True:
n = int(input())
if not n: break
lst = [[]]
weight = [-1 for i in range(n + 1)]
def setWeight(n):
p, q, r, b = lst[n]
if weight[n] != -1: pass
elif r == 0 and b == 0:
weight[n] = (p +... | s570083063 | s146465314 | p00443 | python | Runtime Error |
from math import gcd
def lcm(i, j):
return i * j // gcd(i, j)
def main():
while True:
n = int(input())
if not n: break
lst = [[]]
weight = [-1 for i in range(n + 1)]
def setWeight(n):
p, q, r, b = lst[n]
if weight[n] != -1: pass
elif r == 0 and b == 0:
weight[n] = (p +... |
from math import gcd
def lcm(i, j):
return i * j // gcd(i, j)
def main():
while True:
n = int(input())
if not n: break
lst = [[]]
weight = [-1 for i in range(n + 1)]
def setWeight(n):
p, q, r, b = lst[n]
if weight[n] != -1: pass
elif r == 0 and b == 0:
weight[n] = (p +... | s991084201 | s146465314 | p00443 | python | Runtime Error |
def main()
while True:
m = int(input())
if not m: break
seiza = []
for i in range(m):
seiza.append(list(map(int,input().split())))
kijun = seiza.pop(0)
n = int(input())
hosi = []
point = {}
for i in range(n):
x,y = map(int,input().split())
point[x,y] = 1... | def main():
while True:
m = int(input())
if not m: break
seiza = []
for i in range(m):
seiza.append(list(map(int,input().split())))
kijun = seiza.pop(0)
n = int(input())
hosi = []
point = {}
for i in range(n):
x,y = map(int,input().split())
point[x,y] = ... | s841499843 | s515857105 | p00447 | python | Runtime Error |
while True:
r,c = map(int,input().split())
if not r and not c:
break
lst = []
for i in range(r):
lst.append(list(map(int,input().split())))
def dfs(l,n):
if n == r:
ans = 0
for i in range(c):
count = 0
for j in range(r):
if l[j][i]:
count += 1
... | def f():
while True:
r,c = map(int,input().split())
if not r:
break
lst = [list(map(int,input().split())) for i in range(r)]
dic = [0 for i in range(2 ** r)]
for i in range(c):
num = 0
for j in range(r):
num *= 2
num += lst[j][i]
dic[num] += 1
ans = 0
... | s665637714 | s027429558 | p00448 | python | Time Limit Exceeded |
def main():
while True:
r,c = map(int,input().split())
if not r and not c:
break
lst = []
for i in range(r):
lst.append(list(map(int,input().split())))
def dfs(l,n):
if n == r:
ans = 0
for i in range(c):
count = 0
for j in range(r):
... | def f():
while True:
r,c = map(int,input().split())
if not r:
break
lst = [list(map(int,input().split())) for i in range(r)]
dic = [0 for i in range(2 ** r)]
for i in range(c):
num = 0
for j in range(r):
num *= 2
num += lst[j][i]
dic[num] += 1
ans = 0
... | s616470827 | s027429558 | p00448 | python | Time Limit Exceeded |
#elst...i->j = elst[i]j[]
#vlst...[mincost, ...]
INF = 1000000000
def dyc(n,elst,start,goal):
vlst = [INF for i in range(n)]
ulst = [0 for i in range(n)]
vlst[start] = 0
while True:
v = -1
for i in range(n):
if(ulst[i] == 0 and (v == -1 or vlst[i] < vlst[v])):
v = i
if v == -1:
... | from heapq import heappush,heappop
def dij(s,g,E):
h = []
U = []
heappush(h,(0,s))
while h:
v = heappop(h)
if v[1] == g:
if v[0] >= INF:print(-1)
else:print(v[0])
break
U.append(v[1])
for e in E[v[1]]:
if not e[0] in U:
heappush(h,(v[0] + e[1],e[0]))
else:print... | s529186904 | s160630747 | p00449 | python | Time Limit Exceeded |
INF = 1000000000
while True:
try:
n,k = list(map(int,input().split()))
if n == 0 and k == 0:
break
vlst = [[INF if i != j else 0 for i in range(n)] for j in range(n)]
for i in range(k):
lst = list(map(int,input().split()))
if lst[0] == 0:
if vlst[lst[1] - 1][lst[2] - 1] >= I... | from heapq import heappush,heappop
def dij(s,g,E):
h = []
U = []
heappush(h,(0,s))
while h:
v = heappop(h)
if v[1] == g:
if v[0] >= INF:print(-1)
else:print(v[0])
break
U.append(v[1])
for e in E[v[1]]:
if not e[0] in U:
heappush(h,(v[0] + e[1],e[0]))
else:print... | s607406947 | s160630747 | p00449 | python | Time Limit Exceeded |
INF = 1000000000
while True:
try:
n,k = list(map(int,input().split()))
if n == 0 and k == 0:
break
D = [[INF if i != j else 0 for i in range(n)] for j in range(n)]
for i in range(k):
lst = list(map(int,input().split()))
if lst[0] == 0:
a = min(lst[1],lst[2])
b = max(... | from heapq import heappush,heappop
def dij(s,g,E):
h = []
U = []
heappush(h,(0,s))
while h:
v = heappop(h)
if v[1] == g:
if v[0] >= INF:print(-1)
else:print(v[0])
break
U.append(v[1])
for e in E[v[1]]:
if not e[0] in U:
heappush(h,(v[0] + e[1],e[0]))
else:print... | s034356390 | s160630747 | p00449 | python | Time Limit Exceeded |
INF = 1000000000
while True:
try:
n,k = list(map(int,input().split()))
if n == 0 and k == 0:
break
D = [[INF if i != j else 0 for i in range(j + 1)] for j in range(n)]
for i in range(k):
lst = list(map(int,input().split()))
if lst[0] == 0:
a = min(lst[1],lst[2])
b = ... | from heapq import heappush,heappop
def dij(s,g,E):
h = []
U = []
heappush(h,(0,s))
while h:
v = heappop(h)
if v[1] == g:
if v[0] >= INF:print(-1)
else:print(v[0])
break
U.append(v[1])
for e in E[v[1]]:
if not e[0] in U:
heappush(h,(v[0] + e[1],e[0]))
else:print... | s046594799 | s160630747 | p00449 | python | Time Limit Exceeded |
INF = 1000000000
def solve(s,g,E,n):
D = [INF for i in range(n)]
D[s] = 0
V = [(s,0)]
U = [0 for i in range(n)]
while V:
v = V.pop(0)
U[v[0]] = 1
for e in E[v[0]]:
if U[e[0]] == 0 and D[v[0]] + e[1] < D[e[0]]:
D[e[0]] = D[v[0]] + e[1]
V.append((e[0],D[e[0]]))
V = sor... | from heapq import heappush,heappop
def dij(s,g,E):
h = []
U = []
heappush(h,(0,s))
while h:
v = heappop(h)
if v[1] == g:
if v[0] >= INF:print(-1)
else:print(v[0])
break
U.append(v[1])
for e in E[v[1]]:
if not e[0] in U:
heappush(h,(v[0] + e[1],e[0]))
else:print... | s483454781 | s160630747 | p00449 | python | Time Limit Exceeded |
INF = 1000000000
def solve(s,g,E,n):
D = [INF for i in range(n)]
D[s] = 0
V = [(0,s)]
U = [0 for i in range(n)]
while V:
v = V.pop(0)
U[v[1]] = 1
for e in E[v[1]]:
if U[e[0]] == 0 and D[v[1]] + e[1] < D[e[0]]:
D[e[0]] = D[v[1]] + e[1]
V.append((D[e[0]],e[0]))
V.sort(... | from heapq import heappush,heappop
def dij(s,g,E):
h = []
U = []
heappush(h,(0,s))
while h:
v = heappop(h)
if v[1] == g:
if v[0] >= INF:print(-1)
else:print(v[0])
break
U.append(v[1])
for e in E[v[1]]:
if not e[0] in U:
heappush(h,(v[0] + e[1],e[0]))
else:print... | s199153000 | s160630747 | p00449 | python | Time Limit Exceeded |
INF = 1000000000
def solve(s,g,E,n):
D = [INF for i in range(n)]
D[s] = 0
V = [(0,s)]
while V:
v = V.pop(0)
for e in E[v[1]]:
if D[v[1]] + e[1] < D[e[0]]:
D[e[0]] = D[v[1]] + e[1]
V.append((D[e[0]],e[0]))
V.sort()
if D[g] >= INF:
print(-1)
else:
print(D[g])
... | from heapq import heappush,heappop
def dij(s,g,E):
h = []
U = []
heappush(h,(0,s))
while h:
v = heappop(h)
if v[1] == g:
if v[0] >= INF:print(-1)
else:print(v[0])
break
U.append(v[1])
for e in E[v[1]]:
if not e[0] in U:
heappush(h,(v[0] + e[1],e[0]))
else:print... | s884632295 | s160630747 | p00449 | python | Time Limit Exceeded |
INF = 1000000000
def solve(s,g,E,n):
D = [INF for i in range(n)]
D[s] = 0
V = [s]
while V:
v = V.pop(0)
for e in E[v]:
if D[v] + e[1] < D[e[0]]:
D[e[0]] = D[v] + e[1]
V.append(e[0])
if D[g] >= INF:
print(-1)
else:
print(D[g])
while True:
try:
n,k = list(map... | from heapq import heappush,heappop
def dij(s,g,E):
h = []
U = []
heappush(h,(0,s))
while h:
v = heappop(h)
if v[1] == g:
if v[0] >= INF:print(-1)
else:print(v[0])
break
U.append(v[1])
for e in E[v[1]]:
if not e[0] in U:
heappush(h,(v[0] + e[1],e[0]))
else:print... | s672494790 | s160630747 | p00449 | python | Time Limit Exceeded |
INF = 1000000000
def solve(s,g,E,n):
D = [INF for i in range(n)]
D[s] = 0
U = [0 for i in range(n)]
V = [s]
while V:
v = V.pop(0)
U[v] = 1
if v == g:
break
for e in E[v]:
if U[e[0]] == 0 and D[v] + e[1] < D[e[0]]:
D[e[0]] = D[v] + e[1]
V.append(e[0])
V = sorted(... | from heapq import heappush,heappop
def dij(s,g,E):
h = []
U = []
heappush(h,(0,s))
while h:
v = heappop(h)
if v[1] == g:
if v[0] >= INF:print(-1)
else:print(v[0])
break
U.append(v[1])
for e in E[v[1]]:
if not e[0] in U:
heappush(h,(v[0] + e[1],e[0]))
else:print... | s326205033 | s160630747 | p00449 | python | Time Limit Exceeded |
INF = 1000000000
def solve(s,g,E,n):
D = [0 if i == s else INF for i in range(n)]
U = [0 for i in range(n)]
V = [s]
while V:
v = V.pop(0)
U[v] = 1
if v == g:
break
for e in E[v]:
if not U[e[0]] and D[v] + e[1] < D[e[0]]:
D[e[0]] = D[v] + e[1]
V.append(e[0])
V = s... | from heapq import heappush,heappop
def dij(s,g,E):
h = []
U = []
heappush(h,(0,s))
while h:
v = heappop(h)
if v[1] == g:
if v[0] >= INF:print(-1)
else:print(v[0])
break
U.append(v[1])
for e in E[v[1]]:
if not e[0] in U:
heappush(h,(v[0] + e[1],e[0]))
else:print... | s937298867 | s160630747 | p00449 | python | Time Limit Exceeded |
INF = 1000000000
def solve(s,g,E,n):
D = [0 if i == s else INF for i in range(n)]
U = [0 for i in range(n)]
V = [s]
while V:
v = V.pop(0)
if v == g:
break
for e in E[v]:
if and D[v] + e[1] < D[e[0]]:
D[e[0]] = D[v] + e[1]
V.append(e[0])
V = sorted(V,key=lambda x:D[x]... | from heapq import heappush,heappop
def dij(s,g,E):
h = []
U = []
heappush(h,(0,s))
while h:
v = heappop(h)
if v[1] == g:
if v[0] >= INF:print(-1)
else:print(v[0])
break
U.append(v[1])
for e in E[v[1]]:
if not e[0] in U:
heappush(h,(v[0] + e[1],e[0]))
else:print... | s041523674 | s160630747 | p00449 | python | Runtime Error |
INF = 1000000000
def solve(s,g,E,n):
D = [0 if i == s else INF for i in range(n)]
U = [0 for i in range(n)]
V = [s]
while V:
v = V.pop(0)
if v == g:
break
for e in E[v]:
if D[v] + e[1] < D[e[0]]:
D[e[0]] = D[v] + e[1]
V.append(e[0])
V = sorted(V,key=lambda x:D[x])
... | from heapq import heappush,heappop
def dij(s,g,E):
h = []
U = []
heappush(h,(0,s))
while h:
v = heappop(h)
if v[1] == g:
if v[0] >= INF:print(-1)
else:print(v[0])
break
U.append(v[1])
for e in E[v[1]]:
if not e[0] in U:
heappush(h,(v[0] + e[1],e[0]))
else:print... | s345010766 | s160630747 | p00449 | python | Time Limit Exceeded |
INF = 1000000000
while True:
try:
n,k = list(map(int,input().split()))
if n == 0 and k == 0:
break
D = [[0 if i == j else INF for i in range(n)] for j in range(n)]
for i in range(k):
lst = list(map(int,input().split()))
if lst[0] == 0:
ans = D[lst[1] - 1][lst[2] - 1]
... | from heapq import heappush,heappop
def dij(s,g,E):
h = []
U = []
heappush(h,(0,s))
while h:
v = heappop(h)
if v[1] == g:
if v[0] >= INF:print(-1)
else:print(v[0])
break
U.append(v[1])
for e in E[v[1]]:
if not e[0] in U:
heappush(h,(v[0] + e[1],e[0]))
else:print... | s204882292 | s160630747 | p00449 | python | Time Limit Exceeded |
INF = 1000000000
while True:
try:
n,k = list(map(int,input().split()))
if n == 0 and k == 0:
break
D = [[0 if i == j else INF for i in range(j + 1)] for j in range(n)]
for i in range(k):
lst = list(map(int,input().split()))
if lst[0] == 0:
a = min(lst[1],lst[2])
b = ... | from heapq import heappush,heappop
def dij(s,g,E):
h = []
U = []
heappush(h,(0,s))
while h:
v = heappop(h)
if v[1] == g:
if v[0] >= INF:print(-1)
else:print(v[0])
break
U.append(v[1])
for e in E[v[1]]:
if not e[0] in U:
heappush(h,(v[0] + e[1],e[0]))
else:print... | s585474908 | s160630747 | p00449 | python | Time Limit Exceeded |
INF = 1000000000
while True:
try:
n,k = list(map(int,input().split()))
if n == 0 and k == 0:
break
D = [[0 if i == j else INF for i in range(n)] for j in range(n)]
for i in range(k):
lst = list(map(int,input().split()))
if lst[0] == 0:
ans = D[lst[1] - 1][lst[2] - 1]
... | from heapq import heappush,heappop
def dij(s,g,E):
h = []
U = []
heappush(h,(0,s))
while h:
v = heappop(h)
if v[1] == g:
if v[0] >= INF:print(-1)
else:print(v[0])
break
U.append(v[1])
for e in E[v[1]]:
if not e[0] in U:
heappush(h,(v[0] + e[1],e[0]))
else:print... | s045811013 | s160630747 | p00449 | python | Time Limit Exceeded |
while True:
try:
s1 = input()
s2 = input()
lst = [[1 if s1[i] == s2[j] else 0 for i in range(len(s1))] for j in range(len(s2))]
ans = 0
def search(x,y,count):
while x < len(s2) and y < len(s1) and lst[x][y]:
count += 1
lst[x][y] = 0
x += 1
y += 1
return... | while True:
try:
s1 = input()
except EOFError:
break
s2 = input()
BASE = 27
MOD = 1000000007
def rolling_hash(s):
h_lst = [0]
for c in s:
h_lst.append((h_lst[-1] * BASE + ord(c)) % MOD)
return h_lst
h_lst1 = rolling_hash(s1)
h_lst2 ... | s405990017 | s065156891 | p00451 | python | Time Limit Exceeded |
def solve():
while True:
try:
s1 = input()
s2 = input()
lst = [[1 if s1[i] == s2[j] else 0 for i in range(len(s1))] for j in range(len(s2))]
ans = 0
def search(x,y,count):
while x < len(s2) and y < len(s1) and lst[x][y]:
count += 1
lst[x][y] = 0
... | while True:
try:
s1 = input()
except EOFError:
break
s2 = input()
BASE = 27
MOD = 1000000007
def rolling_hash(s):
h_lst = [0]
for c in s:
h_lst.append((h_lst[-1] * BASE + ord(c)) % MOD)
return h_lst
h_lst1 = rolling_hash(s1)
h_lst2 ... | s177469091 | s065156891 | p00451 | python | Time Limit Exceeded |
def solve():
while True:
try:
s1 = input()
s2 = input()
ans = 0
def search(x,y,count):
while x < len(s1) and y < len(s2) and s1[x] == s2[y]:
count += 1
x += 1
y += 1
return count
for i in range(len(s1)):
for j in range(len(s2)):... | while True:
try:
s1 = input()
except EOFError:
break
s2 = input()
BASE = 27
MOD = 1000000007
def rolling_hash(s):
h_lst = [0]
for c in s:
h_lst.append((h_lst[-1] * BASE + ord(c)) % MOD)
return h_lst
h_lst1 = rolling_hash(s1)
h_lst2 ... | s561520443 | s065156891 | p00451 | python | Time Limit Exceeded |
def search(x,y,s1,s2,end1,end2):
count = 0
while x < end1 and y < end2 and s1[x] == s2[y]:
count += 1
x += 1
y += 1
return count
def solve():
while True:
try:
s1 = input()
s2 = input()
end1 = len(s1)
end2 = len(s2)
ans = 0
for i in range(end1):
for j... | while True:
try:
s1 = input()
except EOFError:
break
s2 = input()
BASE = 27
MOD = 1000000007
def rolling_hash(s):
h_lst = [0]
for c in s:
h_lst.append((h_lst[-1] * BASE + ord(c)) % MOD)
return h_lst
h_lst1 = rolling_hash(s1)
h_lst2 ... | s665170877 | s065156891 | p00451 | python | Time Limit Exceeded |
def search(x,y,s1,s2,end1,end2):
count = 0
while x < end1 and y < end2 and s1[x] == s2[y]:
count += 1
x += 1
y += 1
return count
def solve():
while True:
try:
s1 = input()
s2 = input()
end1 = len(s1)
end2 = len(s2)
dic = dict()
for i in range(end2):
... | while True:
try:
s1 = input()
except EOFError:
break
s2 = input()
BASE = 27
MOD = 1000000007
def rolling_hash(s):
h_lst = [0]
for c in s:
h_lst.append((h_lst[-1] * BASE + ord(c)) % MOD)
return h_lst
h_lst1 = rolling_hash(s1)
h_lst2 ... | s086159533 | s065156891 | p00451 | python | Time Limit Exceeded |
def solve():
while True:
try:
s1 = input()
s2 = input()
end1 = len(s1)
end2 = len(s2)
checked = [[False for i in range(end2)] for j in range (end1)]
dic = {}
def check(i, j):
count = 0
while i < end1 and j < end2 and (not checked[i][j]) and s1[i] == s2[j... | while True:
try:
s1 = input()
except EOFError:
break
s2 = input()
BASE = 27
MOD = 1000000007
def rolling_hash(s):
h_lst = [0]
for c in s:
h_lst.append((h_lst[-1] * BASE + ord(c)) % MOD)
return h_lst
h_lst1 = rolling_hash(s1)
h_lst2 ... | s599368681 | s065156891 | p00451 | python | Time Limit Exceeded |
def solve():
while True:
try:
s1 = input()
s2 = input()
end1 = len(s1)
end2 = len(s2)
checked = [[0 for i in range(len(s2) + 1)] for j in range(len(s1) + 1)]
dic = {}
def check(i, j):
count = 0
while not checked[i][j] and i < end1 and j < end2 and s1[i] =... | while True:
try:
s1 = input()
except EOFError:
break
s2 = input()
BASE = 27
MOD = 1000000007
def rolling_hash(s):
h_lst = [0]
for c in s:
h_lst.append((h_lst[-1] * BASE + ord(c)) % MOD)
return h_lst
h_lst1 = rolling_hash(s1)
h_lst2 ... | s217223607 | s065156891 | p00451 | python | Time Limit Exceeded |
while True:
n,m = map(int,input().split())
if not n and not m: break
lst = []
lst2 = []
for i in range(n):
lst.append(int(input()))
for i in lst:
for j in lst:
lst2.append(i + j)
lst2 = lst2 + lst
lst2.sort()
ans = 0
def search(x, l, r):
y = len(l)
if y == 0:
return r
... | def solve():
while True:
n,m = map(int,input().split())
if not n and not m: break
lst = [int(input()) for _ in range(n)]
lst.append(0)
lst = sorted(lst)
lst2 = [i + j for i in lst for j in lst if i <= j]
lst2 = sorted(lst2)
A = []
index = len(lst2) - 1
for i in lst2:
... | s656279248 | s046553921 | p00452 | python | Time Limit Exceeded |
def solve():
while True:
n,m = map(int,input().split())
if not n and not m: break
lst = []
lst2 = []
for i in range(n):
lst.append(int(input()))
for i in lst:
for j in lst:
lst2.append(i + j)
lst2 = lst2 + lst
lst2.sort()
ans = 0
def search(x, l, r):
y... | def solve():
while True:
n,m = map(int,input().split())
if not n and not m: break
lst = [int(input()) for _ in range(n)]
lst.append(0)
lst = sorted(lst)
lst2 = [i + j for i in lst for j in lst if i <= j]
lst2 = sorted(lst2)
A = []
index = len(lst2) - 1
for i in lst2:
... | s334751535 | s046553921 | p00452 | python | Time Limit Exceeded |
def solve():
while True:
n,m = map(int,input().split())
if not n and not m: break
lst = []
lst2 = []
for i in range(n):
lst.append(int(input()))
for i in lst:
for j in lst:
lst2.append(i + j)
lst2 = list(set(lst2 + lst))
lst2.sort()
ans = 0
def binary(x, lef... | def solve():
while True:
n,m = map(int,input().split())
if not n and not m: break
lst = [int(input()) for _ in range(n)]
lst.append(0)
lst = sorted(lst)
lst2 = [i + j for i in lst for j in lst if i <= j]
lst2 = sorted(lst2)
A = []
index = len(lst2) - 1
for i in lst2:
... | s930141772 | s046553921 | p00452 | python | Time Limit Exceeded |
def solve():
while True:
n,m = map(int,input().split())
if not n and not m: break
lst = []
lst2 = []
for i in range(n):
x = int(input())
if x <= m:
lst.append(x)
lst2 = [i + j for i in lst for j in lst if i <= j]
#for i in lst:
# for j in lst:
# if i + j <= ... | def solve():
while True:
n,m = map(int,input().split())
if not n and not m: break
lst = [int(input()) for _ in range(n)]
lst.append(0)
lst = sorted(lst)
lst2 = [i + j for i in lst for j in lst if i <= j]
lst2 = sorted(lst2)
A = []
index = len(lst2) - 1
for i in lst2:
... | s747339417 | s046553921 | p00452 | python | Time Limit Exceeded |
def solve():
while True:
n,m = map(int,input().split())
if not n and not m: break
lst = []
lst2 = []
lst = [int(input()) for _ in range(n)]
lst.append(0)
lst2 = [i + j for i in lst for j in lst if i <= j]
#for i in lst:
# for j in lst:
# if i + j <= m:
# lst2.appen... | def solve():
while True:
n,m = map(int,input().split())
if not n and not m: break
lst = [int(input()) for _ in range(n)]
lst.append(0)
lst = sorted(lst)
lst2 = [i + j for i in lst for j in lst if i <= j]
lst2 = sorted(lst2)
A = []
index = len(lst2) - 1
for i in lst2:
... | s368872373 | s046553921 | p00452 | python | Time Limit Exceeded |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.