code1 stringlengths 16 427k | code2 stringlengths 16 427k | similar int64 0 1 | pair_id int64 6.82M 181,637B ⌀ | question_pair_id float64 101M 180,471B ⌀ | code1_group int64 2 299 | code2_group int64 2 299 |
|---|---|---|---|---|---|---|
import sys,queue,math,copy,itertools,bisect,collections,heapq
def main():
sys.setrecursionlimit(10**7)
INF = 10**7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
N = NI()
up = 0
down = 0
mp = []
mm = []
for _ in range(N):
... | from sys import stdin
readline = stdin.buffer.readline
def r_map(): return map(int, readline().rstrip().split())
def r_list(): return list(r_map())
def main():
N = int(readline().rstrip())
A = r_list()
M = max(A)
d = [0] * (M + 1)
g = True
for a in A:
d[a] += 1
for i in range(2, M +... | 0 | null | 13,891,757,488,290 | 152 | 85 |
n = int(input())
i = 1
ret = ""
while True:
x = i
if x % 3 == 0:
ret += " " + str(i)
elif x % 10 == 3:
ret += " " + str(i)
else:
x //= 10
while x != 0:
if x % 10 == 3:
ret += " " + str(i)
break
x //= 10
i+=1
... | n=int(input())
a,c,i=[],0,1
while i <= n:
if c==0:
x=i
if x%3==0:
print(' '+str(i), end='')
i+=1
continue
c=0
if x%10==3:
print(' '+str(i), end='')
i+=1
continue
x//=10
if x == 0:
i+=1
continue
else:
... | 1 | 950,750,277,510 | null | 52 | 52 |
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
X = int(readline())
def make_divisors(n):
lower_divisors = []
i = 1
while i*i <= n:
if n % i == 0:
lower_divisors.append(i)
i += 1
return lower_divisors
A = ... | x = int(input())
n = 120
for i in range(n):
for j in range(i):
if x == i**5-j**5:
print(i,j)
exit(0)
if x == i**5+j**5:
print(i,-j)
exit(0) | 1 | 25,588,417,164,530 | null | 156 | 156 |
import sys
N = int(input())
S = input()
if N%2!=0 :
print("No")
sys.exit(0)
else:
for i in range(int(N/2)):
if S[i]!=S[i+int(N/2)]:
print("No")
sys.exit(0)
print("Yes") | N=int(input())
S=input()
if N%2==1:print('No')
else:
s1,s2=S[:N//2],S[N//2:]
ok=1
for i in range(N//2):
if s1[i]!=s2[i]:
print('No')
ok=0
break
if ok==1:print('Yes') | 1 | 146,604,704,954,878 | null | 279 | 279 |
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
if A1 < B1:
A1, A2, B1, B2 = B1, B2, A1, A2
if A1*T1+A2*T2 == B1*T1+B2*T2:
print('infinity')
exit()
if (A1-B1)*T1 > (B2-A2)*T2:
print(0)
exit()
d = abs(A1*T1+A2*T2 - B1*T1-B2*T2) # T1,T2が終わった... | h, w, k = map(int, input().split())
mat = [input() for i in range(h)]
num = 0
ans = [[0]*w for _ in range(h)]
heights = [0]*h
for i in range(h):
for j in range(w):
if mat[i][j] == "#":
heights[i] += 1
hs = []
for v in range(h):
if heights[v] >= 1:
hs.append(v)
for i in range(len(hs)):
... | 0 | null | 137,210,366,243,098 | 269 | 277 |
A = input()
B = input()
se = set(["1","2","3"])
a = se-set([A,B])
print(a.pop()) | x='123'
for _ in range(2):
x=x.replace(input(),'')
print(x)
| 1 | 110,565,142,482,668 | null | 254 | 254 |
import math
char = str(input())
char = char.replace('?','D')
print(char)
| t = input()
if(len(t) == 1):
if (t[0] == '?'): t = "D"
if(t[0] == '?'):
if (t[1] == 'D'): t = "".join(['P' , t[1:]])
elif(t[1] == '?'): t = "".join(['PD', t[2:]])
else: t = "".join(['D' , t[1:]])
if(t[-1] == '?'):
t = "".join([t[:-1], 'D'])
for i in range(len(t)-1):
if(t[i] == '?')... | 1 | 18,413,735,896,150 | null | 140 | 140 |
def main():
import sys
input = sys.stdin.readline
N = int(input())
plus = []
minus = []
total = 0
for _ in range(N):
s = input().strip()
h = 0
bottom = 0
for ss in s:
if ss == "(":
h += 1
else:
h -= 1
... | # coding: utf-8
import sys
from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import combinations, product
#import bisect# lower_bound etc
#import numpy as n... | 1 | 23,785,970,484,260 | null | 152 | 152 |
n = input()
A = [i for i in input().split()]
A.reverse()
print(' '.join(A)) | num = int(input())
numbers = list(map(int,input().split()))
for i in reversed(numbers):
print(i,end="")
if i != numbers[0]:
print(" ",end="")
print()
| 1 | 987,524,937,300 | null | 53 | 53 |
def main():
N, S = map(int, input().split())
A = tuple(map(int, input().split()))
MOD = 998244353
dp = [[0]*(S+1) for _ in range(N+1)]
dp[0][0] = 1
# morau
for i, a in enumerate(A):
dp[i][0] = pow(2, i, MOD)
for j in range(S+1):
if j >= a:
... | def main():
h,w,k=map(int,input().split())
grid=[input() for _ in [0]*h]
ans=[[0]*w for _ in [0]*h]
berry=0
for i in range(h):
if "#" in grid[i]:
cnt=0
berry+=1
for j in range(w):
if grid[i][j]=="#":
cnt+=1
... | 0 | null | 81,066,397,215,440 | 138 | 277 |
import sys
def resolve(in_):
A, B = map(int, in_.readline().split())
for i in range(1, 1251):
if i * 8 // 100 == A and i // 10 == B:
return i
return -1
def main():
answer = resolve(sys.stdin.buffer)
print(answer)
if __name__ == '__main__':
main()
| alp=list("abcdefghijklmnopqrstuvwxyz")
print(alp[alp.index(input())+1]) | 0 | null | 74,084,625,750,762 | 203 | 239 |
a = int(input())
b = int(a + a ** 2 + a ** 3)
print(b)
| n = int(input())
pr = {}
for i in range(n):
s = input()
if pr != s:
pr[s] = True
print(len(pr))
| 0 | null | 20,356,589,983,688 | 115 | 165 |
n=int(input())
Ns=list(map(int, input().split() ) )
ans=0
for i in range(n):
for j in range(i,n):
for k in range(j,n):
a , b , c = sorted([Ns[i] , Ns[j] , Ns[k]])
if a+b>c and a!=b and b!=c:
ans+=1
print(ans)
| nums = input().split(' ')
a = int(nums[0])
b = int(nums[1])
c = int(nums[2])
d = int(nums[3])
multi = []
multi.append(a * c)
multi.append(a * d)
multi.append(b * c)
multi.append(b * d)
ans = - 10 ** 18
for i in range(4):
if multi[i] > ans:
ans = multi[i]
print(ans) | 0 | null | 4,039,496,426,910 | 91 | 77 |
import math
x1, y1, x2, y2 = map(float, input().split())
a = x2 - x1
b = y2 - y1
print(math.sqrt(a**2 + b**2))
| import math
x1,y1,x2,y2=input().split()
x1=float(x1)
y1=float(y1)
x2=float(x2)
y2=float(y2)
r=math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
print(r) | 1 | 154,350,161,810 | null | 29 | 29 |
S,T=list(input().split())
T+=S
print(T)
| def q1():
S, T = input().split()
print('{}{}'.format(T, S))
if __name__ == '__main__':
q1()
| 1 | 103,057,429,224,288 | null | 248 | 248 |
a,b,c=map(int,input().split())
d=0
while b<=a:
b*=2
d+=1
while c<=b:
c*=2
d+=1
print("Yes"if d<=int(input())else"No") | import math
n = float(raw_input())
a = n * n * math.pi
b = 2 * n * math.pi
print ('%.6f %.6f' % (a, b)) | 0 | null | 3,752,089,901,212 | 101 | 46 |
import numpy as np
n = int(input())
k = np.arange(1,n+1)
d = n // k
print((k*d*(d+1)//2).sum()) | N=int(input())
ans = 0
for k in range(1,N+1):
n_ = N // k
ans_ = k*n_*(n_+1)//2
ans+= ans_
print(ans) | 1 | 11,052,279,597,572 | null | 118 | 118 |
N=int(input())
S=input()
l=[]
for i in range(N-1):
if S[i]!=S[i+1]:
l.append(S[i])
l.append(S[N-1])
print(len(l)) | N=int(input())
S=list(map(str,input()))
ans=1
for i in range(N-1):
if S[i]!=S[i+1]:
ans+=1
print(ans) | 1 | 169,822,736,543,460 | null | 293 | 293 |
from math import *
def main():
n = int(input())
print(n+n**2+n**3)
main() | n,k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
b = [0]*(k-n)
a.extend(b)
print(sum(a[k:])) | 0 | null | 44,398,836,872,580 | 115 | 227 |
n = int(input())
c = list('abcdefghijklmnopqrstuvwxyz')
ans = []
def calc(k):
if k == 0:
return ''
else:
k -= 1
return calc(k // 26) + c[k % 26]
print(calc(n))
| def main():
n = int(input())
ab_max = n-1
ans = sum(ab_max // a for a in range(1, n))
return ans
if __name__ == '__main__':
print(main())
| 0 | null | 7,290,610,500,708 | 121 | 73 |
import sys
l = sys.stdin.readlines()
for i in l:
if "?" in i:
break
else:
str = i.replace('/','//')
print(eval(str)) | n = int(input())
s = str(input())
a = 0
c = len(s)//2
if n % 2 == 0:
for i in range(c):
if s[i] == s[c+i]:
a += 1
if a == n/2 :
print("Yes")
else :
print("No")
else :
print("No") | 0 | null | 73,905,426,892,038 | 47 | 279 |
x = int(input())
print('1' if x == 0 else '0') | x = not(int(input()))
print(int(x)) | 1 | 2,932,677,675,682 | null | 76 | 76 |
import sys
from collections import defaultdict
# from collections import Counter
# from queue import PriorityQueue
# sys.setrecursionlimit(2000000)
def distance(X, Y, start, goal):
ans = float('inf')
tmp = goal - start
if tmp < ans:
ans = tmp
# start ~ X ~ Y ~ goal,
tmp = abs(X - start) +... | n = int(input())
s = input()
ans = 0
for i in range(n-2):
if s[i] == 'A':
if s[i+1] == 'B':
if s[i+2] == 'C':
ans += 1
print(ans)
| 0 | null | 71,847,948,908,018 | 187 | 245 |
N,X,M = map(int,input().split())
ls = [X]
for i in range(M):
Ai = ls[-1]**2 % M
if Ai in ls:
loop = ls[ls.index(Ai):]
lenloop = len(loop)
sumloop = sum(loop)
startls = ls[:ls.index(Ai)]
break
ls.append(Ai)
if N <= len(startls):
ans = sum(startls[:N])
else:
ans... | import collections
n = int(input())
x = list(map(int, input().split()))
y = collections.Counter(x)
for i in range(1, len(x)+2):
print(y[i], end = "\n") | 0 | null | 17,836,028,177,570 | 75 | 169 |
# Transformation
string = input()
commandAmount = int(input())
for i in range(commandAmount):
command = input().rstrip().split()
start = int(command[1])
end = int(command[2])
if command[0] == 'print':
print(string[start : end + 1]) # ここはコメントアウトしないこと
elif command[0] == 'reverse':
re... | N, K = map(int, input().split())
*A, = map(int, input().split())
b = [i for i in A]
for c in range(K):
buf = [0]*(N+1)
for i, j in enumerate(b):
buf[max(i-j, 0)] += 1
buf[min(i+j+1, N)] -= 1
for i in range(1, N+1):
buf[i] += buf[i-1]
b = [buf[i] for i in range(N)]
if all([i=... | 0 | null | 8,787,487,456,360 | 68 | 132 |
count, outrate = map(int, input().split())
if count >= 10:
result = outrate
print(result)
else:
result = outrate + 100 * (10 - count)
print(result)
| H,W,K = map(int,input().split())
A = []
for i in range(H):
b = list(input())
b.append("0")
A.append(b)
ans = 10**6
for i in range(2**(H-1)):
p = "0" + str(H-1)
bin_list = list(format(i,p+"b"))
sec = []
for i in range(H-1):
if bin_list[i] == "1":
sec.append(i)
sec.app... | 0 | null | 56,291,902,493,540 | 211 | 193 |
#162B
#FizzBuzz Sum
n=int(input())
print(sum(x for x in range(1,n+1) if x%3!=0 and x%5!=0)) | n,k = map(int,input().split())
a = list(map(int,input().split()))
def cmb(n, r, mod):
if ( r<0 or r>n ):
return 0
r = min(r, n-r)
return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10**5+100
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + ... | 0 | null | 65,694,933,894,272 | 173 | 242 |
a,b,c=[int(i) for i in input().split()]
if a < b and b < c:
print("Yes");
else:
print("No"); | import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))
n... | 0 | null | 39,908,189,687,808 | 39 | 227 |
a, b = map(int, input().split())
mat = [map(int, input().split()) for i in range(a)]
vec = [int(input()) for i in range(b)]
for row in mat:
print(sum([x*y for x, y in zip(row, vec)]))
| def modpow(val, n, mod):
ret = 1
while n:
if n & 1:
ret = (ret * val) % mod
val = (val * val) % mod
n = n >> 1
return ret
mod = 10 ** 9 + 7
n, k = map(int, input().split())
my_dict = dict()
ret = 0
for i in range(k, 0, -1):
tmp = modpow(k // i, n, mod)
cnt = 2... | 0 | null | 18,997,689,141,740 | 56 | 176 |
N,K = map(int,input().split())
S = [tuple(map(int,input().split())) for _ in range(K)]
MOD=998244353
dp=[0]*N
dp[0]=1
for i in range(N-1):
x = dp[i]
dp[0]=0
for k in range(K):
l,r = S[k]
if i+l < N:
dp[i+l]+=x
dp[i+l]%=MOD
if i+r+1 < N:
dp[i+r+1]-=... | def scoring(d, t, k=10):
arr = [l for l in last]
arr[t] = d
penalty = sum((d - l) * c for l, c in zip(arr, C))
score = S[d][t] - penalty
score -= (min(D, d + k) - d - 1) * penalty
return score
D = int(input())
C = list(map(int, input().split()))
S = []
for _ in range(D):
s = list(map(int, i... | 0 | null | 6,214,531,196,608 | 74 | 113 |
from scipy.sparse.csgraph import csgraph_from_dense
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
import numpy as np
N,M,L=map(int,input().split())
A=[0]*M
B=[0]*M
C=[0]*M
for i in range(M):
A[i],B[i],C[i] = map(int,input().split())
A[i] -=1
B[i] -=1
Q=int(input())
ST=[... | # N=int(input())
A,B=[int(x) for x in input().rstrip().split()]
if A<=B*2:
print(0)
else:
print(A-B*2) | 0 | null | 170,222,048,869,288 | 295 | 291 |
s = input()
summation = sum([int(i) for i in s])
is_mul = summation%9
if is_mul == 0:
print("Yes")
else:
print("No") | n = int(input())
a = set([input() for i in range(n)])
print(len(a)) | 0 | null | 17,321,902,335,738 | 87 | 165 |
# B Popular Vote
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse = True)
border = sum(A) / (4 * M)
cnt = 0
for a in A:
if a >= border:
cnt += 1
else:
break
if cnt >= M:
print("Yes")
else:
print("No")
| N,M=map(int, input().split())
a=[0]*(N+1)
w=[0]*(N+1)
for _ in range(M):
p,s=input().split()
p=int(p)
if s=='AC':
a[p]=1
else:
if a[p]==0:
w[p]+=1
a2=0
w2=0
for n in range(N+1):
if a[n]==1:
a2+=a[n]
w2+=w[n]
print(a2, w2)
| 0 | null | 66,382,074,374,182 | 179 | 240 |
def solve(sup,rest,digit,used1,used2):
if rest<0:
return 0
if digit==0:
if rest==0:
return 1
else:
return 0
sum=0
for i in range(1,sup+1):
if i!=used1 and i!=used2:
if used1==0:
sum+=solve(sup,rest-i,digit-1,i,used2)
... | def get_num(n, x):
ans = 0
for n3 in xrange(min(n, x - 3), (x + 2) / 3, -1):
for n2 in xrange(min(n3 - 1, x - n3 - 1), (x - n3) / 2, -1):
if n3 + min(n2 - 1, x - n3 - n2):
ans += 1
# for n1 in xrange(min(n2 - 1, x - n3 - n2), x - n3 - n2 - 1, -1):
# ... | 1 | 1,281,927,099,168 | null | 58 | 58 |
def main():
a, b, c, d = map(int, input().split())
if a*b > 0 and c*d > 0 and a*c < 0:
print(max(a*d, b*c))
else:
print(max(a*c, b*d, 0))
if __name__ == "__main__":
main() | a,b,c,d = map(int, input().split())
if a >=0:
if c > 0:
print(b * d)
elif d < 0:
print(a * d)
else:
print(b*d)
elif a < 0 and b >= 0:
if c >= 0:
print(b * d)
elif d <= 0:
print(a * c)
else:
ac = a * c
bd = b * d
if ac >= bd:
... | 1 | 3,030,434,519,502 | null | 77 | 77 |
n, a, b = map(int, input().split())
if a % 2 == b % 2:
print((b - a) // 2)
else:
if a > n - b + 1:
rest = (b - a) // 2
print(n - a - rest)
else:
rest = (b - a) // 2
print(b - 1 - rest)
#print(max(a, n - b + 1) - 1) | n = int(input())
my_cards = {input() for _ in range(n)}
lost_cards = (
"{} {}".format(s, i)
for s in ('S', 'H', 'C', 'D')
for i in range(1, 13 + 1)
if "{} {}".format(s, i) not in my_cards
)
for card in lost_cards:
print (card) | 0 | null | 54,940,630,735,620 | 253 | 54 |
# print(max([len(v) for v in input().split('S')]))
d = {
'RRR': 3,
'RRS': 2,
'RSR': 1,
'RSS': 1,
'SRR': 2,
'SRS': 1,
'SSR': 1,
'SSS': 0,
}
print(d[input()])
| import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
s = str(readline().rstrip().decode('utf-8'))
if s == "RRR":
print(3)
elif s == "RRS" or s == "SRR":
print(2)
elif s.count("R") == 0:
print(0)
else:
print(1)
if __name__ == '__ma... | 1 | 4,924,109,114,358 | null | 90 | 90 |
X=int(input())
#m1,d1=map(int,input().split())
#hl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
flag=0
for i in range(1,1001):
if i*100 <= X and X <= i*105:
flag=1
break
print(flag)
| # -*- coding:utf-8 -*-
import math
def insertion_sort(num_list, length, interval):
cnt = 0
for i in range(interval, length):
v = num_list[i]
j = i - interval
while j >= 0 and num_list[j] > v:
num_list[j+interval] = num_list[j]
j = j - interval
cnt = ... | 0 | null | 63,432,378,583,560 | 266 | 17 |
X,Y,A,B,C=map(int,input().split())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
R=list(map(int,input().split()))
P.sort(reverse=True)
Q.sort(reverse=True)
R.sort(reverse=True)
P.append(float("inf"))
Q.append(float("inf"))
ans=sum(P[:X]+Q[:Y])
rfinish=False
gfinish=False
r,g,f=X-1,Y-1,0
while f<C an... | K = int(input())
S = str(input())
SK = S[0: (K)]
if len(S) <= K:
print(S)
else:
print(SK + '...') | 0 | null | 32,136,841,133,812 | 188 | 143 |
n,a,b = map(int,input().split())
A=n//(a+b)
B=n%(a+b)
ans = a * A
if B>=a:
ans += a
else:
ans += B
print(ans) | N, A, B = input().split(' ')
N = int(N)
A = int(A)
B = int(B)
a = A * (N // (A+B))
if (N%(A+B)) > A:
a += A
else:
a += (N%(A+B))
print(a) | 1 | 55,482,209,919,488 | null | 202 | 202 |
x,y = map(int,input().split())
a = [0]*210
a[:3] = [300000, 200000, 100000]
if x == y and x == 1:
print(1000000)
else:
print(a[x-1] + a[y-1])
| #!/usr/bin/env python3
x, y = map(int, input().split())
ans = (x == y == 1) * 400000
ans += 100000 * max(0, 4 - x)
ans += 100000 * max(0, 4 - y)
print(ans)
| 1 | 141,048,758,711,260 | null | 275 | 275 |
N = int(input())
XL = [list(map(int, input().split())) for x in range(N)]
XL = sorted(XL, key=lambda x: x[0]+x[1])
cnt = 0
prev_right = -10**9+10
for x, l in XL:
left = x - l
right = x + l
if left >= prev_right:
cnt += 1
prev_right = right
print(cnt)
| class Modulo_Error(Exception):
pass
class Modulo():
def __init__(self,a,n):
self.a=a%n
self.n=n
def __str__(self):
return "{} (mod {})".format(self.a,self.n)
#+,-
def __pos__(self):
return self
def __neg__(self):
return Modulo(-self.a,self.n)
#等号... | 0 | null | 77,894,107,408,220 | 237 | 214 |
ans = ["1","2","3"]
a,b = input(),input()
ans.remove(a)
ans.remove(b)
print(ans[0])
| N, K =map(int,input().split())
p = list(map(int,input().split()))
for i in range(N):
for n in range(N-1):
if p[n]>p[n+1]:
tmp = p[n]
p[n] = p[n+1]
p[n+1] = tmp
ans =0
for i in range(K):
ans += p[i]
print(ans) | 0 | null | 60,881,743,294,812 | 254 | 120 |
s = input()
p = input()
ret = 'No'
tts = s + s[:len(p)]
if p in tts: ret = 'Yes'
print(ret)
| n=str(input())
a=len(n)
N=list(n)
m=str(input())
A=len(m)
x=0
for i in range(a):
C=[]
for i in range(A):
C.append(N[i])
B=''.join(C)
c=N[0]
if B==m:
x=x+1
N.remove(c)
N.append(c)
if x>0:
print('Yes')
else:
print('No')
| 1 | 1,770,323,494,632 | null | 64 | 64 |
input()
A = [i for i in input().split()]
A.reverse()
print(' '.join(A)) | raw_input()
print " ".join([i for i in raw_input().split()][::-1]) | 1 | 979,633,127,220 | null | 53 | 53 |
number = int(input())
Total = []
for i in range(1, number + 1):
if number % 3 == 0 and i % 5 ==0:
"FizzBuzz"
elif i % 3 ==0:
"Fizz"
elif i % 5 == 0:
"Buzz"
else:
Total.append(i)
print(sum(Total))
| n = int(input())
x = 0
for i in range(1, n + 1):
if i % 5 == 0 or i % 3 == 0:
pass
else:
x += i
print(x) | 1 | 34,929,952,031,140 | null | 173 | 173 |
N = int(input())
S, T = map(str, input().split())
S = list(S)
T = list(T)
ANS = []
for i in range(N):
ANS.append(S[i])
ANS.append(T[i])
ANS = ''.join(ANS)
print(ANS) | d=list(map(int,input().split()))
c=list(input())
class dice(object):
def __init__(self, d):
self.d = d
def roll(self,com):
a1,a2,a3,a4,a5,a6=self.d
if com=="E":
self.d = [a4,a2,a1,a6,a5,a3]
elif com=="W":
self.d = [a3,a2,a6,a1,a5,a4]
elif com=="S":
self.d = [a5,a1,a3,a4,a6,a2]
elif com=="N":
... | 0 | null | 56,053,891,383,350 | 255 | 33 |
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): r... | data = list(map(int,input().split()))
if(data[0] < data[1]): data[0],data[1] = data[1],data[0]
def gcd(x,y):
return x if y == 0 else gcd(y,x%y)
print(gcd(data[0],data[1]))
| 0 | null | 20,900,766,818,678 | 184 | 11 |
N=input()
if N.isupper():
print("A")
else:
print("a") | import sys
# sys.setrecursionlimit(100000)
from collections import deque
def input():
return sys.stdin.readline().strip()
def input_int():
return int(input())
def input_int_list():
return [int(i) for i in input().split()]
def main():
s = deque(list(input()))
q = input_int()
inverse = Fal... | 0 | null | 34,456,173,220,300 | 119 | 204 |
L = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
L = L.split(", ")
k = int(input())
print(L[k-1]) | import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))
# sys.setrecursionlimit(10**6)
def solve():
s = inp().strip();
dic = defaultdict(int); dic[0] = 1
# sett.add(0)
ans = 0; cu... | 0 | null | 40,350,769,187,300 | 195 | 166 |
k = int(input())
s = input()
MOD = 10**9+7
class Facts():
# O(max_num)
def __init__(self, max_num=10**5, p=10**9+7):
self.p = p
self.max_num = max_num
self.fact = [1] * (self.max_num + 1)
self.rev = [1] * (self.max_num + 1)
for i in range(1, self.max_num + 1):
self.fact[i] ... | N, M, L = map(int, raw_input().split())
nm = [map(int, raw_input().split()) for n in range(N)]
ml = [map(int, raw_input().split()) for m in range(M)]
ml_t = []
for l in range(L):
tmp = []
for m in range(M):
tmp.append(ml[m][l])
ml_t.append(tmp)
for n in range(N):
tmp1 = nm[n]
col = [0]*L
... | 0 | null | 7,128,057,263,172 | 124 | 60 |
while True:
m,f,r=map(int,input().split())
if (m,f,r)==(-1,-1,-1):
break
h=m+f
if m == -1 or f == -1:
print('F')
elif h >= 80:
print('A')
elif h>=65 and h<80:
print('B')
elif h>=50 and h<65:
print('C')
elif h>=30 and h<50 and r>=50:
print('C')
elif h>=30 and h<50 and r<50:
... | a=map(int,raw_input().split())
print(str(a[0]*a[1])+" "+str(2*(a[0]+a[1]))) | 0 | null | 749,646,485,210 | 57 | 36 |
N = int(input())
A = sorted(list(map(int,input().split())))
ans = "YES"
for i in range(1,N,2):
boollist = [ A[i-1] == A[i] ]
if i < N-1 :
boollist.append(A[i] == A[i+1])
if any(boollist):
ans = "NO"
break
print(ans) | # -*- coding:utf-8 -*-
class Cards:
trump = [False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,False,F... | 0 | null | 37,276,548,991,460 | 222 | 54 |
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]
# 購買する全パターンを回す
most_row_price = 10**10
for i in range(2**n):
comb = str(bin(i)[2:]).zfill(n)
# 購買パターン毎の購入金額と理解度を算出する
money_per_pattern = [0] * n # 購買パターン毎の金額の初期化
understanding = [0] * m # 理解度の初期化
total... | import math
N,M=map(int,input().split())
def comb(num,k):
if num<2:
return 0
return math.factorial(num)/(math.factorial(k)*math.factorial(num-k))
ans=int(comb(N,2)+comb(M,2))
print(ans) | 0 | null | 33,927,833,515,800 | 149 | 189 |
import sys
def main():
sys.stdin.readline()
list1 = [int(i) for i in sys.stdin.readline().split()]
print(min(list1), max(list1), sum(list1))
if __name__ == '__main__':
main()
| A,B,C = map(int,input().split())
if A == B:
if A != C:
print("Yes")
else:
print("No")
else:
if B == C or A == C:
print("Yes")
else:
print("No") | 0 | null | 34,469,522,267,164 | 48 | 216 |
def resolve():
S = input()
print('Yes' if S[2]==S[3] and S[4]==S[5] else 'No')
resolve() | co ="coffee"
S = input()
if S[2]!=S[3]:
print("No")
elif S[4]!=S[5]:
print("No")
else:
print("Yes") | 1 | 42,330,873,321,702 | null | 184 | 184 |
res = []
n = int(input())
for i in range(n):
r = input()
res.append(r)
ac = res.count("AC")
wa = res.count("WA")
tle = res.count("TLE")
re = res.count("RE")
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re)) | n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
status = input()
if status == 'AC':
ac += 1
elif status == 'WA':
wa += 1
elif status == 'TLE':
tle += 1
else:
re += 1
print('AC x', ac)
print('WA x', wa)
print('TLE x', tle)
print('RE x', re)
| 1 | 8,677,545,423,260 | null | 109 | 109 |
import math as mt
a,b,h,m=map(int, input().split())
print(mt.sqrt(a**2+b**2-2*a*b*mt.cos(2*mt.pi*(1/12*(h+m/60)-m/60))))
| import math
a, b, h, m = map(int, input().split())
x = 6 * m
y = 30 * h + 0.5 * m
C = max(x, y) - min(x, y)
C = min(C, 360 - C)
print(math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(C))))
| 1 | 20,196,075,671,770 | null | 144 | 144 |
def resolve():
N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]
good = [True for i in range(N)]
for a, b in AB:
a, b = a-1, b-1
if H[a] < H[b]:
good[a] = False
elif H[a] == H[b]:
... | n = int(input())
s = input().replace("ABC", "")
print((n-len(s))//3)
| 0 | null | 62,354,509,163,798 | 155 | 245 |
n = int(input())
a = int(n**0.5+1)
ans = [0]*n
for x in range(1, a):
for y in range(1, a):
for z in range(1, a):
if x**2 + y**2 + z**2 + x*y + y*z + z*x <= n:
ans[x**2 + y**2 + z**2 + x*y + y*z + z*x -1] += 1
[print(i) for i in ans] | while True:
text = input()
if text == '0':
break
total = 0
for a in range(len(text)):
total += int(text[a])
print(total) | 0 | null | 4,798,304,507,062 | 106 | 62 |
a, b, c, d = map(int, input().split())
x = 0
y = 0
while c > 0:
c -= b
x += 1
while a > 0:
a -= d
y += 1
if x <= y:
print('Yes')
else:
print('No')
| def main():
s = input()
t = input()
ans = 0
for i, char in enumerate(s):
if char != t[i]:
ans += 1
print(ans)
if __name__ == '__main__':
main()
| 0 | null | 20,236,793,265,718 | 164 | 116 |
a, b = input().split()
a = int(a)
b = int(b)
if a > b:
print('a > b')
elif a < b:
print('a < b')
else:
print('a == b')
| x=raw_input()
list=x.split()
a=int(list[0])
b=int(list[1])
if a<b:
print 'a < b'
elif a>b:
print 'a > b'
elif a==b:
print 'a == b' | 1 | 365,547,475,100 | null | 38 | 38 |
x,n=map(int,input().split())
if n==0:
print(x)
exit()
p=[int(y) for y in input().split()]
a=0
for i in range(101):
if x-a not in p:
print(x-a)
break
elif x+a not in p:
print(x+a)
break
a+=1 | X, N = map(int, input().split())
p_list = list(map(int, input().split()))
if N == 0:
print(X)
else:
for i in range(0,100):
if not X-i in p_list:
print(X-i)
break
elif not X+i in p_list:
print(X+i)
break | 1 | 14,007,025,238,820 | null | 128 | 128 |
mod = 998244353
N, S = map(int, input().split())
A = list(map(int, input().split()))
dp = [[0]*(S+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1,N+1):
dp[i][0] = dp[i-1][0]*2%mod
for i in range(1,N+1):
for j in range(1,S+1):
dp[i][j] = dp[i-1][j]*2%mod
if j>=A[i-1]:
dp[i][j] ... | #!/usr/bin/env python3
import sys
input = sys.stdin.readline
MOD = 998244353
n, s = map(int, input().split())
a = [int(item) for item in input().split()]
dp = [[0] * (s + 1) for _ in range(n+1)]
dp[0][0] = 1
for i, item in enumerate(a):
for j in range(s, -1, -1):
if dp[i][j] == 0:
continue
... | 1 | 17,603,634,760,228 | null | 138 | 138 |
# -*- coding: utf-8 -*-
H, N = map(int, input().split(' '))
nums = [float('inf') for _ in range(H+1)]
nums[0] = 0
for _ in range(N):
a, b = map(int, input().split(' '))
for i in range(H + 1):
j = min(H, i+a)
nums[j] = min(nums[j], nums[i] + b)
print(nums[H]) | h,n=map(int,input().split())
A=[]
B=[]
for i in range(n):
a,b=map(int,input().split())
A.append(a)
B.append(b)
dp=[10**10 for i in range(h+1)]
dp[h]=0
for i in reversed(range(1,h+1)):
for j in range(n):
if i-A[j]>=0:
dp[i-A[j]]=min(dp[i-A[j]],dp[i]+B[j])
else:
... | 1 | 81,220,359,735,120 | null | 229 | 229 |
def gcd(a,b):
# assume a,b are +ve integers.
if a>b:
a,b = b,a
if b%a==0:
return a
return gcd(a,b%a)
print(360//(gcd(360,int(input())))) | sentence = input().lower()
ans = input().lower()
doublesentence = sentence + sentence
print("Yes" if ans in doublesentence else "No")
| 0 | null | 7,475,016,463,798 | 125 | 64 |
n = int(input())
ans = ['a'] # 最初の一文字は'a'で固定
for i in range(n-1): # 'a'に'n-1'文字分ループで足す
tmp = [] # リセット
for j in ans:
l = len(set(j)) # 'j'の使用文字種の数をカウント
for k in range(l+1): # 'j'の使用文字種の数 '+1'回ループして...
tmp.append(j + chr(ord('a') + k)) # 'j'に appendする
ans = tmp[:] # 'ans'を書き換える
... | def A():
n, x, t = map(int, input().split())
print(t * ((n+x-1)//x))
def B():
n = list(input())
s = 0
for e in n:
s += int(e)
print("Yes" if s % 9 == 0 else "No")
def C():
int(input())
a = list(map(int, input().split()))
l = 0
ans = 0
for e in a:
if e < l: a... | 0 | null | 28,237,785,866,940 | 198 | 86 |
import math
r=float(input())
print('%f %f' %(math.pi*r*r, 2*math.pi*r)) | r = float(input())
pi = 3.141592653589793
print(pi*r**2, 2*pi*r)
| 1 | 645,516,567,498 | null | 46 | 46 |
from sys import stdin, setrecursionlimit
def main():
input = stdin.buffer.readline
l = int(input())
print((l / 3) ** 3)
if __name__ == "__main__":
setrecursionlimit(10000)
main()
| n,m,k=map(int, input().split( ))
mod = 998244353
ans=0
if m==1:##コーナー
print(1 if k==n-1 else 0)
exit()
tmp=m*pow(m-1,n-1,mod)
m_inv=pow(m-1,mod-2,mod)
invs=[0]+[pow(i+1,mod-2,mod) for i in range(n)]
for i in range(1,k+2):
ans+=tmp
#print(ans)
tmp*=m_inv
if i<n:##?
tmp*=n-i
tmp*=in... | 0 | null | 35,024,331,392,058 | 191 | 151 |
def main():
A, B, C, K = map(int, input().split())
result = A if K >= A else K
K -= A
if K <= 0:
print(result)
return
K -= B
if K <= 0:
print(result)
return
result -= K
print(result)
main()
| from sys import exit
A, B, C, K = [int(x) for x in input().split()]
if A + B >= K:
print(min(A, K))
exit()
print(A - (K - (A + B)))
| 1 | 21,842,205,899,430 | null | 148 | 148 |
N=int(input())
def num_divisors_table(n):
table=[0]*(n+1)
for i in range(1,n+1):
for j in range(i,n+1,i):
table[j]+=1
return table
l=num_divisors_table(N-1)
print(sum(l)) | import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
class modfact(object):
def __init__(self, n):
fact, invfact = [1] * (n + 1), [1] * (n + 1)
for i in range(1, n + 1): fact[i] = i * fact[i - 1] % MOD
invfact[n]... | 0 | null | 35,009,509,000,816 | 73 | 215 |
import collections
N = int(input())
S = input()
S_list = [S[i] for i in range(N)]
S_c = collections.Counter(S_list)
list12 = []
list1 = []
ans = 0
for i in range(N-2):
s1 = S_list[i]
S_c[s1] = S_c[s1]-1
if s1 in list1:
continue
S_c23 = S_c.copy()
list1.append(s1)
for j in range(i+1,N-... | a=list(input().split())
b=set(a)
if len(b) == 2:
print('Yes')
else:
print('No') | 0 | null | 98,520,060,858,648 | 267 | 216 |
n = int(input())
s = 0
q = int(n ** .5)
for i in range(1, q+1):
x = n // i
s += i * (x * (x+1)) / 2
if x**2 != n:
y = max(n // (i+1), q)
s += (i * (i+1) // 2) * ((x * (x+1) // 2) - (y * (y+1) // 2))
print(int(s)) | h,w = map(int,input().split())
s = [input() for _ in range(h)]
dp = [[float('inf')]*w for i in range(h)]
dp[0][0] = 1 if s[0][0]=='#' else 0
for x in range(h):
for y in range(w):
if x+1<h:
a = 1 if s[x][y]=='.' and s[x+1][y]=='#' else 0
dp[x+1][y] = min(dp[x][y]+a,dp[x+1][y])
... | 0 | null | 29,956,328,427,462 | 118 | 194 |
input_line = set([])
input_line.add(int(input()))
input_line.add(int(input()))
for i in range(1,4):
if i not in input_line:
print(i) | import sys
n = int( sys.stdin.readline() )
nums = sys.stdin.readline().rstrip().split( " " )
nums.reverse()
print( " ".join( nums ) ) | 0 | null | 55,699,335,331,640 | 254 | 53 |
from collections import *
from heapq import *
import sys
input=lambda :sys.stdin.readline().rstrip()
N=int(input())
A=list(map(int,input().split()))
mod=10**9+7
count=1
lst=[0,0,0]
for a in A:
data=[i for i in range(3) if lst[i] == a]
if not data:
count=0
break
count*=len(data)
count%=... | h1, m1, h2, m2, K = map(int, input().split())
h = h2-(h1+1)
m = m2+60-m1
m += 60*h
m -= K
print(m)
| 0 | null | 74,496,619,782,590 | 268 | 139 |
N=int(input())
S=input()
cntR,cntG,cntB=S.count('R'),S.count('G'),S.count('B')
ans=cntR*cntG*cntB
for i in range(N-2):
for j in range(i+1,N-1):
if S[i]!=S[j]:
k=2*j-i
if k<N and S[k]!=S[i] and S[k]!=S[j]:
ans-=1
print(ans) | N = int(input())
S = input()
ans = S.count("R")*S.count("G")*S.count("B")
for i in range(N):
for j in range(i+1,N):
k = 2*j-i
if k<N and S[i]!=S[j]!=S[k]!=S[i]:
ans-=1
print(ans) | 1 | 35,893,315,354,850 | null | 175 | 175 |
import math
(a,b,C) = [int(i) for i in input().split()]
c = math.sqrt(a ** 2 + b ** 2 - (2 * a * b) * math.cos(C * math.pi / 180))
h = float(b * math.sin(C * math.pi / 180))
s = float(a * h / 2)
l = float(a + b + c)
print(s)
print(l)
print(h) | def GCD(x, y):
if y == 0:
return x
return GCD(y, x % y)
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(set(A))
check = set()
for a in A:
cnt = 0
while a % 2 == 0:
cnt += 1
a //= 2
check.add(cnt)
if len(check) > 1:
print(0)
exit()
... | 0 | null | 51,001,952,444,928 | 30 | 247 |
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)
n, u, v = map(int, input().split())
GRAPH = {i:[] for i in range(1, n + 1)}
for _ in range(n - 1):
a, b = map(int, input().split())
GRAPH[a].append(b)
GRAPH[b].append(a)
def dfs(now, prev = 0):
PARENT[now] = prev
DEPTH[now] = DEP... | N,u,v = map(int, input().split())
G=[[] for i in range(N)]
for i in range(N-1):
s,t = map(int, input().split())
G[s-1].append(t-1)
G[t-1].append(s-1)
def expro(u):
D=[0]*N
D[u]=0
S=[]
S.append(u)
L=[]
q=0
while(q<N):
l=S[q]
for i in range(len(G[l])):
... | 1 | 117,365,150,833,720 | null | 259 | 259 |
N, K, C = map(int, input().split())
S = input()
L, R = [], []
i = 0
while len(L) < K:
if S[i] == "o":
L.append(i)
i += C+1
else:
i += 1
i = N-1
while len(R) < K:
if S[i] == "o":
R.append(i)
i -= C+1
else:
i -= 1
R = R[::-1]
for i in rang... | print('pphbhhphph'[int(input()[-1])]+'on') | 0 | null | 29,822,439,897,342 | 182 | 142 |
n, k = list(map(int, input().split()))
mod = 1000000007
fac = [1]
inv = [1]
for i in range(n * 2):
fac.append(fac[-1] * (i + 1) % mod)
inv.append(pow(fac[-1], mod - 2, mod))
def cmb(n, k):
if k < 0 or k > n:
return 0
return ((fac[n] * inv[k]) % mod * inv[n - k]) % mod
ret = 0
for m in range(... | #coding:utf-8
class Combination:
def __init__(self,N,P=10**9+7):
if N > 10**7:
self.fact = lambda x: x * self.fact(x-1) % P if x > 2 else 2
self.perm = lambda x, r: x * self.perm(x-1,r-1) % P if r > 0 else 1
self.cmb = lambda n,r: (self.perm(n,min(n-r,r)) * pow(self.fact(... | 1 | 67,237,089,400,232 | null | 215 | 215 |
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
N = input()
s = 0
for i in range(len(N)):
s += int(N[i])
if s%9 == 0:
print('Yes')
else:
print('No')
if __name__ == '__main__':
main()
|
strN = input()
s = 0
for c in strN:
s += int(c)
if s % 9 == 0:
print("Yes")
else:
print("No") | 1 | 4,402,202,013,312 | null | 87 | 87 |
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
... | input()
A=list(map(int,input().split()))
M=[0,1000]
for i in range(0,len(A)-1):
if A[i]>A[i+1]:
M[1]+=A[i]*M[0]
M[0]=0
elif A[i]<A[i+1]:
M[0]+=int(M[1]/A[i])
M[1]=M[1]%A[i]
M[1]+=A[i+1]*M[0]
M[0]=0
print(M[1])
| 1 | 7,303,848,196,772 | null | 103 | 103 |
n, d = map(int, input().split())
s = 0
for i in range(n):
a, b = map(int, input().split())
if (a ** 2 + b ** 2) ** 0.5 <= d:
s += 1
print(s) | import math
n = int(input())
i = 1
tmp = n-1
while i <= math.sqrt(n):
if n%i == 0:
j = n//i
if i + j < tmp:
tmp = i + j -2
else:
pass
else:
pass
i += 1
print(tmp) | 0 | null | 83,505,112,429,496 | 96 | 288 |
n = int(input())
p = list(map(int, input().split()))
ans = 0
min_p = n
for i in p:
if i <= min_p:
min_p = i
ans += 1
print(ans)
| n=int(input())
p=list(map(int,input().split()))
min_val=10**18
ans=0
for i in range(n):
if i==0:
min_val=p[i]
ans+=1
continue
if min_val>=p[i]:
min_val=p[i]
ans+=1
print(ans)
| 1 | 85,420,588,721,540 | null | 233 | 233 |
data = [int(i) for i in input().split()]
print(f'{data[0] * data[1]} {data[0] * 2 + data[1] * 2}')
| (a,b) = map(int,raw_input().split())
print '%d %d' %(a*b,(a+b)*2) | 1 | 307,174,248,990 | null | 36 | 36 |
H = int(input())
import math
def caracal(H):
if H == 1:
return 1
return 2*caracal(math.floor(H/2)) + 1
print(caracal(H))
| n=int(input())
a=0
b=0
while n!=0:
n=n//2
a+=2**b
b+=1
print(a) | 1 | 79,810,695,666,970 | null | 228 | 228 |
import sys
input = sys.stdin.readline
x, y = [int(x) for x in input().split()]
ans = 0
for i in [x, y]:
if i == 1:
ans += 300000
elif i == 2:
ans += 200000
elif i == 3:
ans += 100000
if x == 1 and y == 1:
ans += 400000
print(ans)
| x, y=map(int, input().split())
s=0
if (x==3): s+=100000
if (x==2): s+=200000
if (x==1): s+=300000
if (y==3): s+=100000
if (y==2): s+=200000
if (y==1): s+=300000
if (s==600000): s+=400000
print(s) | 1 | 140,302,354,951,980 | null | 275 | 275 |
N,A,B=map(int,input().split())
if (B-A)%2==0:
print((B-A)//2)
else:
if A-1<=N-B:
#Aが1に到達するまで+AとBの距離が2の倍数になるまで
x=A-1+1
#Aは負け続け、Bは勝ち続ける
y=(B-A)//2
print(x+y)
else:
#BがNに到達するまで+AとBの距離が2の倍数になるまで
x=N-B+1
#Aは勝ち続け、Bは負け続ける
y=(B-A)//2
... | n, a, b = map(int,input().split())
tmp = abs(a-b)
if tmp%2 == 0:
print(tmp//2)
else:
x = a-1
y = n-b
print(min(x,y)+1+((b-a-1)//2))
| 1 | 109,368,039,772,940 | null | 253 | 253 |
a=int(input())
b=[input() for i in range(a)]
c=0
d=0
e=0
f=0
for i in range(a):
if b[i]=="AC":
c=c+1
if b[i]=="WA":
d=d+1
if b[i]=="TLE":
e=e+1
if b[i]=="RE":
f=f+1
print("AC","x",c)
print("WA","x",d)
print("TLE","x",e)
print("RE","x",f) | input()
P=map(int,input().split())
ans,mn=0,2*10**5
for x in P:
if mn>=x: ans+=1; mn=x
print(ans)
| 0 | null | 47,016,106,255,448 | 109 | 233 |
import sys
def calc_cell(x, y):
return '.' if (x + y) % 2 else '#'
def print_chessboard(height, width):
for y in range(height):
l = []
for x in range(width):
l.append(calc_cell(x, y))
print ''.join(l)
if __name__ == '__main__':
while True:
h, w = map(int, sys.stdin.readline().split())
print_chessbo... | A = []
b = []
row, col = (int(x) for x in input().split())
for i in range(row):
A.append([int(x) for x in input().split()])
for i in range(col):
b.append(int(input()))
for i in range(row):
print(sum(A[i][j]*b[j] for j in range(col))) | 0 | null | 1,028,180,953,670 | 51 | 56 |
n = input()
A=[int(j) for j in input().split()]
nums = [0,0,0]
ans = 1
for a in A:
ans = (ans*nums.count(a))%(10**9 +7)
for i in range(len(nums)):
if nums[i] == a:
nums[i] = a+1
break
print(ans) | #!/usr/bin/env python3
def main():
h,w,k = map(int, input().split())
s = [input() for i in range(h)]
l = [[0]*w for i in range(h)]
from collections import deque
d = deque()
c = 1
for i in range(h):
for j in range(w):
if s[i][j] == '#':
d.append([... | 0 | null | 137,252,417,071,360 | 268 | 277 |
a,b,c=map(int,input().split())
import math
d=math.radians(c)
S=a*b*math.sin(d)*(1/2)
e=math.cos(d)
x=a**2+b**2-2*a*b*e
L=a+b+math.sqrt(x)
h=2*S/a
print('{:.6f}'.format(S))
print('{:.6f}'.format(L))
print('{:.6f}'.format(h))
| import math
a,b,c = map(float,input().split())
rad = math.radians(c)
x = (a**2+b**2-2*a*b*math.cos(rad))**(1/2)
L = a+b+x
S = a*b*math.sin(rad)/2
h = 2*S/a
print("{:.8f}\n{:.8f}\n{:.8f}".format(S,L,h))
| 1 | 174,950,267,510 | null | 30 | 30 |
# -*- coding: utf-8 -*-
n = int(raw_input())
dic = set()
for i in range(n):
com, s = map(str, raw_input().split())
if com == "insert":
dic.add(s)
elif com == "find":
if s in dic:
print "yes"
else:
print "no" | h, w, k = map(int, input().split())
c = [list(input()) for i in range(h)]
ans = 0
for i in range(1 << h):
for j in range(1 << w):
black = 0
for x in range(h):
for y in range(w):
if (i >> x) & 1:
continue
if (j >> y... | 0 | null | 4,558,199,453,262 | 23 | 110 |
import collections
N, X, Y = [int(x) for x in input().split()]
c = collections.Counter()
for i in range(1, N + 1):
for j in range(i, N + 1):
if (i == X and j == Y) or (i == Y and j == X):
c[1] += 1
else:
c[min([j - i, abs(X - i) + 1 + abs(Y - j), abs(X - j) + 1 + abs(Y - i... | N,X,Y =map(int,input().split())
count = [0] * (N-1)
for i in range(1,N):
path = abs(X-i) +1
for j in range(i+1,N+1):
dist = min(j-i, path+abs(Y-j))
count[dist-1] +=1
print(*count, sep="\n") | 1 | 44,081,272,680,550 | null | 187 | 187 |
N = int(input())
amount = 0
for i in range(1, N + 1):
if (i % 15 == 0) or (i % 3 == 0) or (i % 5 == 0):
pass
else:
amount = amount + i
print(amount)
| def main():
n = int(input())
ans = 0
for i in range(1, n + 1):
if (i % 3 != 0) and (i % 5 != 0):
ans += i
print(ans)
main()
| 1 | 34,945,575,854,882 | null | 173 | 173 |
def abc160c_traveling_salesman_around_lake():
k, n = map(int, input().split())
a = list(map(int, input().split()))
total = 0
max_distance = 0
for i in range(n - 1):
total += a[i + 1] - a[i]
max_distance = max(max_distance, a[i + 1] - a[i])
total += k - a[n - 1] + a[0]
max_dis... | K,N=map(int,input().split())
lis=list(map(int,input().split()))
dt=[lis[i+1]-lis[i] for i in range(N-1)]+[lis[0]+(K-lis[-1])]
print(K-max(dt)) | 1 | 43,321,029,550,888 | null | 186 | 186 |
import numpy as np
N = int(input())
X = str(input())
num_one = X.count("1")
dp = [-1] * N
dp[0] = 0
def dfs(n):
if dp[n] == -1:
dp[n] = 1 + dfs(n % bin(n).count('1'))
return dp[n]
num_one = X.count("1")
bool_arr = np.array([True if X[N-i-1] == "1" else False for i in range(N)])
zero_ver = np.array([p... | X=int(input())
ans=1000*(X//500)+5*((X-(X//500*500))//5)
print(ans) | 0 | null | 25,395,280,560,430 | 107 | 185 |
import sys
from functools import reduce
from math import gcd
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
mod = 10 ** 9 + 7
N = int(readline())
A = list(map(int,readline().split()))
lcm = reduce(lambda x,y:x*y//gcd(x,y),A)
ans = 0
ans = sum(lcm//x for x in A)... | def factorize(n):
tmp = n
for i in range(2, int(n**0.5)+1):
if tmp % i == 0:
cnt = 0
while tmp % i == 0:
cnt += 1
tmp //= i
if i in fact:
fact[i] = max(fact[i],cnt)
else:
fact[i] = cnt
... | 1 | 87,720,118,352,020 | null | 235 | 235 |
n,K = map(int, input().split())
mod = 10**9 + 7
def modcomb(n,a,mod):
cnt = 1
for i in range(a):
cnt *= (n-i)
cnt *= pow(i+1,mod-2,mod)
cnt %= mod
# print(cnt)
return cnt
def modconb(n,mod):
# テーブルを作る
fac = [0]*(n+1)
finv = [0]*(n+1)
inv = [0]*(n+1)
fac[0... | a,b = map(int, input().split())
d = a/b
r = a%b
print('%d %d %f' % (d,r,d))
| 0 | null | 33,803,779,436,448 | 215 | 45 |
from collections import deque
q=deque()
n=int(input())
for i in range(n):
cmd=input()
if cmd=="deleteFirst":
try:
q.popleft()
except:
pass
elif cmd=="deleteLast":
try:
q.pop()
except:
pass
else:
cm... | if __name__ == "__main__":
S = input()
list_s = [s for s in S]
ans = 0
if list_s[0] == 'S' and list_s[1] == 'S' and list_s[2] == 'S':
ans = 0
elif list_s[0] == 'S' and list_s[1] == 'S' and list_s[2] == 'R':
ans = 1
elif list_s[0] == 'S' and list_s[1] == 'R' and list_s[2] == 'R':
... | 0 | null | 2,475,239,647,090 | 20 | 90 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.