Datasets:

problem_id
stringlengths
6
6
buggy_code
stringlengths
8
526k
fixed_code
stringlengths
12
526k
labels
listlengths
0
15
buggy_submission_id
int64
1
1.54M
fixed_submission_id
int64
2
1.54M
user_id
stringlengths
10
10
language
stringclasses
8 values
p02792
N = int(input()) lst = [[0 for i in range(10)]for j in range(10)] ans = 0 for i in range(N): tmp = list(str(i)) lst[int(tmp[0])][int(tmp[-1])]+=1 for i in range(10): for j in range(10): if i == 0 or j == 0: continue if i == j: ans+=lst[i][j]**2 else: ans+=lst[i][j]*lst[j][i] print(ans)
N = int(input()) lst = [[0 for i in range(10)]for j in range(10)] ans = 0 for i in range(1,N+1): tmp = list(str(i)) lst[int(tmp[0])][int(tmp[-1])]+=1 for i in range(10): for j in range(10): if i == 0 or j == 0: continue if i == j: ans+=lst[i][j]**2 else: ans+=lst[i][j]*lst[j][i] print(ans)
[ "call.arguments.add" ]
598,704
598,705
u189479417
python
p02792
def g(n): D = [[0]*10 for i in range(10)] for i in range(1,n+1): si = str(i) D[int(si[0])][int(si[-1])] += 1 res = 0 for i in range(10): for j in range(10): res += D[i][j]*D[j][i] return res print(g(int(n)))
def g(n): D = [[0]*10 for i in range(10)] for i in range(1,n+1): si = str(i) D[int(si[0])][int(si[-1])] += 1 res = 0 for i in range(10): for j in range(10): res += D[i][j]*D[j][i] return res print(g(int(input())))
[ "call.arguments.change", "call.add" ]
598,706
598,707
u406492455
python
p02792
s=input() n=int(s) d={} for i in range(1,n): ts=str(i) hs=ts[0]+" "+ts[len(ts)-1] if(hs in d): d[hs]+=1 else: d[hs]=1 ans=0 for i in range(1,10): for j in range(1,10): if(((str(i)+" "+str(j)) in d) and ((str(j)+" "+str(i)) in d)): ans+=d[(str(i)+" "+str(j))]*d[(str(j)+" "+str(i))] print(ans)
s=input() n=int(s) d={} for i in range(1,n+1): ts=str(i) hs=ts[0]+" "+ts[len(ts)-1] if(hs in d): d[hs]+=1 else: d[hs]=1 ans=0 for i in range(1,10): for j in range(1,10): if(((str(i)+" "+str(j)) in d) and ((str(j)+" "+str(i)) in d)): ans+=d[(str(i)+" "+str(j))]*d[(str(j)+" "+str(i))] print(ans)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
598,708
598,709
u235172502
python
p02792
import queue import math import copy """ N = int(input()) #S = input() # (N,M) = (int(i) for i in input().split(" ")) # A = [int(i) for i in input().split()] A = [] for i in range(N): A.append(int(input())) print(A) """ N = int(input()) mp = [[0 for j in range(10)]for i in range(10)] for i in range(N): j = i while j >= 10: j //= 10 mp[j][i%10] += 1 ans = 0 for i in range(1,10): for j in range(1,10): ans += mp[i][j]*mp[j][i] print(ans)
import queue import math import copy """ N = int(input()) #S = input() # (N,M) = (int(i) for i in input().split(" ")) # A = [int(i) for i in input().split()] A = [] for i in range(N): A.append(int(input())) print(A) """ N = int(input()) mp = [[0 for j in range(10)]for i in range(10)] for i in range(1,N+1): j = i while j >= 10: j //= 10 mp[j][i%10] += 1 ans = 0 for i in range(1,10): for j in range(1,10): ans += mp[i][j]*mp[j][i] print(ans)
[ "call.arguments.add" ]
598,714
598,715
u869595612
python
p02792
N = int(input()) A = [[0 for i in range(11)] for j in range(11)] for i in range(1, N): A[int(str(i)[0])][int(str(i)[-1])] +=1 B = [[0 for i in range(11)] for j in range(11)] for i in range(1, N): B[int(str(i)[0])][int(str(i)[-1])] +=1 ans = 0 for i in range(10): for j in range(10): ans += A[i][j] * B[j][i] print(ans)
N = int(input()) A = [[0 for i in range(11)] for j in range(11)] for i in range(1, N+1): A[int(str(i)[0])][int(str(i)[-1])] +=1 B = [[0 for i in range(11)] for j in range(11)] for i in range(1, N+1): B[int(str(i)[0])][int(str(i)[-1])] +=1 ans = 0 for i in range(10): for j in range(10): ans += A[i][j] * B[j][i] print(ans)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
598,716
598,717
u667084803
python
p02792
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**8) input = sys.stdin.readline n = int(input()) cnt = [[0] * 10 for _ in range(10)] for i in range(n): s = str(i) front = int(s[0]) end = int(s[-1]) cnt[front][end] += 1 ans = 0 for i in range(1, 10): for j in range(1, 10): ans += cnt[i][j] * cnt[j][i] print(ans)
#!/usr/bin/env python3 import sys sys.setrecursionlimit(10**8) input = sys.stdin.readline n = int(input()) cnt = [[0] * 10 for _ in range(10)] for i in range(1, n+1): s = str(i) front = int(s[0]) end = int(s[-1]) cnt[front][end] += 1 ans = 0 for i in range(1, 10): for j in range(1, 10): ans += cnt[i][j] * cnt[j][i] print(ans)
[ "call.arguments.add" ]
598,729
598,730
u052499405
python
p02792
n=int(input()) s=str(n) m=len(s) ans=0 if n<=9: print(n) exit() if n<=99: for i in range(1,n+1): for j in range(1,n+1): if str(i)[-1]=="0": continue if str(i)[0]==str(j)[-1] and str(j)[0]==str(i)[-1]: ans+=1 print(ans) exit() y=int(s[1:m-1]) for i in range(1,n+1): a,b=str(i)[0],str(i)[-1] if b=="0": continue if a==b: ans+=1 dig=1 for j in range(m-2): ans+=dig dig*=10 if int(b)==int(s[0]): if int(a)>int(s[-1]): ans+=y else: ans+=y elif int(b)<int(s[0]): ans+=dig print(ans)
n=int(input()) s=str(n) m=len(s) ans=0 if n<=9: print(n) exit() if n<=99: for i in range(1,n+1): for j in range(1,n+1): if str(i)[-1]=="0": continue if str(i)[0]==str(j)[-1] and str(j)[0]==str(i)[-1]: ans+=1 print(ans) exit() y=int(s[1:m-1]) for i in range(1,n+1): a,b=str(i)[0],str(i)[-1] if b=="0": continue if a==b: ans+=1 dig=1 for j in range(m-2): ans+=dig dig*=10 if int(b)==int(s[0]): if int(a)>int(s[-1]): ans+=y else: ans+=y+1 elif int(b)<int(s[0]): ans+=dig print(ans)
[ "expression.operation.binary.add" ]
598,751
598,752
u225388820
python
p02792
n = int(input()) n_digit = len(str(n)) ans = 0 for i in range(1,n+1): max_a = list(str(i))[0] min_a = list(str(i))[-1] if min_a == "0": continue else: if max_a == min_a: if int(max_a)<=n: ans += 1 for j in range(n_digit-1): max_b = int(min_a+"9"*j+max_a) min_b = int(min_a+"0"*j+max_a) if max_b <= n: ans += int(10**j) elif min_b > n: continue else: ans += (n-min_b)//10 print(ans)
n = int(input()) n_digit = len(str(n)) ans = 0 for i in range(1,n+1): max_a = list(str(i))[0] min_a = list(str(i))[-1] if min_a == "0": continue else: if max_a == min_a: if int(max_a)<=n: ans += 1 for j in range(n_digit-1): max_b = int(min_a+"9"*j+max_a) min_b = int(min_a+"0"*j+max_a) if max_b <= n: ans += int(10**j) elif min_b > n: continue else: ans += (n-min_b)//10+1 print(ans)
[ "expression.operation.binary.add" ]
598,757
598,758
u097317219
python
p02792
N = int(input()) Nm = int(str(N)[0]) N0 = int(str(N)[-1]) ORD_N = len(str(N)) N_LEFT = int(str(N)[1:-1]) if 2 < ORD_N else -1 def get_number_less_than_N(bm, b0): """ 先頭bm, 後ろb0 を持ち、N より小さい値の数 """ count = 0 # print('='*10) # b が1桁 if bm == b0: count += 1 # print('1k', count) # b が2桁 (N以下ならば該当) if bm*10 + b0 <= N: count += 1 # print('2k', count) # order(N) 未満の桁 # たとえばN=10000 なら、3桁(bm x b0), 4桁(bm xx b0) のパターンは全てOK for i in range(3, ORD_N): count += 10 ** (i-2) # print('M', i, count) # order(N) のけた # bm xx.. b0 <= Nm N1 N2.. N0 if ORD_N >= 3 and bm <= Nm: if bm < Nm: count += 10 ** (ORD_N-2) # print('L++', count) elif b0 == N0: count += N_LEFT + 1 # print('L+', count) else: count += N_LEFT # print('L', count) return count count = 0 for i in range(1, N+1): bm, b0 = int(str(i)[-1]), int(str(i)[0]) if bm == 0: continue cold = count count += get_number_less_than_N(bm, b0) print(count)
N = int(input()) Nm = int(str(N)[0]) N0 = int(str(N)[-1]) ORD_N = len(str(N)) N_LEFT = int(str(N)[1:-1]) if 2 < ORD_N else -1 # print(N, ORD_N) # print(Nm, N0, N_LEFT) # print('!' * 10) # print() # def get_number_less_than_N(bm, b0): """ 先頭bm, 後ろb0 を持ち、N より小さい値の数 """ count = 0 # b が1桁 if bm == b0: count += 1 # print('1k', count) # b が2桁 (N以下ならば該当) if bm*10 + b0 <= N: count += 1 # print('2k', count) # order(N) 未満の桁 # たとえばN=10000 なら、3桁(bm x b0), 4桁(bm xx b0) のパターンは全てOK for i in range(3, ORD_N): count += 10 ** (i-2) # print('M', i, count) # order(N) のけた # bm xx.. b0 <= Nm N1 N2.. N0 if ORD_N >= 3 and bm <= Nm: if bm < Nm: count += 10 ** (ORD_N-2) # print('L++', count) elif b0 <= N0: count += N_LEFT + 1 # print('L+', count) else: count += N_LEFT # print('L', count) # print('='*10) return count count = 0 for i in range(1, N+1): # couniprint("<<", i) bm, b0 = int(str(i)[-1]), int(str(i)[0]) if bm == 0: continue cold = count count += get_number_less_than_N(bm, b0) print(count)
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
598,763
598,764
u347064383
python
p02792
N = int(input()) Nm = int(str(N)[0]) N0 = int(str(N)[-1]) ORD_N = len(str(N)) N_LEFT = int(str(N)[1:-1]) if 2 < ORD_N else -1 def get_number_less_than_N(bm, b0): """ 先頭bm, 後ろb0 を持ち、N より小さい値の数 """ count = 0 # print('='*10) # b が1桁 if bm == b0: count += 1 # print('1k', count) # b が2桁 (N以下ならば該当) if bm*10 + b0 <= N: count += 1 # print('2k', count) # order(N) 未満の桁 # たとえばN=10000 なら、3桁(bm x b0), 4桁(bm xx b0) のパターンは全てOK for i in range(3, ORD_N): count += 10 ** (i-2) # print('M', i, count) # order(N) のけた # bm xx.. b0 <= Nm N1 N2.. N0 if ORD_N >= 3 and bm <= Nm: if bm < Nm: count += 10 ** (ORD_N-2) # print('L++', count) elif b0 == N0: count += N_LEFT + 1 # print('L+', count) else: count += N_LEFT # print('L', count) return count count = 0 for i in range(1, N+1): bm, b0 = int(str(i)[-1]), int(str(i)[0]) if bm == 0: continue cold = count count += get_number_less_than_N(bm, b0) print(count)
N = int(input()) Nm = int(str(N)[0]) N0 = int(str(N)[-1]) ORD_N = len(str(N)) N_LEFT = int(str(N)[1:-1]) if 2 < ORD_N else -1 # print(N, ORD_N) # print(Nm, N0, N_LEFT) # print('!' * 10) # print() # def get_number_less_than_N(bm, b0): """ 先頭bm, 後ろb0 を持ち、N より小さい値の数 """ count = 0 # b が1桁 if bm == b0: count += 1 # print('1k', count) # b が2桁 (N以下ならば該当) if bm*10 + b0 <= N: count += 1 # print('2k', count) # order(N) 未満の桁 # たとえばN=10000 なら、3桁(bm x b0), 4桁(bm xx b0) のパターンは全てOK for i in range(3, ORD_N): count += 10 ** (i-2) # print('M', i, count) # order(N) のけた # bm xx.. b0 <= Nm N1 N2.. N0 if ORD_N >= 3 and bm <= Nm: if bm < Nm: count += 10 ** (ORD_N-2) # print('L++', count) elif b0 <= N0: count += N_LEFT + 1 # print('L+', count) else: count += N_LEFT # print('L', count) # print('='*10) return count count = 0 for i in range(1, N+1): # couniprint("<<", i) bm, b0 = int(str(i)[-1]), int(str(i)[0]) if bm == 0: continue cold = count count += get_number_less_than_N(bm, b0) print(count)
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
598,765
598,764
u347064383
python
p02792
n = int(input()) a = [0] * 100 for i in range(1,n+1): msb = str(i)[0] lsb = str(i)[-1] if msb == '0' or lsb == '0': continue a[int(msb) * 10 + int(lsb)] += 1 tmp = 0 for i, ai in enumerate(a): if '0' not in str(i): if i % 11 == 0: tmp += ai * ai else: tmp += ai * a[int(str(i)[::-1])] else: continue print(tmp) print(a)
n = int(input()) a = [0] * 100 for i in range(1,n+1): msb = str(i)[0] lsb = str(i)[-1] if msb == '0' or lsb == '0': continue a[int(msb) * 10 + int(lsb)] += 1 tmp = 0 for i, ai in enumerate(a): if '0' not in str(i): if i % 11 == 0: tmp += ai * ai else: tmp += ai * a[int(str(i)[::-1])] else: continue print(tmp)
[ "call.remove" ]
598,770
598,771
u762275701
python
p02792
n = int(input()) a = [0] * 100 for i in range(n): msb = str(i)[0] lsb = str(i)[-1] if msb == '0' or lsb == '0': continue a[int(msb) * 10 + int(lsb)] += 1 tmp = 0 for i, ai in enumerate(a): if '0' not in str(i): if i % 11 == 0: tmp += ai * ai else: tmp += ai * a[int(str(i)[::-1])] else: continue print(tmp)
n = int(input()) a = [0] * 100 for i in range(1,n+1): msb = str(i)[0] lsb = str(i)[-1] if msb == '0' or lsb == '0': continue a[int(msb) * 10 + int(lsb)] += 1 tmp = 0 for i, ai in enumerate(a): if '0' not in str(i): if i % 11 == 0: tmp += ai * ai else: tmp += ai * a[int(str(i)[::-1])] else: continue print(tmp)
[ "call.arguments.add" ]
598,772
598,771
u762275701
python
p02792
n = int(input()) mem=[[0] * 10 for _ in range(10)] for i in range(1, N+1): s = str(i) mem[int(s[0])][int(s[-1])] += 1 ans = 0 for i in range(1, 10): for j in range(1, 10): ans += mem[i][j] * mem[j][i] print(ans)
N = int(input()) mem=[[0] * 10 for _ in range(10)] for i in range(1, N+1): s = str(i) mem[int(s[0])][int(s[-1])] += 1 ans = 0 for i in range(1, 10): for j in range(1, 10): ans += mem[i][j] * mem[j][i] print(ans)
[ "assignment.variable.change", "identifier.change" ]
598,775
598,776
u580404776
python
p02792
N = int(input()) from collections import defaultdict d=defaultdict(int) for i in range(1,N): a,b=str(i)[0],str(i)[-1] d[(int(a),int(b))]+=1 r = 0 for i in range(1,10): for j in range(1,10): r += d[(i,j)] * d[(j,i)] print(r)
N = int(input()) from collections import defaultdict d=defaultdict(int) for i in range(1,N+1): a,b=str(i)[0],str(i)[-1] d[(int(a),int(b))]+=1 r = 0 for i in range(1,10): for j in range(1,10): r += d[(i,j)] * d[(j,i)] print(r)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
598,777
598,778
u941407962
python
p02792
N = int(input()) ans = 0 l=[[0]*10 for _ in range(10)] for i in range(1,2021): s = str(i) l[int(s[0])][int(s[-1])]+=1 for i in range(10): for j in range(10): ans+=l[i][j]*l[j][i] print(ans)
N = int(input()) ans = 0 l=[[0]*10 for _ in range(10)] for i in range(1,N+1): s = str(i) l[int(s[0])][int(s[-1])]+=1 for i in range(10): for j in range(10): ans+=l[i][j]*l[j][i] print(ans)
[ "identifier.replace.add", "literal.replace.remove", "call.arguments.change", "control_flow.loop.range.bounds.upper.change" ]
598,781
598,782
u268554510
python
p02792
def bunkai(n:int): ls=list(str(n)) top,bottom=int(ls[0]),int(ls[-1]) if n<=99: middle=0 else: middle=int("".join(ls[1:-1])) return top, middle, bottom n=int(input()) Nt,Nm,Nb = bunkai(n) count=0 for i in range(1,n+1): t,m,b = bunkai(i) if b==0:continue if t==b:count+=1 if n<=99: if int(b+t)<=n:count+=1 else: keta = len(str(n)) for x in range(keta-2): count+=10**x x+=1 if Nt>b: count+=10**x elif Nt==b: if Nb>=t: count+=Nm+1 else: count+=Nm print(count)
def bunkai(n:int): ls=list(str(n)) top,bottom=int(ls[0]),int(ls[-1]) if n<=99: middle=0 else: middle=int("".join(ls[1:-1])) return top, middle, bottom n=int(input()) Nt,Nm,Nb = bunkai(n) count=0 for i in range(1,n+1): t,m,b = bunkai(i) if b==0:continue if t==b:count+=1 if n<=99: if int(str(b)+str(t))<=n:count+=1 else: keta = len(str(n)) for x in range(keta-2): count+=10**x x+=1 if Nt>b: count+=10**x elif Nt==b: if Nb>=t: count+=Nm+1 else: count+=Nm print(count)
[ "control_flow.branch.if.condition.change", "control_flow.loop.for.condition.change", "call.add" ]
598,783
598,784
u256351611
python
p02792
# 解答見た n = int(input()) a = [[0 for i in range(10)] for j in range(10)] for i in range(n): b = int(str(i)[0]) c = int(str(i)[-1]) a[b][c] += 1 ans = 0 for i in range(1,10): for j in range(1,10): ans += a[i][j]*a[j][i] print(ans)
n = int(input()) a = [[0 for i in range(10)] for j in range(10)] for i in range(1,n+1): b = int(str(i)[0]) c = int(str(i)[-1]) a[b][c] += 1 ans = 0 for i in range(1,10): for j in range(1,10): ans += a[i][j]*a[j][i] print(ans)
[ "call.arguments.add" ]
598,790
598,791
u190405389
python
p02792
n = int(input()) table = [ [0]*10 for _ in range(10) ] # print(table) for i in range(1,n): a = str(i) s = int(a[0]) e = int(a[-1]) table[s][e] += 1 # print(table) ans = 0 for i in range(10): for j in range(10): ans += table[i][j] * table[j][i] print(ans)
n = int(input()) table = [ [0]*10 for _ in range(10) ] # print(table) for i in range(1,n+1): a = str(i) s = int(a[0]) e = int(a[-1]) table[s][e] += 1 # print(table) ans = 0 for i in range(10): for j in range(10): ans += table[i][j] * table[j][i] print(ans)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
598,794
598,795
u255673886
python
p02792
N = int(input()) cnt = [[0 for _ in range(10)] for _ in range(10)] for k in range(1, n+1): s = str(k) cnt[int(s[0])][int(s[-1])] += 1 ans = 0 for i in range(10): for j in range(10): ans += cnt[i][j] * cnt[j][i] print(ans)
N = int(input()) cnt = [[0 for _ in range(10)] for _ in range(10)] for k in range(1, N+1): s = str(k) cnt[int(s[0])][int(s[-1])] += 1 ans = 0 for i in range(10): for j in range(10): ans += cnt[i][j] * cnt[j][i] print(ans)
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "control_flow.loop.range.bounds.upper.change" ]
598,805
598,806
u459150945
python
p02792
N = int(input()) cnt = [[0 for _ in range(10)] for _ in range(10)] for k in range(1, n+1): s = str(k) cnt[int(s[0])][int(s[-1])] += 1 ans = 0 for i in range(10): for j in range(10): ans += c[i][j] * c[j][i] print(ans)
N = int(input()) cnt = [[0 for _ in range(10)] for _ in range(10)] for k in range(1, N+1): s = str(k) cnt[int(s[0])][int(s[-1])] += 1 ans = 0 for i in range(10): for j in range(10): ans += cnt[i][j] * cnt[j][i] print(ans)
[ "identifier.change", "call.arguments.change", "expression.operation.binary.change", "control_flow.loop.range.bounds.upper.change" ]
598,807
598,806
u459150945
python
p02792
n = int(input()) ans = 0 table = [[0]*10 for _ in range(10)] for number in range(1, n): i = int(str(number)[0]) j = int(str(number)[-1]) table[i][j] += 1 for i in range(1,10): for j in range(1, 10): ans += table[j][i] * table[i][j] print(ans)
n = int(input()) ans = 0 table = [[0]*10 for _ in range(10)] for number in range(1, n+1): i = int(str(number)[0]) j = int(str(number)[-1]) table[i][j] += 1 for i in range(1,10): for j in range(1, 10): ans += table[j][i] * table[i][j] print(ans)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
598,808
598,809
u952467214
python
p02792
N = int(input()) C = [0]*100 for i in range(N): s = str(i) C[10*int(s[0])+int(s[-1])] += 1 print(sum([C[10*i+j]*C[10*j+i] for i in range(10) for j in range(10)]))
N = int(input()) C = [0]*100 for i in range(1,N+1): s = str(i) C[10*int(s[0])+int(s[-1])] += 1 print(sum([C[10*i+j]*C[10*j+i] for i in range(10) for j in range(10)]))
[ "call.arguments.add" ]
598,812
598,813
u602740328
python
p02792
N = int(input()) count = 0 c = [[0 for i in range(10)]for j in range(10)] for i in range(1,N): str_i = str(i) c[int(str_i[0])][int(str_i[-1])] += 1 for j in range(10): for k in range(10): count += c[j][k] * c[k][j] print(count)
N = int(input()) count = 0 c = [[0 for i in range(10)]for j in range(10)] for i in range(1,N+1): str_i = str(i) c[int(str_i[0])][int(str_i[-1])] += 1 for j in range(10): for k in range(10): count += c[j][k] * c[k][j] print(count)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
598,814
598,815
u231189826
python
p02792
N = int(input()) table = [[0] * 10 for _ in range(10)] for i in range(1, N): s = str(i) if s[-1] == '0': continue table[int(s[0])][int(s[-1])] += 1 ans = 0 for i in range(1, 10): for j in range(1, 10): ans += table[i][j] * table[j][i] print(ans)
N = int(input()) table = [[0] * 10 for _ in range(10)] for i in range(1, N+1): s = str(i) if s[-1] == '0': continue table[int(s[0])][int(s[-1])] += 1 ans = 0 for i in range(1, 10): for j in range(1, 10): ans += table[i][j] * table[j][i] print(ans)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
598,819
598,820
u894934980
python
p02792
N = int(input()) l = [[0] * 10 for _ in range(10)] ans = 0 for i in range(1, N+1): s = int(str(i)[0]) t = int(str(i)[-1]) l[s][t] += 1 for i in range(1, 10): for j in range(1, 10): ans += l[i][j] * l[j][i] print(l) print(ans)
N = int(input()) l = [[0] * 10 for _ in range(10)] ans = 0 for i in range(1, N+1): s = int(str(i)[0]) t = int(str(i)[-1]) l[s][t] += 1 for i in range(1, 10): for j in range(1, 10): ans += l[i][j] * l[j][i] print(ans)
[ "call.remove" ]
598,823
598,824
u580073714
python
p02792
N = int(input()) l = [[0] * 10 for _ in range(10)] ans = 0 for i in range(N): s = int(str(i)[0]) t = int(str(i)[-1]) l[s][t] += 1 for i in range(1, 10): for j in range(1, 10): ans += l[i][j] * l[j][i] print(ans)
N = int(input()) l = [[0] * 10 for _ in range(10)] ans = 0 for i in range(1, N+1): s = int(str(i)[0]) t = int(str(i)[-1]) l[s][t] += 1 for i in range(1, 10): for j in range(1, 10): ans += l[i][j] * l[j][i] print(ans)
[ "call.arguments.add" ]
598,825
598,824
u580073714
python
p02792
import numpy as np N = int(input()) # TT = [[0]*10 for i in range(10)] TT = np.zeros((10,10)) for i in range(N+1): top = int(str(i)[0]) tail = int(str(i)[-1]) TT[top,tail] += 1 print(TT) y = 0 for i in range(1,10): for j in range(1,10): y += TT[i,j]*TT[j,i] print(int(y))
import numpy as np N = int(input()) # TT = [[0]*10 for i in range(10)] TT = np.zeros((10,10)) for i in range(N+1): top = int(str(i)[0]) tail = int(str(i)[-1]) TT[top,tail] += 1 #print(TT) y = 0 for i in range(1,10): for j in range(1,10): y += TT[i,j]*TT[j,i] print(int(y))
[ "call.remove" ]
598,828
598,829
u899308536
python
p02792
N = int(input()) TT = [[0]*10 for i in range(10)] for i in range(N+1): top = int(str(i)[0]) tail = int(str(i)[-1]) TT[top][tail] += 1 print(TT) y = 0 for i in range(1,10): for j in range(1,10): y += TT[i][j]*TT[j][i] print(y)
N = int(input()) TT = [[0]*10 for i in range(10)] for i in range(N+1): top = int(str(i)[0]) tail = int(str(i)[-1]) TT[top][tail] += 1 #print(TT) y = 0 for i in range(1,10): for j in range(1,10): y += TT[i][j]*TT[j][i] print(y)
[ "call.remove" ]
598,830
598,831
u899308536
python
p02792
N = int(input()) TT = [[0]*10 for i in range(10)] for i in range(N): top = int(str(i)[0]) tail = int(str(i)[-1]) TT[top][tail] += 1 #print(TT) y = 0 for i in range(1,10): for j in range(1,10): y += TT[i][j]*TT[j][i] print(y)
N = int(input()) TT = [[0]*10 for i in range(10)] for i in range(N+1): top = int(str(i)[0]) tail = int(str(i)[-1]) TT[top][tail] += 1 #print(TT) y = 0 for i in range(1,10): for j in range(1,10): y += TT[i][j]*TT[j][i] print(y)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
598,832
598,831
u899308536
python
p02792
N = int(input()) K = len(str(N)) MS = int(str(N)[0]) ML = int(str(N)[-1]) res = 0 for i in range(1, N+1): AS = int(str(i)[0]) AL = int(str(i)[-1]) if AL == 0: continue for k in range(1, K+1): if k == 1: if AS == AL and AS <= N: res += 1 continue if k == 2: if int(str(AL) + str(AS)) <= N: res += 1 continue if k < K: res += 10 ** (k - 2) continue if k == K: if AL > MS: continue if AL < MS: res += 10 ** (k - 2) continue if AL == MS: if AS < ML: res += (int(str(N)[1:])+9) // 10 continue else: res += (int(str(N)[1:])) // 10 continue print(res)
N = int(input()) K = len(str(N)) MS = int(str(N)[0]) ML = int(str(N)[-1]) res = 0 for i in range(1, N+1): AS = int(str(i)[0]) AL = int(str(i)[-1]) if AL == 0: continue for k in range(1, K+1): if k == 1: if AS == AL and AS <= N: res += 1 continue if k == 2: if int(str(AL) + str(AS)) <= N: res += 1 continue if k < K: res += 10 ** (k - 2) continue if k == K: if AL > MS: continue if AL < MS: res += 10 ** (k - 2) continue if AL == MS: if AS <= ML: res += (int(str(N)[1:])+9) // 10 continue else: res += (int(str(N)[1:])) // 10 continue print(res)
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
598,835
598,836
u596368396
python
p02792
N = int(input()) K = len(str(N)) MS = int(str(N)[0]) ML = int(str(N)[-1]) res = 0 for i in range(1, N+1): AS = int(str(i)[0]) AL = int(str(i)[-1]) if AL == 0: continue for k in range(1, K+1): if k == 1: if AS == AL and AS <= N: res += 1 continue if k == 2: if int(str(AL) + str(AS)) <= N: res += 1 continue if k < K: res += 10 ** (k - 2) continue if k == K: if AL > MS: continue if AL < MS: res += 10 ** (k - 2) continue if AL == MS: if AS < ML: res += int(str(N)[1:] + 9) // 10 continue else: res += (int(str(N)[1:])) // 10 continue print(res)
N = int(input()) K = len(str(N)) MS = int(str(N)[0]) ML = int(str(N)[-1]) res = 0 for i in range(1, N+1): AS = int(str(i)[0]) AL = int(str(i)[-1]) if AL == 0: continue for k in range(1, K+1): if k == 1: if AS == AL and AS <= N: res += 1 continue if k == 2: if int(str(AL) + str(AS)) <= N: res += 1 continue if k < K: res += 10 ** (k - 2) continue if k == K: if AL > MS: continue if AL < MS: res += 10 ** (k - 2) continue if AL == MS: if AS <= ML: res += (int(str(N)[1:])+9) // 10 continue else: res += (int(str(N)[1:])) // 10 continue print(res)
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change", "call.arguments.change" ]
598,837
598,836
u596368396
python
p02792
N = int(input()) c = [] for i in range(10): c.append([0] * 10) for i in range(1,N): s = str(i) i1 = int(s[0]) i2 = int(s[-1]) c[i1][i2] += 1 total = 0 for i in range(10): for j in range(10): total += c[i][j] * c[j][i] print(total)
N = int(input()) c = [] for i in range(10): c.append([0] * 10) for i in range(N): s = str(i+1) i1 = int(s[0]) i2 = int(s[-1]) c[i1][i2] += 1 total = 0 for i in range(10): for j in range(10): total += c[i][j] * c[j][i] print(total)
[ "call.arguments.change" ]
598,842
598,843
u006883624
python
p02792
n = int(input()) d = [[0] * 10 for _ in range(10)] for i in range(1, n + 1): s = str(i) if s[-1] == '0': continue d[int(s[0])][int(s[-1])] += 1 result = 0 for i in range(1, 10): for j in range(1, 10): result = d[i][j] * d[j][i] print(result)
n = int(input()) d = [[0] * 10 for _ in range(10)] for i in range(1, n + 1): s = str(i) if s[-1] == '0': continue d[int(s[0])][int(s[-1])] += 1 result = 0 for i in range(1, 10): for j in range(1, 10): result += d[i][j] * d[j][i] print(result)
[ "assignment.value.change" ]
598,846
598,847
u079427319
python
p02792
N= int(input()) lead_N = int(str(N)[0]) end_N = int(str(N)[len(str(N)) - 1]) ans = 0 #print(str(100)[len(str(100)) - 1]) for i in range(1, N + 1): lead = int(str(i)[0]) end = int(str(i)[len(str(i)) - 1]) # 一桁 if lead == end: ans += 1 #2桁以上ループ lead + 中間 + end  for j in range((len(str(N)) - 2) + 1): if end == 0: #末尾が0 continue elif end > lead_N and j == (len(str(N)) - 2) : #生成する整数がNに収まらない場合 continue elif end == lead_N and j == (len(str(N)) - 2): #生成する整数の一部がNに収まらない場合 #中間の数字 if len(str(N)) >= 4: ans += int(str(N)[1:len(str(N)) - 2]) if lead <= end_N: ans += 1 #print("b") pass else: #何も気にしないときは組み合わせの分だけたす ans += 10 ** j print(ans)
N= int(input()) lead_N = int(str(N)[0]) end_N = int(str(N)[len(str(N)) - 1]) ans = 0 #print(str(100)[len(str(100)) - 1]) for i in range(1, N + 1): lead = int(str(i)[0]) end = int(str(i)[len(str(i)) - 1]) # 一桁 if lead == end: ans += 1 #2桁以上ループ lead + 中間 + end  for j in range((len(str(N)) - 2) + 1): if end == 0: #末尾が0 continue elif end > lead_N and j == (len(str(N)) - 2) : #生成する整数がNに収まらない場合 continue elif end == lead_N and j == (len(str(N)) - 2): #生成する整数の一部がNに収まらない場合 #中間の数字 if len(str(N)) >= 3: ans += int(str(N)[1:len(str(N)) - 1]) if lead <= end_N: ans += 1 #print("b") pass else: #何も気にしないときは組み合わせの分だけたす ans += 10 ** j print(ans)
[ "literal.number.integer.change", "control_flow.branch.if.condition.change", "variable_access.subscript.index.change", "call.arguments.change" ]
598,857
598,856
u504256702
python
p02792
import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) n = int(input()) ans_dict = {} ans = 0 for i in range(1,10): for j in range(1,10): ans_dict[i*10+j]=0 for num in range(1,n+1): num_str = str(num) i = int(num_str[len(num_str)-1]) j = int(num_str[0]) if (i!=0) & (j!=0): ans_dict[i*10+j] +=1 print(ans_dict) for key_ in ans_dict.keys(): if str(key_)[0] == str(key_)[1]: ans += ans_dict[key_]**2 else: key_s = key_//10+int(str(key_)[1])*10 ans += ans_dict[key_] * ans_dict[key_s]*2 ans_dict[key_s] = 0 print(ans)
import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) n = int(input()) ans_dict = {} ans = 0 for i in range(1,10): for j in range(1,10): ans_dict[i*10+j]=0 for num in range(1,n+1): num_str = str(num) i = int(num_str[len(num_str)-1]) j = int(num_str[0]) if (i!=0) & (j!=0): ans_dict[i*10+j] +=1 for key_ in ans_dict.keys(): if str(key_)[0] == str(key_)[1]: ans += ans_dict[key_]**2 else: key_s = key_//10+int(str(key_)[1])*10 ans += ans_dict[key_] * ans_dict[key_s]*2 ans_dict[key_s] = 0 print(ans)
[ "call.remove" ]
598,870
598,871
u214561383
python
p02792
import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) n = int(input()) ans_dict = {} ans = 0 for i in range(1,10): for j in range(1,10): ans_dict[i*10+j]=0 for num in range(1,n+1): num_str = str(num) i = int(num_str[len(num_str)-1]) j = int(num_str[0]) if (i!=0) & (j!=0): ans_dict[i*10+j] +=1 for key_ in ans_dict.keys(): if str(key_)[0] == str(key_)[1]: ans += ans_dict[key_]**2 else: key_s = key_//10+int(str(key_)[1])*10 ans += ans_dict[key_] * ans_dict[key_s] ans_dict[key_s] = 0 print(ans)
import math def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) n = int(input()) ans_dict = {} ans = 0 for i in range(1,10): for j in range(1,10): ans_dict[i*10+j]=0 for num in range(1,n+1): num_str = str(num) i = int(num_str[len(num_str)-1]) j = int(num_str[0]) if (i!=0) & (j!=0): ans_dict[i*10+j] +=1 for key_ in ans_dict.keys(): if str(key_)[0] == str(key_)[1]: ans += ans_dict[key_]**2 else: key_s = key_//10+int(str(key_)[1])*10 ans += ans_dict[key_] * ans_dict[key_s]*2 ans_dict[key_s] = 0 print(ans)
[ "expression.operation.binary.add" ]
598,872
598,871
u214561383
python
p02792
n=int(input()) a=[[0]*10 for i in range(10)] for i in range(1,n+1): a[int(str(i)[0])][i%10]+=1 def N(x,y): # no of x...y < n return a[x][y] ans=0 for x in range(1,10): ans+=N(x,x)*N(x,x) for y in range(x+1,10): ans+=N(x,y,n)*N(y,x,n)*2 print(ans)
n=int(input()) a=[[0]*10 for i in range(10)] for i in range(1,n+1): a[int(str(i)[0])][i%10]+=1 def N(x,y): # no of x...y < n return a[x][y] ans=0 for x in range(1,10): ans+=N(x,x)*N(x,x) for y in range(x+1,10): ans+=N(x,y)*N(y,x)*2 print(ans)
[ "call.arguments.change" ]
598,877
598,878
u623819879
python
p02792
def N(x,y,n): # no of x...y < n if n<100: r=0 for i in range(1,n+1): if str(i)[0]==str(x) and str(i)[-1]==str(y): r+=1 return r r=N(x,y,99) d=len(str(n)) for i in range(1,d-2): r+=10**i top=int(str(n)[0]) if top<x: r+=0 elif top==x: r+=int(str(n)[1:-1]) if str(n)[-1]==str(y): r+=1 else: r+=10**(d-2) return r ans=0 n=int(input()) for x in range(1,10): for y in range(1,10): ans+=N(x,y,n)*N(y,x,n) print(ans)
def N(x,y,n): # no of x...y < n if n<100: r=0 for i in range(1,n+1): if str(i)[0]==str(x) and str(i)[-1]==str(y): r+=1 return r r=N(x,y,99) d=len(str(n)) for i in range(1,d-2): r+=10**i top=int(str(n)[0]) if top<x: r+=0 elif top==x: r+=int(str(n)[1:-1]) if str(n)[-1]>=str(y): r+=1 else: r+=10**(d-2) return r ans=0 n=int(input()) for x in range(1,10): for y in range(1,10): ans+=N(x,y,n)*N(y,x,n) print(ans)
[ "expression.operator.compare.change", "control_flow.branch.if.condition.change" ]
598,879
598,880
u623819879
python
p02792
def main3(N): lst = list() for i in range(1, 10): lst.append([0]*9) for n in range(1, N+1): head = int(str(n)[0]) tail = int(str(n)[-1]) lst[head-1][tail-1] += 1 count = 0 for i in range(0, len(lst)): for j in range(0, len(lst[i])): count += lst[i][j] * lst[j][i] print(count) N = int(input()) main3(N)
def main3(N): lst = list() for i in range(1, 10): lst.append([0]*9) for n in range(1, N+1): head = int(str(n)[0]) tail = int(str(n)[-1]) #末尾が0はNG if tail != 0: lst[head-1][tail-1] += 1 #for i in range(0, len(lst)): # print(lst[i]) count = 0 for i in range(0, len(lst)): for j in range(0, len(lst[i])): count += lst[i][j] * lst[j][i] print(count) N = int(input()) main3(N)
[ "control_flow.branch.if.add" ]
598,883
598,884
u358957649
python
p02792
N = int(input()) def f(n): str_n = str(n) return (str_n[0], str_n[-1]) from collections import Counter c = Counter() for i in range(1, N): p = f(i) c[p] += 1 # for k in sorted(c.keys()): # print(k, c[k]) ans = 0 for i in range(1, N): p = f(i) p_ = (p[1], p[0]) ans += c[p_] print(ans)
N = int(input()) def f(n): str_n = str(n) return (str_n[0], str_n[-1]) from collections import Counter c = Counter() for i in range(1, N+1): p = f(i) c[p] += 1 # for k in sorted(c.keys()): # print(k, c[k]) ans = 0 for i in range(1, N+1): p = f(i) p_ = (p[1], p[0]) ans += c[p_] print(ans)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
598,887
598,888
u002459665
python
p02792
n = int(input()) c = [[0 for i in range(10)] for j in range(10)] for i in range(n): if i % 10 == 0: continue s = str(i) a = int(s[0]) b = int(s[-1]) c[a][b] += 1 ans = 0 for i in range(10): for j in range(10): ans += c[i][j] * c[j][i] print(ans)
n = int(input()) c = [[0 for i in range(10)] for j in range(10)] for i in range(n+1): if i % 10 == 0: continue s = str(i) a = int(s[0]) b = int(s[-1]) c[a][b] += 1 ans = 0 for i in range(10): for j in range(10): ans += c[i][j] * c[j][i] print(ans)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
598,902
598,903
u301984327
python
p02792
N=int(input()) IJ = [[0] * 10 for i in range(10)] ans = 0 for i in range(N): Top = str(i)[0] Btm = str(i)[-1] if Btm == '0': continue IJ[int(Top)][int(Btm)] += 1 for i in range(1, 10): for j in range(1, 10): ans += IJ[i][j] * IJ[j][i] print(ans)
N=int(input()) IJ = [[0] * 10 for i in range(10)] ans = 0 for i in range(1,N+1): Top = str(i)[0] Btm = str(i)[-1] if Btm == '0': continue IJ[int(Top)][int(Btm)] += 1 for i in range(1, 10): for j in range(1, 10): ans += IJ[i][j] * IJ[j][i] print(ans)
[ "call.arguments.add" ]
598,906
598,907
u396961814
python
p02792
N=int(input()) A=[[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9] for n in range(N): temp=str(n) r=int(temp[-1]) l=int(temp[0]) A[r-1][l-1]+=1 ans=0 for i in range(9): for j in range(9): ans+=A[i][j]*A[j][i] if N<=9: print(N) else: print(ans)
N=int(input()) A=[[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9] for n in range(N+1): temp=str(n) r=int(temp[-1]) l=int(temp[0]) A[r-1][l-1]+=1 ans=0 for i in range(9): for j in range(9): ans+=A[i][j]*A[j][i] if N<=9: print(N) else: print(ans)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
598,912
598,913
u794910686
python
p02792
N=int(input()) A=[[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9] for n in range(N): temp=str(n) r=int(temp[-1]) l=int(temp[0]) A[r-1][l-1]+=1 ans=0 for i in range(9): for j in range(9): ans+=A[i][j]*A[j][i] if N==1: print(1) else: print(ans)
N=int(input()) A=[[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9,[0]*9] for n in range(N+1): temp=str(n) r=int(temp[-1]) l=int(temp[0]) A[r-1][l-1]+=1 ans=0 for i in range(9): for j in range(9): ans+=A[i][j]*A[j][i] if N<=9: print(N) else: print(ans)
[ "identifier.replace.add", "literal.replace.remove", "call.arguments.change", "io.output.change" ]
598,914
598,913
u794910686
python
p02792
n = int(input()) ans = 0 def solve(x): df = str(x)[0] dl = str(x)[-1] return df, dl # return df + '-' + dl numMap = {} for i in range(1, n): # print(i) # print(solve(i)) pair = solve(i) if pair in numMap: numMap[pair] += 1 else: numMap[pair] = 1 for i in range(n): key = solve(i) rev = key[::-1] # print('key:', key) # print('rev:', rev) if rev in numMap: ans += numMap[rev] # print(numMap) print(ans)
n = int(input()) ans = 0 def solve(x): df = str(x)[0] dl = str(x)[-1] return df, dl numMap = {} for i in range(1, n+1): # print(i) # print(solve(i)) pair = solve(i) if pair in numMap: numMap[pair] += 1 else: numMap[pair] = 1 for i in range(1, n+1): key = solve(i) rev = key[::-1] # print('key:', key) # print('rev:', rev) if rev in numMap: ans += numMap[rev] # print(numMap) print(ans)
[ "call.arguments.add" ]
598,916
598,917
u600195339
python
p02792
n = int(input()) table = [[0 for i in range(10)] for j in range(10)] for i in range(1, n+1): i = str(i) a, b = i[0], i[-1] table[a][b] += 1 ans = 0 for i in range(10): for j in range(10): ans += table[i][j] * table[j][i] print(ans)
n = int(input()) table = [[0 for i in range(10)] for j in range(10)] for i in range(1, n+1): i = str(i) a, b = int(i[0]), int(i[-1]) table[a][b] += 1 ans = 0 for i in range(10): for j in range(10): ans += table[i][j] * table[j][i] print(ans)
[ "call.add", "call.arguments.change" ]
598,920
598,921
u426108351
python
p02792
N = int(input()) ans = 0 C = [ [0 for i in range(10)] for i in range(10)] for i in range(1,N): first_num = int(str(i)[0]) last_num = int(str(i)[-1]) C[first_num][last_num] += 1 for first_num in range(1,10): for last_num in range(1,10): ans += C[first_num][last_num] * C[last_num][first_num] print(ans)
N = int(input()) ans = 0 C = [ [0 for i in range(10)] for i in range(10)] for i in range(1,N+1): first_num = int(str(i)[0]) last_num = int(str(i)[-1]) C[first_num][last_num] += 1 for first_num in range(1,10): for last_num in range(1,10): ans += C[first_num][last_num] * C[last_num][first_num] print(ans)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
598,922
598,923
u960653324
python
p02792
N = int(input()) ans = 0 C = [ [0 for i in range(10)] for i in range(10)] for i in range(1,N): first_num = int(str(i)[0]) last_num = int(str(i)[-1]) C[first_num][last_num] += 1 for first_num in range(10): for last_num in range(10): ans += C[first_num][last_num] * C[last_num][first_num] print(ans)
N = int(input()) ans = 0 C = [ [0 for i in range(10)] for i in range(10)] for i in range(1,N+1): first_num = int(str(i)[0]) last_num = int(str(i)[-1]) C[first_num][last_num] += 1 for first_num in range(1,10): for last_num in range(1,10): ans += C[first_num][last_num] * C[last_num][first_num] print(ans)
[ "call.arguments.add" ]
598,924
598,923
u960653324
python
p02792
n = int(input()) d = [[0]*10 for _ in range(n)] ans = 0 for i in range(1, n+1): s = str(i) if s[0] == '0' or s[-1] == '0': continue d[int(s[0])][int(s[-1])] += 1 for i in range(1, 10): for j in range(1, 10): ans += d[i][j] * d[j][i] print(ans)
n = int(input()) d = [[0]*10 for _ in range(10)] ans = 0 for i in range(1, n+1): s = str(i) if s[0] == '0' or s[-1] == '0': continue d[int(s[0])][int(s[-1])] += 1 for i in range(1, 10): for j in range(1, 10): ans += d[i][j] * d[j][i] print(ans)
[ "assignment.value.change", "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "control_flow.loop.range.bounds.upper.change" ]
598,927
598,928
u690781906
python
p02792
n=int(input()) tbl=[[0 for j in range(10)] for i in range(10)] for i in range(n): s=str(i) h=int(s[0]) b=int(s[-1]) tbl[h][b]+=1 ans=0 for i in range(10): for j in range(i,10): ans+=tbl[i][j]*tbl[j][i] print(ans)
n=int(input()) tbl=[[0 for j in range(10)] for i in range(10)] for i in range(1,n+1): s=str(i) h=int(s[0]) b=int(s[-1]) tbl[h][b]+=1 ans=0 for i in range(10): for j in range(10): ans+=tbl[i][j]*tbl[j][i] print(ans)
[ "call.arguments.add", "call.arguments.change" ]
598,929
598,930
u202570162
python
p02792
N = int(input()) table = [[0]*10 for i in range(10)] for i in range(1, N): s = str(i) id1 = int(s[0]) id2 = int(s[-1]) table[id1][id2] += 1 ans = 0 for i in range(10): for j in range(10): ans += table[i][j]*table[j][i] print(ans)
N = int(input()) table = [[0]*10 for i in range(10)] for i in range(1, N+1): s = str(i) id1 = int(s[0]) id2 = int(s[-1]) table[id1][id2] += 1 ans = 0 for i in range(10): for j in range(10): ans += table[i][j]*table[j][i] print(ans)
[ "control_flow.loop.range.bounds.upper.change", "expression.operation.binary.add" ]
598,939
598,940
u922449550
python
p02793
import math N = int(input()) A = list(map(int, input().split())) mod = 10**9+7 primes = [0]*(10**3+1) def prime_fac(n): temp = n Flag = True for i in range(2, int(math.sqrt(n)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i primes[i] = max(primes[i], cnt) Flag = False if temp != 1: primes[temp] = max(primes[temp], 1) if Flag: primes[n] = max(primes[n], 1) for a in A: prime_fac(a) LCM = 1 for p, i in enumerate(primes): if i: LCM *= pow(p, i, mod) LCM %= mod ans = 0 for a in A: ans += LCM * pow(a, mod-2, mod) % mod ans %= mod print(ans)
import math N = int(input()) A = list(map(int, input().split())) mod = 10**9+7 primes = [0]*(10**6+1) def prime_fac(n): temp = n Flag = True for i in range(2, int(math.sqrt(n)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i primes[i] = max(primes[i], cnt) Flag = False if temp != 1: primes[temp] = max(primes[temp], 1) if Flag: primes[n] = max(primes[n], 1) for a in A: prime_fac(a) LCM = 1 for p, i in enumerate(primes): if i: LCM *= pow(p, i, mod) LCM %= mod ans = 0 for a in A: ans += LCM * pow(a, mod-2, mod) % mod ans %= mod print(ans)
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change" ]
598,978
598,979
u692453235
python
p02793
import math N = int(input()) A = list(map(int, input().split())) mod = 10**9+7 primes = [0]*(10**3+1) def prime_fac(n): temp = n Flag = True for i in range(2, int(math.sqrt(n)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i primes[i] = max(primes[i], cnt) Flag = False if temp != 1: primes[temp] = max(primes[temp], 1) if Flag: primes[n] = max(primes[n], 1) for a in A: prime_fac(a) LCM = 1 for p, i in enumerate(primes): if p: LCM *= pow(p, i, mod) LCM %= mod ans = 0 for a in A: ans += LCM * pow(a, mod-2, mod) % mod ans %= mod print(ans)
import math N = int(input()) A = list(map(int, input().split())) mod = 10**9+7 primes = [0]*(10**6+1) def prime_fac(n): temp = n Flag = True for i in range(2, int(math.sqrt(n)) + 1): if temp % i == 0: cnt = 0 while temp % i == 0: cnt += 1 temp //= i primes[i] = max(primes[i], cnt) Flag = False if temp != 1: primes[temp] = max(primes[temp], 1) if Flag: primes[n] = max(primes[n], 1) for a in A: prime_fac(a) LCM = 1 for p, i in enumerate(primes): if i: LCM *= pow(p, i, mod) LCM %= mod ans = 0 for a in A: ans += LCM * pow(a, mod-2, mod) % mod ans %= mod print(ans)
[ "literal.number.integer.change", "assignment.value.change", "expression.operation.binary.change", "identifier.change", "control_flow.branch.if.condition.change" ]
598,980
598,979
u692453235
python
p02793
n = int(input()) a = list(map(int,input().split())) so_list = [0 for i in range(10**4)] mod = 10**9+7 def fac(n): temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i if so_list[i]<cnt: so_list[i]= cnt if temp!=1: if so_list[temp]==0: so_list[temp]=1 for i in range(n): a1 = a[i] fac(a1) l = 1 for i in range(len(so_list)): if so_list[i]!=0: l *= pow(i,so_list[i],mod) l %= mod ans = 0 #print(l) for i in a: t = pow(i,mod-2,mod) ans += (l*t)%mod print(ans%mod)
n = int(input()) a = list(map(int,input().split())) so_list = [0 for i in range(10**6)] mod = 10**9+7 def fac(n): temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i if so_list[i]<cnt: so_list[i]= cnt if temp!=1: # print(temp) if so_list[temp]==0: so_list[temp]=1 for i in range(n): a1 = a[i] fac(a1) l = 1 for i in range(len(so_list)): if so_list[i]!=0: l *= pow(i,so_list[i],mod) l %= mod ans = 0 #print(l) for i in a: t = pow(i,mod-2,mod) ans += (l*t)%mod print(ans%mod)
[ "literal.number.integer.change", "assignment.value.change", "call.arguments.change", "expression.operation.binary.change", "control_flow.loop.range.bounds.upper.change" ]
599,006
599,007
u288430479
python
p02793
N = int(input()) *A, = map(int, input().split()) mod = 10**9 + 7 MAX = 1_000_000 def gen_primes(n): n = int(n**0.5) + 2 is_prime = [True]*n is_prime[0] = is_prime[1] = False for i in range(2, n): if is_prime[i]: for j in range(2*i, n, i): is_prime[j] = False return [i for i, flag in enumerate(is_prime) if flag] C = [0]*(MAX+1) primes = gen_primes(MAX) def prime_fact(n): cnt = 0 for p in primes: if n % p: continue while n % p == 0: cnt += 1 n //= p C[p] = max(C[p], cnt) cnt = 0 if n != 1: C[n] = 1 for a in A: prime_fact(a) lcm = 1 for i, c in enumerate(C): if c: lcm = lcm * pow(i, c, mod) % mod print(lcm) ans = 0 for a in A: ans = (ans + lcm * pow(a, mod-2, mod) % mod) % mod print(ans)
N = int(input()) *A, = map(int, input().split()) mod = 10**9 + 7 MAX = 1_000_000 def gen_primes(n): n = int(n**0.5) + 2 is_prime = [True]*n is_prime[0] = is_prime[1] = False for i in range(2, n): if is_prime[i]: for j in range(2*i, n, i): is_prime[j] = False return [i for i, flag in enumerate(is_prime) if flag] C = [0]*(MAX+1) primes = gen_primes(MAX) def prime_fact(n): cnt = 0 for p in primes: if n % p: continue while n % p == 0: cnt += 1 n //= p C[p] = max(C[p], cnt) cnt = 0 if n != 1: C[n] = 1 for a in A: prime_fact(a) lcm = 1 for i, c in enumerate(C): if c: lcm = lcm * pow(i, c, mod) % mod ans = 0 for a in A: ans = (ans + lcm * pow(a, mod-2, mod) % mod) % mod print(ans)
[ "call.remove" ]
599,008
599,009
u223663729
python
p02793
N = int(input()) *A, = map(int, input().split()) mod = 10**9 + 7 MAX = 1_000_000 def gen_primes(n): n = int(n**0.5) + 2 is_prime = [True]*n is_prime[0] = is_prime[1] = False for i in range(2, n): if is_prime[i]: for j in range(2*i, n, i): is_prime[j] = False return [i for i, flag in enumerate(is_prime) if flag] C = [0]*(MAX+1) primes = gen_primes(MAX) def prime_fact(n): cnt = 0 for p in primes: if n % p: continue while n % p == 0: cnt += 1 n //= p C[p] = max(C[p], cnt) cnt = 0 if n != 1: C[p] = 1 for a in A: prime_fact(a) lcm = 1 for i, c in enumerate(C): if c: lcm = lcm * pow(i, c, mod) % mod ans = 0 for a in A: ans = (ans + lcm * pow(a, mod-2, mod) % mod) % mod print(ans)
N = int(input()) *A, = map(int, input().split()) mod = 10**9 + 7 MAX = 1_000_000 def gen_primes(n): n = int(n**0.5) + 2 is_prime = [True]*n is_prime[0] = is_prime[1] = False for i in range(2, n): if is_prime[i]: for j in range(2*i, n, i): is_prime[j] = False return [i for i, flag in enumerate(is_prime) if flag] C = [0]*(MAX+1) primes = gen_primes(MAX) def prime_fact(n): cnt = 0 for p in primes: if n % p: continue while n % p == 0: cnt += 1 n //= p C[p] = max(C[p], cnt) cnt = 0 if n != 1: C[n] = 1 for a in A: prime_fact(a) lcm = 1 for i, c in enumerate(C): if c: lcm = lcm * pow(i, c, mod) % mod ans = 0 for a in A: ans = (ans + lcm * pow(a, mod-2, mod) % mod) % mod print(ans)
[ "assignment.variable.change", "identifier.change", "variable_access.subscript.index.change" ]
599,010
599,009
u223663729
python
p02793
import numpy as np class SieveOfEratosthenes: def __init__(self, V): self.is_prime = np.ones(V + 1, dtype=bool) self.is_prime[4::2] = False self.is_prime[9::3] = False self.is_prime[25::5] = False self.primes = [2, 3, 5] for i in range(7, V + 1, 2): if self.is_prime[i]: self.primes.append(i) if i * i < V + 1: self.is_prime[i * i::i] = False def factorize(self, x): assert x >= 1 if x == 1: return [(1, 1)] result = [] for p in self.primes: exp = 0 while x % p == 0: exp += 1 x = x // p if exp > 0: result.append((p, exp)) if p * p > x: break if x > 1: result.append((x, 1)) return result N = int(input()) M = 10**9 + 7 A = list(map(int, input().split())) sieve = SieveOfEratosthenes(10**3) F = [dict(sieve.factorize(a)) for a in A] lcm = F[0] for i in range(1, len(F)): for p, e in F[i].items(): if p in lcm: lcm[p] = max(lcm[p], e) else: lcm[p] = e val = 1 for p, e in lcm.items(): val = val * pow(p, e, M) % M print(val) B = [val * pow(a, M - 2, M) % M for a in A] print(sum(B) % M)
import numpy as np class SieveOfEratosthenes: def __init__(self, V): self.is_prime = np.ones(V + 1, dtype=bool) self.is_prime[4::2] = False self.is_prime[9::3] = False self.is_prime[25::5] = False self.primes = [2, 3, 5] for i in range(7, V + 1, 2): if self.is_prime[i]: self.primes.append(i) if i * i < V + 1: self.is_prime[i * i::i] = False def factorize(self, x): assert x >= 1 if x == 1: return [(1, 1)] result = [] for p in self.primes: exp = 0 while x % p == 0: exp += 1 x = x // p if exp > 0: result.append((p, exp)) if p * p > x: break if x > 1: result.append((x, 1)) return result N = int(input()) M = 10**9 + 7 A = list(map(int, input().split())) sieve = SieveOfEratosthenes(10**3) F = [dict(sieve.factorize(a)) for a in A] lcm = F[0] for i in range(1, len(F)): for p, e in F[i].items(): if p in lcm: lcm[p] = max(lcm[p], e) else: lcm[p] = e val = 1 for p, e in lcm.items(): val = val * pow(p, e, M) % M # print(val) B = [val * pow(a, M - 2, M) % M for a in A] print(sum(B) % M)
[ "call.remove" ]
599,011
599,012
u019685451
python
p02793
#!/usr/bin/env python3 from math import gcd N = input() A = list(map(int, input().split(" "))) def lcm(x, y): return (x * y) // gcd(x, y) tmp = 1 for i in A: tmp = lcm(tmp, i) print(int(sum([tmp / i for i in A]) % (10**9 + 7)))
#!/usr/bin/env python3 from math import gcd N = input() A = list(map(int, input().split(" "))) def lcm(x, y): return (x * y) // gcd(x, y) tmp = 1 for i in A: tmp = lcm(tmp, i) print(sum([tmp // i for i in A]) % (10**9 + 7))
[ "call.arguments.change", "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
599,112
599,113
u665598835
python
p02793
from math import gcd def lcm(a, b): return a * b / gcd(a, b) MOD = 10 ** 9 + 7 N = int(input()) A = list(map(int, input().split())) _lcm = 1 for a in A: # _lcm = lcm(_lcm, a) _lcm = _lcm * a / gcd(_lcm, a) ans = _lcm * sum([pow(s, MOD - 2, MOD) for s in A]) % MOD print(int(ans % MOD))
from math import gcd def lcm(a, b): return a * b // gcd(a, b) MOD = 10 ** 9 + 7 N = int(input()) A = list(map(int, input().split())) _lcm = 1 for a in A: _lcm = lcm(_lcm, a) ans = _lcm * sum([pow(s, MOD - 2, MOD) for s in A]) % MOD print(int(ans % MOD))
[ "expression.operator.arithmetic.change", "function.return_value.change", "expression.operation.binary.change", "assignment.value.change", "expression.operation.binary.remove" ]
599,116
599,117
u970308980
python
p02793
from math import gcd def lcm(a, b): return a * b / gcd(a, b) MOD = 10 ** 9 + 7 N = int(input()) A = list(map(int, input().split())) _lcm = 1 for a in A: _lcm = lcm(_lcm, a) ans = _lcm * sum([pow(s, MOD - 2, MOD) for s in A]) % MOD print(int(ans % MOD))
from math import gcd def lcm(a, b): return a * b // gcd(a, b) MOD = 10 ** 9 + 7 N = int(input()) A = list(map(int, input().split())) _lcm = 1 for a in A: _lcm = lcm(_lcm, a) ans = _lcm * sum([pow(s, MOD - 2, MOD) for s in A]) % MOD print(int(ans % MOD))
[ "expression.operator.arithmetic.change", "function.return_value.change", "expression.operation.binary.change" ]
599,118
599,117
u970308980
python
p02793
from math import gcd def lcm(a, b): return a * b / gcd(a, b) MOD = 10 ** 9 + 7 N = int(input()) A = list(map(int, input().split())) _lcm = 1 for a in A: # _lcm = lcm(_lcm, a) _lcm = _lcm * a / gcd(_lcm, a) ans = _lcm * sum([pow(s, MOD - 2, MOD) for s in A]) % MOD print(int(ans % MOD))
from math import gcd def lcm(a, b): return a * b / gcd(a, b) MOD = 10 ** 9 + 7 N = int(input()) A = list(map(int, input().split())) _lcm = 1 for a in A: # _lcm = lcm(_lcm, a) _lcm = _lcm * a // gcd(_lcm, a) ans = _lcm * sum([pow(s, MOD - 2, MOD) for s in A]) % MOD print(int(ans % MOD))
[ "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change" ]
599,116
599,119
u970308980
python
p02793
from math import gcd def lcm(a, b): return a * b / gcd(a, b) MOD = 10 ** 9 + 7 N = int(input()) A = list(map(int, input().split())) _lcm = 1 for a in A: _lcm = lcm(_lcm, a) ans = _lcm * sum([pow(s, MOD - 2, MOD) for s in A]) % MOD print(int(ans % MOD))
from math import gcd def lcm(a, b): return a * b / gcd(a, b) MOD = 10 ** 9 + 7 N = int(input()) A = list(map(int, input().split())) _lcm = 1 for a in A: # _lcm = lcm(_lcm, a) _lcm = _lcm * a // gcd(_lcm, a) ans = _lcm * sum([pow(s, MOD - 2, MOD) for s in A]) % MOD print(int(ans % MOD))
[ "assignment.value.change" ]
599,118
599,119
u970308980
python
p02793
mod=10**9+7 n=int(input()) a=list(map(int,input().split())) def gcd(m, n): while n: m, n = n, m % n return m def lcm(a,b): return a*b//gcd(a,b) L=1 for i in range(n): L = lcm(l, a[i]) ans = 0 L %= mod for i in range(n): ans += l * pow(a[i], mod - 2, mod) ans %= mod print(ans)
mod=10**9+7 n=int(input()) a=list(map(int,input().split())) def gcd(m, n): while n: m, n = n, m % n return m def lcm(a,b): return a*b//gcd(a,b) L = 1 for i in range(n): L = lcm(L, a[i]) ans = 0 L %= mod for i in range(n): ans += L * pow(a[i], mod - 2, mod) ans %= mod print(ans)
[ "assignment.value.change", "identifier.change", "call.arguments.change", "expression.operation.binary.change" ]
599,134
599,135
u532573979
python
p02793
import math n=int(input()) a=[int(i) for i in input().split()] g=1 dx=math.gcd for i in a: g*=i//dx(g,i) suml=0 mod=10**9+7 print(g) for i in a: suml+=g*pow(i,mod-2,mod) suml%=mod print(suml)
import math n=int(input()) a=[int(i) for i in input().split()] g=1 dx=math.gcd for i in a: g*=i//dx(g,i) suml=0 mod=10**9+7 for i in a: suml+=g*pow(i,mod-2,mod) suml%=mod print(suml)
[ "call.remove" ]
599,172
599,173
u547167033
python
p02793
import math N = int(input()) a = list(map(int,input().split())) lcm = a[0] for i in range(1,N): lcm = lcm*a[i]//math.gcd(lcm,a[i]) print(lcm) b = [0]*N ans = 0 for i in range(N): ans += lcm//a[i] print(int(ans%(10**9+7)))
import math N = int(input()) a = list(map(int,input().split())) lcm = a[0] for i in range(1,N): lcm = lcm*a[i]//math.gcd(lcm,a[i]) b = [0]*N ans = 0 for i in range(N): ans += lcm//a[i] print(int(ans%(10**9+7)))
[ "call.remove" ]
599,176
599,177
u444732068
python
p02793
import math N = int(input()) a = list(map(int,input().split())) lcm = a[0] for i in range(1,N): lcm = lcm*a[i]//math.gcd(lcm,a[i]) b = [0]*N ans = 0 for i in range(N): ans += lcm/a[i] print(int(ans%(10**9+7)))
import math N = int(input()) a = list(map(int,input().split())) lcm = a[0] for i in range(1,N): lcm = lcm*a[i]//math.gcd(lcm,a[i]) b = [0]*N ans = 0 for i in range(N): ans += lcm//a[i] print(int(ans%(10**9+7)))
[ "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
599,178
599,177
u444732068
python
p02793
import fractions N = int(input()) a = list(map(int,input().split())) lcm = a[0] for i in range(1,N): lcm = lcm*a[i]//math.fractions(lcm,a[i]) b = [0]*N ans = 0 for i in range(N): ans += lcm/a[i] print(int(ans%(10**9+7)))
import math N = int(input()) a = list(map(int,input().split())) lcm = a[0] for i in range(1,N): lcm = lcm*a[i]//math.gcd(lcm,a[i]) b = [0]*N ans = 0 for i in range(N): ans += lcm//a[i] print(int(ans%(10**9+7)))
[ "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
599,179
599,177
u444732068
python
p02793
import math N = int(input()) a = list(map(int,input().split())) lcm = a[0] for i in range(1,N): lcm = lcm*a[i]//math.gcd(lcm,a[i]) b = [0]*N ans = 0 for i in range(N): ans += lcm/a[i] print(int(ans%(10**9+7)))
import math N = int(input()) a = list(map(int,input().split())) lcm = a[0] for i in range(1,N): lcm = lcm*a[i]//math.gcd(lcm,a[i]) b = [0]*N ans = 0 for i in range(N): ans += lcm//a[i] print(int(ans%(10**9+7)))
[ "identifier.change", "assignment.value.change", "expression.operation.binary.change", "expression.operator.arithmetic.change" ]
599,180
599,177
u444732068
python
p02793
import math N = int(input()) A_list = list(map(int, input().split())) mod = 10**9+7 R = 1 # 最小公倍数 # 最小公倍数を求める for A in A_list: R *= A // math.gcd(R, A) # Bの合計を求める ans = 0 for A in A_list: ans = ans + R // A # 計算は小数として出してはダメだから//を使う ans %= mod+7 print(ans)
import math N = int(input()) A_list = list(map(int, input().split())) mod = 10**9+7 R = 1 # 最小公倍数 # 最小公倍数を求める for A in A_list: R *= A // math.gcd(R, A) # Bの合計を求める ans = 0 for A in A_list: ans = ans + R // A # 計算は小数として出してはダメだから//を使う ans %= mod print(ans)
[ "expression.operation.binary.remove" ]
599,189
599,190
u368249389
python
p02793
import sys input = sys.stdin.readline def pow_mod(x, n): if n == 0: return 1 K = 1 while n > 1: if n % 2 != 0: K *= x K %= mod x *= x x %= mod n //= 2 return K*x #main関数 def main(): """"ここに今までのコード""" N = int(input()) A = list(map(int, input().split())) mod = 10**9+7 plist = [0]*1000 lcm = 1 nokori=set() for a in A: for j in range(2, 1001): count_j=0 while a % j == 0: count_j += 1 a //= j plist[j-1]=max(plist[j-1],count_j) nokori |= {a} for x in nokori: lcm *= x lcm %= mod for i in range(1000): lcm *= pow_mod(i+1, plist[i], mod) lcm %= mod ans = 0 for a in A: ans += lcm * pow_mod(a, mod-2, mod) ans %= mod print(ans) if __name__ == '__main__': main()
import sys input = sys.stdin.readline def pow_mod(x, n, mod): if n == 0: return 1 K = 1 while n > 1: if n % 2 != 0: K *= x K %= mod x *= x x %= mod n //= 2 return K*x #main関数 def main(): """"ここに今までのコード""" N = int(input()) A = list(map(int, input().split())) mod = 10**9+7 plist = [0]*1000 lcm = 1 nokori=set() for a in A: for j in range(2, 1001): count_j=0 while a % j == 0: count_j += 1 a //= j plist[j-1]=max(plist[j-1],count_j) nokori |= {a} for x in nokori: lcm *= x lcm %= mod for i in range(1000): lcm *= pow_mod(i+1, plist[i], mod) lcm %= mod ans = 0 for a in A: ans += lcm * pow_mod(a, mod-2, mod) ans %= mod print(ans) if __name__ == '__main__': main()
[]
599,193
599,194
u667135132
python
p02793
# from math import gcd from fraction import gcd n = int(input()) a = list(map(int,input().split())) ans = 1 for i in a: ans = ans * i // gcd(ans, i) mod = 10**9+7 print(sum(map(lambda x: ans // x, a)) % mod)
# from math import gcd from math import gcd n = int(input()) a = list(map(int,input().split())) ans = 1 for i in a: ans = ans * i // gcd(ans, i) mod = 10**9+7 print(sum(map(lambda x: ans // x, a)) % mod)
[ "identifier.change" ]
599,195
599,196
u743272507
python
p02793
MOD = (10**9) + 7 class modint(): def __init__(self, value): self.value = value % MOD def __int__(self): return int(self.value) def __float__(self): return float(self.value) def __str__(self): return str(self.value) def __repr__(self): return str(self.value) def __add__(self, other): return (modint(self.value + other.value) if isinstance(other, modint) else modint(self.value + other)) def __sub__(self, other): return (modint(self.value - other.value) if isinstance(other, modint) else modint(self.value - other)) def __mul__(self, other): return (modint(self.value * other.value) if isinstance(other, modint) else modint(self.value * other)) def __truediv__(self, other): return (modint(self.value * pow(other.value, MOD - 2, MOD)) if isinstance(other, modint) else modint(self.value * pow(other, MOD - 2, MOD))) def __pow__(self, other): return (modint(pow(self.value, other.value, MOD)) if isinstance(other, modint) else modint(pow(self.value, other, MOD))) def __eq__(self, other): return (self.value == other.value if isinstance(other, modint) else self.value == (other % MOD)) def __ne__(self, other): return (self.value == other.value if isinstance(other, modint) else self.value == (other % MOD)) def __radd__(self, other): return (modint(other.value + self.value) if isinstance(other, modint) else modint(other + self.value)) def __rsub__(self, other): return (modint(other.value - self.value) if isinstance(other, modint) else modint(other - self.value)) def __rmul__(self, other): return (modint(other.value * self.value) if isinstance(other, modint) else modint(other * self.value)) def __rtruediv__(self, other): return (modint(other.value * pow(self.value, MOD - 2, MOD)) if isinstance(other, modint) else modint(other * pow(self.value, MOD - 2, MOD))) def __rpow__(self, other): return (modint(pow(other.value, self.value, MOD)) if isinstance(other, modint) else modint(pow(other, self.value, MOD))) def modinv(self): return modint(pow(self.value, MOD - 2, MOD)) def gcd(x, y): if y == 0: return x while y != 0: x, y = y, x % y return x def lcm(x, y): return x*y//gcd(x, y) def main(): N = int(input()) A = [int(i) for i in input().split()] k = A[0] for a in A[1:]: k *= a//gcd(k, a) k = modint(k) ans = modint(0) for a in A: ans += k//a print(ans) if __name__ == '__main__': main()
MOD = (10**9) + 7 class modint(): def __init__(self, value): self.value = value % MOD def __int__(self): return int(self.value) def __float__(self): return float(self.value) def __str__(self): return str(self.value) def __repr__(self): return str(self.value) def __add__(self, other): return (modint(self.value + other.value) if isinstance(other, modint) else modint(self.value + other)) def __sub__(self, other): return (modint(self.value - other.value) if isinstance(other, modint) else modint(self.value - other)) def __mul__(self, other): return (modint(self.value * other.value) if isinstance(other, modint) else modint(self.value * other)) def __truediv__(self, other): return (modint(self.value * pow(other.value, MOD - 2, MOD)) if isinstance(other, modint) else modint(self.value * pow(other, MOD - 2, MOD))) def __pow__(self, other): return (modint(pow(self.value, other.value, MOD)) if isinstance(other, modint) else modint(pow(self.value, other, MOD))) def __eq__(self, other): return (self.value == other.value if isinstance(other, modint) else self.value == (other % MOD)) def __ne__(self, other): return (self.value == other.value if isinstance(other, modint) else self.value == (other % MOD)) def __radd__(self, other): return (modint(other.value + self.value) if isinstance(other, modint) else modint(other + self.value)) def __rsub__(self, other): return (modint(other.value - self.value) if isinstance(other, modint) else modint(other - self.value)) def __rmul__(self, other): return (modint(other.value * self.value) if isinstance(other, modint) else modint(other * self.value)) def __rtruediv__(self, other): return (modint(other.value * pow(self.value, MOD - 2, MOD)) if isinstance(other, modint) else modint(other * pow(self.value, MOD - 2, MOD))) def __rpow__(self, other): return (modint(pow(other.value, self.value, MOD)) if isinstance(other, modint) else modint(pow(other, self.value, MOD))) def modinv(self): return modint(pow(self.value, MOD - 2, MOD)) def gcd(x, y): if y == 0: return x while y != 0: x, y = y, x % y return x def lcm(x, y): return x*y//gcd(x, y) def main(): N = int(input()) A = [int(i) for i in input().split()] k = A[0] for a in A[1:]: k = lcm(k, a) k = modint(k) ans = modint(0) for a in A: ans += k/a print(ans) if __name__ == '__main__': main()
[ "expression.operation.binary.remove", "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
599,212
599,213
u312025627
python
p02793
MOD = (10**9) + 7 class modint(): def __init__(self, value): self.value = value % MOD def __int__(self): return int(self.value) def __float__(self): return float(self.value) def __str__(self): return str(self.value) def __repr__(self): return str(self.value) def __add__(self, other): return (modint(self.value + other.value) if isinstance(other, modint) else modint(self.value + other)) def __sub__(self, other): return (modint(self.value - other.value) if isinstance(other, modint) else modint(self.value - other)) def __mul__(self, other): return (modint(self.value * other.value) if isinstance(other, modint) else modint(self.value * other)) def __truediv__(self, other): return (modint(self.value * pow(other.value, MOD - 2, MOD)) if isinstance(other, modint) else modint(self.value * pow(other, MOD - 2, MOD))) def __pow__(self, other): return (modint(pow(self.value, other.value, MOD)) if isinstance(other, modint) else modint(pow(self.value, other, MOD))) def __eq__(self, other): return (self.value == other.value if isinstance(other, modint) else self.value == (other % MOD)) def __ne__(self, other): return (self.value == other.value if isinstance(other, modint) else self.value == (other % MOD)) def __radd__(self, other): return (modint(other.value + self.value) if isinstance(other, modint) else modint(other + self.value)) def __rsub__(self, other): return (modint(other.value - self.value) if isinstance(other, modint) else modint(other - self.value)) def __rmul__(self, other): return (modint(other.value * self.value) if isinstance(other, modint) else modint(other * self.value)) def __rtruediv__(self, other): return (modint(other.value * pow(self.value, MOD - 2, MOD)) if isinstance(other, modint) else modint(other * pow(self.value, MOD - 2, MOD))) def __rpow__(self, other): return (modint(pow(other.value, self.value, MOD)) if isinstance(other, modint) else modint(pow(other, self.value, MOD))) def modinv(self): return modint(pow(self.value, MOD - 2, MOD)) def gcd(x, y): if y == 0: return x while y != 0: x, y = y, x % y return x def lcm(x, y): return x*y//gcd(x, y) def main(): N = int(input()) A = [int(i) for i in input().split()] k = A[0] for a in A[1:]: k *= a//gcd(k, a) k = modint(k) ans = modint(0) for a in A: ans += k//a print(ans) if __name__ == '__main__': main()
MOD = (10**9) + 7 class modint(): def __init__(self, value): self.value = value % MOD def __int__(self): return int(self.value) def __float__(self): return float(self.value) def __str__(self): return str(self.value) def __repr__(self): return str(self.value) def __add__(self, other): return (modint(self.value + other.value) if isinstance(other, modint) else modint(self.value + other)) def __sub__(self, other): return (modint(self.value - other.value) if isinstance(other, modint) else modint(self.value - other)) def __mul__(self, other): return (modint(self.value * other.value) if isinstance(other, modint) else modint(self.value * other)) def __truediv__(self, other): return (modint(self.value * pow(other.value, MOD - 2, MOD)) if isinstance(other, modint) else modint(self.value * pow(other, MOD - 2, MOD))) def __pow__(self, other): return (modint(pow(self.value, other.value, MOD)) if isinstance(other, modint) else modint(pow(self.value, other, MOD))) def __eq__(self, other): return (self.value == other.value if isinstance(other, modint) else self.value == (other % MOD)) def __ne__(self, other): return (self.value == other.value if isinstance(other, modint) else self.value == (other % MOD)) def __radd__(self, other): return (modint(other.value + self.value) if isinstance(other, modint) else modint(other + self.value)) def __rsub__(self, other): return (modint(other.value - self.value) if isinstance(other, modint) else modint(other - self.value)) def __rmul__(self, other): return (modint(other.value * self.value) if isinstance(other, modint) else modint(other * self.value)) def __rtruediv__(self, other): return (modint(other.value * pow(self.value, MOD - 2, MOD)) if isinstance(other, modint) else modint(other * pow(self.value, MOD - 2, MOD))) def __rpow__(self, other): return (modint(pow(other.value, self.value, MOD)) if isinstance(other, modint) else modint(pow(other, self.value, MOD))) def modinv(self): return modint(pow(self.value, MOD - 2, MOD)) def gcd(x, y): if y == 0: return x while y != 0: x, y = y, x % y return x def lcm(x, y): return x*y//gcd(x, y) def main(): N = int(input()) A = [int(i) for i in input().split()] k = A[0] for a in A[1:]: k *= a//gcd(k, a) k = modint(k) ans = modint(0) for a in A: ans += k/a print(ans) if __name__ == '__main__': main()
[ "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
599,212
599,214
u312025627
python
p02793
def s(): from sys import stdin read=stdin.buffer.readline n=int(read()) l=list(map(int,read().split())) f=l[0] mod=10**9+7 def gcd(s,d): s,d=max(s,d),min(s,d) while d: s,d=d,s%d return s for i in l: f=i*f//gcd(i,f) ans=0 for iu in l: b,u,v=mod,1,0 while b: t=x//b;x,b=b,x%b;u-=t*v;u,v=v,u ans+=(f*u%mod)%mod ans%=mod print(ans) if __name__=="__main__":s()
def s(): from sys import stdin read=stdin.buffer.readline n=int(read()) l=list(map(int,read().split())) f=l[0] mod=10**9+7 def gcd(s,d): s,d=max(s,d),min(s,d) while d: s,d=d,s%d return s for i in l: f=i*f//gcd(i,f) ans=0 for iu in l: b,u,v=mod,1,0 while b: t=iu//b;iu,b=b,iu%b;u-=t*v;u,v=v,u ans+=(f*u%mod)%mod ans%=mod print(ans) if __name__=="__main__":s()
[ "assignment.value.change", "identifier.change", "expression.operation.binary.change", "assignment.variable.change" ]
599,219
599,220
u896741788
python
p02793
from math import gcd MOD = 10**9+7 N = int(input()) A = list(map(int, input().split())) now = A[0] ans = 0 for i in range(1,N): now = now//gcd(now, A[i])*A[i] for i in range(N): ans += now//A[i] print(ans)
from math import gcd MOD = 10**9+7 N = int(input()) A = list(map(int, input().split())) now = A[0] ans = 0 for i in range(1,N): now = now//gcd(now, A[i])*A[i] for i in range(N): ans += now//A[i] print(ans%MOD)
[ "expression.operation.binary.add" ]
599,230
599,231
u924691798
python
p02793
from collections import defaultdict primes=[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,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009] n=int(input()) a=list(map(int,input().split())) mod = 10**9+7 factors=defaultdict(lambda: 0) for i in a: lfactors=defaultdict(lambda: 0) for prime in primes: if prime>i: lfactors[i]+=1 break while i%prime==0: i=i//prime lfactors[prime]+=1 for key,value in zip(lfactors.keys(),lfactors.values()): factors[key]=max(factors[key],value) ans=1 for fact,p in zip(factors.keys(),factors.values()): ans=(ans*pow(fact,p))%mod print(sum([(ans*pow(i,mod-2,mod))%mod for i in a])%mod)
from collections import defaultdict primes=[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,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997,1009,10**7] n=int(input()) a=list(map(int,input().split())) mod = 10**9+7 factors=defaultdict(lambda: 0) for i in a: lfactors=defaultdict(lambda: 0) for prime in primes: if prime>i: lfactors[i]+=1 break while i%prime==0: i=i//prime lfactors[prime]+=1 for key,value in zip(lfactors.keys(),lfactors.values()): factors[key]=max(factors[key],value) ans=1 for fact,p in zip(factors.keys(),factors.values()): ans=(ans*pow(fact,p))%mod print(sum([(ans*pow(i,mod-2,mod))%mod for i in a])%mod)
[]
599,236
599,237
u211706121
python
p02793
from math import gcd n=int(input()) a=list(map(int,input().split())) b=1 for i in a: b=gcd(b,i) ans=0 for i in a: ans+=(b//i) print(ans%(10**9+7))
from math import gcd n=int(input()) a=list(map(int,input().split())) b=1 for i in a: b=b//gcd(b,i)*i ans=0 for i in a: ans+=(b//i) print(ans%(10**9+7))
[ "assignment.change" ]
599,244
599,245
u813174766
python
p02793
from fraction import gcd n=int(input()) a=list(map(int,input().split())) b=1 for i in a: b=gcd(b,i) ans=0 for i in a: ans+=(b//i) print(ans%(10**9+7))
from math import gcd n=int(input()) a=list(map(int,input().split())) b=1 for i in a: b=b//gcd(b,i)*i ans=0 for i in a: ans+=(b//i) print(ans%(10**9+7))
[ "identifier.change" ]
599,246
599,245
u813174766
python
p02793
import sys input = sys.stdin.buffer.readline import math from functools import reduce def main(): N = int(input()) a = list(map(int,input().split())) MOD = 10**9+7 def lcm(x,y): return((x*y)//math.gcd(x,y)) l = reduce(lcm,a) ans = 0 for num in a: ans += l//num print(ans) if __name__ == "__main__": main()
import sys input = sys.stdin.buffer.readline import math from functools import reduce def main(): N = int(input()) a = list(map(int,input().split())) MOD = 10**9+7 def lcm(x,y): return((x*y)//math.gcd(x,y)) l = reduce(lcm,a) ans = 0 for num in a: ans += l//num print(ans%MOD) if __name__ == "__main__": main()
[ "expression.operation.binary.add" ]
599,251
599,252
u648212584
python
p02793
from math import gcd n = int(input()) a = list(map(int, input().split())) max_a = max(a) mod = 10**9 + 7 inverse = [1] * (max_a + 1) for i in range(2, max_a + 1): inverse[i] = -inverse[i % mod] * (mod // i) % mod lcm = 1 for i in range(n): lcm = lcm * a[i] // gcd(lcm, a[i]) lcm %= mod sum_b = 0 for i in range(n): sum_b = (sum_b + lcm * inverse[a[i]]) % mod print(sum_b)
from math import gcd n = int(input()) a = list(map(int, input().split())) max_a = max(a) mod = 10**9 + 7 inverse = [1] * (max_a + 1) for i in range(2, max_a + 1): inverse[i] = -inverse[mod % i] * (mod // i) % mod lcm = 1 for i in range(n): lcm = lcm * a[i] // gcd(lcm, a[i]) lcm %= mod sum_b = 0 for i in range(n): sum_b = (sum_b + lcm * inverse[a[i]]) % mod print(sum_b)
[ "expression.operation.binary.remove" ]
599,273
599,274
u686230543
python
p02793
#!/usr/bin/env python3 import sys from functools import reduce import math MOD = 1000000007 # type: int GCD_CACHE = {} def gcd(x, y): if (x, y) in GCD_CACHE: return GCD_CACHE[(x, y)] d = math.gcd(x, y) GCD_CACHE[(x, y)] = d return d def lcm_base(x, y): return (x * y) // gcd(x, y) % MOD def lcm(*numbers): return reduce(lcm_base, numbers, 1) def solve(N: int, A: "List[int]"): m = lcm(*A) sum = 0 for a in A: sum = (sum + m*pow(a, MOD-2, MOD)) % MOD print(sum) return # Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int A = [int(next(tokens)) for _ in range(N)] # type: "List[int]" solve(N, A) if __name__ == '__main__': main()
#!/usr/bin/env python3 import sys from functools import reduce import math MOD = 1000000007 # type: int GCD_CACHE = {} def gcd(x, y): if (x, y) in GCD_CACHE: return GCD_CACHE[(x, y)] d = math.gcd(x, y) GCD_CACHE[(x, y)] = d return d def lcm_base(x, y): return (x * y) // gcd(x, y) def lcm(*numbers): return reduce(lcm_base, numbers, 1) def solve(N: int, A: "List[int]"): m = lcm(*A) % MOD sum = 0 for a in A: sum = (sum + m*pow(a, MOD-2, MOD)) % MOD print(sum) return # Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int A = [int(next(tokens)) for _ in range(N)] # type: "List[int]" solve(N, A) if __name__ == '__main__': main()
[ "expression.operation.binary.remove" ]
599,298
599,297
u873927631
python
p02793
mod = 10**9 + 7 def iip(listed = False): ret = [int(i) for i in input().split()] if len(ret) == 1 and not listed: return ret[0] return ret def inv(n, mod): return power(n, mod-2) def power(n, p): if p == 0: return 1 if p % 2 == 0: return (power(n, p//2) ** 2) % mod if p % 2 == 1: return (n * power(n, p-1)) % mod def soinsuu_bunkai(n): ret = [] for i in range(2, int(n**0.5)+1): while n % i == 0: n //= i ret.append(i) if i > n: break if n != 1: ret.append(n) return ret n = iip() A = iip() def main(): ss = [] for a_i in A: for s in ss: if a_i % s == 0: a_i //= s ss.extend(soinsuu_bunkai(a_i)) #print(ss) all = 1 for s in ss: all *= s all %= mod ans = 0 for a_i in A: ans += (all * inv(a_i, mod)) % mod ans %= mod print(ans) main()
mod = 10**9 + 7 def iip(listed = False): ret = [int(i) for i in input().split()] if len(ret) == 1 and not listed: return ret[0] return ret def inv(n, mod): return power(n, mod-2) def power(n, p): if p == 0: return 1 if p % 2 == 0: return (power(n, p//2) ** 2) % mod if p % 2 == 1: return (n * power(n, p-1)) % mod def soinsuu_bunkai(n): ret = [] for i in range(2, int(n**0.5)+1): while n % i == 0: n //= i ret.append(i) if i > n: break if n != 1: ret.append(n) return ret n = iip() A = iip(listed=True) def main(): ss = [] for a_i in A: for s in ss: if a_i % s == 0: a_i //= s ss.extend(soinsuu_bunkai(a_i)) #print(ss) all = 1 for s in ss: all *= s all %= mod ans = 0 for a_i in A: ans += (all * inv(a_i, mod)) % mod ans %= mod print(ans) main()
[ "call.arguments.keyword_argument.add" ]
599,315
599,316
u946996108
python
p02793
import sys from math import gcd sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def lcm(a, b): return a * b // gcd(a, b) def resolve(): n = int(input()) A = list(map(int, input().split())) L = 1 for a in A: L = lcm(L, a) L %= mod res = 0 for a in A: res += L * pow(a, mod - 2, mod) res %= mod print(res) if __name__ == '__main__': resolve()
import sys from math import gcd sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def lcm(a, b): return a * b // gcd(a, b) def resolve(): n = int(input()) A = list(map(int, input().split())) L = 1 for a in A: L = lcm(L, a) res = 0 for a in A: res += L * pow(a, mod - 2, mod) res %= mod print(res) if __name__ == '__main__': resolve()
[]
599,329
599,330
u489959379
python
p02793
from functools import reduce from math import gcd MOD = 10 ** 9 + 7 _ = int(input()) la = list(map(int, input().split())) def inv(a): return pow(a, MOD - 2, MOD) def lcm(a, b): return (a * b // gcd(a, b)) def addmod(a, b): return (a + b) % MOD l = reduce(lcm, la) % MOD answer = reduce(addmod, (l * inv(a) for a in la)) print(answer)
from functools import reduce from math import gcd MOD = 10 ** 9 + 7 _ = int(input()) la = list(map(int, input().split())) def inv(a): return pow(a, MOD - 2, MOD) def lcm(a, b): return a * b // gcd(a, b) def addmod(a, b): return (a + b) % MOD l = reduce(lcm, la) % MOD answer = reduce(addmod, (l * inv(a) for a in la), 0) print(answer)
[ "call.arguments.change", "call.arguments.add" ]
599,339
599,340
u439542873
python
p02793
import math def lcm(x, y): return (x * y) // math.gcd(x, y) MOD = 1000000007 N = int(input()) A = list(map(int, input().split())) lcm_ = 1 for a in A: lcm_ = lcm(lcm_, a) ans = 0 for a in A: ans += lcm_ / a ans %= MOD print(int(ans))
import math def lcm(x, y): return (x * y) // math.gcd(x, y) MOD = 1000000007 N = int(input()) A = list(map(int, input().split())) lcm_ = 1 for a in A: lcm_ = lcm(lcm_, a) ans = 0 for a in A: ans += lcm_ // a ans %= MOD print(ans)
[ "expression.operator.arithmetic.change", "expression.operation.binary.change", "call.remove", "call.arguments.change" ]
599,351
599,352
u736788838
python
p02793
import math # import math as fractions mod = 10**9+7 n = int(input()) a = list(map(int, input().split())) if n == 1: print(a[0]) exit() g = math.gcd(a[0], a[1]) f = a[0]*a[1]//g ans = a[0]//g+a[1]//g for i in range(2, n): # print(ans, g, f) h = math.gcd(f, a[i]) g = a[i] // h f = f*a[i]// h ans *= g ans += f // a[i] ans %= mod print(ans%mod)
import math # import math as fractions mod = 10**9+7 n = int(input()) a = list(map(int, input().split())) if n == 1: print(1) exit() g = math.gcd(a[0], a[1]) # 最大公約数 f = a[0]*a[1]//g # 最小公倍数 ans = a[0]//g+a[1]//g for i in range(2, n): # print(ans, g, f) h = math.gcd(f, a[i]) g = a[i] // h f = f*a[i]// h ans *= g ans += f // a[i] ans %= mod print(ans%mod)
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "io.output.change" ]
599,364
599,365
u940831163
python
p02793
import math # import math as fractions mod = 10**9+7 n = int(input()) a = list(map(int, input().split())) if n == 1: print(a[0]) exit() g = math.gcd(a[0], a[1]) f = a[0]*a[1]//g ans = a[0]//g+a[1]//g for i in range(2, n): # print(ans, g, f) h = math.gcd(f, a[i]) g = a[i] // h f = f*a[i]// h ans *= g ans += f // a[i] ans %= mod print(ans%mod)
import math # import math as fractions mod = 10**9+7 n = int(input()) a = list(map(int, input().split())) if n == 1: print(1) exit() g = math.gcd(a[0], a[1]) f = a[0]*a[1]//g ans = a[0]//g+a[1]//g for i in range(2, n): # print(ans, g, f) h = math.gcd(f, a[i]) g = a[i] // h f = f*a[i]// h ans *= g ans += f // a[i] ans %= mod print(ans%mod)
[ "identifier.replace.remove", "literal.replace.add", "call.arguments.change", "io.output.change" ]
599,364
599,366
u940831163
python
p02793
from math import gcd def lcm(x,y): return (x*y) // gcd(x,y) n = int(input()) a = list(map(int,input().split())) mod = 10**9+7 l = a[0] for i in range(1,n): l = lcm(l,a[i]) for i in range(n): ans += l//a[i] print(ans%mod)
from math import gcd def lcm(x,y): return (x*y) // gcd(x,y) n = int(input()) a = list(map(int,input().split())) mod = 10**9+7 l = a[0] for i in range(1,n): l = lcm(l,a[i]) ans = 0 for i in range(n): ans += l//a[i] print(ans%mod)
[ "assignment.add" ]
599,394
599,395
u948911484
python
p02793
import sys from collections import Counter def prime_factorize(n): ans = [] while not n%2: ans.append(2) n //= 2 mod = 3 while mod**2 < n: if n%mod == 0: ans.append(mod) n //= mod else: mod += 2 if n != 1: ans.append(n) counter = Counter(ans) return counter def main(): input = sys.stdin.readline mod = pow(10,9)+7 n = int(input()) a = [int(x) for x in input().split()] prime_list = dict() for i in range(n): primes = prime_factorize(a[i]) for key, value in primes.items(): if key in prime_list: if prime_list[key] < value: prime_list[key] = value else: prime_list[key] = value L = 1 for key, value in prime_list.items(): L *= pow(key, value, mod) L %= mod ans = 0 for i in range(n): ans += (L*pow(a[i], mod-2, mod))%mod ans %= mod print(ans) if __name__ == "__main__": main()
import sys from collections import Counter def prime_factorize(n): ans = [] while not n%2: ans.append(2) n //= 2 mod = 3 while mod**2 <= n: if n%mod == 0: ans.append(mod) n //= mod else: mod += 2 if n != 1: ans.append(n) counter = Counter(ans) return counter def main(): input = sys.stdin.readline mod = pow(10,9)+7 n = int(input()) a = [int(x) for x in input().split()] prime_list = dict() for i in range(n): primes = prime_factorize(a[i]) for key, value in primes.items(): if key in prime_list: if prime_list[key] < value: prime_list[key] = value else: prime_list[key] = value L = 1 for key, value in prime_list.items(): L *= pow(key, value, mod) L %= mod ans = 0 for i in range(n): ans += (L*pow(a[i], mod-2, mod))%mod ans %= mod print(ans) if __name__ == "__main__": main()
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
599,409
599,410
u021548497
python
p02793
import sys from collections import Counter def prime_factorize(n): ans = [] while not n%2: ans.append(2) n //= 2 mod = 3 while mod**2 < n: if n%mod == 0: ans.append(mod) n //= mod else: mod += 2 if n != 1: ans.append(n) counter = Counter(ans) return counter def main(): input = sys.stdin.readline mod = pow(10,9)+7 n = int(input()) a = [int(x) for x in input().split()] prime_list = dict() for i in range(n): primes = prime_factorize(a[i]) for key, value in primes.items(): if key in prime_list: if prime_list[key] < value: prime_list[key] = value else: prime_list[key] = value L = 1 for key, value in prime_list.items(): L *= pow(key, value, mod) L %= mod ans = 0 for i in range(n): ans += (L*pow(a[i], mod-2, mod))%mod ans %= mod print(ans) if __name__ == "__main__": main()
import sys from collections import Counter def prime_factorize(n): ans = [] while not n%2: ans.append(2) n //= 2 mod = 3 while mod**2 <= n: if n%mod == 0: ans.append(mod) n //= mod else: mod += 2 if n != 1: ans.append(n) counter = Counter(ans) return counter def main(): input = sys.stdin.readline mod = pow(10,9)+7 n = int(input()) a = [int(x) for x in input().split()] prime_list = dict() for i in range(n): primes = prime_factorize(a[i]) for key, value in primes.items(): if key in prime_list: if prime_list[key] < value: prime_list[key] = value else: prime_list[key] = value L = 1 for key, value in prime_list.items(): L *= pow(key, value, mod) L %= mod ans = 0 for i in range(n): ans += (L*pow(a[i], mod-2, mod))%mod ans %= mod print(ans) if __name__ == "__main__": main()
[ "expression.operator.compare.change", "control_flow.loop.condition.change" ]
599,409
599,411
u021548497
python
p02793
N = int(input()) A = [int(x) for x in input().split()] import math G = A[0] for i in range(N): G = G * A[i] // math.gcd(G, A[i]) ans = 0 for j in range(N): ans += G / A[j] print(ans % (10 ** 9 + 7))
N = int(input()) A = [int(x) for x in input().split()] import math G = A[0] for i in range(1,N): G = G * A[i] // math.gcd(G, A[i]) ans = 0 for j in range(N): ans += G // A[j] print(ans % (10 ** 9 + 7))
[ "call.arguments.add", "expression.operator.arithmetic.change", "expression.operation.binary.change" ]
599,412
599,413
u430336181
python
p02793
N = int(input()) A = [int(x) for x in input().split()] import math G = A[0] for i in range(N): G = G * A[i] // math.gcd(G, A[i]) ans = 0 for j in range(N): ans += G / A[j] print(int(ans % (10**9 +7)))
N = int(input()) A = [int(x) for x in input().split()] import math G = A[0] for i in range(1,N): G = G * A[i] // math.gcd(G, A[i]) ans = 0 for j in range(N): ans += G // A[j] print(ans % (10 ** 9 + 7))
[ "call.arguments.add", "expression.operator.arithmetic.change", "expression.operation.binary.change", "call.arguments.change" ]
599,414
599,413
u430336181
python
p02793
import collections as col def prime(n): ans = [] for i in range(2, int(n**0.5)+1): while not n%i: n //= i ; ans.append(i) if n != 1: ans.append(num) return col.Counter(ans) n = int(input()) a = list(map(int,input().split())) cnt = col.Counter() for num in a: new = prime(num) for key,val in new.items(): if val > cnt[key] : cnt[key] = val LCM = 1 MOD = 10**9 + 7 for key,val in cnt.items(): LCM *= key**val %MOD ans = 0 for num in a: b = LCM * pow(num, MOD-2, MOD) #割るのではなく逆元をかける ans += b print(ans%MOD)
import collections as col def prime(n): ans = [] for i in range(2, int(n**0.5)+1): while not n%i: n //= i ; ans.append(i) if n != 1: ans.append(n) return col.Counter(ans) n = int(input()) a = list(map(int,input().split())) cnt = col.Counter() for num in a: new = prime(num) for key,val in new.items(): if val > cnt[key] : cnt[key] = val LCM = 1 MOD = 10**9 + 7 for key,val in cnt.items(): LCM *= key**val %MOD ans = 0 for num in a: b = LCM * pow(num, MOD-2, MOD) #割るのではなく逆元をかける ans += b print(ans%MOD)
[ "identifier.change", "call.arguments.change" ]
599,417
599,418
u054556734
python
p02793
def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque #from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush import math #inf = 10**17 mod = 10**9 + 7 # 素因数分解 def prime_decomp(n): i = 2 res = [] while i ** 2 <= n: while n % i==0: n //= i res.append(i) i += 1 if n > 1: res.append(n) return res # 素因数のリストを返す(0, 1は空) # aの逆元を求める def inv(a, mod=mod): return pow(a, mod-2, mod) n = int(input()) a = list(map(int, input().split())) lcm = [0]*(max(a)+1) for i in a: l = prime_decomp(i) c = Counter(l) for k, v in c.items(): if lcm[k] < v: lcm[k] = v b = 1 for i in range(1000): if lcm[i] != 0: b *= pow(i, lcm[i], mod) if n == 1: print(1) else: res = 0 for i in a: res += inv(i) print(res*b%mod) if __name__ == '__main__': main()
def main(): import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque #from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush import math #inf = 10**17 mod = 10**9 + 7 # 素因数分解 def prime_decomp(n): i = 2 res = [] while i ** 2 <= n: while n % i==0: n //= i res.append(i) i += 1 if n > 1: res.append(n) return res # 素因数のリストを返す(0, 1は空) # aの逆元を求める def inv(a, mod=mod): return pow(a, mod-2, mod) n = int(input()) a = list(map(int, input().split())) lcm = [0]*(max(a)+1) for i in a: l = prime_decomp(i) c = Counter(l) for k, v in c.items(): if lcm[k] < v: lcm[k] = v b = 1 for i in range(len(lcm)): if lcm[i] != 0: b *= pow(i, lcm[i], mod) if n == 1: print(1) else: res = 0 for i in a: res += inv(i) print(res*b%mod) if __name__ == '__main__': main()
[ "identifier.replace.add", "literal.replace.remove", "call.arguments.change", "control_flow.loop.range.bounds.upper.change", "call.arguments.add" ]
599,449
599,450
u863442865
python
p02793
#かけて最小公倍数になる そのために必要な数がB from math import gcd N=int(input()) if N==1: print(1) exit() mod=10**9+7 A=list(map(int, input().split())) def lcm(a,b): return (a*b)/gcd(a,b) if N==2: LCM=lcm(A[0],A[1]) ans=((LCM//A[0])+(LCM//A[1]))%mod print(ans) exit() LCM=1 #LCM%=mod for a in A: LCM=lcm(LCM, a) #LCM%=mod #print(LCM) ans=0 for a in A: ans+=LCM//a #ans%=mod print(int(ans%mod))
#かけて最小公倍数になる そのために必要な数がB from math import gcd N=int(input()) if N==1: print(1) exit() mod=10**9+7 A=list(map(int, input().split())) def lcm(a,b): return a//gcd(a,b)*b if N==2: LCM=lcm(A[0],A[1]) ans=((LCM//A[0])+(LCM//A[1]))%mod print(ans) exit() LCM=1 #LCM%=mod for a in A: LCM=lcm(LCM, a) #LCM%=mod #print(LCM) ans=0 for a in A: ans+=LCM//a #ans%=mod print(int(ans%mod))
[ "expression.operator.arithmetic.change", "function.return_value.change", "expression.operation.binary.change", "expression.operation.binary.remove" ]
599,462
599,463
u784022244
python
p02793
import sys input = sys.stdin.readline MOD = 10 ** 9 + 7 # 最大公約数 def gcd(a, b): if a < b: a, b = b, a while a % b != 0: a, b = b, a % b return b # 最小公倍数 def lcm(a, b): return a * b // gcd(a, b) def main(): n = int(input()) A = list(map(int, input().split())) l = 1 for a in A: l = lcm(l, a) c = 0 for a in A: c += l * pow(a, MOD - 2, MOD) ans = l * c % MOD print(ans) if __name__ == '__main__': main()
import sys input = sys.stdin.readline # sys.setrecursionlimit(10 ** 6) MOD = 10 ** 9 + 7 # INF = float("inf") # 最大公約数 def gcd(a, b): if a < b: a, b = b, a while a % b != 0: a, b = b, a % b return b # 最小公倍数 def lcm(a, b): return a * b // gcd(a, b) def main(): n = int(input()) A = list(map(int, input().split())) l = 1 for a in A: l = lcm(l, a) c = 0 for a in A: c += pow(a, MOD - 2, MOD) ans = l * c % MOD print(ans) if __name__ == '__main__': main()
[ "expression.operation.binary.remove" ]
599,464
599,465
u281610856
python
p02793
#-*- coding: utf-8 -*- """ oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d oj test -d test-d -c "python abc116d.py" oj test -d test-d -c "python abc116d.py" test-d/sample-3.in """ from collections import defaultdict import sys import math from datetime import datetime import re import math #sys.setrecursionlimit(314159265) def gcd(a,b): while b!=0: a,b=b,a%b return a def lcm(a,b): return a*b//gcd(a,b) def lcm_list(nums): if len(nums) == 0: return None if len(nums) == 1: return nums[0] if len(nums) == 2: lcm(nums[0], nums[1]) else: # > 2 a = lcm(nums[0], nums[1]) for i in range(2, len(nums)): A = lcm(a, nums[i]) a = A return a def sol(S): mod = 10**9 + 7 x = lcm_list(S) print(x) T = [ x//s for s in S] return sum(T) % mod do_submit = True #do_submit = False def input_parse(input_str): lines = [x.strip() for x in input_str.split("\n") if x.strip()] parsed_lines = [list(map(str, line.split())) for line in lines] print(parsed_lines) # n = int(parsed_lines[0][0]) # k = int(parsed_lines[0][1]) S = parsed_lines[0][0] return S if not do_submit: S = input_parse(""" 1905 """) print(sol(S)) S = input_parse(""" 0112 """) print(sol(S)) S = input_parse(""" 1700 """) print(sol(S)) S = input_parse(""" 0000 """) print(sol(S)) S = input_parse(""" 1001 """) print(sol(S)) else: n = int(input()) S = list(map(int, input().split())) #S = input() print(sol(S)) # S = input().strip() # print(sol(S)) # print(lcm(2, 3)) # print(lcm_list([2, 3, 4])) # print(lcm_list([27, 9, 3]))
#-*- coding: utf-8 -*- """ oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d oj test -d test-d -c "python abc116d.py" oj test -d test-d -c "python abc116d.py" test-d/sample-3.in """ from collections import defaultdict import sys import math from datetime import datetime import re import math #sys.setrecursionlimit(314159265) def gcd(a,b): while b!=0: a,b=b,a%b return a def lcm(a,b): return a*b//gcd(a,b) def lcm_list(nums): if len(nums) == 0: return None if len(nums) == 1: return nums[0] if len(nums) == 2: lcm(nums[0], nums[1]) else: # > 2 a = lcm(nums[0], nums[1]) for i in range(2, len(nums)): A = lcm(a, nums[i]) a = A return a def sol(S): mod = 10**9 + 7 x = lcm_list(S) #print(x) T = [ x//s for s in S] return sum(T) % mod do_submit = True #do_submit = False def input_parse(input_str): lines = [x.strip() for x in input_str.split("\n") if x.strip()] parsed_lines = [list(map(str, line.split())) for line in lines] print(parsed_lines) # n = int(parsed_lines[0][0]) # k = int(parsed_lines[0][1]) S = parsed_lines[0][0] return S if not do_submit: S = input_parse(""" 1905 """) print(sol(S)) S = input_parse(""" 0112 """) print(sol(S)) S = input_parse(""" 1700 """) print(sol(S)) S = input_parse(""" 0000 """) print(sol(S)) S = input_parse(""" 1001 """) print(sol(S)) else: n = int(input()) S = list(map(int, input().split())) #S = input() print(sol(S)) # S = input().strip() # print(sol(S)) # print(lcm(2, 3)) # print(lcm_list([2, 3, 4])) # print(lcm_list([27, 9, 3]))
[ "call.remove" ]
599,466
599,467
u474514603
python
p02793
n = int(input()) a = list(map(int, input().split())) mod = 10 ** 9 + 7 ans = a[0] for i in range(1, n): ans = ans * a[i] // math.gcd(ans, a[i]) c = 0 for i in range(n): b = ans // a[i] c += b print(c % mod)
import math n = int(input()) a = list(map(int, input().split())) mod = 10 ** 9 + 7 ans = a[0] for i in range(1, n): ans = ans * a[i] // math.gcd(ans, a[i]) c = 0 for i in range(n): b = ans // a[i] c += b print(c % mod)
[]
599,472
599,473
u262801165
python
p02793
from math import gcd def lcm(x, y): return (x * y) // gcd(x, y) n = int(input()) a = list(map(int,input().split())) g = a[0] for i in range(n): g = lcm(g,a[i]) ans = 0 for i in range(n): ans += g/a[i] print(int(ans%1000000007))
from math import gcd def lcm(x, y): return (x * y) // gcd(x, y) n = int(input()) a = list(map(int,input().split())) g = a[0] for i in range(n): g = lcm(g,a[i]) ans = 0 for i in range(n): ans += g // a[i] print(ans%1000000007)
[ "expression.operator.arithmetic.change", "expression.operation.binary.change", "call.remove", "call.arguments.change" ]
599,475
599,476
u623115612
python
p02793
def gcd(a, b): 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())) l=1 for i in range(0,n): l=lcm(l,a[i]) ans=0 for i in range(0,n): ans=ans+l/a[i] print (int(ans%(10**9+7)))
def gcd(a, b): 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())) l=1 for i in range(0,n): l=lcm(l,a[i]) ans=0 for i in range(0,n): ans=ans+l//a[i] print (ans%(10**9+7))
[ "expression.operator.arithmetic.change", "assignment.value.change", "expression.operation.binary.change", "call.arguments.change" ]
599,477
599,478
u277353449
python