code1
stringlengths 16
24.5k
| code2
stringlengths 16
24.5k
| similar
int64 0
1
| pair_id
int64 2
181,637B
⌀ | question_pair_id
float64 3.71M
180,628B
⌀ | code1_group
int64 1
299
| code2_group
int64 1
299
|
---|---|---|---|---|---|---|
import math
a = float(input())
print(2*a*math.pi) | R = int(input())
print(R * 2 * 3.1415) | 1 | 31,229,415,616,728 | null | 167 | 167 |
while True:
try:
a, b = map(int, input().split(" "))
if a < b:
key = a
a = b
b = key
A = a
B = b
while a % b != 0:
key = a % b
a = b
b = key
key = int(A * B / b)
print(b, key)
except:
break
| n = input()
x = list(n)
length = len(x)
if x[length-1] == "3":
print("bon")
elif x[length-1] == "0" or x[length-1] == "1" or x[length-1] == "6" or x[length-1] =="8":
print("pon")
else:
print("hon") | 0 | null | 9,723,915,444,478 | 5 | 142 |
#List of Top 3 Hills
set = []
a = 9
for i in range(10):
n = int(input())
set.append(n)
set.sort()
while a >= 7:
print(set[a])
a -= 1 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
m = []
for i in range(0,10):
m.append(int(input()))
for i in range(0,3):
print(list(reversed(sorted(m)))[i]) | 1 | 35,146,300 | null | 2 | 2 |
H = int(input())
en = 1
at = 0
while H > 0:
H //= 2
at += en
en *= 2
print(at) | h = int(input())
cnt = 0
for i in range(h.bit_length()):
cnt += 2**i
print(cnt) | 1 | 80,157,950,019,340 | null | 228 | 228 |
H=int(input())
W=int(input())
N=int(input())
cnt=0
black=0
if H>=W:
for i in range(W):
black+=H
cnt+=1
if black>=N:
break
elif H<W:
for i in range(H):
black+=W
cnt+=1
if black>=N:
break
print(cnt) | H=int(input())
W=int(input())
N=int(input())
k=max(H, W)
cnt=0
while k*cnt<N:
cnt+=1
print(cnt) | 1 | 88,498,404,705,060 | null | 236 | 236 |
while(1):
m, f, r = map(int, input().split())
if m == -1 and f == -1 and r == -1:
break
score = m + f
if m == -1 or f == -1:
print("F")
continue
if score >= 80:
print("A")
continue
if score >= 65 and score < 80:
print("B")
continue
if score >= 50 and score < 65:
print("C")
continue
if score >= 30 and score < 50:
if r >= 50:
print("C")
else:
print("D")
continue
if score < 30:
print("F") | while True:
m, f, r = map(int, raw_input().split())
p = ""
if m == -1 and f == -1 and r == -1:
break
if m == -1 or f == -1:
p = "F"
else:
s = m + f
if s >= 80:
p = "A"
elif s >= 65:
p = "B"
elif s >= 50:
p = "C"
elif s >= 30:
p = "C" if r >= 50 else "D"
else:
p = "F"
print(p) | 1 | 1,232,593,386,860 | null | 57 | 57 |
import sys
input = lambda: sys.stdin.readline().rstrip()
def solve():
s = input()
ans = 0
if s == 'SUN':
ans = 7
elif s == 'MON':
ans = 6
elif s == 'TUE':
ans = 5
elif s == 'WED':
ans = 4
elif s == 'THU':
ans = 3
elif s == 'FRI':
ans = 2
elif s == 'SAT':
ans = 1
print(ans)
if __name__ == '__main__':
solve()
| days = ["SUN", 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
days.reverse()
d = input()
print(days.index(d)+1)
| 1 | 132,939,059,854,328 | null | 270 | 270 |
import math
N = int(input())
if N % 2 == 0:
ans = 0.5
else :
ans = math.ceil(N / 2) / N
print(ans) | # 142 A
n = int(input())
odd = 0
for i in range(1, n+1):
if i % 2 != 0:
odd += 1
x = odd/n
print('%.10f' % x) | 1 | 176,986,075,060,250 | null | 297 | 297 |
def getN():
return int(input())
def getNM():
return map(int, input().split())
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(input()) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
ns = []
while len(ns) < rantime:
n = random.randint(ran1, ran2)
if not n in ns:
ns.append(n)
return sorted(ns)
def rand_query(ran1, ran2, rantime):
r_query = []
while len(r_query) < rantime:
n_q = rand_ints_nodup(ran1, ran2, 2)
if not n_q in r_query:
r_query.append(n_q)
return sorted(r_query)
from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7
#############
# Main Code #
#############
N = getN()
A = getList()
numlist = [0] * N
list_zero = 3
ans = 1
for i in range(N):
if A[i] == 0:
ans *= list_zero
list_zero -= 1
numlist[0] += 1
else:
ans *= numlist[A[i] - 1]
numlist[A[i] - 1] -= 1
numlist[A[i]] += 1
ans %= mod
print(ans % mod) | N = int(input())
A = list(map(int,input().split()))
C = [0,0,0]
Ans = 1
MOD = 1000000007
for a in A:
ask = C.count(a)
if ask==0:
Ans=0
break
ind = C.index(a)
C[ind] += 1
Ans = (Ans*ask)%MOD
print(Ans)
| 1 | 130,250,221,905,498 | null | 268 | 268 |
def main():
input()
x, y = [list(map(int, input().split())) for _ in range(2)]
for p in (1, 2, 3):
distance = (sum(map(lambda i: i ** p, [abs(xi - yi) for xi, yi, in zip(x, y)]))) ** (1/p)
print('{:.5f}'.format(distance))
distance = max([abs(xi - yi) for xi, yi in zip(x, y)])
print('{:.5f}'.format(distance))
if __name__ == '__main__':
main()
| from math import *
n = input()
x = map(float, raw_input().split())
y = map(float, raw_input().split())
for i in range(1,4):
temp = 0
for j in range(n):
temp += fabs(x[j]-y[j])**i
print pow(temp,1.0/i)
d = 0
for i in range(n):
if(fabs(x[i]-y[i]) > d):
d = fabs(x[i]-y[i])
print d | 1 | 218,641,642,270 | null | 32 | 32 |
a, b, c, k = map(int, input().split())
ans = 0
if k <= a:
ans = k
elif k <= a+b:
ans = a
else:
ans = 2*a +b - k
print(ans) | a, b, c, k = map(int, input().split())
if k >= a + b + c:
print(a - c)
exit()
elif k <= a:
print(k)
elif k <= a + b:
print(a)
exit()
else:
print(a - (k - a - b))
exit() | 1 | 21,865,851,035,018 | null | 148 | 148 |
if __name__ == '__main__':
n = int(input())
R = [int(input()) for i in range(n)]
minv = R[0]
maxv = R[1] - R[0]
for j in range(1, n):
if (maxv < R[j] - minv):
maxv = R[j] - minv
if (R[j] < minv):
minv = R[j]
print(maxv) | a,b,c,d=map(int,input().split())
prd=[a*c,a*d,b*c,b*d]
if (a<0<b or c<0<d) and max(prd)<0:
print(0)
else:
print(max(prd)) | 0 | null | 1,502,364,621,550 | 13 | 77 |
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 = sorted(P, reverse=True)[:X]
Q = sorted(Q, reverse=True)[:Y]
R = sorted(R, reverse=True)
L = sorted(P + Q + R, reverse=True)
print(sum(L[:X+Y]))
| h = int(input())
sumn = 0
i,k = 0,1
while k <= h:
sumn+=k
i+=1
k = 2**i
print(sumn) | 0 | null | 62,632,981,302,372 | 188 | 228 |
n = int(input())
s = 'abcdefghijklmnopqrstuvwxyz'
ans = ''
while n > 0:
n -= 1
# print(n//26,n%26)
ans = s[n%26] + ans
n = n // 26
print(ans) | # -*- coding: utf-8 -*-
from sys import stdin
input = stdin.readline
MOD = 10**9+7
def main():
D, T, S = list(map(int,input().split()))
print('Yes' if D/S <= T else 'No')
if __name__ == "__main__":
main()
| 0 | null | 7,714,271,360,560 | 121 | 81 |
import math
x1, y1, x2, y2 = map(float, input().split())
dist = math.sqrt((x1-x2) ** 2 + (y1-y2) ** 2)
print("{:.5f}".format(dist))
| def main():
coordinates = list(map(float, input().split()))
distance = ((coordinates[2] - coordinates[0])**2 + (coordinates[3] - coordinates[1])**2)**(1/2)
print('{:.5f}'.format(distance))
if __name__ == '__main__':
main()
| 1 | 157,908,113,220 | null | 29 | 29 |
n = int(input())
numbers = input()
lst = set()
ans = []
for i in range(n):
pin = ''
if numbers[i] not in lst:
pin += numbers[i]
lst.add(pin)
lst2 = set()
for j in range(i+1, n):
pin += numbers[j]
if pin[1] not in lst2:
lst2.add(pin[1])
lst3 = set()
for k in range(j+1, n):
pin += numbers[k]
if pin[2] not in lst3:
lst3.add(pin[2])
ans.append(pin)
if ('0' in lst3) and ('1' in lst3) and ('2' in lst3) and ('3' in lst3) and ('4' in lst3) and ('5' in lst3) and ('6' in lst3) and ('7' in lst3) and ('8' in lst3) and ('9' in lst3):
break
pin = pin[0] + pin[1]
if ('0' in lst2) and ('1' in lst2) and ('2' in lst2) and ('3' in lst2) and ('4' in lst2) and ('5' in lst2) and ('6' in lst2) and ('7' in lst2) and ('8' in lst2) and ('9' in lst2):
break
pin = pin[0]
if ('0' in lst) and ('1' in lst) and ('2' in lst) and ('3' in lst) and ('4' in lst) and ('5' in lst) and ('6' in lst) and ('7' in lst) and ('8' in lst) and ('9' in lst):
break
print(len(ans))
| import math
from decimal import *
def cnt_prime(p, n):
div = Decimal(str(n))
s = 0
while True:
div /= p
if div < 1:
break
if p == 2:
s += int(div.quantize(Decimal('0.0'), rounding=ROUND_FLOOR))
else:
s += int(div.quantize(Decimal('0.0'), rounding=ROUND_FLOOR)) // 2
return s
N = int(input())
if N % 2 == 1:
print(0)
else:
print(min(cnt_prime(2, N), cnt_prime(5, N))) | 0 | null | 122,246,162,366,240 | 267 | 258 |
r = int(input())
print(r * 2 * 3.1415926535897932384626433) | # 176 B
N = int(input())
print('Yes') if N % 9 == 0 else print('No') | 0 | null | 17,831,470,118,592 | 167 | 87 |
#解説参照
#i桁目で10^i円多くはらうか否か
n_ =list(input())
n = [int(i) for i in n_]
ans = 0
if len(n_)==1:
print(min(n[0],11-n[0]))
exit()
dp1 = 0
dp2 = 1
for i in range(len(n)):
dp_1 = min(dp1+n[i],dp2+10-n[i])
dp_2 = min(dp1+n[i]+1,dp2+9-n[i])
dp1 = dp_1
dp2 = dp_2
print(dp1)
| s = "0"+input()
ans = 0
n = len(s)
f = 0
p = 0
for i in range(1,n+1):
n = int(s[-i])
# n += f
if p+(n>4) > 5:
f = 1
else:
# ans += f
f = 0
n += f
ans += min(n,10-n)
p = n
# ans += f
print(ans) | 1 | 71,089,816,989,712 | null | 219 | 219 |
n = map(int,raw_input().split())
for i in range(0,3):
for k in range(i,3):
if n[i]>n[k]:
temp = n[i]
n[i] = n[k]
n[k]= temp
for j in range(0,3):
print str(n[j]), | n = int(input())
shou500 = n//500
shou5 = (n-shou500*500)//5
print(shou500*1000+shou5*5) | 0 | null | 21,446,641,288,214 | 40 | 185 |
from decimal import Decimal
p=3.141592653589
r=float(raw_input())
print Decimal(r*r*p),Decimal(r*2*p) | import math
r = input()
print "%.6f %.6f" % (math.pi * r * r, math.pi * 2 * r) | 1 | 645,990,552,834 | null | 46 | 46 |
a = int(input())
if(a%2 == 1):
print((a+1)//2)
if(a%2 == 0):
print(a//2)
| n = int(input())
ans = (n//2) + (n%2)
print (ans) | 1 | 59,021,581,787,770 | null | 206 | 206 |
while True:
s = input().split(" ")
H = int(s[0])
W = int(s[1])
if H == 0 and W == 0:
break
for i in range(H):
for j in range(W):
if j == W-1:
print("#")
else:
print("#",end="")
print("") | def getN():
return int(input())
def getNM():
return map(int, input().split())
def getList():
return list(map(int, input().split()))
def getArray(intn):
return [int(input()) for i in range(intn)]
def input():
return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
ns = []
while len(ns) < rantime:
n = random.randint(ran1, ran2)
if not n in ns:
ns.append(n)
return sorted(ns)
def rand_query(ran1, ran2, rantime):
r_query = []
while len(r_query) < rantime:
n_q = rand_ints_nodup(ran1, ran2, 2)
if not n_q in r_query:
r_query.append(n_q)
return sorted(r_query)
from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7
#############
# Main Code #
#############
N, K = getNM()
memo = [-1] * (K + 1)
# 2の倍数だけで作った組み合わせ - 4の倍数だけで作った組み合わせ - 6の...
def rec(x):
if memo[x] >= 0:
return memo[x]
multi = 0
# x * 2, x * 3...について
for i in range(x * 2, K + 1, x):
multi += rec(i)
memo[x] = pow(K // x, N, mod) - multi
res = memo[x]
return res
ans = 0
rec(1)
for i in range(1, K + 1):
ans += i * memo[i]
print(ans % mod) | 0 | null | 18,665,840,939,190 | 49 | 176 |
def merge(A, left, mid, right):
global cnt
L = A[left:mid] + [1000000001]
R = A[mid:right] + [1000000001]
i = j = 0
for k in range(left, right):
if L[i] <= R[j]:
A[k] = L[i]
i += 1
else:
A[k] = R[j]
j += 1
cnt += right - left
def mergeSort(A, left, right):
if left + 1 < right:
mid = (left + right) // 2
mergeSort(A, left, mid)
mergeSort(A, mid, right)
merge(A, left, mid, right)
if __name__ == '__main__':
n = int(input())
A = list(map(int, input().split()))
cnt = 0
mergeSort(A, 0, n)
print(*A)
print(cnt) | from collections import Counter
n=int(input())
a=list(map(int,input().split()))
b=dict(Counter([i-j for i,j in enumerate(a)]))
c=dict(Counter([i+j for i,j in enumerate(a)]))
cnt=0
for i in b:
cnt+=b[i]*c.get(i,0)
print(cnt) | 0 | null | 13,147,749,273,582 | 26 | 157 |
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')
def main():
N = in_n()
ans = []
def dfs(s):
if len(s) == N:
ans.append(s)
return
maxs = max(map(ord, s))
for i in range(ord('a'), maxs + 2):
dfs(s + chr(i))
dfs('a')
print('\n'.join(sorted(ans)))
if __name__ == '__main__':
main()
| import math
X = int(input())
year = 0
money = 100
while(money < X):
money = money * 101//100
year += 1
print(year)
| 0 | null | 39,884,891,310,322 | 198 | 159 |
s = input()
t = input()
c = 0
for i in range(len(s)):
if s[i]==t[i] and len(t)==len(s)+1:
c+=1
if c==len(s):
print("Yes")
else:
print("No") | def main():
s = input()
t = input()
if s == t[0:len(t) - 1]:
print('Yes')
else:
print('No')
main() | 1 | 21,570,150,552,992 | null | 147 | 147 |
A, B = map(int, input().split())
R = A * B
print(R)
| Ans=[]
i=0
while True:
l=input().split()
m=int(l[0])
f=int(l[1])
r=int(l[2])
if m==-1 and f==-1 and r==-1:
break
elif m==-1 or f==-1:
Ans.append("F")
elif m+f>=80:
Ans.append("A")
elif m+f>=65 and m+f<80:
Ans.append("B")
elif m+f>=50 and m+f<65:
Ans.append("C")
elif m+f>=30 and m<50:
if r>=50:
Ans.append("C")
else:
Ans.append("D")
else:
Ans.append("F")
i+=1
m=0
while m<i:
print(Ans[m])
m=m+1
| 0 | null | 8,495,557,107,410 | 133 | 57 |
n = int(input())
c = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
a = int(str(i)[0])
b = int(str(i)[-1])
c[a][b] += 1
res = 0
for i in range(10):
for j in range(10):
res += c[i][j]*c[j][i]
print(res)
| def main():
N = int(input())
n = str(N)
cnt = [[0] * (10) for _ in range(10)]
for i in range(1, N+1):
a = int(str(i)[0])
b = i%10
cnt[a][b] += 1
ans = 0
for i in range(1, 10):
for j in range(1, 10):
ans += cnt[i][j]*cnt[j][i]
print(ans)
main() | 1 | 86,468,635,081,820 | null | 234 | 234 |
n = int(input())
taro = 0
hanako = 0
for i in range(n):
t,h =input().split()
if t > h:
taro+=3
elif t<h:
hanako += 3
else:
taro += 1
hanako += 1
print("%d %d" % (taro,hanako)) |
n = int(input())
taro = 0
hanako = 0
for i in range(n):
columns = input().rstrip().split()
tcard = columns[0]
hcard = columns[1]
if tcard > hcard:
taro += 3
elif hcard > tcard:
hanako += 3
else:
taro += 1
hanako += 1
print(taro,hanako)
| 1 | 1,997,328,957,328 | null | 67 | 67 |
# coding=utf-8
from math import pi
r = float(raw_input().strip())
print "{0:f} {1:f}".format(pi * r * r, 2 * pi * r) | import math
r, pi= float(input()), math.pi
print("{} {}".format(pi * r * r, 2 * pi * r))
| 1 | 654,900,729,990 | null | 46 | 46 |
n=int(input())
a=list(map(int, input().split()))
joushi = [0]*(n+1)
for i in range(n-1):
joushi[a[i]] += 1
del joushi[0]
for i in range(len(joushi)):
print(joushi[i])
| n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7
temp = sum(a)**2
for x in a:
temp -= x**2
print((temp//2)%mod) | 0 | null | 18,245,896,889,922 | 169 | 83 |
import math
if __name__ == '__main__':
x1, y1, x2, y2 = [float(i) for i in input().split()]
d = math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
print("{0:.5f}".format(d)) | N = int(input())
S,T=input().split()
ST = "".join([S[i]+T[i] for i in range(N)])
print(ST) | 0 | null | 56,220,204,706,640 | 29 | 255 |
#Macで実行する時
import sys
import os
if sys.platform=="darwin":
base = os.path.dirname(os.path.abspath(__file__))
name = os.path.normpath(os.path.join(base, '../atcoder/input.txt'))
#print(name)
sys.stdin = open(name)
a = str(input())
print(chr(ord(a)+1))
| # ABC151
# A Next Alphabet
c = input()
l = [chr(ord("a")+i) for i in range(26)]
for i in range(26):
if l[i] == c:
print(l[i+1])
break
| 1 | 92,289,337,600,992 | null | 239 | 239 |
import sys
sys.setrecursionlimit(300000)
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')
class BinomialCoefficient(object):
def __init__(self, N=510000, MOD=10**9+7):
self.fac = [1, 1]
self.finv = [1, 1]
self.inv = [0, 1]
self.MOD = MOD
for i in range(2, N + 1):
self.fac.append((self.fac[-1] * i) % MOD)
self.inv.append((-self.inv[MOD % i] * (MOD // i)) % MOD)
self.finv.append((self.finv[-1] * self.inv[-1]) % MOD)
def comb(self, n, r):
if r < 0 or n < r or r < 0:
return 0
return self.fac[n] * self.finv[r] * self.finv[n - r] % self.MOD
K = I()
S = input()
bi = BinomialCoefficient(N=10 ** 6 * 2 + 1)
ans = 0
# i := Snのindex
for i in range(len(S) - 1, len(S) + K):
tail = len(S) + K - i - 1
lans = bi.comb(i, len(S) - 1)
lans = lans * pow(25, K - tail, MOD) % MOD
lans = lans * pow(26, tail, MOD) % MOD
ans = (ans + lans) % MOD
print(ans) | def main():
N = int(input())
A = list(map(int,input().split()))
buka_num = [0]*(N+1)
for i in range(N-1):
buka_num[A[i]] += 1
for i in range(1,N+1,1):
print(buka_num[i])
main()
| 0 | null | 22,546,381,172,824 | 124 | 169 |
s = input()
t = input()
s_len = len(s)
t_len = len(t)
ans = 99999
for i in range(-~s_len-t_len):
cnt = 0
for j in range(t_len):
if s[i+j] != t[j]:
cnt += 1
ans = min(ans, cnt)
print(ans) | while True:
L = map(int,raw_input().split())
H = (L[0])
W = (L[1])
if H == 0 and W == 0:break
for x in range(0,H):
if x % 2 == 0:
if W % 2 == 1:
print "{}#".format("#."* (W / 2))
else:
print "#." * (W / 2)
else:
if W % 2 == 1:
print "{}.".format(".#"* (W / 2))
else:
print ".#" * (W / 2)
print "" | 0 | null | 2,266,064,210,240 | 82 | 51 |
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(): return list(sys.stdin.readline().rstrip().split())
def main():
A = [[]for _ in range(3)]
for i in range(3):
A[i] = LI()
A_ = [[]for _ in range(3)]
for i in range(3):
for j in range(3):
A_[j].append(A[i][j])
A__ = [[]for _ in range(2)]
for i in range(3):
A__[0].append(A[i][i])
A__[1].append(A[i][2 - i])
N = I()
B = []
for i in range(N):
b = I()
B.append(b)
for i in range(3):
if b in A[i]:
ind = A[i].index(b)
A[i][ind] = 0
if b in A_[i]:
ind = A_[i].index(b)
A_[i][ind] = 0
for j in range(2):
if b in A__[j]:
ind = A__[j].index(b)
A__[j][ind] = 0
ans_list = []
for i in range(3):
ans_list.append(sum(A[i]))
ans_list.append(sum(A_[i]))
for j in range(2):
ans_list.append(sum(A__[j]))
if 0 in ans_list:
print('Yes')
else:
print('No')
if __name__ == "__main__":
main() | A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]
field = 0
for v in b:
for i in range(9):
if A[i // 3][i % 3] == v:
field = field | (1 << i)
ans = False
for v in sum([[273,84],sum([[73<<i,7<<i*3]for i in range(3)],[])],[]):
ans = ans or field&v==v;
print('Yes' if ans else 'No')
| 1 | 59,972,315,271,760 | null | 207 | 207 |
import sys
A, B, C, D = map(int, input().split())
while A > 0 or B > 0:
C = C - B
if C <= 0:
print("Yes")
sys.exit()
A = A - D
if A <= 0:
print("No")
sys.exit() | n = int(input())
s = list(input())
m = n//2
if n%2 != 0:
ans = "No"
else:
for i in range(m):
if s[i] != s[m+i]:
ans = "No"
break
ans = "Yes"
print(ans) | 0 | null | 88,469,164,466,340 | 164 | 279 |
X= int(input())
if(X>=400 and X<=599):
print(8)
elif(X>599 and X<800):
print(7)
elif(X>=800 and X<1000):
print(6)
elif(X>=1000 and X<1200):
print(5)
elif(X>=1200 and X<1400):
print(4)
elif(X>=1400 and X<1600):
print(3)
elif(X>=1600 and X<1800):
print(2)
elif(X>=1800 and X<2000):
print(1) | x = int(input())
ans = 8
if x < 600: ans=8
elif x < 800: ans=7
elif x < 1000: ans=6
elif x < 1200: ans=5
elif x < 1400: ans=4
elif x < 1600: ans=3
elif x < 1800: ans=2
else: ans=1
print(ans)
| 1 | 6,751,454,166,940 | null | 100 | 100 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# E - Sum of gcd of Tuples (Hard)
n, k = map(int, input().split())
modulus = 10 ** 9 + 7
def expt(x, k):
"""(x ** k) % modulus"""
p = 1
for b in (bin(k))[2:]:
p = p * p % modulus
if b == '1':
p = p * x % modulus
return p
# iの倍数をn個並べた列の個数
nseq = [expt((k // i), n) if i > 0 else None for i in range(k + 1)]
for i in range(k, 0, -1):
# iの2倍以上の倍数からなる列の個数を引く
s = sum(nseq[m] for m in range(2 * i, k + 1, i))
nseq[i] = (nseq[i] - s % modulus + modulus) % modulus
# nseq[i]はgcd==iになる列の個数
ans = sum(i * nseq[i] % modulus for i in range(1, k + 1))
print(ans % modulus)
| l,r,d=map(int,input().split());print(r//d-~-l//d) | 0 | null | 22,265,567,317,292 | 176 | 104 |
import math
H = int(input())
print(2 ** (int(math.log(H, 2)) + 1 ) - 1) | import math
def pow(x, n):
ans = 1
while n:
if n % 2:
ans *= x
x *= x
n >>= 1
return ans
H = int(input())
#print(int(math.log2(H)))
print(pow(2,int(math.log2(H))+1)-1)
| 1 | 80,495,655,914,560 | null | 228 | 228 |
import fractions
A,B=map(int,input().split())
def lcm(x,y):
return int((x*y)/fractions.gcd(x,y))
print(lcm(A,B)) | i = 1
while True:
factor = input()
if factor == '0':
break
print('Case ', i, ': ', factor, sep='')
i += 1
| 0 | null | 56,697,011,765,342 | 256 | 42 |
N = int(input())
A = [0] * (N + 1)
B = [0] * (N + 1)
count = 0
for i in range(1, N + 1):
A[i], B[i] = map(int, input().split())
A.sort()
B.sort()
if N % 2 == 1:
centerA = A[(N + 1) // 2]
centerB = B[(N + 1) // 2]
else:
centerA = (A[N // 2] + A[N // 2 + 1]) / 2
centerB = (B[N // 2] + B[N // 2 + 1]) / 2
#print(centerA, centerB)
if N % 2 == 1:
count = centerB - centerA + 1
else:
count = (centerB - centerA) * 2 + 1
print(int(count)) | def resolve():
n, a, b = list(map(int, input().split()))
MOD = 10**9+7
ntoa = 1
ato1 = 1
ntob = 1
bto1 = 1
for i in range(a):
ntoa *= (n-i)
ntoa %= MOD
ato1 *= (a-i)
ato1 %= MOD
for i in range(b):
ntob *= (n-i)
ntob %= MOD
bto1 *= (b-i)
bto1 %= MOD
def pow(x, n, MOD=10**9+7):
ret = 1
while n > 0:
if n & 1:
ret = (ret*x)%MOD
x = (x*x)%MOD
n >>= 1
return ret
nca = ntoa*pow(ato1, MOD-2)%MOD
ncb = ntob*pow(bto1, MOD-2)%MOD
print((pow(2, n)%MOD-1-nca-ncb)%MOD)
if '__main__' == __name__:
resolve()
| 0 | null | 41,496,822,007,960 | 137 | 214 |
N,K = map(int,input().split())
i = N%K
j = -i+K
print(min(i,j)) | import math
def koch(n, h, i, j, k):
if n == 0:
return
sx = (h*2+j)/3
sy = (i*2+k)/3
tx = (h+j*2)/3
ty = (i+k*2)/3
ux = (tx-sx)*math.cos(math.pi/3) - (ty-sy)*math.sin(math.pi/3) + sx
uy = (tx-sx)*math.sin(math.pi/3) + (ty-sy)*math.cos(math.pi/3) + sy
koch(n-1, h, i, sx, sy)
print sx, sy
koch(n-1, sx, sy, ux, uy)
print ux, uy
koch(n-1, ux, uy, tx, ty)
print tx, ty
koch(n-1, tx, ty, j, k)
n = input()
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
print px, py
koch(n, px, py, qx, qy)
print qx, qy | 0 | null | 19,671,970,695,550 | 180 | 27 |
N, K = map(int, input().split())
n = N%K
m = K - n
print(min(abs(n), abs(m))) | from sys import stdin
input = stdin.readline
def main():
N, K = list(map(int, input().split()))
surp = N % K
print(min(surp, abs(surp-K)))
if(__name__ == '__main__'):
main()
| 1 | 39,416,803,867,012 | null | 180 | 180 |
n=int(input())
s=input()
r=0
for i in s:
if(i=="R"):
r+=1
ans=0
for j in range(r):
if(s[j]=="W"):
ans+=1
print(ans) | N = int(input())
C = input()
T = 'R' * C.count('R') + 'W' * C.count('W')
ans = sum([1 for a, b in zip(C, T) if a != b]) // 2
print(ans) | 1 | 6,277,503,592,950 | null | 98 | 98 |
[A, B, C] = [int(i) for i in input().split()]
K = int(input())
def cal():
global A, B, C, K
count = 0
while A >= B:
B *= 2
count += 1
if K < count:
return "No"
while B >= C:
C *= 2
count += 1
if K < count:
return "No"
return "Yes"
print(cal())
| n = int(input())
x = list(map(float, input().split()))
y = list(map(float, input().split()))
def minc_dis(n, x, y, p):
sum = 0
for i in range(n):
sum = sum + (abs(x[i] - y[i])) ** p
return sum ** (1/p)
def cheb_dis(n, x, y):
dis = 0
for i in range(n):
dif = abs(x[i] - y[i])
if dis < dif:
dis = dif
return dis
for p in range(1 , 4):
print(minc_dis(n, x, y, p))
print(cheb_dis(n, x, y))
#print(cheb_dis(2, [1, 2, 3], [2, 0, 4]))
| 0 | null | 3,532,025,882,720 | 101 | 32 |
X, Y = map(int, input().split())
if (2*X-Y)%3==0 and (2*Y-X)%3==0:
a = (2*X-Y)//3
b = (2*Y-X)//3
if a>=0 and b>=0:
MOD = 10**9+7
n = a+b+1
fac = [1]*(n+1)
rev = [1]*(n+1)
for i in range(1,n+1):
fac[i] = i*fac[i-1]%MOD
rev[i] = pow(fac[i], MOD-2, MOD)
comb = lambda a,b:(fac[a]*rev[a-b]*rev[b])%MOD
print(comb(a+b, a))
else:
print(0)
else:
print(0)
| class Dice(object):
def __init__(self, List):
self.face = List
def n_spin(self, List):
temp = List[0]
List[0] = List[1]
List[1] = List[5]
List[5] = List[4]
List[4] = temp
def s_spin(self, List):
temp = List[0]
List[0] = List[4]
List[4] = List[5]
List[5] = List[1]
List[1] = temp
def e_spin(self, List):
temp = List[0]
List[0] = List[3]
List[3] = List[5]
List[5] = List[2]
List[2] = temp
def w_spin(self, List):
temp = List[0]
List[0] = List[2]
List[2] = List[5]
List[5] = List[3]
List[3] = temp
dice = Dice(map(int, raw_input().split()))
command = list(raw_input())
for c in command:
if c == "N":
dice.n_spin(dice.face)
elif c == "S":
dice.s_spin(dice.face)
elif c == "E":
dice.e_spin(dice.face)
elif c == "W":
dice.w_spin(dice.face)
print dice.face[0] | 0 | null | 74,944,830,425,970 | 281 | 33 |
X = int(input())
for i in range(X, 9999999999999999):
flag = 1
for j in range(2, X//2 +1):
if i % j == 0:
flag = -1
break
if X == 2:
print(2)
break
elif X == 3:
print(3)
break
elif flag == 1:
print(i)
break | N, K = map(int, input().split())
def createFacArr(n, mod):
'''
二項係数計算用の配列の作成
Parameters
n : int
配列のサイズ
mod : int
あまり
Returns
fac : list
階乗のリスト
finv : list
modの逆元のリスト
ivn : list
'''
fac = [0] * n
finv = [0] * n
inv = [0] * n
fac[0], fac[1] = 1, 1
finv[0], finv[1] = 1, 1
inv[1] = 1
for i in range(2, n):
fac[i] = fac[i-1] * i % mod
inv[i] = mod - inv[mod%i] * (mod // i) % mod
finv[i] = finv[i-1] * inv[i] % mod
return fac, finv
def comb(n ,k, mod, fac, finv):
'''
二項係数の計算
Parameters
n : int
元集合
k : int
元集合から選択する数
mod : int
あまり
fac : list
階乗のリスト
finv : list
逆元のリスト
Returns
c : int
nCkの組み合わせの数
'''
if n < k:
return 0
if n < 0 or k < 0:
return 0
return fac[n] * (finv[k] * finv[n-k] % mod) % mod
K = min(N-1, K)
ans = 0
MOD = 10 ** 9 + 7
fac, finv = createFacArr(N+100, MOD)
for i in range(K+1):
# iは0の個数
ans += comb(N, i, MOD, fac, finv) * comb(N-1, N-i-1, MOD, fac, finv) % MOD
ans %= MOD
print(ans)
| 0 | null | 86,699,830,846,410 | 250 | 215 |
import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
def main():
S = input()
l = len(S)
print("x" * l)
if __name__ == '__main__':
main()
| n = int(input())
iteration = n
ex = 0
count = 0
for i in range(1,n):
ex = iteration-i
#print(ex)
if ex <=i:
break
else:
count += 1
print(count) | 0 | null | 113,016,017,547,680 | 221 | 283 |
N, K = map(int, input().split())
p = list(map(int, input().split()))
import numpy as np
data = np.array(p) + 1
Pcum = np.zeros(N + 1, np.int32)
Pcum[1:] = data.cumsum()
length_K_sums = Pcum[K:] - Pcum[0:-K]
print(np.max(length_K_sums)/2)
| n=int(input())
a=list(map(int,input().split()))
money=1000
kabu=0
for i in range(n-1):
if a[i]<a[i+1] and a[i]<=money:
kabu+=money//a[i]
money-=kabu*a[i]
if a[i]>a[i+1] and kabu>0:
money+=kabu*a[i]
kabu=0
if kabu>0:
money+=kabu*a[-1]
print(money)
| 0 | null | 40,973,686,177,828 | 223 | 103 |
def func(K):
result = ""
for i in range(K):
result += "ACL"
return result
if __name__ == "__main__":
K = int(input())
print(func(K)) | X=int(input())
big=X//500
small=(X%500)//5
print(1000*big+5*small) | 0 | null | 22,493,583,177,540 | 69 | 185 |
while 1 :
try:
h,w=map(int,input().split())
#print(h,w)
if( h==0 and w==0 ):
break
else:
for hi in range(h):
print("#" * w)
print() #??????
if( h==0 and w==0 ): break
except (EOFError):
#print("EOFError")
break | n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7
ans = 0
for i in range(60):
cnt = 0
digit = 1 << i
for j in a:
if digit & j:
cnt += 1
ans += digit*cnt*(n - cnt)%mod
print(ans%mod)
| 0 | null | 61,766,210,060,448 | 49 | 263 |
import sys
input = sys.stdin.readline
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)
ans = sum(P[:X]) + sum(Q[:Y])
x = X-1
y = Y-1
for z in range(C):
if x < 0:
if R[z] > Q[y]:
ans += R[z] - Q[y]
y -= 1
elif y < 0:
if R[z] > P[x]:
ans += R[z] - P[x]
x -= 1
else:
if R[z] > P[x] >= Q[y]:
ans += R[z] - Q[y]
y -= 1
elif R[z] > Q[y] > P[x]:
ans += R[z] - P[x]
x -= 1
elif P[x] >= R[z] > Q[y]:
ans += R[z] - Q[y]
y -= 1
elif Q[y] >= R[z] > P[x]:
ans += R[z] - P[x]
x -= 1
print(ans)
| N,M=map(int,input().split())
n=N*(N-1)
m=M*(M-1)
result=int((n+m)/2)
print(result) | 0 | null | 45,232,351,678,848 | 188 | 189 |
S = int(input())
s = S%60
m = (S-s)/60%60
h = S/3600%24
answer = str(int(h))+":"+str(int(m))+":"+str(s)
print(answer)
| X = list(map(int, input().split()))
sum = X[0] + X[1] + X[2] + X[3] + X[4]
print(15 - sum)
| 0 | null | 6,915,737,082,540 | 37 | 126 |
n, k, c = map(int, input().split())
s = input()
l = [0] * k
r = [0] * k
p = 0
# for i in range(n):
i = 0
while i < n:
if s[i] == "o":
l[p] = i
p += 1
if (p >= k):
break
i += c
i += 1
p = k-1
# for i in range(n - 1, -1, -1):
i = n - 1
while i >= 0:
if s[i] == "o":
r[p] = i
p -= 1
if (p < 0):
break
i -= c
i -= 1
#print(l, r)
for i in range(k):
if l[i] == r[i]:
print(l[i]+1)
| n,k,c=map(int,input().split())
s=input()
l=[]
r=[]
i=0
j=0
while len(l)<k and i<n:
if s[i]=='o':
l.append(i+1)
i+=c+1
else: i+=1
while len(r)<k and j<n:
if s[-j-1]=='o':
r.append(n-j)
j+=c+1
else: j+=1
for n in range(k):
if l[n]==r[-n-1]:
print(l[n]) | 1 | 40,943,778,817,760 | null | 182 | 182 |
def main():
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
#from operator import itemgetter
#inf = 10**17
#mod = 10**9 + 7
n = int(input())
a =[0]+list(map(int, input().split()))
b = list(accumulate(a))
c = sum(a)
res = 10000000000000000
for i in range(1, n):
s = b[i]
t = c-s
res = min(res, abs(s-t))
print(res)
if __name__ == '__main__':
main() | n=int(input())
a=list(map(int,input().split()))
tot=sum(a)
b=0
c=10**10
d=0
for i in range(n):
b+=a[i]
d=abs(tot/2 - b)
if d<c:
c=d
print(int(2*c)) | 1 | 142,153,192,438,118 | null | 276 | 276 |
x = int(input().rstrip())
if x >= 30:
print("Yes")
else:
print("No") | n = int(input())
z = input().split()
odd = 0
for i in range(n):
if i % 2 == 0:
if int(z[i]) % 2 == 1:
odd += 1
print(odd) | 0 | null | 6,807,599,744,998 | 95 | 105 |
# 7
from collections import Counter
import collections
import sys
def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()
INF = float('inf')
n = I()
d = LI()
mod = 998244353
if d[0] != 0:
print(0)
exit(0)
# 頂点 i に隣接する頂点のうち、頂点 1 に近い頂点を pi とすると
# d_pi = d_i - 1 となる
# 各 i (i >= 2) について上の条件を満たす pi の個数の総乗を求める
c = Counter(d)
counts = [0] * (max(d)+1)
for k, v in c.items():
counts[k] = v
if counts[0] > 1:
print(0)
exit(0)
ans = 1
for i in range(1, len(counts)):
ans *= pow(counts[i-1], counts[i])
ans %= mod
print(ans)
| #%%
from collections import Counter
n = input()
d = list(map(int, input().split()))
#%%
d_cnt =Counter(d)
d_cnt = dict(d_cnt)
d_cnt_keys = list(d_cnt.keys())
d_cnt_keys.sort()
if d[0] != 0 or d_cnt[0] != 1 or len(d_cnt_keys)!= d_cnt_keys[-1]+1:
print(0)
exit()
#%%
ans = 1
p = 998244353
for key in d_cnt_keys:
if key == 0:
continue
ans =ans*pow(d_cnt[key-1], d_cnt[key],p)%p
print(ans) | 1 | 154,842,074,914,618 | null | 284 | 284 |
from sys import stdin
from collections import deque
def main():
#入力
readline=stdin.readline
k=int(readline())
lunlun_number=[]
d=deque(map(str,range(1,10)))
cnt=0
while cnt<k:
now=d.popleft()
lunlun_number.append(now)
cnt+=1
if now[-1]=="0":
nex=("0","1")
elif now[-1]=="9":
nex=("8","9")
else:
last=int(now[-1])
nex=(str(last-1),str(last),str(last+1))
for x in nex:
d.append(now+x)
print(lunlun_number[k-1])
if __name__=="__main__":
main() | A = int(input())
B = int(input())
if A+B == 3:
print(3)
elif A+B == 4:
print(2)
else:
print(1) | 0 | null | 75,177,600,079,960 | 181 | 254 |
n = int(input())
num_AC = 0
num_WA = 0
num_TLE = 0
num_RE = 0
for i in range(n):
i = input()
if i == "AC":
num_AC += 1
elif i == "WA":
num_WA += 1
elif i == "TLE":
num_TLE += 1
elif i == "RE":
num_RE += 1
print("AC x " + str(num_AC))
print("WA x " + str(num_WA))
print("TLE x " + str(num_TLE))
print("RE x " + str(num_RE)) | N = int(input())
A = list(map(int, input().split()))
answer = 'DENIED'
for i in range(0, N):
if A[i] % 2 == 0:
if A[i] % 3 == 0 or A[i] % 5 == 0:
answer = 'APPROVED'
else:
answer = 'DENIED'
break
else:
answer = 'APPROVED'
print(answer) | 0 | null | 38,954,576,567,140 | 109 | 217 |
n = int(input())
s = list(input())
t = []
ans = 0
for i in range(1000):
t.append(str(i//100))
t.append(str(i//10%10))
t.append(str(i%10))
k = 0
p = 0
for j in range(3):
if t[j] in s[k:]:
p = s[k:].index(t[j]) + 1
k += p
else:
p = -1
break
if p != -1:
ans += 1
t.clear()
print(ans) | N = int(input())
st = [tuple(input().split()) for _ in range(N)]
X = input()
ans = 0
for s, t in st:
ans += int(t)
for s, t in st:
ans -= int(t)
if s == X: break
print(ans) | 0 | null | 112,786,618,235,018 | 267 | 243 |
h, w, k = map(int, input().split())
s = [input() for _ in range(h)]
a = [[0]*w for _ in range(h)]
cnt = 0
later = []
for i in range(h):
if '#' not in s[i]: continue
later.append(i)
fst = False
idx = -1
for j in range(w):
if not fst and not s[i][j] == '#':
continue
if not fst and s[i][j] == '#':
idx = j
if s[i][j] == '#':
fst = True
cnt += 1
a[i][j] = cnt
for j in range(idx):
a[i][j] = a[i][idx]
for i in later:
if i >= h-1: break
for j in range(w):
k = i
while k < h-1:
if a[k+1][j] == 0:
a[k+1][j] = a[k][j]
k += 1
else:
break
if later[0] != 0:
for i in range(later[0], 0, -1):
for j in range(w):
a[i-1][j] = a[i][j]
for ans in a:
print(*ans) | h, w, k = map(int, input().split())
s = [list(input()) for _ in range(h)]
g = 1
for i in range(h):
for j in range(w):
if s[i][j] != '#':
continue
s[i][j] = g
k = j - 1
while k >= 0 and s[i][k]=='.':
s[i][k] = g
k -= 1
k = j + 1
while k < w and s[i][k] == '.':
s[i][k] = g
k += 1
g += 1
for i in range(h - 2)[::-1]:
if s[i][0]=='.':
for j in range(w):
s[i][j] = s[i + 1][j]
for i in range(h):
if s[i][0] == '.':
for j in range(w):
s[i][j] = s[i - 1][j]
for t in s:
print(*t)
| 1 | 143,676,507,671,242 | null | 277 | 277 |
n = int(input())
a = [int(x) for x in input().split()]
ans = [0] * n
for i in range(n-1):
ans[a[i]-1] += 1
for i in range(n):
print(ans[i]) | import sys
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
n = I()
A = LI()
sub = [0]*n
for a in A:
sub[a-1] += 1
for s in sub:
print(s)
if __name__ == '__main__':
main() | 1 | 32,509,695,463,732 | null | 169 | 169 |
#coding: UTF-8
import math
def PF(a):
for k in range(len(a)):
area = ""
H = int(a[k].split(" ")[0])
W = int(a[k].split(" ")[1])
if H == 0 and W == 0:
break
for j in range(H):
if j == 0 or j == (H-1):
for i in range(W):
area += "#"
else:
area = "#"
for i in range(1,W-1):
area += "."
area += "#"
print(area)
area = ""
print("")
if __name__=="__main__":
a = []
for i in range(300):
a.append(input())
if a[i] == "0 0":
break
PF(a) | n = int(input())
c = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
a = int(str(i)[0])
b = int(str(i)[-1])
c[a][b] += 1
res = 0
for i in range(10):
for j in range(10):
res += c[i][j]*c[j][i]
print(res)
| 0 | null | 43,606,916,824,460 | 50 | 234 |
from collections import defaultdict
h, w, m = map(int, input().split())
targets = defaultdict(int)
targets_count_yoko = defaultdict(int)
targets_count_tate = defaultdict(int)
for _ in range(m):
y, x = map(int, input().split())
y -= 1
x -= 1
targets_count_yoko[x] += 1
targets_count_tate[y] += 1
targets[(y, x)] = -1
max_row = max(targets_count_yoko.values())
max_line = max(targets_count_tate.values())
y_idx = defaultdict(bool)
x_idx = defaultdict(bool)
max_count_x = 0
max_count_y = 0
for i in range(w):
if targets_count_yoko[i] == max_row:
x_idx[i] = True
max_count_x += 1
for i in range(h):
if targets_count_tate[i] == max_line:
y_idx[i] = True
max_count_y += 1
ans = max_line + max_row
kumi = max_count_x*max_count_y
for key_y, key_x in targets.keys():
if y_idx[key_y] and x_idx[key_x]:
kumi -= 1
if kumi == 0:
break
if kumi == 0:
print(ans-1)
else:
print(ans)
| n, s = input(), input()
print(s[:s.count("R")].count("W")) | 0 | null | 5,565,880,386,276 | 89 | 98 |
from collections import deque
N = input()
digit = len(N)
f_digit = int(N[0])
l_digit = int(N[-1])
N = int(N)
cnt = 0
g_cnt = [[0]*10 for _ in range(10)]
for i in range(1, 10):
for j in range(1, 10):
g_cnt[i][j] = 0
if i == j:
if i <= N:
g_cnt[i][j] += 1
if i*10+i <= N:
g_cnt[i][j] += 1
else:
if i*10+j <= N:
g_cnt[i][j] += 1
if digit >= 3:
num = deque([str(k) for k in range(10)])
while num:
q = num.popleft()
for k in range(10):
if int(str(i)+q+str(k)+str(j)) <= N:
num.append(q+str(k))
if int(str(i)+q+str(j)) <= N:
g_cnt[i][j] += 1
for i in range(1, 10):
for j in range(i, 10):
if i == j:
cnt += g_cnt[i][j] ** 2
else:
cnt += g_cnt[i][j] * g_cnt[j][i] * 2
print(cnt) | n = int(input())
mod = 10**9+7
ans = 10**n-9**n-9**n+8**n
ans %= mod
print(ans)
| 0 | null | 44,750,388,419,260 | 234 | 78 |
import math
def prime(num):
array=[]
tmp=int(math.sqrt(n))+1
for i in range(2,tmp):
while num % i == 0:
num/=i
array.append(i)
# リストが空なら入力(num)は素数
if array==[]:
return [num]
else:
if num>1:
array.append(int(num))
return array
n=int(input())
P=prime(n)
P=sorted(P)
num=n
if 1 in P:
print(0)
else:
ans=0
tmp=0
for i in range(0,len(P)):
if i==0:
tmp=P[i]
elif P[i]==P[i-1]:
tmp*=P[i]
else:
tmp=P[i]
num=n
if num%tmp==0:
num/=tmp
ans+=1
print(ans) | from collections import deque
h, w = map(int, input().split())
meiro = [list(input()) for i in range(h)]
# meiro[y][x]
def bfs(a, b): # a縦b横
mx_dist = 0
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]
dist = [[-1] * w for i in range(h)]
dist[a][b] = 0
que = deque([])
que.append((a, b))
while que:
y, x = que.popleft()
D = dist[y][x]
for i in range(4):
X = x + dx[i]
Y = y + dy[i]
if 0 <= Y and Y <= h - 1 and X <= w - 1 and 0 <= X:
if meiro[Y][X] == ".":
if dist[Y][X] == -1:
dist[Y][X] = D + 1
que.append((Y, X))
mx_dist = max(mx_dist, D + 1)
return mx_dist
saidai = 0
for i in range(h):
for j in range(w):
if meiro[i][j] == ".":
saidai = max(saidai, bfs(i, j))
print(saidai)
| 0 | null | 55,997,031,729,472 | 136 | 241 |
#!/usr/bin/env python3
a, b, c = map(int, input().split())
k = int(input())
for _ in range(k):
if a >= b:
b *= 2
elif b >= c:
c *= 2
print(["No", "Yes"][a < b < c])
| #coding: utf-8
n = int(input())
R = []
#input_value?????????
for i in range(n):
R.append(int(input()))
max_dif = -2000000000
min_value = R[0]
for i in range(1, n):
max_dif = max(max_dif, R[i] - min_value)
min_value = min(min_value, R[i])
print(max_dif) | 0 | null | 3,479,437,928,790 | 101 | 13 |
import math
n=int(input())
x=math.ceil(n/1.08)
if(math.floor(1.08*x)==n):
ans=x
else:
ans=str(":(")
print(ans) | import math
n = int(input())
for i in range(n+1):
if math.floor(i * 1.08) == n:
print(i)
exit(0)
print(":(") | 1 | 125,221,961,094,230 | null | 265 | 265 |
a=map(int,raw_input().split())
print(str(a[0]*a[1])+" "+str(2*(a[0]+a[1]))) | N,X,Y=map(int,input().split())
ANS=[0 for i in range(N-1)]
for i in range(N-1):
for k in range(i+1,N):
d=min(k-i,abs(X-i-1)+abs(Y-k-1)+1)
ANS[d-1]+=1
for i in ANS:
print(i) | 0 | null | 22,319,001,695,002 | 36 | 187 |
def main():
N=int(input())
A=list(map(int,input().split()))
L={}
R={}
for i in range(N):
l=(i+1)+A[i]
r=(i+1)-A[i]
if (l in L.keys()):
L[l]+=1
else:
L[l]=1
if r in R.keys():
R[r]+=1
else:
R[r]=1
res=0
for key in L.keys():
if key in R.keys():
res+=R[key]*L[key]
print(res)
if __name__=="__main__":
main()
| import math
def main():
A, B = map(int, input().split())
a_min = int(math.ceil(A / 0.08))
a_max = int(math.floor((A+1) / 0.08)) - 1
b_min = 10 * B
b_max = 10 * (B+1) - 1
if a_max < b_min or b_max < a_min:
print(-1)
else:
print(max([a_min, b_min]))
if __name__ == '__main__':
main()
| 0 | null | 41,330,325,924,010 | 157 | 203 |
class Queue:
def __init__(self):
self.queue = []
def enqueue(self, value):
self.queue.append(value)
def dequeue(self):
return self.queue.pop(0)
class Task:
def __init__(self, name, time):
self.name = name
self.time = int(time)
self.endtime = 0
def __repr__(self):
return '{} {}'.format(self.name, self.endtime)
def rr(queue, q):
time = 0
while len(queue.queue) > 0:
task = queue.dequeue()
if task.time > q:
task.time -= q
time += q
queue.enqueue(task)
else:
time += task.time
task.time = 0
task.endtime = time
print(task)
if __name__ == '__main__':
nq = [int(s) for s in input().split()]
N = nq[0]
q = nq[1]
queue = Queue()
task_arr = [Task(*input().split()) for i in range(N)]
for t in task_arr:
queue.enqueue(t)
rr(queue, q) | S=input()
ch=""
for i in range(len(S)):
ch+="x"
print(ch) | 0 | null | 36,614,625,149,102 | 19 | 221 |
from sys import stdin
from collections import deque
n = int(stdin.readline())
d = [-1] * (n + 1)
def bfs(G):
d[1] = 0
dq = deque([1])
while len(dq) > 0:
v = dq.popleft()
for c in G[v]:
if d[c] < 0:
d[c] = d[v] + 1
dq.append(c)
for i, x in enumerate(d[1:], start=1):
print(i, x)
G = [0]
for i in range(n):
G.append(list(map(int, stdin.readline().split()[2:])))
bfs(G) | import sys
def solve():
readline = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
h, w, k = list(map(int, readline().split()))
a = [list(str(readline().rstrip().decode('utf-8'))) for _ in range(h)]
no = 0
is_f = True
for i in range(h):
if a[i].count("#") != 0:
row_f = True
no += 1
for j in range(w):
if a[i][j] == "#":
if not row_f:
no += 1
else:
row_f = False
a[i][j] = no
if is_f:
is_f = False
if i != 0:
for j in range(i - 1, -1, -1):
for k in range(w):
a[j][k] = a[i][k]
else:
for j in range(w):
a[i][j] = a[i-1][j]
for i in range(h):
print(*a[i])
if __name__ == '__main__':
solve()
| 0 | null | 71,972,986,231,230 | 9 | 277 |
h = int(input())
w = int(input())
n = int(input())
total = h*w
kesu = max(h, w)
if n%kesu==0:
print(n//kesu)
else:
print(n // kesu + 1) | import math
t8 = [[] for _ in range(130)]
t10 = [[] for _ in range(130)]
for i in range(1251):
t8[math.floor(i * 0.08)].append(i)
t10[math.floor(i * 0.1)].append(i)
a, b = map(int, input().split())
if min(t8[a]) > max(t10[b]) or max(t8[a]) < min(t10[b]):
print(-1)
else:
print(max(min(t8[a]), min(t10[b])))
| 0 | null | 72,656,179,373,488 | 236 | 203 |
l=[[[0 for i in range(10)] for i in range(3)] for i in range(4)]
n=int(input())
for i in range(n):
a,b,c,d=list(map(int,input().split()))
l[a-1][b-1][c-1]+=d
for i in l[:-1]:
for j in i:
print(" "+" ".join(list(map(str,j))))
print("####################")
for j in l[-1]:
print(" "+" ".join(list(map(str,j)))) | data = [
[[0 for k in range(10)] for j in range(3)] for i in range(4)
]
count = int(input())
for x in range(count):
(b,f,r,v) = [int(i) for i in input().split()]
data[b - 1][f - 1][r - 1] += v
for b in range(4):
for f in range(3):
print(' ',end='')
for r in range(10):
if r == 9:
print(data[b][f][r], end='')
else:
print(data[b][f][r], '', end='')
print()
if b == 3:
break
for x in range(20):
print('#',end='')
print() | 1 | 1,090,076,424,778 | null | 55 | 55 |
A = map(int, input().split())
print('bust' if(sum(A) >= 22) else 'win')
| cards = list(map(int, input().split()))
print('win' if sum(cards) <= 21 else 'bust') | 1 | 118,501,297,453,380 | null | 260 | 260 |
N = int(input())
senter = N // 1.08
for i in range(1000):
if int((senter-100+i) * 1.08) == N:
print(int(senter-100+i))
break
else:
print(":(")
| n=int(input())
ans=':('
for i in range(1,n+1):
if int((i*1.08)//1)==n:
ans=i
break
print(ans)
| 1 | 126,146,805,364,268 | null | 265 | 265 |
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
for k in range(N):
B = int(input())
for l in range(3):
for m in range(3):
if A[l][m] == B:
A[l][m] = 0
if (A[0][0] == A[0][1] == A[0][2] == 0) or (A[1][0] == A[1][1] == A[1][2] == 0) or (A[2][0] == A[2][1] == A[2][2] == 0):
print ("Yes")
elif (A[0][0] == A[1][0] == A[2][0] == 0) or (A[0][1] == A[1][1] == A[2][1] == 0) or (A[0][2] == A[1][2] == A[2][2] == 0):
print ("Yes")
elif (A[0][0] == A[1][1] == A[2][2] == 0) or (A[0][2] == A[1][1] == A[2][0] == 0):
print ("Yes")
else:
print ("No") | # cook your dish here
import sys
def file():
sys.stdin = open('input.py', 'r')
sys.stdout = open('output.py', 'w')
def main(N, arr):
#initialising with positive infinity value
maxi=float("inf")
#initialising the answer variable
ans=0
#iterating linesrly
for i in range(N):
#finding minimum at each step
maxi=min(maxi,arr[i])
#increasing the final ans
ans+=maxi
print("dhh")
#returning the answer
return ans
#file()
if __name__ == '__main__':
#length of the array
'''N = 4
#Maximum size of each individual bucket
Arr = [4,3,2,1]
#passing the values to the main function
answer = main(N,Arr)
#printing the result
print(answer)'''
n=int(input())
s=input()
#l=list(map(int, input().split()))
ans=0
for i in range(1,n):
if(s[i]!=s[i-1]):
ans+=1
print(ans+1)
| 0 | null | 114,954,574,151,908 | 207 | 293 |
import sys
print('Yes' if len(set(sys.stdin.read().strip())) >= 2 else 'No') | x = input().split()
W, H, x, y, r = int(x[0]), int(x[1]), int(x[2]), int(x[3]), int(x[4])
if r <= x and r <= y and x + r <= W and y + r <= H:
print('Yes')
else:
print('No')
| 0 | null | 27,510,322,010,626 | 201 | 41 |
n,m = input().split()
n=int(n)
m=float(m)*100+0.5
m=int(m)
ans = int(n*m//100)
print(ans) | from decimal import Decimal
A, B = input().split()
A = int(A)
if len(B) == 1:
B = int(B[0] + '00')
elif len(B) == 3:
B = int(B[0] + B[2] + '0')
else:
B = int(B[0]+B[2]+B[3])
x = str(A*B)
print(x[:-2] if len(x) > 2 else 0)
| 1 | 16,475,190,909,408 | null | 135 | 135 |
N = int(input())
S = input()
R = set()
G = set()
B = set()
for i, s in enumerate(S):
if s == 'R':
R.add(i)
elif s == 'G':
G.add(i)
elif s == 'B':
B.add(i)
ans = 0
for r in R:
for g in G:
ans += len(B)
d = abs(r-g)
if (r+g) % 2 == 0 and (r+g)//2 in B:
ans -= 1
if r+d in B or g+d in B:
ans -= 1
if r-d in B or g-d in B:
ans -= 1
print(ans)
| N = int(input())
if N % 2 == 1:
print(0)
else:
i = 1
ans = 0
while 2*(5**i) <= N:
div = 2 * (5 ** i)
ans += int(N//div)
i += 1
print(ans) | 0 | null | 76,398,457,040,682 | 175 | 258 |
from collections import deque
H, W = map(int, input().split())
S=[]
for _ in range(H):
S.append(input())
vx = [1, 0, -1, 0]
vy = [0, 1, 0, -1]
ans = 0
def func(si, sj):
queue = deque([si, sj])
seen = [[-1]*W for _ in range(H)]
seen[si][sj] = 0
while queue:
x = queue.popleft()
y = queue.popleft()
for i in range(4):
nx = x + vx[i]
ny = y + vy[i]
if nx<0 or nx>=H or ny<0 or ny>=W:
continue
if S[nx][ny]=="#" or seen[nx][ny]>=0:
continue
seen[nx][ny]=seen[x][y]+1
queue.append(nx)
queue.append(ny)
return seen[x][y]
ans = 0
for i in range(H):
for j in range(W):
if S[i][j]==".":
ans = max(ans, func(i, j))
print(ans) | from collections import deque
h,w=map(int,input().split())
s=[list(input()) for _ in range(h)]
ans=0
for i in range(h):
for j in range(w):
if s[i][j]==".":
cnt=[[-1]*w for _ in range(h)]
cnt[i][j]=0
queue=deque()
queue.append([i,j])
for k in range(100*h*w):
if len(queue)==0:
break
num=queue.popleft()
num1=num[0]
num2=num[1]
if num1!=0:
if s[num1-1][num2]=="." and cnt[num1-1][num2]==-1:
cnt[num1-1][num2]=cnt[num1][num2]+1
queue.append([num1-1,num2])
if num2!=0:
if s[num1][num2-1]=="." and cnt[num1][num2-1]==-1:
cnt[num1][num2-1]=cnt[num1][num2]+1
queue.append([num1,num2-1])
if num1!=h-1:
if s[num1+1][num2]=="." and cnt[num1+1][num2]==-1:
cnt[num1+1][num2]=cnt[num1][num2]+1
queue.append([num1+1,num2])
if num2!=w-1:
if s[num1][num2+1]=="." and cnt[num1][num2+1]==-1:
cnt[num1][num2+1]=cnt[num1][num2]+1
queue.append([num1,num2+1])
cnt2=0
for k in range(h):
cnt2=max(cnt2,max(cnt[k]))
ans=max(ans,cnt2)
print(ans)
| 1 | 94,573,630,345,696 | null | 241 | 241 |
a,b = map(int,input().split())
w = []
t = {}
for i in range(b):
c = int(input())
s = list(map(int,input().split()))
w +=s
t = set(w)
print(a-len(t)) |
from sys import stdin
input = stdin.readline().rstrip
#x = input().rstrip()
#n = int(input())
#a,b,c = input().split()
#a,b,c = map(int, input().split())
D,T,S = map(int, input().split(" "))
if(T * S >= D):
print("Yes")
else:
print("No")
| 0 | null | 14,147,087,573,830 | 154 | 81 |
# -*- coding: utf-8 -*-
def main():
X, Y, Z = map(int, input().split())
X, Y = change(X, Y)
X, Z = change(X, Z)
print(X, Y ,Z)
def change(a, b):
num = a
a = b
b = num
return(a, b)
if __name__ == "__main__":
main() | while True:
n, x = map(int,input().split())
count=0
if n == x == 0:
break
else:
ls = []
for i in range(1,n+1):
ls.append(i)
for s in ls:
num1 = s
for j in ls:
if num1 == j:
break
else:
num2 = j
if x < num1+num2:
break
for k in ls:
if num1 == k:
break
elif num2 == k:
break
elif num1+num2+k == x:
count+=1
else:
pass
print(count) | 0 | null | 19,527,199,222,328 | 178 | 58 |
N,K = map(int,input().split())
A = list(map(int,input().split()))
MOD = 10**9+7
if all(a>=0 for a in A):
A.sort()
ans = 1
for _ in range(K):
ans *= A.pop()
ans %= MOD
print(ans)
exit()
if all(a<0 for a in A):
A.sort(reverse=K%2==0)
ans = 1
for _ in range(K):
ans *= A.pop()
ans %= MOD
print(ans)
exit()
if N==K:
ans = 1
for a in A:
ans *= a
ans %= MOD
print(ans)
exit()
arr = []
for a in A:
if a < 0:
arr.append((-a,1))
else:
arr.append((a,0))
arr.sort()
pz = []
ng = []
for _ in range(K):
v,s = arr.pop()
if s:
ng.append(v)
else:
pz.append(v)
if len(ng)%2 == 0:
ans = 1
for v in ng:
ans *= v
ans %= MOD
for v in pz:
ans *= v
ans %= MOD
print(ans)
exit()
b = pz[-1] if pz else None
c = ng[-1] if ng else None
a = d = None
while arr and (a is None or d is None):
v,s = arr.pop()
if s:
if a is None:
a = v
else:
if d is None:
d = v
if (a is None or b is None) and (c is None or d is None):
assert False
ans = 1
if a is None or b is None:
ans = d
for v in ng[:-1]:
ans *= v
ans %= MOD
for v in pz:
ans *= v
ans %= MOD
elif c is None or d is None:
ans = a
for v in ng:
ans *= v
ans %= MOD
for v in pz[:-1]:
ans *= v
ans %= MOD
else:
if a*c > b*d:
ans = a
for v in ng:
ans *= v
ans %= MOD
for v in pz[:-1]:
ans *= v
ans %= MOD
else:
ans = d
for v in ng[:-1]:
ans *= v
ans %= MOD
for v in pz:
ans *= v
ans %= MOD
ans %= MOD
print(ans) | import sys
input = sys.stdin.readline
mod = int(1e9+7)
n,k = map(int,input().split())
L=list(map(int,input().split()))
ans = 1
if k==n:
for i in L:
ans*=i
ans%=mod
print(ans%mod)
sys.exit()
pos = []
neg = []
for i in L:
if i>=0:
pos.append(i)
else:
neg.append(i)
pos.sort(reverse=True)
neg.sort()
if len(pos) == 0 and k%2!=0:
for i in range(1,k+1):
ans*=neg[-i]
ans%=mod
print(ans%mod)
sys.exit()
if k%2!=0:
ans*=pos.pop(0)
k-=1
l=[]
for i in range(1,len(pos),2):
l.append(pos[i]*pos[i-1])
for i in range(1,len(neg),2):
l.append(neg[i]*neg[i-1])
l.sort(reverse = True)
for i in range(k//2):
ans*=l[i]
ans%=mod
print(ans%mod)
| 1 | 9,462,261,079,300 | null | 112 | 112 |
n,m,k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
from itertools import accumulate
import bisect
cumsum_a = list(accumulate(a))
cumsum_b = list(accumulate(b))
ans = 0
for i in range(1, n+1):
if cumsum_a[i-1] > k:
break
cnt_b = bisect.bisect(cumsum_b, k - cumsum_a[i-1])
ans = max(ans, i + cnt_b)
for i in range(1, m+1):
if cumsum_b[i-1] > k:
break
cnt_a = bisect.bisect(cumsum_a, k - cumsum_b[i-1])
ans = max(ans, i + cnt_a)
print(ans) | import bisect
N, M, K = map(int, input().split())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
Asums = [0] * (N + 1)
for i, a in enumerate(A):
Asums[i+1] = Asums[i] + a
Bsums = [0] * (M + 1)
for i, b in enumerate(B):
Bsums[i+1] = Bsums[i] + b
ans = 0
for anum in range(N + 1):
t = Asums[anum]
if K < t:
break
bnum = bisect.bisect_right(Bsums, K - t) - 1
ans = max(ans, anum + bnum)
print(ans) | 1 | 10,726,190,040,320 | null | 117 | 117 |
n, k = map(int, input().split())
p = list(map(int, input().split()))
e = []
for i in range(n):
e.append(p[i] + 1)
sum_e = [0]
for i in range(1,n+1):
sum_e.append(sum_e[i-1]+e[i-1])
ans = []
for i in range(n-k+1):
ans.append(sum_e[i+k]-sum_e[i])
print(max(ans)/2) | import sys
from itertools import accumulate
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
n, k = rm()
a = [(i+1)/2 for i in rl()]
a = [0] + list(accumulate(a))
ans = 0
for i in range(n-k+1):
ans = max(ans, a[i+k] - a[i])
print(ans) | 1 | 74,821,060,409,890 | null | 223 | 223 |
N = int(input())
A = list(map(int, input().split()))
print(" ".join(map(str,A)))
for i in range(1,N):
tmp = A[i]
j = i-1
while j >= 0 and A[j] > tmp:
A[j+1] = A[j]
j += -1
A[j+1] = tmp
print(" ".join(map(str,A)))
| S = input()
T = input()
ans = ''
if len(T) != len(S) + 1:
ans = 'No'
else:
ans = 'Yes'
for i in range(len(S)):
if S[i] != T[i]:
ans = 'No'
print(ans) | 0 | null | 10,686,247,571,338 | 10 | 147 |
import math
A, B, N = [int(x) for x in input().split()]
count = min(B-1, N)
a = math.floor(float(A*count)/B) - A * math.floor(float(count)/B)
print(a)
| from collections import Counter as C
n=int(input())
S=list(input())
a=1
L=C(S).most_common(3)
for l in L:
a*=l[1]
for i in range(1,n):
for j in range(n-2*i):
if len(set((S[j],S[j+i],S[j+2*i])))==3:
a-=1
print(a if len(L)>2 else 0) | 0 | null | 31,898,529,504,830 | 161 | 175 |
def main():
t = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
circle = a[0] * t[0] + a[1] * t[1] - b[0] * t[0] - b[1] * t[1]
if circle == 0:
print('infinity')
return
d = [0, 0]
cd = 0
ans = -1
for i in range(2):
d[i] = cd + a[i] * t[i] - b[i] * t[i]
if cd * d[i] <= 0:
ans += 1
cd = d[i]
if ans == 0:
print(0)
return
if circle < 0:
if d[0] > 0:
ans += d[0] // -circle * 2
if d[0] % (-circle) == 0:
ans -= 1
elif d[1] > 0:
ans += d[1] // -circle * 2
if d[1] % (-circle) == 0:
ans -= 1
else:
if d[0] < 0:
ans += -d[0] // circle * 2
if -d[0] % (circle) == 0:
ans -= 1
elif d[1] < 0:
ans += -d[1] // circle * 2
if -d[1] % (circle) == 0:
ans -= 1
print(ans)
main() | T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
Ad = A1 * T1 + A2 * T2
Bd = B1 * T1 + B2 * T2
if Ad == Bd:
print('infinity')
else:
if Bd > Ad:
Ad, Bd = Bd, Ad
A1, B1 = B1, A1
if A1 > B1:
print(0)
else:
num = (B1 - A1) * T1 // (Ad - Bd)
if (B1 - A1) * T1 % (Ad - Bd) == 0:
print(num * 2)
else:
print(num * 2 + 1)
| 1 | 131,404,139,538,462 | null | 269 | 269 |
W = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
S = input()
print(len(W) - W.index(S))
| youbi = ['SUN','MON','TUE','WED','THU','FRI','SAT']
y = input()
for i in range(7):
if y == youbi[i]:
print(7-i) | 1 | 132,988,563,426,202 | null | 270 | 270 |
from math import sqrt
a,b,c,d=map(float,input().split())
e=sqrt((c-a)**2+(d-b)**2)
print(e)
| x1, y1, x2, y2 = map(float,input().split())
print(f'{((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5:8f}')
| 1 | 157,364,988,130 | null | 29 | 29 |
from math import sqrt
n = int(input())
p = 0
for i in range(n):
x = int(input())
ad = 1
j = 2
while j < (int(sqrt(x))+1):
if x%j == 0:
ad = 0
break
else:
j += 1
p += ad
print(p)
| def main():
bingo = []
for ss in range(3):
s = list(map(int,input().strip().split()))
bingo.append(s)
n = int(input())
nl = []
for nn in range(n):
nl.append(int(input()))
for i in range(3):
for j in range(3):
for n in nl:
if bingo[i][j] == n:
bingo[i][j] = -1
for i in range(3):
if bingo[0][i] == bingo[1][i] == bingo[2][i] == -1:
print("Yes")
return
if bingo[i][0] == bingo[i][1] == bingo[i][2] == -1:
print("Yes")
return
if bingo[0][0] == bingo[1][1] == bingo[2][2] == -1:
print("Yes")
return
if bingo[0][2] == bingo[1][1] == bingo[2][0] == -1:
print("Yes")
return
print("No")
return
main()
| 0 | null | 30,158,300,493,740 | 12 | 207 |
def resolve():
N, M = map(int, input().split())
ans = 0
if N == 1 and M == 1:
pass
else:
if N != 0:
ans += N*(N-1)/2
if M != 0:
ans += M*(M-1)/2
print(int(ans))
resolve() | import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
def select(n,k):
return math.factorial(n)//(math.factorial(k)*math.factorial(n-k))
n,m = LI()
ans = 0
if n>=2:
ans += n*(n-1)//2
if m>=2:
ans += m*(m-1)//2
print(ans)
main()
| 1 | 45,675,090,257,642 | null | 189 | 189 |
n=int(input())
l=list(map(int,input().split()))
summ=0
for i in l:
summ+=i
ans=0
for i in l:
summ-=i
ans+=i*summ
print(ans%1000000007) | import sys
stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))
def main():
n = ni()
A = nl()
mod = 10 ** 9 + 7
s = sum(A)
q = sum([a ** 2 for a in A])
ans = (((s * s) - q)) // 2
print(int(ans % mod))
if __name__ == '__main__':
main()
| 1 | 3,774,633,451,840 | null | 83 | 83 |
card = []
suit = ["S","H","C","D"]
for s in suit:
for i in range(1,14):
card.append(s + " " + str(i))
n = int(input())
for i in range(n):
card.remove(input())
for c in card:
print(c) | S, T = map(str, input().split())
A, B = map(int, input().split())
U = input()
if U == S:
A -= 1
else:
B -= 1
print(str(A) + ' ' + str(B)) | 0 | null | 36,642,985,691,576 | 54 | 220 |
A = input()
print('A') if A.isupper() else print('a') | def atc_160b(X: int) -> int:
return X // 500 * 1000 + X % 500 // 5 * 5
X_input = int(input())
print(atc_160b(X_input))
| 0 | null | 26,943,135,865,660 | 119 | 185 |
n, m = map(int,input().split())
a = [[0]*m for i in range(n)]
b = [0]*m
for i in range(n):
a[i] = list(map(int,input().split()))
for j in range(m):
b[j] = int(input())
c = [0]*n
for i in range(n):
for j in range(m):
c[i] += a[i][j] * b[j]
for i in c:
print(i)
| import collections
N=int(input())
s=[str(input()) for i in range(N)]
c=collections.Counter(s)
maximum =max(c.values())
max_c_list = sorted(key for key,value in c.items() if value == maximum)
for s in max_c_list:
print(s) | 0 | null | 35,387,236,735,300 | 56 | 218 |
import sys
sys.setrecursionlimit(300000)
from math import sqrt, ceil
from collections import defaultdict
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')
N = I()
n = ceil(sqrt(N))
d = defaultdict(int)
for x in range(1, n + 1):
for y in range(1, n + 1):
for z in range(1, n + 1):
a = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
if a <= N:
d[a] += 1
for i in range(1, N + 1):
print(d[i]) | import collections
import sys
A = []
n = int(input())
for i in range(1,100):
for j in range(1,100):
for k in range(1,100):
A.append(i**2+j**2+k**2+i*j+j*k+k*i)
c = collections.Counter(A)
for x in range(1,n+1):
print(c[x])
sys.exit()
| 1 | 7,961,619,178,150 | null | 106 | 106 |
N, K = map(int,input().split())
ans = 0
MOD = 10**9 + 7
for i in range(K,N+2):
x = (N+1-i) * i + 1
ans += x
ans %= MOD
print (ans) | n,k=map(int,input().split())
DIV = 10**9+7
count = 0
for i in range(k,n+2):
min_k = i*(i-1)/2
max_k = i*(2*n-i+1)/2
count += max_k - min_k + 1
print(int(count % DIV)) | 1 | 33,044,100,162,892 | null | 170 | 170 |
print('A%sC'%'BR'[input()<'AR']) | import math
a,b,deg = map(float,input().split(" "))
sindeg = math.sin(math.radians(deg))
S = (a*b*sindeg)/2
cosdeg = math.cos(math.radians(deg))
z = a*a + b*b - 2*a*b*cosdeg
L = a + b + math.sqrt(z)
h = b*sindeg
print("{:.5f}".format(S))
print("{:.5f}".format(L))
print("{:.5f}".format(h))
| 0 | null | 12,190,936,439,440 | 153 | 30 |