s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1 value | original_language stringclasses 11 values | filename_ext stringclasses 1 value | status stringclasses 1 value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s111525273 | p00042 | u019169314 | 1527996936 | Python | Python3 | py | Runtime Error | 0 | 0 | 1116 | case = 0
while True:
W = int(input())
if W == 0:
break
N = int(input())
case += 1
# a list of [itemValue, itemWeight]
items = [list(map(int,input().split(','))) for i in range(N)]
dp = {}
def bestVW(item, capa):
if (item,capa) in dp:
return dp[(item,capa)]
elif item == 0:
bestVWForCapa = items[item] if items[item][1] <= capa else [0,0]
dp[(item,capa)] = bestVWForCapa
return bestVWForCapa
else:
if items[item][1] > capa:
bestVWForCapa = bestVW(item-1, capa)
dp[(item,capa)] = bestVWForCapa
return bestVWForCapa
else:
pickedVW = bestVW(item-1,capa)
notPickedVW = list(map(sum, zip(items[item], bestVW(item-1, capa-items[item][1]))))
bestVWForCapa = pickedVW if pickedVW[0] > notPickedVW[0] else notPickedVW
dp[(item,capa)] = bestVWForCapa
return bestVWForCapa
msg = 'Case '+case+':\n'
print(msg)
print('\n'.join(map(str,bestVW(N-1,W))))
|
s497587343 | p00042 | u019169314 | 1527997057 | Python | Python3 | py | Runtime Error | 20 | 5616 | 1120 | case = 0
while True:
W = int(input())
if W == 0:
break
N = int(input())
case += 1
# a list of [itemValue, itemWeight]
items = [list(map(int,input().split(','))) for i in range(N)]
dp = {}
def bestVW(item, capa):
if (item,capa) in dp:
return dp[(item,capa)]
elif item == 0:
bestVWForCapa = items[item] if items[item][1] <= capa else [0,0]
dp[(item,capa)] = bestVWForCapa
return bestVWForCapa
else:
if items[item][1] > capa:
bestVWForCapa = bestVW(item-1, capa)
dp[(item,capa)] = bestVWForCapa
return bestVWForCapa
else:
pickedVW = bestVW(item-1,capa)
notPickedVW = list(map(sum, zip(items[item], bestVW(item-1, capa-items[item][1]))))
bestVWForCapa = pickedVW if pickedVW[0] > notPickedVW[0] else notPickedVW
dp[(item,capa)] = bestVWForCapa
return bestVWForCapa
msg = "Case "+str(case)+":"
print(msg)
print('\n'.join(map(str,bestVW(N-1,W))))
|
s909005656 | p00042 | u647766105 | 1356490433 | Python | Python | py | Runtime Error | 10 | 4284 | 422 | 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]<=W:
dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i])
print max(dp)
print dp.index(max(dp)) |
s466099884 | p00042 | u104911888 | 1365033286 | Python | Python | py | Runtime Error | 0 | 0 | 525 | num=1
maxw=input()
while maxw<>0:
N=input()
ws,ps=[],[]
for i in range(N):
tmp=input()
ws.append(tmp[1])
ps.append(tmp[0])
dp=[[0]*(maxw+1) for i in range(len(ws)+1)]
ret=0
for i in range(len(ws)):
for j in range(maxw+1):
if (j+ws[i])<=maxw:
dp[i+1][j+ws[i]]=max(dp[i+1][j+ws[i]],dp[i][j]+ps[i])
ret=max(dp[i+1][j+ws[i]],ret)
print "Case %d:"%num
print ret
print dp[len(ws)].index(ret)
num+=1
maxw=input() |
s725835884 | p00042 | u104911888 | 1365034666 | Python | Python | py | Runtime Error | 0 | 0 | 525 | num=1
while True:
maxw=input()
if maxw==0:break
N=input()
ws,ps=[0]*N,[0]*N
for i in xrange(N):
ps[i],ws[i]=map(int,raw_input().strip().split(","))
dp=[[0]*(maxw+1) for i in range(len(ws)+1)]
ret=0
for i in range(len(ws)):
for j in range(maxw+1):
if (j+ws[i])<=maxw:
dp[i+1][j+ws[i]]=max(dp[i+1][j+ws[i]],dp[i][j]+ps[i])
ret=max(dp[i+1][j+ws[i]],ret)
print "Case %d:"%num
print ret
print dp[len(ws)].index(ret)
num+=1 |
s339135834 | p00042 | u104911888 | 1365034733 | Python | Python | py | Runtime Error | 0 | 0 | 533 | num=1
while True:
maxw=input()
if maxw==0:break
N=input()
ws,ps=[0]*N,[0]*N
for i in xrange(N):
ps[i],ws[i]=map(int,raw_input().strip().split(","))
dp=[[0]*(maxw+1) for i in range(len(ws)+1)]
ret=0
for i in range(len(ws)):
for j in range(maxw+1):
if (j+ws[i])<=maxw:
dp[i+1][j+ws[i]]=max(dp[i+1][j+ws[i]],dp[i][j]+ps[i])
ret=max(dp[i+1][j+ws[i]],ret)
print "Case {}:".format(num)
print ret
print dp[len(ws)].index(ret)
num+=1 |
s657829285 | p00042 | u104911888 | 1365034850 | Python | Python | py | Runtime Error | 0 | 0 | 513 | num=1
while True:
maxw=input()
if maxw==0:break
N=input()
ws,ps=[0]*N,[0]*N
for i in range(N):
ps[i],ws[i]=map(int,raw_input().strip().split(","))
#dp=[[0]*(maxw+1) for i in range(N+1)]
ret=0
for i in range(N):
for j in range(maxw+1):
if (j+ws[i])<=maxw:
dp[i+1][j+ws[i]]=max(dp[i+1][j+ws[i]],dp[i][j]+ps[i])
ret=max(dp[i+1][j+ws[i]],ret)
print "Case %d:"%num
print ret
print dp[len(ws)].index(ret)
num+=1 |
s401954916 | p00042 | u542421762 | 1369487284 | Python | Python | py | Runtime Error | 0 | 0 | 1433 |
import sys
import itertools
class Treasure:
def __init__(self, value, weight):
self.value = value
self.weight = weight
def solv(treasures, w_limit):
comb = t_combinations(treasures)
ts = filter(lambda x: t_sum_weight(x) <= w_limit, comb)
max_value = max(map(lambda x: t_sum_value(x), ts))
ts2 = filter(lambda x: t_sum_value(x) == max_value, ts)
if len(ts2) == 1:
return (ts2[0].value, ts2[0].weight)
else:
rt = rightest(ts2)
return (t_sum_value(rt), t_sum_weight(rt))
def t_combinations(t):
l = len(t)
r = []
for x in range(1, l+1):
for y in itertools.combinations(t, x):
r.append(y)
return r
def t_sum_weight(t):
return sum(map(lambda x: x.weight, t))
def t_sum_value(t):
return sum(map(lambda x: x.value, t))
def rightest(ts):
return reduce(lambda a, b: take_right(a, b), ts)
def take_right(a, b):
if t_sum_weight(a) <= t_sum_weight(b):
return a
else:
return b
case = 0
while True:
weight_limit = int(sys.stdin.readline())
case += 1
if weight_limit == 0:
exit()
n = int(sys.stdin.readline())
treasures = []
for i in range(n):
v, w = map(int, sys.stdin.readline().split(','))
treasures.append(Treasure(v, w))
value, weight = solv(treasures, weight_limit)
print 'Case ' + str(case) + ':'
print value
print weight |
s728223965 | p00042 | u542421762 | 1369487540 | Python | Python | py | Runtime Error | 0 | 0 | 1441 |
import sys
import itertools
class Treasure:
def __init__(self, value, weight):
self.value = value
self.weight = weight
def solv(treasures, w_limit):
comb = t_combinations(treasures)
ts = filter(lambda x: t_sum_weight(x) <= w_limit, comb)
max_value = max(map(lambda x: t_sum_value(x), ts))
ts2 = filter(lambda x: t_sum_value(x) == max_value, ts)
if len(ts2) == 1:
return (ts2[0].value, ts2[0].weight)
else:
rt = rightest(ts2)
return (t_sum_value(rt), t_sum_weight(rt))
def t_combinations(t):
l = len(t)
r = []
for x in range(1, l+1):
for y in itertools.combinations(t, x):
r.append(y)
return r
def t_sum_weight(ts):
return sum(map(lambda x: x.weight, ts))
def t_sum_value(ts):
return sum(map(lambda x: x.value, ts))
def rightest(tss):
return reduce(lambda a, b: take_right(a, b), tss)
def take_right(a, b):
if t_sum_weight(a) <= t_sum_weight(b):
return a
else:
return b
case = 0
while True:
weight_limit = int(sys.stdin.readline())
case += 1
if weight_limit == 0:
exit()
n = int(sys.stdin.readline())
treasures = []
for i in range(n):
v, w = map(int, sys.stdin.readline().split(','))
treasures.append(Treasure(v, w))
value, weight = solv(treasures, weight_limit)
print 'Case ' + str(case) + ':'
print value
print weight |
s830414421 | p00042 | u782850731 | 1375710950 | Python | Python | py | Runtime Error | 0 | 0 | 810 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
unicode_literals)
from sys import stdin
from itertools import count, combinations
for case in count(1):
W = int(stdin.readline())
if not W:
break
N = int(stdin.readline())
data = []
for _ in range(N):
data.append([int(s) for s in stdin.readline().split(',')])
total = []
for i in range(1, N+1):
for cmb in combinations(data, i):
tv, tw = 0, 0
for value, weight in cmb:
tv += value
tw += weight
if tw < W:
total.append((tv, tw))
tv, tw = max(total, key=lambda(tv, tw): (tv, -tw))
print('Case {}:\n{}\n{}'.format(case, tv, tw)) |
s799922147 | p00042 | u633068244 | 1394280102 | Python | Python | py | Runtime Error | 0 | 0 | 371 | r = 50001
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
if p[i]:
p[2*i+1::i+1] = [0 for x in range(2*i+1,r,i+1)]
while True:
n = int(raw_input())
if n == 0:
break
count = 0
for i in range(n/2):
if p[i] == 1:
m = n - (i+1)
if p[m-1] == 1:
count += 1
print count |
s511089478 | p00042 | u633068244 | 1396011923 | Python | Python | py | Runtime Error | 20 | 4236 | 411 | def get():
p,w = map(int, raw_input().split(","))
for i in range(W-w+1,-1,-1):
if bag[i] > 0 and bag[i]+p > bag[i+w]:
bag[i+w] = bag[i]+p
else:
if p > bag[w]: bag[w] = p
return
c = 1
while True:
W = int(raw_input())
if W == 0: break
bag = [0]*(W+1)
N = int(raw_input())
for i in range(N): get()
w_all = max(bag)
money = bag.index(w_all)
print "Case {}:\n{}\n{}".format(c,w_all,money)
c += 1 |
s562709946 | p00042 | u246033265 | 1396697375 | Python | Python | py | Runtime Error | 100 | 20604 | 666 | for h in range(1, 10000):
w = int(raw_input())
if w == 0:
break
n = int(raw_input())
a = [map(int, raw_input().split(',')) for i in range(n)]
d = [[None] * 1010 for i in range(1010)]
def f(ix, w):
if ix == n:
return 0, 0
if d[ix][w] is not None:
return d[ix][w]
mx = f(ix + 1, w)
if w >= a[ix][1]:
e = [p + q for p, q in zip(f(ix + 1, w - a[ix][1]), a[ix])]
if mx[0] < e[0] or (mx[0] == e[0] and mx[1] > e[1]):
mx = e
d[ix][w] = mx
return mx
mx = f(0, w)
print 'Case {}:'.format(h)
print mx[0]
print mx[1] |
s387003722 | p00042 | u246033265 | 1396800210 | Python | Python | py | Runtime Error | 0 | 0 | 655 | def mlist(n, *args, **keys):
if args:
return [mlist(*args, **keys) for i in range(n)]
else:
return [keys.get('default')] * n
while True:
w = int(raw_input())
if w == 0: break
n = int(raw_input())
a, b = zip(*[map(int, raw_input().split(',')) for i in range(5)])
c = mlist(1010, 1010)
c[0][0] = 0
for i in range(n):
for j in range(w + 1):
if c[i][j] is None: continue
c[i + 1][j] = max(c[i + 1][j], c[i][j])
if j + b[i] <= w:
c[i + 1][j + b[i]] = max(c[i + 1][j + b[i]], c[i][j] + a[i])
mx = max(c[n])
print mx
print c[n].index(mx) |
s235164523 | p00042 | u072661006 | 1397791080 | Python | Python | py | Runtime Error | 0 | 0 | 1064 | #!/bin/env python3
from __future__ import division, print_function
try:
input = raw_input
range = xrange
except NameError:
pass
# 上記のコードはPython2とPython3の違いを一部吸収するためのもの
def main():
value = [0] * 1000
weight = [0] * 1000
casenum = 1
while True:
W = int(input())
if(W == 0):
return
N = int(input())
dp = [[0 for x in range(W+1)] for y in range(N+1)]
for x in range(0, N):
value[x], weight[x] = map(int, input().split(','))
for i in range(0, N):
for w in range(0, W+1):
if w - weight[i] >= 0:
use = dp[i][w - weight[i]] + value[i]
else:
use = 0
unuse = dp[i][w]
dp[i+1][w] = max(use, unuse)
print("Case " + str(casenum) + ":")
for w in range(W+1):
if(dp[N][w] == dp[N][W]):
print(str(dp[N][w]) + "\n" + str(w))
break
casenum += 1
main() |
s825420812 | p00043 | u508732591 | 1486108930 | Python | Python3 | py | Runtime Error | 0 | 0 | 692 | import scala.io.StdIn.{readLine,readInt}
object Main extends App {
val seq1 = for(i<-1 to 9) yield Vector(i,i,i)
val seq2 = for(i<-1 to 7) yield Vector(i,i+1,i+2)
def check(m:Vector[Int], count:Int,u:Int,v:Int):Boolean =
if(m.length != count) false
else if(count==2) m(0)==m(1)
else
(u to 8).exists( i=> check(m diff seq1(i),count-3,i+1,v)) || (v to 6).exists(i=> check(m diff seq2(i),count-3,u,i))
Iterator.continually(readLine).takeWhile ( _!=null ).foreach { line =>
val l = line.map(_.asDigit).toVector
val m = (1 to 9).filter { i=> l.count( _==i ) < 4 && check((i+:l).sorted,14,0,0) }
if(m.length>0) println(m.mkString(" ")) else println(0)
}
} |
s832322259 | p00043 | u508732591 | 1486108983 | Python | Python3 | py | Runtime Error | 0 | 0 | 692 | import scala.io.StdIn.{readLine,readInt}
object Main extends App {
val seq1 = for(i<-1 to 9) yield Vector(i,i,i)
val seq2 = for(i<-1 to 7) yield Vector(i,i+1,i+2)
def check(m:Vector[Int], count:Int,u:Int,v:Int):Boolean =
if(m.length != count) false
else if(count==2) m(0)==m(1)
else
(u to 8).exists( i=> check(m diff seq1(i),count-3,i+1,v)) || (v to 6).exists(i=> check(m diff seq2(i),count-3,u,i))
Iterator.continually(readLine).takeWhile ( _!=null ).foreach { line =>
val l = line.map(_.asDigit).toVector
val m = (1 to 9).filter { i=> l.count( _==i ) < 4 && check((i+:l).sorted,14,0,0) }
if(m.length>0) println(m.mkString(" ")) else println(0)
}
} |
s154419502 | p00043 | u150984829 | 1518744624 | Python | Python3 | py | Runtime Error | 0 | 0 | 513 | import sys
def f(c,h=0):
if 2 in c and sum(c)==2:return 1
if 5 in c:return 0 # sum(c)==2
if 4 in c:
k=c.index(4);c[k]-=3
if f(c,h+1):return 1
c[k]+=3
if 3 in c:
k=c.index(3);c[k]-=3
if f(c,h+1):return 1
c[k]+=3
for i in range(7):
if c[i]and c[i+1]and c[i+2]:
c[i]-=1;c[i+1]-=1;c[i+2]-=1
if f(c,h+1):return 1
c[i]+=1;c[i+1]+=1;c[i+2]+=1
n='123456789'
for e in sys.stdin:
e=list(e)
a=[i for i in n if f([(e+[i]).count(j)for j in n])]
print(*a if a else 0)
|
s034930116 | p00043 | u150984829 | 1518744708 | Python | Python3 | py | Runtime Error | 0 | 0 | 521 | import sys
def f(c,h=0):
if 2 in c and sum(c)==2:return 1
if 5 in c:return 0 # sum(c)==2
if 4 in c:
k=c.index(4);c[k]-=3
if f(c,h+1):return 1
c[k]+=3
if 3 in c:
k=c.index(3);c[k]-=3
if f(c,h+1):return 1
c[k]+=3
for i in range(7):
if c[i]and c[i+1]and c[i+2]:
c[i]-=1;c[i+1]-=1;c[i+2]-=1
if f(c,h+1):return 1
c[i]+=1;c[i+1]+=1;c[i+2]+=1
n='123456789'
for e in sys.stdin:
e=list(e.strip())
a=[i for i in n if f([(e+[i]).count(j)for j in n])]
print(*a if a else 0)
|
s244894053 | p00043 | u017525488 | 1351356695 | Python | Python | py | Runtime Error | 0 | 0 | 1209 |
def dfs(hands, pair):
hands.sort()
if not hands:
return True
target = hands[0]
# sequence
if all(map(lambda x: x in hands, range(target, target + 3))):
for i in range(target, target + 3):
hands.remove(i)
if dfs(hands, pair):
return True
for i in range(target, target + 3):
hands.append(i)
# triple
if hands.count(target) >= 3:
for i in range(3):
hands.remove(target)
if dfs(hands, pair):
return True
for i in range(3):
hands.append(target)
# pair
if not pair and hands.count(target) >= 2:
for i in range(2):
hands.remove(target)
if dfs(hands, True):
return True
for i in range(2):
hands.append(target)
return False
for line in filter(lambda line: line.strip(), open("input.txt").readlines()):
result = []
data = [int(ch) for ch in line.strip()]
for num in filter(lambda x: data.count(x) < 4, range(1, 10)):
data_cp = list(data)
data_cp.append(num)
data_cp.sort()
if dfs(data_cp, False):
result.append(num)
print result |
s029031198 | p00043 | u017525488 | 1351356737 | Python | Python | py | Runtime Error | 0 | 0 | 1207 |
def dfs(hands, pair):
hands.sort()
if not hands:
return True
target = hands[0]
# sequence
if all(map(lambda x: x in hands, range(target, target + 3))):
for i in range(target, target + 3):
hands.remove(i)
if dfs(hands, pair):
return True
for i in range(target, target + 3):
hands.append(i)
# triple
if hands.count(target) >= 3:
for i in range(3):
hands.remove(target)
if dfs(hands, pair):
return True
for i in range(3):
hands.append(target)
# pair
if not pair and hands.count(target) >= 2:
for i in range(2):
hands.remove(target)
if dfs(hands, True):
return True
for i in range(2):
hands.append(target)
return False
for line in filter(lambda line: line.strip(), stdin.readlines()):
result = []
data = [int(ch) for ch in line.strip()]
for num in filter(lambda x: data.count(x) < 4, range(1, 10)):
data_cp = list(data)
data_cp.append(num)
data_cp.sort()
if dfs(data_cp, False):
result.append(num)
print " ".join(result) |
s019074781 | p00044 | u075836834 | 1458951446 | Python | Python3 | py | Runtime Error | 0 | 0 | 477 | def sieve(n):
p=[True]*(n+1)
p[0]=p[1]=False
for i in range(2,int((n+1)*0.5)+1):
if p[i]==True:
for j in range(i*i,n+1,i):
p[j]=False
prime=[]
for i in range(n+1):
if p[i]==True:
prime.append(i)
return prime
def solve(n):
i=0
a,b=0,0
while True:
if n>prime[i]:
a=prime[i]
elif n==prime[i]:
a=prime[i-1]
else:
b=prime[i]
break
i+=1
print(a,b)
prime=sieve(5100)
while True:
try:
n=int(input())
solve(n)
except EOFError:
break |
s676810956 | p00044 | u075836834 | 1458951690 | Python | Python3 | py | Runtime Error | 0 | 0 | 468 | def sieve(n):
p=[True]*(n+1)
p[0]=p[1]=False
for i in range(2,int((n+1)*0.5)+1):
if p[i]==True:
for j in range(i*i,n+1,i):
p[j]=False
prime=[]
for i in range(n+1):
if p[i]==True:
prime.append(i)
return prime
def solve(n):
i=0
while True:
if n>prime[i]:
a=prime[i]
elif n==prime[i]:
a=prime[i-1]
else:
b=prime[i]
break
i+=1
print(a,b)
prime=sieve(5003)
while True:
try:
n=int(input())
solve(n)
except EOFError:
break |
s372965692 | p00044 | u130979865 | 1461237733 | Python | Python | py | Runtime Error | 0 | 0 | 442 | # -*- coding: utf-8 -*-
import sys
primes = [2]
for i in range(3, 50010):
flag = True
for p in primes:
if i % p == 0:
flag = False
break
if flag:
primes.append(i)
for line in sys.stdin:
n = int(line)
i = 0
while primes[i] < n and i < len(primes):
i += 1
if primes[i] == n:
s = primes[i-1]
else:
s = primes[i]
m = primes[i+1]
print s, m |
s004023313 | p00044 | u546285759 | 1483587468 | Python | Python3 | py | Runtime Error | 0 | 0 | 373 | import sys
from itertools import takewhile, dropwhile
L, pn, tmp = 224, [], [i for i in range(2, 50000)]
while tmp[0] < 224:
v = tmp.pop(0)
pn.append(v)
tmp = list(filter(lambda x: x%v!=0, tmp))
for t in tmp: pn.append(t)
for line in sys.stdin:
n = int(line.strip())
print(list(takewhile(lambda x: x<n, pn))[-1], list(dropwhile(lambda x: x<n, pn))[1]) |
s758617065 | p00044 | u546285759 | 1483620598 | Python | Python3 | py | Runtime Error | 0 | 0 | 376 | from itertools import takewhile, dropwhile
pn, tmp = [], [i for i in range(2, 50000)]
while tmp[0] < 224:
v = tmp.pop(0)
pn.append(v)
tmp = list(filter(lambda x: x%v!=0, tmp))
for t in tmp: pn.append(t)
while True:
try:
n = int(input())
except:
break
print(list(takewhile(lambda x: x<n, pn))[-1], list(dropwhile(lambda x: x<=n, pn))[0]) |
s841300489 | p00044 | u546285759 | 1483620769 | Python | Python3 | py | Runtime Error | 0 | 0 | 392 | from itertools import takewhile, dropwhile
pn, tmp = [], [i for i in range(2, 50000)]
while tmp[0] < 224:
v = tmp.pop(0)
pn.append(v)
tmp = list(filter(lambda x: x%v!=0, tmp))
for t in tmp: pn.append(t)
while True:
try:
n = int(input())
a, b = list(takewhile(lambda x: x<n, pn))[-1], list(dropwhile(lambda x: x<=n, pn))[0]
print(a, b)
except:
break |
s098281297 | p00044 | u546285759 | 1483677461 | Python | Python3 | py | Runtime Error | 0 | 0 | 376 | from itertools import takewhile, dropwhile
pn, tmp = [], [i for i in range(2, 50000)]
while tmp[0] < 224:
v = tmp.pop(0)
pn.append(v)
tmp = list(filter(lambda x: x%v!=0, tmp))
for t in tmp: pn.append(t)
while True:
try:
n = int(input())
except:
break
print(list(takewhile(lambda x: x<n, pn))[-1], list(dropwhile(lambda x: x<=n, pn))[0]) |
s066972854 | p00044 | u078042885 | 1484102459 | Python | Python3 | py | Runtime Error | 0 | 0 | 271 | n=1000000
p=[1]*(n+1)
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
if p[i]:
for j in range(i*i,n+1,i):
p[j]=0
p=[i for i in range(n+1) if p[i]==1]
while 1:
try:n=int(input())
except:break
i=p.index(n)
print(p[i-1],p[i+1]) |
s318604868 | p00044 | u546285759 | 1491461360 | Python | Python3 | py | Runtime Error | 0 | 0 | 322 | primes = [0, 0] + [1]*49999
for i in range(2, 224):
if primes[i]:
for j in range(i*i, 50001, i):
primes[j] = 0
while True:
try:
n = int(input())
except:
break
m, o = n-1, n+1
while not primes[m]:
m -= 1
while not primes[o]:
o += 1
print(m, o) |
s304070735 | p00044 | u811733736 | 1492493987 | Python | Python3 | py | Runtime Error | 0 | 0 | 1172 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0044
?´???°II
"""
import sys
def create_prime_list(limit):
""" ??¨??????????????????????????§limit?????§????´???°?????????????±???????
https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9
"""
x = limit**0.5
primes = []
# print('x={0}'.format(x))
nums = [x for x in range(2, limit+1)]
while nums[0] <= x:
primes.append(nums[0])
current_prime = nums[0]
nums = [x for x in nums if x % current_prime != 0]
primes.extend(nums)
# print(primes)
return primes
def main(args):
primes = create_prime_list(50000) # ?´???°????????????????????¨???
for line in sys.stdin: # ??????????????\???
limit = int(line.strip())
unders = [x for x in primes if x < limit]
largest_prime = unders[-1]
overs = [x for x in primes if x > limit]
smallest_prime = overs[0]
# ???????????????
print('{0} {1}'.format(largest_prime, smallest_prime))
if __name__ == '__main__':
main(sys.argv[1:]) |
s343150782 | p00044 | u462831976 | 1493082870 | Python | Python3 | py | Runtime Error | 0 | 0 | 467 | # -*- coding: utf-8 -*-
import sys
import os
import math
import itertools
def is_prime(q):
q = abs(q)
if q == 2: return True
if q < 2 or q&1 == 0: return False
return pow(2, q-1, q) == 1
for s in sys.stdin:
n = int(s)
for i in range(n-1, 3, -1):
if is_prime(i):
answer0 = i
break
for i in range(n+1, 50000):
if is_prime(i):
answer1 = i
break
print(answer0, answer1) |
s742950324 | p00044 | u462831976 | 1493082976 | Python | Python3 | py | Runtime Error | 0 | 0 | 471 | # -*- coding: utf-8 -*-
import sys
import os
import math
import itertools
def is_prime(q):
q = abs(q)
if q == 2: return True
if q < 2 or q&1 == 0: return False
return pow(2, q-1, q) == 1
for s in sys.stdin:
n = int(s)
for i in range(n-1, 3, -1):
if is_prime(i):
answer0 = i
break
for i in range(n+1, 100000, 1):
if is_prime(i):
answer1 = i
break
print(answer0, answer1) |
s680131495 | p00044 | u136916346 | 1527605439 | Python | Python3 | py | Runtime Error | 0 | 0 | 1030 | #include <stdio.h>
int pm(int n,int *l){
int i,j,p=0,c=n-1,target[n-1];
for(i=0;i<n-1;i++){target[i]=i+2;}
for(i=0;i<n-1;i++){
if (!target[i]){continue;}
for(j=i;j<n-1;j=j+i+2){
if (!target[j]){continue;}
if (j!=i && target[j]%target[i]==0){target[j]=0;c--;}
}
}
for(i=0;i<n-1;i++){
if(target[i]){l[p]=target[i];p++;}
}
return p;
}
int main(void){
int i,p,n,idx=0,l[59999],ds[50000][2];
p=pm(60000,l);
while(scanf("%d",&n)!=EOF){
for(i=0;i<p-1;i++){
if(n>l[i]&&n<l[i+1]){
if((n-l[i]) > (l[i+1]-n)){ds[idx][0]=l[i];ds[idx][1]=l[i+2];break;}
if((n-l[i]) < (l[i+1]-n)){ds[idx][0]=l[i-1];ds[idx][1]=l[i+1];break;}
}
else if(n==l[i]){ds[idx][0]=l[i-1];ds[idx][1]=l[i+1];break;}
else if(n==l[i+1]){ds[idx][0]=l[i];ds[idx][1]=l[i+2];break;}
}
idx++;
}
for(i=0;i<idx;i++){printf("%d %d\n",ds[i][0],ds[i][1]);}
return 0;
}
|
s858057299 | p00044 | u894941280 | 1355934871 | Python | Python | py | Runtime Error | 0 | 0 | 260 | q=[]
for i in range(2,10000):
for j in range(2,i):
if i % j == 0:
break
else:
q.append(i)
if __name__ =='__main__':
while True:
try:
a = int(input())
ans = q.index(a)
print q[ans-1],q[ans+1]
except EOFError: break |
s337875573 | p00044 | u310759044 | 1365522578 | Python | Python | py | Runtime Error | 0 | 0 | 966 | import sys
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1
for n in sys.stdin:
    a=int(n.strip())
    b=a
    while 1:
        a+=2
        if is_prime(a):
            max_a=a
            break
    while 1:
        b-=2
        if is_prime(b):
            min_b=b
            break
    print min_b,max_a |
s073194175 | p00044 | u147801965 | 1365525214 | Python | Python | py | Runtime Error | 0 | 0 | 270 | from sys import stdin
te=lambda x:pow(2,x-1,x) == 1
for i in stdin:
a=b=int(i.strip())
while 1:
a+=1
if te(a):
ans=a
break
while 1:
b-=1
if te(b):
ans2=b
break
print ans,ans2 |
s499392637 | p00044 | u542421762 | 1370094234 | Python | Python | py | Runtime Error | 0 | 0 | 729 |
import sys
primes = [2]
def solv(num):
if num < primes[-1]:
p1 = filter(lambda x: x < num)[-1]
else:
for p in prime_list(num * 2):
primes.append(p)
if num < p:
p2 = p
break
else:
if p < num:
p1 = p
return (p1, p2)
def prime_list(n):
limit = int(n ** 0.5) + 1
lis = range(1, n + 1, 2)
lis[0] = 2
while True:
if len(lis) == 0:
break
p = lis.pop(0)
yield p
if p <= limit:
lis = [x for x in lis if x % p != 0]
for line in sys.stdin:
number = int(line)
p1, p2 = solv(number)
print ' '.join(map(str, [p1, p2])) |
s498738460 | p00044 | u542421762 | 1370094349 | Python | Python | py | Runtime Error | 0 | 0 | 737 |
import sys
primes = [2]
def solv(num):
if num < primes[-1]:
p1 = filter(lambda x: x < num, primes)[-1]
else:
for p in prime_list(num * 2):
primes.append(p)
if num < p:
p2 = p
break
else:
if p < num:
p1 = p
return (p1, p2)
def prime_list(n):
limit = int(n ** 0.5) + 1
lis = range(1, n + 1, 2)
lis[0] = 2
while True:
if len(lis) == 0:
break
p = lis.pop(0)
yield p
if p <= limit:
lis = [x for x in lis if x % p != 0]
for line in sys.stdin:
number = int(line)
p1, p2 = solv(number)
print ' '.join(map(str, [p1, p2])) |
s122080096 | p00044 | u260980560 | 1384349548 | Python | Python | py | Runtime Error | 0 | 0 | 340 | M = 50100
p = [1]*M; p[0],p[1]=0,0;
pm = [0]*M; pM = [0]*M;
for i in range(2,M):
if p[i]:
for j in range(i*i,M,i): p[j] = 0
num = -1
for i in range(1,M):
pm[i] = num
if p[i]: num = i
num = -1
for i in range(M-1,2,-1):
pM[i] = num
if p[i]: num = i
while 1:
n = input()
if n==0: break
print pm[n],pM[n] |
s513940817 | p00044 | u633068244 | 1393666169 | Python | Python | py | Runtime Error | 0 | 0 | 1075 | import math
 
r = 50000
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        for j in range(2*i+1,r,i+1):
            p[j] = 0
 
while True:
    try:
        n = int(raw_input())
        for i in range(n,50000):
         if p[i] == 1:
         lp = i
         break
        for i in range(n-1,3,-1):
         if p[i] == 1:
         sp = i
         break
        print lp, sp
    except:
        break |
s762765634 | p00044 | u912237403 | 1394870550 | Python | Python | py | Runtime Error | 0 | 0 | 415 | import sys
def sieves(m):
global S
S = range(1,m+1,2)
r = int(m**.5)
h = len(S)
S[0] = 0
for i in range(h):
x = S[i]
if x>r: break
if x and i+x<h: S[i+x:h:x] = [0]*((h-1-i-x)/x+1)
S[0] = 2
return
S=[]
sieves(50001)
for s in sys.stdin:
n = int(s)
p1 = n/2-1
p2 = (n+1)/2
while S[p1]==0: p1 -=1
while S[p2]==0: p2 +=1
print S[p1],S[p2] |
s304191578 | p00044 | u912237403 | 1394870735 | Python | Python | py | Runtime Error | 0 | 0 | 415 | import sys
def sieves(m):
global S
S = range(1,m+1,2)
r = int(m**.5)
h = len(S)
S[0] = 0
for i in range(h):
x = S[i]
if x>r: break
if x and i+x<h: S[i+x:h:x] = [0]*((h-1-i-x)/x+1)
S[0] = 2
return
S=[]
sieves(50001)
for s in sys.stdin:
n = int(s)
p1 = n/2-1
p2 = (n+1)/2
while S[p1]==0: p1 -=1
while S[p2]==0: p2 +=1
print S[p1],S[p2] |
s894409161 | p00044 | u912237403 | 1394882334 | Python | Python | py | Runtime Error | 0 | 0 | 359 | import sys
m = 50001
S = range(1,m+1,2)
r = int(m**.5)
h = len(S)
S[0] = 0
for i in range(h):
x = S[i]
if x>r: break
if x and i+x<h: S[i+x:h:x] = [0]*((h-1-i-x)/x+1)
S[0] = 2
for s in sys.stdin:
n = int(s)
for p1 in range(n/2-1,0,-1):
if S[p1]: break
for p2 in range((n+1)/2,m/2):
if S[p2]: break
print S[p1],S[p2] |
s532520360 | p00044 | u912237403 | 1394885346 | Python | Python | py | Runtime Error | 0 | 0 | 450 | import sys,math
def sieves(m):
global S
S = range(1,m+1,2)
r = int(m**.5)
h = len(S)
S[0] = 0
for i in range(h):
x = S[i]
if x>r: break
if x and i+x<h: S[i+x:h:x] = [0]*((h-1-i-x)/x+1)
S[0] = 2
return
m = 50100
sieves(m)
for s in sys.stdin:
n = int(s)
for p1 in range(n/2-1,0,-1):
if S[p1]: break
for p2 in range((n+1)/2,m/2+1):
if S[p2]: break
print S[p1],S[p2] |
s778650883 | p00044 | u912237403 | 1394885411 | Python | Python | py | Runtime Error | 0 | 0 | 457 | import sys,math
def sieves(m):
global S
S = range(1,m+1,2)
r = int(m**.5)
h = len(S)
S[0] = 0
for i in range(h):
x = S[i]
if x>r: break
if x and i+x<h: S[i+x:h:x] = [0]*((h-1-i-x)/x+1)
S[0] = 2
return
m = 50100
S = []
sieves(m)
for s in sys.stdin:
n = int(s)
for p1 in range(n/2-1,0,-1):
if S[p1]: break
for p2 in range((n+1)/2,m/2+1):
if S[p2]: break
print S[p1],S[p2] |
s440675759 | p00044 | u246033265 | 1396804560 | Python | Python | py | Runtime Error | 0 | 0 | 437 | from bisect import *
def sieve(n):
a = range(n)
a[:2] = None, None
for i in range(2, n):
if i ** 2 >= n: break
if not a[i]: continue
for i in range(i ** 2, n, i):
a[i] = None
return [v for v in a if v]
try:
a = sieve(9000)
while True:
n = int(raw_input())
i = bisect_right(a, n)
print a[i - (2 if a[i - 1] == n else 1)], a[i]
except EOFError:
pass |
s561483050 | p00044 | u436634575 | 1401185301 | Python | Python3 | py | Runtime Error | 0 | 0 | 400 | N = 50001
a = [True] * N
i = 3
while i * i < N:
for j in range(3 * i, N, 2 * i): a[j] = False
i += 2
while True:
try:
n = int(input())
except:
break
n0 = n + 2 if (n & 1) else n + 1
for maxv in range(n0, N, 2):
if a[maxv]: break
n0 = n - 2 if (n & 1) else n - 1
for minv in range(n0, 2, -2):
if a[minv]: break
print(minv, maxv) |
s211018937 | p00045 | u300946041 | 1475299791 | Python | Python3 | py | Runtime Error | 0 | 0 | 463 | # -*- coding: utf-8 -*-
def sum_and_average(_input):
_sum_list = []
_avg_list = []
while 1:
try:
_sum, _avg = [int(e) for e in _input]
_sum_list.append(_sum)
_avg_list.append(_avg)
except EOFError:
break
return sum(_sum_list), (sum(_avg_list) / len(_avg_list))
if __name__ == '__main__':
_sum, _avg = sum_and_average(input().split())
print(round(_sum, 1), round(_avg, 1)) |
s811268252 | p00045 | u300946041 | 1475299890 | Python | Python3 | py | Runtime Error | 0 | 0 | 451 | # -*- coding: utf-8 -*-
def sum_and_average():
_sum_list = []
_avg_list = []
while 1:
try:
_sum, _avg = [int(e) for e in input().split()]
_sum_list.append(_sum)
_avg_list.append(_avg)
except EOFError:
break
return sum(_sum_list), (sum(_avg_list) / len(_avg_list))
if __name__ == '__main__':
_sum, _avg = sum_and_average()
print(round(_sum, 1), round(_avg, 1)) |
s970381802 | p00045 | u300946041 | 1475300108 | Python | Python3 | py | Runtime Error | 0 | 0 | 327 | # -*- coding: utf-8 -*-
_sum_list = []
_avg_list = []
while 1:
try:
_sum, _avg = [int(e) for e in input().split()]
_sum_list.append(_sum)
_avg_list.append(_avg)
except EOFError:
break
_sum, _avg = sum(_sum_list), sum(_avg_list) / len(_avg_list)
print(round(_sum, 1), round(_avg, 1)) |
s547981168 | p00045 | u300946041 | 1475300284 | Python | Python3 | py | Runtime Error | 0 | 0 | 317 | # -*- coding: utf-8 -*-
_sum_list = []
_avg_list = []
while 1:
try:
_sum, _avg = [int(e) for e in input().split()]
_sum_list.append(_sum)
_avg_list.append(_avg)
except:
break
_sum, _avg = sum(_sum_list), sum(_avg_list) / len(_avg_list)
print(round(_sum, 1), round(_avg, 1)) |
s294948625 | p00045 | u546285759 | 1482921299 | Python | Python3 | py | Runtime Error | 0 | 0 | 181 | a, b = [], []
while True:
try:
x, y = map(int, line.strip().split(","))
a, b = a+[x*y], b+[y]
except:
break
print(sum(a))
print(round(sum(b)/len(b))) |
s001808026 | p00045 | u786299861 | 1500643933 | Python | Python3 | py | Runtime Error | 0 | 0 | 242 | # _*_ coding: utf-8 _*_
sum = 0
total = 0
cnt = 0
while True:
s = input()
if s == '':
break
list = s.split(',')
sum += int(list[0])*int(list[1])
total += int(list[1])
cnt += 1
ave = total / cnt + 0.5
print(sum)
print(int(ave)) |
s528061313 | p00045 | u786299861 | 1500644067 | Python | Python | py | Runtime Error | 0 | 0 | 242 | # _*_ coding: utf-8 _*_
sum = 0
total = 0
cnt = 0
while True:
s = input()
if s == '':
break
list = s.split(',')
sum += int(list[0])*int(list[1])
total += int(list[1])
cnt += 1
ave = total / cnt + 0.5
print(sum)
print(int(ave)) |
s068912337 | p00045 | u786299861 | 1500644730 | Python | Python3 | py | Runtime Error | 0 | 0 | 217 | sum = 0
total = 0
cnt = 0
while True:
s = input()
if s == '':
break
list = s.split(',')
sum += int(list[0])*int(list[1])
total += int(list[1])
cnt += 1
ave = total / cnt + 0.5
print(sum)
print(int(ave)) |
s592007717 | p00045 | u350064373 | 1501556391 | Python | Python3 | py | Runtime Error | 0 | 0 | 221 | try:
while True:
result = result2 = count = 0
a, b = map(int, input().split(','))
result += a*b
result2 += b
count += 1
except:
print(result,"{0:.1f}".format(result2/count)) |
s728293752 | p00045 | u498511622 | 1501556585 | Python | Python | py | Runtime Error | 0 | 0 | 161 | total=0
s=0
i=0
while True:
try:
a,b = map(int,input().split(','))
total += a*b
s+=b
i+=1
except:
result=s/i
print(total)
print(round(result)) |
s372235637 | p00045 | u498511622 | 1501556629 | Python | Python | py | Runtime Error | 0 | 0 | 161 | total=0
s=0
i=0
try:
while True:
a,b = map(int,input().split(','))
total += a*b
s+=b
i+=1
except:
result=s/i
print(total)
print(round(result)) |
s329744541 | p00045 | u498511622 | 1501556901 | Python | Python3 | py | Runtime Error | 0 | 0 | 152 | total=0
s=0
i=0
try:
while True:
a,b = map(int,input().split(','))
total += a*b
s+=b
i+=1
except:
result=s/i
print(total)
print(round(result)) |
s491180005 | p00045 | u350064373 | 1501557805 | Python | Python3 | py | Runtime Error | 0 | 0 | 222 | try:
result = result2 = count = 0
while True:
a, b = map(int, input().split(','))
result += a*b
result2 += b
count += 1
except:
print(result)
print((round(result2/count+0.5)) |
s353734665 | p00045 | u633068244 | 1393667467 | Python | Python | py | Runtime Error | 0 | 0 | 205 | i, all, sum = 0, 0, 0
while True:
try:
price, n = map(int, raw_input().split(",")))
i += 1; all += n; sum += price
except
break
print sum
print int(round(float(all)/i)) |
s956313629 | p00045 | u633068244 | 1393667484 | Python | Python | py | Runtime Error | 0 | 0 | 204 | i, all, sum = 0, 0, 0
while True:
try:
price, n = map(int, raw_input().split(","))
i += 1; all += n; sum += price
except
break
print sum
print int(round(float(all)/i)) |
s735341633 | p00045 | u436634575 | 1401185775 | Python | Python3 | py | Runtime Error | 0 | 0 | 126 | import sys
s = c = 0
for line in sys.stdin:
x, y = map(int line.split())
s += x * y
c += y
print(s, round(s / c)) |
s670057487 | p00045 | u436634575 | 1401185802 | Python | Python3 | py | Runtime Error | 0 | 0 | 129 | import sys
s = c = 0
for line in sys.stdin:
x, y = map(int line.split(','))
s += x * y
c += y
print(s, round(s / c)) |
s123767376 | p00046 | u814278309 | 1558934252 | Python | Python3 | py | Runtime Error | 0 | 0 | 72 | import sys
a=list(map(float,sys.stdin.readline()))
print(max(a)-min(a))
|
s690915138 | p00046 | u879226672 | 1425396417 | Python | Python | py | Runtime Error | 0 | 0 | 177 | ls = []
while True:
try:
data = map(float,raw_input().split())
ls.append(data)
except EOFError:
break
ls.sort()
ans = ls[-1]-ls[0]
print ans
|
s521228028 | p00046 | u879226672 | 1425396476 | Python | Python | py | Runtime Error | 0 | 0 | 168 | ls = []
while True:
try:
data = float(raw_input().split())
ls.append(data)
except EOFError:
break
ls.sort()
ans = ls[-1]-ls[0]
print ans |
s676441851 | p00046 | u746468741 | 1461315243 | Python | Python3 | py | Runtime Error | 0 | 0 | 80 | A=[]
for i in range(0,5):
a=float(input())
A.append(a)
print(max(A)-min(B)) |
s269594228 | p00046 | u746468741 | 1461582288 | Python | Python3 | py | Runtime Error | 0 | 0 | 81 | A=[]
while not a == false:
a=float(input())
A.append(a)
print(max(A)-min(A)) |
s937330250 | p00046 | u746468741 | 1461826365 | Python | Python3 | py | Runtime Error | 0 | 0 | 81 | A=[]
do:
a=float(input())
A.append(a)
while a != Null:
print(max(A)-min(A)) |
s290578244 | p00046 | u746468741 | 1461826442 | Python | Python3 | py | Runtime Error | 0 | 0 | 80 | A=[]
do:
a=float(input())
A.append(a)
while a != Null
print(max(A)-min(A)) |
s178305029 | p00046 | u746468741 | 1461826770 | Python | Python3 | py | Runtime Error | 0 | 0 | 99 |
A=[]
while True:
a=float(input())
A.append(a)
if a==Null:
break
print(max(A)-min(A)) |
s279238785 | p00046 | u746468741 | 1461826849 | Python | Python3 | py | Runtime Error | 0 | 0 | 99 |
A=[]
while True:
a=float(input())
A.append(a)
if a==Null:
break
print(max(A)-min(A)) |
s170704682 | p00046 | u862440080 | 1473937444 | Python | Python3 | py | Runtime Error | 0 | 0 | 70 | inputs = [flaot(i) for i in input()]
print(max(inputs) - min(inputs)) |
s911767102 | p00046 | u862440080 | 1473937512 | Python | Python3 | py | Runtime Error | 0 | 0 | 70 | inputs = [float(i) for i in input()]
print(max(inputs) - min(inputs)) |
s044935236 | p00046 | u866760195 | 1378346578 | Python | Python | py | Runtime Error | 0 | 0 | 179 | fir=0
sec=0
while True:
a=raw_input()
if a >= fir:
sec = fir
fir = a
elif a >= sec:
sec = a
print fir-sec |
s000434035 | p00046 | u866760195 | 1378346708 | Python | Python | py | Runtime Error | 0 | 0 | 287 | fir=0
sec=0
while True:
try:
a=raw_input()
if a >= fir:
sec = fir
fir = a
elif a >= sec:
sec = a
except EOFError:
break
print fir-sec |
s423380106 | p00046 | u866760195 | 1378346907 | Python | Python | py | Runtime Error | 0 | 0 | 207 | import sys
fir=0
sec=0
for line in sys.stdin:
a=float(raw_input())
if a >= fir:
sec = fir
fir = a
elif a >= sec:
sec = a
print fir-sec |
s187700379 | p00046 | u866760195 | 1378346994 | Python | Python | py | Runtime Error | 0 | 0 | 204 | import sys
fir=0
sec=0
for a in sys.stdin:
a=float(raw_input())
if a >= fir:
sec = fir
fir = a
elif a >= sec:
sec = a
print fir-sec |
s618232857 | p00046 | u866760195 | 1378347128 | Python | Python | py | Runtime Error | 0 | 0 | 202 | import sys
fir=0
las=0
for a in sys.stdin:
a=float(raw_input())
if a >= fir:
fir = a
a = las
elif a <= las:
las = a
print fir-las |
s718860604 | p00046 | u866760195 | 1378347382 | Python | Python | py | Runtime Error | 0 | 0 | 155 | a=[]
while True:
try:
i=raw_input()
except EOFError:
break
a.append(i)
print "%f" %(max(a)-min(a)) |
s217138569 | p00046 | u866760195 | 1378347398 | Python | Python | py | Runtime Error | 0 | 0 | 157 | a=[]
while True:
try:
i=raw_input()
except EOFError:
break
a.append(i)
print "%f" %(max(a)-min(a), ) |
s199762106 | p00046 | u866760195 | 1378347619 | Python | Python | py | Runtime Error | 0 | 0 | 120 | a=[]
while True:
try:
i=raw_input()
a.append(i)
print "%f" %(max(a)-min(a)) |
s081910669 | p00046 | u633068244 | 1393583930 | Python | Python | py | Runtime Error | 0 | 0 | 92 | i = 0
while 1:
try:
a[i] = float(raw_input())
a.sort()
print a[len(a)-1] - a[0] |
s489331326 | p00046 | u633068244 | 1393583991 | Python | Python | py | Runtime Error | 0 | 0 | 116 | i = 0
a=[]
while 1:
try:
a.append(float(raw_input()))
i += 1
a.sort()
print a[len(a)-1] - a[0] |
s022845907 | p00046 | u633068244 | 1393584048 | Python | Python | py | Runtime Error | 0 | 0 | 94 | a=[]
while 1:
try:
a.append(float(raw_input()))
a.sort()
print a[len(a)-1] - a[0] |
s668075387 | p00046 | u633068244 | 1393584084 | Python | Python | py | Runtime Error | 0 | 0 | 109 | a=[]
while 1:
try:
h = float(row_input())
a.append(h)
a.sort()
print a[len(a)-1] - a[0] |
s796305375 | p00046 | u633068244 | 1393584131 | Python | Python | py | Runtime Error | 0 | 0 | 112 | a=[]
while True:
try:
h = float(row_input())
a.append(h)
a.sort()
print a[len(a)-1] - a[0] |
s175154663 | p00046 | u633068244 | 1393584189 | Python | Python | py | Runtime Error | 0 | 0 | 115 | a=[]
while True:
try:
h = float(row_input())
a.append(h)
except:
break
a.sort()
print a[len(a)-1] - a[0] |
s763047912 | p00047 | u560838141 | 1410781968 | Python | Python | py | Runtime Error | 0 | 0 | 158 | ball = 0
while True:
try:
a, b = map(lambda x: ord(x) - ord("A") raw_input().strip().split(","))
if (a == ball):
ball = b;
print chr(ball + ord("A")) |
s099514964 | p00047 | u560838141 | 1410781989 | Python | Python | py | Runtime Error | 0 | 0 | 176 | ball = 0
while True:
try:
a, b = map(lambda x: ord(x) - ord("A") raw_input().strip().split(","))
if (a == ball):
ball = b;
except:
break;
print chr(ball + ord("A")) |
s158902473 | p00047 | u935184340 | 1468122049 | Python | Python3 | py | Runtime Error | 0 | 0 | 354 | let () =
let rec read pos =
try let l = read_line ()
|> Str.split (Str.regexp_string ",")
in
if (List.nth l 0) = pos then
read (List.nth l 1)
else if (List.nth l 1) = pos then
read (List.nth l 0)
else
read pos
with End_of_file -> pos
in print_endline (read "A")
;; |
s871873229 | p00047 | u300946041 | 1471267951 | Python | Python3 | py | Runtime Error | 0 | 0 | 170 | import sys
d = {'A': 1, 'B': 0, 'C': 0}
for line in sys.stdin:
a, t = line.split(',')
d[a], d[t] = d[t], d[a]
for k, v in d.items():
if v:
print(k) |
s872967539 | p00047 | u300946041 | 1471268069 | Python | Python3 | py | Runtime Error | 0 | 0 | 170 | import sys
d = {'A': 1, 'B': 0, 'C': 0}
for line in sys.stdin:
a, t = line.split(',')
d[a], d[t] = d[t], d[a]
for k, v in d.items():
if v:
print(k) |
s917134121 | p00047 | u300946041 | 1471268183 | Python | Python3 | py | Runtime Error | 0 | 0 | 186 | import sys
d = {'A': 1, 'B': 0, 'C': 0}
_input = sys.stdin
for line in _input:
a, t = line.split(',')
d[a], d[t] = d[t], d[a]
for k, v in d.items():
if v:
print(k) |
s835000232 | p00047 | u300946041 | 1471268292 | Python | Python3 | py | Runtime Error | 0 | 0 | 178 | import sys
d = {'A': 1, 'B': 0, 'C': 0}
for line in sys.stdin:
a, t = line.split().split(',')
d[a], d[t] = d[t], d[a]
for k, v in d.items():
if v:
print(k) |
s186321564 | p00047 | u300946041 | 1471268322 | Python | Python3 | py | Runtime Error | 0 | 0 | 189 | import sys
d = {'A': True, 'B': False, 'C': False}
for line in sys.stdin:
a, t = line.split().split(',')
d[a], d[t] = d[t], d[a]
for k, v in d.items():
if v:
print(k) |
s778220471 | p00047 | u300946041 | 1471268470 | Python | Python3 | py | Runtime Error | 0 | 0 | 224 | d = {'A': True, 'B': False, 'C': False}
while True:
try:
line = input()
except:
break
a, t = line.split().split(',')
d[a], d[t] = d[t], d[a]
for k, v in d.items():
if v:
print(k) |
s241289625 | p00047 | u300946041 | 1471268714 | Python | Python3 | py | Runtime Error | 0 | 0 | 181 | import sys
d = {'A': True, 'B': False, 'C': False}
for line in sys.stdin:
a, t = line.split(',')
d[a], d[t] = d[t], d[a]
for k, v in d.items():
if v:
print(k) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.