language stringclasses 5
values | dataset stringclasses 1
value | code stringlengths 26 25k | id stringlengths 10 10 | test_IO listlengths 1 1 |
|---|---|---|---|---|
Python | codenet | def main():
X, K, D = map(int, input().split())
r = X // D
if abs(r) > K:
print(abs(X) - K * D)
exit()
a = X - r * D
if (K - r) % 2 == 0:
print(a)
else:
print(abs(D - a))
if __name__ == '__main__':
main()
| s814885508 | [
{
"input": "6 2 4\n",
"output": "2\n"
}
] |
Python | codenet | n = int(input())
l = input().split()
max = -1e9
min = 1e9
sum = 0
for i in range(n):
sum += int(l[i])
if max < int(l[i]):
max = int(l[i])
if min > int(l[i]):
min = int(l[i])
print(min, max, sum)
| s704354119 | [
{
"input": "5\n10 1 5 4 17\n",
"output": "1 17 37\n"
}
] |
Python | codenet | H, W = map(int, input().split())
h, w = map(int, input().split())
ans = H * W - (h * W + w * H - h * w)
print(ans)
| s043174379 | [
{
"input": "3 2\n2 1\n",
"output": "1\n"
}
] |
Python | codenet | N, A, B = map(int, input().split())
ans = A * (N//(A+B)) + min(A, N % (A+B))
print(ans)
| s246930871 | [
{
"input": "8 3 4\n",
"output": "4\n"
}
] |
Python | codenet | A, B, K = map(int, input().split())
if A+K-1 >= B-K+1:
while A <= B:
print(A)
A += 1
else:
i = 0
while i <= K-1:
print(A+i)
i += 1
while B-K+1 <= B:
print(B-K+1)
K -= 1
| s357377130 | [
{
"input": "3 8 2\n",
"output": "3\n4\n7\n8\n"
}
] |
Python | codenet | N, x = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
for i in range(1, N):
tmp = a[i - 1] + a[i]
if tmp > x:
if tmp - x > a[i]:
a[i - 1] = tmp - a[i] - x
a[i] = 0
else:
a[i] = a[i] - (tmp - x)
cnt += tmp - x
print(cnt)
| s708549466 | [
{
"input": "3 3\n2 2 2\n",
"output": "1\n"
}
] |
Python | codenet | a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if a == b:
print('YES')
elif v <= w:
print('NO')
else:
if t < abs(a - b) / (v - w):
print('NO')
else:
print('YES')
| s122565091 | [
{
"input": "1 2\n3 1\n3\n",
"output": "YES\n"
}
] |
Python | codenet | from collections import deque
n = int(input())
a = list(map(str, input().split()))
b = []
b = a[1::2][::-1]+a[::2]
if len(a) % 2 == 0:
print(' '.join(b))
else:
print(' '.join(b[::-1]))
| s735480710 | [
{
"input": "4\n1 2 3 4\n",
"output": "4 2 1 3\n"
}
] |
Python | codenet | n = int(input())
arr = {}
for i in range(n):
s = input()
if not s in arr:
arr[s] = 1
else:
arr[s] += 1
max_count = max(arr.values())
dic = [key[0] for key in arr.items() if key[1] == max_count]
out_sort = sorted(dic)
for i in out_sort:
print(i)
| s622795537 | [
{
"input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n",
"output": "beet\nvet\n"
}
] |
Python | codenet | n = int(input())
s = str(input())
ans = 0
for i in range(n):
x = set(s[:i+1])
y = set(s[i+1:])
z = 0
for w in x:
if w in y:
z += 1
if z > ans:
ans = z
print(ans)
| s232279435 | [
{
"input": "6\naabbca\n",
"output": "2\n"
}
] |
Python | codenet | s = input()
if len(s) == 2:
print(s)
else:
print(s[::-1])
| s195311365 | [
{
"input": "abc\n",
"output": "cba\n"
}
] |
Python | codenet | import math
MOD = 10**9+7
f = math.factorial
n, m = sorted(map(int, input().split()))
print(max(2 - m + n, 0)*f(n)*f(m) % MOD)
| s840967243 | [
{
"input": "2 2\n",
"output": "8\n"
}
] |
Python | codenet | N = int(input())
m = []
line = ''
m = [[[0 for k in range(10)] for j in range(3)] for i in range(10)]
for i in range(N):
n = input().split()
b = int(n[0])
f = int(n[1])
r = int(n[2])
v = int(n[3])
m[b-1][f-1][r-1] += v
for i in range(4):
for j in range(3):
for k in range(10):
... | s067092519 | [
{
"input": "3\n1 1 3 8\n3 2 2 7\n4 3 8 1\n",
"output": " 0 0 8 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n####################\n 0 0 0 0 0 0 0 0 0 0\n 0 7 0 0 0 0 0 0 0 0\n 0 0 0 0 0 0 0 0 0 0\n##########... |
Python | codenet | a = input()
print("Yes" if '9' in a else "No")
| s485638370 | [
{
"input": "29\n",
"output": "Yes\n"
}
] |
Python | codenet | N = int(input())
S = input()
x = 1
for i in range(N-1):
if S[i] != S[i+1]:
x = x+1
print(x)
| s642705424 | [
{
"input": "10\naabbbbaaca\n",
"output": "5\n"
}
] |
Python | codenet | def main():
N, M, Q = map(int, input().split())
train = [[0 for _ in range(N)] for _ in range(N)]
for _ in range(M):
l, r = map(int, input().split())
train[l-1][r-1] += 1
accum = [[0 for _ in range(N+1)]]
for i in range(N):
temp = [0]
v = 0
for j in range(N)... | s048491063 | [
{
"input": "2 3 1\n1 1\n1 2\n2 2\n1 2\n",
"output": "3\n"
}
] |
Python | codenet | A, B = map(int, input().split())
if A == B:
print("Draw")
elif A == 1:
print("Alice")
elif B == 1:
print("Bob")
elif A > B:
print("Alice")
else:
print("Bob")
| s040517919 | [
{
"input": "8 6\n",
"output": "Alice\n"
}
] |
Python | codenet | print(input().swapcase())
| s147181072 | [
{
"input": "fAIR, LATER, OCCASIONALLY CLOUDY.\n",
"output": "Fair, later, occasionally cloudy.\n"
}
] |
Python | codenet | import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy
def prime_decomposition(n):
i = 2
table = []
while i * i <= n:
while n % i == 0:
n /= i
table.append(int(i))
i += 1
if n >... | s086522214 | [
{
"input": "2019/04/30\n",
"output": "Heisei\n"
}
] |
Python | codenet | import re
import math
from collections import defaultdict
import itertools
from copy import deepcopy
import random
from heapq import heappop, heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
readline = sys.stdin.readline
sys.setrecursionlimit(2000000)
alphabet = "... | s977408144 | [
{
"input": "3 3\ndxx\naxx\ncxx\n",
"output": "axxcxxdxx\n"
}
] |
Python | codenet | from itertools import *
N = int(input())
x = 1
N_list = [x+1 for x in range(N)]
n = list(product(N_list, repeat=3))
m = len(n)
print(m)
| s797394058 | [
{
"input": "2\n",
"output": "8\n"
}
] |
Python | codenet | n, x = map(int, input().split())
m = [int(input()) for _ in range(n)]
m.sort()
print(n + (x - sum(m)) // m[0])
| s934308496 | [
{
"input": "3 1000\n120\n100\n140\n",
"output": "9\n"
}
] |
Python | codenet | N, K = [int(_) for _ in input().split()]
S = set()
for i in range(K):
d = int(input())
A = [int(_) for _ in input().split()]
S = S | set(A)
print(N - len(S))
| s411244720 | [
{
"input": "3 2\n2\n1 3\n1\n3\n",
"output": "1\n"
}
] |
Python | codenet | N = int(input())
ans = []
for i in range(1, N+1):
if sum(range(1, i + 1)) < N:
continue
else:
ans = [i - 1, sum(range(1, i + 1)) - N]
break
for i in range(ans[0]+1):
if i + 1 != ans[1]:
print(i + 1)
| s200092246 | [
{
"input": "4\n",
"output": "1\n3\n"
}
] |
Python | codenet | a, b = map(int, input().split())
if a <= 8 and b <= 8:
print("Yay!")
else:
print(":(")
| s453478465 | [
{
"input": "5 4\n",
"output": "Yay!\n"
}
] |
Python | codenet | import collections
n = int(input())
ls = [input() for i in range(n)]
c = collections.Counter(ls)
count = c.most_common()[0][1]
ans = []
p = c.most_common()
for i in range(len(c)):
if p[i][1] == count:
ans.append(p[i][0])
else:
break
ans = sorted(ans)
for i in ans:
print(i)
| s668439281 | [
{
"input": "7\nbeat\nvet\nbeet\nbed\nvet\nbet\nbeet\n",
"output": "beet\nvet\n"
}
] |
Python | codenet | n, a, b = map(int, input().split())
ans = n//(a+b)*a
r = min(n % (a+b), a)
ans += r
print(ans)
| s615966179 | [
{
"input": "8 3 4\n",
"output": "4\n"
}
] |
Python | codenet | from collections import deque
H, W = map(int, input().split())
G = []
for i in range(H+2):
if i == 0 or i == H+1:
G.append('#'*(W+2))
else:
G.append('#' + input() + '#')
ans = 0
for sx in range(W+2):
for sy in range(H+2):
if G[sy][sx] == '.':
dist = [[-float('inf') for i... | s951169509 | [
{
"input": "3 3\n...\n...\n...\n",
"output": "4\n"
}
] |
Python | codenet | s = input()
t = input()
if t[:-1] == s:
print('Yes')
else:
print('No')
| s676839884 | [
{
"input": "chokudai\nchokudaiz\n",
"output": "Yes\n"
}
] |
Python | codenet | N = int(input())
mo = []
for _ in range(N):
x, u = input().split()
x = float(x)
mo.append([x, u])
okz = 0
for i in mo:
if i[1] == "JPY":
okz += i[0]
else:
okz += i[0]*380000
print(okz)
| s554393427 | [
{
"input": "2\n10000 JPY\n0.10000000 BTC\n",
"output": "48000.0\n"
}
] |
Python | codenet | import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)
s = sorted(readline().rstrip())
t = sorted(readline().rstrip())[::-1]
print("Yes" if s < t else "No")
| s441329208 | [
{
"input": "yx\naxy\n",
"output": "Yes\n"
}
] |
Python | codenet | R, G, B, N = map(int, input().split())
score = 0
for i in range(N // R + 1):
for j in range((N-i * R) // G + 1):
if N - i * R - j * G >= 0 and (N - i * R - j * G) % B == 0:
score += 1
print(score)
| s897879131 | [
{
"input": "1 2 3 4\n",
"output": "4\n"
}
] |
Python | codenet | import sys
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
def getS(): return input().strip()
def getN(): return int(input())
def getList(): return list(map(int, input().split()))
def getZList(): return [int(x) - 1 for x in input().split()]
INF = 10 ** 20
MOD = 1000000007
def solve():
... | s344468705 | [
{
"input": "5\n2\n1\n4\n5\n3\n",
"output": "2\n"
}
] |
Python | codenet | from collections import deque
N, M = map(int, input().split())
G = {i: [] for i in range(1, N+1)}
for _ in range(M):
a, b = map(int, input().split())
G[a].append(b)
G[b].append(a)
col = [-1 for _ in range(N+1)]
cnt = 0
for i in range(1, N+1):
if col[i] < 0:
col[i] = cnt
que = deque([i])
... | s233116196 | [
{
"input": "3 1\n1 2\n",
"output": "1\n"
}
] |
Python | codenet | a, b = map(int, input().split())
print(a+b if a == b else max(a, b)*2-1)
| s062747389 | [
{
"input": "5 3\n",
"output": "9\n"
}
] |
Python | codenet | memTime = int(input())
memLate = input().split()
memLate = [int(i) for i in memLate]
colorList = []
memColor = 0
highLate = 0
for color in range(memTime):
member = memLate[color]
if member // 400 >= 8:
highLate += 1
elif ((member // 400) in colorList) == False:
colorList.append(member // 400... | s964794058 | [
{
"input": "4\n2100 2500 2700 2700\n",
"output": "2 2\n"
}
] |
Python | codenet | def main():
A, B, C, X, Y = map(int, input().split())
ans = 10 ** 10
for k in range(max(X, Y) + 1):
total = 2 * C * k + A * max(0, X - k) + B * max(0, Y - k)
if total < ans:
ans = total
print(ans)
if __name__ == "__main__":
main()
| s724326345 | [
{
"input": "1500 2000 1600 3 2\n",
"output": "7900\n"
}
] |
Python | codenet | import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
def main():
N = int(readline())
s = {1, 2, 4, 8, 16, 32, 64}
ans = 0
for i in range(1, N + 1):
if i in s:
ans = i
print(ans)
if __name__ == '__main__':
main()
| s878873709 | [
{
"input": "7\n",
"output": "4\n"
}
] |
Python | codenet | n = input()
n = int(n[-1])
if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
print("hon")
elif n == 0 or n == 1 or n == 6 or n == 8:
print("pon")
else:
print("bon")
| s652791025 | [
{
"input": "16\n",
"output": "pon\n"
}
] |
Python | codenet | x = int(input())
print("ai1333{}".format("3"*(x // 100)))
| s039768540 | [
{
"input": "0\n",
"output": "ai1333\n"
}
] |
Python | codenet | N = int(input())
S = input()
ans = 1
tmp = S[0]
for s in S:
if s != tmp:
ans += 1
tmp = s
print(ans)
| s174910557 | [
{
"input": "10\naabbbbaaca\n",
"output": "5\n"
}
] |
Python | codenet | n = input()
l = list(map(int, input().split()))
b = max(l)
s = sum(l)
if b < s - b:
print('Yes')
else:
print('No')
| s893778513 | [
{
"input": "4\n3 8 5 1\n",
"output": "Yes\n"
}
] |
Python | codenet | I = input
s = I()*2
print(['No', 'Yes'][I() in s])
| s592421258 | [
{
"input": "vanceknowledgetoad\nadvance\n",
"output": "Yes\n"
}
] |
Python | codenet | N, K = map(int, input().split())
score = list(map(int, input().split()))
mae = 0
usiro = K
for i in range(N-K):
if score[mae] < score[usiro]:
print('Yes')
else:
print('No')
mae += 1
usiro += 1
| s182651529 | [
{
"input": "5 3\n96 98 95 100 20\n",
"output": "Yes\nNo\n"
}
] |
Python | codenet | N = str(input())
print("ABC"+N)
| s681170949 | [
{
"input": "100\n",
"output": "ABC100\n"
}
] |
Python | codenet | import math
def keta(s):
if len(s) < 2:
return int(s)
n = sum(map(int, s))
return keta(str(n))
def main():
N = input()
if keta(N) % 9 == 0:
print("Yes")
else:
print("No")
if __name__ == "__main__":
main()
| s486032847 | [
{
"input": "123456789\n",
"output": "Yes\n"
}
] |
Python | codenet | x = int(input())
a = int(input())
b = int(input())
print((x-a) % b)
| s694958625 | [
{
"input": "1234\n150\n100\n",
"output": "84\n"
}
] |
Python | codenet | n = int(input())
r = 0
for ii in range(n):
if (ii+1) % 3 != 0 and (ii+1) % 5 != 0:
r += (ii+1)
print(r)
| s702834515 | [
{
"input": "15\n",
"output": "60\n"
}
] |
Python | codenet | from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
def I(): return int(input())
def MI(): return map(int, input().split())
def ... | s664563518 | [
{
"input": "3\ndwango 2\nsixth 5\nprelims 25\ndwango\n",
"output": "30\n"
}
] |
Python | codenet | n = int(input())
if n >= 1000:
print('ABD')
else:
print('ABC')
| s870744379 | [
{
"input": "999\n",
"output": "ABC\n"
}
] |
Python | codenet | W, H, x, y, r = map(int, input().split())
if x >= r and (W - r) >= x:
if y >= r and (H - r) >= y:
print('Yes')
else:
print('No')
else:
print('No')
| s103354654 | [
{
"input": "5 4 2 2 1\n",
"output": "Yes\n"
}
] |
Python | codenet | N = int(input())
H = list(map(int, list(input().split())))
count_best, count_tmp = 0, 0
for i in range(N-1):
if H[i] >= H[i+1]:
count_tmp += 1
else:
if count_tmp > count_best:
count_best = count_tmp
count_tmp = 0
if count_tmp > count_best:
count_best = count_tmp
prin... | s895229833 | [
{
"input": "5\n10 4 8 7 3\n",
"output": "2\n"
}
] |
Python | codenet | from itertools import chain
import numpy as np
import networkx as nx
X = iter(open(0).readlines())
h, w = map(int, next(X).split())
C = np.zeros((10, 10), dtype=int)
for i in range(10):
for j, c in enumerate(map(int, next(X).split())):
C[i, j] = c
A = np.zeros((h, w), dtype=int)
for i in range(h):
for ... | s749244504 | [
{
"input": "2 4\n0 9 9 9 9 9 9 9 9 9\n9 0 9 9 9 9 9 9 9 9\n9 9 0 9 9 9 9 9 9 9\n9 9 9 0 9 9 9 9 9 9\n9 9 9 9 0 9 9 9 9 2\n9 9 9 9 9 0 9 9 9 9\n9 9 9 9 9 9 0 9 9 9\n9 9 9 9 9 9 9 0 9 9\n9 9 9 9 2 9 9 9 0 9\n9 2 9 9 9 9 9 9 9 0\n-1 -1 -1 -1\n8 1 1 8\n",
"output": "12\n"
}
] |
Python | codenet | n, k = map(int, input().split())
a = [i for i in input()]
c = [0]*n
for i in range(1, n):
if a[i] == "C" and a[i-1] == "A":
c[i] = c[i-1]+1
else:
c[i] = c[i-1]
for w in range(k):
l, r = map(int, input().split())
print(c[r-1]-c[l-1])
| s759499751 | [
{
"input": "8 3\nACACTACG\n3 7\n2 3\n1 8\n",
"output": "2\n0\n3\n"
}
] |
Python | codenet | from collections import deque
from itertools import product, permutations, combinations
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline
ra = range
enu = enumerate
def exit(*argv, **kwarg):
print(*argv, **kwarg)
sys.exit()
def mina(*argv, sub=1): retur... | s124725275 | [
{
"input": "4 4\n1 1\n4 4\n..#.\n..#.\n.#..\n.#..\n",
"output": "1\n"
}
] |
Python | codenet | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
s = sum(a)/(4*m)
if a[m-1] >= s:
print('Yes')
else:
print('No')
| s777789287 | [
{
"input": "4 1\n5 4 2 1\n",
"output": "Yes\n"
}
] |
Python | codenet | a, b = map(int, input().split())
if a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:
print('Possible')
else:
print('Impossible')
| s858647829 | [
{
"input": "4 5\n",
"output": "Possible\n"
}
] |
Python | codenet | n = int(input())
p = [int(x) for x in input().split()]
p_copy = p[:]
p.sort()
count = 0
for i in range(n):
if p[i] != p_copy[i]:
count += 1
if count == 0 or count == 2:
print("YES")
else:
print("NO")
| s763097776 | [
{
"input": "5\n5 2 3 4 1\n",
"output": "YES\n"
}
] |
Python | codenet | N = int(input())
capacity_list = [int(input()) for _ in range(5)]
capacity_list.sort()
bottle_neck = capacity_list[0]
print(4+int((N+bottle_neck-1)/bottle_neck))
| s582886163 | [
{
"input": "5\n3\n2\n4\n3\n5\n",
"output": "7\n"
}
] |
Python | codenet | n = int(input())
ls = [list(map(int, input().split())) for i in range(n)]
ls = sorted(ls, key=lambda x: sum(x), reverse=True)
taka = sum([ls[i][0] for i in range(0, len(ls), 2)])
aoki = sum([ls[i][1] for i in range(1, len(ls), 2)])
print(taka-aoki)
| s787811177 | [
{
"input": "3\n10 10\n20 20\n30 30\n",
"output": "20\n"
}
] |
Python | codenet | n = int(input())
F = [tuple(map(int, input().split())) for _ in range(n)]
P = [tuple(map(int, input().split())) for _ in range(n)]
ans = -10 ** 18
for i in range(1, 2**10):
tmp = 0
lst = [0]*n
for j in range(10):
if (i >> j) & 1:
for k in range(n):
lst[k] += F[k][j]
... | s906994739 | [
{
"input": "1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -2 -3 4 -2\n",
"output": "8\n"
}
] |
Python | codenet | X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
p.sort()
candidates = {}
for i in range(-1, 102):
if i in p:
continue
if not (abs(X-i) in candidates.keys()):
candidates[abs(X-i)] = [i]
else:
candidates[abs(X-i)].append(i)
smallest = min(candidates.keys... | s957164965 | [
{
"input": "6 5\n4 7 10 6 5\n",
"output": "8\n"
}
] |
Python | codenet | from math import factorial as f
N = int(input())
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
divs = []
for i in range(1, 101):
tmp = [0 for _ in range(len(primes))]
for j in range(len(primes)):
p = primes[j]
tmp[j] = 0
while (i//p == i/p):
i = i//p
... | s259116349 | [
{
"input": "9\n",
"output": "0\n"
}
] |
Python | codenet | a, b, c, d, e = map(int, input().split())
print(15-a-b-c-d-e)
| s191853417 | [
{
"input": "0 2 3 4 5\n",
"output": "1\n"
}
] |
Python | codenet | N = input()
if N == 0:
print('Yes')
else:
N = str(N)
L = list(N)
L = [int(s) for s in L]
X = sum(L)
if X % 9 == 0:
print('Yes')
else:
print('No')
| s557080041 | [
{
"input": "123456789\n",
"output": "Yes\n"
}
] |
Python | codenet | from math import floor
from heapq import heappush, heappop
n, m = map(int, input().split())
a = []
for i in map(int, input().split()):
heappush(a, -i)
def dis(x, y): return x // 2**y
for _ in range(m):
heappush(a, -dis(-heappop(a), 1))
print(-sum(a))
| s763208424 | [
{
"input": "3 3\n2 13 8\n",
"output": "9\n"
}
] |
Python | codenet | import math
N = input()
XS = [int(i) for i in input().split()]
m = 9999999999
for i in range(1, 101):
c = sum([(x - i) ** 2 for x in XS])
if m > c:
m = c
print(m)
| s880494034 | [
{
"input": "2\n1 4\n",
"output": "5\n"
}
] |
Python | codenet | n = int(input())
res = []
for i in range(n):
a = input()
res.append(a)
print(len(set(res)))
| s770408311 | [
{
"input": "3\napple\norange\napple\n",
"output": "2\n"
}
] |
Python | codenet | N, M = map(int, input().split())
a = N * (N - 1) // 2
b = M * (M - 1) // 2
print(a + b)
| s167793578 | [
{
"input": "2 1\n",
"output": "1\n"
}
] |
Python | codenet | d, g = list(map(int, input().split()))
pc = [list(map(int, input().split())) for _ in range(d)]
ans = float("inf")
for bit in range(1 << d):
count = 0
sum = 0
nokori = set(range(1, d + 1))
for i in range(d):
if bit & (1 << i):
sum += pc[i][0] * (i + 1) * 100 + pc[i][1]
... | s591424993 | [
{
"input": "2 700\n3 500\n5 800\n",
"output": "3\n"
}
] |
Python | codenet | a, b = map(int, input().split())
x = [a + b]
x.append(a - b)
x.append(a * b)
print(max(x))
| s142939923 | [
{
"input": "3 1\n",
"output": "4\n"
}
] |
Python | codenet | n = int(input())
for i in range(1, 10 ** 5):
if i * i > n:
print((i-1) * (i-1))
exit()
| s666154520 | [
{
"input": "10\n",
"output": "9\n"
}
] |
Python | codenet | n = int(input())
s = input()
left = 0
for i in s:
if i == ")":
left += 1
else:
break
left1 = 0
right1 = 0
for i in range(left, n):
if s[i] == "(":
right1 += 1
elif right1 > 0:
right1 -= 1
else:
left1 += 1
left1 += left
for i in range(right1):
s += ")"
... | s952876397 | [
{
"input": "3\n())\n",
"output": "(())\n"
}
] |
Python | codenet | R = int(input())
G = int(input())
print(G*2-R)
| s151217193 | [
{
"input": "2002\n2017\n",
"output": "2032\n"
}
] |
Python | codenet | import bisect
N = int(input())
arr = [111, 222, 333, 444, 555, 666, 777, 888, 999]
ans_idx = bisect.bisect_left(arr, N)
print(arr[ans_idx])
| s052231578 | [
{
"input": "111\n",
"output": "111\n"
}
] |
Python | codenet | import numpy
n = int(input())
a = []
for i in range(2):
a.append(list(map(int, input().split())))
a[1] = a[1][::-1]
res_0 = numpy.cumsum(a[0])
res_1 = numpy.cumsum(a[1])
ans = 0
for i in range(n):
check = res_0[i] + res_1[n-1-i]
ans = max(ans, check)
print(ans)
| s146553386 | [
{
"input": "5\n3 2 2 4 1\n1 2 2 2 1\n",
"output": "14\n"
}
] |
Python | codenet | N = int(input())
a = list(map(int, input().split()))
a.sort()
s = [ai for ai in a[N::2]]
print(sum(s))
| s913338871 | [
{
"input": "2\n5 2 8 5 1 5\n",
"output": "10\n"
}
] |
Python | codenet | n = int(input())
print(n**3)
| s454986054 | [
{
"input": "2\n",
"output": "8\n"
}
] |
Python | codenet | N, T = map(int, input().split())
L = [[int(l) for l in input().split()] for _ in range(N)]
dp = [[0]*T for _ in range(N+1)]
for i in range(N):
for j in range(T):
if j < L[i][0]:
dp[i+1][j] = dp[i][j]
else:
dp[i+1][j] = max(dp[i][j], dp[i][j-L[i][0]]+L[i][1])
used = []
B = ... | s793709854 | [
{
"input": "2 60\n10 10\n100 100\n",
"output": "110\n"
}
] |
Python | codenet | n = int(input())
x = list(map(int, input().split()))
ans = 10**10
for i in range(101):
tmp = [abs(i - x[j])**2 for j in range(n)]
if sum(tmp) < ans:
ans = sum(tmp)
print(ans)
| s246280701 | [
{
"input": "2\n1 4\n",
"output": "5\n"
}
] |
Python | codenet | N = int(input())
L = list(map(int, input().split()))
ans = 0
for i in range(N-2):
for j in range(i+1, N-1):
for k in range(j+1, N):
a = L[i]
b = L[j]
c = L[k]
if a == b or b == c or c == a:
continue
if a+b > c and b+c > a and c+a >... | s590045523 | [
{
"input": "5\n4 4 9 7 5\n",
"output": "5\n"
}
] |
Python | codenet | import sys
from collections import Counter, defaultdict
INF = float('inf')
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
de... | s007458552 | [
{
"input": "4\nRRBR\n",
"output": "Yes\n"
}
] |
Python | codenet | input = list(map(str, input().split()))
num = ''.join(input)
if (int(num) % 4 == 0):
print('YES')
else:
print('NO')
| s554858080 | [
{
"input": "4 3 2\n",
"output": "YES\n"
}
] |
Python | codenet | a, b = input().split()
if a < b:
print("<")
elif a > b:
print(">")
else:
print("=")
| s110149598 | [
{
"input": "A B\n",
"output": "<\n"
}
] |
Python | codenet | import math
N = int(input())
sqN = int(math.sqrt(N))
for i in range(sqN):
if N % (sqN-i) == 0:
print(int(N/(sqN-i)+sqN-i)-2)
break
| s538657784 | [
{
"input": "10\n",
"output": "5\n"
}
] |
Python | codenet | n = int(input())
a = list(map(int, input().split()))
below = 0
for i in range(n):
below += 1/a[i]
print(1/below)
| s001486412 | [
{
"input": "2\n10 30\n",
"output": "7.5\n"
}
] |
Python | codenet | N = int(input())
A = [int(x) for x in input().split()]
ans = abs(A[-1])
A = [0]+A+[0]
diff = [0 for x in range(N)]
for i in range(1, N+1):
dif = abs(A[i]-A[i-1])+abs(A[i]-A[i+1])-abs(A[i-1]-A[i+1])
ans += abs(A[i]-A[i-1])
diff[i-1] = dif
for i in range(N):
print(ans-diff[i])
| s242961129 | [
{
"input": "3\n3 5 -1\n",
"output": "12\n8\n10\n"
}
] |
Python | codenet | s = list(str(input()))
s.sort()
if s[0] == s[1] and s[0] != s[2] and s[2] == s[3]:
print("Yes")
else:
print("No")
| s896397037 | [
{
"input": "ASSA\n",
"output": "Yes\n"
}
] |
Python | codenet | A, B = map(int, input().split())
if (A+B) % 2 == 1:
print('IMPOSSIBLE')
else:
print((A+B)//2)
| s423256012 | [
{
"input": "2 16\n",
"output": "9\n"
}
] |
Python | codenet | N = int(input())
Hs = list(map(int, input().split()))
ans = 0
maxH = 0
for H in Hs:
if maxH <= H:
ans += 1
maxH = H
print(ans)
| s002779582 | [
{
"input": "4\n6 5 6 8\n",
"output": "3\n"
}
] |
Python | codenet | h, w = map(int, input().split())
l = []
for _ in range(h):
a = list(map(str, input()))
l.append(a)
tmp = 0
for i in range(h):
for j in range(w):
if l[i][j] == "#":
if j < tmp:
print("Impossible")
exit()
else:
tmp = j
print("... | s331817031 | [
{
"input": "4 5\n##...\n.##..\n..##.\n...##\n",
"output": "Possible\n"
}
] |
Python | codenet | n = int(input())
if n % 1000 == 0:
print(0)
else:
print(1000 - n % 1000)
| s355314304 | [
{
"input": "1900\n",
"output": "100\n"
}
] |
Python | codenet | def solver():
N = int(input())
action = []
for i in range(N):
action.append(list(map(int, input().split())))
dp = [[0 for _ in range(3)] for _ in range(N)]
for i in range(3):
dp[0][i] = action[0][i]
for i in range(1, N):
dp[i][0] = max(dp[i-1][1] + action[i][0], dp[i-1... | s210889193 | [
{
"input": "3\n10 40 70\n20 50 80\n30 60 90\n",
"output": "210\n"
}
] |
Python | codenet | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ope = [list(map(int, input().split())) for _ in range(m)]
ope = sorted(ope, key=lambda x: x[1], reverse=True)
j = 0
for i in range(n):
if a[i] < ope[j][1]:
a[i] = ope[j][1]
ope[j][0] -= 1
if ope[j][0] == 0:
... | s289483518 | [
{
"input": "3 2\n5 1 4\n2 3\n1 5\n",
"output": "14\n"
}
] |
Python | codenet | R = int(input())
if R < 1200:
print("ABC")
elif R < 2800:
print("ARC")
else:
print("AGC")
| s607161467 | [
{
"input": "1199\n",
"output": "ABC\n"
}
] |
Python | codenet | A, B = [int(x) for x in input().split()]
if A < 10 and B < 10:
print(A*B)
else:
print(-1)
| s179314665 | [
{
"input": "2 5\n",
"output": "10\n"
}
] |
Python | codenet | from operator import itemgetter
n, k = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n)]
info = sorted(info, key=itemgetter(1), reverse=True)
selected = info[0:k]
selected_only = []
selected_chohuku = []
unselected_only = []
memo = {}
for t, d in selected:
if t not in memo:
... | s804484425 | [
{
"input": "5 3\n1 9\n1 7\n2 6\n2 5\n3 1\n",
"output": "26\n"
}
] |
Python | codenet | H = int(input())
count = 0
def dfs(h):
if h == 1:
return 1
return dfs(h // 2) * 2 + 1
print(dfs(H))
| s661542483 | [
{
"input": "2\n",
"output": "3\n"
}
] |
Python | codenet | A, B = map(int, input().split())
S = list(input())
if S[A] == '-' and S.count('-') == 1:
print("Yes")
else:
print("No")
| s013976107 | [
{
"input": "3 4\n269-6650\n",
"output": "Yes\n"
}
] |
Python | codenet | n, k = map(int, input().split())
if k % 2 == 1:
print((n//k)**3)
else:
print((n//k)**3+((n+k//2)//k)**3)
| s398580870 | [
{
"input": "3 2\n",
"output": "9\n"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.