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
s032750763
p00027
u504990413
1353416606
Python
Python
py
Runtime Error
0
5648
955
dates = [] youbi = [] for i in range(1,13): if i == 1 or i == 3 or i == 5 or i == 7 or i == 8 or i == 10 or i == 12: for j in range(1,32): dates.append([i,j]) elif i == 4 or i == 6 or i == 9 or i == 11: for j in range(1,31): dates.append([i,j]) elif i == 2: for j in range(1,30): dates.append([i,j]) while True: x = map(int, raw_input().split(' ')) if x == [0,0]: for yo in youbi: print yo elif dates.index(x) % 7 == 0: youbi.append('Thursday') elif dates.index(x) % 7 == 1: youbi.append('Friday') elif dates.index(x) % 7 == 2: youbi.append('Saturday') elif dates.index(x) % 7 == 3: youbi.append('Sunday') elif dates.index(x) % 7 == 4: youbi.append('Monday') elif dates.index(x) % 7 == 5: youbi.append('Tuesday') elif dates.index(x) % 7 == 6: youbi.append('Wednesday')
s600862127
p00027
u782850731
1362267571
Python
Python
py
Runtime Error
0
0
401
#include <stdio.h> const char WEEKDAYS[7][10] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }; const int MONTHS_1ST_WEEKDAY[] = { 3, 6, 0, 3, 5, 1, 3, 6, 2, 4, 0, 2 }; int main() { int month, day; while (1) { scanf(" %d %d", &month, &day); if (month == 0 && day == 0) break; puts(WEEKDAYS[(MONTHS_1ST_WEEKDAY[month-1] + day - 1) % 7]); } return 0; }
s321278370
p00027
u147801965
1364408740
Python
Python
py
Runtime Error
0
0
464
ans ={} for i in range(1,13): if i%2 !=0: ans[str(i)] = 31 else: ans[str(i)] = 30 ans['2']=29 while True: a,b=map(int,raw_input().split()) day =b if a+b == 0: break; if a == 1: day = b; elif a == 2: day+=31 else: for i in range(a): if i ==0: pass; day += ans[str(i)] print ['Wednesday','Thurday','Friday', 'Saturday','Sunday','Monday', 'Tuesday'][day%7]
s326302604
p00027
u350508326
1372112808
Python
Python
py
Runtime Error
0
0
664
nm = [0,31,29,31,30,31,30,31,31,30,31,30] while True: m,d = map(int,raw_input().split(" ")) if m == 0: break nd = 0 for i in range(m): nd += nm[i] nd += d n = nd%7 if n == 1: print "Thursday" elif n == 2: print "Tryday" elif n == 3: print "Saturday" elif n == 4: print "Sunday" elif n == 5: print "Monday" elif n == 6: print "Tuesday" elif n == 7: print "Wednesday" ~
s608566709
p00027
u350508326
1372113141
Python
Python
py
Runtime Error
0
0
1049
nm = [0,31,29,31,30,31,30,31,31,30,31,30] while True: m,d = map(int,raw_input().split(" ")) if m == 0: break nd = 0 for i in range(m): nd += nm[i] nd += d n = nd%7 if n == 1: print "Thursday" elif n == 2: print "Tryday" elif n == 3: print "Saturday" elif n == 4: print "Sunday" elif n == 5: print "Monday" elif n == 6: print "Tuesday" else: print "Wednesday" ~ ~ ~ ~
s655013966
p00027
u350508326
1372113550
Python
Python
py
Runtime Error
0
0
907
nm = [0,31,29,31,30,31,30,31,31,30,31,30] while True: m,d = map(int,raw_input().split(" ")) if m == 0: break nd = 0 for i in range(m): nd += nm[i] nd += d n = nd%7 if n == 1: print "Thursday" elif n == 2: print "Friday" elif n == 3: print "Saturday" elif n == 4: print "Sunday" elif n == 5: print "Monday" elif n == 6: print "Tuesday" else: print "Wednesday" ~ ~ ~
s527616498
p00027
u350508326
1372114182
Python
Python
py
Runtime Error
0
0
901
nm = [0,31,29,31,30,31,30,31,31,30,31,30] while True: m,d = map(int,raw_input().split(" ")) if m == 0: break else: nd = 0 for i in range(m): nd += nm[i] nd += d n = nd%7 if n == 1: print "Thursday" elif n == 2: print "Friday" elif n == 3: print "Saturday" elif n == 4: print "Sunday" elif n == 5: print "Monday" elif n == 6: print "Tuesday" else: print "Wednesday" ~ ~
s442086726
p00027
u633068244
1393391963
Python
Python
py
Runtime Error
0
0
92
while True: m, d = map(int, raw_inpud().split()) if m == 0 and d == 0: break
s922785544
p00027
u633068244
1393392726
Python
Python
py
Runtime Error
0
0
329
y = [31,29,31,30,31,30,31,31,30,31,30,31] dow = [0:"Monday", 1:"Thuesday", 2:"Wednesday", 3:"Thursday", 4:"Friday", 5:"Saturday", 6:"Sunday"] while True: m, d = map(int, raw_inpud().split()) if m == 0 and d == 0: break n = 0 for i in range(m): n += y[i] n -= (n[m]-d+1) print dow[(n+3)%7]
s222793806
p00027
u912237403
1394315183
Python
Python
py
Runtime Error
0
0
255
wd=["Mon","Tues","Wednes","Thurs","Fri","Satur","Sun"] md=[0,31,29,31,30,31,30,31,31,30,31,30,31] while 1: m,d = map(int, raw_input().split()) if m==0: break s = sum([md[i] for i in range(month)]) + day + 2 s = wd[s % 7]+"day" print s
s544629219
p00028
u560838141
1408859469
Python
Python
py
Runtime Error
0
0
186
hist = [0 for i in range(100)] l = [] while True: try: hist[input() - 1] += 1 except: break; for k in filter(lambda x: max(hist) == x[1], enumlate(hist)): print k[0] + 1
s257242906
p00028
u379956761
1435314589
Python
Python3
py
Runtime Error
0
0
296
import sys count = [0 for _ in range(100)] mode = [0] for s in sys.stdin: x = int(s) count[x-1] += 1 for i in range(len(count)): if count[i] > mode[0]: mode.clear() mode.append(i+1) elif count[i] == mode[0]: mode.append(i+1) for i in mode: print(i)
s431059801
p00028
u379956761
1435314691
Python
Python3
py
Runtime Error
0
0
290
import sys count = [0 for _ in range(101)] mode = [0] for s in sys.stdin: x = int(s) count[x] += 1 for i in range(len(count)): if count[i] > mode[0]: mode.clear() mode.append(i) elif count[i] == mode[0]: mode.append(i) for i in mode: print(i)
s340852889
p00028
u560214129
1450502096
Python
Python3
py
Runtime Error
0
0
508
import sys def max(count): m = count[0] for i in range(1,len(count)): if count[i] > m: m = count[i] return m list = [] count = [] mode = 0 for i in range(10): count.append(0) list.append('m') for line in sys.stdin.readlines(): num = int(line) if num not in list: list[num] = num count[num] = count[num] + 1 else: count[num] = count[num] + 1 m = max(count) print("max is",m) for i in range(len(count)): if m == count[i]: print(list[i])
s881167344
p00028
u560214129
1450502357
Python
Python3
py
Runtime Error
0
0
490
import sys def max(count): m = count[0] for i in range(1,len(count)): if count[i] > m: m = count[i] return m list = [] count = [] mode = 0 for i in range(10): count.append(0) list.append('m') for line in sys.stdin.readlines(): num = int(line) if num not in list: list[num] = num count[num] = count[num] + 1 else: count[num] = count[num] + 1 m = max(count) for i in range(len(count)): if m == count[i]: print(list[i])
s939834813
p00028
u650459696
1458984280
Python
Python3
py
Runtime Error
0
0
362
a, md = [], [] c, mx = 1, 1 while True: try: a.append(int(input())) except EOFError: break a = sorted(a) print(a) for i in range(0, len(a) - 1): if a[i] == a[i + 1]: c += 1 else: c = 1 if mx < c: mx = c md = [a[i]] elif mx == c: md.append(a[i]) print('\n'.join(map(str, sorted(md)))
s981109715
p00028
u966364923
1459427605
Python
Python3
py
Runtime Error
0
0
286
import collections import sys cntr = collections.Counter for line in sys.stdin: cntr[int(line)] += 1 lst = [] for k,v in cntr.items(): lst.append((v,k)) lst.sort() t = len(lst)-1 while t>0 and lst[t][0] == lst[t-1][0]: t -= 1 for i in range(t,len(lst)): print(lst[i][1])
s765900581
p00028
u300946041
1469014283
Python
Python3
py
Runtime Error
0
0
373
# -*- coding: utf-8 -*- DICT = {k: 0 for k in range(0, 10)} def solve(d): l = [] _max = max(d.values()) for k, v in d.items(): if _max == v: l.append(k) print('\n'.join(l)) if __name__ == '__main__': while True: try: n = int(input()) DICT[n] += 1 except: break solve(DICT)
s142397502
p00028
u301729341
1481123041
Python
Python3
py
Runtime Error
0
0
438
kosu = [0] * 100 k = 1 while True: try: n = int(input()) kosu[n - 1] += 1 except (EOFError,ValueError): ma = max(kosu) num = kosu.index(ma) + k print(num) kosu.remove(max(kosu)) while True: if ma > max(kosu): break k += 1 num = kosu.index(ma) + k kosu.remove(max(kosu)) print(num)
s615773268
p00028
u546285759
1481887834
Python
Python3
py
Runtime Error
0
0
208
import sys from itertools import dropwhile a = [] for v in sys.stdin: a.append(int(v)) m = max([a.count(v) for v in set(a)]) next(dropwhile(lambda x: True, (print(v) for v in set(a) if a.count(v) == m)))
s191551803
p00028
u711765449
1483969851
Python
Python3
py
Runtime Error
0
0
255
# -*- coding:utf-8 -*- import sys array = [] for i in sys.stdin: array.append(int(i)) data = [0]*100 for i in range(len(array)): data[array[i]] += 1 m = [i for i,j in enumerate(data) if j == max(data)] for i in range(len(m)): print(m[i])
s027611519
p00028
u072398496
1489290030
Python
Python
py
Runtime Error
0
0
134
import sys c=[0 for i in range(101)] for n in sys.stdin: n=int(n) counter[n]+=1 m=max(c) for i in range(101): if c[i]==m: print i
s884876907
p00028
u184989919
1505712635
Python
Python3
py
Runtime Error
0
0
157
import sys arr = [0 for i in range(0,101)] for i in sys.stdin: arr[int(i)] += 1 max = max(arr) for i in for(0,101): if arr[i]==max: print(i)
s223152813
p00028
u933096856
1506369224
Python
Python3
py
Runtime Error
0
0
264
d={} try: while True: n=int(input()) if n in d: d[n]+=1 else: d[n]=1 except EOFError: pass a=[] m=max(d.value()) for key, value in d: if value == m: a.append(key) a.sort() for i in a: print(i)
s432767459
p00028
u845643816
1509254773
Python
Python3
py
Runtime Error
0
0
295
# 0028 import collections array = [0]*100 i = 0 while True: a = input() if a == '': break array[i] = int(a) i += 1 array = filter(lambda a: a != 0, array) counter = collections.Counter(array).most_common() for a, count in counter: if count < counter[0][1]: break print(a)
s181423045
p00028
u845643816
1509255503
Python
Python3
py
Runtime Error
0
0
281
# 0028 import collections array = [0]*100 i = 0 while True: try: array[i] = int(input()) i += 1 except EOFError: break array = filter(lambda a: a != 0, array) max = max(array.count()) print(filter(lambda a: array.count(a) == max, array), sep = '\n')
s691692808
p00028
u845643816
1509257208
Python
Python3
py
Runtime Error
0
0
300
# 0028 import collections array = [] i = 0 while True: try: array.append(int(input())) i += 1 except ValueError: break count = list(map(lambda a: array.count(a), array)) modes = list(set(filter(lambda a: array.count(a) == max(count), array))) print(*modes, sep = '\n')
s322323376
p00028
u845643816
1509259928
Python
Python3
py
Runtime Error
0
0
276
# 0028 array = [] while True: try: a = input() array.append(int(a)) except EOFError: break s = set(array) mx = max(list(map(lambda a: array.count(a), s))) modes = list(filter(lambda a: array.count(a) == mx), sorted(s)) print(*modes, sep = '\n')
s284192584
p00028
u845643816
1509259937
Python
Python3
py
Runtime Error
0
0
302
# 0028 array = [] while True: try: a = input() if a == '': break array.append(int(a)) except EOFError: break s = set(array) mx = max(list(map(lambda a: array.count(a), s))) modes = list(filter(lambda a: array.count(a) == mx), sorted(s)) print(*modes, sep = '\n')
s244156714
p00028
u845643816
1509260023
Python
Python3
py
Runtime Error
0
0
298
# 0028 array = []*100 i = 0 while True: try: a = input() array[i] = int(a) i += 1 except EOFError: break s = set(array) mx = max(list(map(lambda a: array.count(a), s))) modes = list(filter(lambda a: array.count(a) == mx, sorted(s))) print(*modes, sep = '\n')
s972441918
p00028
u419407022
1356271513
Python
Python
py
Runtime Error
0
0
176
import sys l = [] c = list([0] * 100) for i in sys.stdin.readlines(): c[int(i)] += 1 m = max(c) for i in xrange(c.count(m)): i = c.index(m) print i + 1 c.pop(i)
s897792455
p00028
u419407022
1356271544
Python
Python
py
Runtime Error
0
0
180
import sys l = [] c = list([0] * 100) for i in sys.stdin.readlines(): c[int(i - 1)] += 1 m = max(c) for i in xrange(c.count(m)): i = c.index(m) print i + 1 c.pop(i)
s205842697
p00028
u912237403
1378066301
Python
Python
py
Runtime Error
0
0
149
d=[0]*101 while True: try: n=input() d[n]+=1 except: break tmp=max(d) for i in range(101): if d[i]=tmp: print i
s898913857
p00028
u193025715
1395397311
Python
Python
py
Runtime Error
0
0
387
nums = [] val = [] while True: try: nums.append(int(raw_input())) except EOFError: num_list = sorted(list(set(nums))) for n in num_list: val.append(nums.count(n)) ans.append(num_list[val.index(max(val))]) tmp = max(val) val.remove(max(val)) while max(val) == tmp: ans.append(num_list[val.index(max(val))]) val.remove(max(val)) for s in ans: print s break
s244285619
p00028
u193025715
1395397801
Python
Python
py
Runtime Error
0
0
441
nums = [] val = [] ans = [] while True: try: nums.append(int(raw_input())) break: num_list = sorted(list(set(nums))) for n in num_list: val.append(nums.count(n)) ans.append(num_list[val.index(max(val))]) tmp = max(val) val.remove(max(val)) num_list.pop(val.index(tmp)) while max(val) == tmp: ans.append(num_list[val.index(max(val))]) num_list.pop(val.index(tmp)) val.remove(max(val)) for s in ans: print s
s138453021
p00029
u525366883
1535623517
Python
Python
py
Runtime Error
0
0
255
# coding: utf-8 # Your code here! a = raw_input().lower() s = a.split() ss = "" tmp = "" n = 0 for i in s: if len(ss) < len(i): ss = i for i in s: i+=" " if a.count(i) > n: n = a.count(i) tmp = i.trip() print tmp, ss
s886572503
p00029
u560838141
1408860091
Python
Python
py
Runtime Error
0
0
230
while True: words = raw_input().strip().split(" ") count = {}; for word in words: s = count.setdefault(word, 0); count[word] = s + 1 print max(count.items(), key=lambda x: x[1])[0], max(words, key=lambda x: len(x))
s779294404
p00029
u506132575
1416141212
Python
Python
py
Runtime Error
0
0
492
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys dic = {} for s in sys.stdin: d = [ e.lower() for e in map(str,s.split()) ] for e in d: if e in dic: dic[e] += 1 else: dic[e] = 1 sdict = sorted(dic.items(),key=lambda x:-x[1]) maxnum = sdict[0][1] for i in range(len(sdict)): if sdict[i][1] == maxnum: print sdict[i][0], else: break maxlen = max([len(e) for e in d]) longterm = [ e for e in d if len(e) == maxlen ] for e in longterm: print e,
s707426300
p00029
u567380442
1422883478
Python
Python3
py
Runtime Error
0
0
218
import sys f = sys.stdin rhombus = oblong = 0 for line in f: a, b, c = map(int, line.split(',')) if a == b: rhombus += 1 if a * a + b * b == c * c: oblong += 1 print(oblong) print(rhombus)
s085030920
p00029
u879226672
1424159766
Python
Python
py
Runtime Error
0
0
544
# -*- coding: utf-8 -*- while True: try: ls = [] dic = {}# {'your' : [appeared,len]} ls = raw_input().split() for k in range(len(ls)): if ls[k] not in dic.keys(): dic[ls[k]] = [] dic[ls[k]].append(1) dic[ls[k]].append(len(ls[k])) else: dic[ls[k]][0] += 1 a=max(dic) # value[0] b=max(dic.items(), key=lambda x: x[1][1])[0] print "%s %s" % (a,b) except EOFError: break
s693346938
p00029
u879226672
1424159904
Python
Python
py
Runtime Error
0
0
520
while True: try: ls = [] dic = {}# {'your' : [appeared,len]} ls = raw_input().split() for k in range(len(ls)): if ls[k] not in dic.keys(): dic[ls[k]] = [] dic[ls[k]].append(1) dic[ls[k]].append(len(ls[k])) else: dic[ls[k]][0] += 1 a=max(dic) # value[0] b=max(dic.items(), key=lambda x: x[1][1])[0] print "%s %s" % (a,b) except EOFError: break
s336145294
p00029
u461370825
1449744900
Python
Python
py
Runtime Error
0
0
298
from math import * PI = 3.1415926535898 while True: try: arr = map(str, raw_input().strip().split()) ans1 = arr[0] ans2 = arr[0] for s in arr: if arr.count(s) > arr.count(ans1): ans1 = s if len(s) > len(ans2): ans2 = s print "%s %s" % (ans1, ans2) except EOFError: break
s221340421
p00029
u148101999
1459391909
Python
Python
py
Runtime Error
0
0
230
#encoding=utf-8 import statistics as st word1 = [] word = raw_input().split() print st.mode(word) for i in xrange(len(word)): word1.append(len(word[i])) for i in xrange(len(word)): if len(word[i]) == max(word1): print word[i]
s178485971
p00029
u148101999
1459391990
Python
Python
py
Runtime Error
0
0
216
import statistics as st word1 = [] word = raw_input().split() for i in xrange(len(word)): word1.append(len(word[i])) for i in xrange(len(word)): if len(word[i]) == max(word1): print st.mode(word), word[i] break
s253994800
p00029
u148101999
1459392046
Python
Python3
py
Runtime Error
0
0
217
import statistics as st word1 = [] word = raw_input().split() for i in xrange(len(word)): word1.append(len(word[i])) for i in xrange(len(word)): if len(word[i]) == max(word1): print(st.mode(word), word[i]) break
s015064809
p00029
u011621222
1509749644
Python
Python3
py
Runtime Error
0
0
516
import sys def main(): input_line = [] test_line = 'Thank you for your mail and your lectures' # for line in test_line.split(): # input_line.append(line) for line in sys.stdin: input_line.append(line.split()) #print(input_line.count('your')) number_len = {} number_fre = {} for i in input_line: number_len.update({i:len(i)}) number_fre.update({i:test_line.count(i)}) if __name__ == '__main__': main()
s919582965
p00029
u011621222
1509757338
Python
Python3
py
Runtime Error
0
0
680
import sys def main(): input_line = [] # with open('test_data') as f: # for line in f.readline().split(): # input_line.append(line) for line in sys.stdin.readline().split(): input_line.append(line) #print(input_line) number_len = {} number_fre = {} for i in input_line: number_len.update({i:len(i)}) number_fre.update({i:input_line.count(i)}) sorted_x = sorted(number_len.items(), key=operator.itemgetter(1)) sorted_y = sorted(number_fre.items(), key=operator.itemgetter(1)) print(sorted_x[-1][0],sorted_y[-1][0]) if __name__ == '__main__': main()
s325803005
p00029
u928329738
1511778492
Python
Python3
py
Runtime Error
0
0
221
from collections import Counter def most_arise(s): c = Counter(s.split()) maxone = sorted(s.split(),key=lambda x:len(x))[-1] print("{0} {1}".format(c.most_common()[0][0],maxone)) s = raw_input() most_arise(s)
s540057432
p00029
u928329738
1511778594
Python
Python3
py
Runtime Error
0
0
179
from collections import Counter s = raw_input() c = Counter(s.split()) maxone = sorted(s.split(),key=lambda x:len(x))[-1] print("{0} {1}".format(c.most_common()[0][0],maxone))
s548446557
p00029
u928329738
1511778637
Python
Python3
py
Runtime Error
0
0
143
s = raw_input() c = Counter(s.split()) maxone = sorted(s.split(),key=lambda x:len(x))[-1] print("{0} {1}".format(c.most_common()[0][0],maxone))
s186137145
p00029
u912237403
1378121678
Python
Python
py
Runtime Error
0
0
217
for word in s: try: dic[word]+=1 except: dic[word]=1 m=0 l=0 for word, e in dic.items(): if e>m: m=e w1=word if len(word)>l: l=len(word) w2=word print w1, w2
s637949460
p00029
u708217907
1398813782
Python
Python
py
Runtime Error
0
0
318
import datetime, sys wday_lst = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] for s in sys.stdin: m,d = map(int, s.split()) if m == 0 or d == 0: break str = '2004-%d-%d 00:00:00'%(m,d) day = datetime.datetime.strptime(str, '%Y-%m-%d %H:%M:%S') print wday_lst[day.weekday()]
s277008167
p00030
u647694976
1556258474
Python
Python3
py
Runtime Error
0
0
294
import itertools import combinations while True: n,s=map(int,input().split()) if n==0 and s==0: break num=[i for i in range(0,s+1)] print(num) ans=0 comb=itertools.combinations(num,n) for c in comb: if sum(c) == s: ans +=1 print(ans)
s243854071
p00030
u316268279
1418003362
Python
Python3
py
Runtime Error
0
0
394
#!/usr/bin/env python # -*- coding: utf-8 -*- import itertools S = [] N = [] while True: n,s = map(int,input().split(" ")) if s == 0 and n == 0: break else: N.append(n) S.append(s) for i in range(0,len(S)): sumMap = list(map(sum,list(itertools.combinations(range(0,S[i]+1),N[i])))) print(sum([1 for j in range(0,len(sumMap)) if sumMap[j] == S[i]]))
s166802799
p00030
u567380442
1423028196
Python
Python3
py
Runtime Error
0
0
206
import sys f = sys.stdin while True: n, s = map(int, f.readline().split()) if n == 0: break print(sum(1 for nums in itertools.combinations([i for i in range(10)], n) if sum(nums) == s))
s482001740
p00030
u873482706
1434614567
Python
Python
py
Runtime Error
0
0
596
def move(move_count, current, flag): for i in range(move_count): n_lis.append(num_lis[current+i]) if flag == n: calculate() del n_lis[-1] else: move(move_count, current+i+1, flag+1) move_count -= 1 del n_lis[-1] def calculate(): print n_lis global count if sum(n_lis) == s: count += 1 while True: n, s = map(int, raw_input().split()) if n == 0 and s == 0: break num_lis = [0,1,2,3,4,5,6,7,8,9] n_lis = [] count = 0 move(8,0,1) print count
s418019543
p00030
u873482706
1434614598
Python
Python
py
Runtime Error
0
0
596
def move(move_count, current, flag): for i in range(move_count): n_lis.append(num_lis[current+i]) if flag == n: calculate() del n_lis[-1] else: move(move_count, current+i+1, flag+1) move_count -= 1 del n_lis[-1] def calculate(): print n_lis global count if sum(n_lis) == s: count += 1 while True: n, s = map(int, raw_input().split()) if n == 0 and s == 0: break num_lis = [0,1,2,3,4,5,6,7,8,9] n_lis = [] count = 0 move(8,0,1) print count
s654145994
p00030
u873482706
1434615091
Python
Python
py
Runtime Error
0
0
580
def move(move_count, current, flag): for i in range(move_count): n_lis.append(num_lis[current+i]) if flag == n: calculate() del n_lis[-1] else: move(move_count, current+i+1, flag+1) move_count -= 1 del n_lis[-1] def calculate(): global count if sum(n_lis) == s: count += 1 while True: n, s = map(int, raw_input().split()) if n == 0 and s == 0: break num_lis = [0,1,2,3,4,5,6,7,8,9] n_lis = [] count = 0 move(8,0,1) print count
s423646646
p00030
u775586391
1448352911
Python
Python3
py
Runtime Error
0
0
256
def f(n,s,x): if n == s == 0: return 1 elif n == 0 or x == 0: return 0 else: a = 0 for i in range(x): a += f(n-1,s-i,i) return a while True: n,s = map(int,raw_input().split()) if n == s == 0: break print(f(n,s,10))
s759718526
p00030
u379499530
1473155986
Python
Python
py
Runtime Error
0
0
193
import itertools while 1: n, s = map(int, raw_input().split()) d = [i for i in xrange(s)] if n == 0: break x = map(sum, list(itertools.combinations(d, n))) print x.count(s)
s447524333
p00030
u379499530
1473156522
Python
Python
py
Runtime Error
0
0
200
import itertools d = [i for i in xrange(101)] while 1: n, s = map(int, raw_input().split()) if n == 0: break x = map(sum, list(itertools.combinations(d[0:s + 1], n))) print x.count(s)
s034887347
p00030
u777299405
1480061408
Python
Python3
py
Runtime Error
0
0
235
while True: n = int(input()) a = sorted(list(map(int, input().split()))) if n == 0: break ans = 1000 for i in range(n - 1): j = a[i + 1] - a[i] if j <= ans: ans = j print(ans)
s493873057
p00030
u777299405
1480061492
Python
Python3
py
Runtime Error
0
0
236
while True: n = int(input()) if n == 0: break a = sorted(list(map(int, input().split()))) ans = 10000 for i in range(n - 1): j = a[i + 1] - a[i] if j <= ans: ans = j print(ans)
s292587805
p00030
u811733736
1481689910
Python
Python3
py
Runtime Error
0
0
1346
from collections import deque class Bt(object): def __init__(self): self.used = [False] * 10 # ?????°???????????¨?????????????????????????????° self.answers = [] # ?????¶??????????????????????????? self.Q = deque() # ????????§???????????¢??????????????°???????¨???¶??¨ def solve(self, num, rem): num -= 1 if rem < 10 and self.used[rem] == False and num == 0: self.Q.append(rem) # print('{0}'.format(self.Q)) ans = [*self.Q] ans.sort() if not ans in self.answers: self.answers.append(ans) self.Q.pop() return try: min_num = self.used.index(True) except ValueError: min_num = 0 for i in range(min_num, 10): if self.used[i] == False and (rem - i) >= 0: self.used[i] = True self.Q.append(i) self.solve(num, rem - i) self.used[i] = False self.Q.pop() if __name__ == '__main__': while True: # ??????????????\??? n, s = [int(x) for x in input().split(' ')] if n == 0 and s == 0: break # ???????????? a = Bt() a.solve(n, s) # ???????????¨??? print(len(a.answers))
s726885421
p00030
u811733736
1481698950
Python
Python3
py
Runtime Error
0
0
1444
from collections import deque class Bt(object): def __init__(self): self.used = [False] * 10 # ?????°???????????¨?????????????????????????????° self.answers = [] # ?????¶??????????????????????????? self.Q = deque() # ????????§???????????¢??????????????°???????¨???¶??¨ def solve(self, num, remain): num -= 1 if remain < 10 and self.used[remain] == False and num == 0: self.Q.append(remain) # print('{0}'.format(self.Q)) ans = [*self.Q] ans.sort() if not ans in self.answers: self.answers.append(ans) self.Q.pop() return try: min_num = self.used.index(True) except ValueError: min_num = 0 for i in range(min_num, 10): if self.used[i] == False and (remain - i) >= 0: self.used[i] = True self.Q.append(i) self.solve(num, remain - i) self.used[i] = False self.Q.pop() if __name__ == '__main__': while True: # ??????????????\??? n, s = [int(x) for x in input().split(' ')] if n == 0 and s == 0: break if 0 <= s <= 45: # ???????????? a = Bt() a.solve(n, s) # ???????????¨??? print(len(a.answers)) else: print(0)
s129658057
p00030
u811733736
1481703504
Python
Python3
py
Runtime Error
0
0
1481
from collections import deque class Bt(object): def __init__(self): self.used = [False] * 10 # 0-9????????°???????????¨?????????????????????????????° self.answers = [] # ?????¶??????????????????????????? self.Q = deque() # ????????§???????????¢??????????????°???????¨???¶??¨ def solve(self, num, remain): if remain < 10 and self.used[remain] == False and num == 1: self.Q.append(remain) # print('{0}'.format(self.Q)) ans = [*self.Q] ans.sort() if not ans in self.answers: self.answers.append(ans) self.Q.pop() return elif num < 0: return try: min_choice = max(self.Q) + 1 except ValueError: min_choice = 0 for i in range(min_choice, 10): if self.used[i] == False and (remain - i) >= 0: self.used[i] = True self.Q.append(i) self.solve(num - 1, remain - i) self.used[i] = False self.Q.pop() if __name__ == '__main__': while True: # ??????????????\??? n, s = [int(x) for x in input().split(' ')] if n == 0 and s == 0: break if 0 <= s <= 45: # ???????????? a = Bt() a.solve(n, s) # ???????????¨??? print(len(a.answers)) else: print(0)
s834072829
p00030
u811733736
1481705205
Python
Python3
py
Runtime Error
0
0
1664
from collections import deque class Bt(object): def __init__(self): self.used = [False] * 10 # 0-9????????°???????????¨?????????????????????????????° self.answers = [] # ?????¶??????????????????????????? self.Q = deque() # ????????§???????????¢??????????????°???????¨???¶??¨ def solve(self, num, remain): # ????´¢??????????°??????§?????????????????????????????§????????????????????§????????°?????????????????????????????? try: min_choice = max(self.Q) + 1 except ValueError: min_choice = 0 if min_choice <= remain < 10 and self.used[remain] == False and num == 1: self.Q.append(remain) # print('{0}'.format(self.Q)) ans = [*self.Q] ans.sort() if not ans in self.answers: self.answers.append(ans) self.Q.pop() # self.answers.append(1) return elif num < 0: return for i in range(min_choice, 10): if self.used[i] == False and (remain - i) >= 0: self.used[i] = True self.Q.append(i) self.solve(num - 1, remain - i) self.used[i] = False self.Q.pop() if __name__ == '__main__': while True: # ??????????????\??? n, s = [int(x) for x in input().split(' ')] if n == 0 and s == 0: break if 0 <= s <= 45: # ???????????? a = Bt() a.solve(n, s) # ???????????¨??? print(len(a.answers)) else: print(0)
s661991808
p00030
u087002048
1482069367
Python
Python3
py
Runtime Error
0
0
728
class Depth_First_Search_stack: def __init__(self, n, s): self.n = n self.s = s self.stack=[[i] for i in range(self.s)] self.ans = 0 def search(self): while self.stack: c = self.stack.pop() if sum(c) == self.s and len(c) == self.n: self.ans += 1 for i in range(max(c)+1, self.s-max(c) + 1): if sum(c+[i]) <= self.s and len(c+[i]) <= self.n: self.stack.append(c+[i]) if __name__ == '__main__': while 1: n, s = list(map(int, input().split(' '))) if n==0 and s==0: break DFS = Depth_First_Search_stack(n, s) DFS.search() print(DFS.ans) ~
s677492783
p00030
u032662562
1486803611
Python
Python3
py
Runtime Error
0
0
362
def solve(n,s,lst): if n == 0 and s == 0: return(1) elif s < lst[0] or len(lst)==0: return(0) else: return(solve(n-1,s-lst[0],lst[1:]) + solve(n,s,lst[1:])) if __name__ == "__main__": while True: n, s = map(int, input().split()) if n==0 and s==0: break print(solve(n,s,list(range(9))))
s679605808
p00030
u150984829
1517605144
Python
Python3
py
Runtime Error
0
0
115
while 1: n,s=map(int,input().split()) if n:print(len([1 for i in range(0,8)for j in range(i+1,9)if j<s-i-j<=9]))
s423935973
p00030
u150984829
1517637569
Python
Python3
py
Runtime Error
0
0
141
from itertools import combinations while 1: n,s=map(int,input().split()) if n:print(sum(1 for p in combinations(range(10),n)if sum(p)==s))
s998592052
p00030
u150984829
1517637673
Python
Python3
py
Runtime Error
0
0
153
from itertools import combinations while 1: n,s=map(int,input().split()) if n+x==0:break print(sum(1 for p in combinations(range(10),n)if sum(p)==s))
s728483846
p00030
u150984829
1517637920
Python
Python3
py
Runtime Error
0
0
143
from itertools import combinations while 1: n,s=map(int,input().split()) if n:print(sum([1 for p in combinations(range(10),n)if sum(p)==s]))
s304859522
p00030
u150984829
1517638127
Python
Python3
py
Runtime Error
0
0
141
from itertools import combinations while 1: n,s=map(int,input().split()) if n:print(sum(1 for p in combinations(range(10),n)if sum(p)==s))
s981794196
p00030
u504990413
1354719902
Python
Python
py
Runtime Error
0
5344
296
import itertools while True: a,b = map(int, raw_input().split(' ')) count = 0 if a == 0 and b == 0: break else: for com in itertools.combinations([0,1,2,3,4,5,6,7,8,9],a): if sum(com) == b: count += 1 print count
s526023438
p00030
u504990413
1355829979
Python
Python
py
Runtime Error
0
0
328
import itertools while True: a,b = map(str, raw_input().split(' ')) a = int(a) b = int(b) count = 0 if a == 0 and b == 0: break else: for com in itertools.combinations([0,1,2,3,4,5,6,7,8,9],a): if sum(com) == b: count += 1 print count
s108713800
p00030
u419407022
1356279972
Python
Python
py
Runtime Error
0
0
310
while True: (n, s) = [int(i) for i in raw_input().split()] if((0,0) == (n,s)): break r = xrange(10**(n-1),10**n) r = map(str,r) r = filter(lambda x:len(set(x)) == len(x),r) r = map(lambda x:map(int,x),r) r = filter(lambda x:reduce(lambda x,y:x+y,x) == s, r) print len(r)
s033079840
p00030
u542421762
1368280507
Python
Python
py
Runtime Error
0
0
366
import sys def subset(a): for n in range(2**len(a)): yield [a[i] for i in xrange(len(a)) if (n >> i) & 1 == 1] for line in sys.stdin: (n, s) = tuple(map(int, line.rstrip('\r\n').split(' '))) if n == 0 and s == 0: exit() x = 0 for b in subset(range(10)): if len(b) == n and sum(b) == s: x += 1 print x
s462737866
p00030
u912237403
1379238204
Python
Python
py
Runtime Error
0
0
430
def dec2bin(n, base=10): s="" x=["0","1"] while n>0: s+=x[n%2] n/=2 return (s+"0"*base)[:base] x=[[0 for i in range(50)] for i in range(11)] for i in range(0, 2**10): tmp = dec2bin(i) s=0 c=0 for j in range(10): if tmp[j]=="1": s+=j c+=1 x[c][s]+=1 while True: n,s=map(int, raw_input().split()) if n==0 and s==0: break print x[n][s]
s645822064
p00030
u912237403
1394320878
Python
Python
py
Runtime Error
0
0
289
x = [[0]*50 for i in range(11)] for i in range(0, 2**10): B = format(i,'b')[::-1] s,c,j = 0,0,0 for e in B: if e=="1": s,c = s+j, c+1 j += 1 x[c][s]+=1 while 1: n, s=map(int, raw_input().split()) if n==0 and s==0: break print [x[n][s],0][s>=50]
s060484031
p00030
u912237403
1394321514
Python
Python
py
Runtime Error
0
0
301
x = [[0]*50 for i in range(11)] for i in range(0, 2**10): B = format(i,'b')[::-1] s,c,j = 0,0,0 for e in B: if e=="1": s+=j; c+=1 j += 1 x[c][s] += 1 while 1: n,s = map(int, raw_input().split()) if n==0 and s==0: break print 0 if s>=50 else x[n][s]
s045109678
p00031
u647694976
1556531030
Python
Python3
py
Runtime Error
0
0
352
def bin(w, l):   if w == 0:     return l     l.append(w % 2)   return bin(w // 2, l)   while True:   try:     w = int(input())     w_bin = bin(w, [])     ans = ""     for i, v in enumerate(w_bin):       if v:         ans += str(2 ** i) + " "     print(ans.rstrip())     except EOFError:     break
s495881677
p00031
u469154576
1479043411
Python
Python
py
Runtime Error
0
0
199
import sys """ a=[] while True: n=input() if n==-1: break a.append(n) """ for line in sys.stdin: a.append(int(line)) for x in a: out=1 while x: if x&1: print out, x/=2 out*=2 print
s855039518
p00031
u777299405
1480660336
Python
Python3
py
Runtime Error
0
0
259
import sys waight = ["1", "2", "4", "8", "16", "32", "64", "128", "256", "512"] for n in sys.stdin: ans = [] n = bin(n)[2:].zfill(10) for i, x in enumerate(n[::-1]): if x == "1": ans.append(waight[i]) print(" ".join(ans))
s389433264
p00031
u777299405
1480661008
Python
Python3
py
Runtime Error
0
0
259
import sys waight = ["1", "2", "4", "8", "16", "32", "64", "128", "256", "512"] for n in sys.stdin: ans = [] n = bin(n)[2:].zfill(10) for i, x in enumerate(n[::-1]): if x == "1": ans.append(waight[i]) print(" ".join(ans))
s445424539
p00031
u901080241
1491634452
Python
Python3
py
Runtime Error
0
0
185
while True: instr = str(bin(int(input()))) ans = [] for i in range(len(instr)): if instr[-i]=="1": ans.append(1<<i-1) print(" ".join(map(lambda x: str(x), ans)))
s606896802
p00031
u011621222
1509014858
Python
Python3
py
Runtime Error
0
0
965
# -*- coding: utf-8 -*- # !/usr/bin/env python # vim: set fileencoding=utf-8 : """ # # Author: Noname # URL: https://github.com/pettan0818 # License: MIT License # Created: 木 10/26 19:32:38 2017 # Usage # """ import sys WEIGHTS = [2 ** i for i in range(9)] def solver_greedy(target_weight: int): """ >>> print(solver_greedy(127)) [1, 2, 4, 8, 16, 32, 64] """ res = [] for w in sorted(WEIGHTS, reverse=True): if w <= target_weight: res.append(w) target_weight = target_weight - w if target_weight == 0: return sorted(res) if __name__ == '__main__': data = [] for line in sys.stdin: data.append(int(line)) for i in data: res = solver_greedy(i) for x,n in enumerate(res): sys.stdout.write(str(n)) if x + 1 == len(data): sys.stdout.write("\n") break sys.stdout.write(" ")
s735854925
p00031
u011621222
1509015671
Python
Python3
py
Runtime Error
0
0
1057
# -*- coding: utf-8 -*- # !/usr/bin/env python # vim: set fileencoding=utf-8 : """ # # Author: Noname # URL: https://github.com/pettan0818 # License: MIT License # Created: 木 10/26 19:32:38 2017 # Usage # """ import sys WEIGHTS = [2 ** i for i in range(9)] def solver_greedy(target_weight: int): """ >>> print(solver_greedy(127)) [1, 2, 4, 8, 16, 32, 64] >>> print(solver_greedy(10)) [2, 8] """ res = [] for w in sorted(WEIGHTS, reverse=True): if w <= target_weight: res.append(w) target_weight = target_weight - w if target_weight == 0: return sorted(res) if __name__ == '__main__': data = [] for line in sys.stdin: data.append(line.rstrip("\n")) data = [int(d) for d in data[:-1]] for i in data: res = solver_greedy(i) for x,n in enumerate(res): sys.stdout.write(str(n)) if x + 1 == len(data): sys.stdout.write("\n") break sys.stdout.write(" ")
s501206760
p00031
u009288816
1515324798
Python
Python
py
Runtime Error
0
0
420
import sys def isn2(x): if(x == 1): return True elif(x % 2 != 0): return False return True and isn2(x/2) def n2(x): a = 1 while(True): print a, x -= a if(isn2(x) == True): print x, break a *= 2 if(a > x): break print l = [] for input in sys.stdin: l.append(int(input)) for data in l: n2(data)
s639061881
p00031
u150984829
1517639192
Python
Python3
py
Runtime Error
0
0
89
while 1:print(*[int(b)*2**i for i,b in enumerate(bin(int(input()))[2:][::-1])if int(b)])
s943820274
p00031
u150984829
1517639237
Python
Python3
py
Runtime Error
0
0
113
import sys while 1:print(*[int(b)*2**i for i,b in enumerate(bin(int(sys.stdin.readline()))[2:][::-1])if int(b)])
s012591157
p00031
u306037418
1518313781
Python
Python3
py
Runtime Error
0
0
291
while True: g = int(input()) now = 512 ans = [] while True: if g == 0: break elif g >= now: g -= now ans.append(now) now //= 2 temp = '' for i in ans[::-1]: temp += str(i) + ' ' print(temp[:-1])
s184153847
p00031
u350508326
1369238503
Python
Python
py
Runtime Error
0
0
416
mport math def cal(x): a=10 y= [] for i in range(1,11): d= pow(2,(10-i)) if x>=d: x -= d y.append(d) return y if __name__ == "__main__": while True: try: a=int(raw_input()) b = cal(a) b.reverse() for y in b: print y, print except EOFError: break
s480217834
p00031
u180584272
1379830930
Python
Python
py
Runtime Error
0
0
215
for n in sys.stdin: ans = [] n = int(n) nb = format(n,'b') nb.reverse nb += " "*(10-len(nb)) for i in xrange(10): if nb[i] == 1: answer.append(str(2**i)) print ' '.join(answer)
s851397672
p00031
u180584272
1379830971
Python
Python
py
Runtime Error
0
0
209
for n in sys.stdin: ans = [] n = int(n) nb = format(n,'b') nb.reverse nb += " "*(10-len(nb)) for i in xrange(10): if nb[i] == 1: ans.append(str(2**i)) print ' '.join(ans)
s359883443
p00031
u180584272
1379831007
Python
Python
py
Runtime Error
0
0
220
import sys for n in sys.stdin: ans = [] n = int(n) nb = format(n,'b') nb.reverse nb += " "*(10-len(nb)) for i in xrange(10): if nb[i] == 1: ans.append(str(2**i)) print ' '.join(ans)
s126479013
p00031
u180584272
1379831233
Python
Python
py
Runtime Error
0
0
223
import sys for n in sys.stdin: ans = [] n = int(n) nb = format(n,'b') nb.reverse nb += " "*(10-len(nb)) for i in xrange(10): if nb[i] == 1: ans.append(str(2**(9-i)) print ' '.join(ans)
s726760131
p00031
u180584272
1379832112
Python
Python
py
Runtime Error
0
0
246
while True: try: ans = [] n = int(raw_input()) nb = format(n,'b') nb.reverse nb += " "*(10-len(nb)) for i in xrange(10): if nb[i] == 1: ans.append(str(2**(9-i)) print ' '.join(ans) except: break
s704563637
p00031
u180584272
1379836924
Python
Python
py
Runtime Error
0
0
247
import sys from math import sqrt nyu = sys.stdin.read() nyu = nyu.split("\n") cheese = map(float,nyu[0].split()) cheese.sort() supk = sqrt((cheeze[0]/2)**2 + (cheeze[1]/2)**2) nyu = nyu[2:] for k in nyu: if k < supk: print "OK" else: print "NA"
s605713105
p00032
u148101999
1459404164
Python
Python
py
Runtime Error
0
0
233
import sys import math num = [] cyou, hisi = 0, 0 for i in sys.stdin: num = map(int, i.split(",")) kaku = math.acos(num[0]/num[1])*(180/math.pi) if kaku == 90: cyou += 1 elif num[0] == num[1]: hisi += 1 print cyou print hisi