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
s238303597
p03705
u089230684
1553129459
Python
Python (2.7.6)
py
Runtime Error
11
2568
185
n = int(input()) a = int(input()) b = int(input()) def add(n,a,b): print((n * b + (a - b)) - (n * a + (b - a)) + 1) return (n * b + (a - b)) - (n * a + (b - a)) + 1 add(n,a,b)
s824649350
p03705
u089230684
1553129354
Python
Python (2.7.6)
py
Runtime Error
11
2692
101
n = int(input()) a = int(input()) b = int(input()) return (n * b + (a - b)) - (n * a + (b - a)) + 1
s943252398
p03705
u580362735
1552776192
Python
Python (3.4.3)
py
Runtime Error
17
2940
177
N,A,B = map(int,input().split()) data = range(A,B+1) if N-2>=0: print( (B − A)(N − 2) + 1) elif N == 1: if A!=B: print('0') else: print('1') else: print('0')
s455394182
p03705
u580362735
1552776068
Python
Python (3.4.3)
py
Runtime Error
2322
157812
279
import itertools N,A,B = map(int,input().split()) data = range(A,B+1) if N-2>=0: tmp = list(itertools.combinations_with_replacement(data,N-2)) ans = [] for i in range(len(tmp)): ans.append(sum(tmp[i])) print(len(set(ans))) elif N == 1: print('1') else: print('0')
s524778167
p03705
u580362735
1552775935
Python
Python (3.4.3)
py
Runtime Error
2353
157812
261
import itertools N,A,B = map(int,input().split()) data = range(A,B+1) if N-2>=0: tmp = list(itertools.combinations_with_replacement(data,N-2)) ans = [] for i in range(len(tmp)): ans.append(tmp[i][0]+tmp[i][1]) print(len(set(ans))) else: print('0')
s074439959
p03705
u740284863
1552097510
Python
Python (3.4.3)
py
Runtime Error
18
2940
121
n,a,b = map(int,input().split()) if a > b: print(0) elif a == b: print(1) else: print((n - 2) * (b - a) + 1))
s445757488
p03705
u740284863
1552097480
Python
Python (3.4.3)
py
Runtime Error
17
2940
120
n,a,b = map(int,input().split()) if a > b: print(0) elif a == b: print(1) else: pritn((n - 2) * (b - a) + 1)
s287160663
p03705
u175034939
1552021140
Python
Python (3.4.3)
py
Runtime Error
20
3060
149
n,a,b = map(int,input().split()) if a == b: print(1) elif n == 1 or a > b: print(0) else: print(len(list(range(a*(n-1)+b, a+(n-1)*b+1))))
s297105192
p03705
u175034939
1552020598
Python
Python (3.4.3)
py
Runtime Error
20
3060
160
n,a,b = map(int,input().split()) if n == 1 and a == b: print(1) elif n == 1 or a > b: print(0) else: print(len(list(range(a*(n-1)+b, a+(n-1)*b+1))))
s104738442
p03705
u175034939
1552020408
Python
Python (3.4.3)
py
Runtime Error
18
3060
136
n,a,b = map(int,input().split()) if a > b or (n == 1 and a != b): print(0) else: print(len(list(range(a*(n-1)+b, a+(n-1)*b+1))))
s002662063
p03705
u367130284
1551866408
Python
Python (3.4.3)
py
Runtime Error
2291
3440
300
n,a,b=map(int,input().split()) if n==1: if a==b: print(1) else: print(0) elif n==2: if b<a: print(0) else: print(1) else: if b<a: print(0) elif a==b: print(1) else: print(sum(list(range(b-a+2))[::-1][:n-2]))
s089113262
p03705
u367130284
1551866037
Python
Python (3.4.3)
py
Runtime Error
2312
3060
268
n,a,b=map(int,input().split()) if n==1: if a==b: print(1) else: print(0) elif n==2: if b<a: print(0) else: print(1) else: if b<a: print(0) else: print(sum(list(range(b-a+2))[::-1][:n-2]))
s672397462
p03705
u761989513
1551821611
Python
Python (3.4.3)
py
Runtime Error
2313
157812
251
import itertools n, a, b = map(int, input().split()) if n < 2 and a != b: print(0) elif n == 1: print(1) else: c = set() for i in itertools.combinations_with_replacement(range(a, b + 1), n - 2): c.add(sum(i)) print(len(c))
s471302588
p03705
u426964396
1550717809
Python
Python (3.4.3)
py
Runtime Error
17
2940
172
s=input().split();n,a,b=int(s[0]),int(s[1]),int(s[2]) if a>b: print(0) elif n=1: if a==b: print(1) else: print(0) else: print((a-b)*(n-2)+1)
s989890576
p03705
u950708010
1550079540
Python
Python (3.4.3)
py
Runtime Error
19
3064
6
1 3 3
s698291996
p03705
u270681687
1549747856
Python
Python (3.4.3)
py
Runtime Error
18
3064
580
a = int(input()) b = int(input()) if a == b: print(1) exit() # 二進数xの長さを求める時、len(bin(x)) - 2 では、xが0のとき1を返してしまい、バグる原因になる # よって、二進数の長さを計算する関数を用意しておく def bitlen(x): return 1 + bitlen(x >> 1) if x else 0 t = a ^ b n = bitlen(t) T = 1 << (n - 1) a = a & (T * 2 - 1) b = b & (T * 2 - 1) sb = b & (T - 1) b_max...
s224587827
p03705
u863370423
1547432026
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38640
175
line = input().split() N = line[0] A = line[1] B = line[2] if A > B: cnt = 0 elif N == 1: cnt = 0 elif A == B: cnt = 1 else: cnt=(2-N)*A+(N-2)*B+1 print(cnt)
s202146408
p03705
u863370423
1547328918
Python
Python (3.4.3)
py
Runtime Error
18
2940
147
n = int(input()) a = int(input()) b = int(input()) if n == 1 and a == b: print(1) elif n<2 or a>b: print(0) else: print((n-2)*(b-a)+1)
s099841369
p03705
u723721005
1541089256
Python
Python (3.4.3)
py
Runtime Error
17
2940
73
c=int(input()),a=int(input()),b=int(input()) print((a+b*c-b)-(a*c-a+b)+1)
s125160138
p03705
u138486156
1540610816
Python
Python (3.4.3)
py
Runtime Error
2239
1989784
323
from itertools import combinations_with_replacement as h_func n, a, b = map(int, input().split()) if a > b: print(0) exit() if n == 1: if a == b: print(1) else: print(0) exit() x = [i for i in range(a, b+1)] ans = set() y = h_func(x, n-2) for p in y: ans.add(sum(p)) print(len(ans...
s075032344
p03705
u138486156
1540610690
Python
Python (3.4.3)
py
Runtime Error
2243
2059032
317
from itertools import combinations_with_replacement as h_func n, a, b = map(int, input().split()) if a > b: print(0) exit() if n == 1: if a == b: print(1) else: print(0) exit() x = [i for i in range(a, b+1)] ans = set() for p in h_func(x, n-2): ans.add(sum(p)) print(len(ans))
s120822040
p03705
u017810624
1536950180
Python
Python (3.4.3)
py
Runtime Error
17
2940
103
n,a,b=map(int,input().split()) if a>b:print(0) elif n==1 and a!=b:print(0) else:print((n-2)*(b-a)+1)​
s447208304
p03705
u426964396
1533575984
Python
Python (3.4.3)
py
Runtime Error
17
2940
59
n=input().slipt() print(int(n[2]*(n[0]-2)-(n[1]*n[0]-2)+1))
s983431175
p03705
u426964396
1533413547
Python
Python (2.7.6)
py
Runtime Error
10
2568
59
n=input() a=input() b=input() print(int(b*(n-2)-(a*n-2)+1))
s530491307
p03705
u476418095
1533413330
Python
Python (3.4.3)
py
Runtime Error
17
2940
142
#include<iostream> using namespace std; unsigned long long n,a,b; int main(){ cin>>n>>a>>b; cout<<(b*(n-2)-a*(n-2)+1); return 0; }
s427931612
p03705
u723721005
1533413255
Python
Python (3.4.3)
py
Runtime Error
17
2940
147
#include<iostream> #define ll long long using namespace std; ll n,a,b; int main(){ cin>>n>>a>>b; cout<<(b*(n-2)-a*(n-2)+1); return 0; }
s140525313
p03705
u306142032
1531077211
Python
Python (3.4.3)
py
Runtime Error
17
2940
190
n, a, b = map(int, input().split()) if n == 1: if a == b: print(1) else: print(0) else: if a > b: print(0) else: print((b-a)(n-2)+1)
s122497061
p03705
u828847847
1530477601
Python
Python (2.7.6)
py
Runtime Error
12
2692
78
n,a,b = map(int,raw_input().split()) print (a + b(n - 1) ) - (a(n-1) + b) + 1
s712337449
p03705
u766407523
1522460960
Python
Python (3.4.3)
py
Runtime Error
17
2940
172
N, A, B = map(int, input().split()) if A > B: print(0) elif N = 1: if A = B: print(1) else: print(0) else: print((A+(N-1)*B)-((N-1)*A+B)+1)
s137068067
p03705
u432780056
1509833146
Python
Python (2.7.6)
py
Runtime Error
1883
157444
322
def main(): n, a, b = [int(x) for x in raw_input().split()] if a == b: print 1 return if n == 1: print 0 return from itertools import combinations s = set() for t in combinations(sorted(range(a, b + 1) * 2), n - 2): ans = a + b for e in t: ans += e s.add(ans) print len(s) print s return main...
s045233620
p03705
u833990553
1497674823
Python
Python (2.7.6)
py
Runtime Error
2567
6512
165
N,A,B=map(lambda x:int(x) , raw_input().split(' ')) if A>B or N<2: print 0 elif A==B: print 1 else: li= range(0,B-A+2)[::-1] print li print sum(li[:N-2])
s390242515
p03705
u713627549
1497572654
Python
Python (3.4.3)
py
Runtime Error
18
2940
150
s = list(input()) z = 0 for i in s: if s[i] == "U": z += (len(s) - i)*1 + i * 2 else: z += (len(s) - i)*2 + i * 1 print(z)
s816868487
p03705
u713627549
1497571098
Python
Python (3.4.3)
py
Runtime Error
18
2940
292
s = list(input()) count = 0L for i in range(len(s)): for j in range(len(s)): #print(i, j) if (i < j and s[i] == "D") or (i > j and s[i] == "U"): count += 2 elif (i < j and s[i] == "U") or (i > j and s[i] == "D"): count += 1 print(count)
s628543247
p03705
u280667879
1497391601
Python
PyPy2 (5.6.0)
py
Runtime Error
81
184812
517
f=lambda s,h,w,a,q:s[h+1].__setitem__(w+1,s[h+1][w]+s[h][w+1]-s[h][w]+a[h][w]*q) g=lambda s,y1,x1,y2,x2:s[y2][x2]-s[y2][x1-1]-s[y1-1][x2]+s[y1-1][x1-1] H,W,N=map(int,raw_input().split()) a=[map(int,raw_input())for _ in[0]*H] s,s1,s2=[[[0]*(W+1)for _ in[0]*-~H]for _ in[0]*3] for h in range(H): for w in range(W): f(s,...
s780591678
p03705
u742895474
1496254348
Python
Python (3.4.3)
py
Runtime Error
3395
25352
375
import itertools import numpy as np def calc(n, a, b): if a > b: return 0 elif a == b: return 1 elif n == 1: return 0 s = set() ary = np.arange(a, b+1) it = itertools.combinations_with_replacement(ary, n-2) for x in it: s.add(sum(x)) return len(s) N, ...
s034270785
p03705
u268210555
1496183627
Python
PyPy3 (2.4.0)
py
Runtime Error
2145
816000
681
n,m,q=map(int,input().split()) s,v,el,eu=([[0]*(m+2) for _ in range(n+2)] for _ in range(4)) for i in range(1,n+1): s[i][1:m+1]=map(int,input()) for j in range(1,m+1): v[i][j]=v[i][j-1]+s[i][j] el[i][j]=el[i][j-1]+s[i][j]*s[i][j-1] eu[i][j]=eu[i][j-1]+s[i][j]*s[i-1][j] for i in range(2,n...
s208066649
p03705
u966695411
1495942269
Python
Python (3.4.3)
py
Runtime Error
17
3060
267
#! /usr/bin/env python3 import itertools N, A, B = map(int, input().split()) t = B - A + 1 if B <= A or N < 2: if A == B: print(1) else: print(0) else: s = set() print(len({sum(i) for i in itertools.product(range(t), repeat = N - 2)}))
s634185881
p03705
u966695411
1495941964
Python
Python (3.4.3)
py
Runtime Error
18
3060
263
#! /usr/bin/env python3 import itertools N, A, B = map(int, input().split()) t = B - A + 1 s = set() if B <= A or N < 3: if A == B: print(1) else: print(0) else: print(len({sum(i) for i in itertools.product(range(t), repeat = N - 2)}))
s267069906
p03705
u205678452
1495940370
Python
Python (3.4.3)
py
Runtime Error
17
3064
564
N = input().split() N[0] = int(N[0]) N[1] = int(N[1]) N[2] = int(N[2]) if(N[0] == 1): if(N[1] == N[2]): print("1") exit() print("0") exit() if(N[1] > N[2]): print("0") exit() print((N[2] * (N[0] -1) + N[1]) - (N[1] * (N[0] - 1) + N[2]) + 1) N = input().split() N[0] = int(N[0]) ...
s068375863
p03705
u330205771
1495940356
Python
Python (2.7.6)
py
Runtime Error
22
3532
416
N, A, B = map(int, raw_input().split()) def fact(n, c): if c == 0: return 1 return n * fact(n - 1, c - 1) if B < A: print(0) elif N == 1: if B == A: print(1) else: print(0) elif A == B: print(1) elif N == 2: print(3) else: result1 = fact(B - A + 2, N - 2) / fact(N - 2,...
s112886838
p03705
u330205771
1495940254
Python
Python (2.7.6)
py
Runtime Error
22
3528
416
N, A, B = map(int, raw_input().split()) def fact(n, c): if c == 0: return 1 return n * fact(n - 1, c - 1) if B < A: print(0) elif N == 1: if B == A: print(1) else: print(0) elif A == B: print(1) elif N == 2: print(3) else: result1 = fact(B - A + 2, N - 2) / fact(N - 2,...
s011109644
p03705
u657471067
1495939480
Python
Python (2.7.6)
py
Runtime Error
2370
467204
387
# -*- coding: utf-8 -*- import itertools N,A,B = map(int,raw_input().split())# 文字列の入力 wa = A+B list1=[] if N ==1: print 0 elif N ==2: print A+B else: plus=list(itertools.product(range(A,B+1), repeat=N-2)) for x in plus: su=wa+sum(x) if su in list1: pass else:...
s249931218
p03705
u125205981
1495938760
Python
Python (3.4.3)
py
Runtime Error
2241
7392
177
def main(): N, A, B = map(int, input().split()) num = tuple(range(A, B+1)) n = len(num) cmb = n ** (N - 2) ans = (cmb + 1) // 2 print(int(ans)) main()
s224923781
p03705
u205678452
1495937783
Python
Python (3.4.3)
py
Runtime Error
18
3064
197
import sys N = input().split() N[0] = int(N[0]) N[1] = int(N[1]) N[2] = int(N[2]) if(N[1] > N[2]): print("0") exit(1) print((N[2] * (N[0] -1) + N[1]) - (N[1] * (N[0] - 1) + N[2]) + 1)
s006494162
p03705
u205678452
1495937664
Python
Python (3.4.3)
py
Runtime Error
17
3064
227
N = input().split() N[0] = int(N[0]) N[1] = int(N[1]) N[2] = int(N[2]) if(N[0] == 1): print("0") exit(1) if(N[1] > N[2]): print("0") exit(1) print((N[2] * (N[0] -1) + N[1]) - (N[1] * (N[0] - 1) + N[2]) + 1)
s564713187
p03705
u205678452
1495937601
Python
Python (3.4.3)
py
Runtime Error
70
3064
247
import sys N = input().split() N[0] = int(N[0]) N[1] = int(N[1]) N[2] = int(N[2]) if(N[0] == 1): print("0") sys.exit(1) if(N[1] > N[2]): print("0") sys.exit(1) print((N[2] * (N[0] -1) + N[1]) - (N[1] * (N[0] - 1) + N[2]) + 1)
s355368919
p03705
u667084803
1495937512
Python
Python (3.4.3)
py
Runtime Error
18
3064
261
A=int(input()) B=int(input()) S=[] times=len(format(A^B,"b")) for i in range(A,B+1): S+=[i] D=S[:] #Dは基礎集合 SET=set(S) #for t in range(times): for i in range(len(S)): for j in range(len(D)): S+=[S[i]|D[j]] SET.add(S[i]|D[j]) print(len(SET))
s496800068
p03705
u205678452
1495937216
Python
Python (3.4.3)
py
Runtime Error
19
3064
247
import sys N = input().split() N[0] = int(N[0]) N[1] = int(N[1]) N[2] = int(N[2]) if(N[0] == 1): print("0") sys.exit(1) if(N[1] > N[2]): print("0") sys.exit(1) print((N[2] * (N[0] -1) + N[1]) - (N[1] * (N[0] - 1) + N[2]) + 1)
s121667993
p03705
u330205771
1495936425
Python
Python (2.7.6)
py
Runtime Error
22
3532
392
N, A, B = map(int, raw_input().split()) def fact(n, c): if c == 0: return 1 return n * fact(n - 1, c - 1) if B < A: print(0) elif N == 1: if B == A: print(1) else: print(0) elif A == B: print(1) else: result1 = fact(B - A + 2, N - 2) / fact(N - 2, N - 2) result2 = ((B ...
s581717228
p03705
u600601196
1495936243
Python
Python (3.4.3)
py
Runtime Error
2343
6492
400
import itertools def solve(N,A,B): if (A>B) or (N==1 and A<B): return 0 if (N==1 and A==B) or N==2: return 1 N = N-2 nums_memo = set() for nums in itertools.combinations_with_replacement(range(A,B+1), N): nums_memo.add(sum(nums)) return len(nums_memo) if __name__ == '...
s124289039
p03705
u062864034
1495936197
Python
Python (3.4.3)
py
Runtime Error
2236
4564
399
from itertools import combinations n = [int(i) for i in input().split()] if n[0] == 1 and n[1] < n[2]: print(0) elif n[1]>n[2]: print(0) elif n[0] == 1 and n[1]==n[2]: print(1) else: m = range(n[1],n[2]+1) if n[0] != 2: c = list(combinations(m,n[0]-2)) c.extend([(i,i) for i in m]) ...
s915063816
p03705
u330205771
1495935984
Python
Python (2.7.6)
py
Runtime Error
22
3528
457
N, A, B = map(int, raw_input().split()) def fact(n, c): if c == 0: return 1 return n * fact(n - 1, c - 1) if B < A: print(0) elif N == 1: if 1 < (B - A): print(0) else: print(1) elif A == B: print(1) else: result1 = fact(B - A + 2, N - 2) / fact(N - 2, N - 2) minimum ...
s820669026
p03705
u062864034
1495935817
Python
Python (3.4.3)
py
Runtime Error
17
2940
331
import combinations from itertools n = [int(i) for i in input().split()] if n[0] == 1 and n[1] < n[2]: print(0) elif n[1]>n[2]: print(0) elif n[0] == 1 and n[1]==n[2]: print(1) else: m = range(n[1],n[2]+1) c = list(combinations(m,n[0]-2)) c.extend([(i,i) for i in m]) print(len(set([i+j for i...
s726018537
p03705
u330205771
1495935733
Python
Python (2.7.6)
py
Runtime Error
22
3532
431
N, A, B = map(int, raw_input().split()) def fact(n, c): if c == 0: return 1 return n * fact(n - 1, c - 1) if B < A: print(0) elif N == 1: if 1 < (B - A): print(0) else: print(1) else: result1 = fact(B - A + 2, N - 2) / fact(N - 2, N - 2) minimum = A * (N - 1) + B maxi...
s993986049
p03705
u106342872
1495935584
Python
Python (3.4.3)
py
Runtime Error
2238
7648
345
#! -*- coding:utf-8 -*- import itertools n,a,b = map(int,input().split()) l = range(a,b+1) arr = [] if a > b: print(0) elif n == 1 and a == b: print(1) elif n == 1 and a != b: print(0) else: for elem in itertools.combinations_with_replacement(l,n-2): #sum = a + b arr.append(sum(elem)) ...
s076104154
p03705
u062864034
1495935432
Python
Python (3.4.3)
py
Runtime Error
2242
7520
333
import itertools n = [int(i) for i in input().split()] if n[0] == 1 and n[1] < n[2]: print(0) elif n[1]>n[2]: print(0) elif n[0] == 1 and n[1]==n[2]: print(1) else: m = range(n[1],n[2]+1) l = n[0]-2 c = list(itertools.combinations(m,l)) c.extend([(i,i) for i in m]) print(len(set([i+j for...
s282528156
p03705
u125205981
1495935325
Python
Python (3.4.3)
py
Runtime Error
2246
157812
293
import itertools def main(): N, A, B = map(int, input().split()) num = tuple(range(A, B+1)) val = [] for n in itertools.combinations_with_replacement(num, N): if n[0] == A and n[-1] == B: val.append(sum(n)) ans = len(set(val)) print(ans) main()
s961404198
p03705
u106342872
1495935324
Python
Python (3.4.3)
py
Runtime Error
2249
3808
442
#! -*- coding:utf-8 -*- import itertools n,a,b = map(int,input().split()) l = range(a,b+1) arr = [] if a > b: print(0) elif n == 1 and a == b: print(1) elif n == 1 and a != b: print(0) else: for elem in itertools.combinations_with_replacement(l,n-2): sum = a + b for i in range(len(elem...
s436411245
p03705
u341087021
1495935177
Python
Python (3.4.3)
py
Runtime Error
18
2940
501
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time def LI(): return [int(x) for x in sys.stdin.readline().split()] def FI(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def I(): return int(sys.stdin.readline()) def F(): ret...
s197888852
p03705
u106342872
1495934988
Python
Python (3.4.3)
py
Runtime Error
2266
4052
400
#! -*- coding:utf-8 -*- import itertools n,a,b = map(int,input().split()) l = range(a,b+1) arr = [] if a > b: print(0) elif n == 1 and a == b: print(1) elif n == 1 and a != b: print(0) else: for elem in itertools.combinations_with_replacement(l,n-2): sum = a + b for i in range(len(elem...
s778913608
p03707
u535803878
1594438782
Python
PyPy3 (7.3.0)
py
Runtime Error
883
295312
1169
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,m,q = list(map(int, input().split())) s = [None]*n for i in range(n): s[i] = list(map(int, input())) e1 = [[0]*(m) for _ in range(n-1)] e2 = [[0]*(m-1) for _ in range(n)] ...
s057785360
p03707
u535803878
1594350064
Python
Python (3.8.2)
py
Runtime Error
4420
398784
1432
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,m,q = list(map(int, input().split())) s = [None]*n for i in range(n): s[i] = list(map(int, input())) e1 = [[0]*(m) for _ in range(n-1)] e2 = [[0]*(m-1) for _ in range(n)] ...
s388511671
p03707
u535803878
1594350031
Python
PyPy3 (7.3.0)
py
Runtime Error
1813
487700
1432
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,m,q = list(map(int, input().split())) s = [None]*n for i in range(n): s[i] = list(map(int, input())) e1 = [[0]*(m) for _ in range(n-1)] e2 = [[0]*(m-1) for _ in range(n)] ...
s741272725
p03707
u535803878
1594349827
Python
PyPy3 (7.3.0)
py
Runtime Error
1852
488832
1437
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,m,q = list(map(int, input().split())) s = [None]*n for i in range(n): s[i] = list(map(int, input())) e1 = [[0]*(m) for _ in range(n-1)] e2 = [[0]*(m-1) for _ in range(n)] ...
s956679277
p03707
u141610915
1594146525
Python
PyPy3 (7.3.0)
py
Runtime Error
983
241168
1199
import sys input = sys.stdin.readline N, M, Q = map(int, input().split()) S = [list(map(int, list(input())[: -1])) for _ in range(N)] e = [[0] * M for _ in range(N + 1)] for i in range(1, N + 1): for j in range(M - 1): e[i][j + 1] = e[i][j] + ((S[i - 1][j] == 1) and (S[i - 1][j + 1] == 1)) for i in range(1, N): for...
s847053096
p03707
u060752882
1589926124
Python
Python (3.4.3)
py
Runtime Error
4211
127636
725
n,m,q = map(int, input().split()) s = [] for i in range(n): s.append(list((1 if x == '1' else 0 for x in input().strip()))) def g(s,x,y,n): s[x][y] += n if x > 0 and s[x-1][y]==1: g(s,x-1,y,n) if x < len(s)-1 and s[x+1][y]==1: g(s,x+1,y,n) if y > 0 and s[x][y-1]==1: g(s,x,y-...
s787108398
p03707
u794173881
1580624274
Python
PyPy3 (2.4.0)
py
Runtime Error
3672
410120
1496
class Ruiseki2D(): def __init__(self, matrix): self.h = len(matrix) self.w = len(matrix[0]) self.ruiseki = [[0] * (self.w + 1) for _ in range(self.h + 1)] for i in range(self.h): for j in range(self.w): self.ruiseki[i + 1][j + 1] = self.ruiseki[i + 1][j] ...
s763655664
p03707
u794173881
1580623071
Python
PyPy3 (2.4.0)
py
Runtime Error
3864
410120
1508
class Ruiseki2D(): def __init__(self, matrix): self.h = len(matrix) self.w = len(matrix[0]) self.ruiseki = [[0] * (self.w + 1) for _ in range(self.h + 1)] for i in range(self.h): for j in range(self.w): self.ruiseki[i + 1][j + 1] = self.ruiseki[i + 1][j] ...
s564639003
p03707
u794173881
1580622993
Python
PyPy3 (2.4.0)
py
Runtime Error
2859
456916
1545
class Ruiseki2D(): def __init__(self, matrix): self.h = len(matrix) self.w = len(matrix[0]) self.ruiseki = [[0] * (self.w + 1) for _ in range(self.h + 1)] for i in range(self.h): for j in range(self.w): self.ruiseki[i + 1][j + 1] = self.ruiseki[i + 1][j] ...
s396636265
p03707
u467736898
1572978569
Python
Python (3.4.3)
py
Runtime Error
1501
289848
1406
def main(): import sys import numpy as np input = sys.stdin.readline H, W, Q = map(int, input().split()) S = [list(map(lambda x: x=="1", input())) for _ in range(H)] + [[False]*(W+1)] S = np.array(S, dtype=np.int32) M = np.zeros((H + 1, W + 1), dtype=np.int32) L = np.zeros((H + 1, W + 1)...
s932471219
p03707
u297574184
1563076650
Python
PyPy3 (2.4.0)
py
Runtime Error
1599
317600
1447
import sys input = sys.stdin.readline from itertools import accumulate from operator import add def solve(): def getAccAss(Ass): accAss = [[0] * (len(Ass[0])+1)] + [accumulate([0] + As) for As in Ass] for x in range(1, len(accAss)): accAss[x] = list(map(add, accAss[x], accAss[x-1])) ...
s300679616
p03707
u297574184
1563076593
Python
Python (3.4.3)
py
Runtime Error
4240
607064
1447
import sys input = sys.stdin.readline from itertools import accumulate from operator import add def solve(): def getAccAss(Ass): accAss = [[0] * (len(Ass[0])+1)] + [accumulate([0] + As) for As in Ass] for x in range(1, len(accAss)): accAss[x] = list(map(add, accAss[x], accAss[x-1])) ...
s683057833
p03707
u957084285
1551463142
Python
Python (3.4.3)
py
Runtime Error
17
2940
1269
#include <iostream> using namespace std; #define REP(i,n) for (int i = 0; i < n; ++i) #define FOR(i,m,n) for (int i = m; i < n; ++i) const int MAX = 2222; int N, M, Q; int grid[MAX][MAX], cumulative[MAX][MAX]; int hedge[MAX][MAX], vedge[MAX][MAX]; int main() { cin >> N >> M >> Q; REP(n, N) { string ...
s577229114
p03707
u905506603
1539825830
Python
Python (2.7.6)
py
Runtime Error
4228
300428
1159
n, m, q=map(int, raw_input().split()) s=["0"*(m+2)]+["0"+raw_input()+"0" for i in range(n)]+["0"*(m+2)] visited=[[False]*(m+2) for i in range(n+2)] cnt=[[0]*(m+2) for i in range(n+2)] father=[[(-1, -1)]*(m+2) for i in range(n+2)] def dfs(cur_x, cur_y): visited[cur_x][cur_y]=True for delta_x, delta_y in ((-1, 0), (1, ...
s620239097
p03707
u663102311
1497448411
Python
Python (2.7.6)
py
Runtime Error
4215
321320
921
import fileinput iterator = fileinput.input() n, m, q = map(int, iterator.next().split()) board = [list(iterator.next()) for _ in range(n)] def flood_fill(visited, i, j, ai, bi, aj, bj): if i < ai or i > aj or j < bi or j > bj: return if board[i][j] != '1' or (i,j) in visited: return v...
s538466275
p03707
u663102311
1497447709
Python
Python (2.7.6)
py
Runtime Error
4217
333440
886
import fileinput data = list(fileinput.input()) n, m, q = map(int, data[0].split()) board = map(lambda x: list(x), data[1:1+n]) def flood_fill(visited, i, j, ai, bi, aj, bj): if i < ai or i > aj or j < bi or j > bj: return if board[i][j] != '1' or (i,j) in visited: return visited[(i,j)]...
s570666366
p03707
u663102311
1497446539
Python
Python (2.7.6)
py
Runtime Error
4216
193076
967
import fileinput from copy import deepcopy data = list(fileinput.input()) n, m, q = map(int, data[0].split()) board = map(lambda x: list(x), data[1:1+n]) queries = map(lambda x: x.split(), data[1+n:]) def flood_fill(board, i, j, ai, bi, aj, bj): if i < ai or i > aj or j < bi or j > bj: return if boa...
s350417839
p03707
u341087021
1496128927
Python
Python (3.4.3)
py
Runtime Error
4222
206108
1578
import sys import numpy as np import copy n, m, q = [int(x) for x in sys.stdin.readline().split()] aaa = [] def lister(n): s = [] for _ in range(n): a = input() s.append(list(map(int, a))) return s def normal_accumulator(s): for i in s: for j,k in enumerate(i): if j != 0: i[j] = k + i[j-1] for i i...
s628457546
p03707
u341087021
1496126905
Python
Python (3.4.3)
py
Runtime Error
4221
206152
1386
import sys import numpy as np import copy n, m, q = [int(x) for x in sys.stdin.readline().split()] def lister(n): s = [] for _ in range(n): a = input() s.append(list(map(int, a))) return s def normal_accumulator(s): for i in s: for j,k in enumerate(i): if j != 0: i[j] = k + i[j-1] for i in range(m)...
s451828751
p03707
u341926204
1496034244
Python
Python (3.4.3)
py
Runtime Error
4209
138552
792
def c(): import numpy as np n, m, q = map(int, input().split()) grid = np.zeros([n*2-1, m*2-1]) for i in range(n): s = list(map(int, input())) for j in range(m): grid[i*2][j*2] = s[j] for i in range(2*n-1, 2): # 0,1,2 for j in range(2*m-3, 2): # 0,1,2(,3) ...
s527802583
p03707
u104282757
1495950678
Python
Python (3.4.3)
py
Runtime Error
3316
178672
878
import numpy as np N, M, Q = map(int, input().split()) S = np.zeros((N+1, M+1), dtype='int') for n in range(1, N+1): S[n, 1:] = list(map(int, list(input()))) # count nodes N_cum = np.cumsum(np.cumsum(S, axis=0), axis=1) # count edges(row) ER_cum = np.cumsum(np.cumsum(S[:N, :]*S[1:, :], axis=0), axis=1) # coun...
s203052987
p03707
u777923818
1495939786
Python
Python (3.4.3)
py
Runtime Error
1780
223648
1693
# -*- coding: utf-8 -*- from collections import Counter from string import ascii_lowercase r_map = [] # check questions = [] result = "" N, M, Q = [int(n) for n in input().split()] for n_ in range(N): r_map.append([int(n) for n in list(input())]) for q in range(Q): questions.append([int(n) for n in input()....
s137231568
p03707
u382748202
1495939723
Python
Python (3.4.3)
py
Runtime Error
4210
103756
1141
N, M, Q = map(int, input().split()) dirs = [(1, 0), (-1, 0), (0, 1), (0, -1)] def step(x, y, id, ids, xmin, xmax, ymin, ymax): ids[y - ymin][x - xmin] = id for d in dirs: next_x = x + d[0] next_y = y + d[1] if next_x < xmin or next_x > xmax: continue if next_y < ymin...
s198338602
p03707
u777923818
1495939701
Python
Python (3.4.3)
py
Runtime Error
1642
81828
1696
# -*- coding: utf-8 -*- from collections import Counter from string import ascii_lowercase r_map = [] # check questions = [] result = "" N, M, Q = [int(n) for n in input().split()] for n_ in range(N): r_map.append([int(n) for n in list(input())]) for q in range(Q): questions.append([int(n) for n in input()....
s374206428
p03707
u777923818
1495939671
Python
Python (3.4.3)
py
Runtime Error
1764
223640
1699
# -*- coding: utf-8 -*- from collections import Counter from string import ascii_lowercase r_map = [] # check questions = [] result = "" N, M, Q = [int(n) for n in input().split()] for n_ in range(N): r_map.append([int(n) for n in list(input())]) for q in range(Q): questions.append([int(n) for n in input()...
s440648688
p03707
u971672726
1495939396
Python
Python (3.4.3)
py
Runtime Error
4206
41972
761
N, M, Q = list(map(int, input().split())) direction = [(1, 0), (0, 1), (0, -1), (-1, 0)] grid = [] checked = [] n = N m = M def search(x, y): for d in direction: i = x + d[0] j = y + d[1] if i < 0 or j < 0 or i >= n or j >= m: continue if not((i, j) in checked): checked.append((i, j)) ...
s958513580
p03707
u786082266
1495938999
Python
Python (2.7.6)
py
Runtime Error
4212
141328
807
import numpy as np def search(xt, yt, a): if a[xt, yt] == '1': a[xt, yt] = '2' search(xt - 1, yt, a) search(xt + 1, yt, a) search(xt, yt - 1, a) search(xt, yt + 1, a) n, m, q = map(int, raw_input().split()) arr = [] for i in range(n): s = raw_input() arr.append(list(s)) arr_np = np.array(arr) for i i...
s513480709
p03707
u786082266
1495938224
Python
Python (2.7.6)
py
Runtime Error
4212
141376
803
import numpy as np def search(xt, yt, a): if a[xt, yt] == '1': a[xt, yt] = '2' search(xt - 1, yt, a) search(xt + 1, yt, a) search(xt, yt - 1, a) search(xt, yt + 1, a) n, m, q = map(int, raw_input().split()) arr = [] for i in range(n): s = raw_input() arr.append(list(s)) arr_np = np.array(arr) for i i...
s790129666
p03707
u466826467
1495938210
Python
Python (3.4.3)
py
Runtime Error
4208
70752
846
N, M, Q = list(map(int, input().split())) S = [list(map(int, list(input()))) for i in range(N)] dx = [-1, 0, 1, 0] dy = [0, 1, 0, -1] def dfs(_x, _y): target_map[_x][_y] = 0 for l in range(0, 4): nx = _x + dx[l] ny = _y + dy[l] if 0 <= nx <= tmp_N and 0 <= ny <= tmp_M and target_map[n...
s683678998
p03708
u905582793
1578385375
Python
Python (3.4.3)
py
Runtime Error
17
3064
441
a=int(input()) b=int(input()) if a==b: print(1) exit() abin=bin(a)[2:] bbin=bin(b)[2:] la=len(abin) lb=len(bbin) if la==lb: while abin[0]==bbin[0]: abin=abin[1:] bbin=bbin[1:] while abin[0]=="0": abin=abin[1:] cbin=bbin[1:] while cbin[0]=="0": cbin=cbin[1:] c=2**(len(cbin))-1 a=int(abin,2) b=int(b...
s811454377
p03708
u905582793
1578384651
Python
Python (3.4.3)
py
Runtime Error
17
3064
414
a=int(input()) b=int(input()) if a==b: print(1) exit() abin=bin(a)[2:] bbin=bin(b)[2:] la=len(abin) lb=len(bbin) if la==lb: while abin[0]==bbin[0]: abin=abin[1:] bbin=bbin[1:] while abin[0]=="0": abin=abin[1:] cbin=bbin[1:] while cbin[0]=="0": cbin=cbin[1:] c=2**(len(cbin)) a=int(abin,2) lbnd=2**(...
s022782609
p03708
u905582793
1578384219
Python
Python (3.4.3)
py
Runtime Error
17
3064
413
a=int(input()) b=int(input()) if a==b: print(1) exit() abin=bin(a)[2:] bbin=bin(b)[2:] la=len(abin) lb=len(bbin) if la==lb: while abin[0]==bbin[0]: abin=abin[1:] bbin=bbin[1:] while abin[0]=="0": abin=abin[1:] cbin=bbin[1:] while cbin[0]=="0": cbin=cbin[1:] c=2**(len(cbin)) a=int(abin,2) lbnd=2**(...
s296589495
p03708
u905582793
1578384094
Python
Python (3.4.3)
py
Runtime Error
18
3064
405
a=int(input()) b=int(input()) if a==b: print(1) exit() abin=bin(a)[2:] bbin=bin(b)[2:] la=len(abin) lb=len(bbin) if la==lb: while abin[0]==bbin[0]: del abin[0] del bbin[0] while abin[0]=="0": del abin[0] cbin=bbin[1:] while cbin[0]=="0": del cbin[0] c=2**(len(cbin)) a=int(abin,2) lbnd=2**(lb-1)+c ...
s232857925
p03708
u247366051
1562013497
Python
Python (3.4.3)
py
Runtime Error
18
2940
531
#include <stdio.h> #include <math.h> #include <algorithm> long long a, b; int main() { scanf("%lld%lld", &a, &b); if (a == b)return !puts("1"); int _ = 60; while (~(-- _)) if ((a & (1ll << _)) ^ (b & (1ll << _))) { a &= (1ll << (_ + 1)) - 1, b &= (1ll << (_ + 1)) - 1; ...
s545117718
p03708
u263933075
1562013040
Python
Python (3.4.3)
py
Runtime Error
18
2940
529
#include <stdio.h> #include <math.h> #include <algorithm> long long a, b; int main() { scanf("%lld%lld", &a, &b); if (a == b)return !puts("1"); int _ = 60; while (~(-- _)) if ((a & (1ll << _)) ^ (b & (1ll << _))) { a &= (1ll << (_ + 1)) - 1, b &= (1ll << (_ + 1)) - 1; ...
s593213810
p03708
u263933075
1561992410
Python
Python (3.4.3)
py
Runtime Error
17
2940
140
n,a,b=map(int,input().split()) if b<a: print(0) elif n==1 and a!=b: print(0) else: A=a*(n-1)+b B=a+b*(n-1) print(B-A+1)
s080479313
p03708
u905506603
1539829564
Python
Python (2.7.6)
py
Runtime Error
10
2696
355
a=bin(input()+(1<<60))[2:] b=bin(input()+(1<<60))[2:] while a[0]==b[0]: a=a[1:] b=b[1:] assert a[0]=="0" and b[0]=="1" result=int("1"+"0"*(len(a)-1), 2)-int(a, 2) b=b[1:] while b and b[0]=="0": b=b[1:] if not b: result=result*2+1 else: b="1"*len(b) if int(b, 2)>=int(a, 2): result+=(1<<(len(a)-1)) else: resul...
s875035194
p03708
u211742028
1529867799
Python
Python (3.4.3)
py
Runtime Error
18
3188
495
import math A = int(input()) B = int(input()) if B < A: A,B = B,A if A == B: print(1) else: t = int(math.floor(math.log2(B))) while (A & 2**t) == (B & 2**t): if A & 2**t: A -= 2**t B -= 2**t t-=1 ans = 2**t - A # [A,2^t-1] r = t-1 while 2**t ...
s702638181
p03708
u917874190
1497282678
Python
Python (2.7.6)
py
Runtime Error
11
2692
427
A = int(raw_input()) B = int(raw_input()) ans = 0 bin_A = bin(A)[2:] bin_B = bin(B)[2:] bin_A = bin_A.zfill(len(bin_B)) x1 = None x2 = None for i in range(len(bin_A)): if x1 is None and bin_A[i] != bin_B[i]: x1 = len(bin_A)-i elif x1 is not None and x2 is None and bin_B[i]=='1': x2 = len(bin_A)-...
s192021211
p03708
u067983636
1495939724
Python
Python (3.4.3)
py
Runtime Error
17
3188
987
A = int(input()) B = int(input()) binA = bin(A)[2:] binB = bin(B)[2:] #print("A: {0}\nB: {1}".format(binA, binB)) if A == B: print(1) elif len(binB) - len(binA) > 1: maxnum = int("1" * len(binB), 2) print(maxnum - A + 1) elif len(binB) - len(binA) == 1: res = 2 * (int("1" * len(binA), 2) - A + 1) ...