Problem:


Score : 100 points

Problem Statement

You are given an integer N that has exactly four digits in base ten.
How many times does 2 occur in the base-ten representation of N?

Constraints

1000 \leq N \leq 9999

Input

Input is given from Standard Input in the following format:

N

Output

Print the answer.

Sample Input 1

1222

Sample Output 1

3

2 occurs three times in 1222. By the way, this contest is held on December 22 (JST).

Sample Input 2

3456

Sample Output 2

0

Sample Input 3

9592

Sample Output 3

1



Sample input:
1222


Sample output:
3

Submission status: Runtime Error

Solution code:
print(input().count(2))

Submission status: Runtime Error

Solution code:
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == '__main__':
    a = [str(i) for i in input().split()]
    
    count = 0

    for  i in range(a[0]):
        if "2" == i:
            count +=1
    print(count)

Submission status: Runtime Error

Solution code:
s=input()
ans=0
for i in len(s):
    if s[i]=="2": ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
n=int(input())
ans=0
for i in range(4):
  if n%10=2:
    ans+=1
  n=n/10
print(ans)

Submission status: Runtime Error

Solution code:
#include<iostream>
using namespace std;

int main(){
  string S;
  cin >> S;
  int cnt = 0;
  for (int i = 0; i < 4; i++){
    if (S[i] == 2) {
      cnt++;
    }
  }
  cout << cnt << endl;

Submission status: Runtime Error

Solution code:
n=int(input())
count=0
for i in range(4):
    if n[i]==2:
        count+=1
print(count)

Submission status: Runtime Error

Solution code:
n=int(inout())
count=0
for i in range(4):
    if n[i]==2:
        count+=1
print(count)

Submission status: Runtime Error

Solution code:
print(int(input()).count(2))

Submission status: Runtime Error

Solution code:
def main(n):
    print(str(n).count('2'))


if __name__ == '__main__':
    n = int(input())
    main()

Submission status: Runtime Error

Solution code:
s=list(str(input()))
ans=0
for i in range(4):
    id s[i]=='2':
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
s=list(input())
ans=0
for i in range(4):
    id s[i]=='2':
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
s=input()
print(s.count(2))

Submission status: Runtime Error

Solution code:
n = list(int(input())

cnt = 0

for i in range(len(n)):
    if n[i] == 2:
        cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
print(input().conut("2"))

Submission status: Runtime Error

Solution code:
print(input().conut('2'))

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
ans=0
for s in range(a):
    d,e=map(int,input().split())
    if b<=d and c<=e:
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
n=list(input())
print(n.count('2))

Submission status: Runtime Error

Solution code:
n,h,w = map(int,input().split())
ans = 0
for i in range(n):
    a,b = map(int,input().split())
    if a>=h and w<=b:
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
n, p = map(int, raw_input().split())
fac = {}
primes = [1]*(10**6 + 200)
i = 2
prim = []
while i <= 10**6 + 100:
    if primes[i]:
        prim.append(i)
        j = i*2
        while j <= 10**6 + 100:
            primes[j] = 0
            j += i 
    i += 1 
for i in prim:
    while p%i == 0:
        p /= i 
        fac[i] = fac[i] + 1 if i in fac else 1
if p > 1:
    fac[p] = 1
ans = 1
for i in fac:
    if fac[i] >= n:
        ans *= i**(fac[i]/n)
print ans

Submission status: Runtime Error

Solution code:
n, p = map(int, raw_input().split())
fac = {}
primes = [1]*(10**6 + 200)
i = 2
prim = []
while i <= 10**6 + 100:
    if primes[i]:
        prim.append(i)
        j = i*2
        while j <= 10**6 + 100:
            primes[j] = 0
            j += i 
    i += 1 
for i in prim:
    while p%i == 0:
        p /= i 
        fac[i] = fac[i] + 1 if i in fac else 1
ans = 1
for i in fac:
    if fac[i] >= n:
        ans *= i**(fac[i]/n)
print ans

Submission status: Runtime Error

Solution code:
n, p = map(int, raw_input().split())
fac = {}
primes = [1]*(10**6 + 200)
i = 2
prim = []
while i <= 10**6 + 100:
    if primes[i]:
        prim.append(i)
        j = i*2
        while j <= 10**6:
            primes[j] = 0
            j += i 
    i += 1 
for i in prim:
    while p%i == 0:
        p /= i 
        fac[i] = fac[i] + 1 if i in fac else 1
ans = 1
for i in fac:
    if fac[i] >= n:
        ans *= i**(fac[i]/n)
print ans

Submission status: Runtime Error

Solution code:
import math
n,p=map(int,input().split())
if p==1:
    print(1)
    exit()
if n==1:
    print(p)
    exit()
i = 2
cnt,ans=0,1
while i<=p:
    if p % i == 0:
        cnt+=1
        p/=i
    else:
        if cnt>=n:
            ans*=i*math.floor(cnt/n)
        cnt=0
        if i==2:
            i+=1
        else:
            i+=2
if cnt>=n:
    ans*=i*math.floor(cnt/n)
print(ans)

Submission status: Runtime Error

Solution code:
s=input()
ans=0
for moji in s:
  if mojl == '2':
    ans += 1
    
print(ans)

Submission status: Runtime Error

Solution code:
N,P = map(int,input().split())
i = round(P**(1/N))
res = []
if N == 1:
  print(P)
elif P == 1|N>=40:
  print(1)
else:
  for i in range(i,0,-1):
    if P%i**N==0:
      print(i)
      break

Submission status: Runtime Error

Solution code:
import functools
import operator

N,P = map(int,input().split())

i = 2
res = []
i_2 = i**N
while i * i<=P:
  while P%i_2==0:
    P/=i_2
    res.append(i)
  else:
    i += 1
    
res.append(1)
result = functools.reduce(operator.mul, res)
print(result)

Submission status: Runtime Error

Solution code:
import collections
from functools import reduce
from operator import mul
N,P = map(int,input().split())

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

P = prime_decomposition(P)
c = collections.Counter(P)
temp = [i[0] for i in c.items() if i[1] >= N]
 
temp.append(1)
 
print(int(reduce(mul,temp)))

Submission status: Runtime Error

Solution code:
import sys
import math
import random


N, P = map(int, input().split())
if N == 1:
    print(P)
    sys.exit()


class Prime:
    seed_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

    def is_prime(self, n):
        """
        prime test (hybrid)

        see also: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """
        is_prime_common = self.is_prime_common(n)
        if is_prime_common is not None:
            return is_prime_common

        if n < 2000000:
            return self.is_prime_brute_force(n)
        else:
            return self.is_prime_miller_rabin(n)

    def is_prime_common(self, n):
        if n == 1: return False
        if n in Prime.seed_primes: return True
        if any(map(lambda x: n % x == 0, self.seed_primes)): return False

    def is_prime_brute_force(self, n):
        """
        brute force prime test
        use with is_prime_common if you want to skip seed_primes

        :param n:
        :return: boolean
        """
        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False
        return True

    def is_prime_miller_rabin(self, n):
        """
        miller rabin prime test
        use with is_prime_common if you want to skip seed_primes

        see also
            algorithm: https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test
            implementation: https://qiita.com/srtk86/items/609737d50c9ef5f5dc59
            improvement: https://qiita.com/gushwell/items/ff9ed83ba55350aaa369

        :param n:
        :return: boolean
        """

        d = n - 1
        while d & 1 == 0:
            d >>= 1

        # use one of these lines / upper is more efficient.
        witnesses = self.get_witnesses(n)
        # witnesses = [random.randint(1, n - 1) for _ in range(100)]

        for w in witnesses:
            y = pow(w, d, n)

            while d != n - 1 and y != 1 and y != n - 1:
                y = (y * y) % n
                d <<= 1

            if y != n - 1 and d & 1 == 0:
                return False

        return True

    def get_witnesses(self, num):
        def _get_range(num):
            if num < 2047:
                return 1
            if num < 1373653:
                return 2
            if num < 25326001:
                return 3
            if num < 3215031751:
                return 4
            if num < 2152302898747:
                return 5
            if num < 3474749660383:
                return 6
            if num < 341550071728321:
                return 7
            if num < 3825123056546413051:
                return 9
            return 12

        return self.seed_primes[:_get_range(num)]

    def gcd(self, a, b):
        if a < b:
            return self.gcd(b, a)
        if b == 0:
            return a
        while b:
            a, b = b, a % b
        return a

    @staticmethod
    def f(x, n, seed):
        """
        pseudo prime generator
        :param x:
        :param n:
        :param seed:
        :return: pseudo prime
        """
        p = Prime.seed_primes[seed % len(Prime.seed_primes)]
        return (p * x + seed) % n

    def find_factor(self, n, seed=1):
        """
        find one of factor of n
        this function is based to Pollard's rho algorithm

        see also
            algorithm: https://en.wikipedia.org/wiki/Pollard%27s_rho_algorithm
            implementation: https://qiita.com/gushwell/items/561afde2e00bf3380c98

        :param n:
        :param seed:
        :return: factor
        """
        if self.is_prime(n):
            return n

        x, y, d = 2, 2, 1
        count = 0
        while d == 1:
            count += 1
            x = self.f(x, n, seed)
            y = self.f(self.f(y, n, seed), n, seed)
            d = self.gcd(abs(x - y), n)

        if d == n:
            return self.find_factor(n, seed+1)
        return self.find_factor(d)

    def find_factors(self, n):
        primes = {}
        if self.is_prime(n):
            primes[n] = 1
            return primes

        while n > 1:
            factor = self.find_factor(n)

            primes.setdefault(factor, 0)
            primes[factor] += 1

            n //= factor

        return primes

prime = Prime()
factors = prime.find_factors(P)
print(factors)

GCD = 1

for k, v in factors.items():
    if v >= N:
        GCD *= k * (v // N)

print(GCD)

Submission status: Runtime Error

Solution code:
n,p = map(int,input().split())
N = round(p**(1/n))
for i in range(N,0,-1):
        if p%(i**n)==0:
            print(i)
            exit()

Submission status: Runtime Error

Solution code:
N = int(input())
An = []
for p in range(N):
    Ai = int(input())
    An.append(Ai)
res = True
for i in An:
    if i % 2 == 0:
        res = False
print("first" if res else "second")

Submission status: Runtime Error

Solution code:
n, p= [int(i) for i in input().split()]
#print(n,p)
ans=0
pp=int(p**(1/n))+1
for i in range(1,pp):
  b=i**n
  c=p/b
  if c.is_integer()==True:
    ans=i
    
print(ans)

Submission status: Runtime Error

Solution code:
N, P = map(int, raw_input().split())
if N == 1:
    print P
else:
    res = 2
    for i in range(2, int(N ** (1/2.)) + 1):
        if i ** N > P:
            break
        if P % (i ** N) == 0:
            res = i
    print res

Submission status: Runtime Error

Solution code:
N, P = map(int, raw_input().split())
i = 2
res = 1
if N == 1:
    print P
else:
    while i ** N <= P:
        if P % (i ** N) == 0:
            res = i
        i += 1
    print res

Submission status: Runtime Error

Solution code:
N, P = map(int, raw_input().split())
i = 2
res = 1
while i ** N <= P and N > 1:
    if P % (i ** N) == 0:
        res = i
    i += 1
print res

Submission status: Runtime Error

Solution code:
n,p= map(int,input().split())
res=1
if n==1:
    res=p
else:
    for i in range(2,int(p**(1/n))+1):
        x=i**n
        if x>p:
            break
        if p%x==0:
            res=i
print(res)

Submission status: Runtime Error

Solution code:
n,p= map(int,input().split())
res=1
if n==1:
    res=p
else:
    for i in range(int(p**(1/n))+2,1,-1):
        if p%i**n==0:
            res=i
            break
print(res)

Submission status: Runtime Error

Solution code:
n,p=map(int,input().split())

if n==1:
  print(p)
else:
  ans=1
  for i in range(1,int(p**(1/n))+2):
    tmp=i**n
    if (p>=tmp) and (p%tmp == 0):
     ans=i
    if(p<tmp):
      break
  print(ans)

Submission status: Runtime Error

Solution code:
import math
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
for i in reversed(range(round(math.pow(P,(1/N)))):
    tmp=math.pow(i,N-1)
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if (P/i)%tmp==0:
        ans=i
        break
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

args = [int(i) for i in input().split()]
N = args[0]
P = args[1]

num = 1
i = 2

count = 0
while True:
    if P % i == 0:
        P /= i
        count += 1
    else:
        x = count // N
        num *= i**x
        break

i = 3
while True:
    count = 0
    while True:
        if P % i == 0:
            P /= i
            count += 1
        else:
            x = count // N
            num *= i**x
            i += 2
            break
    if i**N > P:
        break

print(num)

Submission status: Runtime Error

Solution code:
N, P = map(int, input().split())
p = P**(1/N)
if p % 1 == 0:
    print(int(p))
    exit()

lim = int(p) + 1

dic = {}

def my(N,newP=P):
    for i in range(2,lim+1):
        while newP % i == 0:
            dic[i] = dic.get(i,0) + 1
            newP = newP // i
        if newP < i or i == lim+1:
            res = 1
            for j,k in dic.items():
                res *= j**(k//N)
            print(res)
            exit()
my(N)
print(1)

Submission status: Runtime Error

Solution code:
N,P=list(map(int,input().split()))
 
root=P**(1/N)
x=round(root)

if n==1:
    print(p)
else:
	for i in range(x):
		if P%((x-i)**N)==0:
			print(x-i)
			break

Submission status: Runtime Error

Solution code:
#encoding:utf-8

import math

N,P = map(int,input().split())

def factorint(N):
    table = {}
    while(N > 1):
        for i in range(2,N+1):
            if N%i == 0:
                while N%i == 0:
                    N = N//i
                    if i in table.keys():
                        table[i] += 1
                    else:
                        table[i] = 1
                break
    return table
ans = 1
if N == 1:
    ans = P
elif 1 < N < 40:
    #Nが２以上なのでpをｓｑｒｔしても良い
    facters = factorint(P)
    # print(facters)

    ans = 1
    for key in facters.keys():
        if facters[key]/N >= 1:
            ans *= key**(facters[key]//N)
else:
    pass

print(int(ans))
# print(type(ans))

Submission status: Runtime Error

Solution code:
print('second' if all(a[i] % 2 == 0 for i in range(N)) else 'first')

Submission status: Runtime Error

Solution code:
n,p= map(int,input().split())
if n==1:
    print(p)
    exit
if n==2:
    import math
    sqrt=math.sqrt(p)
    if sqrt==int(sqrt):
        print(int(sqrt))
 
else :print(1)

Submission status: Runtime Error

Solution code:
import math

N, P = list(map(int, input().split()))

now_max = 1

for i in range(round(math.pow(P, 1 / N)) + 1, 0, -1):
    if P % (i ** N) == 0:
        now_max = i
        break

print(now_max)

Submission status: Runtime Error

Solution code:
N = int(input())
cnt = 0
for i in range(0, N):
    if int(input()) != 1:
        cnt = cnt + 1

if N % 2 == 0:
    if cnt % 2 == 0:
        print('second')
    else:
        print('first')
else:
    if cnt % 2 == 0:
        print('first')
    else:
        print('second')

Submission status: Runtime Error

Solution code:
n,p=map(int,input().split())


def kouyaku(n,p):
    if n==1:
        return p 
    
    else:
        if int(p**(1/n))-p**(1/n)< 1e-11:
            return int(p**(1/n))
        else:
            for i in range(round((p**(1/n)/2+1)),0,-1):        
                if p%i==0:
                    if p%(i**2)==0:
                        if p%(i**n)==0:
                            return i

            
print(kouyaku(n,p))

Submission status: Runtime Error

Solution code:
N, P = map(int, input().split())
b=0
a = int(pow(P, 1/N))
for i in range(1, a+1):
  if P % pow(a+1-i,N) == 0:
     b = a+1-i
     break
print(b)

Submission status: Runtime Error

Solution code:
N = int(input())
H = int(input())
W = int(input())
n = 0
cnt = 0
while n<N:
    A = int(input())
    B = int(input())
    n +=1
    if (H == A and W == B) or (H == A/2 and W == B/2):
        cnt = +1
print(cnt)

Submission status: Runtime Error

Solution code:
import random
N = int(input())
for i in range(N):
    a = int(input())

b = random.randint(0,1)
if b == 1:
    print("first")
else:
    print("second")

Submission status: Runtime Error

Solution code:
n,p=map(int,input().split())


def kouyaku(n,p):
    if n==1:
        return p 
    else:
        if int(p**(1/n))*n-p< 1e-6:
            return int(p**(1/n))
        else:
            for i in range(round((p**(1/n)/2+1)),0,-1):        
                if p%i==0:
                    if p%(i**2)==0:
                        if p%(i**n)==0:
                            return i

            
print(kouyaku(n,p))

Submission status: Runtime Error

Solution code:
N = int(input())
H = int(input())
W = int(input())
n = 0
while n<N:
    A = int(input())
    B = int(input())
    n +=1
if (H == A and W == B) or (H == A/2 and W == B/2):
    print(cnt = +1)

Submission status: Runtime Error

Solution code:
import math

n,p=map(int,input().split())

def C(N,P):
    if N == 1: return P
    b=int(math.log2(N))
    a=P**(1/b)

    res=1
    for i in range(2,int(a)+2):
        if i**N > P : break
        if P % i**N == 0 : res = i

    return res

print(C(n,p))

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
if a==0:
    print(b)
elif b==1:
    print(b)
else:
    print(b)

Submission status: Runtime Error

Solution code:
N = int(input())
H = int(input())
W = int(input())
while 0<N:
    A = int(input())
    B = int(input())
if (H == A and W == B) or (H == A/2 and W == B/2):
    cnt = +1
print(int(cnt))

Submission status: Runtime Error

Solution code:
import math

n,p=map(int,input().split())

def C(N,P):
    if N == 1: return P
    a=P
    N1=2
    while N >= N1:
        N1*=2
        a=math.sqrt(a)

    res=1
    for i in range(2,int(a)+2):
        if i**N > P : break
        if P % i**N == 0 : res = i

    return res

print(C(n,p))

Submission status: Runtime Error

Solution code:
import sys
def soin(n):
    I=n
    s=0
    R=int(I)
    L=[]
    while s==0:
        for i in range(2,R+1):
            if I%i==0:
                I=I/i
                if I==1:
                    s=1
                L.append(i)
                break
    if len(L)==1:
        print(R)
    else:
        print(L)

n,p= map(int,input().split())
if n==1:
    print(p)
    sys.exit()
l=soin(p)
if len(l)<n:
    print(1)
    sys.exit()
print(l.min())

Submission status: Runtime Error

Solution code:
N = int(input())
a = [0 for i in range(N)]
for i in range(N):
    a[i] = int(input())
dp = [0 for i in range(N + 1)]
dp[0] = 0
for i in range(N):
    dp[i + 1] = (dp[i] + a[i]) % 2
if dp[i] == 1:
    print("first")
elif dp[i] == 0:
    if a[i] % 2 == 0:
        flag = 0
        for i in range(N):
            if a[i] == 1:
                flag = 1
        if flag == 1:
            print("first")
        else:
            print("second")
    else:
        print("first")

Submission status: Runtime Error

Solution code:


if __name__ == '__main__':
    num = int(input())
    # data = [int(input()) for i in range(num)]
    
    ans = 0
    for i in range(num):
        data = input()
        if int(data[-1]) % 2 == 1:
            ans += 1

    if ans+1 % 2 == 0:
        print('second')
    else:
        print('first')

Submission status: Runtime Error

Solution code:
def usage():
    product = 1
    N, P = map(int, input().split())

    fct = factorize(P)

    for i in range(len(fct)):
        fct[i][1] = fct[i][1]//N

        if fct[i][1] >= 1:
            product = product*(fct[i][0]**fct[i][1])
    print(product)
    
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append([b, e])
        b, e = b + 1, 0
    if n > 1:
        fct.append([n, 1])
    return fct

if __name__ == '__main__':
    usage()

Submission status: Runtime Error

Solution code:
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))
pro = 1
for a in A:
    if a:
        pro *= a
if pro % 2 == 1:
    print('first')
else:
    print('second')

Submission status: Runtime Error

Solution code:
N, P = list(map(int, input().split()))

now = 1

x = 2
while P >= x ** N:
    while P % (x ** N) == 0:
        now *= x
        P = P / (x ** N)
    while P % x == 0:
        P = P / x
    x += 1

print(now)

Submission status: Runtime Error

Solution code:

import collections

# def get_lim(n):
#     # for i in range(n):
#     #     if i * i > n:
#     #         return i + 1
#     return pow(10, int((len(str(n)) / 2)))

def prime_factor(n, length):
    ass = collections.defaultdict(int)
    # break_num = pow()
    # for i in range(2,int(n**0.5)+1):
    # lim = get_lim(n)
    for i in range(2, n):
        # print(pow(i, length),  n)
        # if pow(i, length) > n:
        #     break
        if i > n or n == 1:
            break
        print(n, i)
        # i = pow(i, num)
        while n % i==0:
            ass[i] += 1
            n = n//i

    if n != 1:
        ass[n] += 1
    return ass

if __name__ == '__main__':
    length, num = list(map(int, input().split()))

    if length == 1:
        print(num)
    else:

        soinnsuu = prime_factor(num, length)
        ans = 1
        # print(soinnsuu)
        for data in soinnsuu.keys():
            if soinnsuu[data] >= length:
               ans *= data
        print(ans)

Submission status: Runtime Error

Solution code:
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
for i in reversed(range(int(pow(P,(1/N))))+1):
    tmp=i**N
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if P%tmp==0:
        ans=i
        break
print(ans)

Submission status: Runtime Error

Solution code:
n,p=map(int,input().split())

def kouyaku(n,p):
    for i in range(round((p**(1/n)+1)),0,-1):
        if p%i==0:
            if p%(i**n)==0:
                return i
            
print(kouyaku(n,p))

Submission status: Runtime Error

Solution code:

import collections

def prime_factor(n, length):
    ass = collections.defaultdict(int)
    # break_num = pow()
    for i in range(2,int(n**0.5)+1):
        # print(pow(i, length),  n)
        if pow(i, length) > n:
            break
        if i > n or n == 1:
            break
        # i = pow(i, num)
        while n % i==0:
            ass[i] += 1
            n = n//i

    if n != 1:
        ass[n] += 1
    return ass

if __name__ == '__main__':
    length, num = list(map(int, input().split()))

    soinnsuu = prime_factor(num, length)
    ans = 1
    # print(soinnsuu)
    for data in soinnsuu.keys():
        if soinnsuu[data] >= length:
           ans *= data
    print(ans)

Submission status: Runtime Error

Solution code:
N = int(input())
a = [0]*N
r=[0,0]
for i in range(N):
    a[i]=int(input())
a = list(set(a))
for i in a:
    r[i%2]+=1

if r[1]%2==1:
    print("first")
else:
    print("second")

Submission status: Runtime Error

Solution code:
import math

N,P=map(int,input().split())
a=math.sqrt(P)
if N > 3 :
    b=math.sqrt(a)
    a=b

res=1
for i in range(1,int(a)+1):
    if P % i**N: continue
    res = i

print(res)

Submission status: Runtime Error

Solution code:
import math

N,P=map(int,input().split())
a=math.sqrt(P)
if N > 3 : a=math.sqrt(a)

res=1
for i in range(1,int(a)+1):
    if P % i**N: continue
    res = i

print(res)

Submission status: Runtime Error

Solution code:
N, H, W = map(int, input().split())
A = []
B = []
counter = 0
for i in range(0,N):
    a,b  = map(int, input().split())
    if a>H and b>W:
        counter +=1
print(counter)

Submission status: Runtime Error

Solution code:
n,p=map(int,input().split())

i=1
gcd=1
if(n==1):
    print(p)
else:
    while((i**n)<=p):
        if(p%(i**n)==0):
            gcd*=i
            i+=1
    print(gcd)

Submission status: Runtime Error

Solution code:
import math


def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]


N, P = map(int, input().split(' '))
ans = 1
t = 2
while t**N <= P:
    t += 1
prime_nums = primes(t)
for a in prime_nums:
    if P % (a**N) == 0:
        temp = P // (a**N)
        count = 1
        while temp % (a**N) == 0:
            count += 1
            temp // (a**N)
        ans *= a**temp
    elif a**N > P:
        break
print(ans)

Submission status: Runtime Error

Solution code:
N,P = map(int, input().split())

i = 1
ans = 1
if N > 1:
	while P >= i**N:
		if P % i**N == 0:
			ans = i
		i += 1
else:
	ans = P
print(ans)

Submission status: Runtime Error

Solution code:
N, H, W = map(int, input().split())

count=0

for i in range(N):
    A, B = map(int, input().split())
    if (A >= H)&(B >= W):
        count = count + 1

print(count)

Submission status: Runtime Error

Solution code:
n,h,w=map(int, input().split())
c=0
for i in range(n):
  a,b = map(int, input().split())
  if a>=h and b>=w:
    c=c+1
print(c)

Submission status: Runtime Error

Solution code:
a = str(input())
b = 0
for i in range(4):
if a[i]==2:
b=b+1
else:
b=b

print(b)

Submission status: Runtime Error

Solution code:
N = int(input())
ans = 0
for i in range(4)
 a = N%10
 if a==2:
  ans += 1
 N /= 10
print(ans)

Submission status: Runtime Error

Solution code:
a = input()
b = 0
for i in range(len(a)):
if a[i]==2:
b=b+1
else:
b=b
print(b)

Submission status: Runtime Error

Solution code:
text = input()
cnt = 0
if 1000 <= int(text) and int(text) <= 9000:
	for i in range(len(text)):
		if i == "2":
			cnt += 1
		else:
			pass
print (i)

Submission status: Runtime Error

Solution code:
text = input()
cnt = 0
if 1000 <= int(text) and int(text) <= 9000:
	for i in range(len(text)):
		if i == 2:
			cnt += 1
		else:
			pass
print (i)

Submission status: Runtime Error

Solution code:
a = input()
b = 0
for i in range(len(a)):
if a[i]==2:
b=b+1
print(b)

Submission status: Runtime Error

Solution code:
N = map(str,input())
M = [M for M in N]
print(M.count("2")

Submission status: Runtime Error

Solution code:
a = input()
b = 0
for i in range(len(a)):

Submission status: Runtime Error

Solution code:
a = input()
return a.count("2")

Submission status: Runtime Error

Solution code:
s=input()
c=0
if s % 10 ==2:
    c=c+1
s=int((s-(s%10))/10)
if s % 10 ==2:
    c=c+1
s=int((s-(s%10))/10)
if s % 10 ==2:
    c=c+1
s=int((s-(s%10))/10)
if s % 10 ==2:
    c=c+1
s=int((s-(s%10))/10)
print(c)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int INF=999999;
int ans;
int main(){
 string h;
cin>>h;
for(int i=0;i<4;++i){
  if(h[i]=='2') ++ans;
}
cout<<ans<<endl;
}