buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
w=raw_input() W=w.lower() Text=[] while True: text=raw_input() if text=='END_OF_TEXT': break Text.extend(text.split()) for i in range(len(Text)): Text[i]=Text[i].lower() print('%d'%Text.count(W))
w=input() W=w.lower() Text=[] while True: text=input() if text=='END_OF_TEXT': break Text.extend(text.split()) for i in range(len(Text)): Text[i]=Text[i].lower() print('%d'%Text.count(W))
[["-", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 0, 656, 0, 1, 0, 662, 12, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22]]
5
79
import sys W = input() print(sys.stdin.read().rstrip('END_OF_TEXT').lower().split(" ").count(W))
import sys W = input().lower() print(sys.stdin.read().rstrip('END_OF_TEXT').lower().split().count(W))
[["+", 0, 1, 0, 662, 12, 652, 63, 319, 0, 131], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25], ["-", 63, 319, 500, 652, 3, 4, 0, 557, 0, 654], ["-", 63, 319, 500, 652, 3, 4, 0, 557, 0, 6], ["-", 63, 319, 500, 652, 3, 4, 0, 557, 0, 65...
5
40
import sys W = input().lower() T = sys.stdin.read().lower() print(T.count(W))
import sys W = input().lower() T = sys.stdin.read().lower() print(T.split().count(W))
[["+", 0, 652, 63, 319, 500, 652, 63, 319, 319, 22], ["+", 0, 652, 63, 319, 500, 652, 3, 4, 0, 24], ["+", 0, 652, 63, 319, 500, 652, 3, 4, 0, 25], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 0, 131]]
5
33
#!usr/bin/env python3 import sys def main(): w = sys.stdin.readline().lower().strip('\n') s = 0 for line in sys.stdin: if line == 'END_OF_TEXT': break s += line.split().count(w) print(s) if __name__ == '__main__': main()
#!usr/bin/env python3 import sys def main(): w = sys.stdin.readline().lower().strip('\n') s = 0 for line in sys.stdin: if line == 'END_OF_TEXT': break s += line.lower().split().count(w) print(s) if __name__ == '__main__': main()
[["+", 500, 652, 63, 319, 500, 652, 63, 319, 319, 22], ["+", 500, 652, 63, 319, 500, 652, 3, 4, 0, 24], ["+", 500, 652, 63, 319, 500, 652, 3, 4, 0, 25], ["+", 12, 652, 63, 319, 500, 652, 63, 319, 0, 131]]
5
72
import re W = input() T = [] count = 0 while(1): line = input() if (line == "END_OF_TEXT"): break words = list(line.split()) for word in words: T.append(word) for word in T: matchOB = re.search(W, word.lower()) if matchOB: count += 1 print(count)
import re W = input() T = [] count = 0 while(1): line = input() if (line == "END_OF_TEXT"): break words = list(line.split()) for word in words: T.append(word) for word in T: matchOB = re.fullmatch(W, word.lower()) if matchOB: count += 1 print(count)
[["-", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22]]
5
84
count = 0 s = "" array =[] while True: count += 1 if count == 1: s = input() n = input() if n == "END_OF_TEXT": break array.append(n) count = 0 for i in range(len(array)): for i2 in array[i].split(): if s.upper() in i2.upper() or s.lower() in i2.lower(): count...
count = 0 s = "" array =[] while True: count += 1 if count == 1: s = input() n = input() if n == "END_OF_TEXT": break array.append(n) count = 0 for i in range(len(array)): for i2 in array[i].split(): if s.upper() == i2.upper() or s.lower() == i2.lower(): count...
[["-", 8, 196, 0, 57, 15, 679, 31, 666, 667, 267], ["+", 8, 196, 0, 57, 15, 679, 31, 666, 667, 60], ["-", 8, 196, 0, 57, 15, 679, 12, 666, 667, 267], ["+", 8, 196, 0, 57, 15, 679, 12, 666, 667, 60]]
5
104
W = input().lower() count = 0 while True: T = input() if T == "END_OF_TEXT": break count += T.lower().count(W) print(count)
W = input().lower() count = 0 while True: T = input() if T == "END_OF_TEXT": break count += T.lower().split(" ").count(W) print(count)
[["+", 12, 652, 63, 319, 500, 652, 63, 319, 319, 22], ["+", 12, 652, 63, 319, 500, 652, 3, 4, 0, 24], ["+", 63, 319, 500, 652, 3, 4, 0, 557, 0, 654], ["+", 63, 319, 500, 652, 3, 4, 0, 557, 0, 6], ["+", 63, 319, 500, 652, 3, 4, 0, 557, 0, 655], ["+", 12, 652, 63, 319, 500, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 677, 12, 652,...
5
44
#!/usr/bin/env python contents = [] counter = 0 word = input() while True: text = input() if text == "END_OF_TEXT": break textWords = text.split() contents.append(textWords) for x in contents: for y in textWords: if y.lower() == word: counter += 1 print(counter)
#!/usr/bin/env python contents = [] counter = 0 word = input() while True: text = input() if text == "END_OF_TEXT": break textWords = text.split() contents.append(textWords) for x in contents: for y in x: if y.lower() == word: counter += 1 print(counter)
[["-", 0, 656, 0, 7, 8, 196, 0, 7, 12, 22], ["+", 0, 656, 0, 7, 8, 196, 0, 7, 12, 22]]
5
68
#coding:utf-8 w = input().rstrip() bun ="" a ="" while a !="END_OF_TEXT": a = input().rstrip() if a =="END_OF_TEXT": break bun += a.lower() print(bun.count(w))
#coding:utf-8 w = input().rstrip() bun =[] a ="" while a !="END_OF_TEXT": a = input().rstrip() if a =="END_OF_TEXT": break bun += a.lower().split() print(bun.count(w))
[["-", 0, 656, 0, 1, 0, 662, 12, 557, 0, 654], ["-", 0, 656, 0, 1, 0, 662, 12, 557, 0, 655], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 70], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 73], ["+", 12, 652, 63, 319, 500, 652, 3, 4, 0, 24], ["+", 12, 652, 63, 319, 500, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 677, 12, 652, 63, 319, 0, ...
5
58
from collections import Counter W=input().lower() count=0 while True: line=input().split() if line==["END_OF_TEXT"]: break print(line) count+=Counter(map(lambda x:x.lower(),line))[W] print(count)
from collections import Counter W=input().lower() count=0 while True: line=input().split() if line==["END_OF_TEXT"]: break count+=Counter(map(lambda x:x.lower(),line))[W] print(count)
[["-", 0, 52, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
67
W = input() counter = 0 T = [] while True: string = input() if string == "END_OF_TEXT": break else: T.append(string) for i in range(len(T)): memo = T[i].split() for j in range(len(memo)): if memo[j] == W: counter += 1 print(counter)
W = input() counter = 0 T = [] while True: string = input() if string == "END_OF_TEXT": break else: T.append(string) for i in range(len(T)): memo = T[i].split() for j in range(len(memo)): if memo[j].lower() == W: counter += 1 print(counter)
[["+", 0, 57, 15, 666, 0, 652, 63, 319, 0, 131], ["+", 0, 57, 15, 666, 0, 652, 63, 319, 319, 22], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25]]
5
83
import re c=0 p=input().upper() ptn=re.compile(r'^'+p+r'$') while True: s=input() if s =='END_OF_TEXT': break a=s.upper().split() for i in a: print(i) if re.match(ptn, i): c+=1 print(c)
import re c=0 p=input().upper() ptn=re.compile(r'^'+p+r'$') while True: s=input() if s =='END_OF_TEXT': break a=s.upper().split() for i in a: if re.match(ptn, i): c+=1 print(c)
[["-", 0, 7, 8, 196, 0, 1, 0, 652, 63, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 24], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 22], ["-", 8, 196, 0, 1, 0, 652, 3, 4, 0, 25]]
5
83
word=input().lower() how_int=0 while True: letters=input() if letters=='END_OF_TEXT': break for i in letters.lower().split(): if i==word: how_in+=1 print(how_in)
word=input().lower() how_in=0 while True: letters=input() if letters=='END_OF_TEXT': break for i in letters.lower().split(): if i==word: how_in+=1 print(how_in)
[["-", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22], ["+", 36, 36, 0, 656, 0, 1, 0, 662, 31, 22]]
5
53
word = input().lower() text = [] c = 0 while True: read = input().split() if read[0] == 'END_OF_TEXT': break else: text.append(read) for i in text: for n in i: if word in n.lower(): c += 1 print(c)
word = input().lower() text = [] c = 0 while True: read = input().split() if read[0] == 'END_OF_TEXT': break else: text.append(read) for i in text: for n in i: if word == n.lower(): c += 1 print(c)
[["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 267], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 60]]
5
73
word = input().lower() texts = [] while TRUE: str = input() if str == 'END_OF_TEXT': break texts.extend([s.lower() for s in str.split()] ) ans = texts.count(word) print(ans)
word = input().lower() texts = [] while True: str = input() if str == 'END_OF_TEXT': break texts.extend([s.lower() for s in str.split()] ) ans = texts.count(word) print(ans)
[["-", 36, 36, 36, 36, 0, 656, 0, 52, 15, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 52, 15, 146]]
5
61
word = input() counter = 0 while True: line = input() if line == "end_of_text": break counter += line.lower().split(" ").count(word) print(counter)
word = input() counter = 0 while True: line = input() if line == "END_OF_TEXT": break counter += line.lower().split(" ").count(word) print(counter)
[["-", 8, 196, 0, 57, 15, 666, 0, 557, 0, 6], ["+", 8, 196, 0, 57, 15, 666, 0, 557, 0, 6]]
5
47
import sys w=input().upper() print(sys.stdin.read().upper().count(w))
import sys w=input().upper() print(sys.stdin.read().upper().split().count(w))
[["+", 0, 652, 63, 319, 500, 652, 63, 319, 319, 22], ["+", 0, 652, 63, 319, 500, 652, 3, 4, 0, 24], ["+", 0, 652, 63, 319, 500, 652, 3, 4, 0, 25], ["+", 0, 652, 3, 4, 0, 652, 63, 319, 0, 131]]
5
30
W=input() T=[] while 1: a=input() if'END_OF_TEXT '==a:break T+=[s.lower() for s in a.split()] print(T.count(W))
W=input() T=[] while 1: a=input() if'END_OF_TEXT'==a:break T+=[s.lower() for s in a.split()] print(T.count(W))
[["-", 8, 196, 0, 57, 15, 666, 0, 557, 0, 6], ["+", 8, 196, 0, 57, 15, 666, 0, 557, 0, 6]]
5
51
st=input() count=0 while(True): s=input() if s=="END_OF_TEXT": break t=s.split() for k in t: if k==s: count+=1 print(count)
st=input() count=0 while(True): s=input() if s=="END_OF_TEXT": break t=s.split() for k in t: if k.lower()==st: count+=1 print(count)
[["+", 0, 57, 15, 666, 0, 652, 63, 319, 0, 131], ["+", 0, 57, 15, 666, 0, 652, 63, 319, 319, 22], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22]]
5
50
W = input().lower() words = '' while True: word = input() if word == 'END_OF_TEXT': break words = words + word.lower() print(sum([1 for c in words.split() if c == W]))
W = input().lower() words = '' while True: word = input() if word == 'END_OF_TEXT': break words = words + word.lower() + " " print(sum([1 for c in words.split() if c == W]))
[["+", 8, 196, 0, 1, 0, 662, 12, 657, 17, 72], ["+", 0, 1, 0, 662, 12, 657, 12, 557, 0, 654], ["+", 0, 1, 0, 662, 12, 657, 12, 557, 0, 6], ["+", 0, 1, 0, 662, 12, 657, 12, 557, 0, 655]]
5
59
w = input() cnt = 0 while(True): t = input() if t == "END_OF_TEXT": break t = t.lower t = t.split() for i in t: if i == w: cnt += 1 print(cnt)
w = input() cnt = 0 while(True): t = input() if t == "END_OF_TEXT": break t = t.lower() t = t.split() for i in t: if i == w: cnt += 1 print(cnt)
[["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
55
w = input() cnt = 0 while(True): t = input() if t == "END_OF_TEXT": break t = t.lower t = list(t.split()) for i in t: if i == w: cnt += 1 print(cnt)
w = input() cnt = 0 while(True): t = input() if t == "END_OF_TEXT": break t = t.lower().split() for i in t: if i == w: cnt += 1 print(cnt)
[["-", 0, 52, 8, 196, 0, 1, 0, 662, 31, 22], ["-", 0, 52, 8, 196, 0, 1, 0, 662, 0, 32], ["-", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22], ["-", 12, 652, 3, 4, 0, 652, 63, 319, 500, 22], ["+", 12, 652, 63, 319, 500, 652, 3, 4, 0, 25], ["-", 12, 652, 3, 4, 0, 652, 3, 4, 0, 25]]
5
58
w = input() small = 'abcdefghijklmnopqrstuvwxyz' large = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' count = 0 while True: text = input() if text == 'END_OF_TEXT': break else: stext = '' for i in text: j = 0 while j < 26: if i == large[j]: ...
w = input() small = 'abcdefghijklmnopqrstuvwxyz' large = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' count = 0 while True: text = input() if text == 'END_OF_TEXT': break else: stext = '' for i in text: j = 0 while j < 26: if i == large[j]: ...
[["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 121], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 22], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 60], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 8, 196, 0, 7, 8, 196, 0, 57, 0, 102]]
5
109
string=[] W = input()#単語入力 while True: T = input()#入力 if T == '':#EOT入力のときループぬける break string.append(T)#list追加 count=0 for i in range(len(string)): string[i]=string[i].lower() string[i] = string[i].split(" ") for j in range(len(string[i])): if W == string[i][j]: count...
string=[] W = input()#単語入力 while True: T = input()#入力 if T == 'END_OF_TEXT':#EOT入力のときループぬける break string.append(T)#list追加 count=0 for i in range(len(string)): string[i]=string[i].lower() string[i] = string[i].split(" ") for j in range(len(string[i])): if W == string[i][j]: ...
[["+", 8, 196, 0, 57, 15, 666, 0, 557, 0, 6]]
5
109
w = input() count = 0 while True: text = input() if text == "END_OF_TEXT": break words = [_ for _ in text.split()] for word in words: if w == word: count += 1 print(count)
w = input() count = 0 while True: text = input() if text == "END_OF_TEXT": break words = [w.lower() for w in text.split()] for word in words: if w == word: count += 1 print(count)
[["-", 8, 196, 0, 1, 0, 662, 12, 658, 8, 22], ["+", 0, 662, 12, 658, 8, 652, 63, 319, 500, 22], ["+", 0, 662, 12, 658, 8, 652, 63, 319, 0, 131], ["+", 0, 662, 12, 658, 8, 652, 63, 319, 319, 22], ["+", 0, 662, 12, 658, 8, 652, 3, 4, 0, 24], ["+", 0, 662, 12, 658, 8, 652, 3, 4, 0, 25], ["-", 0, 1, 0, 662, 12, 658, 0, 659...
5
54
import fileinput W = input() cnt = 0 for T in fileinput.input(): if T.rstrip() =='END_OF_TEXT': break T = T.lower() cnt += T.count(W) print(cnt)
import fileinput W = input() cnt = 0 for T in fileinput.input(): if T.rstrip() =='END_OF_TEXT': break T = T.lower().split() cnt += T.count(W) # print(T, cnt) print(cnt)
[["+", 0, 1, 0, 662, 12, 652, 63, 319, 0, 131], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 319, 22], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 24], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 25]]
5
50
import fileinput cnt = 0 W = input() for line in fileinput.input(): if line.rstrip() == "END_OF_TEXT": break cnt += line.lower().count(W) print(cnt)
import fileinput cnt = 0 W = input() for line in fileinput.input(): if line.rstrip() == "END_OF_TEXT": break cnt += line.lower().split().count(W) print(cnt)
[["+", 12, 652, 63, 319, 500, 652, 63, 319, 319, 22], ["+", 12, 652, 63, 319, 500, 652, 3, 4, 0, 24], ["+", 12, 652, 63, 319, 500, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 677, 12, 652, 63, 319, 0, 131]]
5
47
cnt = 0 W = input() while True: li = input().split() if li[0] == "END_OF_TEXT": break for w in li: if w.lower == W: cnt += 1 print(cnt)
cnt = 0 W = input() while True: li = input().split() if li[0] == "END_OF_TEXT": break for w in li: if w.lower() == W: cnt += 1 print(cnt)
[["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["+", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25]]
5
50
# Finding a Word import re word = input() text = "" end = 0 while end == 0: input_line = input() if input_line == 'END_OF_TEXT': end += 1 else: text += input_line text += " " blocked = text.split() # この方法では記号を取り除けないという問題がある count = 0 for a in blocked: if a == word: cou...
# Finding a Word import re word = input() text = "" end = 0 while end == 0: input_line = input() if input_line == 'END_OF_TEXT': end += 1 else: text += input_line text += " " blocked = text.lower().split() # この方法では記号を取り除けないという問題がある count = 0 for a in blocked: if a == word: ...
[["+", 12, 652, 63, 319, 500, 652, 63, 319, 319, 22], ["+", 12, 652, 63, 319, 500, 652, 3, 4, 0, 24], ["+", 12, 652, 63, 319, 500, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 662, 12, 652, 63, 319, 0, 131]]
5
73
W=input().lower() T="" while True: t=input() if t=="END_OF_TEXT": break T+=t.lower() print(T.count(W))
W=input().lower() T=[] while True: t=input() if t=="END_OF_TEXT": break T+=t.lower().split() print(T.count(W))
[["-", 0, 656, 0, 1, 0, 662, 12, 557, 0, 654], ["-", 0, 656, 0, 1, 0, 662, 12, 557, 0, 655], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 70], ["+", 0, 656, 0, 1, 0, 662, 12, 634, 0, 73], ["+", 12, 652, 63, 319, 500, 652, 3, 4, 0, 24], ["+", 12, 652, 63, 319, 500, 652, 3, 4, 0, 25], ["+", 0, 1, 0, 677, 12, 652, 63, 319, 0, ...
5
45
w = input().lower() sum = 0 while True: t = input().split() if t[0] == "END_OF_TEXT": break else: for ti in t: if ti.lower() == w: sum += 0 print(sum)
w = input().lower() sum = 0 while True: t = input().split() if t[0] == "END_OF_TEXT": break else: for ti in t: if ti.lower() == w: sum += 1 print(sum)
[["-", 0, 57, 64, 196, 0, 1, 0, 677, 12, 612], ["+", 0, 57, 64, 196, 0, 1, 0, 677, 12, 612]]
5
58
#include <algorithm> #include <stdio.h> using namespace std; int main() { int n, a[20], tot = 1; scanf("%d", &n); for (int i = 1; i <= n; i++) { a[i] = i; tot *= i; } tot *= n; for (int i = 0; i < tot; i++) { printf("%d", a[1]); for (int j = 2; j <= n; j++) printf(" %d", a[j]); pri...
#include <algorithm> #include <stdio.h> using namespace std; int main() { int n, a[20], tot = 1; scanf("%d", &n); for (int i = 1; i <= n; i++) { a[i] = i; tot *= i; } for (int i = 0; i < tot; i++) { printf("%d", a[1]); for (int j = 2; j <= n; j++) printf(" %d", a[j]); printf("\n"); ...
[["-", 0, 14, 8, 9, 0, 1, 0, 11, 31, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 17, 108], ["-", 0, 14, 8, 9, 0, 1, 0, 11, 12, 22], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
141
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define FORq(i, m, n) for (int i = (m); i <= (n); ++i) #define SCD(n) scanf("%d", &n) #define SCD2(m, n) scanf("%d%d", &m, &n) #define SCD3(m, n, k) scanf("%d%d%d", &m, &n, &k) #define PB push_b...
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) for (int i = 0; i < (n); ++i) #define FORq(i, m, n) for (int i = (m); i <= (n); ++i) #define SCD(n) scanf("%d", &n) #define SCD2(m, n) scanf("%d%d", &m, &n) #define SCD3(m, n, k) scanf("%d%d%d", &m, &n, &k) #define PB push_b...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 0, 57, 15, 339, 51, 16, 31, 69, 28, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0, 70], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 15, 339, 51, 16, 31, 69, 341, 342, 0,...
1
296
#include <bits/stdc++.h> using namespace std; #define lp(i, n) for (int i = 0; i < n; i++) int main() { vector<int> a, b; int n, m; cin >> n; lp(i, n) { int hoge; cin >> hoge; a.push_back(hoge); } cin >> m; lp(i, m) { int hoge; cin >> hoge; b.push_back(hoge); } vector<int> ans...
#include <bits/stdc++.h> using namespace std; #define lp(i, n) for (int i = 0; i < n; i++) int main() { vector<int> a, b; int n, m; cin >> n; lp(i, n) { int hoge; cin >> hoge; a.push_back(hoge); } cin >> m; lp(i, m) { int hoge; cin >> hoge; b.push_back(hoge); } vector<int> ans...
[["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22]]
1
162
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) tuple<int, int, char, int, string> t[111111]; int main() { int n; cin >> n; rep(i, n) { int a, b, d; char c; string e; cin >> a >> b >> c >> d >> e; t[i] = make_tuple(a, b, c, d, e); } sort(t, t + n...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define int long long tuple<int, int, char, int, string> t[111111]; signed main() { int n; cin >> n; rep(i, n) { int a, b, d; char c; string e; cin >> a >> b >> c >> d >> e; t[i] = make_tuple(a, b, c, d...
[["+", 36, 36, 36, 36, 0, 30, 0, 58, 0, 148], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 141, 22], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 36, 36, 36, 36, 0, 30, 0, 14, 39, 40], ["+", 36, 36, 0, 30, 0, 14, 39, 86, 0, 156]]
1
215
#include <bits/stdc++.h> using namespace std; int a[10]; void print(int n) { for (int i = 0; i < n; i++) printf("%d%c", a[i], i == n - 1 ? '\n' : ' '); } int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } prev_permutation(a, a + n); print(n); next_perm...
#include <bits/stdc++.h> using namespace std; int a[10]; void print(int n) { for (int i = 0; i < n; i++) printf("%d%c", a[i], i == n - 1 ? '\n' : ' '); } int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } if (prev_permutation(a, a + n)) print(n); nex...
[["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 0, 57, 15, 339, 51, 2, 3, 4, 0, 25], ["-", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
155
#include <algorithm> #include <stdio.h> using namespace std; int main() { bool big = true, less = true; int n, a[20], tot = 1; scanf("%d%d", &n, &a[0]); for (int i = 1; i < n; i++) { scanf("%d", &a[i]); big &= a[i] > a[i - 1]; less &= a[i] < a[i - 1]; tot *= i; } tot *= n; for (int i = 1; ...
#include <algorithm> #include <stdio.h> using namespace std; int main() { bool big = true, less = true; int n, a[20], tot = 1; scanf("%d%d", &n, &a[0]); for (int i = 1; i < n; i++) { scanf("%d", &a[i]); big &= a[i] < a[i - 1]; less &= a[i] > a[i - 1]; tot *= i; } tot *= n; for (int i = 1; ...
[["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 47], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 18], ["-", 8, 9, 0, 1, 0, 11, 12, 16, 17, 18], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 47]]
1
306
#include <stdio.h> int search(int s[], int key, int head, int tail) { if (head > tail) return -1; int mid = (head + tail) / 2; if (s[mid] == key) return mid; else if (s[mid] > key) tail = mid - 1; else if (s[mid] < key) head = mid + 1; return search(s, key, head, tail); } int getLB(int s...
#include <stdio.h> int search(int s[], int key, int head, int tail) { if (head > tail) return -1; int mid = (head + tail) / 2; if (s[mid] == key) return mid; else if (s[mid] > key) tail = mid - 1; else if (s[mid] < key) head = mid + 1; return search(s, key, head, tail); } int getLB(int s...
[["+", 0, 16, 31, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 16, 31, 2, 3, 4, 0, 16, 12, 13]]
0
564
#include <bits/stdc++.h> using namespace std; template <typename T> class avl_tree { struct node { T val; int dep; node *ch[2]; node() : node(0) {} node(T v, node *l = nullptr, node *r = nullptr) : val(v), dep(1), ch{l, r} {} void *operator new(size_t) { static const int pmax = ...
#include <bits/stdc++.h> using namespace std; template <typename T> class avl_tree { struct node { T val; int dep; node *ch[2]; node() : node(0) {} node(T v, node *l = nullptr, node *r = nullptr) : val(v), dep(1), ch{l, r} {} void *operator new(size_t) { static const int pmax = ...
[["+", 0, 14, 8, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 14, 8, 9, 0, 1, 0, 27, 28, 22], ["+", 8, 123, 0, 14, 8, 9, 0, 1, 0, 35]]
1
879
#include <iostream> #include <set> using namespace std; int main() { // set<int>a; int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int m; set<int> b; for (int i = 0; i < m; i++) { int x; cin >> x; b.insert(x); } for (int i = 0; i < n; i++) { if (b.find(a...
#include <iostream> #include <set> using namespace std; int main() { // set<int>a; int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int m; cin >> m; set<int> b; for (int i = 0; i < m; i++) { int x; cin >> x; b.insert(x); } for (int i = 0; i < n; i++) { ...
[["+", 0, 14, 8, 9, 0, 1, 0, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 152], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 30, 0, 14, 8, 9, 0, 1, 0, 35]]
1
136
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.NoSuchElementException; public class Main { ArrayList<Integer> prime; int N, n; public void solve() { N = nextInt(); boolean find = false; n = N; out.print(N + ":")...
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.NoSuchElementException; public class Main { ArrayList<Integer> prime; int N, n; public void solve() { N = nextInt(); boolean find = false; n = N; out.print(N + ":")...
[["-", 8, 196, 0, 7, 15, 16, 31, 16, 17, 48], ["-", 8, 196, 0, 7, 15, 16, 31, 16, 12, 22], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 17, 85], ["+", 8, 196, 0, 7, 15, 16, 12, 16, 12, 499]]
3
489
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLi...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws NumberFormatException, IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLi...
[["-", 0, 195, 8, 196, 0, 7, 15, 16, 17, 18], ["+", 0, 195, 8, 196, 0, 7, 15, 16, 17, 19]]
3
162
#include <math.h> // sqrt() #include <stdbool.h> #include <stdio.h> // printf(), scanf() #define MAX_V 31623 #define min(a, b) ((a) < (b) ? (a) : (b)) int main(int argc, char **argv) { int x; bool f[MAX_V + 1]; int i, j; scanf("%d", &x); printf("%d:", x); for (i = 0; i < min(x, MAX_V); ++i) f[i] = t...
#include <math.h> // sqrt() #include <stdbool.h> #include <stdio.h> // printf(), scanf() #define MAX_V 31623 #define min(a, b) ((a) < (b) ? (a) : (b)) int main(int argc, char **argv) { int x; bool f[MAX_V + 1]; int i, j; scanf("%d", &x); printf("%d:", x); for (i = 0; i < min(x, MAX_V); ++i) f[i] = t...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13]]
0
205
#include <stdio.h> int devide(int N, int k) { while (N % k == 0) { N = N / k; printf(" %d", k); } return N; } int main() { int N, k = 3; scanf("%d", &N); printf(" %d:", N); N = devide(N, 2); while (N > 1) { if (N < k * k) { printf("%d", N); N = 1; } else { N = devide(...
#include <stdio.h> int devide(int N, int k) { while (N % k == 0) { N = N / k; printf(" %d", k); } return N; } int main() { int N, k = 3; scanf("%d", &N); printf("%d:", N); N = devide(N, 2); while (N > 1) { if (N < k * k) { printf(" %d", N); N = 1; } else { N = devide(...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
139
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <math.h> #include <stdio.h> void P(int *n); void PF(int *n, int p[], int j); int main() { int n; scanf("%d", &n); printf("%d:", n); P(&n); printf(" %d\n", n); return 0; } void P(int *n) { int p[7000]; int i, j = 4, k; p[0] = 2; p[1]...
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <math.h> #include <stdio.h> void P(int *n); void PF(int *n, int p[], int j); int main() { int n; scanf("%d", &n); printf("%d:", n); P(&n); printf(" %d\n", n); return 0; } void P(int *n) { int p[7000]; int i, j = 4, k; p[0] = 2; p[1]...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18]]
0
323
#include <math.h> #include <stdio.h> int sosu[10000] = {0}; // int factors[31] = {0}; int getSosuu(int N) { int i, j; int count_prime = 1; int flag; sosu[0] = 2; for (i = 2; i <= N; ++i) { flag = 0; for (j = 0; sosu[j] != 0; ++j) { if (i % sosu[j] == 0) { flag = 1; break; ...
#include <math.h> #include <stdio.h> int sosu[10000] = {0}; // int factors[31] = {0}; int getSosuu(int N) { int i, j; int count_prime = 1; int flag; sosu[0] = 2; for (i = 2; i <= N; ++i) { flag = 0; for (j = 0; sosu[j] != 0; ++j) { if (i % sosu[j] == 0) { flag = 1; break; ...
[["-", 0, 57, 15, 23, 0, 16, 31, 69, 71, 22], ["+", 0, 57, 15, 23, 0, 16, 31, 69, 71, 13]]
0
363
#include <stdio.h> int main() { int i, n; scanf("%d", &n); printf("%d:", n); while (1) { for (i = 2; i <= n; i++) { if (n % i == 0) { n /= i; printf(" %d", i); break; } if (n > i * i) i = n - 1; } if (n == 1) break; } printf("\n"); return...
#include <stdio.h> int main() { int i, n; scanf("%d", &n); printf("%d:", n); while (1) { for (i = 2; i <= n; i++) { if (n % i == 0) { n /= i; printf(" %d", i); break; } if (n < i * i) i = n - 1; } if (n == 1) break; } printf("\n"); return...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 18]]
0
110
p[169] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 2...
p[169] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 2...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 31, 22], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 79]]
0
446
#include <stdio.h> main() { int i, n; scanf("%d", &n); printf("%d:", n); for (i = 2; i * i < n; i++) { while (n % i == 0) { n /= i; printf(" %d", i); } } if (n > 1) { printf(" %d\n", n); } else { putchar('\n'); } }
#include <stdio.h> main() { int i, n; scanf("%d", &n); printf("%d:", n); for (i = 2; i * i <= n; i++) { while (n % i == 0) { n /= i; printf(" %d", i); } } if (n > 1) { printf(" %d\n", n); } else { putchar('\n'); } }
[["-", 0, 30, 0, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 30, 0, 9, 0, 7, 15, 16, 17, 19]]
0
100
#include <math.h> #include <stdio.h> int main() { int n, i, N; double x; scanf("%d", &n); N = n; x = sqrt(n); printf("%d:", n); i = 2; while (i <= x) { while (n % i == 0) { printf(" %d", i); n = n / i; } i++; } if (n == N) printf(" %d", n); printf("\n"); retu...
#include <math.h> #include <stdio.h> int main() { int n, i, N; double x; scanf("%d", &n); N = n; x = sqrt(n); printf("%d:", n); i = 2; while (i <= x) { while (n % i == 0) { printf(" %d", i); n = n / i; } i++; } if (n != 1) printf(" %d", n); printf("\n"); retu...
[["-", 8, 9, 0, 57, 15, 23, 0, 16, 17, 60], ["-", 8, 9, 0, 57, 15, 23, 0, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 17, 79], ["+", 8, 9, 0, 57, 15, 23, 0, 16, 12, 13]]
0
115
#include <stdio.h> int main(void) { int n, a; scanf("%d", &n); printf("%d:", n); a = 2; while (n >= a * a) { if (n % a == 0) { printf("%d ", a); n /= a; } else a++; } printf("%d\n", n); return 0; }
#include <stdio.h> int main(void) { int n, a; scanf("%d", &n); printf("%d: ", n); a = 2; while (n >= a * a) { if (n % a == 0) { printf("%d ", a); n /= a; } else a++; } printf("%d\n", n); return 0; }
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
87
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define MOD 1000000007LL #define REP(i, n) for (int i = 0; i < (n); ++i) typedef long long ll; signed main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; int tmp = n; cout << n << ':'; for (int i = 2; i * i <= tmp; i++) { ...
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define MOD 1000000007LL #define REP(i, n) for (int i = 0; i < (n); ++i) typedef long long ll; signed main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; int tmp = n; cout << n << ':'; for (int i = 2; i * i <= tmp; i++) { ...
[["-", 8, 9, 0, 57, 64, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 57, 64, 1, 0, 16, 12, 22]]
1
148
#include <bits/stdc++.h> typedef long long LL; using namespace std; int main() { int n; cin >> n; cout << n << ":"; int m = sqrt(n); while (n % 2 == 0) { n /= 2; cout << " " << 2; } int i = 3; while (i <= m) { if (n % i == 0) { cout << " " << i; n /= i; } else { i += ...
#include <bits/stdc++.h> typedef long long LL; using namespace std; int main() { int n; cin >> n; cout << n << ":"; int m = sqrt(n); while (n % 2 == 0) { n /= 2; cout << " " << 2; } int i = 3; while (i <= m) { if (n % i == 0) { cout << " " << i; n /= i; } else { i += ...
[["-", 64, 9, 0, 1, 0, 16, 31, 16, 12, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 0, 57, 64, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 16, 12, 22]]
1
122
#include <cmath> #include <iostream> #include <vector> #define int long long using namespace std; signed main() { int n, m; vector<int> v; cin >> n; m = n; for (int i = 2; i <= sqrt(n); i++) { while (m % i == 0) { v.push_back(i); m /= i; } } if (m >= v.back()) v.push_back(m); cou...
#include <cmath> #include <iostream> #include <vector> #define int long long using namespace std; signed main() { int n, m; vector<int> v; cin >> n; m = n; for (int i = 2; i <= sqrt(n); i++) { while (m % i == 0) { v.push_back(i); m /= i; } } if (m != 1) v.push_back(m); cout << n ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["-", 15, 339, 51, 16, 12, 2, 63, 118, 28, 22], ["-", 15, 339, 51, 16, 12, 2, 63, 118, 17, 131], ["-", 15, 339, 51, 16, 12, 2, 63, 118, 119, 120], ["-", 15, 339, 51, 16, 12, 2, 3, 4, 0, 24], ["-", 15, 339, 51, 16, 12, 2, 3, 4, 0, 25], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17,...
1
122
#include <algorithm> #include <iostream> #include <math.h> #include <stdio.h> #include <vector> using namespace std; int main() { int n; cin >> n; cout << n << ":"; int ren = n; for (int i = 1; i <= sqrt(n); i++) { while (ren != 1) { if (ren % (i + 1) == 0) { cout << " " << i + 1; ...
#include <algorithm> #include <iostream> #include <math.h> #include <stdio.h> #include <vector> using namespace std; int main() { int n; cin >> n; cout << n << ":"; int ren = n; for (int i = 1; i <= sqrt(n); i++) { while (ren != 1) { if (ren % (i + 1) == 0) { cout << " " << i + 1; ...
[["-", 0, 57, 64, 9, 0, 1, 0, 16, 12, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 16, 12, 22]]
1
127
#include <iostream> #include <vector> using namespace std; vector<int> factorize(const int n) { vector<int> ps; int tmp = n; while (tmp % 2 == 0) { ps.push_back(2); tmp /= 2; } for (int i = 3; i * i <= n; i += 2) { while (tmp % i == 0) { ps.push_back(i); tmp /= i; } } if (ps...
#include <iostream> #include <vector> using namespace std; vector<int> factorize(const int n) { vector<int> ps; int tmp = n; while (tmp % 2 == 0) { ps.push_back(2); tmp /= 2; } for (int i = 3; 2 * i <= n; i += 2) { while (tmp % i == 0) { ps.push_back(i); tmp /= i; } } if (ps...
[["-", 8, 9, 0, 7, 15, 16, 31, 16, 31, 22], ["+", 8, 9, 0, 7, 15, 16, 31, 16, 31, 13]]
1
189
#include <cmath> #include <iostream> using namespace std; int main() { int n; cin >> n; cout << n << ":"; for (int i = 2; i < sqrt(n); i++) { if (n % i == 0) { while (n % i == 0) { n /= i; cout << " " << i; } } } if (n > 1) { cout << " " << n; } cout << endl; r...
#include <cmath> #include <iostream> using namespace std; int main() { int n; cin >> n; cout << n << ":"; for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) { while (n % i == 0) { n /= i; cout << " " << i; } } } if (n > 1) { cout << " " << n; } cout << endl; ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
103
#include <cmath> #include <iostream> #include <vector> using namespace std; u_int make_prime_list(u_int a[], u_int size) { a[0] = 2; a[1] = 3; u_int i = 2; for (u_int q = 5; q <= size; q += 2) { u_int threshold = (u_int)sqrt(q); bool is_prime = true; for (u_int j = 1; a[j] <= threshold; j++) ...
#include <cmath> #include <iostream> #include <vector> using namespace std; u_int make_prime_list(u_int a[], u_int size) { a[0] = 2; a[1] = 3; u_int i = 2; for (u_int q = 5; q <= size; q += 2) { u_int threshold = (u_int)sqrt(q); bool is_prime = true; for (u_int j = 1; a[j] <= threshold; j++) ...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 106], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 31, 22], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 17, 79], ["+", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13]]
1
304
#include <iostream> using namespace std; int main(void) { int num; cin >> num; cout << num << ":"; for (int i = 2; i * i < num; ++i) { while (num % i == 0) { num /= i; cout << " " << i; } } if (num != 1) { cout << " " << num; } cout << endl; return 0; }
#include <iostream> using namespace std; int main(void) { int num; cin >> num; cout << num << ":"; for (int i = 2; i * i <= num; ++i) { while (num % i == 0) { num /= i; cout << " " << i; } } if (num != 1) { cout << " " << num; } cout << endl; return 0; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
91
#include <algorithm> #include <cmath> #include <iostream> #include <vector> //#define rep(i,0,n) for(int i=0; i<n; i++) using namespace std; bool fact(int n) { int k = sqrt(n); if (n % 2 == 0) return false; else { for (int i = 3; i <= k; i = i + 2) { if (n % i == 0) return false; } ...
#include <algorithm> #include <cmath> #include <iostream> #include <vector> //#define rep(i,0,n) for(int i=0; i<n; i++) using namespace std; bool fact(int n) { int k = sqrt(n); if (n % 2 == 0) return false; else { for (int i = 3; i <= k; i = i + 2) { if (n % i == 0) return false; } ...
[["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["+", 8, 9, 0, 57, 64, 9, 0, 37, 0, 38], ["+", 0, 14, 8, 9, 0, 57, 64, 9, 0, 46]]
1
261
#include <iostream> #include <math.h> int main(void) { long int in; long int i = 2; std::cin >> in; std::cout << in << ":"; while (in != 1) { if (i < sqrt(in)) { std::cout << " " << in; break; } else if (in % i != 0) { i += 1; } else { in = in / i; std::cout << " " <...
#include <iostream> #include <math.h> int main(void) { long int in; long int i = 2; std::cin >> in; std::cout << in << ":"; while (in != 1) { if (i > sqrt(in)) { std::cout << " " << in; break; } else if (in % i != 0) { i += 1; } else { in = in / i; std::cout << " " <...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
114
#include <iostream> using namespace std; int main() { int n, i = 2; cin >> n; cout << n << ':'; while (i * i <= n) { if (n % i != 0) { i++; continue; } cout << ' ' << i; n /= i; } cout << n << endl; return 0; }
#include <iostream> using namespace std; int main() { int n, i = 2; cin >> n; cout << n << ':'; while (i * i <= n) { if (n % i != 0) { i++; continue; } cout << ' ' << i; n /= i; } cout << ' ' << n << endl; return 0; }
[["+", 0, 16, 31, 16, 31, 16, 12, 103, 0, 104], ["+", 0, 16, 31, 16, 31, 16, 12, 103, 0, 125], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
77
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); i++) using namespace std; int n; int main() { cin >> n; int def_half_n = n / 2 + 2; int def_n = n; cout << n << ":"; while (n % 2 == 0) { cout << " " << 2; n /= 2; } if (n == 1) { cout << endl; return 0; } for (int i ...
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); i++) using namespace std; int n; int main() { cin >> n; int def_half_n = n / 2 + 2; int def_n = n; cout << n << ":"; while (n % 2 == 0) { cout << " " << 2; n /= 2; } if (n == 1) { cout << endl; return 0; } for (int i ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
156
#include <bits/stdc++.h> bool isprime[102400]; int main() { for (int i = 0; i < 102400; ++i) isprime[i] = true; isprime[0] = isprime[1] = false; for (int i = 2; i < 320; ++i) { if (not isprime[i]) continue; for (int j = i * i; j < 102400; ++j) { isprime[j] = false; } } int n; ...
#include <bits/stdc++.h> bool isprime[102400]; int main() { for (int i = 0; i < 102400; ++i) isprime[i] = true; isprime[0] = isprime[1] = false; for (int i = 2; i < 320; ++i) { if (not isprime[i]) continue; for (int j = i * i; j < 102400; j += i) { isprime[j] = false; } } int n;...
[["-", 0, 7, 8, 9, 0, 7, 26, 27, 17, 29], ["+", 0, 7, 8, 9, 0, 7, 26, 11, 17, 107], ["+", 0, 7, 8, 9, 0, 7, 26, 11, 12, 22]]
1
198
#include <iostream> #include <sstream> #include <string> int main() { unsigned int n; std::stringstream ss; std::cin >> n; ss << n << ": "; for (unsigned int i = 2; i * i < n; i++) { if (!(n % i)) { n /= i; ss << i << " "; i = 1; } } if (n != 1) ss << n << " "; std::strin...
#include <iostream> #include <sstream> #include <string> int main() { unsigned int n; std::stringstream ss; std::cin >> n; ss << n << ": "; for (unsigned int i = 2; i * i <= n; i++) { if (!(n % i)) { n /= i; ss << i << " "; i = 1; } } if (n != 1) ss << n << " "; std::stri...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
132
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> // by NeighThorn using namespace std; int n, m; signed main(void) { scanf("%d", &n); m = sqrt(n); printf("%d:", n); for (int i = 2; i <= m; i++) if (n % i == 0) { while (n % i == 0) n /= i, printf(" ...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstring> #include <iostream> // by NeighThorn using namespace std; int n, m; signed main(void) { scanf("%d", &n); m = sqrt(n); printf("%d:", n); for (int i = 2; i <= m; i++) if (n % i == 0) { while (n % i == 0) n /= i, printf(" ...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
124
#include <iostream> int main() { int n; std::cin >> n; std::cout << n << ":"; int i = 2; int odd = 0; while (i <= n) { if (n % i == 0) { std::cout << " " << i; n /= i; i = 2; odd = 0; } else { if (i == 2 && odd == 0) { odd = 1; i++; } if (i...
#include <iostream> int main() { int n; std::cin >> n; std::cout << n << ":"; int i = 2; int odd = 0; while (i <= n) { if (n % i == 0) { std::cout << " " << i; n /= i; i = 2; odd = 0; } else { if (i == 2 && odd == 0) { odd = 1; i = 3; } else if (...
[["-", 0, 57, 64, 9, 0, 1, 0, 27, 17, 29], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 17, 32], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 75, 76, 0, 9, 0, 57, 75, 76, 0, 95]]
1
141
#include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> using namespace std; int n; list<int> ans; bool is_prime(int n) { int m = sqrt(n); for (int i = 2; i <= m; i++) { if (n % 2 == 0) return false; } return true; } void prime_factorize(int n) { ...
#include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <list> using namespace std; int n; list<int> ans; bool is_prime(int n) { int m = sqrt(n); for (int i = 2; i <= m; i++) { if (n % i == 0) return false; } return true; } void prime_factorize(int n) { ...
[["-", 0, 57, 15, 339, 51, 16, 31, 16, 12, 13], ["+", 0, 57, 15, 339, 51, 16, 31, 16, 12, 22]]
1
262
#include <cstdio> int n; int isPrime(int x) { int i; if (x < 2) return 0; else if (x == 2) return 1; if (x % 2 == 0) return 0; for (i = 3; i * i <= x; i += 2) { if (x % i == 0) return 0; } return 1; } int main(void) { scanf("%d", &n); printf("%d:", n); for (int i = 2; i * i ...
#include <cstdio> int n; int isPrime(int x) { int i; if (x < 2) return 0; else if (x == 2) return 1; if (x % 2 == 0) return 0; for (i = 3; i * i <= x; i += 2) { if (x % i == 0) return 0; } return 1; } int main(void) { scanf("%d", &n); printf("%d:", n); for (int i = 2; i * i ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
183
#include <algorithm> #include <cctype> #include <cmath> #include <iostream> #include <queue> #include <string> #include <vector> #define rep(i, a, b) for (int i = (a); i < b; i++) #define INF 1000000000 #define MAX_N 100000000 using namespace std; bool debug = false; int main() { int n; cin >> n; cout << n << ":...
#include <algorithm> #include <cctype> #include <cmath> #include <iostream> #include <queue> #include <string> #include <vector> #define rep(i, a, b) for (int i = (a); i < b; i++) #define INF 1000000000 #define MAX_N 100000000 using namespace std; bool debug = false; int main() { int n; cin >> n; cout << n << ":...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79]]
1
158
#include <iostream> #include <vector> using namespace std; typedef long long ll; vector<int> primeFactors(ll n) { ll k = n; vector<int> result; for (int i = 2; i * i <= n; i++) { while (k % i == 0) { result.push_back(i); k = k / i; } } if (k > 0) { result.push_back(k); } return r...
#include <iostream> #include <vector> using namespace std; typedef long long ll; vector<int> primeFactors(ll n) { ll k = n; vector<int> result; for (int i = 2; i * i <= n; i++) { while (k % i == 0) { result.push_back(i); k = k / i; } } if (k > 1) { result.push_back(k); } return r...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
150
#include <algorithm> #include <functional> #include <iostream> #include <list> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string> #include <vector> using namespace std; #define FOR(k, m, n) for (int(k) = (m); (k) < (n); (k)++) #define REP(i, n) FOR((i), 0, (n)) #de...
#include <algorithm> #include <functional> #include <iostream> #include <list> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdlib.h> #include <string> #include <vector> using namespace std; #define FOR(k, m, n) for (int(k) = (m); (k) < (n); (k)++) #define REP(i, n) FOR((i), 0, (n)) #de...
[["-", 0, 57, 64, 1, 0, 2, 3, 4, 0, 22], ["+", 0, 57, 64, 1, 0, 2, 3, 4, 0, 22]]
1
281
#include <math.h> #include <stdio.h> int main(void) { int n, i; scanf("%d", &n); printf("%d:", n); for (i = 2; i <= sqrt(n);) { if (!(n % i)) { n /= i; printf(" %d", i); } else ++i; } printf("\n"); return 0; }
#include <math.h> #include <stdio.h> int main(void) { int n, i; scanf("%d", &n); printf("%d:", n); for (i = 2; i <= sqrt(n);) { if (!(n % i)) { n /= i; printf(" %d", i); } else ++i; } printf(" %d\n", n); return 0; }
[["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 21], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
89
#include <iostream> using namespace std; int main() { int n; cin >> n; cout << n << ":"; for (int i = 2; i * i < n; i++) { while (n % i == 0) { n /= i; cout << " " << i; } } if (n - 1) cout << " " << n; cout << endl; return 0; }
#include <iostream> using namespace std; int main() { int n; cin >> n; cout << n << ":"; for (int i = 2; i * i <= n; i++) { while (n % i == 0) { n /= i; cout << " " << i; } } if (n - 1) cout << " " << n; cout << endl; return 0; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
88
#include <iostream> using namespace std; int main() { int n; cin >> n; cout << n << ":"; for (int i = 2; i * i < n; i++) { while (n % i == 0) { cout << " " << i; n /= i; } } if (n != 1) cout << " " << n; cout << endl; return 0; }
#include <iostream> using namespace std; int main() { int n; cin >> n; cout << n << ":"; for (int i = 2; i * i <= n; i++) { while (n % i == 0) { cout << " " << i; n /= i; } } if (n != 1) cout << " " << n; cout << endl; return 0; }
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 17, 18], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 17, 19]]
1
88
#include <bits/stdc++.h> using namespace std; ///// int main() { bool fact[200000]; fill(fact, fact + 200000, true); fact[0] = fact[1] = false; for (int i = 2; i < 100000; i++) { if (!fact[i]) continue; for (int j = 2; i * j < 200000; j++) { fact[i * j] = false; } } set<int> prime...
#include <bits/stdc++.h> using namespace std; ///// int main() { bool fact[200000]; fill(fact, fact + 200000, true); fact[0] = fact[1] = false; for (int i = 2; i < 100000; i++) { if (!fact[i]) continue; for (int j = 2; i * j < 200000; j++) { fact[i * j] = false; } } set<int> prime...
[["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["-", 0, 57, 64, 1, 0, 16, 31, 16, 12, 22], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 62], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["-", 8, 9, 0, 57, 64, 1, 0, 16, 12, 22], ["+", 8, 9, 0, 57, 64, 1, 0, 16, 12, 22]]
1
200
n=gets.chomp.to_i max_root=Math.sqrt(n).to_i prime=Array.new m=n i=2 while i <= max_root if n%i==0 prime << i n=n/i elsif i==2 i+=1 else i+=2 end end puts n if m==n || n!=1 prime << n end print "#{m}: #{prime.join(" ")}\n"
n=gets.chomp.to_i max_root=Math.sqrt(n).to_i prime=Array.new m=n i=2 while i <= max_root if n%i==0 prime << i n=n/i elsif i==2 i+=1 else i+=2 end end if m==n || n!=1 prime << n end print "#{m}: #{prime.join(" ")}\n"
[["-", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["-", 36, 36, 0, 493, 0, 652, 3, 4, 0, 22]]
4
91
def factorial(n) i = 2 while i <= Math.sqrt(n) if n % i == 0 return [i, n / i] end i = i + 1 end end n = gets.to_i print "#{n}: " while n > 1 f, n = factorial(n) if n == 1 print "#{f}\n" break else print "#{f} " end end
def factorial(n) i = 2 while i <= Math.sqrt(n) if n % i == 0 return [i, n / i] end i = i + 1 end return [n, 1] end n = gets.to_i print "#{n}: " while n > 1 f, n = factorial(n) if n == 1 print "#{f}\n" break else print "#{f} " end end
[["+", 0, 493, 0, 735, 8, 736, 0, 38, 0, 38], ["+", 8, 736, 0, 38, 0, 4, 0, 516, 0, 70], ["+", 8, 736, 0, 38, 0, 4, 0, 516, 0, 22], ["+", 8, 736, 0, 38, 0, 4, 0, 516, 0, 21], ["+", 8, 736, 0, 38, 0, 4, 0, 516, 0, 612], ["+", 8, 736, 0, 38, 0, 4, 0, 516, 0, 73]]
4
85
require 'Prime' n = gets.to_i puts "#{n}:" + Prime.prime_division(n).map{|d, e| " #{d}" * e}.join
require 'prime' n = gets.to_i puts "#{n}:" + Prime.prime_division(n).map{|d, e| " #{d}" * e}.join
[["-", 0, 493, 0, 652, 3, 4, 0, 557, 0, 6], ["+", 0, 493, 0, 652, 3, 4, 0, 557, 0, 6]]
4
42
a=int(input()) n=a i=2 fc=[] while i*i<=a: while a%i==0: a//=i fc.append(i) i+=1 if a>1: fc.append(a) print(str(n)+":"+" ".join(str(b) for b in fc))
a=int(input()) n=a i=2 fc=[] while i*i<=a: while a%i==0: a//=i fc.append(i) i+=1 if a>1: fc.append(a) print(str(n)+": "+" ".join(str(b) for b in fc))
[["-", 3, 4, 0, 657, 31, 657, 12, 557, 0, 6], ["+", 3, 4, 0, 657, 31, 657, 12, 557, 0, 6]]
5
82
import math def sieve(n): p = [1] * (n + 1) p[0] = p[1] = 0 for i in range(math.ceil((n + 1) ** 0.5)): if p[i]: for j in range(2 * i, len(p), i): p[j] = 0 return p def prime_factor(n): p = sieve(int(n ** 0.5)) factor = [] for pi in compress(count(0),...
import math def sieve(n): p = [1] * (n + 1) p[0] = p[1] = 0 for i in range(math.ceil((n + 1) ** 0.5)): if p[i]: for j in range(2 * i, len(p), i): p[j] = 0 return p def prime_factor(n): p = sieve(int(n ** 0.5)) factor = [] for pi in compress(count(0),...
[["-", 8, 196, 0, 57, 15, 666, 0, 652, 63, 22], ["-", 0, 57, 15, 666, 0, 652, 3, 4, 0, 24], ["-", 0, 57, 15, 666, 0, 652, 3, 4, 0, 22], ["-", 0, 57, 15, 666, 0, 652, 3, 4, 0, 25], ["-", 0, 14, 8, 196, 0, 57, 15, 666, 667, 60], ["-", 0, 14, 8, 196, 0, 57, 15, 666, 0, 612], ["+", 0, 14, 8, 196, 0, 57, 15, 666, 0, 22], ["...
5
197
m, n = gets.split.map &:to_i $t = 1000000007 def pow(m, n) m = m % $t if n == 0 1 elsif n.even? pow(m * m, n / 2) else pow(m * m, n / 2) * m end end puts pow(m, n)
m, n = gets.split.map &:to_i $t = 1000000007 def pow(m, n) m = m % $t if n == 0 1 elsif n.even? pow(m * m, n / 2) else pow(m * m, n / 2) * m end end puts pow(m, n) % $t
[["+", 0, 493, 0, 652, 3, 4, 0, 738, 17, 109], ["+", 0, 493, 0, 652, 3, 4, 0, 738, 12, 744]]
4
67
m, n = map(int, input().split()) print(pow(m, n))
m, n = map(int, input().split()) print(pow(m, n, 1000000007))
[["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 21], ["+", 0, 652, 3, 4, 0, 652, 3, 4, 0, 612]]
5
25
from math import * def main(): m, n = [int(_) for _ in input().split()] print(pow(m, n, 1000000007)) main()
def main(): m, n = [int(_) for _ in input().split()] print(pow(m, n, 1000000007)) main()
[["-", 36, 36, 36, 36, 0, 656, 0, 686, 0, 314], ["-", 36, 36, 0, 656, 0, 686, 687, 673, 0, 22], ["-", 36, 36, 36, 36, 0, 656, 0, 686, 0, 487], ["-", 36, 36, 0, 656, 0, 686, 0, 690, 0, 48]]
5
43
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define int long long #define MOD 1000000007 int gcd(int a, int b) { if (a % b == 0) return b; return gcd(a, b % a); } int lcm(int a, int b) { return a / gcd(a, b) * b; } signed main() { int n; int a[11]; cin >> n;...
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < n; i++) #define int long long #define MOD 1000000007 int gcd(int a, int b) { if (a % b == 0) return b; return gcd(b, a % b); } int lcm(int a, int b) { return a / gcd(a, b) * b; } signed main() { int n; int a[11]; cin >> n;...
[["-", 8, 9, 0, 37, 0, 2, 3, 4, 0, 22], ["-", 8, 9, 0, 37, 0, 2, 3, 4, 0, 21], ["-", 0, 37, 0, 2, 3, 4, 0, 16, 17, 109], ["+", 8, 9, 0, 37, 0, 2, 3, 4, 0, 21], ["+", 0, 37, 0, 2, 3, 4, 0, 16, 17, 109], ["+", 0, 37, 0, 2, 3, 4, 0, 16, 12, 22]]
1
143
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; // < "D:\D_Download\Visual Studio // 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D...
#include "bits/stdc++.h" #include <unordered_map> #include <unordered_set> #pragma warning(disable : 4996) using namespace std; using ld = long double; template <class T> using Table = vector<vector<T>>; const ld eps = 1e-9; // < "D:\D_Download\Visual Studio // 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13]]
1
811
#include <algorithm> #include <cmath> #include <iostream> #include <stack> #include <string> #include <vector> using namespace std; int GCD(int a, int b) { while (1) { if (a < b) { swap(a, b); } a = a % b; if (a == 0) { return b; } } } int main() { int n; cin >> n; int a, b;...
#include <algorithm> #include <cmath> #include <iostream> #include <stack> #include <string> #include <vector> using namespace std; int GCD(int a, int b) { while (1) { if (a < b) { swap(a, b); } a = a % b; if (a == 0) { return b; } } } int main() { int n; cin >> n; int a, b;...
[["+", 0, 1, 0, 11, 12, 16, 31, 16, 31, 22], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 17, 48], ["+", 0, 1, 0, 11, 12, 16, 31, 16, 12, 22], ["+", 8, 9, 0, 1, 0, 11, 12, 16, 17, 85]]
1
125
#include <iostream> #include <vector> using namespace std; inline int gcd(int x, int y) { if (!y) return x; return gcd(y, x % y); } inline int lcm(int x, int y) { return (x * y) / gcd(y, x % y); } int main() { int n, x; vector<int> v; cin >> n; for (int i = 1; i <= n; ++i) cin >> x, v.push_back(x); ...
#include <iostream> #include <vector> using namespace std; inline int gcd(int x, int y) { if (!y) return x; return gcd(y, x % y); } inline int lcm(int x, int y) { return (x * y) / gcd(y, x % y); } int main() { int n, x; vector<int> v; cin >> n; for (int i = 1; i <= n; ++i) cin >> x, v.push_back(x); ...
[["+", 8, 9, 0, 7, 15, 16, 12, 16, 17, 33], ["+", 8, 9, 0, 7, 15, 16, 12, 16, 12, 13]]
1
164
#include <cstdio> #include <iostream> using namespace std; int gcd(int m, int n) { if (n == 0) return m; return gcd(n, m % n); } int lcm(int m, int n) { return m * n / gcd(m, n); } int main() { int n, A[n - 1]; cin >> n; for (int i = 0; i <= n - 1; i++) cin >> A[i]; int ans = A[0]; for (int i ...
#include <cstdio> #include <iostream> using namespace std; int gcd(int m, int n) { if (n == 0) return m; return gcd(n, m % n); } int lcm(int m, int n) { return m * n / gcd(m, n); } int main() { int n, A[10]; cin >> n; for (int i = 0; i <= n - 1; i++) cin >> A[i]; int ans = A[0]; for (int i = 1...
[["-", 8, 9, 0, 43, 49, 80, 81, 16, 31, 22], ["-", 8, 9, 0, 43, 49, 80, 81, 16, 17, 33], ["-", 8, 9, 0, 43, 49, 80, 81, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13]]
1
149
def gcd(a, b): if a < b: a, b = b, a while b: a, b = b, a%b return a def lcm(a, b): return a * b // gcd (a, b) n = int(input()) A = list(map(int, input().split())) ans = 1 for a in A: ans = (ans, a) print(ans)
def gcd(a, b): if a < b: a, b = b, a while b: a, b = b, a%b return a def lcm(a, b): return a * b // gcd (a, b) n = int(input()) A = list(map(int, input().split())) ans = 1 for a in A: ans = lcm(ans, a) print(ans)
[["+", 8, 196, 0, 1, 0, 662, 12, 652, 63, 22]]
5
97
import math def sieve(n): p = [1] * (n + 1) p[0] = p[1] = 0 for i in range(math.ceil((n + 1) ** 0.5)): if p[i]: for j in range(2 * i, len(p), i): p[j] = 0 return p def prime_factor(n): p = sieve(int(n ** 0.5)) factor = [] for pi in compress(count(0),...
import math def sieve(n): p = [1] * (n + 1) p[0] = p[1] = 0 for i in range(math.ceil((n + 1) ** 0.5)): if p[i]: for j in range(2 * i, len(p), i): p[j] = 0 return p from itertools import compress, count def prime_factor(n): p = sieve(int(n ** 0.5)) factor...
[["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 314], ["+", 36, 36, 0, 656, 0, 686, 687, 673, 0, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 487], ["+", 36, 36, 0, 656, 0, 686, 141, 673, 0, 22], ["+", 36, 36, 36, 36, 0, 656, 0, 686, 0, 21]]
5
243
n = eval(input()) nums = list(map(int,input().split())) x = 2 checklist = [0 for i in range(n)] table = [] while x<max(nums)/2: i=0 while i<n: if nums[i]%x==0: checklist[i]=0 nums[i] = nums[i]/x else: checklist[i]=1 i+=1 if 0 in checklist: ...
n = eval(input()) nums = list(map(int,input().split())) x = 2 checklist = [0 for i in range(n)] table = [] while x<=max(nums): i=0 while i<n: if nums[i]%x==0: checklist[i]=0 nums[i] = nums[i]/x else: checklist[i]=1 i+=1 if 0 in checklist: t...
[["-", 36, 36, 0, 656, 0, 52, 15, 666, 667, 18], ["+", 36, 36, 0, 656, 0, 52, 15, 666, 667, 19], ["-", 0, 656, 0, 52, 15, 666, 0, 657, 17, 85], ["-", 0, 656, 0, 52, 15, 666, 0, 657, 12, 612]]
5
159
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main { static BufferedReader in; static PrintWriter out; static StringTokenizer tok; void solve() throws IOException { int n = ni(); out.println(ph...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class Main { static BufferedReader in; static PrintWriter out; static StringTokenizer tok; void solve() throws IOException { int n = ni(); out.println(ph...
[["-", 8, 196, 0, 57, 64, 1, 0, 27, 0, 68], ["+", 8, 196, 0, 57, 64, 1, 0, 11, 17, 110], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 31, 22], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 17, 85], ["+", 0, 57, 64, 1, 0, 11, 12, 16, 12, 22]]
3
464
n; main(r, i) { scanf("%d", &n); r = n; for (i = 2; i * i <= n; i++) if (n % i == 0) for (r = 1LL * r * (i - 1) / i; n % i == 0; n /= i) ; if (n != 1) r = 1LL * r * --n / n; n = !printf("%d\n", r); }
n; main(r, i) { scanf("%d", &n); r = n; for (i = 2; i * i <= n; i++) if (n % i == 0) for (r = 1LL * r * (i - 1) / i; n % i == 0; n /= i) ; if (n != 1) r = 1LL * r * (n - 1) / n; n = !printf("%d\n", r); }
[["-", 0, 11, 12, 16, 31, 16, 12, 27, 17, 68], ["+", 0, 11, 12, 16, 31, 16, 12, 23, 0, 24], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 17, 33], ["+", 12, 16, 31, 16, 12, 23, 0, 16, 12, 13], ["+", 0, 11, 12, 16, 31, 16, 12, 23, 0, 25]]
0
105
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <stdio.h> int main() { int n, i, m; scanf("%d", &n); m = n; for (i = 2; i <= n && m != 1; i++) { if (m % i == 0) { n = n * (i - 1) / i; while (m % i == 0) m /= i; } } printf("%d\n", n); return 0; }
#define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include <stdio.h> int main() { long long int n, i, m; scanf("%lld", &n); m = n; for (i = 2; i <= n && m != 1; i++) { if (m % i == 0) { n = n * (i - 1) / i; while (m % i == 0) m /= i; } } printf("%lld\n", n); return 0;...
[["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
99
#include <math.h> #include <stdio.h> int main() { int n, i, N; double x; int ans; scanf("%d", &n); ans = n; x = sqrt(n); i = 2; while (i <= x) { if (n % i == 0) { while (n % i == 0) { n = n / i; } ans = ans * (i - 1) / i; } i++; } if (n != 1) ans = ans *...
#include <math.h> #include <stdio.h> int main() { long n, i, N; double x; long ans; scanf("%ld", &n); ans = n; x = sqrt(n); i = 2; while (i <= x) { if (n % i == 0) { while (n % i == 0) { n = n / i; } ans = ans * (i - 1) / i; } i++; } if (n != 1) ans = an...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
134
#include <cmath> #include <iostream> using namespace std; int main() { int n; cin >> n; int result = n; for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) { result = result / i * (i - 1); while (n % i == 0) n /= i; } } result = result / n * (n - 1); cout << result << endl; }
#include <cmath> #include <iostream> using namespace std; int main() { int n; cin >> n; int result = n; for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) { result = result / i * (i - 1); while (n % i == 0) n /= i; } } if (n > 1) result = result / n * (n - 1); cout << re...
[["+", 0, 30, 0, 14, 8, 9, 0, 57, 0, 121], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 24], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 31, 22], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 0, 14, 8, 9, 0, 57, 15, 339, 0, 25]]
1
97
#include <stdio.h> int n, r; int main() { scanf("%d", &n); r = n; for (int i = 2; i * i <= n; i++) { if (n % i == 0) r = r * (i - 1) / i; while (n % i == 0) n /= i; } if (n != 1) r = r * (n - 1) / n; printf("%d\n", r); return 0; }
#include <stdio.h> int n, r; int main() { scanf("%d", &n); r = n; for (int i = 2; i * i <= n; i++) { if (n % i == 0) r = 1LL * r * (i - 1) / i; while (n % i == 0) n /= i; } if (n != 1) r = 1LL * r * (n - 1) / n; printf("%d\n", r); return 0; }
[["+", 0, 11, 12, 16, 31, 16, 31, 16, 31, 13], ["+", 0, 11, 12, 16, 31, 16, 31, 16, 17, 48]]
1
108
#include <cmath> #include <iostream> #include <set> using namespace std; void solve() { set<int> primeFactor; int n; cin >> n; int input = n; for (int i = 2; i <= sqrt(input); ++i) { while (n % i == 0) { n /= i; primeFactor.insert(i); } } if (n != 1) { primeFactor.insert(n); } ...
#include <cmath> #include <iostream> #include <set> using namespace std; void solve() { set<int> primeFactor; int n; cin >> n; int input = n; for (int i = 2; i <= sqrt(input); ++i) { while (n % i == 0) { n /= i; primeFactor.insert(i); } } if (n != 1) { primeFactor.insert(n); } ...
[["-", 0, 14, 8, 9, 0, 43, 49, 50, 51, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 50, 51, 22], ["-", 0, 16, 31, 16, 12, 74, 51, 23, 0, 24], ["-", 31, 16, 12, 74, 51, 23, 0, 16, 31, 22], ["-", 31, 16, 12, 74, 51, 23, 0, 16, 17, 48], ["-", 0, 16, 31, 16, 12, 74, 51, 23, 0, 25]]
1
162
#include <cmath> #include <iostream> #include <vector> using namespace std; const int MAX_RN = sqrt(1000000000) + 1; int main() { int n; cin >> n; vector<int> prime(MAX_RN + 1, 1); int def_n = n; int ct = 0; int ans = def_n; for (int i = 2; i * i <= def_n; i++) { bool is_div = false; while (n % ...
#include <cmath> #include <iostream> #include <vector> using namespace std; const int MAX_RN = sqrt(1000000000) + 1; int main() { int n; cin >> n; vector<int> prime(MAX_RN + 1, 1); int def_n = n; int ct = 0; long long ans = def_n; for (int i = 2; i * i <= def_n; i++) { bool is_div = false; while...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 14, 8, 9, 0, 43, 39, 86, 0, 96], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47]]
1
148