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 9
values |
|---|---|---|---|---|---|---|---|
p02844
|
n = int(input())
s = input()
print(s)
cnt = 0
for s1 in range(10):
s1_ind = s.find(str(s1))
if s1_ind == -1 or s1_ind >= len(s)-2 : continue
for s2 in range(10):
s2_ind = s[s1_ind+1: ].find(str(s2)) + s1_ind + 1
if s2_ind <= s1_ind or s2_ind >= len(s)-1: continue
for s3 in range(10):
s3_ind = s[s2_ind+1: ].find(str(s3)) + s2_ind + 1
if s3_ind > s2_ind:
cnt+=1
print(cnt)
|
n = int(input())
s = input()
cnt = 0
for s1 in range(10):
s1_ind = s.find(str(s1))
if s1_ind == -1 or s1_ind >= len(s)-2 : continue
for s2 in range(10):
s2_ind = s[s1_ind+1: ].find(str(s2)) + s1_ind + 1
if s2_ind <= s1_ind or s2_ind >= len(s)-1: continue
for s3 in range(10):
s3_ind = s[s2_ind+1: ].find(str(s3)) + s2_ind + 1
if s3_ind > s2_ind:
cnt+=1
print(cnt)
|
[
"call.remove"
] | 651,003
| 651,004
|
u493520238
|
python
|
p02844
|
N = int(input())
S = list(str(input()))
used = [0]*1000
for i in range(1000):
stri = str(i)
if len(stri) == 2:
stri = "0"+stri
elif len(stri) == 1:
stri = "00"+stri
count = 0
for j in range(N):
if S[j] == stri[count]:
count += 1
if count == 3:
print(i)
used[i] = 1
break
print(sum(used))
|
N = int(input())
S = list(str(input()))
used = [0]*1000
for i in range(1000):
stri = str(i)
if len(stri) == 2:
stri = "0"+stri
elif len(stri) == 1:
stri = "00"+stri
count = 0
for j in range(N):
if S[j] == stri[count]:
count += 1
if count == 3:
used[i] = 1
break
print(sum(used))
|
[
"call.remove"
] | 651,007
| 651,008
|
u442877951
|
python
|
p02844
|
N = int(input())
S = list(str(input()))
used = [0]*1000
for i in range(1,1000):
stri = str(i)
if len(stri) == 2:
stri = "0"+stri
elif len(stri) == 1:
stri = "00"+stri
count = 0
for j in range(N):
if S[j] == stri[count]:
count += 1
if count == 3:
used[i] = 1
break
print(sum(used))
|
N = int(input())
S = list(str(input()))
used = [0]*1000
for i in range(1000):
stri = str(i)
if len(stri) == 2:
stri = "0"+stri
elif len(stri) == 1:
stri = "00"+stri
count = 0
for j in range(N):
if S[j] == stri[count]:
count += 1
if count == 3:
used[i] = 1
break
print(sum(used))
|
[
"call.arguments.change"
] | 651,009
| 651,008
|
u442877951
|
python
|
p02844
|
n = int(input())
s = str(input())
import re
s = re.sub('[0]{4,}','000',s)
s = re.sub('[1]{4,}','111',s)
s = re.sub('[2]{4,}','222',s)
s = re.sub('[3]{4,}','333',s)
s = re.sub('[4]{4,}','444',s)
s = re.sub('[5]{4,}','555',s)
s = re.sub('[6]{4,}','666',s)
s = re.sub('[7]{4,}','777',s)
s = re.sub('[8]{4,}','888',s)
s = re.sub('[9]{4,}','999',s)
ans = 0
target = [0] * 10
for i in s:
target[int(i)] = 1
for xxx in range(1000):
x = str(xxx).zfill(3)
if(not (target[int(x[0])] and target[int(x[1])] and target[int(x[2])])):
continue
ck1,ck2,ck3 = 0,0,0
start = 0
for i in range(start,n):
if(s[i] == x[0]):
ck1 = 1
start = i+1
break
if(ck1):
for i in range(start,n):
if(s[i] == x[1]):
ck2 = 1
start = i+1
break
if(ck1 and ck2):
for i in range(start,n):
if(s[i] == x[2]):
ans += 1
break
print(ans)
|
n = int(input())
s = str(input())
#n = 10000
#s = '8888888888888888888888888888888888888888888888888888888888888888888888888888888888888888818888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888388888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888828888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888885888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888898888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888388888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888488888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888788888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888898888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888788888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888868888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888688888888888888888888888888888888888888888888888808888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888'
import re
s = re.sub('[0]{4,}','000',s)
s = re.sub('[1]{4,}','111',s)
s = re.sub('[2]{4,}','222',s)
s = re.sub('[3]{4,}','333',s)
s = re.sub('[4]{4,}','444',s)
s = re.sub('[5]{4,}','555',s)
s = re.sub('[6]{4,}','666',s)
s = re.sub('[7]{4,}','777',s)
s = re.sub('[8]{4,}','888',s)
s = re.sub('[9]{4,}','999',s)
n = len(s)
ans = 0
target = [0] * 10
for i in s:
target[int(i)] = 1
for xxx in range(1000):
x = str(xxx).zfill(3)
if(not (target[int(x[0])] and target[int(x[1])] and target[int(x[2])])):
continue
ck1,ck2,ck3 = 0,0,0
start = 0
for i in range(start,n):
if(s[i] == x[0]):
ck1 = 1
start = i+1
break
if(ck1):
for i in range(start,n):
if(s[i] == x[1]):
ck2 = 1
start = i+1
break
if(ck1 and ck2):
for i in range(start,n):
if(s[i] == x[2]):
ans += 1
break
print(ans)
|
[
"assignment.add"
] | 651,010
| 651,011
|
u014268998
|
python
|
p02844
|
n = int(input())
s = input()
lst = [0] * 1000
for i in range(1000):
if len(str(i)) == 1:
tmp = '00' + str(i)
lst[i] = tmp
elif len(str(i)) == 2:
tmp = '0' + str(i)
lst[i] = tmp
else:
lst[i] = str(i)
cnt = 0
for v in lst:
id_1 = s.find(v[0])
if id_1 == -1:
continue
id_2 = s.find(v[1], id_1 + 1)
if id_2 == -1:
continue
id_3 = s.find(v[2], id_2 + 1)
if id_3 == -1:
continue
cnt += 1
|
n = int(input())
s = input()
lst = [0] * 1000
for i in range(1000):
if len(str(i)) == 1:
tmp = '00' + str(i)
lst[i] = tmp
elif len(str(i)) == 2:
tmp = '0' + str(i)
lst[i] = tmp
else:
lst[i] = str(i)
cnt = 0
for v in lst:
id_1 = s.find(v[0])
if id_1 == -1:
continue
id_2 = s.find(v[1], id_1 + 1)
if id_2 == -1:
continue
id_3 = s.find(v[2], id_2 + 1)
if id_3 == -1:
continue
cnt += 1
print(cnt)
|
[
"call.add"
] | 651,023
| 651,024
|
u729535891
|
python
|
p02844
|
a = int(input())
b = input()
def my_count(l):
p = 0
for i in range(10):
i = str(i)
if i in l:
p = p + 1
return p
s = []
ans = 0
for i in range(10):
k = str(i)
s.append(b.find(k))
if s[i] >= 0:
for j in range(10):
h = str(j)
y = b[s[i]+1:len(b)]
t = y.find(h)
if t >= 0:
c = y[t+1:len(b)]
ans = ans + my_count(c)
print(s)
print(ans)
|
a = int(input())
b = input()
def my_count(l):
p = 0
for i in range(10):
i = str(i)
if i in l:
p = p + 1
return p
s = []
ans = 0
for i in range(10):
k = str(i)
s.append(b.find(k))
if s[i] >= 0:
for j in range(10):
h = str(j)
y = b[s[i]+1:len(b)]
t = y.find(h)
if t >= 0:
c = y[t+1:len(b)]
ans = ans + my_count(c)
print(ans)
|
[
"call.remove"
] | 651,043
| 651,044
|
u660245210
|
python
|
p02844
|
n = int(input())
s = list(input())
ss = s[::-1]
ans = 0
for i in range(1,1000):
if i < 100:
a = 0
else:
a = i // 100
if i < 10:
b = 0
else:
b = (i-a*100)//10
c = i-(a*100+b*10)
if str(a) in s and str(c) in s:
k = s.index(str(a))
l = n-1-ss.index(str(c))
for j in range(k+1,l):
if s[j] == str(b):
ans += 1
break
print(ans)
|
n = int(input())
s = list(input())
ss = s[::-1]
ans = 0
for i in range(1000):
if i < 100:
a = 0
else:
a = i // 100
if i < 10:
b = 0
else:
b = (i-a*100)//10
c = i-(a*100+b*10)
if str(a) in s and str(c) in s:
k = s.index(str(a))
l = n-1-ss.index(str(c))
for j in range(k+1,l):
if s[j] == str(b):
ans += 1
break
print(ans)
|
[
"call.arguments.change"
] | 651,049
| 651,050
|
u906428167
|
python
|
p02844
|
N = int(input())
S = input()
count = 0
for i in range(1000):
j = i + 1
if(j<10):
first = S.find('0')
if(first >= 0 and first < N):
second = S[first+1:].find('0')
if(second >= 0 and first+second+1 < N):
third = S[first+second+2:].find(str(j))
if(third>=0):
count += 1
elif(j<100):
first = S.find('0')
if(first >= 0 and first < N):
second = S[first+1:].find(str((j%100)//10))
if(second >= 0 and first+second+1 < N):
third = S[first+second+2:].find(str(j%10))
if(third>=0):
count += 1
else:
first = S.find(str(j//100))
if(first >= 0 and first < N):
second = S[first+1:].find(str((j%100)//10))
if(second >= 0 and first+second+1 < N):
third = S[first+second+2:].find(str(j%10))
if(third>=0 ):
count += 1
print(count)
|
N = int(input())
S = input()
count = 0
for i in range(1000):
j = i
if(j<10):
first = S.find('0')
if(first >= 0 and first < N):
second = S[first+1:].find('0')
if(second >= 0 and first+second+2 < N):
third = S[first+second+2:].find(str(j))
if(third>=0):
count += 1
elif(j<100):
first = S.find('0')
if(first >= 0 and first < N):
second = S[first+1:].find(str((j%100)//10))
if(second >= 0 and first+second+2 < N):
third = S[first+second+2:].find(str(j%10))
if(third>=0):
count += 1
else:
first = S.find(str(j//100))
if(first >= 0 and first < N):
second = S[first+1:].find(str((j%100)//10))
if(second >= 0 and first+second+2 < N):
third = S[first+second+2:].find(str(j%10))
if(third>=0 ):
count += 1
print(count)
|
[
"expression.operation.binary.remove",
"literal.number.integer.change",
"control_flow.branch.if.condition.change"
] | 651,053
| 651,054
|
u340153434
|
python
|
p02844
|
def f():
n = int(input())
s = input()
leftMemo = [None]*10
rightMemo = [None]*10
for i in range(10):
char = str(i)
for j in range(n):
if s[j] == char:
leftMemo[i] = j
break
for k in range(n-1,-1,-1):
if s[k] == char:
rightMemo[i] = k
break
ans = 0
for leftNum in range(10):
if leftMemo[leftNum] is None:
continue
start = leftMemo[leftNum]+1
for rightNum in range(10):
if rightMemo[rightNum] is None:
continue
end = rightMemo[rightNum]
ans += len(set(s[start:end]))
print(ans)
|
def f():
n = int(input())
s = input()
leftMemo = [None]*10
rightMemo = [None]*10
for i in range(10):
char = str(i)
for j in range(n):
if s[j] == char:
leftMemo[i] = j
break
for k in range(n-1,-1,-1):
if s[k] == char:
rightMemo[i] = k
break
ans = 0
for leftNum in range(10):
if leftMemo[leftNum] is None:
continue
start = leftMemo[leftNum]+1
for rightNum in range(10):
if rightMemo[rightNum] is None:
continue
end = rightMemo[rightNum]
ans += len(set(s[start:end]))
print(ans)
f()
|
[
"call.add"
] | 651,059
| 651,060
|
u714439871
|
python
|
p02844
|
N = int(input())
S = input()
kouho = [str(i).zfill(3) for i in range(0,100)]
cnt =0
for k in kouho:
ok = True
S_temp = S
for l in k:
if l in S_temp:
basho = S_temp.index(l)
S_temp = S_temp[basho+1:]
else:
ok = False
break
if ok == True:
cnt += 1
print(cnt)
|
N = int(input())
S = input()
kouho = [str(i).zfill(3) for i in range(0,1000)]
cnt =0
for k in kouho:
ok = True
S_temp = S
for l in k:
if l in S_temp:
basho = S_temp.index(l)
S_temp = S_temp[basho+1:]
else:
ok = False
break
if ok == True:
cnt += 1
print(cnt)
|
[
"literal.number.integer.change",
"assignment.value.change",
"call.arguments.change",
"control_flow.loop.range.bounds.upper.change"
] | 651,073
| 651,074
|
u255943004
|
python
|
p02844
|
N = int(input())
S = input()
kouho = [str(i).zfill(3) for i in range(1,1001)]
cnt =0
for k in kouho:
ok = True
S_temp = S
for l in k:
if l in S_temp:
basho = S_temp.index(l)
S_temp = S_temp[basho+1:]
else:
ok = False
break
if ok == True:
cnt += 1
print(cnt)
|
N = int(input())
S = input()
kouho = [str(i).zfill(3) for i in range(0,1000)]
cnt =0
for k in kouho:
ok = True
S_temp = S
for l in k:
if l in S_temp:
basho = S_temp.index(l)
S_temp = S_temp[basho+1:]
else:
ok = False
break
if ok == True:
cnt += 1
print(cnt)
|
[
"literal.number.integer.change",
"assignment.value.change",
"call.arguments.change",
"control_flow.loop.range.bounds.lower.change",
"control_flow.loop.range.bounds.upper.change"
] | 651,075
| 651,074
|
u255943004
|
python
|
p02844
|
N = int(input())
S = input()
count = 0
for i in range(9):
for j in range(9):
for k in range(9):
pas = [str(i),str(j),str(k)]
key = 0
for c in S:
if c == pas[key]:
key += 1
if key ==3:
count +=1
break
print(count)
|
N = int(input())
S = input()
count = 0
for i in range(10):
for j in range(10):
for k in range(10):
pas = (str(i),str(j),str(k))
key = 0
for c in S:
if c == pas[key]:
key += 1
if key ==3:
count +=1
break
print(count)
|
[
"literal.number.integer.change",
"call.arguments.change",
"control_flow.loop.range.bounds.upper.change",
"assignment.value.change"
] | 651,076
| 651,077
|
u103902792
|
python
|
p02844
|
from bisect import bisect_right
n = int(input())
s = input()
ans = 0
pos = [
[] for _ in range(10)
]
def find_gt(a, x):
'Find leftmost value greater than x'
i = bisect_right(a, x)
if i != len(a):
return a[i]
return None
for j in range(n):
pos[int(s[j])].append(j)
for i in range(1001):
t = '000' + str(i)
t = t[-3:]
a, b, c = map(int, tuple(t))
p = -1
p = find_gt(pos[a], p)
if p is None:
continue
q = find_gt(pos[b], p)
if q is None:
continue
r = find_gt(pos[c], q)
if r is None:
continue
ans += 1
print(ans)
|
from bisect import bisect_right
n = int(input())
s = input()
ans = 0
pos = [
[] for _ in range(10)
]
def find_gt(a, x):
'Find leftmost value greater than x'
i = bisect_right(a, x)
if i != len(a):
return a[i]
return None
for j in range(n):
pos[int(s[j])].append(j)
for i in range(1000):
t = '000' + str(i)
t = t[-3:]
a, b, c = map(int, tuple(t))
p = -1
p = find_gt(pos[a], p)
if p is None:
continue
q = find_gt(pos[b], p)
if q is None:
continue
r = find_gt(pos[c], q)
if r is None:
continue
ans += 1
print(ans)
|
[
"literal.number.integer.change",
"call.arguments.change",
"control_flow.loop.range.bounds.upper.change"
] | 651,078
| 651,079
|
u598755311
|
python
|
p02844
|
length = int(input())
string = input()
possible_pins = list()
for pin in [str(num) for num in range(1, 1000)]:
if len(pin) == 1:
pin = "00" + pin
elif len(pin) == 2:
pin = "0" + pin
possible_pins.append(pin)
count = 0
for pin in possible_pins:
start = 0
for letter in pin:
try:
index = string.index(letter, start)
start = index + 1
except ValueError:
break
else:
count += 1
print(count)
|
length = int(input())
string = input()
possible_pins = list()
for pin in [str(num) for num in range(0, 1000)]:
if len(pin) == 1:
pin = "00" + pin
elif len(pin) == 2:
pin = "0" + pin
possible_pins.append(pin)
count = 0
for pin in possible_pins:
start = 0
for letter in pin:
try:
index = string.index(letter, start)
start = index + 1
except ValueError:
break
else:
count += 1
print(count)
|
[
"literal.number.integer.change",
"call.arguments.change",
"control_flow.loop.range.bounds.lower.change"
] | 651,090
| 651,091
|
u721569287
|
python
|
p02844
|
n = int(input())
s = input()
index = 0
cnt = 0
for i in range(0, 1000):
if i < 10:
value = '00' + str(i)
elif i < 100:
value = '0' + str(i)
else:
value = str(i)
print(value)
for j in s:
if value[index] == j:
index += 1
if index == 3:
cnt += 1
index = 0
break
index = 0
print(cnt)
|
n = int(input())
s = input()
index = 0
cnt = 0
for i in range(0, 1000):
if i < 10:
value = '00' + str(i)
elif i < 100:
value = '0' + str(i)
else:
value = str(i)
for j in s:
if value[index] == j:
index += 1
if index == 3:
cnt += 1
index = 0
break
index = 0
print(cnt)
|
[
"call.remove"
] | 651,104
| 651,105
|
u118211443
|
python
|
p02844
|
n = int(input())
s = input()
index = 0
cnt = 0
for i in range(1, 1000):
if i < 10:
value = '00' + str(i)
elif i < 100:
value = '0' + str(i)
else:
value = str(i)
for j in s:
if value[index] == j:
index += 1
if index == 3:
cnt += 1
index = 0
break
index = 0
print(cnt)
|
n = int(input())
s = input()
index = 0
cnt = 0
for i in range(0, 1000):
if i < 10:
value = '00' + str(i)
elif i < 100:
value = '0' + str(i)
else:
value = str(i)
for j in s:
if value[index] == j:
index += 1
if index == 3:
cnt += 1
index = 0
break
index = 0
print(cnt)
|
[
"literal.number.integer.change",
"call.arguments.change",
"control_flow.loop.range.bounds.lower.change"
] | 651,106
| 651,105
|
u118211443
|
python
|
p02844
|
import sys
def input():
return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
s=input()
li=[[-1]*10 for i in range(n+1)]
for i in range(n):
li[-i-2]=li[-i-1][:]
li[-i-2][int(s[-i-1])]=n-1-i
print(li)
ans=0
for i in range(1000):
tmp=str(i)
while len(tmp)!=3:
tmp= "0"+tmp
now=0
for j in range(3):
if li[now][int(tmp[j])]==-1:
break
now=li[now][int(tmp[j])]+1
if j==2:
ans+=1
print(ans)
|
import sys
def input():
return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
s=input()
li=[[-1]*10 for i in range(n+1)]
for i in range(n):
li[-i-2]=li[-i-1][:]
li[-i-2][int(s[-i-1])]=n-1-i
ans=0
for i in range(1000):
tmp=str(i)
while len(tmp)!=3:
tmp= "0"+tmp
now=0
for j in range(3):
if li[now][int(tmp[j])]==-1:
break
now=li[now][int(tmp[j])]+1
if j==2:
ans+=1
print(ans)
|
[
"call.remove"
] | 651,116
| 651,117
|
u654470292
|
python
|
p02844
|
n,s = [input() for i in range(2)]
c = 0
for i in range(1000):
if i < 10:
a1 = '0'
a2 = '0'
a3 = i
elif i < 100:
a1 = '0'
a2 = str(i)[0]
a3 = str(i)[1]
else:
a1 = str(i)[0]
a2 = str(i)[1]
a3 = str(i)[2]
p1 = s.find(a1)
if p1 >= 0:
p2 = s.find(a2, p1 + 1)
if p2 >= 0:
if s.find(a3, p2 + 1) >= 0:
c += 1
print(c)
|
n,s = [input() for i in range(2)]
c = 0
for i in range(1000):
if i < 10:
a1 = '0'
a2 = '0'
a3 = str(i)
elif i < 100:
a1 = '0'
a2 = str(i)[0]
a3 = str(i)[1]
else:
a1 = str(i)[0]
a2 = str(i)[1]
a3 = str(i)[2]
p1 = s.find(a1)
if p1 >= 0:
p2 = s.find(a2, p1 + 1)
if p2 >= 0:
if s.find(a3, p2 + 1) >= 0:
c += 1
print(c)
|
[
"call.add",
"call.arguments.change"
] | 651,118
| 651,119
|
u250583425
|
python
|
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
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.