Dataset Viewer
source
stringclasses 4
values | task_type
stringclasses 1
value | in_source_id
stringlengths 0
125
| problem_statement
stringlengths 235
1.63k
| gold_standard_solution
stringlengths 0
11.2k
| problem_id
stringlengths 7
10
| metadata
dict | verification_info
dict |
---|---|---|---|---|---|---|---|
apps
|
verifiable_code
|
2496
|
Solve the following coding problem using the programming language python:
We have N integers. The i-th number is A_i.
\{A_i\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N.
\{A_i\} is said to be setwise coprime when \{A_i\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1.
Determine if \{A_i\} is pairwise coprime, setwise coprime, or neither.
Here, GCD(\ldots) denotes greatest common divisor.
-----Constraints-----
- 2 \leq N \leq 10^6
- 1 \leq A_i\leq 10^6
-----Input-----
Input is given from Standard Input in the following format:
N
A_1 \ldots A_N
-----Output-----
If \{A_i\} is pairwise coprime, print pairwise coprime; if \{A_i\} is setwise coprime, print setwise coprime; if neither, print not coprime.
-----Sample Input-----
3
3 4 5
-----Sample Output-----
pairwise coprime
GCD(3,4)=GCD(3,5)=GCD(4,5)=1, so they are pairwise coprime.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
from math import gcd
N = int(input())
num_lis = list(map(int, input().split()))
c = True
def osa_k(max_num):
lis = [i for i in range(max_num+1)]
p = 2
while p**2 <= max_num:
if lis[p] == p:
for q in range(2*p, max_num+1, p):
if lis[q] == q:
lis[q] = p
p += 1
return lis
hoge = 0
for i in num_lis:
hoge = gcd(hoge, i)
if hoge > 1:
print("not coprime")
return
d_lis = osa_k(10**6+10)
tmp = set()
for i in num_lis:
num = i
new_tmp = set()
while num > 1:
d = d_lis[num]
new_tmp.add(d)
num //= d
for j in new_tmp:
if j in tmp:
c = False
break
else:
tmp.add(j)
else:
continue
break
if c:
print("pairwise coprime")
else:
print("setwise coprime")
```
|
vfc_19717
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc177/tasks/abc177_e",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n3 4 5\n",
"output": "pairwise coprime\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n6 10 15\n",
"output": "setwise coprime\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n6 10 16\n",
"output": "not coprime\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
1181
|
Solve the following coding problem using the programming language python:
Chef has a natural number N. Cheffina challenges chef to check whether the given number is divisible by the sum of its digits or not. If the given number is divisible then print "Yes" else "No".
-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow.
- Each test case contains a single line of input, $N$.
-----Output:-----
For each test case, output in a single line answer.
-----Constraints-----
- $1 \leq T \leq 10^6$
- $1 \leq N \leq 10^6$
-----Sample Input:-----
2
16
27
-----Sample Output:-----
No
Yes
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
import sys,io,os,math
from math import ceil,log,gcd,inf
from itertools import permutations
mod=1000000007
mod1=998244353
def printlist(n):
sys.stdout.write(" ".join(map(str,n)) + "\n")
printf=lambda n:sys.stdout.write(str(n)+"\n")
def printns(n):
sys.stdout.write(str(n))
def intinp():
return int(sys.stdin.readline())
def strinp():
return sys.stdin.readline()
def arrinp():
return list(map(int,sys.stdin.readline().strip().split()))
def mulinp():
return list(map(int,sys.stdin.readline().strip().split()))
def flush():
return sys.stdout.flush()
def power_two(x):
return (1<<x)
def lcm(a,b):
return a*b//gcd(a,b)
def solve():
n=intinp()
ans=str(n)
count=0
for i in ans:
count+=int(i)
if(n%count==0):
print('Yes')
return 0
print('No')
def main():
tc=intinp()
while(tc):
solve()
tc-=1
main()
```
|
vfc_3566
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PEND2020/problems/ANITGUY9",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n16\n27\n",
"output": "No\nYes\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
1898
|
Solve the following coding problem using the programming language python:
Dr. Bruce Banner hates his enemies (like others don't). As we all know, he can barely talk when he turns into the incredible Hulk. That's why he asked you to help him to express his feelings.
Hulk likes the Inception so much, and like that his feelings are complicated. They have n layers. The first layer is hate, second one is love, third one is hate and so on...
For example if n = 1, then his feeling is "I hate it" or if n = 2 it's "I hate that I love it", and if n = 3 it's "I hate that I love that I hate it" and so on.
Please help Dr. Banner.
-----Input-----
The only line of the input contains a single integer n (1 ≤ n ≤ 100) — the number of layers of love and hate.
-----Output-----
Print Dr.Banner's feeling in one line.
-----Examples-----
Input
1
Output
I hate it
Input
2
Output
I hate that I love it
Input
3
Output
I hate that I love that I hate it
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
n = int(input())
for i in range(1,n):
if i%2 == 1:
print('I hate that',end=' ')
else:
print('I love that',end=' ')
if n%2 == 1:
print('I hate it',end=' ')
else:
print('I love it',end=' ')
```
|
vfc_17346
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/705/A",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n",
"output": "I hate it\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "I hate that I love it\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n",
"output": "I hate that I love that I hate it\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n",
"output": "I hate that I love that I hate that I love it\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n",
"output": "I hate that I love that I hate that I love that I hate it\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n",
"output": "I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love it\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "18\n",
"output": "I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love it\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "19\n",
"output": "I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate it\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "33\n",
"output": "I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate it\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "34\n",
"output": "I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love that I hate that I love it\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
1578
|
Solve the following coding problem using the programming language python:
For an integer N, we will choose a permutation \{P_1, P_2, ..., P_N\} of \{1, 2, ..., N\}.
Then, for each i=1,2,...,N, let M_i be the remainder when i is divided by P_i.
Find the maximum possible value of M_1 + M_2 + \cdots + M_N.
-----Constraints-----
- N is an integer satisfying 1 \leq N \leq 10^9.
-----Input-----
Input is given from Standard Input in the following format:
N
-----Output-----
Print the maximum possible value of M_1 + M_2 + \cdots + M_N.
-----Sample Input-----
2
-----Sample Output-----
1
When the permutation \{P_1, P_2\} = \{2, 1\} is chosen, M_1 + M_2 = 1 + 0 = 1.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
n=int(input())
print(n*(n+1)//2-n)
```
|
vfc_16066
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc139/tasks/abc139_d",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "13\n",
"output": "78\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000000000\n",
"output": "499999999500000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999999\n",
"output": "499999998500000001\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999998\n",
"output": "499999997500000003\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "569\n",
"output": "161596\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "902\n",
"output": "406351\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "55\n",
"output": "1485\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "234679769\n",
"output": "27537296871606796\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "160767\n",
"output": "12922933761\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "106\n",
"output": "5565\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
372
|
Solve the following coding problem using the programming language python:
You are given two circles. Find the area of their intersection.
-----Input-----
The first line contains three integers x_1, y_1, r_1 ( - 10^9 ≤ x_1, y_1 ≤ 10^9, 1 ≤ r_1 ≤ 10^9) — the position of the center and the radius of the first circle.
The second line contains three integers x_2, y_2, r_2 ( - 10^9 ≤ x_2, y_2 ≤ 10^9, 1 ≤ r_2 ≤ 10^9) — the position of the center and the radius of the second circle.
-----Output-----
Print the area of the intersection of the circles. The answer will be considered correct if the absolute or relative error doesn't exceed 10^{ - 6}.
-----Examples-----
Input
0 0 4
6 0 4
Output
7.25298806364175601379
Input
0 0 5
11 0 5
Output
0.00000000000000000000
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
#!/usr/bin/env python3
# 600D_circles.py - Codeforces.com/problemset/problem/600/D by Sergey 2015
import unittest
import sys
import math
import decimal
###############################################################################
# Circles Class (Main Program)
###############################################################################
def sin(x):
decimal.getcontext().prec += 2
i, lasts, s, fact, num, sign = 1, 0, x, 1, x, 1
while s != lasts:
lasts = s
i += 2
fact *= i * (i-1)
num *= x * x
sign *= -1
s += num / fact * sign
decimal.getcontext().prec -= 2
return +s
def cos(x):
decimal.getcontext().prec += 2
i, lasts, s, fact, num, sign = 0, 0, 1, 1, 1, 1
while s != lasts:
lasts = s
i += 2
fact *= i * (i-1)
num *= x * x
sign *= -1
s += num / fact * sign
decimal.getcontext().prec -= 2
return +s
def pi():
decimal.getcontext().prec += 2
three = decimal.Decimal(3)
lasts, t, s, n, na, d, da = 0, three, 3, 1, 0, 0, 24
while s != lasts:
lasts = s
n, na = n+na, na+8
d, da = d+da, da+32
t = (t * n) / d
s += t
decimal.getcontext().prec -= 2
return +s
def asin(x):
decimal.getcontext().prec += 2
b, e = -pi()/2, pi()/2
while True:
mid = (b + e) / 2
if e == mid or b == mid:
break
if sin(mid) <= x:
b = mid
else:
e = mid
decimal.getcontext().prec -= 2
return +b
def acos(x):
return pi() / 2 - asin(x)
class Circles:
""" Circles representation """
def __init__(self, test_inputs=None):
""" Default constructor """
it = iter(test_inputs.split("\n")) if test_inputs else None
def uinput():
return next(it) if it else sys.stdin.readline().rstrip()
# Reading single elements
[self.xa, self.ya, self.ra] = list(map(decimal.Decimal, uinput().split()))
[self.xb, self.yb, self.rb] = list(map(decimal.Decimal, uinput().split()))
decimal.getcontext().prec = 40
self.l = ((self.xb - self.xa)**2 + (self.yb - self.ya)**2).sqrt()
self.p = (self.ra + self.rb + self.l)/2
if self.l >= self.p:
self.sa = 0
self.sb = 0
elif self.ra >= self.p:
self.sa = 0
self.sb = self.rb**2 * decimal.Decimal.from_float(math.pi)
elif self.rb >= self.p:
self.sa = self.ra**2 * decimal.Decimal.from_float(math.pi)
self.sb = 0
else:
self.aa = 2 * acos(
(self.ra**2 - self.rb**2 + self.l**2) /
(2 * self.ra * self.l))
self.ab = 2 * acos(
(self.rb**2 - self.ra**2 + self.l**2) /
(2 * self.rb * self.l))
self.sa = self.ra**2 * (self.aa - sin(self.aa)) / 2
self.sb = self.rb**2 * (self.ab - sin(self.ab)) / 2
def calculate(self):
""" Main calcualtion function of the class """
result = self.sa + self.sb
return str(result)
###############################################################################
# Unit Tests
###############################################################################
class unitTests(unittest.TestCase):
def test_single_test(self):
""" Circles class testing """
# Constructor test
test = "0 0 4\n6 0 4"
d = Circles(test)
self.assertEqual(d.l, 6)
# Sample test
self.assertEqual(Circles(test).calculate()[:8], "7.252988")
# Sample test
test = "0 0 5\n11 0 5"
self.assertEqual(Circles(test).calculate(), "0")
# Sample test
test = "44721 999999999 400000000\n0 0 600000000"
self.assertEqual(Circles(test).calculate()[:9], "0.0018834")
# My tests
test = ""
# self.assertEqual(Circles(test).calculate(), "0")
# Time limit test
# self.time_limit_test(5000)
def time_limit_test(self, nmax):
""" Timelimit testing """
import random
import timeit
# Random inputs
test = str(nmax) + " " + str(nmax) + "\n"
numnums = [str(i) + " " + str(i+1) for i in range(nmax)]
test += "\n".join(numnums) + "\n"
nums = [random.randint(1, 10000) for i in range(nmax)]
test += " ".join(map(str, nums)) + "\n"
# Run the test
start = timeit.default_timer()
d = Circles(test)
calc = timeit.default_timer()
d.calculate()
stop = timeit.default_timer()
print(("\nTimelimit Test: " +
"{0:.3f}s (init {1:.3f}s calc {2:.3f}s)".
format(stop-start, calc-start, stop-calc)))
def __starting_point():
# Avoiding recursion limitaions
sys.setrecursionlimit(100000)
if sys.argv[-1] == "-ut":
unittest.main(argv=[" "])
# Print the result string
sys.stdout.write(Circles().calculate())
__starting_point()
```
|
vfc_11242
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/600/D",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "0 0 4\n6 0 4\n",
"output": "7.25298806364175601379\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0 5\n11 0 5\n",
"output": "0.00000000000000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0 10\n9 0 1\n",
"output": "3.14159265358979311600\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0 2\n2 2 2\n",
"output": "2.28318530717958647659\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0 10\n5 0 5\n",
"output": "78.53981633974482789995\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-9 8 7\n-9 8 5\n",
"output": "78.53981633974482789995\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-60 -85 95\n-69 -94 95\n",
"output": "25936.37843115316246844770\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "159 111 998\n161 121 1023\n",
"output": "3129038.84934604830277748988\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6008 8591 6693\n5310 8351 7192\n",
"output": "138921450.46886559338599909097\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-13563 -6901 22958\n-19316 -16534 18514\n",
"output": "868466038.83295116270892322063\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-875463 79216 524620\n-891344 76571 536598\n",
"output": "862534134678.47474157810211181641\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-8907963 -8149654 8808560\n-8893489 -8125053 8830600\n",
"output": "243706233220003.66226196289062500000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-56452806 56199829 45467742\n-56397667 56292048 45489064\n",
"output": "6487743741270471.46582031250000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-11786939 388749051 844435993\n-11696460 388789113 844535886\n",
"output": "2240182216213578196.25000000000000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-944341103 -3062765 891990581\n-943884414 -3338765 891882754\n",
"output": "2498325849744150942.00000000000000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "808468733 166975547 650132512\n807140196 169714842 655993403\n",
"output": "1327864139649690571.00000000000000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-16 -107 146\n75 25 19\n",
"output": "75.73941676175987183783\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "468534418 -876402362 779510\n392125478 -856995174 1\n",
"output": "0.00000000000000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "368831644 125127030 959524552\n690900461 -368007601 1000000000\n",
"output": "1877639096067727828.75000000000000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "638572730 86093565 553198855\n-151099010 -5582761 1000000000\n",
"output": "648156847022339121.87500000000000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "567845488 379750385 112902105\n567845488 379750385 112902105\n",
"output": "40045521256826535.57031250000000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "817163584 -145230792 164258581\n826720200 -149804696 98\n",
"output": "30171.85584507637308604444\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-812130546 -209199732 799576707\n-728169661 -278950375 4385\n",
"output": "60407250.40157159973750822246\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-36140638 -933845433 250828868\n90789911 -245130908 328547\n",
"output": "0.00000000000000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "34537868 -531411810 591044372\n34536968 -531411968 58\n",
"output": "10568.31768667606404221715\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-410889750 -716765873 303980004\n-410889749 -716765874 7\n",
"output": "153.93804002589986268390\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-304 -310 476\n120 -294 1\n",
"output": "3.14159265358979311600\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-999999999 0 1000000000\n999999999 0 1000000000\n",
"output": "119256.95877838134765625000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-1000000000 0 1000000000\n999999999 0 1000000000\n",
"output": "42163.70213317871093750000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-99999999 0 100000000\n99999999 0 100000000\n",
"output": "37712.36160683631896972656\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-999999999 0 1000000000\n999999999 1 1000000000\n",
"output": "119256.95874786376953125000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-1000000000 0 999999999\n999999997 0 999999999\n",
"output": "42163.70211410522460937500\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 1000000000 1\n0 0 1000000000\n",
"output": "1.57079632649338855020\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10000000 0 10000001\n-10000000 0 10000000\n",
"output": "4216.37028734199702739716\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000000000 0 1000000000\n-999999999 1 1000000000\n",
"output": "42163.70212173461914062500\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "44721 999999999 400000000\n0 0 600000000\n",
"output": "0.00188343226909637451\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-1000000000 1 1000000000\n999999998 0 1000000000\n",
"output": "119256.95874786376953125000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0 500000000\n431276 999999907 500000000\n",
"output": "0.33492207527160644531\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000000000 0 1000000000\n-999999998 -87334 1000000000\n",
"output": "1199.53919601440429687500\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0 10\n0 0 25\n",
"output": "314.15926535897931159980\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0 1000000000\n707106781 707106781 1\n",
"output": "2.09224628662147114737\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 10 10\n100 20 10\n",
"output": "122.83696986087568455565\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000000000 0 1000000000\n-999999998 -88334 1000000000\n",
"output": "461.20431423187255859375\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0 999999999\n1000000000 0 2\n",
"output": "2.45673939563023624650\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-99999999 0 100000000\n99999999 1 100000000\n",
"output": "37712.36153602600097656250\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000000000 0 1000000000\n-999999999 60333 1000000000\n",
"output": "1138.08371162414550781250\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000000000 0 1000000000\n-999999999 58333 1000000000\n",
"output": "2432.73669052124023437500\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000000000 0 1000000000\n-999999998 -85334 1000000000\n",
"output": "3207.25725555419921875000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0 1000000000\n999999999 1 2\n",
"output": "10.10963121370591567653\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0 1000000000\n999999998 0 3\n",
"output": "25.17685179846658691770\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "141 9999 5000\n0 0 5000\n",
"output": "0.04272695172407026121\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "-1000000000 0 1000000000\n999999998 0 1000000000\n",
"output": "119256.95877838134765625000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0 10\n1 0 10\n",
"output": "294.16760182010623145277\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0 0 1000000000\n707106782 707106781 2\n",
"output": "4.52465731000908907454\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
719
|
Solve the following coding problem using the programming language python:
-----Problem-----
Suppose there is a circle. There are N Juice shops on that circle. Juice shops are numbered 0 to N-1 (both inclusive). You have two pieces of information corresponding to each of the juice shop:
(1) the amount of Juice that a particular Juice shop can provide and
(2) the distance from that juice shop to the next juice shop.
Initially, there is a man with a bottle of infinite capacity carrying no juice. He can start the tour at any of the juice shops. Calculate the first point from where the man will be able to complete the circle. Consider that the man will stop at every Juice Shop. The man will move one kilometer for each litre of the juice.
-----Input-----
-
The first line will contain the value of N.
-
The next N lines will contain a pair of integers each, i.e. the amount of juice that a juice shop can provide(in litres) and the distance between that juice shop and the next juice shop.
-----Output-----
An integer which will be the smallest index of the juice shop from which he can start the tour.
-----Constraints-----
-
1 ≤ N ≤ 105
-
1 ≤ amt of juice, distance ≤ 109
-----Sample Input-----
3
1 5
10 3
3 4
-----Sample Output-----
1
-----Explanation-----
He can start the tour from the SECOND Juice shop.
p { text-align:justify }
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
import re,sys
def isCirlePossible(juices,distances):
if juices == [] or distances == []:
return -1;
total_juice_consumed = 0
juice_consumed = 0
start=0
for i in range(0,len(juices)):
diff = juices[i] - distances[i]
if juice_consumed >= 0:
juice_consumed += diff
else:
juice_consumed = diff
start = i
total_juice_consumed += diff
return start
juices = []
distances = []
numLines = int(input())
for each in range(0,numLines):
line = input()
result = [int(x) for x in re.findall('\d+',line)]
if len(result) == 2:
juices.append(result[0])
distances.append(result[1])
print(isCirlePossible(juices,distances))
return
```
|
vfc_1718
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COMN2016/problems/SUMTOUR",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 5\n10 3\n3 4\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
545
|
Solve the following coding problem using the programming language python:
Marina loves strings of the same length and Vasya loves when there is a third string, different from them in exactly t characters. Help Vasya find at least one such string.
More formally, you are given two strings s_1, s_2 of length n and number t. Let's denote as f(a, b) the number of characters in which strings a and b are different. Then your task will be to find any string s_3 of length n, such that f(s_1, s_3) = f(s_2, s_3) = t. If there is no such string, print - 1.
-----Input-----
The first line contains two integers n and t (1 ≤ n ≤ 10^5, 0 ≤ t ≤ n).
The second line contains string s_1 of length n, consisting of lowercase English letters.
The third line contain string s_2 of length n, consisting of lowercase English letters.
-----Output-----
Print a string of length n, differing from string s_1 and from s_2 in exactly t characters. Your string should consist only from lowercase English letters. If such string doesn't exist, print -1.
-----Examples-----
Input
3 2
abc
xyc
Output
ayd
Input
1 0
c
b
Output
-1
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
def main():
import sys
n, t, s1, s2 = sys.stdin.read().split()
n, t = int(n), int(t)
result = [-1] * n
rest = n - t
for i in range(n):
if rest == 0: break
if s1[i] == s2[i]:
result[i] = s1[i]
rest -= 1
k = rest
for i in range(n):
if k == 0: break
if result[i] == -1:
result[i] = s1[i]
k -= 1
k = rest
for i in range(n):
if k == 0: break
if result[i] == -1:
result[i] = s2[i]
k -= 1
if k > 0:
print(-1)
return
for i in range(n):
if result[i] == -1:
for j in range(ord('a'), ord('a') + 4):
if chr(j) != s1[i] and chr(j) != s2[i]:
result[i] = chr(j)
break
sys.stdout.write(''.join(result))
main()
```
|
vfc_11934
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/584/C",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3 2\nabc\nxyc\n",
"output": "bac",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 0\nc\nb\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\na\na\n",
"output": "b",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1\naa\naa\n",
"output": "ab",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 1\nbcb\nbca\n",
"output": "bcc",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 3\nccbb\ncaab\n",
"output": "cbca",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 2\nacbc\nacba\n",
"output": "acab",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 1\nbcbc\nacab\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 2\nacbb\nbabc\n",
"output": "aaba",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 2\nabaac\nbbbaa\n",
"output": "abbab",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 2\nabbab\nacbab\n",
"output": "aabaa",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 3\nbcaaa\ncbacc\n",
"output": "bbabb",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 3\ncbacb\ncbacb\n",
"output": "cbbaa",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 1\ncbabb\nbabaa\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 0\na\na\n",
"output": "a",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\nbb\ncb\n",
"output": "aa",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1\ncc\nba\n",
"output": "ca",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 0\nbb\nab\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\naac\nabc\n",
"output": "bca",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\na\nc\n",
"output": "b",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 0\ncba\ncca\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1\niy\niy\n",
"output": "ia",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2\nfg\nfn\n",
"output": "aa",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 1\npd\nke\n",
"output": "pe",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 3\nyva\nyvq\n",
"output": "aab",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 2\npxn\ngxn\n",
"output": "axa",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 1\nlos\nlns\n",
"output": "las",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 2\nhbnx\nhwmm\n",
"output": "hbma",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 4\nqtto\nqtto\n",
"output": "aaaa",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 3\nchqt\nchet\n",
"output": "caaa",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 3\nwzcre\nwzcrp\n",
"output": "wzaaa",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 1\nicahj\nxdvch\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 1\npmesm\npzeaq\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 4\nycgdbph\nfdtapch\n",
"output": "yctaaah",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 6\nrnsssbuiaq\npfsbsbuoay\n",
"output": "aasasbuaba",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "20 5\ndsjceiztjkrqgpqpnakr\nyijdvcjtjnougpqprrkr\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 85\njknccpmanwhxqnxivdgguahjcuyhdrazmbfwoptatlgytakxsfvdzzcsglhmswfxafxyregdbeiwpawrjgwcqrkbhmrfcscgoszf\nhknccpmanwhxjnxivdggeahjcuyhdrazmbfwoqtatlgytdkxsfvdztcsglhmssfxsfxyrngdbeiwpawrjgwcqrkbhmrfcsckoskf\n",
"output": "aknccpmanwhxanxivaaaabaaaaaaaabaaaaaaaabaaaaabaaaaaaaaaaaaaaaaaabaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaa",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 0\nz\nz\n",
"output": "z",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\nz\ny\n",
"output": "a",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\nz\nz\n",
"output": "a",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 0\nz\ny\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 1\ngjsywvenzc\nfssywvenzc\n",
"output": "gssywvenzc",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "20 2\nywpcwcwgkhdeonzbeamf\ngdcmwcwgkhdeonzbeamf\n",
"output": "ywcmwcwgkhdeonzbeamf",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
758
|
Solve the following coding problem using the programming language python:
Everyone loves short problem statements.
Given a function $ f(x) $ find its minimum value over the range $ 0 < x < π/2$
$
f(x) = ( x^2 + b*x + c ) / sin( x )
$
-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow.
- Each test case contains a single line of input, two real numbers $b, c$.
-----Output:-----
For each test case, output the minimum value of $ f(x) $ over the given range. Absolute error of $10^{-6}$ is allowed.
-----Constraints-----
- $1 \leq T \leq 100000$
- $1 \leq b,c \leq 20$
-----Sample Input:-----
1
2 2
-----Sample Output:-----
5.8831725615
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
import sys
import math
input=sys.stdin.readline
def binary(l,r,co,b,c):
x=(l+r)/2
#print(x)
val1=(2*x+b)*math.sin(x)
val2=(x**2+b*x+c)*math.cos(x)
x=(l+r)/2
val=val1-val2
if(abs(val)<.0000001 or co==150):
return (l+r)/2
if(val<0):
return binary((l+r)/2,r,co+1,b,c)
else:
return binary(l,(l+r)/2,co+1,b,c)
t=int(input())
for _ in range(t):
b,c=list(map(float,input().split()))
x=binary(.0000000001,math.pi/2-.0000000001,0,b,c)
#print("t=",_)
val=(x*x+b*x+c)/math.sin(x)
print(val)
```
|
vfc_1874
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ICM2020/problems/ICM2003",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n2 2\n",
"output": "5.8831725615\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
4400
|
Solve the following coding problem using the programming language python:
We have weather records at AtCoder Town for some consecutive three days. A string of length 3, S, represents the records - if the i-th character is S, it means it was sunny on the i-th day; if that character is R, it means it was rainy on that day.
Find the maximum number of consecutive rainy days in this period.
-----Constraints-----
- |S| = 3
- Each character of S is S or R.
-----Input-----
Input is given from Standard Input in the following format:
S
-----Output-----
Print the maximum number of consecutive rainy days in the period.
-----Sample Input-----
RRS
-----Sample Output-----
2
We had rain on the 1-st and 2-nd days in the period. Here, the maximum number of consecutive rainy days is 2, so we should print 2.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
S = str(input())
if "RRR" in S:
print(3)
elif "RR" in S:
print(2)
elif "R" in S:
print(1)
else:
print(0)
```
|
vfc_26307
|
{
"difficulty": "introductory",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc175/tasks/abc175_a",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "RRS\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "SSS\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "RSR\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "SRS\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "SSR\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "RRR\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "RSS\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "SRR\n",
"output": "2\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
404
|
Solve the following coding problem using the programming language python:
Ivan has number $b$. He is sorting through the numbers $a$ from $1$ to $10^{18}$, and for every $a$ writes $\frac{[a, \,\, b]}{a}$ on blackboard. Here $[a, \,\, b]$ stands for least common multiple of $a$ and $b$. Ivan is very lazy, that's why this task bored him soon. But he is interested in how many different numbers he would write on the board if he would finish the task. Help him to find the quantity of different numbers he would write on the board.
-----Input-----
The only line contains one integer — $b$ $(1 \le b \le 10^{10})$.
-----Output-----
Print one number — answer for the problem.
-----Examples-----
Input
1
Output
1
Input
2
Output
2
-----Note-----
In the first example $[a, \,\, 1] = a$, therefore $\frac{[a, \,\, b]}{a}$ is always equal to $1$.
In the second example $[a, \,\, 2]$ can be equal to $a$ or $2 \cdot a$ depending on parity of $a$. $\frac{[a, \,\, b]}{a}$ can be equal to $1$ and $2$.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
#JMD
#Nagendra Jha-4096
import sys
import math
#import fractions
#import numpy
###File Operations###
fileoperation=0
if(fileoperation):
orig_stdout = sys.stdout
orig_stdin = sys.stdin
inputfile = open('W:/Competitive Programming/input.txt', 'r')
outputfile = open('W:/Competitive Programming/output.txt', 'w')
sys.stdin = inputfile
sys.stdout = outputfile
###Defines...###
mod=1000000007
###FUF's...###
def nospace(l):
ans=''.join(str(i) for i in l)
return ans
ans=[]
def printDivisors(n) :
# Note that this loop runs till square root
i = 1
while i <= math.sqrt(n):
if (n % i == 0) :
# If divisors are equal, print only one
if (n / i == i) :
ans.append(i)
else :
# Otherwise print both
ans.append(i)
ans.append(n//i)
i = i + 1
##### Main ####
t=1
for tt in range(t):
n=int(input())
printDivisors(n)
s=set(ans)
print(len(s))
#a=list(map(int,sys.stdin.readline().split(' ')))
#n,k,s= map(int, sys.stdin.readline().split(' '))
#####File Operations#####
if(fileoperation):
sys.stdout = orig_stdout
sys.stdin = orig_stdin
inputfile.close()
outputfile.close()
```
|
vfc_11370
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1068/B",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "16\n",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "433494437\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10000000000\n",
"output": "121",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "169\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "244078129\n",
"output": "9",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7169516929\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2147483647\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2971215073\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "14\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999393068\n",
"output": "24",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9749081567\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1024\n",
"output": "11",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "48932\n",
"output": "12",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "179\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "58697100\n",
"output": "324",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "603979776\n",
"output": "81",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1048576\n",
"output": "21",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "963837006\n",
"output": "32",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "196729490\n",
"output": "8",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5760838\n",
"output": "24",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6508183\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999152231\n",
"output": "16",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1073676287\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2162160\n",
"output": "320",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4324320\n",
"output": "384",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "13693680\n",
"output": "480",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "985944960\n",
"output": "1280",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "898781184\n",
"output": "364",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9133684560\n",
"output": "1920",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8872504640\n",
"output": "56",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9886593024\n",
"output": "728",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6983776800\n",
"output": "2304",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5587021440\n",
"output": "2048",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4655851200\n",
"output": "2016",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3491888400\n",
"output": "1920",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2793510720\n",
"output": "1792",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2327925600\n",
"output": "1728",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2205403200\n",
"output": "1680",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2095133040\n",
"output": "1600",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1396755360\n",
"output": "1536",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1102701600\n",
"output": "1440",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2000000014\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "51\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "45\n",
"output": "6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4000000028\n",
"output": "6",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
3861
|
Solve the following coding problem using the programming language python:
Given an array a_1, a_2, ..., a_{n} of n integers, find the largest number in the array that is not a perfect square.
A number x is said to be a perfect square if there exists an integer y such that x = y^2.
-----Input-----
The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of elements in the array.
The second line contains n integers a_1, a_2, ..., a_{n} ( - 10^6 ≤ a_{i} ≤ 10^6) — the elements of the array.
It is guaranteed that at least one element of the array is not a perfect square.
-----Output-----
Print the largest number in the array which is not a perfect square. It is guaranteed that an answer always exists.
-----Examples-----
Input
2
4 2
Output
2
Input
8
1 2 4 8 16 32 64 576
Output
32
-----Note-----
In the first sample case, 4 is a perfect square, so the largest number in the array that is not a perfect square is 2.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
a.reverse()
for i in a:
if i < 0:
print(i)
return
if int(i ** 0.5) ** 2 != i:
print(i)
return
```
|
vfc_24151
|
{
"difficulty": "competition",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/914/A",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n4 2\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n1 2 4 8 16 32 64 576\n",
"output": "32\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n-1 -4 -9\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n918375 169764 598796 76602 538757\n",
"output": "918375\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n804610 765625 2916 381050 93025\n",
"output": "804610\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n984065 842724 127449 525625 573049\n",
"output": "984065\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n226505 477482\n",
"output": "477482\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n370881 659345\n",
"output": "659345\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n4 5\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n3 4\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n999999 1000000\n",
"output": "999999\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n-1 -2 -3\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n-1000000 1000000\n",
"output": "-1000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n-1 0\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n2\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n-1\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "35\n-871271 -169147 -590893 -400197 -476793 0 -15745 -890852 -124052 -631140 -238569 -597194 -147909 -928925 -587628 -569656 -581425 -963116 -665954 -506797 -196044 -309770 -701921 -926257 -152426 -991371 -624235 -557143 -689886 -59804 -549134 -107407 -182016 -24153 -607462\n",
"output": "-15745\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "16\n-882343 -791322 0 -986738 -415891 -823354 -840236 -552554 -760908 -331993 -549078 -863759 -913261 -937429 -257875 -602322\n",
"output": "-257875\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "71\n908209 289 44521 240100 680625 274576 212521 91809 506944 499849 3844 15376 592900 58081 240100 984064 732736 257049 600625 180625 130321 580644 261121 75625 46225 853776 485809 700569 817216 268324 293764 528529 25921 399424 175561 99856 295936 20736 611524 13924 470596 574564 5329 15376 676 431649 145161 697225 41616 550564 514089 9409 227529 1681 839056 3721 552049 465124 38809 197136 659344 214369 998001 44944 3844 186624 362404 -766506 739600 10816 299209\n",
"output": "-766506\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "30\n192721 -950059 -734656 625 247009 -423468 318096 622521 678976 777924 1444 748303 27556 62001 795664 89401 221841 -483208 467856 477109 196 -461813 831744 772641 574564 -519370 861184 67600 -717966 -259259\n",
"output": "748303\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "35\n628849 962361 436921 944784 444889 29241 -514806 171396 685584 -823202 -929730 6982 198025 783225 552049 -957165 782287 -659167 -414846 695556 -336330 41616 963781 71289 119639 952576 -346713 178929 232324 121802 393266 841 649636 179555 998001\n",
"output": "963781\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "53\n280988 756430 -515570 -248578 170649 -21608 642677 216770 827291 589500 940901 216097 -118956 -919104 -319264 -761585 289479 499613 588276 883036 480518 -323196 -274570 -406556 -381484 -956025 702135 -445274 -783543 136593 153664 897473 352651 737974 -21123 -284944 501734 898033 604429 624138 40804 248782 -786059 -304592 -209210 -312904 419820 -328648 -47331 -919227 -280955 104827 877304\n",
"output": "940901\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "15\n256 -227055 427717 827239 462070 66049 987533 -175306 -552810 -867915 -408251 -693957 -972981 -245827 896904\n",
"output": "987533\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n-1 1 0\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n0 -5\n",
"output": "-5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n-1 -2 0\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n-5 0\n",
"output": "-5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n-439\n",
"output": "-439\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n-1000000\n",
"output": "-1000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n-917455\n",
"output": "-917455\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 1 -1\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n131073 1\n",
"output": "131073\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n99999 3\n",
"output": "99999\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n-524272 -1000000\n",
"output": "-524272\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n15 131073\n",
"output": "131073\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
1003
|
Solve the following coding problem using the programming language python:
Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. How many consecutive days pass until Vasya runs out of socks?
-----Input-----
The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space.
-----Output-----
Print a single integer — the answer to the problem.
-----Examples-----
Input
2 2
Output
3
Input
9 3
Output
13
-----Note-----
In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two.
In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
"""
Codeforces Contest 262 Div 2 Problem A
Author : chaotic_iak
Language: Python 3.3.4
"""
def main():
n,m = read()
i = 0
while n:
n -= 1
i += 1
if not i%m: n += 1
print(i)
################################### NON-SOLUTION STUFF BELOW
def read(mode=2):
# 0: String
# 1: List of strings
# 2: List of integers
inputs = input().strip()
if mode == 0: return inputs
if mode == 1: return inputs.split()
if mode == 2: return list(map(int, inputs.split()))
def write(s="\n"):
if s is None: s = ""
if isinstance(s, list): s = " ".join(map(str, s))
s = str(s)
print(s, end="")
write(main())
```
|
vfc_13766
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/460/A",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 2\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9 3\n",
"output": "13\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 2\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 3\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 99\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 4\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 2\n",
"output": "19\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 9\n",
"output": "11\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 100\n",
"output": "101\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 27\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "99 100\n",
"output": "99\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "99 2\n",
"output": "197\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 3\n",
"output": "149\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "98 3\n",
"output": "146\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 4\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 2\n",
"output": "199\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "62 4\n",
"output": "82\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "99 10\n",
"output": "109\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 5\n",
"output": "124\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "80 80\n",
"output": "81\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "95 16\n",
"output": "101\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "75 16\n",
"output": "79\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "99 74\n",
"output": "100\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "20 21\n",
"output": "20\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "52 96\n",
"output": "52\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "24 5\n",
"output": "29\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
4444
|
Solve the following coding problem using the programming language python:
Given are two strings S and T consisting of lowercase English letters. Concatenate T and S in this order, without space in between, and print the resulting string.
-----Constraints-----
- S and T are strings consisting of lowercase English letters.
- The lengths of S and T are between 1 and 100 (inclusive).
-----Input-----
Input is given from Standard Input in the following format:
S T
-----Output-----
Print the resulting string.
-----Sample Input-----
oder atc
-----Sample Output-----
atcoder
When S = oder and T = atc, concatenating T and S in this order results in atcoder.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
S,T = map(str,input().split())
print(T + S)
```
|
vfc_26483
|
{
"difficulty": "introductory",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc149/tasks/abc149_a",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "oder atc\n",
"output": "atcoder\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "humu humu\n",
"output": "humuhumu\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "c a\n",
"output": "ac\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "oekdkfjdjgjknbfkwnfnhaoekdkfjdjgjknbfkwnfnhahjekkengkfoekdkfjdjgjknbfkwnfnhaoekdkfjdjgjknbfkwnfnhahj yowkymbmhkkgjjeokdlakbndkkworqotkfnblgpnkkrogjrfnvmbjisnbkzvmbnrrrigeoibgpefjobvmovpqosqoqrgrkengrlk\n",
"output": "yowkymbmhkkgjjeokdlakbndkkworqotkfnblgpnkkrogjrfnvmbjisnbkzvmbnrrrigeoibgpefjobvmovpqosqoqrgrkengrlkoekdkfjdjgjknbfkwnfnhaoekdkfjdjgjknbfkwnfnhahjekkengkfoekdkfjdjgjknbfkwnfnhaoekdkfjdjgjknbfkwnfnhahj\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "dttd dttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttd\n",
"output": "dttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttddttd\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "mmkmkmkmkkkmkkkmmmkkkmkmkmmkkkmmkkkkmmmkkkmmkmmkmkmkmmkmkkmkmkmmmmkkkmkkkmmmkkkkkkmkmmmkmmmk zk\n",
"output": "zkmmkmkmkmkkkmkkkmmmkkkmkmkmmkkkmmkkkkmmmkkkmmkmmkmkmkmmkmkkmkmkmmmmkkkmkkkmmmkkkkkkmkmmmkmmmk\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
608
|
Solve the following coding problem using the programming language python:
Abhi Ram analyses london stock exchange and invests in a software company C-.gate . He wants to sell his shares after 5 weeks.
Given the investment m, increase or decrease of share prices of 5 weeks(+/- pi) , help him to calculate his net profit or loss percentage(n%) of his investment to establish his own company KMC.
-----Input:-----
- The first line contains an integer T which denotes the number of test cases.
- Each test case comprises of two lines: the first line contains the integer m which denotes the amount invested.
The second line consists of five space separated integers(p1, p2, p3, p4, p5) each preceeded by + (increase) or - (decrease) which give the percentage of change in share prices over 5 weeks.
.
-----Output:-----
The output contains a single number n which gives the percentage of profit or loss preceeded by + (profit) or - (loss).
-----Constraints:-----
- 1 ≤ T ≤ 100
- 1 ≤ m ≤ 105
- -100 ≤ pi ≤ 100
-----Example:-----
Input:
2
10000
+5 -3 -2 +10 +15
6256250
-24 +22 +4 -16 +20
Output:
+26.2634
-2.79977
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
for i in range(int(input())):
n = int(input())
P = list(map(float, input().split()))
pr = 1
for p in P:
a = 100+p
pr = (pr*a)/100
pr = (pr-1)*100
x = 6-len(str(int(abs(pr))))
if (x==1):
if (pr==0):
print(0)
elif (pr>0):
print("+"+str("%.1f" % round(pr,x)))
else:
print(str("%.1f" % round(pr,x)))
elif (x==2):
if (pr==0):
print(0)
elif (pr>0):
print("+"+str("%.2f" % round(pr,x)))
else:
print(str("%.2f" % round(pr,x)))
elif (x==3):
if (pr==0):
print(0)
elif (pr>0):
print("+"+str("%.3f" % round(pr,x)))
else:
print(str("%.3f" % round(pr,x)))
elif (x==4):
if (pr==0):
print(0)
elif (pr>0):
print("+"+str("%.4f" % round(pr,x)))
else:
print(str("%.4f" % round(pr,x)))
elif (x==5):
if (pr==0):
print(0)
elif (pr>0):
print("+"+str("%.5f" % round(pr,x)))
else:
print(str("%.5f" % round(pr,x)))
elif (x==6):
if (pr==0):
print(0)
elif (pr>0):
print("+"+str("%.6f" % round(pr,x)))
else:
print(str("%.6f" % round(pr,x)))
```
|
vfc_1274
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ITRA2016/problems/ITRA03",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n10000\n+5 -3 -2 +10 +15\n6256250\n-24 +22 +4 -16 +20\n",
"output": "+26.2634\n-2.79977\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
923
|
Solve the following coding problem using the programming language python:
Like all minions Dave also like to eat bananas. So as to his obsession, he is eating banana, but this time in different way. There are N bananas in dish. Dave wants to eat all of them. He starts eating at speed 1 banana/second. He can increase or decrease speed of eating by one only. The condition is that he must end eating at speed 1 banana/second. So, your task is to find minimum time required to finish all bananas in a dish.
-----Input-----
First line contain number of test cases T. Next T lines contain one integer N. Where N is number of bananas in a dish.
-----Output-----
For each test case print minimum time require to eat all N bananas.
-----Constraints-----
- 1 ≤ T ≤ 100
- 1 ≤ N ≤ 105
-----Example-----
Input:
2
2
4
Output:
2
3
-----Explanation-----
Example case 1.Dave will start to eat with rate of 1 banana/second. Then only one banana will remain. He will eat that banana in 1 second. Thus, Total time is 2 seconds.
Example case 2.Dave starts with rate of 1 banana/second, and then increase it to 2 bananas/second and again decrease it to 1 banana/second. So total time is 3 seconds.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
t=int(input())
while(t):
k=1
j=0
n=int(input())
while(n>0):
if(n<=k):
j+=1
n=0
elif n>2*k:
j+=2
n=n-2*k
k+=1
else:
j+=2
n=0
print(j)
t-=1
```
|
vfc_2534
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/CFSN2015/problems/PUNBAN",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n4\n",
"output": "2\n3\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
4577
|
Solve the following coding problem using the programming language python:
You are given three integers A, B and C.
Determine whether C is not less than A and not greater than B.
-----Constraints-----
- -100≤A,B,C≤100
- A, B and C are all integers.
-----Input-----
Input is given from Standard Input in the following format:
A B C
-----Output-----
If the condition is satisfied, print Yes; otherwise, print No.
-----Sample Input-----
1 3 2
-----Sample Output-----
Yes
C=2 is not less than A=1 and not greater than B=3, and thus the output should be Yes.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
# 3 つの整数 A , B , C が与えられます。
# 整数 C が A 以上 かつ B 以下であるかを判定してください。
A,B,C = map(int,input().split())
if C >= A and C <= B:
print('Yes')
else:
print('No')
```
|
vfc_26997
|
{
"difficulty": "introductory",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc061/tasks/abc061_a",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 3 2\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 5 4\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 2 2\n",
"output": "Yes\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
4724
|
Solve the following coding problem using the programming language python:
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:
- Let the current rating of the user be a.
- Suppose that the performance of the user in the contest is b.
- Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest.
Find the performance required to achieve it.
-----Constraints-----
- 0 \leq R, G \leq 4500
- All input values are integers.
-----Input-----
Input is given from Standard Input in the following format:
R
G
-----Output-----
Print the performance required to achieve the objective.
-----Sample Input-----
2002
2017
-----Sample Output-----
2032
Takahashi's current rating is 2002.
If his performance in the contest is 2032, his rating will be the average of 2002 and 2032, which is equal to the desired rating, 2017.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
# 現在と目標のレーティングを取得
R = int(input())
G = int(input())
# 目標のレーティングになるためのパフォーマンスの数値を計算
Target = (G * 2) - R
# 計算結果を出力
print(Target)
```
|
vfc_27531
|
{
"difficulty": "introductory",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc076/tasks/abc076_a",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2002\n2017\n",
"output": "2032\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4500\n0\n",
"output": "-4500\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
3879
|
Solve the following coding problem using the programming language python:
Limak is an old brown bear. He often plays poker with his friends. Today they went to a casino. There are n players (including Limak himself) and right now all of them have bids on the table. i-th of them has bid with size a_{i} dollars.
Each player can double his bid any number of times and triple his bid any number of times. The casino has a great jackpot for making all bids equal. Is it possible that Limak and his friends will win a jackpot?
-----Input-----
First line of input contains an integer n (2 ≤ n ≤ 10^5), the number of players.
The second line contains n integer numbers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9) — the bids of players.
-----Output-----
Print "Yes" (without the quotes) if players can make their bids become equal, or "No" otherwise.
-----Examples-----
Input
4
75 150 75 50
Output
Yes
Input
3
100 150 250
Output
No
-----Note-----
In the first sample test first and third players should double their bids twice, second player should double his bid once and fourth player should both double and triple his bid.
It can be shown that in the second sample test there is no way to make all bids equal.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
def i23(x):
while x%2==0:
x//=2
while x%3==0:
x//=3
return x == 1
import fractions
from fractions import gcd
x = int(input())
y = list(map(int, input().split(' ')))
gcdx = y[0]
for i in y:
gcdx = gcd(i, gcdx)
for i in y:
if not i23(i/gcdx):
print("No")
quit()
print("Yes")
```
|
vfc_24223
|
{
"difficulty": "competition",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/573/A",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n75 150 75 50\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n100 150 250\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n34 34 68 34 34 68 34\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n72 96 12 18 81 20 6 2 54 1\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "20\n958692492 954966768 77387000 724664764 101294996 614007760 202904092 555293973 707655552 108023967 73123445 612562357 552908390 914853758 915004122 466129205 122853497 814592742 373389439 818473058\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 1\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n72 72\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n49 42\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1000000000 1000000000 1000000000\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n162000 96000 648000 1000 864000 432000\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n600000 100000 100000 100000 900000 600000 900000 600000\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "12\n2048 1024 6144 1024 3072 3072 6144 1024 4096 2048 6144 3072\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "20\n246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246 246\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "50\n840868705 387420489 387420489 795385082 634350497 206851546 536870912 536870912 414927754 387420489 387420489 536870912 387420489 149011306 373106005 536870912 700746206 387420489 777952883 847215247 176645254 576664386 387420489 230876513 536870912 536870912 536870912 387420489 387420489 536870912 460495524 528643722 387420489 536870912 470369206 899619085 387420489 631148352 387420489 387420489 536870912 414666674 521349938 776784669 387420489 102428009 536870912 387420489 536870912 718311009\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n5 6\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n536870912 387420489 257407169\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n2 2 5 2\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n33554432 59049\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n536870912 387420489 387420489\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 5\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "18\n2 3 5 7 11 13 17 19 23 29 31 37 43 47 53 59 67 71\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 30\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n335544320 71744535 71744535\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1000000000 999999999 999999998 999999997 999999996\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n25 5\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n75 150 75 5\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n536870912 387420489 362797056\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n536870912 387420489 89\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n547 2606459 222763549 143466789\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n129140163 33554432 1\n",
"output": "Yes\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n244140625 244140625 244140625 244140625 244140625 244140625 244140625 244140625 536870912 387420489\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n5 5 1\n",
"output": "No\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n3 7 29 36760123 823996703\n",
"output": "No\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
621
|
Solve the following coding problem using the programming language python:
Given n words w[1..n], which originate from the same stem (e.g. grace, graceful, disgraceful, gracefully), we are interested in the original stem. To simplify the problem, we define the stem as the longest consecutive substring that occurs in all the n words. If there are ties, we will choose the smallest one in the alphabetical (lexicographic) order.
-----Input-----
The first line contains an integer T denoting the total number of test cases.
In each test cases, the first line contains an integer n denoting the number of words. In the second line, n words w[1..n] consisting of lower case characters are given as a single space-spearated list.
-----Output-----
For each test case, output the stem in a new line.
-----Constraints-----
- 1 <= T <= 10
- 1 <= n <= 10
- 1 <= |w[i]| <= 20
-----Example-----
Input:
1
4
grace graceful disgraceful gracefully
Output:
grace
-----Explanation-----
The stem is grace.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
t = eval(input())
for _ in range(t):
n = eval(input())
a = input().strip().split()
cb, cs = 0, ""
for i in range(len(a[0])):
for j in range(i+1,len(a[0])+1):
al = True
s = a[0][i:j]
for k in a[1:]:
if s not in k:
al = False
break
if al:
if j-i>=cb:
cb = max(cb, j-i)
if len(cs) < cb:
cs = a[0][i:j]
elif len(cs) == cb:
cs = min(cs,a[0][i:j])
print(cs)
```
|
vfc_1326
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COOK63/problems/STEM",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n4\ngrace graceful disgraceful gracefully\n",
"output": "grace\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
961
|
Solve the following coding problem using the programming language python:
The chef has one array of N natural numbers (might be in sorted order). Cheffina challenges chef to find the total number of inversions in the array.
-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow.
- Each test case contains two lines of input, $N$.
- N space-separated natural numbers.
-----Output:-----
For each test case, output in a single line answer as the total number of inversions.
-----Constraints-----
- $1 \leq T \leq 10$
- $1 \leq N \leq 10^5$
- $1 \leq arr[i] \leq 10^5$
-----Sample Input:-----
1
5
5 4 1 3 2
-----Sample Output:-----
8
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
# cook your dish here
def mergeSort(arr, n):
# A temp_arr is created to store
# sorted array in merge function
temp_arr = [0]*n
return _mergeSort(arr, temp_arr, 0, n-1)
# This Function will use MergeSort to count inversions
def _mergeSort(arr, temp_arr, left, right):
# A variable inv_count is used to store
# inversion counts in each recursive call
inv_count = 0
# We will make a recursive call if and only if
# we have more than one elements
if left < right:
# mid is calculated to divide the array into two subarrays
# Floor division is must in case of python
mid = (left + right)//2
# It will calculate inversion
# counts in the left subarray
inv_count += _mergeSort(arr, temp_arr,
left, mid)
# It will calculate inversion
# counts in right subarray
inv_count += _mergeSort(arr, temp_arr,
mid + 1, right)
# It will merge two subarrays in
# a sorted subarray
inv_count += merge(arr, temp_arr, left, mid, right)
return inv_count
# This function will merge two subarrays
# in a single sorted subarray
def merge(arr, temp_arr, left, mid, right):
i = left # Starting index of left subarray
j = mid + 1 # Starting index of right subarray
k = left # Starting index of to be sorted subarray
inv_count = 0
# Conditions are checked to make sure that
# i and j don't exceed their
# subarray limits.
while i <= mid and j <= right:
# There will be no inversion if arr[i] <= arr[j]
if arr[i] <= arr[j]:
temp_arr[k] = arr[i]
k += 1
i += 1
else:
# Inversion will occur.
temp_arr[k] = arr[j]
inv_count += (mid-i + 1)
k += 1
j += 1
# Copy the remaining elements of left
# subarray into temporary array
while i <= mid:
temp_arr[k] = arr[i]
k += 1
i += 1
# Copy the remaining elements of right
# subarray into temporary array
while j <= right:
temp_arr[k] = arr[j]
k += 1
j += 1
# Copy the sorted subarray into Original array
for loop_var in range(left, right + 1):
arr[loop_var] = temp_arr[loop_var]
return inv_count
for _ in range(int(input())):
n = int(input())
a = list(map(int,input().split()))
print(mergeSort(a, n) )
```
|
vfc_2686
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PSTR2020/problems/ANITGUY3",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n5\n5 4 1 3 2\n",
"output": "8\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
4328
|
Solve the following coding problem using the programming language python:
You are given positive integers A and B.
If A is a divisor of B, print A + B; otherwise, print B - A.
-----Constraints-----
- All values in input are integers.
- 1 \leq A \leq B \leq 20
-----Input-----
Input is given from Standard Input in the following format:
A B
-----Output-----
If A is a divisor of B, print A + B; otherwise, print B - A.
-----Sample Input-----
4 12
-----Sample Output-----
16
As 4 is a divisor of 12, 4 + 12 = 16 should be printed.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
a,b = map(int, input().split())
print(a+b if b%a==0 else b-a)
```
|
vfc_26019
|
{
"difficulty": "introductory",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc118/tasks/abc118_a",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 12\n",
"output": "16\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8 20\n",
"output": "12\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 6\n",
"output": "8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 12\n",
"output": "18\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 12\n",
"output": "13\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 9\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 19\n",
"output": "20\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 20\n",
"output": "21\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "20 20\n",
"output": "40\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "19 20\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
1356
|
Solve the following coding problem using the programming language python:
Chef is good at making pancakes. Generally he gets requests to serve N pancakes at once.
He serves them in the form of a stack.
A pancake can be treated as a circular disk with some radius.
Chef needs to take care that when he places a pancake on the top of the stack the radius of the pancake should not exceed the radius of the largest pancake in the stack by more than 1.
Additionally all radii should be positive integers, and the bottom most pancake should have its radius as 1.
Chef wants you to find out in how many ways can he create a stack containing N pancakes.
Input
First line of the input contains T (T <= 1000) denoting the number of test cases.
T lines follow each containing a single integer N (1 <= N <= 1000) denoting the size of the required stack.
Output
For each case the output should be a single integer representing the number of ways a stack of size N can be created. As the answer can be large print it modulo 1000000007.
Example
Input
2
1
2
Output
1
2
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
t=[[1]]
def bell_numbers(start, stop):
## Swap start and stop if start > stop
if stop < start: start, stop = stop, start
if start < 1: start = 1
if stop < 1: stop = 1
c = 1 ## Bell numbers count
while c <= stop:
if c >= start:
yield t[-1][0] ## Yield the Bell number of the previous row
row = [t[-1][-1]] ## Initialize a new row
for b in t[-1]:
row.append((row[-1] + b)%1000000007)
c += 1 ## We have found another Bell number
t.append(row) ## Append the row to the triangle
ar=[0]*1001
i=0
for b in bell_numbers(1,1001):
ar[i]=b
i+=1
T=eval(input())
while T:
N=eval(input())
print(ar[N])
T-=1
```
|
vfc_4266
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/APRIL12/problems/PANSTACK",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n1\n2\n",
"output": "1\n2\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
1007
|
Solve the following coding problem using the programming language python:
Given an array A1,A2...AN, you have to print the size of the largest contiguous subarray such that
GCD of all integers in that subarray is 1.
Formally,
For a subarray Ai,Ai+1...Aj where 1 ≤ i < j ≤ N to be valid: GCD(Ai,Ai+1...Aj) should be 1. You have to print the size of the largest valid subarray.
If no valid subarray exists, output -1.
Note:A single element is not considered as a subarray according to the definition of this problem.
-----Input-----
First line contains T, the number of testcases. Each testcase consists of N in one line followed by N integers in the next line.
-----Output-----
For each testcase, print the required answer in one line.
-----Constraints-----
- 1 ≤ T ≤ 10
- 2 ≤ N ≤ 105
- 1 ≤ Ai ≤ 105
-----Example-----
Input:
2
2
7 2
3
2 2 4
Output:
2
-1
-----Explanation-----
Example case 1.GCD(2,7)=1. So the subarray [A1,A2] is valid.
Example case 2.No subarray satisfies.
Note: Use scanf/print instead of cin/cout. Large input files.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
import math
for _ in range(int(input())):
n=int(input())
ar=[int(x) for x in input().split()]
# dp=[1]*n
f=0
g=ar[0]
for i in range(1,n):
g=math.gcd(g,ar[i])
if g==1:
f=1
print(n)
break
if f==0:
print(-1)
```
|
vfc_2870
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/problems/SUBGCD",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n7 2\n3\n2 2 4\n",
"output": "2\n-1\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
4583
|
Solve the following coding problem using the programming language python:
Sitting in a station waiting room, Joisino is gazing at her train ticket.
The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).
In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds.
The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.
-----Constraints-----
- 0≤A,B,C,D≤9
- All input values are integers.
- It is guaranteed that there is a solution.
-----Input-----
Input is given from Standard Input in the following format:
ABCD
-----Output-----
Print the formula you made, including the part =7.
Use the signs + and -.
Do not print a space between a digit and a sign.
-----Sample Input-----
1222
-----Sample Output-----
1+2+2+2=7
This is the only valid solution.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
S = input()
a = int(S[0])
b = int(S[1])
c = int(S[2])
d = int(S[3])
if a+b+c+d==7:
print('{}+{}+{}+{}=7'.format(a,b,c,d))
elif a+b+c-d==7:
print('{}+{}+{}-{}=7'.format(a,b,c,d))
elif a+b-c+d==7:
print('{}+{}-{}+{}=7'.format(a,b,c,d))
elif a+b-c-d==7:
print('{}+{}-{}-{}=7'.format(a,b,c,d))
elif a-b+c+d==7:
print('{}-{}+{}+{}=7'.format(a,b,c,d))
elif a-b+c-d==7:
print('{}-{}+{}-{}=7'.format(a,b,c,d))
elif a-b-c-d==7:
print('{}-{}-{}-{}=7'.format(a,b,c,d))
elif a-b-c+d==7:
print('{}-{}-{}+{}=7'.format(a,b,c,d))
```
|
vfc_27021
|
{
"difficulty": "introductory",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc079/tasks/abc079_c",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1222\n",
"output": "1+2+2+2=7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0290\n",
"output": "0-2+9+0=7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3242\n",
"output": "3+2+4-2=7\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
2648
|
Solve the following coding problem using the programming language python:
Snuke has decided to play a game using cards.
He has a deck consisting of N cards. On the i-th card from the top, an integer A_i is written.
He will perform the operation described below zero or more times, so that the values written on the remaining cards will be pairwise distinct. Find the maximum possible number of remaining cards. Here, N is odd, which guarantees that at least one card can be kept.
Operation: Take out three arbitrary cards from the deck. Among those three cards, eat two: one with the largest value, and another with the smallest value. Then, return the remaining one card to the deck.
-----Constraints-----
- 3 ≦ N ≦ 10^{5}
- N is odd.
- 1 ≦ A_i ≦ 10^{5}
- A_i is an integer.
-----Input-----
The input is given from Standard Input in the following format:
N
A_1 A_2 A_3 ... A_{N}
-----Output-----
Print the answer.
-----Sample Input-----
5
1 2 1 3 7
-----Sample Output-----
3
One optimal solution is to perform the operation once, taking out two cards with 1 and one card with 2. One card with 1 and another with 2 will be eaten, and the remaining card with 1 will be returned to deck. Then, the values written on the remaining cards in the deck will be pairwise distinct: 1, 3 and 7.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
n=int(input())
a=list(map(int,input().split()))
num=[0]*100001
for i in a:
num[i]+=1
x=0
for i in num:
if i<=0:
continue
elif i%2==0:
n-=i
x+=1
else:
n-=i-1
if x%2:
x-=1
print(n+x)
```
|
vfc_20286
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc053/tasks/arc068_b",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n1 2 1 3 7\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "15\n1 3 5 2 1 3 2 8 8 6 2 6 11 1 1\n",
"output": "7\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
796
|
Solve the following coding problem using the programming language python:
You have $n \times n$ square grid and an integer $k$. Put an integer in each cell while satisfying the conditions below. All numbers in the grid should be between $1$ and $k$ inclusive. Minimum number of the $i$-th row is $1$ ($1 \le i \le n$). Minimum number of the $j$-th column is $1$ ($1 \le j \le n$).
Find the number of ways to put integers in the grid. Since the answer can be very large, find the answer modulo $(10^{9} + 7)$. [Image] These are the examples of valid and invalid grid when $n=k=2$.
-----Input-----
The only line contains two integers $n$ and $k$ ($1 \le n \le 250$, $1 \le k \le 10^{9}$).
-----Output-----
Print the answer modulo $(10^{9} + 7)$.
-----Examples-----
Input
2 2
Output
7
Input
123 456789
Output
689974806
-----Note-----
In the first example, following $7$ cases are possible. [Image]
In the second example, make sure you print the answer modulo $(10^{9} + 7)$.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
fa = [1]
m = 251
P = 10**9+7
for i in range(1, m+1): fa.append(fa[-1] * i % P)
fainv = [pow(fa[m], P-2, P)]
for i in range(1, m+1)[::-1]: fainv.append(fainv[-1] * i % P)
fainv = fainv[::-1]
def C(a, b): return fa[a] * fainv[a-b] * fainv[b] % P
N, K = list(map(int, input().split()))
poK = [1]
for i in range(251): poK.append(poK[-1] * K % P)
poK1 = [1]
for i in range(251): poK1.append(poK1[-1] * (K-1) % P)
dpC = [[C(i, j) for j in range(i+1)] for i in range(N+1)]
dpCpoK = [[C(i, j) * poK[j] % P for j in range(i+1)] for i in range(N+1)]
DP = [[0] * (N+1) for _ in range(N+1)]
DP[0][0] = 1
for i in range(1, N+1):
for j in range(1, N+1):
for k in range(j+1):
if k < j:
DP[i][j] = (DP[i][j] + DP[i-1][k] * dpCpoK[j][k]) % P
else:
DP[i][j] = (DP[i][j] + DP[i-1][k] * dpC[j][k] % P * (poK[k] - poK1[k])) % P
for j in range(1, N+1):
DP[i][j] = DP[i][j] * poK1[N-j] % P
print(DP[N][N])
```
|
vfc_12938
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1228/E",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2 2\n",
"output": "7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "123 456789\n",
"output": "689974806\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "250 1000000000\n",
"output": "770503193\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "250 1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 3\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 497285769\n",
"output": "790515254\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 212096267\n",
"output": "501206544\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 221874066\n",
"output": "274467242\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "244 315404017\n",
"output": "868949606\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "218 325181815\n",
"output": "230476135\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "246 629926913\n",
"output": "283598434\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "216 639704712\n",
"output": "319243107\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "244 22597665\n",
"output": "56808536\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "218 737408162\n",
"output": "720936813\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "242 747185961\n",
"output": "365665959\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "220 51931060\n",
"output": "944377763\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "244 61708858\n",
"output": "84446310\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "216 104981514\n",
"output": "943178465\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "208 1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "236 1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "242 106758452\n",
"output": "437620405\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "216 411503551\n",
"output": "618370501\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "244 126314049\n",
"output": "662993833\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "214 431059147\n",
"output": "37643610\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "242 440836946\n",
"output": "687163955\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "220 528762598\n",
"output": "944995733\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "244 833507696\n",
"output": "89218992\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "218 548318195\n",
"output": "721573920\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "242 558095993\n",
"output": "300047623\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "224 26911790\n",
"output": "554883010\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "206 1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "234 1\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
709
|
Solve the following coding problem using the programming language python:
You are a lover of bacteria. You want to raise some bacteria in a box.
Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. You hope to see exactly x bacteria in the box at some moment.
What is the minimum number of bacteria you need to put into the box across those days?
-----Input-----
The only line containing one integer x (1 ≤ x ≤ 10^9).
-----Output-----
The only line containing one integer: the answer.
-----Examples-----
Input
5
Output
2
Input
8
Output
1
-----Note-----
For the first sample, we can add one bacterium in the box in the first day morning and at the third morning there will be 4 bacteria in the box. Now we put one more resulting 5 in the box. We added 2 bacteria in the process so the answer is 2.
For the second sample, we can put one in the first morning and in the 4-th morning there will be 8 in the box. So the answer is 1.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
n = int(input())
ans = 1
while n != 1:
if n % 2 == 1:
ans += 1
n -= 1
else:
n //= 2
print(ans)
```
|
vfc_12590
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/579/A",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "536870911\n",
"output": "29\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "343000816\n",
"output": "14\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "559980448\n",
"output": "12\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "697681824\n",
"output": "14\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "41313494\n",
"output": "14\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "673935585\n",
"output": "13\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "117422204\n",
"output": "19\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "954746654\n",
"output": "15\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "536838144\n",
"output": "14\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000000000\n",
"output": "13\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999999\n",
"output": "21\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999998\n",
"output": "20\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999997\n",
"output": "20\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999996\n",
"output": "19\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999995\n",
"output": "20\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999994\n",
"output": "19\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999993\n",
"output": "19\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999992\n",
"output": "18\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999991\n",
"output": "20\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999990\n",
"output": "19\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "536870910\n",
"output": "28\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "536870912\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "536870913\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "536870914\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "22\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "14\n",
"output": "3\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
1320
|
Solve the following coding problem using the programming language python:
Chef has many friends, but his best friend is Hemant. They both love to watch anime.
In fact, their weekends are meant for that only. Also, Hemant is highly into games, of which Chef is unaware. Hemant once gave a game to Chef and asked him to determine the winner of the game. Since the Chef is busy, and you are also his friend, he asked you to help him.
The Game is played between two players, $A$ and $B$. There are $N$ marbles. $A$ and $B$ plays alternately, and $A$ goes first. Each player can choose $1$ marble or $even$ number of marbles in his turn. The player who is not able to choose any marbles loses the game.
-----Input:-----
- The first line consists of a single integer $T$ denoting the number of test cases.
- The Second line contains an integers $N$, denoting the number of marbles.
-----Output:-----
For each test case, print the name of the player who loses the game.
-----Constraints-----
- $1 \leq T \leq 10^5$
- $1 \leq N \leq 10^9$
-----Sample Input:-----
3
1
3
7
-----Sample Output:-----
B
A
B
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
for _ in range(int(input())):
n=int(input())
if(n<3):
print("B")
else:
if(n==3):
print("A")
elif(n%2):
print("B")
else:
print("B")
```
|
vfc_4122
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/ENCO2020/problems/ENC2020A",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1\n3\n7\n",
"output": "B\nA\nB\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
4177
|
Solve the following coding problem using the programming language python:
Given is a string S. Replace every character in S with x and print the result.
-----Constraints-----
- S is a string consisting of lowercase English letters.
- The length of S is between 1 and 100 (inclusive).
-----Input-----
Input is given from Standard Input in the following format:
S
-----Output-----
Replace every character in S with x and print the result.
-----Sample Input-----
sardine
-----Sample Output-----
xxxxxxx
Replacing every character in S with x results in xxxxxxx.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
S = input()
l = len(S)
print("x" * l)
```
|
vfc_25415
|
{
"difficulty": "introductory",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc154/tasks/abc154_b",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "sardine\n",
"output": "xxxxxxx\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "xxxx\n",
"output": "xxxx\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "gone\n",
"output": "xxxx\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "x\n",
"output": "x\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "a\n",
"output": "x\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "z\n",
"output": "x\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "abcdefghijklmnopqrstuvwxyz\n",
"output": "xxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "i\n",
"output": "x\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "lhepcdattcowmqbch\n",
"output": "xxxxxxxxxxxxxxxxx\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "bnwvfdrsujwoqplribdfbepsclazsnjiljxwckzgagygeepfaplivyrxvcnrplqiahoccdnqxlwnvmauceaquerkantpjcno\n",
"output": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "kvtvweokpottycaeeyfthzfvsgckwjmgqadfekjfitnsieylhumxjjezqvidkxjpywokrnzxxwraamuimhmrjwqeyvjvyjjzsxxf\n",
"output": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "qvssniprlkdntynymqcjoxpttvplhodrlkpqwtnkdfkgmokodexzspghvslwqrerrsiasriutrrmcscjbfbsnamhrjhhjtydfjsj\n",
"output": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "xfvvxmxxdxxhtcpjx\n",
"output": "xxxxxxxxxxxxxxxxx\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "rixulhoxxmutffxmsiaktsxxlfeuxxfdxodjoxrxnhhmxdnugxxvxqcwcpaqemmglpvodohnxkxofqxttikhltngxaxtvgxca\n",
"output": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "fjxsknxixxknrgbiwwmktdhxgxupxmxxailocxnmfrjjzxcptwxxqcfakxuxpjxusxxnjxgxqxaxbsuiomkxabxqytvxooxyajxx\n",
"output": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"output": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"output": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
3869
|
Solve the following coding problem using the programming language python:
You are given two rectangles on a plane. The centers of both rectangles are located in the origin of coordinates (meaning the center of the rectangle's symmetry). The first rectangle's sides are parallel to the coordinate axes: the length of the side that is parallel to the Ox axis, equals w, the length of the side that is parallel to the Oy axis, equals h. The second rectangle can be obtained by rotating the first rectangle relative to the origin of coordinates by angle α. [Image]
Your task is to find the area of the region which belongs to both given rectangles. This region is shaded in the picture.
-----Input-----
The first line contains three integers w, h, α (1 ≤ w, h ≤ 10^6; 0 ≤ α ≤ 180). Angle α is given in degrees.
-----Output-----
In a single line print a real number — the area of the region which belongs to both given rectangles.
The answer will be considered correct if its relative or absolute error doesn't exceed 10^{ - 6}.
-----Examples-----
Input
1 1 45
Output
0.828427125
Input
6 4 30
Output
19.668384925
-----Note-----
The second sample has been drawn on the picture above.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
from math import sin, cos, tan, atan, pi
def main():
w, h, a = map(int, input().split())
a = min(a, 180 - a) * pi / 180
if h > w:
h, w = w, h
if h * (1 + cos(a)) < w * sin(a):
res = h * h / sin(a)
else:
res = h * w - ((w - h * tan(a / 2)) ** 2 * tan(a) + (h - w * tan(a / 2)) ** 2 * tan(a)) / 4
print('{:.9f}'.format(res))
def __starting_point():
main()
__starting_point()
```
|
vfc_24183
|
{
"difficulty": "competition",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/280/A",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1 1 45\n",
"output": "0.828427125\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6 4 30\n",
"output": "19.668384925\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 100 0\n",
"output": "10000.000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 100 30\n",
"output": "8452.994616207\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "303304 904227 3\n",
"output": "262706079399.496890000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "217708 823289 162\n",
"output": "128074702873.298310000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "872657 1807 27\n",
"output": "7192328.918497734\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "787062 371814 73\n",
"output": "144562337198.439790000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "925659 774524 134\n",
"output": "587010971679.470460000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "852428 738707 49\n",
"output": "517909750353.868960000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "991024 917226 95\n",
"output": "843996470740.052250000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "938133 287232 156\n",
"output": "182978083107.739690000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "76730 689942 119\n",
"output": "6731488956.790288000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "507487 609004 180\n",
"output": "309061612948.000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "646084 979010 45\n",
"output": "491534756284.375060000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "560489 381720 91\n",
"output": "145732354143.406560000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "991245 527535 69\n",
"output": "298092342476.756290000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "129842 930245 115\n",
"output": "18601787610.281502000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "44247 849307 176\n",
"output": "25011463322.593517000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "89781 351632 35\n",
"output": "14053275989.299274000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "36890 754342 82\n",
"output": "1374246169.251312700\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "175486 640701 60\n",
"output": "35559391285.091263000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "606243 819219 106\n",
"output": "382341849885.364870000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "520648 189225 167\n",
"output": "83168927181.776108000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "659245 591935 32\n",
"output": "327438873731.782960000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "90002 994645 176\n",
"output": "72280791543.454956000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "228598 881004 56\n",
"output": "63033386343.331917000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "143003 283714 102\n",
"output": "20906720001.826447000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "314304 429528 163\n",
"output": "119035307824.125410000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "135646 480909 0\n",
"output": "65233382214.000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "34989 23482 180\n",
"output": "821611698.000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 10 80\n",
"output": "101.542661189\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2 100 90\n",
"output": "4.000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "23141 2132 180\n",
"output": "49336612.000000000\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
3736
|
Solve the following coding problem using the programming language python:
Recently, a start up by two students of a state university of city F gained incredible popularity. Now it's time to start a new company. But what do we call it?
The market analysts came up with a very smart plan: the name of the company should be identical to its reflection in a mirror! In other words, if we write out the name of the company on a piece of paper in a line (horizontally, from left to right) with large English letters, then put this piece of paper in front of the mirror, then the reflection of the name in the mirror should perfectly match the line written on the piece of paper.
There are many suggestions for the company name, so coming up to the mirror with a piece of paper for each name wouldn't be sensible. The founders of the company decided to automatize this process. They asked you to write a program that can, given a word, determine whether the word is a 'mirror' word or not.
-----Input-----
The first line contains a non-empty name that needs to be checked. The name contains at most 10^5 large English letters. The name will be written with the next sans serif font: $\text{ABCDEFGHI JKLMNOPQRSTUVWXYZ}$
-----Output-----
Print 'YES' (without the quotes), if the given name matches its mirror reflection. Otherwise, print 'NO' (without the quotes).
-----Examples-----
Input
AHA
Output
YES
Input
Z
Output
NO
Input
XO
Output
NO
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
s=input()
M={"A","H","I","M","O","T","U","V","W","X","Y"}
ans="YES"
n=len(s)
for i in range(len(s)//2):
x=s[i]
y=s[n-i-1]
if(x!=y or x not in M):
ans="NO"
break
if(n%2==1):
if(s[n//2] not in M):
ans="NO"
print(ans)
```
|
vfc_23652
|
{
"difficulty": "competition",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/420/A",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "AHA\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "Z\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "XO\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AAA\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AHHA\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "BAB\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "OMMMAAMMMO\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "YYHUIUGYI\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "TT\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "UUU\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "WYYW\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "MITIM\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "VO\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "WWS\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "VIYMAXXAVM\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "OVWIHIWVYXMVAAAATOXWOIUUHYXHIHHVUIOOXWHOXTUUMUUVHVWWYUTIAUAITAOMHXWMTTOIVMIVOTHOVOIOHYHAOXWAUVWAVIVM\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "CC\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "QOQ\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AEEA\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "OQQQO\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "HNCMEEMCNH\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "QDPINBMCRFWXPDBFGOZVVOCEMJRUCTOADEWEGTVBVBFWWRPGYEEYGPRWWFBVBVTGEWEDAOTCURJMECOVVZOGFBDPXWFRCMBNIPDQ\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "A\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "B\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "C\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "D\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "E\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "F\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "G\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "H\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "I\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "J\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "K\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "L\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "M\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "O\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "P\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "Q\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "R\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "S\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "T\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "U\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "V\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "W\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "X\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "Y\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "JL\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AAAKTAAA\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AKA\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AAJAA\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "ABA\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AAAAAABAAAAAA\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "ZZ\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "ADA\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "N\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "P\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "LAL\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AABAA\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AZA\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "V\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "SSS\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "NNN\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "S\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "I\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "SS\n",
"output": "NO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "E\n",
"output": "NO\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
271
|
Solve the following coding problem using the programming language python:
Vasya has a non-negative integer n. He wants to round it to nearest integer, which ends up with 0. If n already ends up with 0, Vasya considers it already rounded.
For example, if n = 4722 answer is 4720. If n = 5 Vasya can round it to 0 or to 10. Both ways are correct.
For given n find out to which integer will Vasya round it.
-----Input-----
The first line contains single integer n (0 ≤ n ≤ 10^9) — number that Vasya has.
-----Output-----
Print result of rounding n. Pay attention that in some cases answer isn't unique. In that case print any correct answer.
-----Examples-----
Input
5
Output
0
Input
113
Output
110
Input
1000000000
Output
1000000000
Input
5432359
Output
5432360
-----Note-----
In the first example n = 5. Nearest integers, that ends up with zero are 0 and 10. Any of these answers is correct, so you can print 0 or 10.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
import math
n = int(input())
print(10 * round(n / 10))
```
|
vfc_10838
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/898/A",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "113\n",
"output": "110\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000000000\n",
"output": "1000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5432359\n",
"output": "5432360\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999994\n",
"output": "999999990\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "0\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "19\n",
"output": "20\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n",
"output": "100\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "997\n",
"output": "1000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9994\n",
"output": "9990\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10002\n",
"output": "10000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100000\n",
"output": "100000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "99999\n",
"output": "100000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999999\n",
"output": "1000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999998\n",
"output": "1000000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999995\n",
"output": "999999990\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999990\n",
"output": "999999990\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000000\n",
"output": "1000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000010\n",
"output": "1000010\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10000010\n",
"output": "10000010\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100000011\n",
"output": "100000010\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "400000003\n",
"output": "400000000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "234234\n",
"output": "234230\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "675621\n",
"output": "675620\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "43532\n",
"output": "43530\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4576453\n",
"output": "4576450\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "65754674\n",
"output": "65754670\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3245526\n",
"output": "3245530\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "123445\n",
"output": "123440\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "234217\n",
"output": "234220\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "23451218\n",
"output": "23451220\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1231239\n",
"output": "1231240\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1923140\n",
"output": "1923140\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "307910310\n",
"output": "307910310\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "780961030\n",
"output": "780961030\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "103509421\n",
"output": "103509420\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "576560141\n",
"output": "576560140\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "48851642\n",
"output": "48851640\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "226935072\n",
"output": "226935070\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "844450763\n",
"output": "844450760\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "22534183\n",
"output": "22534180\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "640049874\n",
"output": "640049870\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "818133304\n",
"output": "818133300\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "730616285\n",
"output": "730616280\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "613732415\n",
"output": "613732410\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "380991216\n",
"output": "380991220\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "559074636\n",
"output": "559074640\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "176590327\n",
"output": "176590330\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "354673757\n",
"output": "354673760\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "267156738\n",
"output": "267156740\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "150272868\n",
"output": "150272870\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "62755859\n",
"output": "62755860\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "945871979\n",
"output": "945871980\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "46\n",
"output": "50\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999\n",
"output": "1000\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1397\n",
"output": "1400\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
316
|
Solve the following coding problem using the programming language python:
While playing with geometric figures Alex has accidentally invented a concept of a $n$-th order rhombus in a cell grid.
A $1$-st order rhombus is just a square $1 \times 1$ (i.e just a cell).
A $n$-th order rhombus for all $n \geq 2$ one obtains from a $n-1$-th order rhombus adding all cells which have a common side with it to it (look at the picture to understand it better).
[Image]
Alex asks you to compute the number of cells in a $n$-th order rhombus.
-----Input-----
The first and only input line contains integer $n$ ($1 \leq n \leq 100$) — order of a rhombus whose numbers of cells should be computed.
-----Output-----
Print exactly one integer — the number of cells in a $n$-th order rhombus.
-----Examples-----
Input
1
Output
1
Input
2
Output
5
Input
3
Output
13
-----Note-----
Images of rhombus corresponding to the examples are given in the statement.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
n = int(input())
a = n * (n + 1) // 2
print(4 * a - 4 * n + 1)
```
|
vfc_11018
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/1180/A",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n",
"output": "13",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "11\n",
"output": "221",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "21\n",
"output": "841",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "31\n",
"output": "1861",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "41\n",
"output": "3281",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "51\n",
"output": "5101",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n",
"output": "19801",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "34\n",
"output": "2245",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "25\n",
"output": "1201",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "37\n",
"output": "2665",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "39\n",
"output": "2965",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "78\n",
"output": "12013",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "87\n",
"output": "14965",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "26\n",
"output": "1301",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n",
"output": "113",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "94\n",
"output": "17485",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "68\n",
"output": "9113",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "90\n",
"output": "16021",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "72\n",
"output": "10225",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "99\n",
"output": "19405",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n",
"output": "25",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "22\n",
"output": "925",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "35\n",
"output": "2381",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "75\n",
"output": "11101",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "70\n",
"output": "9661",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "52\n",
"output": "5305",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "74\n",
"output": "10805",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "42\n",
"output": "3445",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "40\n",
"output": "3121",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "15\n",
"output": "421",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "49\n",
"output": "4705",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "89\n",
"output": "15665",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n",
"output": "85",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "38\n",
"output": "2813",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "19\n",
"output": "685",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "56\n",
"output": "6161",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "76\n",
"output": "11401",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "86\n",
"output": "14621",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "47\n",
"output": "4325",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "62\n",
"output": "7565",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9\n",
"output": "145",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "57\n",
"output": "6385",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "48\n",
"output": "4513",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n",
"output": "41",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "80\n",
"output": "12641",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "77\n",
"output": "11705",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "45\n",
"output": "3961",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "13\n",
"output": "313",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "79\n",
"output": "12325",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "85\n",
"output": "14281",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "98\n",
"output": "19013",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "95\n",
"output": "17861",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "36\n",
"output": "2521",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "64\n",
"output": "8065",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "16\n",
"output": "481",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "50\n",
"output": "4901",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "53\n",
"output": "5513",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "24\n",
"output": "1105",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
2013
|
Solve the following coding problem using the programming language python:
You are given a non-empty string s consisting of lowercase English letters. You have to pick exactly one non-empty substring of s and shift all its letters 'z' $\rightarrow$ 'y' $\rightarrow$ 'x' $\rightarrow \ldots \rightarrow$ 'b' $\rightarrow$ 'a' $\rightarrow$ 'z'. In other words, each character is replaced with the previous character of English alphabet and 'a' is replaced with 'z'.
What is the lexicographically minimum string that can be obtained from s by performing this shift exactly once?
-----Input-----
The only line of the input contains the string s (1 ≤ |s| ≤ 100 000) consisting of lowercase English letters.
-----Output-----
Print the lexicographically minimum string that can be obtained from s by shifting letters of exactly one non-empty substring.
-----Examples-----
Input
codeforces
Output
bncdenqbdr
Input
abacaba
Output
aaacaba
-----Note-----
String s is lexicographically smaller than some other string t of the same length if there exists some 1 ≤ i ≤ |s|, such that s_1 = t_1, s_2 = t_2, ..., s_{i} - 1 = t_{i} - 1, and s_{i} < t_{i}.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
#!/usr/bin/env python3
import re
try:
while True:
s = input()
m = re.search(r"[^a]", s)
if m is None:
print(s[:-1], end="z\n")
else:
j = s.find('a', m.end())
if j == -1:
j = len(s)
print(end=s[:m.start()])
for i in range(m.start(), j):
print(end=chr((ord(s[i]) - 98) % 26 + 97))
print(s[j:])
except EOFError:
pass
```
|
vfc_5598
|
{
"difficulty": "competition",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/708/A",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "codeforces\n",
"output": "bncdenqbdr\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "abacaba\n",
"output": "aaacaba\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "babbbabaababbaa\n",
"output": "aabbbabaababbaa\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "bcbacaabcababaccccaaaabacbbcbbaa\n",
"output": "abaacaabcababaccccaaaabacbbcbbaa\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "cabaccaacccabaacdbdcbcdbccbccbabbdadbdcdcdbdbcdcdbdadcbcda\n",
"output": "babaccaacccabaacdbdcbcdbccbccbabbdadbdcdcdbdbcdcdbdadcbcda\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "a\n",
"output": "z\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "eeeedddccbceaabdaecaebaeaecccbdeeeaadcecdbeacecdcdcceabaadbcbbadcdaeddbcccaaeebccecaeeeaebcaaccbdaccbdcadadaaeacbbdcbaeeaecedeeeedadec\n",
"output": "ddddcccbbabdaabdaecaebaeaecccbdeeeaadcecdbeacecdcdcceabaadbcbbadcdaeddbcccaaeebccecaeeeaebcaaccbdaccbdcadadaaeacbbdcbaeeaecedeeeedadec\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "fddfbabadaadaddfbfecadfaefaefefabcccdbbeeabcbbddefbafdcafdfcbdffeeaffcaebbbedabddeaecdddffcbeaafffcddccccfffdbcddcfccefafdbeaacbdeeebdeaaacdfdecadfeafaeaefbfdfffeeaefebdceebcebbfeaccfafdccdcecedeedadcadbfefccfdedfaaefabbaeebdebeecaadbebcfeafbfeeefcfaecadfe\n",
"output": "ecceaabadaadaddfbfecadfaefaefefabcccdbbeeabcbbddefbafdcafdfcbdffeeaffcaebbbedabddeaecdddffcbeaafffcddccccfffdbcddcfccefafdbeaacbdeeebdeaaacdfdecadfeafaeaefbfdfffeeaefebdceebcebbfeaccfafdccdcecedeedadcadbfefccfdedfaaefabbaeebdebeecaadbebcfeafbfeeefcfaecadfe\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aaaaaaaaaa\n",
"output": "aaaaaaaaaz\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "abbabaaaaa\n",
"output": "aaaabaaaaa\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "bbbbbbbbbbbb\n",
"output": "aaaaaaaaaaaa\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aabaaaaaaaaaaaa\n",
"output": "aaaaaaaaaaaaaaa\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aaaaaaaaaaaaaaaaaaaa\n",
"output": "aaaaaaaaaaaaaaaaaaaz\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "abaabaaaaaabbaaaaaaabaaaaaaaaabaaaabaaaaaaabaaaaaaaaaabaaaaaaaaaaaaaaabaaaabbaaaaabaaaaaaaabaaaaaaaa\n",
"output": "aaaabaaaaaabbaaaaaaabaaaaaaaaabaaaabaaaaaaabaaaaaaaaaabaaaaaaaaaaaaaaabaaaabbaaaaabaaaaaaaabaaaaaaaa\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "abbbbbbbabbbbbbbbbbbbbbbbbbbbbbbabbabbbbbabbbbbbbbbbbabbbbbbbbabbabbbbbbbbbbbbbbabbabbbaababbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbbbbbbbbabbbbabbbbbbbbbbbbbbbabbbbbbbbbaababbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbbbbbbbbabbbabbbbbaabbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbaabbbbbbbbbbbbababbabbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbabbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbabbbbbbbabbbbbbb\n",
"output": "aaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbabbabbbbbabbbbbbbbbbbabbbbbbbbabbabbbbbbbbbbbbbbabbabbbaababbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbbbbbbbbabbbbabbbbbbbbbbbbbbbabbbbbbbbbaababbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbabbabbbbbbbbbbbbbbbbabbbabbbbbaabbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbbaabbbbbbbbbbbbababbabbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbbbbbabbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbabbbbbbbabbbbbbb\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aaaaa\n",
"output": "aaaaz\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aaa\n",
"output": "aaz\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "aa\n",
"output": "az\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
1224
|
Solve the following coding problem using the programming language python:
Given is an integer N.
Determine whether there is a pair of positive integers (A, B) such that 3^A + 5^B = N, and find one such pair if it exists.
-----Constraints-----
- 1 \leq N \leq 10^{18}
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the following format:
N
-----Output-----
If there is no pair (A, B) that satisfies the condition, print -1.
If there is such a pair, print A and B of one such pair with space in between. If there are multiple such pairs, any of them will be accepted.
-----Sample Input-----
106
-----Sample Output-----
4 2
We have 3^4 + 5^2 = 81 + 25 = 106, so (A, B) = (4, 2) satisfies the condition.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
n=int(input())
for i in range(1,100):
if 3**i > n:
print(-1)
break
x=n-3**i
for j in range(1,100):
if x==5**j:
print(i,j)
return
```
|
vfc_14650
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/arc106/tasks/arc106_a",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "106\n",
"output": "4 2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1024\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10460353208\n",
"output": "21 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "748307129767950488\n",
"output": "37 25\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "450283905890997368\n",
"output": "37 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "298023223876953128\n",
"output": "1 25\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n",
"output": "1 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "258489532\n",
"output": "15 12\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2541865828954\n",
"output": "26 4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "19073486347808\n",
"output": "9 19\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "150094635296999246\n",
"output": "36 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "61457664964242466\n",
"output": "32 24\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "11920928955078134\n",
"output": "2 23\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "126\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1000000000000000000\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "999999999999999999\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "748307129767950592\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "59604644775390625\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "617673396283948\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "359414837200037396\n",
"output": "-1\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
625
|
Solve the following coding problem using the programming language python:
Shaun is very much interested in Subarrays. Shaun wants to count the number of subarrays in his chosen array with sum being a multiple of $10^9$. Since, Shaun is interested in huge numbers.He chose his array such that it contains only $10^8$ and $9*10^8$ as its elements.
Help shaun to count the number of required subarrays.
-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow.
- First line of each testcase contains one integer $N$,size of array $A$.
- Second line of each testcase contains $N$ space separated array elements
-----Output:-----
For each testcase, output in a single line number of subarrays with sum being multiple of $10^9$.
-----Constraints-----
- $1 \leq T \leq 10$
- $1 \leq N \leq 10^5$
- $A[i]$=$10^8$ , $9*10^8$
-----Sample Input:-----
2
3
100000000 900000000 100000000
1
900000000
-----Sample Output:-----
2
0
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
def subCount(arr, n, k):
mod = []
for i in range(k + 1):
mod.append(0)
cumSum = 0
for i in range(n):
cumSum = cumSum + arr[i]
# as the sum can be negative,
# taking modulo twice
mod[((cumSum % k) + k) % k] = mod[((cumSum % k) + k) % k] + 1
result = 0 # Initialize result
for i in range(k):
if (mod[i] > 1):
result = result + (mod[i] * (mod[i] - 1)) // 2
result = result + mod[0]
return result
t=int(input())
while t:
t=t-1
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
if a[i]==100000000:
a[i]=1
elif a[i]==900000000:
a[i]=9
s=10
print(subCount(a,n,s))
```
|
vfc_1342
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/COCA2020/problems/COCA2001",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n3\n100000000 900000000 100000000\n1\n900000000\n",
"output": "2\n0\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
224
|
Solve the following coding problem using the programming language python:
One day, the Grasshopper was jumping on the lawn and found a piece of paper with a string. Grasshopper became interested what is the minimum jump ability he should have in order to be able to reach the far end of the string, jumping only on vowels of the English alphabet. Jump ability is the maximum possible length of his jump.
Formally, consider that at the begginning the Grasshopper is located directly in front of the leftmost character of the string. His goal is to reach the position right after the rightmost character of the string. In one jump the Grasshopper could jump to the right any distance from 1 to the value of his jump ability. [Image] The picture corresponds to the first example.
The following letters are vowels: 'A', 'E', 'I', 'O', 'U' and 'Y'.
-----Input-----
The first line contains non-empty string consisting of capital English letters. It is guaranteed that the length of the string does not exceed 100.
-----Output-----
Print single integer a — the minimum jump ability of the Grasshopper (in the number of symbols) that is needed to overcome the given string, jumping only on vowels.
-----Examples-----
Input
ABABBBACFEYUKOTT
Output
4
Input
AAA
Output
1
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
# You lost the game.
s = str(input())
n = len(s)
d = -1
r = 0
V = "AEIOUY"
for i in range(n):
if V.count(s[i]):
r = max(r,i-d)
d = i
print(max(r, n-d))
```
|
vfc_10650
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/733/A",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "ABABBBACFEYUKOTT\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AAA\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "A\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "B\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AEYUIOAEIYAEOUIYOEIUYEAOIUEOEAYOEIUYAEOUIYEOIKLMJNHGTRWSDZXCVBNMHGFDSXVWRTPPPLKMNBXIUOIUOIUOIUOOIU\n",
"output": "39",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AEYUIOAEIYAEOUIYOEIUYEAOIUEOEAYOEIUYAEOUIYEOIAEYUIOAEIYAEOUIYOEIUYEAOIUEOEAYOEIUYAEOUIYEOI\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "KMLPTGFHNBVCDRFGHNMBVXWSQFDCVBNHTJKLPMNFVCKMLPTGFHNBVCDRFGHNMBVXWSQFDCVBNHTJKLPMNFVC\n",
"output": "85",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "QWERTYUIOPASDFGHJKLZXCVBNMQWERTYUIOPASDFGHJKLZXCVBNMQWERTYUIOPASDFGHJKLZXCVBNMQWERTYUIOPASDFGHJKLZ\n",
"output": "18",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "PKLKBWTXVJ\n",
"output": "11",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "CFHFPTGMOKXVLJJZJDQW\n",
"output": "12",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "TXULTFSBUBFLRNQORMMULWNVLPWTYJXZBPBGAWNX\n",
"output": "9",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "DAIUSEAUEUYUWEIOOEIOUYVYYOPEEWEBZOOOAOXUOIEUKYYOJOYAUYUUIYUXOUJLGIYEIIYUOCUAACRY\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "VRPHBNWNWVWBWMFJJDCTJQJDJBKSJRZLVQRVVFLTZFSGCGDXCWQVWWWMFVCQHPKXXVRKTGWGPSMQTPKNDQJHNSKLXPCXDJDQDZZD\n",
"output": "101",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "SGDDFCDRDWGPNNFBBZZJSPXFYMZKPRXTCHVJSJJBWZXXQMDZBNKDHRGSRLGLRKPMWXNSXJPNJLDPXBSRCQMHJKPZNTPNTZXNPCJC\n",
"output": "76",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "NVTQVNLGWFDBCBKSDLTBGWBMNQZWZQJWNGVCTCQBGWNTYJRDBPZJHXCXFMIXNRGSTXHQPCHNFQPCMDZWJGLJZWMRRFCVLBKDTDSC\n",
"output": "45",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "SREZXQFVPQCLRCQGMKXCBRWKYZKWKRMZGXPMKWNMFZTRDPHJFCSXVPPXWKZMZTBFXGNLPLHZIPLFXNRRQFDTLFPKBGCXKTMCFKKT\n",
"output": "48",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "ICKJKMVPDNZPLKDSLTPZNRLSQSGHQJQQPJJSNHNWVDLJRLZEJSXZDPHYXGGWXHLCTVQSKWNWGTLJMOZVJNZPVXGVPJKHFVZTGCCX\n",
"output": "47",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "XXFPZDRPXLNHGDVCBDKJMKLGUQZXLLWYLOKFZVGXVNPJWZZZNRMQBRJCZTSDRHSNCVDMHKVXCXPCRBWSJCJWDRDPVZZLCZRTDRYA\n",
"output": "65",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "HDDRZDKCHHHEDKHZMXQSNQGSGNNSCCPVJFGXGNCEKJMRKSGKAPQWPCWXXWHLSMRGSJWEHWQCSJJSGLQJXGVTBYALWMLKTTJMFPFS\n",
"output": "28",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "PXVKJHXVDPWGLHWFWMJPMCCNHCKSHCPZXGIHHNMYNFQBUCKJJTXXJGKRNVRTQFDFMLLGPQKFOVNNLTNDIEXSARRJKGSCZKGGJCBW\n",
"output": "35",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "EXNMTTFPJLDHXDQBJJRDRYBZVFFHUDCHCPNFZWXSMZXNFVJGHZWXVBRQFNUIDVLZOVPXQNVMFNBTJDSCKRLNGXPSADTGCAHCBJKL\n",
"output": "30",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "NRNLSQQJGIJBCZFTNKJCXMGPARGWXPSHZXOBNSFOLDQVXTVAGJZNLXULHBRDGMNQKQGWMRRDPYCSNFVPUFTFBUBRXVJGNGSPJKLL\n",
"output": "19",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "SRHOKCHQQMVZKTCVQXJJCFGYFXGMBZSZFNAFETXILZHPGHBWZRZQFMGSEYRUDVMCIQTXTBTSGFTHRRNGNTHHWWHCTDFHSVARMCMB\n",
"output": "30",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "HBSVZHDKGNIRQUBYKYHUPJCEETGFMVBZJTHYHFQPFBVBSMQACYAVWZXSBGNKWXFNMQJFMSCHJVWBZXZGSNBRUHTHAJKVLEXFBOFB\n",
"output": "34",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "NXKMUGOPTUQNSRYTKUKSCWCRQSZKKFPYUMDIBJAHJCEKZJVWZAWOLOEFBFXLQDDPNNZKCQHUPBFVDSXSUCVLMZXQROYQYIKPQPWR\n",
"output": "17",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "TEHJDICFNOLQVQOAREVAGUAWODOCXJXIHYXFAEPEXRHPKEIIRCRIVASKNTVYUYDMUQKSTSSBYCDVZKDDHTSDWJWACPCLYYOXGCLT\n",
"output": "15",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "LCJJUZZFEIUTMSEXEYNOOAIZMORQDOANAMUCYTFRARDCYHOYOPHGGYUNOGNXUAOYSEMXAZOOOFAVHQUBRNGORSPNQWZJYQQUNPEB\n",
"output": "9",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "UUOKAOOJBXUTSMOLOOOOSUYYFTAVBNUXYFVOOGCGZYQEOYISIYOUULUAIJUYVVOENJDOCLHOSOHIHDEJOIGZNIXEMEGZACHUAQFW\n",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "OUUBEHXOOURMOAIAEHXCUOIYHUJEVAWYRCIIAGDRIPUIPAIUYAIWJEVYEYYUYBYOGVYESUJCFOJNUAHIOOKBUUHEJFEWPOEOUHYA\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "EMNOYEEUIOUHEWZITIAEZNCJUOUAOQEAUYEIHYUSUYUUUIAEDIOOERAEIRBOJIEVOMECOGAIAIUIYYUWYIHIOWVIJEYUEAFYULSE\n",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "BVOYEAYOIEYOREJUYEUOEOYIISYAEOUYAAOIOEOYOOOIEFUAEAAESUOOIIEUAAGAEISIAPYAHOOEYUJHUECGOYEIDAIRTBHOYOYA\n",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "GOIEOAYIEYYOOEOAIAEOOUWYEIOTNYAANAYOOXEEOEAVIOIAAIEOIAUIAIAAUEUAOIAEUOUUZYIYAIEUEGOOOOUEIYAEOSYAEYIO\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AUEAOAYIAOYYIUIOAULIOEUEYAIEYYIUOEOEIEYRIYAYEYAEIIMMAAEAYAAAAEOUICAUAYOUIAOUIAIUOYEOEEYAEYEYAAEAOYIY\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "OAIIYEYYAOOEIUOEEIOUOIAEFIOAYETUYIOAAAEYYOYEYOEAUIIUEYAYYIIAOIEEYGYIEAAOOWYAIEYYYIAOUUOAIAYAYYOEUEOY\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "EEEAOEOEEIOUUUEUEAAOEOIUYJEYAIYIEIYYEAUOIIYIUOOEUCYEOOOYYYIUUAYIAOEUEIEAOUOIAACAOOUAUIYYEAAAOOUYIAAE\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AYEYIIEUIYOYAYEUEIIIEUYUUAUEUIYAIAAUYONIEYIUIAEUUOUOYYOUUUIUIAEYEOUIIUOUUEOAIUUYAAEOAAEOYUUIYAYRAIII\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "YOOAAUUAAAYEUYIUIUYIUOUAEIEEIAUEOAUIIAAIUYEUUOYUIYEAYAAAYUEEOEEAEOEEYYOUAEUYEEAIIYEUEYJOIIYUIOIUOIEE\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "UYOIIIAYOOAIUUOOEEUYIOUAEOOEIOUIAIEYOAEAIOOEOOOIUYYUYIAAUIOUYYOOUAUIEYYUOAAUUEAAIEUIAUEUUIAUUOYOAYIU\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "ABBABBB\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "ABCD\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "XXYC\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "YYY\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "ABABBBBBBB\n",
"output": "8",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "YYYY\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "YYYYY\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AXXX\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "YYYYYYY\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "BYYBBB\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "YYYYYYYYY\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "CAAAAA\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "CCCACCCC\n",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "ABABBBACFEYUKOTTTT\n",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AABBYYYYYYYY\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "BYBACYC\n",
"output": "2",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "Y\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "ABBBBBB\n",
"output": "7",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "BACDYDI\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "XEXXXXXXXXXXXXXXX\n",
"output": "16",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "TTYTT\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "AAYBC\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "ABABBBACFEYUKOTTTTT\n",
"output": "6",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "YYAYY\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "YZZY\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "YY\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "ZZYZZ\n",
"output": "3",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "YBBBY\n",
"output": "4",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "BBBACCCCCCC\n",
"output": "8",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "YBBBBY\n",
"output": "5",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "YYYYYYYYYY\n",
"output": "1",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "ABABBBBBBBBBBBB\n",
"output": "13",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
4680
|
Solve the following coding problem using the programming language python:
Iroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.
To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
-----Constraints-----
- 1≦A,B,C≦10
-----Input-----
The input is given from Standard Input in the following format:
A B C
-----Output-----
If it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.
-----Sample Input-----
5 5 7
-----Sample Output-----
YES
Using three phrases of length 5, 5 and 7, it is possible to construct a Haiku.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
haiku = list(map(int, input().split()))
if haiku == [5, 5, 7] or haiku == [5, 7, 5] or haiku == [7, 5, 5]:
print("YES")
else:
print("NO")
```
|
vfc_27355
|
{
"difficulty": "introductory",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc042/tasks/abc042_a",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 5 7\n",
"output": "YES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 7 5\n",
"output": "NO\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
4264
|
Solve the following coding problem using the programming language python:
Given is an integer N. Find the number of positive integers less than or equal to N that have an odd number of digits (in base ten without leading zeros).
-----Constraints-----
- 1 \leq N \leq 10^5
-----Input-----
Input is given from Standard Input in the following format:
N
-----Output-----
Print the number of positive integers less than or equal to N that have an odd number of digits.
-----Sample Input-----
11
-----Sample Output-----
9
Among the positive integers less than or equal to 11, nine integers have an odd number of digits: 1, 2, \ldots, 9.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
n=input()
count=0
for i in range(1,int(n)+1):
l=len(str(i))
if l%2!=0:
count+=1
print(count)
```
|
vfc_25763
|
{
"difficulty": "introductory",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://atcoder.jp/contests/abc136/tasks/abc136_b",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "11\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "136\n",
"output": "46\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100000\n",
"output": "90909\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "99\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3124\n",
"output": "909\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10000\n",
"output": "910\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "45901\n",
"output": "36811\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "99924\n",
"output": "90834\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "99999\n",
"output": "90909\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
435
|
Solve the following coding problem using the programming language python:
High school student Vasya got a string of length n as a birthday present. This string consists of letters 'a' and 'b' only. Vasya denotes beauty of the string as the maximum length of a substring (consecutive subsequence) consisting of equal letters.
Vasya can change no more than k characters of the original string. What is the maximum beauty of the string he can achieve?
-----Input-----
The first line of the input contains two integers n and k (1 ≤ n ≤ 100 000, 0 ≤ k ≤ n) — the length of the string and the maximum number of characters to change.
The second line contains the string, consisting of letters 'a' and 'b' only.
-----Output-----
Print the only integer — the maximum beauty of the string Vasya can achieve by changing no more than k characters.
-----Examples-----
Input
4 2
abba
Output
4
Input
8 1
aabaabaa
Output
5
-----Note-----
In the first sample, Vasya can obtain both strings "aaaa" and "bbbb".
In the second sample, the optimal answer is obtained with the string "aaaaabaa" or with the string "aabaaaaa".
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
n, k = map(int,input().split())
s = input()
maxi = 0
a = 0
b = 0
st = 0
for i in range(0, n):
if s[i] == 'a': a += 1
else: b+=1
if min(a, b) > k:
if s[st] == 'a': a-=1
else: b-=1
st += 1
else: maxi += 1
print(maxi)
```
|
vfc_11494
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/676/C",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4 2\nabba\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8 1\naabaabaa\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 0\na\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\nb\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 0\nb\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\na\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 10\nbbbbbbbbbb\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 2\nbbbbbbbbbb\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 1\nbbabbabbba\n",
"output": "6\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 10\nbbabbbaabb\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 9\nbabababbba\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 4\nbababbaaab\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 10\naabaaabaaa\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 10\naaaabbbaaa\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 1\nbaaaaaaaab\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 5\naaaaabaaaa\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 4\naaaaaaaaaa\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 10\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n",
"output": "100\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 7\nbbbbabbbbbaabbbabbbbbbbbbbbabbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbbbabbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbab\n",
"output": "93\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 30\nbbaabaaabbbbbbbbbbaababababbbbbbaabaabbbbbbbbabbbbbabbbbabbbbbbbbaabbbbbbbbbabbbbbabbbbbbbbbaaaaabba\n",
"output": "100\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 6\nbaababbbaabbabbaaabbabbaabbbbbbbbaabbbabbbbaabbabbbbbabababbbbabbbbbbabbbbbbbbbaaaabbabbbbaabbabaabb\n",
"output": "34\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 45\naabababbabbbaaabbbbbbaabbbabbaabbbbbabbbbbbbbabbbbbbabbaababbaabbababbbbbbababbbbbaabbbbbbbaaaababab\n",
"output": "100\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 2\nababaabababaaababbaaaabbaabbbababbbaaabbbbabababbbabababaababaaabaabbbbaaabbbabbbbbabbbbbbbaabbabbba\n",
"output": "17\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 25\nbabbbaaababaaabbbaabaabaabbbabbabbbbaaaaaaabaaabaaaaaaaaaabaaaabaaabbbaaabaaababaaabaabbbbaaaaaaaaaa\n",
"output": "80\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 14\naabaaaaabababbabbabaaaabbaaaabaaabbbaaabaaaaaaaabaaaaabbaaaaaaaaabaaaaaaabbaababaaaababbbbbabaaaabaa\n",
"output": "61\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 8\naaaaabaaaabaabaaaaaaaabaaaabaaaaaaaaaaaaaabaaaaabaaaaaaaaaaaaaaaaabaaaababaabaaaaaaaaaaaaabbabaaaaaa\n",
"output": "76\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 12\naaaaaaaaaaaaaaaabaaabaaaaaaaaaabbaaaabbabaaaaaaaaaaaaaaaaaaaaabbaaabaaaaaaaaaaaabaaaaaaaabaaaaaaaaaa\n",
"output": "100\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 65\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n",
"output": "100\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 0\nbbbbbbbbbb\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 0\nbbbbabbbbb\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 0\nbbabbbabba\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 0\nbaabbbbaba\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 0\naababbbbaa\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 2\nabbbbbaaba\n",
"output": "8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 0\nabbaaabaaa\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 0\naabbaaabaa\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 1\naaaaaababa\n",
"output": "8\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 0\nbaaaaaaaaa\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10 0\naaaaaaaaaa\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 0\nbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\n",
"output": "100\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 0\nbbbbbbbbbbabbbbaaabbbbbbbbbbbabbbabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbabbbbbbbbbabbbbbbbbbbbbbab\n",
"output": "40\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 11\nbaabbbbbababbbbabbbbbbbabbbbbbbbbbbbbbabbbbbbababbbbababbbbaaabbbbabbbbbabbbbbbbbabababbbabbbbbbbabb\n",
"output": "65\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 8\nbbababbbbbaabbbaaababbbbababababbbbababbabbbabbbbbaabbbabbbababbabbbbabbbabbbbaabbbbabbbaabbbbaaaabb\n",
"output": "33\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 21\nabbaaaabbbababaabbbababbbbbbbbabbaababababbbabbbaaabbaaabbbbabbabbbabbbabaababbbabbbbbabbbbbbabbbbab\n",
"output": "65\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 9\nabbbaabaabaaaaaaabbabbbababbaaabbbaaabbaabaaaaabbbbbabbaabaabbbbbaaaaababbaaabbabaabaaabababbaababbb\n",
"output": "26\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 5\naababababbaaaaaaaabbbabaaaabbabaaaabbaabaaaaabababbabaabaaabaaaaaaaabaababbabbaaabaabbabbaaaaabbabba\n",
"output": "22\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 9\naababaabaaaaaaaaabbbaabaaaaaaabaaaaaaaaaaaaabaaabaabaabbbbabbaababbabbaaaabbababaabaababaabaaaaaaaaa\n",
"output": "49\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 6\naaaaabbaaaaaaaaaaabaaaabaaaaaaaaabaaabaaaaaabaaaaaaaaaaabaabaaaabaaaaaaaaaaaaaaabaabbaaaaaaaaaaaaaaa\n",
"output": "56\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 7\nabaaabaabaabaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaabaaaaaaabbabaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaba\n",
"output": "86\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "100 0\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n",
"output": "100\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
1757
|
Solve the following coding problem using the programming language python:
Eleven wants to choose a new name for herself. As a bunch of geeks, her friends suggested an algorithm to choose a name for her. Eleven wants her name to have exactly n characters. [Image]
Her friend suggested that her name should only consist of uppercase and lowercase letters 'O'. More precisely, they suggested that the i-th letter of her name should be 'O' (uppercase) if i is a member of Fibonacci sequence, and 'o' (lowercase) otherwise. The letters in the name are numbered from 1 to n. Fibonacci sequence is the sequence f where f_1 = 1, f_2 = 1, f_{n} = f_{n} - 2 + f_{n} - 1 (n > 2).
As her friends are too young to know what Fibonacci sequence is, they asked you to help Eleven determine her new name.
-----Input-----
The first and only line of input contains an integer n (1 ≤ n ≤ 1000).
-----Output-----
Print Eleven's new name on the first and only line of output.
-----Examples-----
Input
8
Output
OOOoOooO
Input
15
Output
OOOoOooOooooOoo
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
d = [1, 1]
n = int(input())
while d[-1] < n:
d.append(d[-1] + d[-2])
s = set(d)
res = ''
for i in range(1, n + 1):
if i in s:
res += 'O'
else:
res += 'o'
print(res)
```
|
vfc_16782
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/918/A",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "8\n",
"output": "OOOoOooO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "15\n",
"output": "OOOoOooOooooOoo\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "85\n",
"output": "OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooooooooooooooooooooooooooo\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "381\n",
"output": "OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOoooo\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n",
"output": "O\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "OO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n",
"output": "OOO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n",
"output": "OOOoO\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "17\n",
"output": "OOOoOooOooooOoooo\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "49\n",
"output": "OOOoOooOooooOoooooooOooooooooooooOooooooooooooooo\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "256\n",
"output": "OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooOooooooooooooooooooooooo\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "61\n",
"output": "OOOoOooOooooOoooooooOooooooooooooOooooooooooooooooooooOoooooo\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
1549
|
Solve the following coding problem using the programming language python:
The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow.
- Each testcase contains of a single line of input, one integer $K$.
-----Output:-----
For each testcase, output as pattern.
-----Constraints-----
- $1 \leq T \leq 100$
- $1 \leq K \leq 100$
-----Sample Input:-----
2
2
4
-----Sample Output:-----
2
12
012
12
2
4
34
234
1234
01234
1234
234
34
4
-----EXPLANATION:-----
No need, else pattern can be decode easily.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
# cook your dish here
import copy
for _ in range(int(input())):
k=int(input())
c=[]
d=[]
start=0
while True:
c=[]
for i in range(start):
c.append(" ")
for i in range(start,k+1):
c.append(str(i))
start+=1
d.append(c)
if start>k:
break
e=copy.copy(d[1:])
d.reverse()
d=d+e
##print(d)
for i in range(len(d)):
print(''.join(d[i]))
```
|
vfc_5038
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PBK02020/problems/ITGUY12",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "2\n2\n4\n",
"output": "2\n12\n012\n12\n2\n4\n34\n234\n1234\n01234\n1234\n234\n34\n4\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
322
|
Solve the following coding problem using the programming language python:
You have n distinct points on a plane, none of them lie on OY axis. Check that there is a point after removal of which the remaining points are located on one side of the OY axis.
-----Input-----
The first line contains a single positive integer n (2 ≤ n ≤ 10^5).
The following n lines contain coordinates of the points. The i-th of these lines contains two single integers x_{i} and y_{i} (|x_{i}|, |y_{i}| ≤ 10^9, x_{i} ≠ 0). No two points coincide.
-----Output-----
Print "Yes" if there is such a point, "No" — otherwise.
You can print every letter in any case (upper or lower).
-----Examples-----
Input
3
1 1
-1 -1
2 -1
Output
Yes
Input
4
1 1
2 2
-1 1
-2 2
Output
No
Input
3
1 2
2 1
4 60
Output
Yes
-----Note-----
In the first example the second point can be removed.
In the second example there is no suitable for the condition point.
In the third example any point can be removed.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
n = int(input())
lcnt = 0
rcnt = 0
for i in range(n):
x, y = map(int, input().split())
if x < 0:
lcnt += 1
else:
rcnt += 1
if (lcnt <= 1 or rcnt <= 1):
print("Yes")
else:
print("No")
```
|
vfc_11042
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/900/A",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n1 1\n-1 -1\n2 -1\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 1\n2 2\n-1 1\n-2 2\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 2\n2 1\n4 60\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n1 1\n2 2\n3 3\n4 4\n5 5\n6 6\n7 7\n8 8\n9 9\n-1 -1\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1000000000 -1000000000\n1000000000 1000000000\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "23\n-1 1\n-1 2\n-2 4\n-7 -8\n-3 3\n-9 -14\n-5 3\n-6 2\n-7 11\n-4 4\n-8 5\n1 1\n-1 -1\n-1 -2\n-2 -4\n-7 8\n-3 -3\n-9 14\n-5 -3\n-6 -2\n-7 -11\n-4 -4\n-8 -5\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n-1000000000 -1000000000\n1000000000 1000000000\n-1000000000 1000000000\n1000000000 -1000000000\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n-1000000000 1000000000\n-1000000000 -1000000000\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n-1 -1\n-2 2\n2 2\n2 -2\n3 2\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 0\n-1 0\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n-1 1\n-1 2\n-1 3\n-1 4\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n-1 0\n1 0\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 2\n-1 2\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n8 0\n7 0\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n-1 0\n-2 0\n-1 -1\n-1 5\n1 0\n1 1\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 0\n2 0\n-1 0\n-2 0\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n-2 0\n-1 0\n1 0\n2 0\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 1\n-1 1\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n-1 0\n-2 0\n1 0\n2 0\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n4 3\n-4 -2\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 0\n2 0\n-1 1\n-1 2\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 1\n2 1\n3 1\n-1 1\n-2 1\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 1\n-1 -1\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 2\n1 0\n1 -2\n-1 2\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n-2 3\n-3 3\n4 2\n3 2\n1 2\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n2 0\n3 0\n4 0\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n-3 1\n-2 1\n-1 1\n1 1\n2 1\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n-3 0\n1 0\n2 0\n3 0\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 0\n-1 1\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n-1 0\n1 0\n2 0\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 0\n3 0\n-1 0\n-6 0\n-4 1\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n-1 2\n-2 2\n-3 1\n1 2\n2 3\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 0\n-1 0\n-2 0\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 0\n2 0\n3 1\n4 1\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 0\n1 2\n1 3\n-1 5\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n2 2\n2 5\n-2 3\n-2 0\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 1\n-1 1\n-1 0\n-1 -1\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n2 0\n3 0\n-3 -3\n-3 -4\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n-1 0\n-2 0\n-3 0\n-4 0\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n-1 1\n1 1\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 1\n2 2\n3 3\n-4 -4\n-5 -5\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n2 0\n3 0\n4 0\n5 0\n6 0\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n-1 2\n1 2\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n1 1\n2 1\n-3 0\n-4 0\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n-1 0\n-2 0\n3 0\n4 0\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n3 0\n2 0\n1 0\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n-2 0\n-3 0\n1 -1\n3 1\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n-1 -1\n1 1\n2 2\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n-2 0\n-1 0\n2 0\n1 0\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n-3 5\n3 5\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n-1 5\n1 5\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n2 0\n3 0\n-2 0\n-3 0\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n-1 1\n1 1\n1 -1\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 0\n2 0\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n-1 1\n-2 1\n2 -1\n3 -1\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n1 0\n2 0\n3 0\n-1 0\n-2 0\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n-3 0\n-4 0\n-5 0\n-6 0\n",
"output": "Yes",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n-3 0\n-2 0\n-1 0\n1 0\n2 0\n3 0\n",
"output": "No",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n5 0\n5 1\n6 0\n6 1\n",
"output": "Yes",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
840
|
Solve the following coding problem using the programming language python:
The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K(odd) to form a new pattern. Help the chef to code this pattern problem.
-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow.
- Each test case contains a single line of input, one integer $K$.
-----Output:-----
For each test case, output as the pattern.
-----Constraints-----
- $1 \leq T \leq 50$
- $1 \leq K \leq 50$
-----Sample Input:-----
4
1
3
5
7
-----Sample Output:-----
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
-----EXPLANATION:-----
No need, else pattern can be decode easily.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
def func(num):
for i in range(num):
if i < num//2 + 1:
print(' '*i, end='')
print('*')
else:
print(' '*(num-i-1), end='')
print('*')
for _ in range(int(input())):
num = int(input())
func(num)
```
|
vfc_2202
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://www.codechef.com/PSTR2020/problems/ITGUY45",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n1\n3\n5\n7\n",
"output": "*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n*\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
2012
|
Solve the following coding problem using the programming language python:
A permutation p of size n is the sequence p_1, p_2, ..., p_{n}, consisting of n distinct integers, each of them is from 1 to n (1 ≤ p_{i} ≤ n).
A lucky permutation is such permutation p, that any integer i (1 ≤ i ≤ n) meets this condition p_{p}_{i} = n - i + 1.
You have integer n. Find some lucky permutation p of size n.
-----Input-----
The first line contains integer n (1 ≤ n ≤ 10^5) — the required permutation size.
-----Output-----
Print "-1" (without the quotes) if the lucky permutation p of size n doesn't exist.
Otherwise, print n distinct integers p_1, p_2, ..., p_{n} (1 ≤ p_{i} ≤ n) after a space — the required permutation.
If there are multiple answers, you can print any of them.
-----Examples-----
Input
1
Output
1
Input
2
Output
-1
Input
4
Output
2 4 1 3
Input
5
Output
2 5 3 1 4
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
n = int(input())
if n%4 > 1:
print(-1)
else:
a = [n+1>>1]*n
for i in range(n//4):
j = i*2
a[j], a[j+1], a[-2-j], a[-1-j] = j+2, n-j, j+1, n-1-j
print(' '.join(map(str, a)))
```
|
vfc_5594
|
{
"difficulty": "competition",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/286/A",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "1\n",
"output": "1 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4\n",
"output": "2 4 1 3 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n",
"output": "2 5 3 1 4 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n",
"output": "2 8 4 6 3 5 1 7 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9\n",
"output": "2 9 4 7 5 3 6 1 8 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10002\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10003\n",
"output": "-1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "25\n",
"output": "2 25 4 23 6 21 8 19 10 17 12 15 13 11 14 9 16 7 18 5 20 3 22 1 24 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "29\n",
"output": "2 29 4 27 6 25 8 23 10 21 12 19 14 17 15 13 16 11 18 9 20 7 22 5 24 3 26 1 28 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "33\n",
"output": "2 33 4 31 6 29 8 27 10 25 12 23 14 21 16 19 17 15 18 13 20 11 22 9 24 7 26 5 28 3 30 1 32 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9\n",
"output": "2 9 4 7 5 3 6 1 8 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "13\n",
"output": "2 13 4 11 6 9 7 5 8 3 10 1 12 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "17\n",
"output": "2 17 4 15 6 13 8 11 9 7 10 5 12 3 14 1 16 \n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "99999\n",
"output": "-1\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
4073
|
Solve the following coding problem using the programming language python:
DO YOU EXPECT ME TO FIND THIS OUT?
WHAT BASE AND/XOR LANGUAGE INCLUDES string?
DON'T BYTE OF MORE THAN YOU CAN CHEW
YOU CAN ONLY DISTORT THE LARGEST OF MATHEMATICS SO FAR
SAYING "ABRACADABRA" WITHOUT A MAGIC AND WON'T DO YOU ANY GOOD
THE LAST STACK RUPTURES. ALL DIE. OH, THE EMBARRASSMENT!
I HAVE NO ARRAY AND I MUST SCREAM
ELEMENTS MAY NOT BE STORED IN WEST HYPERSPACE
-----Input-----
The first line of input data contains a single integer n (1 ≤ n ≤ 10).
The second line of input data contains n space-separated integers a_{i} (1 ≤ a_{i} ≤ 11).
-----Output-----
Output a single integer.
-----Example-----
Input
4
2 5 3 1
Output
4
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
n = int(input())
a = list(map(int, input().split()))
print(max(a) ^ a[-1])
```
|
vfc_24999
|
{
"difficulty": "introductory",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/784/C",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "4\n2 5 3 1\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 5\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1\n8\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n1 1 1 3 2 9\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n8 9 3 1 9\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n1 5 2 1 7 11\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n1 6 11 8 5 10 7 8\n",
"output": "3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n4 9 6\n",
"output": "15\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n4 8\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n1 1 5\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n4 5 5 2 11\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n1 7 2 8 8 2\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n3 9 3 2 3\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n6 6 1 1 1 2 3\n",
"output": "5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n11 1 2 8 10 5 9\n",
"output": "2\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n4 5 1 10 10 4 1\n",
"output": "11\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n5 5 10 10 10 2 4 3 4 10\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n4 7 11 3 11 3 1 1\n",
"output": "10\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n5 9\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n2 1 10 2 7 5\n",
"output": "15\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n3 5 9 10 5 4\n",
"output": "14\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n3 5 8 10 3 4 2 10\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7\n1 6 5 3 9 5 9\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "8\n7 2 6 3 6 4 1 8\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n8 10 6 10 4 3 4 6 7 4\n",
"output": "14\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n1 5\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "10\n5 6 4 8 11 4 10 4 8 4\n",
"output": "15\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "2\n3 7\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3\n4 10 3\n",
"output": "9\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5\n5 2 2 11 2\n",
"output": "9\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
2575
|
Solve the following coding problem using the programming language python:
Emuskald needs a fence around his farm, but he is too lazy to build it himself. So he purchased a fence-building robot.
He wants the fence to be a regular polygon. The robot builds the fence along a single path, but it can only make fence corners at a single angle a.
Will the robot be able to build the fence Emuskald wants? In other words, is there a regular polygon which angles are equal to a?
-----Input-----
The first line of input contains an integer t (0 < t < 180) — the number of tests. Each of the following t lines contains a single integer a (0 < a < 180) — the angle the robot can make corners at measured in degrees.
-----Output-----
For each test, output on a single line "YES" (without quotes), if the robot can build a fence Emuskald wants, and "NO" (without quotes), if it is impossible.
-----Examples-----
Input
3
30
60
90
Output
NO
YES
YES
-----Note-----
In the first test case, it is impossible to build the fence, since there is no regular polygon with angle $30^{\circ}$.
In the second test case, the fence is a regular triangle, and in the last test case — a square.
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
import sys
my_file = sys.stdin
##my_file = open("input.txt", "r")
num = int(my_file.readline().strip("\n"))
angles = my_file.read().split()
angles = [int(i) for i in angles]
for i in angles:
if 360%(180-i)>0:
print("NO")
else:
print("YES")
```
|
vfc_20033
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/270/A",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "3\n30\n60\n90\n",
"output": "NO\nYES\nYES\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "6\n1\n2\n3\n170\n179\n25\n",
"output": "NO\nNO\nNO\nYES\nYES\nNO\n",
"type": "stdin_stdout"
}
]
}
|
apps
|
verifiable_code
|
1217
|
Solve the following coding problem using the programming language python:
You are given two arrays of integers a and b. For each element of the second array b_{j} you should find the number of elements in array a that are less than or equal to the value b_{j}.
-----Input-----
The first line contains two integers n, m (1 ≤ n, m ≤ 2·10^5) — the sizes of arrays a and b.
The second line contains n integers — the elements of array a ( - 10^9 ≤ a_{i} ≤ 10^9).
The third line contains m integers — the elements of array b ( - 10^9 ≤ b_{j} ≤ 10^9).
-----Output-----
Print m integers, separated by spaces: the j-th of which is equal to the number of such elements in array a that are less than or equal to the value b_{j}.
-----Examples-----
Input
5 4
1 3 5 7 9
6 4 2 8
Output
3 2 1 4
Input
5 5
1 2 1 2 5
3 1 4 1 5
Output
4 2 4 2 5
The input will be stdin and you should print your solution to stdout
Now solve the problem and return the code.
|
```python
#!/usr/bin/env python3
from bisect import bisect
try:
while True:
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
for x in map(int, input().split()):
print(bisect(a, x), end=' ')
print()
except EOFError:
pass
```
|
vfc_14622
|
{
"difficulty": "interview",
"memory_limit": null,
"memory_limit_bytes": null,
"problem_url": "https://codeforces.com/problemset/problem/600/B",
"time_limit": "None"
}
|
{
"language": "python",
"test_cases": [
{
"fn_name": null,
"input": "5 4\n1 3 5 7 9\n6 4 2 8\n",
"output": "3 2 1 4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 5\n1 2 1 2 5\n3 1 4 1 5\n",
"output": "4 2 4 2 5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n-1\n-2\n",
"output": "0\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n-80890826\n686519510\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "11 11\n237468511 -779187544 -174606592 193890085 404563196 -71722998 -617934776 170102710 -442808289 109833389 953091341\n994454001 322957429 216874735 -606986750 -455806318 -663190696 3793295 41395397 -929612742 -787653860 -684738874\n",
"output": "11 9 8 2 2 1 5 5 0 0 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "20 22\n858276994 -568758442 -918490847 -983345984 -172435358 389604931 200224783 486556113 413281867 -258259500 -627945379 -584563643 444685477 -602481243 -370745158 965672503 630955806 -626138773 -997221880 633102929\n-61330638 -977252080 -212144219 385501731 669589742 954357160 563935906 584468977 -895883477 405774444 853372186 186056475 -964575261 -952431965 632332084 -388829939 -23011650 310957048 -770695392 977376693 321435214 199223897\n",
"output": "11 2 10 12 18 19 16 16 3 13 18 11 2 2 17 8 11 12 3 20 12 11\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 9\n1 3 5 7 9\n1 2 3 4 5 6 7 8 9\n",
"output": "1 1 2 2 3 3 4 4 5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "22 1\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22\n1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 1\n1 3 3 3 5\n3\n",
"output": "4\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "4 5\n1 1 1 4\n1 5 5 4 3\n",
"output": "3 4 4 4 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "5 4\n0 5 5 5 6\n5 1 6 3\n",
"output": "4 1 5 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 3\n0\n-1 0 1\n",
"output": "0 1 1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "96 1\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n1\n",
"output": "96\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "7 1\n1 2 3 4 5 6 7\n1\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "13 13\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000\n-1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000 1000000000 -1000000000\n",
"output": "7 13 7 13 7 13 7 13 7 13 7 13 7\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "9 5\n1 2 3 4 5 6 7 8 9\n1 2 3 4 5\n",
"output": "1 2 3 4 5\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "3 8\n1 1 1\n1 1 1 1 1 1 1 1\n",
"output": "3 3 3 3 3 3 3 3\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n-11111\n-5938\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n1\n400000009\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n1\n300000009\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n1\n200000009\n",
"output": "1\n",
"type": "stdin_stdout"
},
{
"fn_name": null,
"input": "1 1\n1\n200000003\n",
"output": "1\n",
"type": "stdin_stdout"
}
]
}
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 26