s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s457693497
p04021
u619819312
1555804880
Python
Python (3.4.3)
py
Runtime Error
211
8608
187
from collections import defaultdict as d a=[int(input()) for i in range(int(input()))] b=sorted(a) c=d(int) e=0 for i in range(0,n,2): d[b[i]]=1 for i in a[1::2]: e+=d[i] print(e)
s086483000
p04021
u785989355
1552970393
Python
Python (3.4.3)
py
Runtime Error
506
7272
678
def nibutan2(array,value,left,right,first = True): if first: if array[left]>value: return 0 elif array[right]<value: return len(array) if right-left<=1: return right else: i=(left+right)//2 if array[i]>value: return nibutan2(array,value,left,i,False) elif array[i]<value: return nibutan2(array,value,i,right,False) N=int(input()) A=[] B=[] for i in range(N): if i%2==0: A.append(int(input())) else: B.append(int(input())) A.sort() B.sort() count=0 for i in range(len(A)): c=nibutan2(B,A[i],0,len(B)-1) count+=abs(c-i) print(count)
s081071926
p04021
u785989355
1552970249
Python
Python (3.4.3)
py
Runtime Error
235
7268
674
def nibutan2(array,value,left,right,first = True): if first: if array[left]>value: return 0 elif array[right]<value: return len(array) if right-left<=1: return right else: i=(left+right)//2 if array[i]>value: return nibutan(array,value,left,i,False) elif array[i]<value: return nibutan(array,value,i,right,False) N=int(input()) A=[] B=[] for i in range(N): if i%2==0: A.append(int(input())) else: B.append(int(input())) A.sort() B.sort() count=0 for i in range(len(A)): c=nibutan2(B,A[i],0,len(B)-1) count+=abs(c-i) print(count)
s298240560
p04021
u539402331
1545359467
Python
PyPy3 (2.4.0)
py
Runtime Error
179
38256
375
#include <bits/stdc++.h> using namespace std; int n, k[100005], mon[100005], ans; bool pre(int a, int b) { if(k[a]<k[b]){return true;} else{return false;} } int main() { cin>>n; for (int i = 0; i < n; ++i) { cin>>k[i]; mon[i+1] = i+1; } sort(mon,mon+n,pre); for (int i = 0; i < n; i += 2){ if (mon[i+1] % 2 == 0){++ans;} } cout<<ans<<endl; }
s713212475
p04021
u422104747
1539594056
Python
Python (3.4.3)
py
Runtime Error
272
7888
325
import bisect n=int(input()) l=[] e=[] for i in range(n//2): j=int(input()) e.append(j) l.append(j) j=int(input()) l.append(j) if n%2==1: j=int(input()) e.append(j) l.append(j) l.sort() e.sort() res=0 for i in range(0,n,2): if e[bisect.bisect_left(e,l[i])]!=l[i]: res+=1 print(res)
s032688578
p04021
u101225820
1500763870
Python
Python (3.4.3)
py
Runtime Error
2104
7084
387
N=int(input()) l=[int(input()) for _ in range(N)] cnt=0 if(N<3): if N==1:print("0") elif l[1]>l[2]:print("1") else:print("0") for _ in range(N): for i in range(N-2): if l[i]>l[i+2]: l[i], l[i + 2] = l[i + 2], l[i] for _ in range(N): for i in range(N-1): if(l[i]>l[i+1]): l[i],l[i+1]=l[i+1],l[i] cnt+=1 print(cnt)
s767509184
p04021
u866746776
1472818233
Python
Python (3.4.3)
py
Runtime Error
528
14644
256
def solve(a): l = len(a) a1 = [a[2*i+1] for i in range((l+1)//2)] b = a.copy() b.sort() b1 = [b[2*i+1] for i in range((l+1)//2)] a1 = set(a1) b1 = set(b1) return len(a1 - b1) n = int(input()) a = [int(input()) for i in range(n)] print(solve(a))
s739731205
p04021
u914627967
1472507592
Python
Python (3.4.3)
py
Runtime Error
548
8592
428
#coding: cp932 N = int(input()) inp =[] for s in range(N): inp.append(int(input())) check = inp[:] check.sort() flag=1 s,ans,lis2 = 0,0,[] while flag==1: #lis.append(check[s]) lis2.append(inp[s]) s+=2 if s>N-1: flag=0 num =len(lis) #print(lis) #print(lis2) for s in range(num): if s!=0: if check[s+2] not in lis2: ans+=1 lis[s] =-1 continue else: if check[s] not in lis2: ans+=1 lis[s]=-1 print(ans)
s426348718
p04022
u467736898
1596779730
Python
Python (3.8.2)
py
Runtime Error
82
55536
984
import sys from subprocess import Popen, PIPE from itertools import groupby from collections import Counter def main(): sys.stdin.readline() S = sys.stdin.read() T = [] inv_dict = {} Factors = Popen("factor " + S, stdout=PIPE).communicate()[0].split(b"\n") for factors in Factors: factors = map(int, factors.split()[1:]) t = 1 t_inv = 1 for f, group in groupby(factors): n = len(list(group)) % 3 if n == 1: t *= f elif n == 2: t_inv *= f t, t_inv = t * t_inv * t_inv, t * t * t_inv T.append(t) inv_dict[t] = t_inv counter_T = Counter(T) ans = 0 for t, t_cnt in counter_T.items(): if t == 1: ans += 1 continue t_inv = inv_dict[t] t_inv_cnt = counter_T[t_inv] if t_cnt > t_inv_cnt or (t_cnt == t_inv_cnt and t > t_inv): ans += t_cnt print(ans) main()
s769508799
p04022
u638795007
1584505961
Python
PyPy3 (2.4.0)
py
Runtime Error
4399
178520
2787
def examA(): S = SI() if "W" in S and not "E" in S: print("No") elif "E" in S and not "W" in S: print("No") elif "N" in S and not "S" in S: print("No") elif "S" in S and not "N" in S: print("No") else: print("Yes") return def examB(): N = I() A = [I()for _ in range(N)] ans = 0 for i in range(N-1): ans += A[i]//2 if A[i]%2 and A[i+1]>=1: ans += 1 A[i+1] -= 1 ans += A[N-1]//2 print(ans) return def examC(): N = I() A = [I()for _ in range(N)] if N==1: print(0) return odd = set() for i in range(N): if i&1==0: odd.add(A[i]) A.sort() ans = 0 for i in range((N+1)//2): if A[i*2] in odd: continue ans += 1 print(ans) return def examD(): def factorization_(a): rep = [[]for _ in range(2)] pair = [] for i in range(2,int(10**(10*1/3))+2): cur = 0 while a%i==0: cur += 1 a //= i if cur>0: cur %= 3 if cur==0: continue rep[0].append((i,cur)) pair.append((i,3-cur)) if not rep[0]: rep[0].append((0,0)) rep[1] = a rep[0] = tuple(rep[0]) rep = tuple(rep) pair = tuple(pair) return rep, pair N = I() S = [I()for _ in range(N)] group = defaultdict(int) P = defaultdict(tuple) for s in S: g,p = factorization_(s) group[g] += 1 P[g[0]] = p #print(group) G2 = deepcopy(group) #print(P) ans = 0 for key,c in group.items(): rep, rest = key pair = rest**2 if rep==((0,0),) and rest==1: ans += 1 else: ans += max(c,G2[(P[rep],pair)]) G2[(rep,rest)] = 0 group[(P[rep], pair)] = 0 #print(ans) print(ans) return def examE(): ans = 0 print(ans) return def examF(): ans = 0 print(ans) return import sys,bisect,itertools,heapq,math,random from copy import deepcopy 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 LSI(): return list(map(str,sys.stdin.readline().split())) def LS(): return sys.stdin.readline().split() def SI(): return sys.stdin.readline().strip() global mod,mod2,inf,alphabet,_ep mod = 10**9 + 7 mod2 = 998244353 inf = 10**18 _ep = 10**(-12) alphabet = [chr(ord('a') + i) for i in range(26)] sys.setrecursionlimit(10**6) if __name__ == '__main__': examD() """ """
s625536631
p04023
u353919145
1553558463
Python
Python (2.7.6)
py
Runtime Error
10
2568
202
if self.buffInGod > 0 then if real == 2 or real == 3 then g_mvcNotify:notifyToRootView("playEffect", self.posXY, '00buff/wudi.json',self.posZ,0,self.faceTo,'effect1') end return false end
s280612182
p04023
u089230684
1553558380
Python
Python (2.7.6)
py
Runtime Error
10
2568
122
function SignetBackpacker:refreshBag() g_asyncLoad:overFor(self) if self.signetTal[self.listSlotID] then return end
s616776013
p04023
u816631826
1553558228
Python
Python (2.7.6)
py
Runtime Error
10
2568
134
function SignetBackpacker:refreshBagData(data) if data then self.originData = data end self.signetTal = {} self:refreshBag() end
s881927993
p04023
u353919145
1553558026
Python
Python (2.7.6)
py
Runtime Error
10
2568
574
if attackObj and (real == 1 or real == 3) then if not args or args.from ~= 9 then -- 9表示来自反弹的 local nowRound = self._scene.nowRound attackObj.roundRecordTb[nowRound] = attackObj.roundRecordTb[nowRound] or {} local recordTb = attackObj.roundRecordTb[nowRound] local tdmg1 = recordTb["roundTotalDmg"] or 0 recordTb["roundTotalDmg"] = tdmg1 + damage if not args or args.from ~= "buff" then -- 非buff的伤害来源 local tdmg2 = recordTb["roundTotalDmgNoBuff"] or 0 recordTb["roundTotalDmgNoBuff"] = tdmg2 + damage end end end
s058753073
p04023
u089230684
1553557560
Python
Python (2.7.6)
py
Runtime Error
10
2568
208
type Container struct { services sync.Map //map[string]IService remotes map[string]bool factory IFactory nsq *nsq.NSQRPCServer nsqClient *nsq.NSQRPCClient option ContainerOption inited bool }
s908900222
p04025
u762533651
1600211924
Python
PyPy3 (7.3.0)
py
Runtime Error
96
74716
410
n = int(input()) x = sorted(list(map(int, input().split())), reverse = True) x_2 = list(map(lambda x:x ** 2, x)) ichi = sum(x) jijou = sum(x_2) re = 10 ** 100 #def ji(p, x): # ans = p * (p - 2 * x) # return ans for p in range(x[n], x[0] + 1): second = n * (p ** 2) third = -2 * p * ichi summ = jijou + second + third if re > summ: re = summ print(re) #for i in range(x[i]):
s638410104
p04025
u973972117
1598830526
Python
Python (3.8.2)
py
Runtime Error
27
9184
243
N=int(input()) A=list(map(int,input().split())) Sum =0 for i in range(len(A)): Sum += (A[0]-A[i])**2 Answer = Sum for j in range(len(A)): Sum =0 for k in range(-100,101): Sum+= (A[k]-j)**2 Answer =min(Answer, Sum) print(Answer)
s184141885
p04025
u973972117
1598830461
Python
Python (3.8.2)
py
Runtime Error
33
9184
246
N=int(input()) A=list(map(int,input().split())) Sum =0 for i in range(len(A)): Sum += (A[0]-A[i])**2 Answer = Sum for j in range(-100,101): Sum =0 for k in range(len(A)): Sum+= (A[k]-A[j])**2 Answer =min(Answer, Sum) print(Answer)
s004766689
p04025
u973972117
1598830096
Python
Python (3.8.2)
py
Runtime Error
24
9184
243
N=int(input()) A=list(map(int,inout().split())) Sum =0 for i in range(len(N)): Sum += (A[0]-A[i])**2 Answer = Sum for j in range(len(N)): Sum =0 for k in range(len(N)): Sum+= (A[k]-A[j])**2 Answer =min(Answer, Sum) print(Answer)
s131935523
p04025
u933650305
1598826682
Python
Python (3.8.2)
py
Runtime Error
31
9156
243
n=int(input()) a=list(map(int,input().split())) b=sorted(a) x=a[0] y=a[n-1] if x==y: print(0) else: d=[] for i in range(x,y+1): c=0 for v in range(n): c+=(i-a[v])**2 d.append(c) continue d=sorted(d) print(d[0])
s926724554
p04025
u933650305
1598826444
Python
Python (3.8.2)
py
Runtime Error
32
9092
241
n=int(input()) a=list(map(int,input().split())) b=sorted(a) x=a[0] y=a[n-1] if x==y: print(0) else: d=[] for i in range(x,y): c=0 for v in range(n): c+=(i-a[v])**2 d.append(c) continue d=sorted(d) print(d[0])
s426381456
p04025
u933650305
1598825530
Python
Python (3.8.2)
py
Runtime Error
28
9200
196
n=int(input()) a=list(map(int,input().split())) b=sorted(a) x=a[0] y=a[n-1] d=[] for i in range(x,y): c=0 for v in range(n): c+=(i-a[v])**2 d.append(c) continue d=sorted(d) print(d[0])
s172297488
p04025
u390727364
1592503675
Python
PyPy3 (2.4.0)
py
Runtime Error
179
38256
346
def main(): input = stdin.buffer.readline n = int(input()) a = list(map(int, input().split())) x1 = sum(a) // n x2 = x1 + 1 ans1 = 0 ans2 = 0 for ai in a: ans1 += (ai - x1) ** 2 ans2 += (ai - x2) ** 2 print(min(ans1, ans2)) if __name__ == "__main__": setrecursionlimit(10000) main()
s165916825
p04025
u597622207
1589909635
Python
PyPy3 (2.4.0)
py
Runtime Error
184
38512
320
from statistics import mean import math N = int(input()) A = list(map(int, input().split())) mean_num = mean(A) Ceil = math.ceil(mean_num) Floor = math.floor(mean_num) Ceil_sum = 0 Floor_sum = 0 for i in A: Ceil_sum += (Ceil - i) ** 2 for i in A: Floor_sum += (Floor - i) ** 2 print(min(Floor_sum, Ceil_sum))
s858668083
p04025
u114641312
1589340490
Python
Python (3.4.3)
py
Runtime Error
17
3060
246
from math import factorial,sqrt,ceil,gcd import numpy as np N = int(input()) lisA = list(map(int,input().split())) arrA = np.array(lisA) mean = np.mean(arrA) targetnum = round(mean) arrans = (arrA - targetnum)**2 ans = sum(arrans) print(ans)
s511423217
p04025
u197968862
1587089004
Python
PyPy3 (2.4.0)
py
Runtime Error
181
38768
169
import statistics n = int(input()) a = list(map(int,input().split())) mean = round(statistics.mean(a)) ans = 0 for i in range(n): ans += (a[i]-mean)**2 print(ans)
s552297504
p04025
u353895424
1585085523
Python
Python (3.4.3)
py
Runtime Error
17
2940
135
n = int(input()) a = list(map(int, input().split())) ave = round(sum(a)/n) ans = 0 for _a in a: ans += (_a - ave)**2 print(ans1)
s825408271
p04025
u588558668
1584367934
Python
Python (3.4.3)
py
Runtime Error
17
3060
175
n=int(input()) a=list(map(int,input().split())) ma=max(a) mi=min(a) b=[0]*(ma-mi+1) for i in range(mi,ma+1): for j in range(n): b[j]+=(i-a[j])**2 print(min(b[j])
s719325976
p04025
u588558668
1584367701
Python
Python (3.4.3)
py
Runtime Error
17
3060
181
n=int(input()) a=list(map(int,int,input().split())) b=[] ma=max(a) mi=min(a) for i in range(mi,ma+1): c=0 for j in range(n): c+=(i-a[j]**2) b.append(c) print(min(b))
s591132174
p04025
u588558668
1584367657
Python
Python (3.4.3)
py
Runtime Error
17
3060
179
n=int(input()) a=list(map(int,int,input().split())) b=[] ma=max(a) mi=min(a) for i in range(b,a+1): c=0 for j in range(n): c+=(i-a[j]**2) b.append(c) print(min(b))
s739525014
p04025
u588558668
1584367630
Python
Python (3.4.3)
py
Runtime Error
17
3060
179
n=int(input()) a=list(map(int,int,input().split())) b=[] ma=max(a) mi=min(b) for i in range(b,a+1): c=0 for j in range(n): c+=(i-a[j]**2) b.append(c) print(min(b))
s096264902
p04025
u799443198
1577628792
Python
Python (3.4.3)
py
Runtime Error
18
2940
144
import math N, *a = map(int, open(0).read().split()) ave = math.round(sum(a) / N) ans = 0 for x in a: ans += (x - ave) * (x - ave) print(ans)
s979081131
p04025
u580697892
1575466287
Python
Python (3.4.3)
py
Runtime Error
40
5276
275
# coding: utf-8 from math import ceil from statistics import median, mean N = int(input()) A = list(map(int, input().split())) A.sort() if N % 2 == 0: m = ceil((A[N//2] + A[N//2+1]) / 2) else: m = A[N//2] ans = 0 for i in range(N): ans += (A[i] - m)**2 print(ans)
s904935755
p04025
u977642052
1573177322
Python
Python (3.4.3)
py
Runtime Error
18
3056
230
def main(n, a): base = (max(a) + min(a)) / 2 ans = 0 for n in a: ans += (n - base)**2 print(round(ans)) if __name__ == '__main__': n = int(input()) a = map(int, input().split()) main(n, a)
s222752988
p04025
u215743476
1571530765
Python
Python (3.4.3)
py
Runtime Error
38
5144
154
from statistics import mean n = int(input()) a = list(map(int, input().split())) t = round(mean(a)) sum = 0 for t in a: sum += (i - t)**2 print(sum)
s057829753
p04025
u543954314
1571158650
Python
PyPy3 (2.4.0)
py
Runtime Error
180
38896
345
n = int(input()) s = len(input()) mod = 10**9+7 dp = [[0]*(n+1) for _ in range(n+1)] dp[0][0] = 1 for i in range(1,n+1): dp[i][0] = (dp[i-1][0] + dp[i-1][1])%mod for j in range(1,min(n,i+1)): dp[i][j] = (dp[i-1][j-1]*2 + dp[i-1][j+1])%mod dp[i][n] = dp[i-1][n-1]*2%mod s2 = pow(2,s,mod) rev = pow(s2,mod-2,mod) print(dp[n][s]*rev%mod)
s090009797
p04025
u163320134
1555962108
Python
Python (3.4.3)
py
Runtime Error
17
3064
202
n=int(input().split()) arr=list(map(int,input().split())) l=min(arr) r=max(arr) ans=10**10 for i in range(l,r+1): tmp=0 for j in range(n): tmp+=(arr[j]-i)**2 if tmp<ans: ans=tmp print(ans)
s705055040
p04025
u149752754
1555616361
Python
Python (3.4.3)
py
Runtime Error
25
3064
245
N = int(input()) NUM = list(map(int,input().split())) MAX = max(NUM) MIN = min(NUM) COSTLIST = [] for i in range (MIN,MAX): COST = 0 for j in NUM: COST += (j-i)**2 COSTLIST.append(COST) MINIMUM = min(COSTLIST) print(MINIMUM)
s877723486
p04025
u859897687
1554494420
Python
Python (3.4.3)
py
Runtime Error
17
3060
159
n=int(input()) l=[int(input()) for i in range(n)] s=sum(l)/n if s-int(s)<int(s)+1-s: s=int(s) else: s=int(s)+1 ans=0 for i in l: ans+=(s-i)**2 print(ans)
s372838639
p04025
u785578220
1547387825
Python
Python (3.4.3)
py
Runtime Error
18
2940
529
#include <iostream> using namespace std; int N; int x[210]; bool t = true; int s = 0; int main(){ int ms = 10000000000; int t = 1; cin >> N; for (int i = 0; i < N; ++i)cin >> x[i]; for (int j = -100; j <= x[N-1]; ++j){ s = 0; for (int i = 0; i < N; ++i){ int p = x[i] - j; //cout << p << endl; s += p * p; } //cout << s << endl; if (s < ms){ ms = s; t = j; } } cout << ms << endl; }
s160061779
p04025
u785989355
1541392164
Python
Python (3.4.3)
py
Runtime Error
17
3060
182
N=int(input()) a=list(map(int,input().split())) a=np.array(a) min_s = 10**29 for i in range(201): s=np.sum((a-np.ones(N)*(i-100))**2) min_s = min(int(s),min_s) print(min_s)
s003888324
p04025
u218843509
1529731359
Python
Python (3.4.3)
py
Runtime Error
20
3188
340
MOD = (10 ** 9) + 7 N = int(input()) s = list(input()) dp = [[0 for i in range(N + 1)] for j in range(N + 1)] for i in range(N + 1): dp[i][i] = 1 for n in range(1, N + 1): dp[n][0] = (dp[n - 1][0] + 2 * dp[n - 1][1]) % MOD for l in range(1, n): dp[n][l] = (dp[n - 1][l - 1] + 2 * dp[n - 1][l + 1]) % MOD print(dp[N - 1][len(s)])
s892744835
p04025
u218843509
1525712740
Python
PyPy2 (5.6.0)
py
Runtime Error
36
27884
376
MOD = (10 ** 9) + 7 N = int(input()) s = list(input()) dp = [[0 for i in range(N + 1)] for j in range(N + 1)] for i in range(N + 1): dp[i][i] = 1 for i in range(N): dp[i][i + 1] = 1 for n in range(1, N + 1): dp[n][0] = (dp[n - 1][0] + 2 * dp[n - 1][1]) % MOD for l in range(1, n): dp[n][l] = (dp[n - 1][l - 1] + 2 * dp[n - 1][l + 1]) % MOD print(dp[N - 1][len(s)])
s049952429
p04025
u766407523
1525641627
Python
Python (3.4.3)
py
Runtime Error
18
3060
205
import math N = int(input()) a = list(map(int, input().split())) cost = math.inf for i in range(-100, 101): temp = 0 for a_i in a: temp += (a_i-i)**2 cost = min(cost, temp) print(cost)
s475318520
p04025
u835482198
1500852834
Python
Python (3.4.3)
py
Runtime Error
18
3060
227
N = int(input()) a = map(int, input().split()) total_cost = float('inf') for n in range(-100, 101): cost = 0 for i in range(N): cost += (a[i] - n) ** 2 total_cost = min(total_cost, cost) print(total_cost)
s313620186
p04025
u357487020
1471139619
Python
PyPy2 (5.6.0)
py
Runtime Error
63
9072
506
s=raw_input() n=len(s) cnt=[[0]*26 for _ in xrange(n+1)] for i in xrange(n): for j in xrange(26): cnt[i+1][j]=cnt[i][j] cnt[i+1][ord(s[i])-ord("a")]+=1 if n==2: if s[0]==s[1]: print 1,2 quit() else: print -1,-1 quit() for i in xrange(n): for j in xrange(i+3,n+1): max_cnt=0 for k in xrange(26): max_cnt=max(max_cnt,cnt[j][k]-cnt[i][k]) if (j-i)/2<max_cnt: print i+1,j quit() print -1,-1
s917624038
p04025
u813098295
1471137748
Python
Python (2.7.6)
py
Runtime Error
25
2568
297
def cost(n, a, m): hihumi = 0 #hihumi => 滝本ひふみ for i in range(n): hihumi += (a[i] - m) ** 2 return hihumi N = int(raw_input()) a = map(int, raw_input().split()) ans = 100 for i in range(min(a), max(a) + 1): if (ans > cost(N, a, i)): ans = const(N, a, i) print ans
s734769666
p04026
u706414019
1599733908
Python
Python (3.8.2)
py
Runtime Error
29
8856
270
import collections s = input() ls = len(s) if ls ==2 and s[0]=!s[1]: print(-1,-1) elif ls ==2 and s[0]==s[1]: print(1,2) for i in range(2,ls): tmp = collections.Counter(s[i-2:i+1]) if len(tmp.keys())<=2: print(i-1,i+1) exit() print(-1,-1)
s831116991
p04026
u277236383
1597275386
Python
PyPy3 (7.3.0)
py
Runtime Error
81
74736
258
s = input() l = len(s) for i in range(l-2): temp = s[i] if s[i+1]==temp: print(str(i+1)+" "+str(i+2)) quit() if s[i+2]==temp: print(str(i+1)+" "+str(i+3)) quit() if s[i+1]==s[i+2]: print(str(i+2)+ " "+str(i+3)) quit() print("-1 -1")
s766264059
p04026
u995062424
1595635712
Python
Python (3.8.2)
py
Runtime Error
56
9440
340
from collections import Counter s = input() flg = False lst = [] for i in range(len(s)-2): if(s[i] == s[i+1]): flg = True lst.append(i+1) lst.append(i+2) break elif(s[i] == s[i+2]): flg = True lst.append(list(i+1, i+3)) break if(flg): print(*lst) else: print(-1, -1)
s408416057
p04026
u223646582
1591581778
Python
Python (3.4.3)
py
Runtime Error
18
3188
186
s = input() if s[-2] == s[-1]: print(len(s)-1, len(s)) exit() for i in range(s-2): if s[i] == s[i+1] or s[i] == s[i+2]: print(i+1, i+3) exit() print(-1 - 1)
s849200204
p04026
u693933222
1584065860
Python
Python (3.4.3)
py
Runtime Error
53
3188
261
s = input() for i in range(len(s) - 2): if (s[i] == s[i + 1] or s[i] == s[i + 2]): print("{} {}".format(i + 1, i + 3)) break else: if (s[-2] == s[-1]): print("{} {}".format(len(n) - 1, len(n))) else: print("-1 -1")
s458318227
p04026
u888100977
1583891586
Python
Python (3.4.3)
py
Runtime Error
80
3188
239
s = input() # print(s) for i in range(len(s)-1): if s[i]==s[i+1]: print(i+1,i+2) break if i<=len(s)-2: if s[i]==s[i+2]: print(i+1,i+3) break if i == len(s)-3: print(-1,-1)
s288542791
p04026
u852690916
1582763580
Python
PyPy3 (2.4.0)
py
Runtime Error
168
39536
226
s=input() for i in range(len(s)): if i>=1: if s[i]==s[i-1]: print(i-1 + ' ' + i) exit() if i>=2: if s[i]==s[i-2]: print(i-2 + ' ' + i) exit() print(-1 -1)
s535187290
p04026
u852690916
1582763434
Python
PyPy3 (2.4.0)
py
Runtime Error
168
39536
245
s=input() ''' - aa - aba ''' for i in range(len(s)): if i>=1: if s[i]==s[i-1]: print(i-1 + ' ' + i) exit() if i>=2: if s[i]==s[i-2]: print(i-2 + ' ' + i) exit() print(-1 -1)
s133213307
p04026
u018679195
1580540322
Python
Python (3.4.3)
py
Runtime Error
3502
3444
624
s=input() m=[] flag=0 for i in range(len(s)+1): for j in range(len(s)+1): m.append(s[i:j]) for i in range(m.count('')): m.remove('') #print(m) #print(len(m[2])) for i in range(len(m)): if len(m[i])>2: for j in m[i]: #print(j) if len(m[i])%2==0: y=len(m[i])/2 else: y=(len(m[i])+1)/2 if m[i].count(j)>y: h=m[i].index(j) y=m[i].index(j)+len(m[i])-1 flag=1 break if flag==1: break if flag==0: print("-1 -1") else: print(h, y)
s225240487
p04026
u816631826
1580539535
Python
Python (3.4.3)
py
Runtime Error
2622
4164
483
s=input() m=[] flag=0 for i in range(len(s)+1): for j in range(len(s)+1): m.append(s[i:j]) for i in range(m.count('')): m.remove('') print(m) #print(len(m[2])) for i in range(len(m)): if len(m[i])>2: for j in m[i]: if j.count()>len(j)/2: h=j.index() y=j.index()+len(m[i])-1 flag=1 break if flag==1: break if flag==0: print("-1 -1") else: print(h, y)
s039009484
p04026
u994988729
1579137838
Python
Python (3.4.3)
py
Runtime Error
187
17088
407
from collections import defaultdict import numpy as np S = input() d = defaultdict(list) for i, s in enumerate(S): d[s].append(i + 1) ans = (-1, -1) for _, v in d.items(): dif = np.diff(v).tolist() if 1 in dif: i = dif.index(1) ans = (v[i], v[i + 1]) break elif 2 in dif: i = dif.index(1) ans = (v[i], v[i + 1]) break print(*ans, sep=" ")
s011292225
p04026
u073852194
1575168094
Python
Python (3.4.3)
py
Runtime Error
63
3188
178
s = input() N = len(s) for i in range(N-1): if s[i]==s[i+1]: print(i+1,i+2) break if i<N-1 and s[i]==s[i+2]: print(i+1,i+3) else: print(-1,-1)
s264992273
p04026
u754022296
1574369310
Python
Python (3.4.3)
py
Runtime Error
17
3188
193
入力 = input() for i in range(len(入力)-1): if 入力[i]==入力[i+1]: print(i+1, i+2) exit() elif i<n-2 and 入力[i]==入力[i+2]: print(i+1, i+3) exit() print(-1, -1)
s252469455
p04026
u802963389
1570885675
Python
Python (3.4.3)
py
Runtime Error
18
3064
237
# a*a と aaの2パターンを探せばよい? s = input() n = len(s) for i in range(n-2): if s[i] == s[i + 1]: print(i, i + 1) exit() for i in range(n-3): if s[i] == s[i + 2]: print(i, i + 2) exit() print(-1, -1)
s474234331
p04026
u672220554
1570645531
Python
Python (3.4.3)
py
Runtime Error
52
3188
375
s=input() n=len(s) res = -1 leng = 0 for i in range(n-2): if s[i] == s[i+1]: res = i+1 leng = 2 break elif s[i] == s[i+2]: res = i+1 leng = 3 break if s[-2] == s[-1]: res = i+1 leng = 2 if res == -1: print("-1 -1") elif leng == 2: print(str(res)+" "+str(res+1)) else: print(str(res)+" "+str(res+2))
s668548947
p04026
u708255304
1569422927
Python
Python (3.4.3)
py
Runtime Error
68
3188
324
S = str(input()) left = -2 right = -2 for i in range(max(1, len(S)-2)): if S[i] == S[i+1]: left = i right = i+1 break if S[i] == S[i+2]: left = i right = i+2 break if S[i+1] == S[i+2]: left = i+1 right = i+2 break print(left+1, right+1)
s388626195
p04026
u798818115
1568081252
Python
Python (3.4.3)
py
Runtime Error
62
3188
303
# coding: utf-8 # Your code here! s=input() judge=True if s[0]==s[1] or s[1]==s[2] or s[0]==s[1]: print(0,2) else: for i in range(3,len(s)): if s[i-2]==s[i-1] or s[i-2]==s[i]: print(i-2,i) judge=False break if judge: print(-1,-1)
s872720055
p04026
u131666536
1557002883
Python
Python (3.4.3)
py
Runtime Error
55
3188
295
# -*- coding: utf-8 -*- s = input() ans = '' for i in range(len(s)-1): if s[i] == s[i+1]: ans = ' '.join([str(i+1), str(i+2)]) for j in range(len(s)-2): if s[i] == s[i+1] == s[i+2]: ans = ' '.join([str(i+1), str(i+3)]) if ans: print(ans) else: print('-1 -1')
s074655319
p04026
u131666536
1557002477
Python
Python (3.4.3)
py
Runtime Error
55
3188
408
# -*- coding: utf-8 -*- s = input() double = [] triple = [] for i in range(len(s)-1): if s[i] == s[i+1]: double = [str(i+1), str(i+2)] for j in range(len(s)-2): if s[i] == s[i+1] == s[i+2]: triple = [str(i+1), str(i+3)] if double == [] and triple == []: print('-1 -1') else: if double: print(' '.join(double)) else: print(' '.join(triple))
s430118446
p04026
u131666536
1557002356
Python
Python (3.4.3)
py
Runtime Error
55
3188
388
# -*- coding: utf-8 -*- s = input() double = [] triple = [] for i in range(len(s)-1): if s[i] == s[i+1]: double = [str(i+1), str(i+2)] for j in range(len(s)-2): if s[i] == s[i+1] == s[i+2]: triple = [str(i+1), str(i+3)] if double == [] and triple == []: print('-1 -1') elif double: print(' '.join(double)) else: print(' '.join(triple))
s783136015
p04026
u131666536
1557002094
Python
Python (3.4.3)
py
Runtime Error
57
3188
365
# -*- coding: utf-8 -*- s = input() double = [] triple = [] for i in range(len(s)-1): if s[i] == s[i+1]: double = [str(i+1), str(i+2)] for j in range(len(s)-2): if s[i] == s[i+1] == s[i+2]: triple = [str(i+1), str(i+3)] if double: print(' '.join(double)) elif triple: print(' '.join(triple)) else: print('-1 -1')
s430021318
p04026
u131666536
1557001942
Python
Python (3.4.3)
py
Runtime Error
59
3188
339
# -*- coding: utf-8 -*- s = input() double = [] triple = [] for i in range(len(s)-1): if s[i] == s[i+1]: double = [str(i+1), str(i+2)] if s[i] == s[i+1] == s[i+2]: triple = [str(i+1), str(i+3)] if double: print(' '.join(double)) elif triple: print(' '.join(triple)) else: print('-1 -1')
s404089815
p04026
u977389981
1556405132
Python
Python (3.4.3)
py
Runtime Error
41
3188
192
S = input() if S[0] == S[2]: print(1, 3) else: for i in range(1, len(S)): if S[i] == S[i - 1]: print(i, i + 1) break else: print(-1, -1)
s121414412
p04026
u785578220
1553673243
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38384
10
print(2 3)
s327489682
p04026
u852038767
1550129741
Python
Python (3.4.3)
py
Runtime Error
1094
3956
401
S = list(input()) S.append("A") for i in range(26): if S.count(chr(97 + i)) >= 2: for j in range(len(S) - 1): if (S[j] == chr(97 + i)) and (S[j + 1] == chr(97 + i)): print((j+1), (j+2)) exit() if (S[j] == chr(97 + i)) and (S[j + 2] == chr(97 + i)): print((j+1), (j+3)) exit() else: print("-1 -1")
s735419770
p04026
u852038767
1550129479
Python
Python (3.4.3)
py
Runtime Error
1063
3956
393
S = list(input()) S.append("A") for i in range(26): if S.count(chr(97 + i)) >= 2: for j in range(len(S) - 1): if (S[j] == chr(97 + i)) and (S[j + 1] == chr(97 + i)): print(j+1, j+2) exit() if (S[j] == chr(97 + i)) and (S[j + 2] == chr(97 + i)): print(j+1, j+3) exit() else: print("-1 -1")
s796899639
p04026
u852038767
1550129054
Python
Python (3.4.3)
py
Runtime Error
1035
3956
391
S = list(input()) S.append(1) for i in range(26): if S.count(chr(97 + i)) >= 2: for j in range(len(S) - 1): if (S[j] == chr(97 + i)) and (S[j + 1] == chr(97 + i)): print(j+1, j+2) exit() if (S[j] == chr(97 + i)) and (S[j + 2] == chr(97 + i)): print(j+1, j+3) exit() else: print("-1 -1")
s333378161
p04026
u423585790
1547771462
Python
PyPy3 (2.4.0)
py
Runtime Error
178
39280
198
s = input() for i in range(len(s)): if s[i] == s[i + 1] and (s[i + 1] == s[i + 2] or (s[i + 1] != s[i + 2] and s[i + 2] == s[i])): print(i+1, i + 4) quit() print(-1,-1)
s986151713
p04026
u423585790
1547771423
Python
PyPy3 (2.4.0)
py
Runtime Error
179
39280
196
s = input() for i in range(len(s)): if s[i] == s[i + 1] and (s[i + 1] == s[i + 2] or (s[i + 1] != s[i + 2] and s[i + 2] == s[i])): print(i, i + 3) quit() print(-1,-1)
s317300108
p04026
u337802798
1538703869
Python
Python (3.4.3)
py
Runtime Error
17
2940
3286
#pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC optimize(3) #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #pragma GCC target("sse3","sse2","sse") #pragma GCC target("avx","sse4","sse4.1","sse4.2","ssse3") #pragma GCC target("f16c") #pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector") #pragma GCC diagnostic error "-fwhole-program" #pragma GCC diagnostic error "-fcse-skip-blocks" #pragma GCC diagnostic error "-funsafe-loop-optimizations" #pragma GCC diagnostic error "-std=c++14" #include "bits/stdc++.h" //#include "ext/pb_ds/tree_policy.hpp" //#include "ext/pb_ds/assoc_container.hpp" #define PB push_back #define PF push_front #define LB lower_bound #define UB upper_bound #define fr(x) freopen(x,"r",stdin) #define fw(x) freopen(x,"w",stdout) #define iout(x) printf("%d\n",x) #define lout(x) printf("%lld\n",x) #define REP(x,l,u) for(ll x = l;x<u;x++) #define RREP(x,l,u) for(ll x = l;x>=u;x--) #define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end()) #define mst(x,a) memset(x,a,sizeof(x)) #define all(a) a.begin(),a.end() #define PII pair<int,int> #define PLL pair<ll,ll> #define MP make_pair #define sqr(x) ((x)*(x)) #define lowbit(x) (x&(-x)) #define lson (ind<<1) #define rson (ind<<1|1) #define se second #define fi first #define dbg(x) cerr<<#x<<" = "<<(x)<<endl; #define sz(x) ((int)x.size()) #define EX0 exit(0); typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ld; using namespace std; typedef vector<ll> VLL; typedef vector<int> VI; const int block_size = 320; typedef complex<ll> point; const ll mod = 1e9+7; const ll inf = 1e9+7; const ld eps = 1e-9; const db PI = atan(1)*4; template<typename T> inline int sign(const T&a) { if(a<0)return -1; if(a>0)return 1; return 0; } template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;} template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;} template<typename T> inline void in(T &x) { x = 0; T f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } x *= f; } ll twop(int x) { return 1LL<<x; } template<typename A,typename B > inline void in(A&x,B&y) { in(x); in(y); } template<typename A,typename B,typename C>inline void in(A&x,B&y,C&z) { in(x); in(y); in(z); } template<typename A,typename B,typename C,typename D> inline void in(A&x,B&y,C&z,D&d) { in(x); in(y); in(z); in(d); } ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);} namespace SOLVE { void main(){ } } bool unb(string s){ if(sz(s) == 2)return s[0]==s[1]; else{ sort(all(s)); return s[0]==s[1]||s[1]==s[2]; } } int main() { string s; cin>>s; REP(len,2,4){ REP(i,0,sz(s)-len+1){ if(unb( s.substr(i,len))){ cout<<i+1<<" "<<i+1+len;return 0; } } } cout<<"-1 -1"; return 0; }
s324679690
p04026
u909643606
1506785171
Python
Python (3.4.3)
py
Runtime Error
62
3188
138
S=input() a=0 for i in range(len(S)-1): if S[i]==S[i+1] or S[i]==S[i+2] : a=1 print(i+1,i+3) break if a==0: print(-1,-1)
s145844101
p04026
u813098295
1471144328
Python
Python (2.7.6)
py
Runtime Error
28
2692
449
# coding: utf-8 def count_char_max(text): a = "abcdefghijklmnopqrstuvwxyz" l = [0] * 26 for i in text: ascNum = ord(i.lower()) - 97 if ascNum < 0 or 25 < ascNum: continue l[ascNum] += 1 return max(l) s = raw_input() for i in len(s): if (s[i] == s[i + 1]): print "%d %d" % (i + 1, i + 2) quit() elif (count_char_max(s[i:i+3]) == 2): print "%d %d" % (i + 1, i + 3) quit() print "-1 -1"
s019638442
p04026
u237168895
1471139763
Python
Python (3.4.3)
py
Runtime Error
37
3064
355
import re tar = input() foo = [0 for i in range(26)] tmp = "abcdefghijklmnopqrstuvwxyz" for i in tmp: b = re.search(i+"."+i,tar) if b: print (str(b.start()+1)+” " + str(b.start() + 3)) quit() b = re.search(str(i)+str(i),tar) if b: print (str(b.start()+1)+ " " + str(b.start() + 3)) quit() print("-1 -1")
s506142701
p04026
u509661905
1471139458
Python
PyPy3 (2.4.0)
py
Runtime Error
514
51688
655
#!/usr/bin/env pypy3 import collections import itertools MAX_S = 100 NO_SOL = (-1, -1) def is_unbalanced(s): ctr = collections.Counter(s) total = sum(ctr.values()) m = max(ctr.values()) return m >= total // 2 + 1 def find_unbalanced_substr(s): l = len(s) for start, end in itertools.combinations(range(l), 2): if is_unbalanced(s[start:end + 1]): return start, end return NO_SOL def main(): s = input() assert len(s) <= MAX_S ans = find_unbalanced_substr(s) if ans == NO_SOL: print(*ans) else: print(*(x + 1 for x in ans)) if __name__ == '__main__': main()
s295566105
p04026
u707500405
1471138681
Python
PyPy2 (5.6.0)
py
Runtime Error
159
12272
402
from collections import deque S = [ord(a)-97 for a in raw_input()] N = len(S) for c in xrange(26): ls = deque() for i in xrange(N-1): if S[i] == c: l = i break else: continue cnt = 1 for r in xrange(l+1,N): if S[r] == c: cnt += 1 ls.append(r) if cnt * 2 > r - l + 1: print l+1,r+1 quit() else: if cnt * 2 < r - l + 1: l = ls.popleft() cnt -= 1 print -1,-1
s102782653
p04026
u315078622
1471137157
Python
Python (3.4.3)
py
Runtime Error
228
4024
275
import string S = input() N = len(S) assert(len(S) <= 100) for i in range(N): for j in range(i, N): s = S[i:j+1] if len(s) > 1 and any(s.count(a) * 2 > j-i+1 for a in string.ascii_lowercase): print(i+1, j+1) quit(0) print(-1, -1)
s762314167
p04027
u368780724
1574999688
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38256
611
for _ in range(test_case): import sys from itertools import accumulate readline = sys.stdin.readline MOD = 10**9+7 N, C = map(int, readline().split()) A = [0] + list(map(int, readline().split())) B = [0] + list(map(int, readline().split())) acsq = [list(accumulate([pow(i, j, MOD) for i in range(max(B)+1)])) for j in range(C+1)] dp = [[0]*(C+1) for _ in range(N+1)] dp[0][0] = 1 for i in range(1, N+1): a, b = A[i], B[i] for c in range(C+1): res = 0 for j in range(c+1): res = (res + (acsq[c-j][b] - acsq[c-j][a-1])*dp[i-1][j]) % MOD dp[i][c] = res print(dp[N][C])
s289512363
p04027
u892251744
1574880737
Python
PyPy3 (2.4.0)
py
Runtime Error
2333
44012
664
N, C = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) mod = 10**9+7 acc = [[0] for _ in range(401)] for i in range(401): for j in range(1, C+2): acc[i].append(((acc[i][-1] + pow(j, i, mod)) % mod)) dp = [[0 for _ in range(C+1)] for _ in range(N+1)] dp[0][0] = 1 for i in range(N): for candy_cur in range(C+1): for candy_plus in range(C - candy_cur+1): dp[i+1][candy_cur + candy_plus] = (dp[i+1][candy_cur + candy_plus] + (dp[i][candy_cur]\ * ((acc[candy_plus][B[i]] - acc[candy_plus][A[i]-1])%mod)%mod)) % mod print(dp[-1][C])
s550205619
p04027
u892251744
1574863766
Python
PyPy3 (2.4.0)
py
Runtime Error
4209
96448
634
N, C = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) mod = 10**9+7 acc = [[0] for _ in range(401)] for i in range(401): for j in range(1, C+2): acc[i].append(acc[i][-1] + j ** i) dp = [[0 for _ in range(C+1)] for _ in range(N+1)] dp[0][0] = 1 for i in range(N): for candy_cur in range(C+1): for candy_plus in range(C - candy_cur+1): dp[i+1][candy_cur + candy_plus] = (dp[i+1][candy_cur + candy_plus] + dp[i][candy_cur]\ * (acc[candy_plus][B[i]] - acc[candy_plus][A[i]-1])) % mod print(dp[-1][C])
s231205491
p04027
u077337864
1570885896
Python
PyPy3 (2.4.0)
py
Runtime Error
1348
43124
811
import sys input = sys.stdin.readline sys.setrecursionlimit(pow(10, 6)) MOD = pow(10, 9) + 7 def main(): n, c = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) assert(a==b) dp = [[0 for _ in range(c+1)] for _ in range(n+1)] for i in range(n+1): dp[i][0] = 1 pow_table = [[1 for _ in range(401)] for _ in range(n)] for i in range(1, 401): for j in range(n): pow_table[j][i] = pow_table[j][i-1]*a[j]%MOD for i in range(1, n+1): for j in range(1, c+1): for k in range(j+1): dp[i][j] += dp[i-1][j-k] * pow_table[i-1][k] % MOD if dp[i][j] >= MOD: dp[i][j] -= MOD print(dp[n][c]) if __name__ == '__main__': main()
s781945277
p04027
u077337864
1570885723
Python
PyPy3 (2.4.0)
py
Runtime Error
4207
60508
747
import sys input = sys.stdin.readline sys.setrecursionlimit(pow(10, 6)) MOD = pow(10, 9) + 7 def main(): n, c = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) assert(a==b) dp = [[0 for _ in range(c+1)] for _ in range(n+1)] for i in range(n+1): dp[i][0] = 1 pow_table = [[1 for _ in range(401)] for _ in range(n)] for i in range(1, 401): for j in range(n): pow_table[j][i] = pow_table[j][i-1]*a[j]%MOD for i in range(1, n+1): for j in range(1, c+1): for k in range(j+1): dp[i][j] += (dp[i-1][j-k] * pow_table[i-1][k] % MOD) % MOD print(dp[n][c]) if __name__ == '__main__': main()
s767872777
p04027
u077337864
1570885117
Python
PyPy3 (2.4.0)
py
Runtime Error
4207
50560
571
import sys input = sys.stdin.readline sys.setrecursionlimit(pow(10, 6)) MOD = pow(10, 9) + 7 def main(): n, c = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) assert(a==b) dp = [[0 for _ in range(c+1)] for _ in range(n+1)] for i in range(n+1): dp[i][0] = 1 for i in range(1, n+1): for j in range(1, c+1): for k in range(j+1): dp[i][j] += (dp[i-1][j-k] * pow(a[i-1], k, MOD)) % MOD print(dp[n][c]) if __name__ == '__main__': main()
s384905524
p04027
u415905784
1568649872
Python
Python (3.4.3)
py
Runtime Error
17
2940
1116
package main import ( "fmt" "math" ) func max(M *[]int) (ret int) { ret = (*M)[0] for _, m := range (*M) { if ret < m { ret = m } } return } func main() { var N, C int fmt.Scan(&N, &C) A := make([]int, N) B := make([]int, N) p := int64(math.Pow(10, 9) + 7) var x int for i := 0; i < N; i++ { fmt.Scan(&x) A[i] = x } for i := 0; i < N; i++ { fmt.Scan(&x) B[i] = x } B_max := max(&B) X := make([][]int64, C + 2) for i := 0; i < C + 2; i++ { X[i] = make([]int64, B_max + 1) } for j := 1; j < B_max + 1; j++ { X[0][j] = 1 } for i := 0; i < C + 1; i++ { for j := 1; j < B_max + 1; j++ { X[i + 1][j] = (X[i][j] * int64(j)) % p X[i][j] += X[i][j - 1] } } DP := make([][]int64, N + 1) for i := 0; i < N + 1; i++ { DP[i] = make([]int64, C + 1) } DP[0][0] = 1 for i := 1; i < N + 1; i++ { for j := 0; j < C + 1; j++ { for k := 0; k < j + 1; k++ { DP[i][j] += (DP[i - 1][j - k] * (X[k][B[i - 1]] - X[k][A[i - 1] - 1])) % p } DP[i][j] %= p } } fmt.Println(DP[N][C]) }
s832379031
p04027
u102461423
1562859438
Python
Python (3.4.3)
py
Runtime Error
166
22044
1011
import sys input = sys.stdin.readline import numpy as np MOD = 10 ** 9 + 7 N,C = map(int,input().split()) A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] # (i,j) に j^i を入れる kth_pow = np.ones((1024, 401), dtype=np.int64) rng = np.arange(401, dtype=np.int64) for i in range(1,C+1): kth_pow[i] = kth_pow[i-1] * rng % MOD kth_pow_cum = kth_pow.cumsum(axis = 1) % MOD kth_pow_cum[C+1:] = 0 def convolve(A,B,n=32): if n == 8: return np.rint(np.fft.irfft(np.fft.rfft(A) * np.fft.rfft(B))).astype(np.int64) n //= 2 M = 1 << n A1,A2 = np.divmod(A,M) B1,B2 = np.divmod(B,M) X = convolve(A1,B1,n) Y = convolve(A1-A2,B1-B2,n) Z = convolve(A2,B2,n) return (X * (M * M % MOD) + (X + Z - Y) * M + Z) % MOD dp = np.zeros(1024, dtype=np.int64) # これまで配った個数、合計点 dp[0] = 1 for a,b in zip(A,B): arr = kth_pow_cum[:,b] - kth_pow_cum[:,a-1] dp = convolve(dp,arr) dp[C+1:] = 0 answer = dp[C] print(answer)
s797412608
p04027
u102461423
1562859338
Python
Python (3.4.3)
py
Runtime Error
167
22044
1011
import sys input = sys.stdin.readline import numpy as np MOD = 10 ** 9 + 7 N,C = map(int,input().split()) A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] # (i,j) に j^i を入れる kth_pow = np.ones((1024, 401), dtype=np.int64) rng = np.arange(401, dtype=np.int64) for i in range(1,C+1): kth_pow[i] = kth_pow[i-1] * rng % MOD kth_pow_cum = kth_pow.cumsum(axis = 1) % MOD kth_pow_cum[C+1:] = 0 def convolve(A,B,n=32): if n == 8: return np.rint(np.fft.irfft(np.fft.rfft(A) * np.fft.rfft(B))).astype(np.int64) n //= 2 M = 1 << n A1,A2 = np.divmod(A,M) B1,B2 = np.divmod(B,M) X = convolve(A1,B1,n) Y = convolve(A1-A2,B1-B2,n) Z = convolve(A2,B2,n) return (X * (M * M % MOD) + (X + Z - Y) * M + Z) % MOD dp = np.zeros(1024, dtype=np.int64) # これまで配った個数、合計点 dp[0] = 1 for a,b in zip(A,B): arr = kth_pow_cum[:,b] - kth_pow_cum[:,a-1] dp = convolve(dp,arr) dp[C+1:] = 0 answer = dp[C] print(answer)
s350858596
p04027
u726693690
1471717852
Python
Python (3.4.3)
py
Runtime Error
244
12248
676
import numpy as np import sys import itertools # スペース区切りの整数の入力 n, c = [int(i) for i in sys.stdin.readline().split()] a = [int(i) for i in sys.stdin.readline().split()] b = [int(i) for i in sys.stdin.readline().split()] memo = {} def f_i(x, c): global memo if len(x) == 1: return x[0]**c if str((x, c)) not in memo: memo[str((x, c))] = sum([ (x[0]**i) * f_i(x[1:], c-i) for i in xrange(c + 1)]) return memo[str((x, c))] def f(x, c): return f_i(x, c) ranges = [ [ i for i in xrange(a_i, b_i + 1)] for a_i, b_i in zip(a, b)] print(sum([f(x, c) for x in itertools.product(*ranges)]) % (1000000000+7))
s313330535
p04028
u218843509
1525712752
Python
PyPy2 (5.6.0)
py
Runtime Error
38
28652
376
MOD = (10 ** 9) + 7 N = int(input()) s = list(input()) dp = [[0 for i in range(N + 1)] for j in range(N + 1)] for i in range(N + 1): dp[i][i] = 1 for i in range(N): dp[i][i + 1] = 1 for n in range(1, N + 1): dp[n][0] = (dp[n - 1][0] + 2 * dp[n - 1][1]) % MOD for l in range(1, n): dp[n][l] = (dp[n - 1][l - 1] + 2 * dp[n - 1][l + 1]) % MOD print(dp[N - 1][len(s)])
s454681828
p04028
u218843509
1525581986
Python
Python (3.4.3)
py
Runtime Error
2124
281972
364
MOD = (10 ** 9) + 7 N = int(input()) s = list(input()) dp = [[0 for i in range(N)] for j in range(N)] for i in range(N): dp[i][i] = 1 for i in range(N - 1): dp[i][i + 1] = 1 for n in range(1, N): dp[n][0] = (dp[n - 1][0] + 2 * dp[n - 1][1]) % MOD for l in range(1, n): dp[n][l] = (dp[n - 1][l - 1] + 2 * dp[n - 1][l + 1]) % MOD print(dp[N - 1][len(s)])
s326128023
p04028
u526532903
1513795601
Python
Python (3.4.3)
py
Runtime Error
17
2940
950
#include<bits/stdc++.h> #define range(i,a,b) for(int i = (a); i < (b); i++) #define rep(i,b) for(int i = 0; i < (b); i++) #define all(a) (a).begin(), (a).end() #define show(x) cerr << #x << " = " << (x) << endl; //const int INF = 1e8; using namespace std; const long long M = 1000000007; //x^n mod M typedef long long ull; ull power(ull x, ull n){ ull res = 1; if(n > 0){ res = power(x, n / 2); if(n % 2 == 0) res = (res * res) % M; else res = (((res * res) % M) * x ) %M; } return res; } int main(){ int n; string s; cin >> n >> s; vector<long long> dp(n + 1, 0); dp[0] = 1; rep(i,n){ vector<long long> _dp(n + 1, 0); rep(j,n + 1){ if(j == 0) (_dp[j] += dp[j]) %= M; else (_dp[j - 1] += dp[j]) %= M; (_dp[j + 1] += dp[j] * 2LL) %= M; } dp = _dp; //for(auto j : dp){ for(auto k : j){ cout << k << ' '; } cout << endl; } cout << endl; } cout << dp[s.size()] * power(power(2,s.size()), M - 2) % M << endl; }
s976082587
p04029
u401183062
1601222574
Python
Python (3.8.2)
py
Runtime Error
24
8904
160
def iroha(): count = int(input()) result = 0 for i in range(count+1): result += i print(result) if __name__ == "__main__": iroha(
s280702683
p04029
u401183062
1601222428
Python
Python (3.8.2)
py
Runtime Error
26
8948
121
count = int(input()) result = 0 for i in range(count+1): print(i) result += i print(result
s763647030
p04029
u847033024
1599833494
Python
Python (3.8.2)
py
Runtime Error
20
8844
34
n = input() print(n * (n + 1) / 2)
s268787857
p04029
u918422508
1599811224
Python
Python (3.8.2)
py
Runtime Error
23
8892
26
N=input() print(N*(N+1)/2)