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 |
|---|---|---|---|---|---|---|---|
p02844
|
n,S,r=int(input()),input(),0
dp1=[0]*n
dp2=[0]*n
d1=set()
d2=set()
cs=[0]*10
for i in range(n):
dp1[i] = len(d1)
d1.add(S[i])
for i in range(n):
j = n-i-1
dp2[j] = len(d2)
r += dp1[i]*(dp2[j]-dp2[cs[int(S[j])]])
d2.add(S[j])
cs[int(S[j])] = j
print(r)
|
n,S,r=int(input()),input(),0
dp1=[0]*n
dp2=[0]*n
d1=set()
d2=set()
cs=[0]*10
for i in range(n):
dp1[i] = len(d1)
d1.add(S[i])
for i in range(n):
j = n-i-1
dp2[j] = len(d2)
r += dp1[j]*(dp2[j]-dp2[cs[int(S[j])]])
d2.add(S[j])
cs[int(S[j])] = j
print(r)
|
[
"identifier.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 651,122
| 651,123
|
u941407962
|
python
|
p02844
|
N = int(input())
S = input()
count = 0
for p in range(22,1000):
v = format(p, '03')
found = False
pos1 = S.find(v[0])
if pos1 == -1:
continue
pos2 = S[pos1 + 1:].find(v[1])
if pos2 == -1:
continue
pos3 = S[pos1 + pos2 + 2:].find(v[2])
if pos3 == -1:
continue
count += 1
print(count)
|
N = int(input())
S = input()
count = 0
for p in range(1000):
v = format(p, '03')
found = False
pos1 = S.find(v[0])
if pos1 == -1:
continue
pos2 = S[pos1 + 1:].find(v[1])
if pos2 == -1:
continue
pos3 = S[pos1 + pos2 + 2:].find(v[2])
if pos3 == -1:
continue
count += 1
print(count)
|
[
"call.arguments.change"
] | 651,152
| 651,153
|
u471828790
|
python
|
p02844
|
n = int(input())
s = list(map(int, input()))
print(s)
ans = 0
for i in range(10):
for j in range(10):
for k in range(10):
preindex = 0
flag1 = 0
flag2 = 0
flag3 = 0
while preindex < n:
if s[preindex] == i:
preindex += 1
flag1 = 1
break
preindex += 1
while preindex < n:
if s[preindex] == j:
preindex += 1
flag2 = 1
break
preindex += 1
while preindex < n:
if s[preindex] == k:
flag3 = 1
break
preindex += 1
if flag1 and flag2 and flag3:
ans += 1
print(ans)
|
n = int(input())
s = list(map(int, input()))
ans = 0
for i in range(10):
for j in range(10):
for k in range(10):
preindex = 0
flag1 = 0
flag2 = 0
flag3 = 0
while preindex < n:
if s[preindex] == i:
preindex += 1
flag1 = 1
break
preindex += 1
while preindex < n:
if s[preindex] == j:
preindex += 1
flag2 = 1
break
preindex += 1
while preindex < n:
if s[preindex] == k:
flag3 = 1
break
preindex += 1
if flag1 and flag2 and flag3:
ans += 1
print(ans)
|
[
"call.remove"
] | 651,164
| 651,165
|
u691896522
|
python
|
p02844
|
N = int(input())
S = list(map(int,list(input())))
S_riv=S[::-1]
l_lis=[0]*N
r_lis=[0]*N
mat=([0 for j in range(10)])
l_set=set([])
r_set=set([])
for i,s in enumerate(S):
l_lis[i]=l_set.copy()
l_set.add(s)
for i,s in enumerate(S_riv):
r_lis[i]=r_set.copy()
r_set.add(s)
r_lis.reverse()
ans=0
for i,s in enumerate(S):
length=len(l_lis[i])
ans+=(length-mat[s])*len(r_lis[i])
mat[s]=length
|
N = int(input())
S = list(map(int,list(input())))
S_riv=S[::-1]
l_lis=[0]*N
r_lis=[0]*N
mat=([0 for j in range(10)])
l_set=set([])
r_set=set([])
for i,s in enumerate(S):
l_lis[i]=l_set.copy()
l_set.add(s)
for i,s in enumerate(S_riv):
r_lis[i]=r_set.copy()
r_set.add(s)
r_lis.reverse()
ans=0
for i,s in enumerate(S):
length=len(l_lis[i])
ans+=(length-mat[s])*len(r_lis[i])
mat[s]=length
print(ans)
|
[
"call.add"
] | 651,171
| 651,172
|
u268554510
|
python
|
p02844
|
#
# ⋀_⋀
# (・ω・)
# ./ U ∽ U\
# │* 合 *│
# │* 格 *│
# │* 祈 *│
# │* 願 *│
# │* *│
#  ̄
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないyp
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A):
for a in A: print(*a,sep='\n')
def main():
N=int(input())
S=input()
can = set([""]) ## 2文字以下で現在構築可能な文字列(最大10+10*10 = 1010)
ans = set() ## 3文字で現在構築可能な文字列(最大10*10*10 = 1,000)
for s in S:
for c in can.copy(): #途中でcanという集合に追加されるのでcopyする
res = c+s #2文字以下 + 1文字 で結合する
if len(res) == 3: #3文字なので暗証番号の候補
ans.add(res)
elif len(res) < 3: #2文字以下なのでcanに挿入
can.add(res)
print(len(ans))
"""
copyする回数 = N * len(can) <= 10^3 * N
for文の走査回数 = N * len(can) <= 10^3 * N
全体で 2 * (10^3 * N)
N<=3*10^4なので
2*3* 10^3 * 10^4 = 6 * 10^7 -> 間に合わない?んですか・・・?
"""
if __name__ == '__main__':
main()
|
#
# ⋀_⋀
# (・ω・)
# ./ U ∽ U\
# │* 合 *│
# │* 格 *│
# │* 祈 *│
# │* 願 *│
# │* *│
#  ̄
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないyp
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A):
for a in A: print(*a,sep='\n')
def main():
N=int(input())
S=input()[:-1]
can = set([""]) ## 2文字以下で現在構築可能な文字列(最大10+10*10 = 1010)
ans = set() ## 3文字で現在構築可能な文字列(最大10*10*10 = 1,000)
for s in S:
for c in can.copy(): #途中でcanという集合に追加されるのでcopyする
res = c+s #2文字以下 + 1文字 で結合する
if len(res) == 3: #3文字なので暗証番号の候補
ans.add(res)
elif len(res) < 3: #2文字以下なのでcanに挿入
can.add(res)
print(len(ans))
"""
copyする回数 = N * len(can) <= 10^3 * N
for文の走査回数 = N * len(can) <= 10^3 * N
全体で 2 * (10^3 * N)
N<=3*10^4なので
2*3* 10^3 * 10^4 = 6 * 10^7 -> 間に合わない?んですか・・・?
"""
if __name__ == '__main__':
main()
|
[] | 651,179
| 651,180
|
u788137651
|
python
|
p02844
|
import sys
input = sys.stdin.readline
def main():
N = int(input())
S = input().strip()
ans = 0
for i in range(1000+1):
s = "{:03}".format(i)
a = S.find(s[0])
b = S.find(s[1], a+1)
c = S.find(s[2], b+1)
if a >= 0 and b >= 0 and c >= 0 and (a < b < c):
ans += 1
print(ans)
if __name__ == '__main__':
main()
|
import sys
input = sys.stdin.readline
def main():
N = int(input())
S = input().strip()
ans = 0
for i in range(1000):
s = "{:03}".format(i)
a = S.find(s[0])
b = S.find(s[1], a+1)
c = S.find(s[2], b+1)
if a >= 0 and b >= 0 and c >= 0 and (a < b < c):
ans += 1
print(ans)
if __name__ == '__main__':
main()
|
[
"expression.operation.binary.remove"
] | 651,183
| 651,184
|
u076917070
|
python
|
p02844
|
n=int(input())
s=input()
nsl=['{:03}'.format() for i in range(1000)]
res=0
for ns in nsl:
idx=0
for char in s:
if char == ns[idx]:
idx+=1
if idx == 3:
res+=1
break
print(res)
|
n=int(input())
s=input()
nsl=['{:03}'.format(i) for i in range(1000)]
res=0
for ns in nsl:
idx=0
for char in s:
if char == ns[idx]:
idx+=1
if idx == 3:
res+=1
break
print(res)
|
[
"call.arguments.change"
] | 651,185
| 651,186
|
u148218179
|
python
|
p02844
|
N=int(input())
S=int(input())
l_S=list(str(S))
count=0
for i in range(0,1000):
i_1=int(i/100)
i_2=int(i/10)-i_1*10
i_3=i%10
if str(i_1) in l_S[:-2]:
idx_1=l_S[:-2].index(str(i_1))
if str(i_2) in l_S[idx_1+1:-1]:
idx_2=l_S[idx_1+1:-1].index(str(i_2))+idx_1+1
if str(i_3) in l_S[idx_2+1:]:
count+=1
print(count)
|
N=int(input())
S=str(input())
l_S=list(S)
count=0
for i in range(0,1000):
i_1=int(i/100)
i_2=int(i/10)-i_1*10
i_3=i%10
if str(i_1) in l_S[:-2]:
idx_1=l_S[:-2].index(str(i_1))
if str(i_2) in l_S[idx_1+1:-1]:
idx_2=l_S[idx_1+1:-1].index(str(i_2))+idx_1+1
if str(i_3) in l_S[idx_2+1:]:
count+=1
print(count)
|
[
"assignment.value.change",
"identifier.change",
"call.function.change",
"call.remove",
"call.arguments.change"
] | 651,199
| 651,200
|
u517327166
|
python
|
p02844
|
n=int(input())
s=input()
ans=0
for i in range(1,1000):
i=str(i)
i=(3-len(i))*"0"+i
r=0
for j in range(n):
if s[j]==i[r]:
r+=1
if r==3:
break
if r==3:
ans+=1
print(ans)
|
n=int(input())
s=input()
ans=0
for i in range(1000):
i=str(i)
i=(3-len(i))*"0"+i
r=0
for j in range(n):
if s[j]==i[r]:
r+=1
if r==3:
break
if r==3:
ans+=1
print(ans)
|
[
"call.arguments.change"
] | 651,206
| 651,207
|
u296150111
|
python
|
p02844
|
n = int(input())
s = list(map(int, list(input())))
def aruka(a,b,c):
i = 0
while i <= n:
if i == n:
return False
if s[i] == a:
i += 1
break
i += 1
while i <= n:
if i == n:
return False
if s[i] == b:
i += 1
break
i += 1
while i <= n:
if i == n:
return False
if s[i] == c:
return True
i += 1
ans = 0
for i in range(10):
for j in range(10):
for k in range(10):
if aruka(i,j,k):
ans += 1
|
n = int(input())
s = list(map(int, list(input())))
def aruka(a,b,c):
i = 0
while i <= n:
if i == n:
return False
if s[i] == a:
i += 1
break
i += 1
while i <= n:
if i == n:
return False
if s[i] == b:
i += 1
break
i += 1
while i <= n:
if i == n:
return False
if s[i] == c:
return True
i += 1
ans = 0
for i in range(10):
for j in range(10):
for k in range(10):
if aruka(i,j,k):
ans += 1
print(ans)
|
[
"call.add"
] | 651,223
| 651,224
|
u755363325
|
python
|
p02844
|
n = int(input())
S = input()
result = 0
for i in range(10):
if str(i) in S:
T = S[S.index(str(i)):]
for j in range(10):
if str(j) in T:
U = T[T.index(str(j)):]
for k in range(10):
if str(k) in U:
result += 1
print(result)
|
n = int(input())
S = input()
result = 0
for i in range(10):
if str(i) in S:
T = S[S.index(str(i))+1:]
for j in range(10):
if str(j) in T:
U = T[T.index(str(j))+1:]
for k in range(10):
if str(k) in U:
result += 1
print(result)
|
[
"assignment.change"
] | 651,227
| 651,228
|
u079427319
|
python
|
p02845
|
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
G = [0]*3
ans = 1
for i in range(N):
x = 0
cnt = 0
for j, g in enumerate(G):
if g == A[i]:
x = j if cnt == 0 else x
cnt += 1
G[x] += 1
ans *= cnt
ans = ans % mod
print(i, G)
print(ans)
|
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
G = [0]*3
ans = 1
for i in range(N):
x = 0
cnt = 0
for j, g in enumerate(G):
if g == A[i]:
x = j if cnt == 0 else x
cnt += 1
G[x] += 1
ans *= cnt
ans = ans % mod
print(ans)
|
[
"call.remove"
] | 651,234
| 651,235
|
u267718666
|
python
|
p02845
|
n=int(input())
l=list(map(int,input().split()))
mod=10**9+7
ans=1
rgb=[0]*3
for i in range(n):
f=0
for i in range(3):
if l[i]==rgb[i]:
if f==0:
rgb[i]+=1
f+=1
ans*=f
ans%=mod
print(ans)
|
n=int(input())
l=list(map(int,input().split()))
mod=10**9+7
ans=1
rgb=[0]*3
for i in range(n):
f=0
for j in range(3):
if l[i]==rgb[j]:
if f==0:
rgb[j]+=1
f+=1
ans*=f
ans%=mod
print(ans)
|
[
"identifier.change",
"variable_access.subscript.index.change",
"control_flow.branch.if.condition.change"
] | 651,236
| 651,237
|
u223904637
|
python
|
p02845
|
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit
INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7
def mapline(t = int):
return map(t, sysread().split())
def mapread(t = int):
return map(t, read().split())
def run():
N, *A = mapread()
ans = 1
current = [0,0,0]
for a in A:
transition = 0
cache = INF
for i, c in enumerate(current):
if c == a:
transition += 1
cache = i
ans *= transition
ans %= mod
current[cache] += 1
#print(current)
print(ans)
if __name__ == "__main__":
run()
|
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit
INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7
def mapline(t = int):
return map(t, sysread().split())
def mapread(t = int):
return map(t, read().split())
def run():
N, *A = mapread()
ans = 1
current = [0,0,0]
for a in A:
transition = 0
cache = 0
for i, c in enumerate(current):
if c == a:
transition += 1
cache = i
ans *= transition
ans %= mod
current[cache] += 1
#print(current)
print(ans)
if __name__ == "__main__":
run()
|
[
"assignment.value.change",
"identifier.replace.remove",
"literal.replace.add"
] | 651,240
| 651,241
|
u044220565
|
python
|
p02845
|
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit
INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7
def mapline(t = int):
return map(t, sysread().split())
def mapread(t = int):
return map(t, read().split())
def run():
N, *A = mapread()
ans = 1
current = [0,0,0]
for a in A:
transition = 0
#cache = 1
for i, c in enumerate(current):
if c == a:
transition += 1
cache = i
ans *= transition
ans %= mod
current[cache] += 1
#print(current)
print(ans)
if __name__ == "__main__":
run()
|
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit
INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7
def mapline(t = int):
return map(t, sysread().split())
def mapread(t = int):
return map(t, read().split())
def run():
N, *A = mapread()
ans = 1
current = [0,0,0]
for a in A:
transition = 0
cache = 0
for i, c in enumerate(current):
if c == a:
transition += 1
cache = i
ans *= transition
ans %= mod
current[cache] += 1
#print(current)
print(ans)
if __name__ == "__main__":
run()
|
[
"assignment.add"
] | 651,242
| 651,241
|
u044220565
|
python
|
p02845
|
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit
INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7
def mapline(t = int):
return map(t, sysread().split())
def mapread(t = int):
return map(t, read().split())
def run():
N, *A = mapread()
ans = 1
current = [0,0,0]
for a in A:
transition = 0
cache = None
for i, c in enumerate(current):
if c == a:
transition += 1
cache = i
ans *= transition
ans %= mod
current[cache] += 1
#print(current)
print(ans)
if __name__ == "__main__":
run()
|
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit
INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7
def mapline(t = int):
return map(t, sysread().split())
def mapread(t = int):
return map(t, read().split())
def run():
N, *A = mapread()
ans = 1
current = [0,0,0]
for a in A:
transition = 0
cache = 0
for i, c in enumerate(current):
if c == a:
transition += 1
cache = i
ans *= transition
ans %= mod
current[cache] += 1
#print(current)
print(ans)
if __name__ == "__main__":
run()
|
[
"assignment.value.change"
] | 651,243
| 651,241
|
u044220565
|
python
|
p02845
|
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit
INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7
def mapline(t = int):
return map(t, sysread().split())
def mapread(t = int):
return map(t, read().split())
def run():
N, *A = mapread()
ans = 1
current = [0,0,0]
for a in A:
transition = 0
cache = None
for i, c in enumerate(current):
if c == a:
transition += 1
cache = i
ans *= transition
ans %= mod
current[cache] += 1
print(ans)
if __name__ == "__main__":
run()
|
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit
INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7
def mapline(t = int):
return map(t, sysread().split())
def mapread(t = int):
return map(t, read().split())
def run():
N, *A = mapread()
ans = 1
current = [0,0,0]
for a in A:
transition = 0
cache = 0
for i, c in enumerate(current):
if c == a:
transition += 1
cache = i
ans *= transition
ans %= mod
current[cache] += 1
#print(current)
print(ans)
if __name__ == "__main__":
run()
|
[
"assignment.value.change"
] | 651,244
| 651,241
|
u044220565
|
python
|
p02845
|
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit
INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7
def mapline(t = int):
return map(t, sysread().split())
def mapread(t = int):
return map(t, read().split())
def run():
N, *A = mapread()
ans = 1
current = [0,0,0]
for a in A:
transition = 0
cache = None
for i, c in enumerate(current):
if c == a:
transition += 1
cache = i
ans *= transition
ans %= mod
current[cache] += 1
#print(current)
print(ans)
if __name__ == "__main__":
run()
|
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit
INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7
def mapline(t = int):
return map(t, sysread().split())
def mapread(t = int):
return map(t, read().split())
def run():
N, *A = mapread()
ans = 1
current = [0,0,0]
for a in A:
transition = 0
cache = 1
for i, c in enumerate(current):
if c == a:
transition += 1
cache = i
ans *= transition
ans %= mod
current[cache] += 1
#print(current)
print(ans)
if __name__ == "__main__":
run()
|
[
"assignment.value.change"
] | 651,243
| 651,246
|
u044220565
|
python
|
p02845
|
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit
INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7
def mapline(t = int):
return map(t, sysread().split())
def mapread(t = int):
return map(t, read().split())
def run():
N, *A = mapread()
ans = 1
current = [0,0,0]
for a in A:
transition = 0
cache = None
for i, c in enumerate(current):
if c == a:
transition += 1
cache = i
ans *= transition
ans %= mod
current[cache] += 1
print(ans)
if __name__ == "__main__":
run()
|
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit
INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7
def mapline(t = int):
return map(t, sysread().split())
def mapread(t = int):
return map(t, read().split())
def run():
N, *A = mapread()
ans = 1
current = [0,0,0]
for a in A:
transition = 0
cache = 1
for i, c in enumerate(current):
if c == a:
transition += 1
cache = i
ans *= transition
ans %= mod
current[cache] += 1
#print(current)
print(ans)
if __name__ == "__main__":
run()
|
[
"assignment.value.change"
] | 651,244
| 651,246
|
u044220565
|
python
|
p02845
|
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit
INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7
def mapline(t = int):
return map(t, sysread().split())
def mapread(t = int):
return map(t, read().split())
def run():
N, *A = mapread()
ans = 1
current = [0,0,0]
for a in A:
transition = 0
cache = None
for i, c in enumerate(current):
if c == a:
transition += 1
cache = i
ans *= transition
ans %= mod
current[cache] += 1
print(ans)
if __name__ == "__main__":
run()
|
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
from heapq import heappop, heappush
from collections import defaultdict
sys.setrecursionlimit(10**7)
import math
#from itertools import product, accumulate, combinations, product
#import bisect
#import numpy as np
#from copy import deepcopy
#from collections import deque
#from decimal import Decimal
#from numba import jit
INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7
def mapline(t = int):
return map(t, sysread().split())
def mapread(t = int):
return map(t, read().split())
def run():
N, *A = mapread()
ans = 1
current = [0,0,0]
for a in A:
transition = 0
cache = 1
for i, c in enumerate(current):
if c == a:
transition += 1
cache = i
ans *= transition
ans %= mod
current[cache] += 1
#print(current)
print(ans)
if __name__ == "__main__":
run()
|
[
"assignment.value.change"
] | 651,245
| 651,246
|
u044220565
|
python
|
p02845
|
N=int(input())
A=list(map(int, input().split()))
mod=10**9+7
if A[0]!=0:
print(0)
break
L=[1,0,0]
ans=3
for i in range(1,N):
a=A[i]
count=0
add=True
for j,l in enumerate(L):
if a==l:
count+=1
if add:
L[j]+=1
add=False
ans*=count
ans%=mod
print(ans)
#print(L)
|
N=int(input())
A=list(map(int, input().split()))
mod=10**9+7
if A[0]!=0:
print(0)
exit()
L=[1,0,0]
ans=3
for i in range(1,N):
a=A[i]
count=0
add=True
for j,l in enumerate(L):
if a==l:
count+=1
if add:
L[j]+=1
add=False
ans*=count
ans%=mod
print(ans)
#print(L)
|
[
"control_flow.break.remove",
"control_flow.exit.add",
"call.add"
] | 651,249
| 651,250
|
u784022244
|
python
|
p02845
|
n=int(input())
a=list(map(int,input().split()))
a_=max(a)
con=[0]*(a_+1)
tou=[0]*(a_+1)
ans=[]
for i in range(len(a)):
u=a[i]
if u==0:
con[0]+=1
tou[0]+=1
ans.append(4-con[0])
else:
con[u]+=1
tou[u]+=1
ans.append(min(tou[u-1]-con[u]+1,4-con[u]))
c=1
for i in range(len(ans)):
c*=ans[i]
c=c%(10**9+7)
print(c%(10**9+7))
print(ans)
|
n=int(input())
a=list(map(int,input().split()))
a_=max(a)
con=[0]*(a_+1)
tou=[0]*(a_+1)
ans=[]
for i in range(len(a)):
u=a[i]
if u==0:
con[0]+=1
tou[0]+=1
ans.append(4-con[0])
else:
con[u]+=1
tou[u]+=1
ans.append(min(tou[u-1]-con[u]+1,4-con[u]))
c=1
for i in range(len(ans)):
c*=ans[i]
c=c%(10**9+7)
print(c%(10**9+7))
|
[
"call.remove"
] | 651,264
| 651,265
|
u428199834
|
python
|
p02845
|
def read_int():
return int(input().strip())
def read_ints():
return list(map(int, input().strip().split(' ')))
def solve():
"""
"""
N = read_int()
A = read_ints()
T = [0, 0, 0]
answer = 1
modulo = 1000000007
for a in A:
if a not in T:
return -1
answer = (answer*T.count(a))%modulo
T[T.index(a)] += 1
return answer
if __name__ == '__main__':
print(solve())
|
def read_int():
return int(input().strip())
def read_ints():
return list(map(int, input().strip().split(' ')))
def solve():
"""
"""
N = read_int()
A = read_ints()
T = [0, 0, 0]
answer = 1
modulo = 1000000007
for a in A:
if a not in T:
return 0
answer = (answer*T.count(a))%modulo
T[T.index(a)] += 1
return answer
if __name__ == '__main__':
print(solve())
|
[
"function.return_value.change",
"expression.operation.unary.remove"
] | 651,283
| 651,284
|
u309716323
|
python
|
p02845
|
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10
N = INT()
A = LIST()
cnt = [0]*(max(A)+2)
cnt[0] = 3
ans = 1
for a in A:
print(cnt)
ans *= cnt[a] - cnt[a+1]
cnt[a+1] += 1
ans %= mod
print(ans)
|
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10
N = INT()
A = LIST()
cnt = [0]*(max(A)+2)
cnt[0] = 3
ans = 1
for a in A:
ans *= cnt[a] - cnt[a+1]
cnt[a+1] += 1
ans %= mod
print(ans)
|
[
"call.remove"
] | 651,301
| 651,302
|
u285891772
|
python
|
p02845
|
N = int(input())
A = list(map(int,input().split()))
C = [0,0,0]
Ans = 1
MOD = 1000000007
for a in A:
ask = C.count(a)
if ask==0:
Ans=0
break
ind = C.index(a)
C[ind] += 1
Ans = (Ans*ask)%MOD
print(C)
print(Ans)
|
N = int(input())
A = list(map(int,input().split()))
C = [0,0,0]
Ans = 1
MOD = 1000000007
for a in A:
ask = C.count(a)
if ask==0:
Ans=0
break
ind = C.index(a)
C[ind] += 1
Ans = (Ans*ask)%MOD
print(Ans)
|
[
"call.remove"
] | 651,309
| 651,310
|
u665873062
|
python
|
p02845
|
N = int(input())
A = list(map(int,input().split()))
C = [0,0,0]
Ans = 1
MOD = 1000000007
for a in A:
ask = C.count(a)
if ask == 0:
break
ind = C.index(a)
C[ind] += 1
Ans = (Ans*ask)%MOD
print(Ans)
|
N = int(input())
A = list(map(int,input().split()))
C = [0,0,0]
Ans = 1
MOD = 1000000007
for a in A:
ask = C.count(a)
if ask==0:
Ans=0
break
ind = C.index(a)
C[ind] += 1
Ans = (Ans*ask)%MOD
print(Ans)
|
[
"assignment.add"
] | 651,311
| 651,310
|
u665873062
|
python
|
p02845
|
N = int(input())
A = list(map(int,input().split()))
C = [0,0,0]
Ans = 1
MOD = 1000000007
for a in A:
ask = C.count(a)
if ask == 0:
continue
ind = C.index(a)
C[ind] += 1
Ans = (Ans*ask)%MOD
print(Ans)
|
N = int(input())
A = list(map(int,input().split()))
C = [0,0,0]
Ans = 1
MOD = 1000000007
for a in A:
ask = C.count(a)
if ask==0:
Ans=0
break
ind = C.index(a)
C[ind] += 1
Ans = (Ans*ask)%MOD
print(Ans)
|
[
"assignment.variable.change",
"control_flow.break.add"
] | 651,312
| 651,310
|
u665873062
|
python
|
p02845
|
N = int(input())
As = list(map(int, input().split()))
mod = 10**9+7
dp = [[0]*3 for _ in range(N+1)]
ans = 1
for i in range(N):
a = As[i]
dplis = dp[i]
cnt = 0
dp[i+1] = dplis[:]
for j, d in enumerate(dplis):
if a==d:
cnt += 1
if cnt==1:
dp[i+1][j] = a+1
if cnt==0:
print(0)
break
ans = ans*cnt%mod
print(ans%mod)
|
N = int(input())
As = list(map(int, input().split()))
mod = 10**9+7
dp = [[0]*3 for _ in range(N+1)]
ans = 1
for i in range(N):
a = As[i]
dplis = dp[i]
cnt = 0
dp[i+1] = dplis[:]
for j, d in enumerate(dplis):
if a==d:
cnt += 1
if cnt==1:
dp[i+1][j] = a+1
if cnt==0:
print(0)
break
ans = ans*cnt%mod
else:
print(ans%mod)
|
[] | 651,332
| 651,333
|
u054514819
|
python
|
p02845
|
N=int(input())
A=list(map(int,input().split()))
p=1000000007
R=[0]
G=[0]
B=[0]
#print(A)
ans=1
for i in range(N):
if A[i]==R[-1]:
tmp+=1
if A[i]==G[-1]:
tmp+=1
if A[i]==B[-1]:
tmp+=1
ans = (ans*tmp)%p
if A[i]==R[-1]:
R.append(R[-1]+1)
G.append(G[-1])
B.append(B[-1])
elif A[i]==G[-1]:
R.append(R[-1])
G.append(G[-1]+1)
B.append(B[-1])
else:
R.append(R[-1])
G.append(G[-1])
B.append(B[-1]+1)
tmp=0
#print(R)
#print(G)
#print(B)
print(ans)
|
N=int(input())
A=list(map(int,input().split()))
p=1000000007
R=[0]
G=[0]
B=[0]
#print(A)
ans=1
for i in range(N):
tmp=0
if A[i]==R[-1]:
tmp+=1
if A[i]==G[-1]:
tmp+=1
if A[i]==B[-1]:
tmp+=1
ans = (ans*tmp)%p
if A[i]==R[-1]:
R.append(R[-1]+1)
G.append(G[-1])
B.append(B[-1])
elif A[i]==G[-1]:
R.append(R[-1])
G.append(G[-1]+1)
B.append(B[-1])
else:
R.append(R[-1])
G.append(G[-1])
B.append(B[-1]+1)
#print(R)
#print(G)
#print(B)
print(ans)
|
[
"assignment.add",
"assignment.remove"
] | 651,337
| 651,338
|
u089142196
|
python
|
p02845
|
n = int(input())
a = list(map(int,input().split()))
ans = 1
p = [0,0,0]
mod = 10**9+7
for i in range(n-1):
q = 0
for j in range(3):
if p[j] == a[i]:
q +=1
for k in range(3):
if p[k] == a[i]:
p[k] += 1
break
ans = ans*q%mod
print(ans%mod)
|
n = int(input())
a = list(map(int,input().split()))
ans = 1
p = [0,0,0]
mod = 10**9+7
for i in range(n):
q = 0
for j in range(3):
if p[j] == a[i]:
q +=1
for k in range(3):
if p[k] == a[i]:
p[k] += 1
break
ans = ans*q%mod
print(ans%mod)
|
[
"expression.operation.binary.remove"
] | 651,341
| 651,342
|
u342563578
|
python
|
p02845
|
N=int(input())
A=list(map(int,input().split()))
l=[[] for _ in range(3)]
ans=1
p=10**9+7
flag=1
for i in range(N):
cnt=0
piv=A[i]
ind=[]
for j in range(3):
if l[j]==piv:
cnt=cnt+1
ind.append(j)
if len(ind)==0:
flag=0
break
l[ind[0]].append(piv)
ans=(ans*cnt)%p
#print(l,ans)
#input()
if flag==1:
print(ans%p)
else:
print(flag)
|
N=int(input())
A=list(map(int,input().split()))
l=[[] for _ in range(3)]
ans=1
p=10**9+7
flag=1
for i in range(N):
cnt=0
piv=A[i]
ind=[]
for j in range(3):
if len(l[j])==piv:
cnt=cnt+1
ind.append(j)
if len(ind)==0:
flag=0
break
l[ind[0]].append(piv)
ans=(ans*cnt)%p
#print(l,ans)
#input()
if flag==1:
print(ans%p)
else:
print(flag)
|
[
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change",
"call.add"
] | 651,343
| 651,344
|
u995004106
|
python
|
p02845
|
import sys
n=int(input())
a=list(map(int,input().split()))
if a[0]!=0:
print(0)
sys.exit()
mod=10**9+7
acnt=dict()
acnt[a[0]]=1
acntkeymax=0
t=3
for i in range(1,n):
if a[i] in acnt:
acnt[a[i]]+=1
if acnt[a[i]]>3:
print(0)
sys.exit()
else:
if acntkeymax+1==a[i]:
acntkeymax=a[i]
acnt[a[i]]=1
else:
print(0)
sys.exit()
if a[i]!=0:
if acnt[a[i]-1]==1:
if acnt[a[i]]!=1:
print(0)
sys.exit()
if acnt[a[i]-1]==2:
if acnt[a[i]]==1:
t=(t*2)%mod
elif acnt[a[i]]!=2:
print(0)
sys.exit()
elif acnt[a[i]-1]==3:
if acnt[a[i]]==1:
t=(t*3)%mod
elif acnt[a[i]]==2:
t=(t*2)%mod
elif acnt[a[i]]!=3:
print(0)
sys.exit()
else:
if acnt[0]==2:
t=(t*2)%mod
elif acnt[0]!=1:
print(0)
sys.exit()
# print("i:",i,"a[i]:",a[i],"acnt[a[i]]:",acnt[a[i]],"t:",t)
print(t)
|
import sys
n=int(input())
a=list(map(int,input().split()))
#n=54
#a=[0,0,1,0,1,2,1,2,3,2,3,3,4,4,5,4,6,5,7,8,
# 5,6,6,7,7,8,8,9,9,10,10,11,9,12,10,13,14,
# 11,11,12,12,13,13,14,14,15,15,15,16,16,16,
# 17,17,17]
#ans=115295190
#n=10
#a=[3,2,5,1,7,3,6,4,5,4]
#ans=0
if a[0]!=0:
print(0)
sys.exit()
mod=10**9+7
acnt=dict()
acnt[a[0]]=1
acntkeymax=0
t=3
for i in range(1,n):
if a[i] in acnt:
acnt[a[i]]+=1
if acnt[a[i]]>3:
print(0)
sys.exit()
else:
if acntkeymax+1==a[i]:
acntkeymax=a[i]
acnt[a[i]]=1
else:
print(0)
sys.exit()
if a[i]!=0:
if acnt[a[i]-1]==1:
if acnt[a[i]]!=1:
print(0)
sys.exit()
elif acnt[a[i]-1]==2:
if acnt[a[i]]==1:
t=(t*2)%mod
elif acnt[a[i]]!=2:
print(0)
sys.exit()
elif acnt[a[i]-1]==3:
if acnt[a[i]]==1:
t=(t*3)%mod
elif acnt[a[i]]==2:
t=(t*2)%mod
elif acnt[a[i]]!=3:
print(0)
sys.exit()
else:
if acnt[0]==2:
t=(t*2)%mod
elif acnt[0]!=3:
print(0)
sys.exit()
# print("i:",i,"a[i]:",a[i],"acnt[a[i]]:",acnt[a[i]],"t:",t)
print(t)
|
[
"control_flow.branch.if.replace.remove",
"control_flow.branch.else_if.replace.add",
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 651,353
| 651,354
|
u576432509
|
python
|
p02844
|
#import math
#import bisect
#import numpy as np
#import itertools
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
INF = float('INF')
sys.setrecursionlimit(10**5)
def main():
n = int(input())
s = input()
ans = 0
pin = list(itertools.product(range(10), repeat=3))
for cur in pin:
a, b, c = map(str,cur)
if a in s:
aidx = s.index(a)
if b in s[aidx+1:]:
bidx = s[aidx+1:].index(b) + (aidx + 1)
if c in s[bidx+1:]:
ans += 1
print(ans)
if __name__ == '__main__':
main()
|
#import math
#import bisect
#import numpy as np
import itertools
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
INF = float('INF')
sys.setrecursionlimit(10**5)
def main():
n = int(input())
s = input()
ans = 0
pin = list(itertools.product(range(10), repeat=3))
for cur in pin:
a, b, c = map(str,cur)
if a in s:
aidx = s.index(a)
if b in s[aidx+1:]:
bidx = s[aidx+1:].index(b) + (aidx + 1)
if c in s[bidx+1:]:
ans += 1
print(ans)
if __name__ == '__main__':
main()
|
[] | 651,397
| 651,398
|
u261103969
|
python
|
p02844
|
def ok(target, S):
for t in target:
if t in S:
S = S[S.index(t)+1:]
else:
return False
print(target)
return True
N = int(input())
S = input()
ans = 0
for i in range(0, 999+1):
target = str(i).zfill(3)
ans += ok(target, S)
print(ans)
|
def ok(target, S):
for t in target:
if t in S:
S = S[S.index(t)+1:]
else:
return False
return True
N = int(input())
S = input()
ans = 0
for i in range(0, 999+1):
target = str(i).zfill(3)
ans += ok(target, S)
print(ans)
|
[
"call.remove"
] | 651,401
| 651,402
|
u735008991
|
python
|
p02844
|
n=int(input())
s=input()
ans=0
fi=lambda x,y:x.find(str(y))
for i in range(10):
f1=fi(s,i)
if f1==-1:
continue
s1=s[f1+1:]
for j in range(10):
f2=fi(s1,j)
if f2==-1:
continue
s2=s1[f2+1:]
for k in range(10):
f3=fi(s2,k)
if f3>0:
ans+=1
print(ans)
|
n=int(input())
s=input()
ans=0
fi=lambda x,y:x.find(str(y))
for i in range(10):
f1=fi(s,i)
if f1==-1:
continue
s1=s[f1+1:]
for j in range(10):
f2=fi(s1,j)
if f2==-1:
continue
s2=s1[f2+1:]
for k in range(10):
f3=fi(s2,k)
if f3>=0:
ans+=1
print(ans)
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 651,407
| 651,408
|
u762540523
|
python
|
p02844
|
n=int(input())
s=input()
ans=0
fi=lambda x,y:x.find(str(y))
for i in range(10):
f1=fi(s,i)
if f1==-1:
continue
s1=s[f1+1:]
for j in range(10):
f2=fi(s1,j)
if f2==-1:
continue
s2=s1[f2+1:]
for k in range(10):
f3=fi(s1,k)
if f3>0:
ans+=1
print(ans)
|
n=int(input())
s=input()
ans=0
fi=lambda x,y:x.find(str(y))
for i in range(10):
f1=fi(s,i)
if f1==-1:
continue
s1=s[f1+1:]
for j in range(10):
f2=fi(s1,j)
if f2==-1:
continue
s2=s1[f2+1:]
for k in range(10):
f3=fi(s2,k)
if f3>=0:
ans+=1
print(ans)
|
[
"assignment.value.change",
"identifier.change",
"call.arguments.change",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 651,409
| 651,408
|
u762540523
|
python
|
p02844
|
n = int(input())
s = input()
sum = 0
box = []
for i in range(n-2):
if s[i] not in box:
box.append(s[i])
elif len(box) == 10:
break
else:
continue
box_1 = []
for j in range(i+1, n-1):
if s[j] not in box_1:
box_1.append(s[j])
elif len(box_1) == 10:
break
else:
continue
box_2 = []
for k in range(j+1, n):
if s[k] not in box_2:
box_2.append(s[k])
elif len(box_2) == 10:
sum += 10
break
else:
continue
sum += len(box_2)
print(sum)
|
n = int(input())
s = input()
sum = 0
box = []
for i in range(n-2):
if s[i] not in box:
box.append(s[i])
elif len(box) == 10:
break
else:
continue
box_1 = []
for j in range(i+1, n-1):
if s[j] not in box_1:
box_1.append(s[j])
elif len(box_1) == 10:
break
else:
continue
box_2 = []
for k in range(j+1, n):
if s[k] not in box_2:
box_2.append(s[k])
elif len(box_2) == 10:
break
else:
continue
sum += len(box_2)
print(sum)
|
[] | 651,410
| 651,411
|
u768896740
|
python
|
p02844
|
n = int(input())
s = input()
res = 0
lst = [[] for _ in range(10)]
for i in range(n):
lst[int(s[i])].append(i)
done = []
cnt = 0
for i in range(1000):
tmp = str(i).rjust(3, '0')
n1,n2,n3 = int(tmp[0]), int(tmp[1]), int(tmp[2])
mi = -1
mx = -1
if len(lst[n1])!=0:
mi = lst[n1][0]
if len(lst[n3])!=0:
mx = lst[n3][-1]
if mi>0 and mx>0:
for y in lst[n2]:
if mi<y<mx:
done.append(tmp)
else:
continue
print(len(set(done)))
|
n = int(input())
s = input()
res = 0
lst = [[] for _ in range(10)]
for i in range(n):
lst[int(s[i])].append(i)
done = []
cnt = 0
for i in range(1000):
tmp = str(i).rjust(3, '0')
n1,n2,n3 = int(tmp[0]), int(tmp[1]), int(tmp[2])
mi = -1
mx = -1
if len(lst[n1])!=0:
mi = lst[n1][0]
if len(lst[n3])!=0:
mx = lst[n3][-1]
if mi>=0 and mx>=0:
for y in lst[n2]:
if mi<y<mx:
done.append(tmp)
else:
continue
print(len(set(done)))
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 651,420
| 651,421
|
u672475305
|
python
|
p02844
|
n=int(input())
s=input()
t=0
for i in range(10):
for a in range(n):
if s[a]==str(i):
for j in range(10):
for b in range(a+1,n-1)[::-1]:
if s[b]==str(j):
t+=len(set(list(s[a+1:b])))
print(t)
|
n=int(input())
s=input()
t=0
for i in range(10):
for a in range(n):
if s[a]==str(i):
for j in range(10):
for b in range(a+1,n)[::-1]:
if s[b]==str(j):
t+=len(set(list(s[a+1:b])))
break
break
print(t)
|
[
"expression.operation.binary.remove",
"control_flow.break.add"
] | 651,424
| 651,425
|
u539517139
|
python
|
p02845
|
n = int(input())
a = list(map(int, input().split()))
que = [-1, -1, -1]
ans = 1
for i in range(n):
if que[0]+1 == a[i]:
if que[0] == que[1] and que[0] == que[2]:
ans *= 3
ans %= (10**9 + 7)
elif que[0] == que[1]:
ans *= 2
ans %= (10**9 + 7)
que[0] = a[i]
elif que[1]+1 == a[i]:
if que[1] == que[2]:
ans *= 2
ans %= (10**9 + 7)
que[1] = a[i]
elif que[2]+1 == a[i]:
que[2] = a[i]
print(ans)
|
n = int(input())
a = list(map(int, input().split()))
que = [-1, -1, -1]
ans = 1
for i in range(n):
if que[0]+1 == a[i]:
if que[0] == que[1] and que[0] == que[2]:
ans *= 3
ans %= (10**9 + 7)
elif que[0] == que[1]:
ans *= 2
ans %= (10**9 + 7)
que[0] = a[i]
elif que[1]+1 == a[i]:
if que[1] == que[2]:
ans *= 2
ans %= (10**9 + 7)
que[1] = a[i]
elif que[2]+1 == a[i]:
que[2] = a[i]
else:
ans = 0
break
print(ans)
|
[
"control_flow.break.add"
] | 651,437
| 651,438
|
u408375121
|
python
|
p02845
|
n = int(input())
a = list(map(int,input().split()))
mod = 1000000007
ans = 1
l = []
for i in range(n):
if a[i] == 0:
l.append(0)
ans = ans*(4-len(l))%mod
else:
id = -1
count = 0
for j in range(len(l)):
if l[j] == a[i] - 1:
count += 1
id = j
if id == -1:
break
ans = (ans*count)%mod
l[id] = a[i]
if ans == 0:
break
print(ans%mod)
|
n = int(input())
a = list(map(int,input().split()))
mod = 1000000007
ans = 1
l = []
for i in range(n):
if a[i] == 0:
l.append(0)
ans = ans*(4-len(l))%mod
else:
id = -1
count = 0
for j in range(len(l)):
if l[j] == a[i] - 1:
count += 1
id = j
if id == -1:
ans = 0
break
ans = (ans*count)%mod
l[id] = a[i]
if ans == 0:
break
print(ans%mod)
|
[
"assignment.add"
] | 651,441
| 651,442
|
u535236942
|
python
|
p02845
|
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9+7
ans = 1
dp = [0]*3
for a in A:
ans = ans*dp.count(a) % MOD
dp[dp.index(a)] += 1
print(ans)
|
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9+7
ans = 1
dp = [0]*3
for a in A:
ans = ans*dp.count(a) % MOD
try:
dp[dp.index(a)] += 1
except ValueError:
break
print(ans)
|
[
"control_flow.break.add"
] | 651,453
| 651,454
|
u375616706
|
python
|
p02845
|
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[int(i) for i in input().split()]
ans=1
mod=10**9+7
C=[0,0,0]
for i in range(1,n):
cur=A[i]
ct=0
Chk=True
for i,c in enumerate(C):
if cur==c:
ct+=1
if Chk:
C[i]+=1
Chk=False
ans=(ans*ct)%mod
print(ans)
|
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[int(i) for i in input().split()]
ans=1
mod=10**9+7
C=[0,0,0]
for i in range(n):
cur=A[i]
ct=0
Chk=True
for i,c in enumerate(C):
if cur==c:
ct+=1
if Chk:
C[i]+=1
Chk=False
ans=(ans*ct)%mod
print(ans)
|
[
"call.arguments.change"
] | 651,457
| 651,458
|
u969190727
|
python
|
p02845
|
n = int(input())
a = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(int)
ans=1
for num in a:
if num==0:
last_cnt=3
tmp = last_cnt - d[num]
else:
last_cnt=d[num-1]
tmp = last_cnt - d[num]
if tmp == 0:
tmp=1
ans*=tmp
ans%=1000000007
d[num]+=1
print(ans)
|
n = int(input())
a = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(int)
ans=1
for num in a:
if num==0:
last_cnt=3
tmp = last_cnt - d[num]
else:
last_cnt=d[num-1]
tmp = last_cnt - d[num]
if tmp == 0:
# tmp=1
ans=0
ans*=tmp
ans%=1000000007
d[num]+=1
print(ans)
|
[
"assignment.variable.change",
"identifier.change",
"literal.number.integer.change",
"assignment.value.change"
] | 651,477
| 651,478
|
u358254559
|
python
|
p02845
|
n = int(input())
a = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(int)
ans=1
for num in a:
if num==0:
last_cnt=3
tmp = last_cnt - d[num]
else:
last_cnt=d[num-1]
tmp = last_cnt - d[num]
if tmp == 0:
tmp=1
ans*=tmp
ans%=1000000007
d[num]+=1
print(ans)
|
n = int(input())
a = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(int)
ans=1
for num in a:
if num==0:
last_cnt=3
tmp = last_cnt - d[num]
else:
last_cnt=d[num-1]
tmp = last_cnt - d[num]
if tmp == 0:
# tmp=1
ans=0
ans*=tmp
ans%=1000000007
d[num]+=1
print(ans)
|
[
"assignment.variable.change",
"identifier.change",
"literal.number.integer.change",
"assignment.value.change"
] | 651,479
| 651,478
|
u358254559
|
python
|
p02845
|
n = int(input())
a = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(int)
ans=1
for num in a:
if num==0:
last_cnt=3
else:
last_cnt=d[num-1]
tmp = last_cnt - d[num]
if tmp <= 0:
tmp=1
ans*=tmp
ans%=1000000007
d[num]+=1
print(ans)
|
n = int(input())
a = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(int)
ans=1
for num in a:
if num==0:
last_cnt=3
else:
last_cnt=d[num-1]
tmp = last_cnt - d[num]
if tmp < 0:
tmp=1
ans*=tmp
ans%=1000000007
d[num]+=1
print(ans)
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 651,480
| 651,481
|
u358254559
|
python
|
p02845
|
n = int(input())
a = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(int)
ans=1
for num in a:
if num==0:
ans*= (3 - d[0])
else:
ans*= (d[num-1] - d[num])
ans*=tmp
ans%=1000000007
d[num]+=1
print(ans)
|
n = int(input())
a = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(int)
ans=1
for num in a:
if num==0:
ans*= (3 - d[0])
else:
ans*= (d[num-1] - d[num])
ans%=1000000007
d[num]+=1
print(ans)
|
[] | 651,482
| 651,483
|
u358254559
|
python
|
p02845
|
N = int(input())
A = list(map(int, input().split()))
C = [0, 0, 0] # 同じ帽子をかぶっている人数 降順
B = 10 ** 9 + 7
ans = 1
for i in range(N):
if A[i] in C:
ans *= C.count(A[i])
C[C.index(A[i])] += 1
print(ans % B)
|
N = int(input())
A = list(map(int, input().split()))
C = [0, 0, 0] # 同じ帽子をかぶっている人数 降順
B = 10 ** 9 + 7
ans = 1
for i in range(N):
if A[i] in C:
ans *= C.count(A[i])
C[C.index(A[i])] += 1
else:
ans = 0
break
print(ans % B)
|
[
"control_flow.break.add"
] | 651,488
| 651,489
|
u389122588
|
python
|
p02845
|
N = int(input())
A = list(map(int,input().split()))
MOD = 1000000007
#色ごとの人数
C=[0,0,0]
ans=1
for a in A:
#人数が一致する色がなければOUT
found=False
count=C.count(a)
if count==0:
print(0)
exit()
#適当に1人足す
C[C.index(a)]+=1
#今見ている人の色の可能性はcount種類
ans=ans*count%MOD
print(count)
print(ans)
|
N = int(input())
A = list(map(int,input().split()))
MOD = 1000000007
#色ごとの人数
C=[0,0,0]
ans=1
for a in A:
#人数が一致する色がなければOUT
found=False
count=C.count(a)
if count==0:
print(0)
exit()
#適当に1人足す
C[C.index(a)]+=1
#今見ている人の色の可能性はcount種類
ans=ans*count%MOD
print(ans)
|
[
"call.remove"
] | 651,490
| 651,491
|
u852690916
|
python
|
p02845
|
N=int(input())
A=[int(i) for i in input().split()]
X=[-1,-1,-1]
ans=1
mod=10**9+7
for i in range(N):
tmp=0
if A[i]>i:
ans=0
for j in range(3):
if X[j]==A[i]-1:
tmp+=1
for j in range(3):
if X[j]==A[i]-1:
ans=tmp*ans
ans%=mod
X[j]+=1
break
print(ans)
|
N=int(input())
A=[int(i) for i in input().split()]
X=[-1,-1,-1]
ans=1
mod=10**9+7
for i in range(N):
tmp=0
if A[i]>i:
ans=0
for j in range(3):
if X[j]==A[i]-1:
tmp+=1
for j in range(3):
if X[j]==A[i]-1 or tmp==0:
ans=tmp*ans
ans%=mod
X[j]+=1
break
print(ans)
|
[
"control_flow.branch.if.condition.change",
"control_flow.loop.for.condition.change"
] | 651,494
| 651,495
|
u562016607
|
python
|
p02845
|
def examE(mod):
N = I()
A = LI()
a =[0,0,0]
cur = 1
for i in A:
if a[0]==i:
if a[0]==a[1]:
if a[1]==a[2]:
cur *= 3
else:
cur *=2
a[0]+=1
elif a[1]==i:
if a[1] == a[2]:
cur *= 2
a[1] +=1
elif a[2]==i:
a[2]+=1
else:
print("err")
a.sort(reverse=True)
cur %=mod
print(cur)
return
def examF():
return
import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')
examE(mod)
|
def examE(mod):
N = I()
A = LI()
a =[0,0,0]
cur = 1
for i in A:
if a[0]==i:
if a[0]==a[1]:
if a[1]==a[2]:
cur *= 3
else:
cur *=2
a[0]+=1
elif a[1]==i:
if a[1] == a[2]:
cur *= 2
a[1] +=1
elif a[2]==i:
a[2]+=1
else:
cur *=0
a.sort(reverse=True)
cur %=mod
print(cur)
return
def examF():
return
import sys,copy,bisect,itertools,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')
examE(mod)
|
[
"call.arguments.change"
] | 651,565
| 651,566
|
u638795007
|
python
|
p02845
|
MOD = 10**9+7
N = int(input())
count = [0] * 3
ans = 1
A = [int(x) for x in input().split()]
for i in range(N):
sames = 0
for j in range(3):
if A[i] == count[j]:
sames += 1
if sames == 0:
break
ans *= sames
ans %= MOD
for j in range(3):
if A[i] == count[j]:
count[j] += 1
break
print(ans)
|
MOD = 10**9+7
N = int(input())
count = [0] * 3
ans = 1
A = [int(x) for x in input().split()]
for i in range(N):
sames = 0
for j in range(3):
if A[i] == count[j]:
sames += 1
if sames == 0:
ans = 0
break
ans *= sames
ans %= MOD
for j in range(3):
if A[i] == count[j]:
count[j] += 1
break
print(ans)
|
[
"assignment.add"
] | 651,622
| 651,623
|
u118642796
|
python
|
p02845
|
MOD = 10**9+7
N = int(input())
count = [0] * 3
ans = 1
A = [int(x) for x in input().split()]
for i in range(N):
sames = 0
for j in range(3):
if A[i] == count[j]:
sames += 1
if sames == 0:
print(0)
break
ans *= sames
ans %= MOD
for j in range(3):
if A[i] == count[j]:
count[j] += 1
break
print(ans)
|
MOD = 10**9+7
N = int(input())
count = [0] * 3
ans = 1
A = [int(x) for x in input().split()]
for i in range(N):
sames = 0
for j in range(3):
if A[i] == count[j]:
sames += 1
if sames == 0:
ans = 0
break
ans *= sames
ans %= MOD
for j in range(3):
if A[i] == count[j]:
count[j] += 1
break
print(ans)
|
[
"call.arguments.change"
] | 651,624
| 651,623
|
u118642796
|
python
|
p02845
|
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
cnt = [0] * (max(A) + 2)
cnt[-1] = 1
ans = 1
for a in A:
if a == 0:
cnt[0] += 1
continue
ans = (ans * (cnt[a - 1] - cnt[a])) % mod
cnt[a] += 1
if max(cnt) == 1:
print((ans*3) % mod)
elif max(cnt) == 3:
print((ans * 6) % mod)
elif max(cnt) == 2:
print((ans * 3) % mod)
else:
print(0)
|
N = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
cnt = [0] * (max(A) + 2)
cnt[-1] = 1
ans = 1
for a in A:
if a == 0:
cnt[0] += 1
continue
ans = (ans * (cnt[a - 1] - cnt[a])) % mod
cnt[a] += 1
if max(cnt) == 1:
print((ans*3) % mod)
elif max(cnt) == 3:
print((ans * 6) % mod)
elif max(cnt) == 2:
print((ans * 6) % mod)
else:
print(0)
|
[
"literal.number.integer.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 651,643
| 651,644
|
u892251744
|
python
|
p02846
|
T1, T2=(int(i) for i in input().split())
A1, A2=(int(i) for i in input().split())
B1, B2=(int(i) for i in input().split())
if T1*A1+T2*A2==T1*B1+T2*B2:
print("infinity")
elif ((A1>B1) & (T1*A1+T2*A2-(T1*B1+T2*B2)>0)) or ((A1<B1) & (T1*A1+T2*A2-(T1*B1+T2*B2)<0)):
print(0)
else:
d=T1*A1+T2*A2-(T1*B1+T2*B2)#T1+T2だけ走った後離れている距離
ss=0
if abs(T1*(A1-B1))%d==0:
ss=1
print(abs(T1*(A1-B1))//d*2-ss+1)
|
T1, T2=(int(i) for i in input().split())
A1, A2=(int(i) for i in input().split())
B1, B2=(int(i) for i in input().split())
if T1*A1+T2*A2==T1*B1+T2*B2:
print("infinity")
elif ((A1>B1) & (T1*A1+T2*A2-(T1*B1+T2*B2)>0)) or ((A1<B1) & (T1*A1+T2*A2-(T1*B1+T2*B2)<0)):
print(0)
else:
d=abs(T1*A1+T2*A2-(T1*B1+T2*B2))#T1+T2だけ走った後離れている距離
ss=0
if abs(T1*(A1-B1))%d==0:
ss=1
print(abs(T1*(A1-B1))//d*2-ss+1)
|
[
"call.add",
"call.arguments.change"
] | 651,666
| 651,667
|
u069172538
|
python
|
p02846
|
T1, T2=(int(i) for i in input().split())
A1, A2=(int(i) for i in input().split())
B1, B2=(int(i) for i in input().split())
if T1*A1+T2*A2==T1*B1+T2*B2:
print("infinity")
elif ((A1>B1) & (T1*A1+T2*A2-(T1*B1+T2*B2)>0)) or ((A1<B1) & (T1*A1+T2*A2-(T1*B1+T2*B2)<0)):
print(0)
else:
d=T1*A1+T2*A2-(T1*B1+T2*B2)#T1+T2だけ走った後離れている距離
if abs(T1*(A1-B1))%d==0:
ss=1
print(abs(T1*(A1-B1))//d*2-ss+1)
|
T1, T2=(int(i) for i in input().split())
A1, A2=(int(i) for i in input().split())
B1, B2=(int(i) for i in input().split())
if T1*A1+T2*A2==T1*B1+T2*B2:
print("infinity")
elif ((A1>B1) & (T1*A1+T2*A2-(T1*B1+T2*B2)>0)) or ((A1<B1) & (T1*A1+T2*A2-(T1*B1+T2*B2)<0)):
print(0)
else:
d=abs(T1*A1+T2*A2-(T1*B1+T2*B2))#T1+T2だけ走った後離れている距離
ss=0
if abs(T1*(A1-B1))%d==0:
ss=1
print(abs(T1*(A1-B1))//d*2-ss+1)
|
[
"call.add",
"call.arguments.change"
] | 651,668
| 651,667
|
u069172538
|
python
|
p02846
|
T1,T2=[int(i) for i in input().split()]
A1,A2=[int(i) for i in input().split()]
B1,B2=[int(i) for i in input().split()]
if((B1-A1)*((B1-A1)*T1+(B2-A2)*T2)>0):
print(0);
exit();
if((B1-A1)*T1+(B2-A2)*T2==0):
print("infinity")
exit();
ans=(abs((B1-A1)*T1)/abs((B1-A1)*T1+(B2-A2)*T2))*2+1
if(abs((B1-A1)*T1)%abs((B1-A1)*T1+(B2-A2)*T2)==0):
ans-=1
print(int(ans))
|
T1,T2=[int(i) for i in input().split()]
A1,A2=[int(i) for i in input().split()]
B1,B2=[int(i) for i in input().split()]
if((B1-A1)*((B1-A1)*T1+(B2-A2)*T2)>0):
print(0);
exit();
if((B1-A1)*T1+(B2-A2)*T2==0):
print("infinity")
exit();
ans=(abs((B1-A1)*T1)//abs((B1-A1)*T1+(B2-A2)*T2))*2+1
if(abs((B1-A1)*T1)%abs((B1-A1)*T1+(B2-A2)*T2)==0):
ans-=1
print(ans)
|
[
"expression.operator.arithmetic.change",
"assignment.value.change",
"expression.operation.binary.change",
"call.remove",
"call.arguments.change"
] | 651,687
| 651,688
|
u236193715
|
python
|
p02846
|
from decimal import Decimal
T = tuple(map(Decimal, input().split()))
A = list(map(Decimal, input().split()))
B = list(map(Decimal, input().split()))
ans = 0
if A[0] < B[0]:
tmp = (A[0], A[1])
A[0], A[1] = B[0], B[1]
B[0], B[1] = tmp[0], tmp[1]
a = abs(T[0]*A[0] - T[0]*B[0])
b = T[0]*(B[0]-A[0])+T[1]*(B[1]-A[1])
if b == 0:
print("Infinity")
elif b < 0:
print(0)
exit(0)
else:
ans += 1
if b > a:
print(1)
elif b == a:
print("infinity")
else:
if a % b == 0:
print((a//b)*2)
else:
print((a//b)*2 + 1)
|
from decimal import Decimal
T = tuple(map(Decimal, input().split()))
A = list(map(Decimal, input().split()))
B = list(map(Decimal, input().split()))
ans = 0
if A[0] < B[0]:
tmp = (A[0], A[1])
A[0], A[1] = B[0], B[1]
B[0], B[1] = tmp[0], tmp[1]
a = abs(T[0]*A[0] - T[0]*B[0])
b = T[0]*(B[0]-A[0])+T[1]*(B[1]-A[1])
if b == 0:
print("infinity")
elif b < 0:
print(0)
exit(0)
else:
ans += 1
if b > a:
print(1)
elif b == a:
print("infinity")
else:
if a % b == 0:
print((a//b)*2)
else:
print((a//b)*2 + 1)
|
[
"literal.string.change",
"literal.string.case.change",
"call.arguments.change",
"io.output.change"
] | 651,699
| 651,700
|
u814986259
|
python
|
p02846
|
from math import floor
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
diff1 = (a1 - b1) * t1
diff2 = (a2 - b2) * t2
diff = diff1 + diff2
if diff1 * diff > 0:
print("0")
elif diff == 0:
print("infinity")
else:
diff1 = abs(diff1)
diff2 = abs(diff2)
n = diff2 / (diff2 - diff1)
if n == floor(n):
n = floor(n)
ans = 2 * n - 3
else:
n = floor(n)
ans = 2 * n - 1
print(ans)
|
from math import floor
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
diff1 = (a1 - b1) * t1
diff2 = (a2 - b2) * t2
diff = diff1 + diff2
if diff1 * diff > 0:
print("0")
elif diff == 0:
print("infinity")
else:
diff1 = abs(diff1)
diff2 = abs(diff2)
n = diff2 / (diff2 - diff1)
if n == floor(n):
n = floor(n)
ans = 2 * n - 2
else:
n = floor(n)
ans = 2 * n - 1
print(ans)
|
[
"literal.number.integer.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 651,704
| 651,705
|
u893063840
|
python
|
p02846
|
#F
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
l1 = (a1-b1)*t1
l2 = (a2-b2)*t2
if (l1+l2)==0:
print('infinity')
elif (l1>0)*(l1+l2)>0:
print(0)
else:
zure = abs(l1+l2)
oitsuki = abs(l1)
n = oitsuki//zure
if n * zure == oitsuki:
print(2*n)
else:
print(2*n+1)
|
#F
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
l1 = (a1-b1)*t1
l2 = (a2-b2)*t2
if (l1+l2)==0:
print('infinity')
elif (l1)*(l1+l2)>0:
print(0)
else:
zure = abs(l1+l2)
oitsuki = abs(l1)
n = oitsuki//zure
if n * zure == oitsuki:
print(2*n)
else:
print(2*n+1)
|
[] | 651,725
| 651,726
|
u602544363
|
python
|
p02846
|
#%%
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
x = (a1-b1) * t1
y = x + (a2-b2) * t2
#print(x, y)
def p(x, y):
if x%y == 0:
return abs(x//y)
else:
return abs(x//y) + 1
if y == 0:
ans = 'infinity'
else:
if x%y != 0:
if x < 0 and y > 0 :
ans = (abs(x//y) + 1) * 2 - 3
elif x > 0 and y < 0 :
ans = (abs(x//y) + 1) * 2 - 2
else:
ans = 0
else:
if x < 0 and y > 0 :
ans = (abs(x//y) + 1) * 2 - 1
elif x > 0 and y < 0 :
ans = (abs(x//y) + 1) * 2 - 1
else:
ans = 0
print(ans)
|
#%%
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
x = (a1-b1) * t1
y = x + (a2-b2) * t2
#print(x, y)
def p(x, y):
if x%y == 0:
return abs(x//y)
else:
return abs(x//y) + 1
if y == 0:
ans = 'infinity'
else:
if x%y != 0:
if x < 0 and y > 0 :
ans = (abs(x//y) + 1) * 2 - 3
elif x > 0 and y < 0 :
ans = (abs(x//y) + 1) * 2 - 3
else:
ans = 0
else:
if x < 0 and y > 0 :
ans = (abs(x//y) + 1) * 2 - 2
elif x > 0 and y < 0 :
ans = (abs(x//y) + 1) * 2 - 2
else:
ans = 0
print(ans)
|
[
"literal.number.integer.change",
"assignment.value.change",
"expression.operation.binary.change"
] | 651,741
| 651,742
|
u921773161
|
python
|
p02846
|
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
import math
f = (a1-b1)*t1
s = (a2-b2)*t2
if f == -s:
print("infinity")
elif (f>0 and s>0) or (f<0 and s<0):
print(0)
elif f//(-(f+s)) == math.ceil(f/(-(f+s))):
print(f//(-(f+s))*2)
else:
print(f//(-(f+s))*2+1)
|
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
import math
f = (a1-b1)*t1
s = (a2-b2)*t2
if f == -s:
print("infinity")
elif (f>0 and f+s>0) or (f<0 and f+s<0):
print(0)
elif f//(-(f+s)) == math.ceil(f/(-(f+s))):
print(f//(-(f+s))*2)
else:
print(f//(-(f+s))*2+1)
|
[
"control_flow.branch.if.condition.change"
] | 651,773
| 651,774
|
u881116515
|
python
|
p02846
|
t1,t2=map(int, input().split())
a1,a2=map(int, input().split())
b1,b2=map(int, input().split())
a1*=t1
a2*=t2
b1*=t1
b2*=t2
if a1<b1:
a1,a2,b1,b2=b1,b2,a1,a2
#a1>b2
if a1+a2==b1+b2:
print('infinity')
exit()
a1-=b1;b2-=a2
b2-=a1
if b2<0:
print(0)
exit()
ans=1+(a1//b2)*2
if a1%b2==0:
ans+=1
print(ans)
|
t1,t2=map(int, input().split())
a1,a2=map(int, input().split())
b1,b2=map(int, input().split())
a1*=t1
a2*=t2
b1*=t1
b2*=t2
if a1<b1:
a1,a2,b1,b2=b1,b2,a1,a2
#a1>b2
if a1+a2==b1+b2:
print('infinity')
exit()
a1-=b1;b2-=a2
b2-=a1
if b2<0:
print(0)
exit()
ans=1+(a1//b2)*2
if a1%b2==0:
ans-=1####
print(ans)
|
[
"expression.operator.change"
] | 651,798
| 651,799
|
u520276780
|
python
|
p02846
|
t1,t2=map(int, input().split())
a1,a2=map(int, input().split())
b1,b2=map(int, input().split())
a1*=t1
a2*=t2
b1*=t1
b2*=t2
if a1<b1:
a1,a2,b1,b2=b1,b2,a1,a2
#a1>b2
if a1+a2==b1+b2:
print('infinity')
exit()
a1-=b1;b2-=a2
b2-=a1
if b2<0:
print(1)
exit()
ans=1+(a1//b2)*2
if a1%b2==0:
ans+=1
print(ans)
|
t1,t2=map(int, input().split())
a1,a2=map(int, input().split())
b1,b2=map(int, input().split())
a1*=t1
a2*=t2
b1*=t1
b2*=t2
if a1<b1:
a1,a2,b1,b2=b1,b2,a1,a2
#a1>b2
if a1+a2==b1+b2:
print('infinity')
exit()
a1-=b1;b2-=a2
b2-=a1
if b2<0:
print(0)
exit()
ans=1+(a1//b2)*2
if a1%b2==0:
ans-=1####
print(ans)
|
[
"literal.number.integer.change",
"call.arguments.change",
"io.output.change",
"expression.operator.change"
] | 651,800
| 651,799
|
u520276780
|
python
|
p02846
|
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
ave_a, ave_b = t1 * a1 + t2 * a2, t1 * b1 + t2 * b2
if ave_a < ave_b:
a1, a2, b1, b2 = b1, b2, a1, a2
ave_a, ave_b = ave_b, ave_a
if ave_a == ave_b:
print('infinity')
exit()
first, second = t1 * (b1 - a1), ave_a - ave_b
ans = first // second * 2 + (first % second != 0)
print(ans)
|
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
ave_a, ave_b = t1 * a1 + t2 * a2, t1 * b1 + t2 * b2
if ave_a < ave_b:
a1, a2, b1, b2 = b1, b2, a1, a2
ave_a, ave_b = ave_b, ave_a
if ave_a == ave_b:
print('infinity')
exit()
first, second = t1 * (b1 - a1), ave_a - ave_b
ans = first // second * 2 + (first % second != 0)
print(max(0, ans))
|
[
"call.add",
"call.arguments.change"
] | 651,809
| 651,810
|
u222668979
|
python
|
p02846
|
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10
T1, T2 = MAP()
A1, A2 = MAP()
B1, B2 = MAP()
if (A1-B1)*T1 + (A2-B2)*T2 == 0:
print("infinity")
elif 0 < ((A1-B1)*T1) * ((A1-B1)*T1 + (A2-B2)*T2):
print(0)
else:
p = A1*T1-B1*T1
q = 2*A1*T1+A2*T2-2*B1*T1-B2*T2
if p*q < 0:
print(1)
if p%(p-q):
print(2*(p//(p-q))+ 1)
else:
print(2*(p//(p-q)))
|
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10
T1, T2 = MAP()
A1, A2 = MAP()
B1, B2 = MAP()
if (A1-B1)*T1 + (A2-B2)*T2 == 0:
print("infinity")
elif 0 < ((A1-B1)*T1) * ((A1-B1)*T1 + (A2-B2)*T2):
print(0)
else:
p = A1*T1-B1*T1
q = 2*A1*T1+A2*T2-2*B1*T1-B2*T2
if p*q < 0:
print(1)
elif p%(p-q):
print(2*(p//(p-q))+ 1)
else:
print(2*(p//(p-q)))
|
[
"control_flow.branch.if.replace.remove",
"control_flow.branch.else_if.replace.add"
] | 651,811
| 651,812
|
u285891772
|
python
|
p02846
|
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
d1 = t1 * (a1 - b1)
d2 = t2 * (a2 - b2)
if d1 > 0:
d1 *= -1
d2 *= -1
if d1 + d2 == 0:
print("infinity")
elif d1 + d2 < 0:
print(0)
else:
cnt = -d1 // (d1 + d2)
t = -d1 % (d1 + d2)
ans = 1 + 2 * cnt + int(t == 0)
print(ans)
|
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())
d1 = t1 * (a1 - b1)
d2 = t2 * (a2 - b2)
if d1 > 0:
d1 *= -1
d2 *= -1
if d1 + d2 == 0:
print("infinity")
elif d1 + d2 < 0:
print(0)
else:
cnt = -d1 // (d1 + d2)
t = -d1 % (d1 + d2)
ans = 2 * cnt + int(t != 0)
print(ans)
|
[
"expression.operation.binary.remove",
"misc.opposites",
"expression.operator.compare.change",
"assignment.value.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 651,825
| 651,826
|
u057109575
|
python
|
p02846
|
T1, T2 = list(map(int, input().split()))
A1, A2 = list(map(int, input().split()))
B1, B2 = list(map(int, input().split()))
L1 = T1 * (A1- B1)
L2 = L1 + T2 * (A2- B2)
if L1 * L2 > 0:
print(0)
elif L2 == 0:
print("infinity")
else:
M = (-L1) / L2
ans = 2 * M + 1
if float(int(M)) == M:
ans -= 1
print(ans)
|
T1, T2 = list(map(int, input().split()))
A1, A2 = list(map(int, input().split()))
B1, B2 = list(map(int, input().split()))
L1 = T1 * (A1- B1)
L2 = L1 + T2 * (A2- B2)
if L1 * L2 > 0:
print(0)
elif L2 == 0:
print("infinity")
else:
M = (-L1) / L2
ans = 2 * int(M) + 1
if float(int(M)) == M:
ans -= 1
print(ans)
|
[
"call.add",
"call.arguments.change"
] | 651,853
| 651,854
|
u896004073
|
python
|
p02846
|
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
def main():
t1,t2 = map(int,ipt().split())
a1,a2 = map(int,ipt().split())
b1,b2 = map(int,ipt().split())
d1 = t1*(a1-b1)
d2 = t2*(a2-b2)
if d1*d2 > 0:
print(0)
elif d1+d2 == 0:
print("infinity")
else:
dt = d1+d2
if abs(d1)%abs(dt):
print(abs(d1)//abs(dt)*2+1)
else:
print(abs(d1)//abs(dt)*2)
return None
if __name__ == '__main__':
main()
|
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
def main():
t1,t2 = map(int,ipt().split())
a1,a2 = map(int,ipt().split())
b1,b2 = map(int,ipt().split())
d1 = t1*(a1-b1)
d2 = t2*(a2-b2)
if d1*(d1+d2) > 0:
print(0)
elif d1+d2 == 0:
print("infinity")
else:
dt = d1+d2
if abs(d1)%abs(dt):
print(abs(d1)//abs(dt)*2+1)
else:
print(abs(d1)//abs(dt)*2)
return None
if __name__ == '__main__':
main()
|
[
"control_flow.branch.if.condition.change"
] | 651,855
| 651,856
|
u169350228
|
python
|
p02846
|
import sys
sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7
def input():
return sys.stdin.readline().strip()
def main():
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
A = A1 * T1 + A2 * T2
B = B1 * T1 + B2 * T2
if A1 < B1 and A2 < B2:
print(0)
return
if A1 > B1 and A2 > B2:
print(0)
return
if A == B:
print("infinity")
return
# T1 + T2 分後にできる差
diff = abs(A - B)
if T1 * abs(A1 - B1) % diff == 0:
ans = T1 * abs(A1 - B1) // diff * 2
else:
ans = T1 * abs(A1 - B1) // diff * 2 + 1
print(ans)
if __name__ == "__main__":
main()
|
import sys
sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7
def input():
return sys.stdin.readline().strip()
def main():
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
A = A1 * T1 + A2 * T2
B = B1 * T1 + B2 * T2
if A1 < B1 and A < B:
print(0)
return
if A1 > B1 and A > B:
print(0)
return
if A == B:
print("infinity")
return
# T1 + T2 分後にできる差
diff = abs(A - B)
if T1 * abs(A1 - B1) % diff == 0:
ans = T1 * abs(A1 - B1) // diff * 2
else:
ans = T1 * abs(A1 - B1) // diff * 2 + 1
print(ans)
if __name__ == "__main__":
main()
|
[
"identifier.change",
"control_flow.branch.if.condition.change"
] | 651,869
| 651,870
|
u346812984
|
python
|
p02846
|
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
t1,t2 = map(int, input().split())
a1,a2 = map(int, input().split())
b1,b2 = map(int, input().split())
a1 *= t1
a2 *= t2
b1 *= t1
b2 *= t2
if a1+a2==b1+b2:
ans = "infinity"
else:
if a1+a2 < b1+b2:
a1,a2,b1,b2 = b1,b2,a1,a2
# a1+a2が大きい
if a1>b1:
ans = 0
else:
ans = ((b1-a1) // (a1+a2-b1-b2)) * 2 + 1
if (b1-a1) % (a1+a2-b1-b2) ==0:
ans += 1
print(ans)
|
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")
t1,t2 = map(int, input().split())
a1,a2 = map(int, input().split())
b1,b2 = map(int, input().split())
a1 *= t1
a2 *= t2
b1 *= t1
b2 *= t2
if a1+a2==b1+b2:
ans = "infinity"
else:
if a1+a2 < b1+b2:
a1,a2,b1,b2 = b1,b2,a1,a2
# a1+a2が大きい
if a1>b1:
ans = 0
else:
ans = ((b1-a1) // (a1+a2-b1-b2)) * 2 + 1
if (b1-a1) % (a1+a2-b1-b2) ==0:
ans -= 1
print(ans)
|
[
"expression.operator.change"
] | 651,878
| 651,879
|
u535803878
|
python
|
p02846
|
t = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
f_a = t[0]*a[0]
f_b = t[0]*b[0]
if f_a < f_b:
x = 1
else:
x = -1
s_a = f_a + t[1]*a[1]
s_b = f_b + t[1]*b[1]
if s_a < s_b:
y = 1
else:
y = -1
if s_a==s_b:
print('infinity')
else:
if x==y:
print(0)
else:
s = abs(f_a-f_b)
t = abs(s_a-s_b)
print(1+(s//t*2)+(s%t==0))
|
t = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
f_a = t[0]*a[0]
f_b = t[0]*b[0]
if f_a < f_b:
x = 1
else:
x = -1
s_a = f_a + t[1]*a[1]
s_b = f_b + t[1]*b[1]
if s_a < s_b:
y = 1
else:
y = -1
if s_a==s_b:
print('infinity')
else:
if x==y:
print(0)
else:
s = abs(f_a-f_b)
t = abs(s_a-s_b)
print((s//t*2)+(s%t!=0))
|
[
"expression.operation.binary.remove",
"misc.opposites",
"expression.operator.compare.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 651,889
| 651,890
|
u413165887
|
python
|
p02846
|
import sys
input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def main():
mod=10**9+7
T=LI()
A=LI()
B=LI()
SA=T[1]*A[1]+T[0]*A[0]
SB=T[1]*B[1]+T[0]*B[0]
if SA == SB:
print("infinity")
else:
if SB>SA:
SB,SA=SA,SB
A,B=B,A
#t1+t2分後に確実にAが先行するように.
if A[0]>B[0]:
print(0)
else:
diff1=(B[0]-A[0])*T[0]
diff2=SA-SB
cnt=(diff1//diff2+1)
ans=(cnt)*2-1
#基本,1ループで2回,初回は0,0のため-1
#さらに,cnt回目のループでぎり1回だけという場合があるので,その場合は1ひく
if diff2*(cnt-1) == diff1*cnt:
ans-=1
print(ans)
main()
|
import sys
input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def main():
mod=10**9+7
T=LI()
A=LI()
B=LI()
SA=T[1]*A[1]+T[0]*A[0]
SB=T[1]*B[1]+T[0]*B[0]
if SA == SB:
print("infinity")
else:
#t1+t2分後に確実にAが先行するように.
if SB>SA:
SB,SA=SA,SB
A,B=B,A
if A[0]>=B[0]:
print(0)
else:
diff1=(B[0]-A[0])*T[0]
diff2=SA-SB
cnt=(diff1//diff2+1)
ans=(cnt)*2-1
#基本,1ループで2回,初回は0,0のため-1
#さらに,cnt回目のループでぎり1回だけという場合があるので,その場合は1ひく
if diff2*(cnt-1) == diff1:
ans-=1
print(ans)
main()
|
[
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove"
] | 651,911
| 651,912
|
u498487134
|
python
|
p02846
|
import sys
input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def main():
mod=10**9+7
T=LI()
A=LI()
B=LI()
d1=(A[0]-B[0])*T[0]
d2=(A[1]-B[1])*T[1]
if d1>=0:
#最初は必ず正の方向へいかないように調整
d1*=-1
d2*=-1
if d1+d2==0:
print("infinity")
elif d1==0:#d1=0のパターンを排除した
print(0)
elif d2<=0:
print("0")
else:
cnt=(-1*d1)//(d1+d2)
ans=cnt*2+1
if cnt*(d1+d2)==-1*d1:
ans-=1
print(ans)
main()
|
import sys
input = sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def main():
mod=10**9+7
T=LI()
A=LI()
B=LI()
d1=(A[0]-B[0])*T[0]
d2=(A[1]-B[1])*T[1]
if d1>=0:
#最初は必ず正の方向へいかないように調整
d1*=-1
d2*=-1
if d1+d2==0:
print("infinity")
elif d1==0:#d1=0のパターンを排除した
print(0)
elif d1+d2<=0:
print(0)
else:
cnt=(-1*d1)//(d1+d2)
ans=cnt*2+1
if cnt*(d1+d2)==-1*d1:
ans-=1
print(ans)
main()
|
[
"control_flow.branch.if.condition.change",
"call.arguments.change"
] | 651,913
| 651,914
|
u498487134
|
python
|
p02846
|
import numpy as np
t1,t2 = map(int, input().split())
a1,a2 = map(int, input().split())
b1,b2 = map(int, input().split())
# まず大きい方にswap
if a1 <= b1:
a1,b1 = b1,a1
a2,b2 = b2,a2
# t1での距離
x1 = a1*t1 - b1*t1
# t2での距離
x2 = x1 + a2*t2 - b2*t2
if x2 == 0:
print("infinity")
elif x2 > 0:
print(0)
else:
ans = int(np.ceil(x1/abs(x2))*2-1)
if x1 % abs(x2) == 0:
ans -= 1
print(ans)
|
import numpy as np
t1,t2 = map(int, input().split())
a1,a2 = map(int, input().split())
b1,b2 = map(int, input().split())
# まず大きい方にswap
if a1 <= b1:
a1,b1 = b1,a1
a2,b2 = b2,a2
# t1での距離
x1 = a1*t1 - b1*t1
# t2での距離
x2 = x1 + a2*t2 - b2*t2
if x2 == 0:
print("infinity")
elif x2 > 0:
print(0)
else:
ans = int(np.ceil(x1/abs(x2))*2)
if x1 % abs(x2) != 0:
ans -= 1
print(ans)
|
[
"expression.operation.binary.remove",
"misc.opposites",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 651,923
| 651,924
|
u545368057
|
python
|
p02846
|
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
res = list(sys.stdin.readline())
if res[-1] == "\n":
return res[:-1]
return res
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007
def solve():
t = LI()
a = LI()
b = LI()
a[0] -= b[0]
a[1] -= b[1]
if t[0]*a[0] == -t[1]*a[1]:
print("infinity")
return
if a[0] < 0:
a[0] *= -1
a[1] *= -1
if t[0]*a[0]+t[1]*a[1] > 0:
print(0)
return
A = t[0]*a[0]+t[1]*a[1]
k = t[0]*a[0]
l = 0
r = 10**20
while r-l > 1:
x = (l+r) >> 1
if A*x+k > 0:
l = x
else:
r = x
ans = 2*l+1
if A*r+k == 0:
ans -= 1
print(ans)
return
#Solve
if __name__ == "__main__":
solve()
|
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
res = list(sys.stdin.readline())
if res[-1] == "\n":
return res[:-1]
return res
def IR(n):
return [I() for i in range(n)]
def LIR(n):
return [LI() for i in range(n)]
def SR(n):
return [S() for i in range(n)]
def LSR(n):
return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007
def solve():
t = LI()
a = LI()
b = LI()
a[0] -= b[0]
a[1] -= b[1]
if t[0]*a[0] == -t[1]*a[1]:
print("infinity")
return
if a[0] < 0:
a[0] *= -1
a[1] *= -1
if t[0]*a[0]+t[1]*a[1] > 0:
print(0)
return
A = t[0]*a[0]+t[1]*a[1]
k = t[0]*a[0]
l = 0
r = 10**20
while r-l > 1:
x = (l+r) >> 1
if A*x+k > 0:
l = x
else:
r = x
ans = 2*l+1
if A*r+k == 0:
ans += 1
print(ans)
return
#Solve
if __name__ == "__main__":
solve()
|
[
"expression.operator.change"
] | 651,928
| 651,929
|
u585482323
|
python
|
p02845
|
_,a=open(0)
c=1
d=[3]+[0]*10**6
for a in map(int,a.split()):
c=c*d[a]%(10**9+7)
d[a]-=1
d[a]+=1
print(c)
|
_,a=open(0)
c=1
d=[3]+[0]*10**6
for a in map(int,a.split()):
c=c*d[a]%(10**9+7)
d[a]-=1
d[a+1]+=1
print(c)
|
[
"expression.operation.binary.add"
] | 651,950
| 651,951
|
u729133443
|
python
|
p02845
|
_,a=open(0)
c=1
d=[3]+[0]*10**6
for a in map(int,a.split()):
c=c*dp[a]%(10**9+7)
d[a]-=1
d[a]+=1
print(c)
|
_,a=open(0)
c=1
d=[3]+[0]*10**6
for a in map(int,a.split()):
c=c*d[a]%(10**9+7)
d[a]-=1
d[a+1]+=1
print(c)
|
[
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change"
] | 651,952
| 651,951
|
u729133443
|
python
|
p02845
|
import sys
input = sys.stdin.readline
def main():
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
cnt = [[0, 0, 0] for i in range(N+1)]
ans = 1
for i in range(N-1):
a = A[i]
ans = ans * cnt[i].count(a) % mod
for j in range(3):
cnt[i+1][j] = cnt[i][j]
for j in range(3):
if cnt[i][j] == a:
cnt[i+1][j] = a+1
break
print(ans)
if __name__ == '__main__':
main()
|
import sys
input = sys.stdin.readline
def main():
mod = 1000000007
N = int(input())
A = list(map(int, input().split()))
cnt = [[0, 0, 0] for i in range(N+1)]
ans = 1
for i in range(N):
a = A[i]
ans = ans * cnt[i].count(a) % mod
for j in range(3):
cnt[i+1][j] = cnt[i][j]
for j in range(3):
if cnt[i][j] == a:
cnt[i+1][j] = a+1
break
print(ans)
if __name__ == '__main__':
main()
|
[
"expression.operation.binary.remove"
] | 651,990
| 651,991
|
u076917070
|
python
|
p02845
|
N = int(input)
A = list(map(int, input().split()))
L = [0 for i in range(max(A)+2)]
ans = 1
L[0] = 3
p = 10 ** 9 + 7
for i in range(N):
ai = A[i]
ans *= (L[ai] - L[ai + 1])
ans = ans % p
L[ai + 1] += 1
print(ans)
|
N = int(input())
A = list(map(int, input().split()))
L = [0 for i in range(max(A)+2)]
ans = 1
L[0] = 3
p = 10 ** 9 + 7
for i in range(N):
ai = A[i]
ans *= (L[ai] - L[ai + 1])
ans = ans % p
L[ai + 1] += 1
print(ans)
|
[
"call.add"
] | 651,992
| 651,993
|
u729008627
|
python
|
p02845
|
import numpy as np
i8 = np.int64
i4 = np.int32
def solve(A, N):
MOD = 1000000007
x = 0
y = 0
z = 0
count = 1
for i in range(N):
if A[i] == x:
if x == y and x == z:
count = (count * 3) % MOD
elif x == y:
count = (count * 2) % MOD
x += 1
elif A[i] == y:
if y == z:
count = (count * 2) % MOD
y += 1
elif A[i] == z:
z += 1
else:
A[N] = 1
return count
def main2():
stdin = open('/dev/stdin')
N = int(stdin.readline())
A = np.empty(N, i8)
for i, c in enumerate(map(int, stdin.readline().split())):
A[i] = c
print(solve(A, N))
main2()
|
import numpy as np
i8 = np.int64
i4 = np.int32
def solve(A, N):
MOD = 1000000007
x = 0
y = 0
z = 0
count = 1
for i in range(N):
if A[i] == x:
if x == y and x == z:
count = (count * 3) % MOD
elif x == y:
count = (count * 2) % MOD
x += 1
elif A[i] == y:
if y == z:
count = (count * 2) % MOD
y += 1
elif A[i] == z:
z += 1
else:
return 0
return count
def main2():
stdin = open('/dev/stdin')
N = int(stdin.readline())
A = np.empty(N, i8)
for i, c in enumerate(map(int, stdin.readline().split())):
A[i] = c
print(solve(A, N))
main2()
|
[
"assignment.remove"
] | 651,996
| 651,997
|
u326609687
|
python
|
p02845
|
import numpy as np
i8 = np.int64
i4 = np.int32
def solve(A, N):
MOD = 1000000007
x = 0
y = 0
z = 0
count = 1
for i in range(N):
if A[i] == x:
if x == y and x == z:
count = (count * 3) % MOD
elif x == y:
count = (count * 2) % MOD
x += 1
elif A[i] == y:
if y == z:
count = (count * 2) % MOD
y += 1
elif A[i] == z:
z += 1
return count
def main2():
stdin = open('/dev/stdin')
N = int(stdin.readline())
A = np.empty(N, i8)
for i, c in enumerate(map(int, stdin.readline().split())):
A[i] = c
print(solve(A, N))
main2()
|
import numpy as np
i8 = np.int64
i4 = np.int32
def solve(A, N):
MOD = 1000000007
x = 0
y = 0
z = 0
count = 1
for i in range(N):
if A[i] == x:
if x == y and x == z:
count = (count * 3) % MOD
elif x == y:
count = (count * 2) % MOD
x += 1
elif A[i] == y:
if y == z:
count = (count * 2) % MOD
y += 1
elif A[i] == z:
z += 1
else:
return 0
return count
def main2():
stdin = open('/dev/stdin')
N = int(stdin.readline())
A = np.empty(N, i8)
for i, c in enumerate(map(int, stdin.readline().split())):
A[i] = c
print(solve(A, N))
main2()
|
[
"control_flow.return.add"
] | 651,998
| 651,997
|
u326609687
|
python
|
p02845
|
N = int(input())
A = list(map(int, input().split()))
c = [-1, -1 ,-1]
sum = 1
tmp = 0
for a in A:
sum = sum * c.count(A-1) % 1000000007
if A-1 == c[0]:
c[0] += 1
tmp = c.count(c[0] - 1) + 1
elif A-1 == c[1]:
c[1] += 1
tmp = c.count(c[1]-1) + 1
elif A-1 == c[2]:
c[2] += 1
tmp = c.count(c[2] - 1) + 1
print(sum)
|
N = int(input())
A = list(map(int, input().split()))
c = [-1, -1 ,-1]
sum = 1
tmp = 0
for a in A:
sum = sum * c.count(a-1) % 1000000007
if a-1 == c[0]:
c[0] += 1
tmp = c.count(c[0] - 1) + 1
elif a-1 == c[1]:
c[1] += 1
tmp = c.count(c[1]-1) + 1
elif a-1 == c[2]:
c[2] += 1
tmp = c.count(c[2] - 1) + 1
print(sum)
|
[
"assignment.value.change",
"identifier.change",
"call.arguments.change",
"expression.operation.binary.change",
"control_flow.branch.if.condition.change"
] | 652,003
| 652,004
|
u759938562
|
python
|
p02845
|
mod=1000000007
N=int(input())
A=list(map(int,input().split()))
ans=1
c1=c2=c3=0
for Ai in A:
if c1==c2==c3==Ai:
c1+=1
ans=ans*3%mod
elif c1==c2==Ai:
c1+=1
ans=ans*2%mod
elif c2==c3==Ai:
c2+=1
ans=ans*2%mod
elif c1==Ai:
c1+=1
elif c2==Ai:
c2+=1
elif c3==Ai:
c3+=1
print(ans)
|
mod=1000000007
N=int(input())
A=list(map(int,input().split()))
ans=1
c1=c2=c3=0
for Ai in A:
if c1==c2==c3==Ai:
c1+=1
ans=ans*3%mod
elif c1==c2==Ai:
c1+=1
ans=ans*2%mod
elif c2==c3==Ai:
c2+=1
ans=ans*2%mod
elif c1==Ai:
c1+=1
elif c2==Ai:
c2+=1
elif c3==Ai:
c3+=1
else:
ans=0
break
print(ans)
|
[
"control_flow.break.add"
] | 652,025
| 652,026
|
u042802884
|
python
|
p02846
|
"""from collections import *
from itertools import *
from bisect import *
from heapq import *
import math
from fractions import gcd"""
T1,T2=map(int,input().split())
A1,A2=map(int,input().split())
B1,B2=map(int,input().split())
A1*=T1
A2*=T2
B1*=T1
B2*=T2
if A1+A2==B1+B2:
print("infinity")
else:
if A1+A2<B1+B2:
A1,B1=B1,A1
A2,B2=B2,A2
if A1>B1:
print(0)
else:
print(((B1-A1)//(A1+A2-(B1+B2)))*2 +1+(((B1-A1)%(A1+A2-(B1+B2)))==0)*2)
|
"""from collections import *
from itertools import *
from bisect import *
from heapq import *
import math
from fractions import gcd"""
T1,T2=map(int,input().split())
A1,A2=map(int,input().split())
B1,B2=map(int,input().split())
A1*=T1
A2*=T2
B1*=T1
B2*=T2
if A1+A2==B1+B2:
print("infinity")
else:
if A1+A2<B1+B2:
A1,B1=B1,A1
A2,B2=B2,A2
if A1>B1:
print(0)
else:
print(((B1-A1)//(A1+A2-(B1+B2)))*2 +1-(((B1-A1)%(A1+A2-(B1+B2)))==0)*1)
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change",
"literal.number.integer.change"
] | 652,061
| 652,062
|
u779455925
|
python
|
p02846
|
"""from collections import *
from itertools import *
from bisect import *
from heapq import *
import math
from fractions import gcd"""
T1,T2=map(int,input().split())
A1,A2=map(int,input().split())
B1,B2=map(int,input().split())
A1*=T1
A2*=T2
B1*=T1
B2*=T2
if A1+A2==B1+B2:
print("infinity")
else:
if A1+A2<B1+B2:
A1,B1=B1,A1
A2,B2=B2,A2
if A1>B1:
print(0)
else:
print(((B1-A1)//(A1+A2-(B1+B2)))*2 +1+(((B1-A1)%(A1+A2-(B1+B2)))==0)*1)
|
"""from collections import *
from itertools import *
from bisect import *
from heapq import *
import math
from fractions import gcd"""
T1,T2=map(int,input().split())
A1,A2=map(int,input().split())
B1,B2=map(int,input().split())
A1*=T1
A2*=T2
B1*=T1
B2*=T2
if A1+A2==B1+B2:
print("infinity")
else:
if A1+A2<B1+B2:
A1,B1=B1,A1
A2,B2=B2,A2
if A1>B1:
print(0)
else:
print(((B1-A1)//(A1+A2-(B1+B2)))*2 +1-(((B1-A1)%(A1+A2-(B1+B2)))==0)*1)
|
[
"misc.opposites",
"expression.operator.arithmetic.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 652,063
| 652,062
|
u779455925
|
python
|
p02846
|
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
p1 = t1*a1
q1 = t1*b1
p2 = p1+t2*a2
q2 = q1+t2*b2
if p2 == q2:
print("infinity")
exit()
if (p1>q1 and p2>q2) or (p1<q1 and p2<q2):
print(0)
exit()
x = abs(p1-q1)
y = abs(q2-p2)
if x%y == 0:
ans = (x//y)*2-2
else:
ans = (x//y)*2+1
print(ans)
|
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
p1 = t1*a1
q1 = t1*b1
p2 = p1+t2*a2
q2 = q1+t2*b2
if p2 == q2:
print("infinity")
exit()
if (p1>q1 and p2>q2) or (p1<q1 and p2<q2):
print(0)
exit()
x = abs(p1-q1)
y = abs(q2-p2)
if x%y == 0:
ans = (x//y)*2
else:
ans = (x//y)*2+1
print(ans)
|
[
"expression.operation.binary.remove"
] | 652,064
| 652,065
|
u905582793
|
python
|
p02846
|
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
C1 = A1 - B1
C2 = A2 - B2
if C1 > 0:
C1, C2 = -C1, -C2
x1 = C1 * T1 + C2 * T2
x2 = x1 + C1 * T1
if x1 == 0:
print('inifinity')
elif x1 < 0:
print(0)
else:
if 0 < x2:
count = 1
elif 0 == x2:
count = 2
else:
n = (-x2 + x1 - 1) // x1
count = 1 + 2 * n
if x2 % x1 == 0:
count += 1
print(count)
|
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
C1 = A1 - B1
C2 = A2 - B2
if C1 > 0:
C1, C2 = -C1, -C2
x1 = C1 * T1 + C2 * T2
x2 = x1 + C1 * T1
if x1 == 0:
print('infinity')
elif x1 < 0:
print(0)
else:
if 0 < x2:
count = 1
elif 0 == x2:
count = 2
else:
n = (-x2 + x1 - 1) // x1
count = 1 + 2 * n
if x2 % x1 == 0:
count += 1
print(count)
|
[
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 652,098
| 652,099
|
u022488946
|
python
|
p02846
|
#!/usr/bin/env python3
from itertools import combinations
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
t1, t2 = [int(item) for item in input().split()]
a1, a2 = [int(item) for item in input().split()]
b1, b2 = [int(item) for item in input().split()]
a1 *= t1
b1 *= t1
a2 *= t2
b2 *= t2
if a1 + a2 == b1 + b2:
print("infinity")
exit()
if a1 + a2 > b1 + b2:
a1, a2, b1, b2 = b1, b2, a1, a2
diff = (b1 + b2) - (a1 + a2)
mid_diff = b1 - a1
if mid_diff > 0:
print(0)
else:
ans = (abs(mid_diff) + diff-1) // diff * 2 - 1
if abs(mid_diff) % diff == 0:
ans -= 1
print(ans)
|
#!/usr/bin/env python3
from itertools import combinations
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
t1, t2 = [int(item) for item in input().split()]
a1, a2 = [int(item) for item in input().split()]
b1, b2 = [int(item) for item in input().split()]
a1 *= t1
b1 *= t1
a2 *= t2
b2 *= t2
if a1 + a2 == b1 + b2:
print("infinity")
exit()
if a1 + a2 > b1 + b2:
a1, a2, b1, b2 = b1, b2, a1, a2
diff = (b1 + b2) - (a1 + a2)
mid_diff = b1 - a1
if mid_diff > 0:
print(0)
else:
ans = (abs(mid_diff) + diff - 1) // diff * 2
if abs(mid_diff) % diff == 0:
ans += 1
print(ans - 1)
|
[
"expression.operation.binary.remove",
"expression.operator.change"
] | 652,129
| 652,130
|
u052499405
|
python
|
p02846
|
s,t,a,b,x,y=map(int,open(0).read().split())
i=(x-a)*s
j=(b-y)*t-i
print(max(0,i//j*2+(i%j>0))if j else'infinity')
|
s,t,a,b,x,y=map(int,open(0).read().split())
i=(x-a)*s
j=(b-y)*t-i
print(max(0,i//j*2+(i%j!=0))if j else'infinity')
|
[
"expression.operator.compare.change",
"call.arguments.change",
"expression.operation.binary.change",
"io.output.change"
] | 652,155
| 652,156
|
u729133443
|
python
|
p02846
|
# -*- coding: utf-8 -*-
#mitsui f
import sys
import math
import collections
#sys.setrecursionlimit(100000)
#n=int(input())
tmp = input().split()
t1,t2 = list(map(lambda a: int(a), tmp))
tmp = input().split()
a1,a2 = list(map(lambda a: int(a), tmp))
tmp = input().split()
b1,b2 = list(map(lambda a: int(a), tmp))
if(a1*t1+a2*t2==b1*t1+b2*t2):
print("infinity")
sys.exit()
diff=a1*t1+a2*t2-b1*t1+b2*t2
if(diff>0):
c1=a1-b1
c2=a2-b2
else:
c1=b1-a1
c2=b2-a2
if(c1>0):
print("0")
sys.exit()
diff=c1*t1+c2*t2
pitch=c1*t1*-1
ans=pitch//diff*2+1
if(pitch%diff==0):
ans-=1
print(ans)
|
# -*- coding: utf-8 -*-
#mitsui f
import sys
import math
import collections
#sys.setrecursionlimit(100000)
#n=int(input())
tmp = input().split()
t1,t2 = list(map(lambda a: int(a), tmp))
tmp = input().split()
a1,a2 = list(map(lambda a: int(a), tmp))
tmp = input().split()
b1,b2 = list(map(lambda a: int(a), tmp))
if(a1*t1+a2*t2==b1*t1+b2*t2):
print("infinity")
sys.exit()
diff=(a1*t1+a2*t2)-(b1*t1+b2*t2)
if(diff>0):
c1=a1-b1
c2=a2-b2
else:
c1=b1-a1
c2=b2-a2
if(c1>0):
print("0")
sys.exit()
diff=c1*t1+c2*t2
pitch=c1*t1*-1
ans=pitch//diff*2+1
if(pitch%diff==0):
ans-=1
print(ans)
|
[] | 652,170
| 652,171
|
u707870100
|
python
|
p02846
|
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
if a1*t1+a2*t2>=b1*t1+b2*t2:
a1,a2,b1,b2 = b1,b2,a1,a2
d = b1*t1+b2*t2 - (a1*t1+a2*t2)
if d == 0:
print('inifinity')
elif a1*t1<b1*t1:
print(0)
else:
if (a1*t1 - b1*t1)*2%d ==0:
print(((a1*t1 - b1*t1)*2)//d)
else:
print((a1*t1 - b1*t1)//d*2+1)
|
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
if a1*t1+a2*t2>=b1*t1+b2*t2:
a1,a2,b1,b2 = b1,b2,a1,a2
d = b1*t1+b2*t2 - (a1*t1+a2*t2)
if d == 0:
print('infinity')
elif a1*t1<b1*t1:
print(0)
else:
if (a1*t1 - b1*t1)*2%d ==0:
print(((a1*t1 - b1*t1)*2+d-1)//d)
else:
print((a1*t1 - b1*t1)//d*2+1)
|
[
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 652,172
| 652,173
|
u693953100
|
python
|
p02846
|
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
if a1*t1+a2*t2>=b1*t1+b2*t2:
a1,a2,b1,b2 = b1,b2,a1,a2
d = b1*t1+b2*t2 - (a1*t1+a2*t2)
if d == 0:
print('inifinity')
elif a1*t1<b1*t1:
print(0)
else:
if (a1*t1 - b1*t1)*2%d ==0:
print(((a1*t1 - b1*t1)*2+d-1)//d)
else:
print((a1*t1 - b1*t1)//d*2+1)
|
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
if a1*t1+a2*t2>=b1*t1+b2*t2:
a1,a2,b1,b2 = b1,b2,a1,a2
d = b1*t1+b2*t2 - (a1*t1+a2*t2)
if d == 0:
print('infinity')
elif a1*t1<b1*t1:
print(0)
else:
if (a1*t1 - b1*t1)*2%d ==0:
print(((a1*t1 - b1*t1)*2+d-1)//d)
else:
print((a1*t1 - b1*t1)//d*2+1)
|
[
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 652,174
| 652,173
|
u693953100
|
python
|
p02846
|
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
if a1*t1+a2*t2>=b1*t1+b2*t2:
a1,a2,b1,b2 = b1,b2,a1,a2
d = b1*t1+b2*t2 - (a1*t1+a2*t2)
print(d)
if d == 0:
print('inifinity')
elif a1*t1<b1*t1:
print(0)
else:
if (a1*t1 - b1*t1)*2%d ==0:
print(((a1*t1 - b1*t1)*2+d-1)//d)
else:
print((a1*t1 - b1*t1)//d*2+1)
|
t1,t2 = map(int,input().split())
a1,a2 = map(int,input().split())
b1,b2 = map(int,input().split())
if a1*t1+a2*t2>=b1*t1+b2*t2:
a1,a2,b1,b2 = b1,b2,a1,a2
d = b1*t1+b2*t2 - (a1*t1+a2*t2)
if d == 0:
print('infinity')
elif a1*t1<b1*t1:
print(0)
else:
if (a1*t1 - b1*t1)*2%d ==0:
print(((a1*t1 - b1*t1)*2+d-1)//d)
else:
print((a1*t1 - b1*t1)//d*2+1)
|
[
"call.remove",
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 652,175
| 652,173
|
u693953100
|
python
|
p02846
|
t,T,a,A,b,B=map(int,open(0).read().split())
x,y=(b-a)*t,(A-B)*T
if y-x==0:
r="infinity"
else:
s,t=divmod(x,y-x)
r=max(0,s*2+(t>0))
print(r)
|
t,T,a,A,b,B=map(int,open(0).read().split())
x,y=(b-a)*t,(A-B)*T
if y-x==0:
r="infinity"
else:
s,t=divmod(x,y-x)
r=max(0,s*2+(t!=0))
print(r)
|
[
"expression.operator.compare.change",
"assignment.value.change",
"call.arguments.change",
"expression.operation.binary.change"
] | 652,197
| 652,198
|
u941407962
|
python
|
p02846
|
t,T,a,A,b,B=map(int,open(0).read().split())
x,y=(b-a)*t,(A-B)*T
if y-x==0:
r="infinity"
else:
s,t=divmod(x,y-x)
t=0
r=max(0,s*2+bool(t))
print(r)
|
t,T,a,A,b,B=map(int,open(0).read().split())
x,y=(b-a)*t,(A-B)*T
if y-x==0:
r="infinity"
else:
s,t=divmod(x,y-x)
r=max(0,s*2+bool(t))
print(r)
|
[
"assignment.remove"
] | 652,199
| 652,200
|
u941407962
|
python
|
p02846
|
t,T,a,A,b,B=map(int,open(0).read().split())
x,y=(b-a)*t,(A-B)*T
if y-x==0:
r="infinity"
else:
s,t=divmod(x,y-x)
r=max(0,s*2+(t>0))
print(r)
|
t,T,a,A,b,B=map(int,open(0).read().split())
x,y=(b-a)*t,(A-B)*T
if y-x==0:
r="infinity"
else:
s,t=divmod(x,y-x)
r=max(0,s*2+bool(t))
print(r)
|
[
"call.add",
"call.arguments.change"
] | 652,197
| 652,200
|
u941407962
|
python
|
p02846
|
t,T,a,A,b,B=map(int, open(0).read().split())
x,y=(a-b)*t,(A-B)*T
if x+y==0:
r="infinity"
else:
s,t=divmod(-y, x+y)
r=0 if s<0 else s*2+(1 if t else 0)
print(r)
|
t,T,a,A,b,B=map(int, open(0).read().split())
x,y=(a-b)*t,(A-B)*T
if x+y==0:
r="infinity"
else:
s,t=divmod(-x, x+y)
r=0 if s<0 else s*2+(1 if t else 0)
print(r)
|
[
"assignment.value.change",
"identifier.change",
"call.arguments.change"
] | 652,201
| 652,202
|
u941407962
|
python
|
p02846
|
t1,t2 = map(int, input().split())
a1,a2 = map(int, input().split())
b1,b2 = map(int, input().split())
x,y=(a1-b1)*t1 + (a2-b2)*t2, (a1-b1)*t1
if x == 0:
print("infinity")
elif x*y > 0:
print(0)
else:
s,t = divmod(abs(y), abs(x))
print(s*2+1 if t else 0)
|
t1,t2 = map(int, input().split())
a1,a2 = map(int, input().split())
b1,b2 = map(int, input().split())
x,y=(a1-b1)*t1 + (a2-b2)*t2, (a1-b1)*t1
if x == 0:
print("infinity")
elif x*y > 0:
print(0)
else:
s,t = divmod(abs(y), abs(x))
print(s*2+(1 if t else 0))
|
[
"call.arguments.change"
] | 652,203
| 652,204
|
u941407962
|
python
|
p02846
|
T1, T2 = map(int,input().split())
A1, A2 = map(int,input().split())
B1, B2 = map(int,input().split())
if T1*A1 + T2*A2 == T1*B1 + T2*B2:
print("infinity")
else:
if T1*A1 + T2*A2 > T1*B1 + T2*B2:
A1, B1 = B1, A1
A2, B2 = B2, A2
if T1*A1 < T1*B1:
print("0")
else:
forward = T1*A1 - T1*B1
shrink = (T1*B1 + T2*B2) - (T1*A1 + T2*A2)
#print(str(forward))
#print(str(shrink))
if forward % shrink == 0:
print(str(2*forward//shrink - 1 - 1))
else:
print(str((forward//shrink + 1)*2 - 1))
|
T1, T2 = map(int,input().split())
A1, A2 = map(int,input().split())
B1, B2 = map(int,input().split())
if T1*A1 + T2*A2 == T1*B1 + T2*B2:
print("infinity")
else:
if T1*A1 + T2*A2 > T1*B1 + T2*B2:
A1, B1 = B1, A1
A2, B2 = B2, A2
if T1*A1 < T1*B1:
print("0")
else:
forward = T1*A1 - T1*B1
shrink = (T1*B1 + T2*B2) - (T1*A1 + T2*A2)
#print(str(forward))
#print(str(shrink))
if forward % shrink == 0:
print(str(2*forward//shrink))
else:
print(str((forward//shrink + 1)*2 - 1))
|
[
"expression.operation.binary.remove"
] | 652,213
| 652,214
|
u882620594
|
python
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.