Problem:


Score : 100 points

Problem Statement

You are given four digits N_1, N_2, N_3 and N_4. Determine if these can be arranged into the sequence of digits "1974".

Constraints

0 \leq N_1, N_2, N_3, N_4 \leq 9

N_1, N_2, N_3 and N_4 are integers.

Input

Input is given from Standard Input in the following format:

N_1 N_2 N_3 N_4

Output

If N_1, N_2, N_3 and N_4 can be arranged into the sequence of digits "1974", print YES; if they cannot, print NO.

Sample Input 1

1 7 9 4

Sample Output 1

YES

We can get 1974 by swapping N_2 and N_3.

Sample Input 2

1 9 7 4

Sample Output 2

YES

We already have 1974 before doing anything.

Sample Input 3

1 2 9 1

Sample Output 3

NO

Sample Input 4

4 9 0 8

Sample Output 4

NO



Sample input:
1 7 9 4


Sample output:
YES

Submission status: Runtime Error

Solution code:
print('YES' if set(map(int, input().split())) == set(1, 9, 7, 4) else 'NO')

Submission status: Runtime Error

Solution code:
a=''.join(list(sorted(list(map(int,input().split())))))
if(a=='1479'):
	print('YES')
else:
	print('NO')

Submission status: Runtime Error

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

c = [1,,4,7,9]

if s == c:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
n1, n2, n3, n4=map(int,input().split())
n=[]
n.append(n1, n2, n3, n4)
if 1, ,7 ,9, 4 in n:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
n = list(input().split())
print(n)

if n in ('1'):
    if n in ('9'):
        if n in ('7'):
            if n in ('4'):
                print('YES')
                exit(0)

print('NO')

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = set(I())
if N == {1,7,9,4}:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
n = list(map(int,input().split()))
n.sort()
ans = ''.join(n)

if ans == 1479:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
n=sorted(list(map(int,input().split())))
if n=[1,4,7,9]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
var = [int(input()) for _ in range(4)]
var.sort()
print("Yes" if var == [1,4,7,9] else "No")

Submission status: Runtime Error

Solution code:
a=list(map(int,input().split()))
a,sort()
if a==[1,4,7,9] :
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

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

int main(){
  long N1, N2, N3, N4;
  char ans;
  cin >> N1 >>N2 >>N3 >>N4;
  int c;
  c=0;
  if(N1 == 1 || N2 == 1 || N3 == 1 || N4 == 1){
      c++;

  }
  if(N1 == 9|| N2 == 9 || N3 == 9 || N4 == 9){
      c++;

  }
  if(N1 == 7 || N2 == 7 || N3 == 7 || N4 == 7){
      c++;

  }
  if(N1 == 4 || N2 == 4 || N3 == 4 || N4 == 4){
      c++;

  }
  if(c==4){
    cout <<"YES";
  }
  else
  {
    cout << "NO";
  }
  return 0;
}

Submission status: Runtime Error

Solution code:
n = list(map(int,input().split()))
if n.sorted() == [1,4,7,9]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  vector<int> n(4);
  for (auto &x: n) cin >> x;

  sort(n.begin(), n.end());
  if (n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }

  return 0;
}

Submission status: Runtime Error

Solution code:
A=set(list(map(int,input().split())))
print('YES' if A==set(list(1,9,7,4)) else 'NO')

Submission status: Runtime Error

Solution code:
def solve():
    MOD = 10 ** 9 + 7
    N, M = map(int, input().split())
    A = set(map(int, input().split()))
    B = set(map(int, input().split()))
    
    row, columun = 0, 0
    ans = 1
    for i in range(N * M, 0, -1):
        in_A = i in A
        in_B = i in B
        if in_A and in_B:
            row += 1
            columun += 1
        elif in_A:
            row += 1
            ans *= columun
        elif in_B:
            columun += 1
            ans *= row
        else:
            ans *= row * columun - (N * M - i)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
import sys
N, M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]

A.sort(reverse=True)
B.sort(reverse=True)

if len(set(A))!=len(A) or len(set(B))!=len(B):
    print(0)
    sys.exit()

ans = 1
rows, columna = 0,0
mod = 10**9+7
for x in range(N*M, 0, -1):

    if x in A and x in B:
        rows += 1
        columna += 1

    elif x in A and not x in B:
        rows += 1
        ans = ans * (columna)

    elif x in B and not x in A:
        columna += 1
        ans = ans *(rows)

    else:
        ans = ans * (rows * columna -(N*M-x

    ans %= mod    

print(ans%(10**9+7))

Submission status: Runtime Error

Solution code:
l=sorted(list(map(int,input(.split()))))
if l==[1,9,7,4]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
#coding:utf-8
n1, n2, n3, n4 = map(str, input().split())
n = ''.join(n1, n2, n3, n4)

if '1'.count(n) == 1 and '9'.count(n) == 1 and '7'.count(n) == 1 and '4'.count(n) == 1:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
n1, n2, n3, n4 = int(input()), int(input()), int(input()), int(input())

if set(n1, n2, n3, n4) == {1, 4, 7, 9}:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
def main();
	nums = sys.stdin.readline().split()
  	numset = set(nums)
    if numset == {1, 4, 7, 9}:
      return "YES"
    else:
      return "NO"

Submission status: Runtime Error

Solution code:
def main();
	nums = sys.stdin.readline().split()
  	nums.sort()
    if list(nums) == [1, 4, 7, 9]:
      return "YES"
    else:
      return "NO"

Submission status: Runtime Error

Solution code:
def main();
	nums = sys.stdin.readline().split()
  	nums.sort()
    if nums == [1, 4, 7, 9]:
      return "YES"
    else:
      return "NO"

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0index
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1index
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからb - 1まで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //逆
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;  //最大値兼MOD
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }  //GCD
int dp[100010][3];
int a[100010][3];
int main(){
    vector<int>a(4);
    vector<int>b(4);
    a = {1,4,7,9};
    rep0(i,4)cin >> b[i];
    sort(all(b));
    if(a == b){
        cout <<"YES"<< endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Submission status: Runtime Error

Solution code:
l = sorted(map(int, input().split()))
if ''.join(l) == '1479':
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
n = list(map(int, input().split()))
if 1 in n:
  if 4 in n:
    if 7 in n:
      if 9 in n:
        print(‘YES’)
        exit()
print(‘NO’)

Submission status: Runtime Error

Solution code:
n = map(int, input().split())
if 1 in n:
  if 4 in n:
    if 7 in n:
      if 9 in n:
        print(‘YES’)
        exit()
print(‘NO’)

Submission status: Runtime Error

Solution code:
    n = input()
    if "1" in n and "9" in n and "7" in n and "4" in n:
        print("YES")
    else:
        print("NO")

Submission status: Runtime Error

Solution code:
a,b,c,d=int(input()).split()
list=[a,b,c,d]
sort(list)
if list==[1,4,7,9]:
	print('YES')
else:
	print('NO')

Submission status: Runtime Error

Solution code:
a,b,c,d=int(input().split())
list=[a,b,c,d]
sort(list)
if list==[1,4,7,9]:
	print('YES')
else:
	print('NO')

Submission status: Runtime Error

Solution code:
n= sort(list(int,input().split()))
if n == [1,7,9,4]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
n=list(int,input().split())
if n==[1,4,7,9]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
a=list(sort(list(int,input().split())))
if a==[1,4,7,9]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
a=sorted(list(int,input().split()))
if a==[1,4,7,9]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
n = list(int,input().split())
if 1 in n and 9 in n and 7 in n and 4 in n:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
n = int(input())
if 1 in n and 9 in n and 7 in n and 4 in n:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
n = int(input.()split())
if 1 in n and 9 in n and 7 in n and 4 in n:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
N = [int(i) in input().split()]
res = "NO"
if 1 in N and 9 in N and 7 in N and 4 in N:
  res = "YES"

print(res)

Submission status: Runtime Error

Solution code:
a,b,c,d=map(int,input().split())
arr[a,b,c,d]
if arr.count('1')==1 and arr.count('9')==1 and arr.count('7')==1 and arr.count('4')==1:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
N = [int(_) for _ in input().split()]
S = "".join(sorted(N))
print("YES" if S == 1479 else "NO")

Submission status: Runtime Error

Solution code:
import numpy as np

N = input()
a = input().split()
b = input().split()
A = []
B = []
for k in range(0,len(a)):
    A.append(int (a[k]))
    B.append(int (b[k]))

#A = [2,3,5]
#B = [3,4,1]

sum_A = sum(A)
sum_B = sum(B)

#print(sum_A)
#print(sum_B)

sub_AB = []
List = []

if (sum_A>sum_B) :
    for i in range(0,len(A)) :
        sub = A[i]-B[i]
        sub_AB.append(sub)
        if (sub<0) :
            List.append(sub)
        else :
            continue
    sum_List = sum(List)            
    Max = max(sub_AB)
    delta = Max + sum_List
    
    sub_AB.sort()
    sub_AB.reverse()
    count_a = 0
    while (sub_AB[-1]<0):
        sub_AB.pop()
        count_a+=1 
    if (count_a==0):
        print(0)
        exit()

    count_b = 1

    while (sum_List+max(sub_AB)<=0):
        sub_AB.remove(max(sub_AB))
        count_b+=1

    count = count_a+count_b
    print(count)

else :
    print(-1)
    exit()

"""
    sub_AB.sort()
    sub_AB.reverse()
    count_a = 0
    while (sub_AB[-1]<0):
        sub_AB.pop()
        count_a+=1 
    if (count_a==0):
        print(0)
        exit()
    
    count_b = 0

    print(max(sub_AB))

    if (max(sub_AB)==None):
        pass
    else :
        while (sum_List+max(sub_AB)>=0):
            sub_AB.remove(max(sub_AB))
            count_b+=1

        count = count_a+count_b
        print(len(A)-count)

else :
    print(-1)
"""

Submission status: Runtime Error

Solution code:
        if set(input().split())==set("1974"):
          print("Yes")
        else:
          print("No")

Submission status: Runtime Error

Solution code:
    if set(input().split())==set([1,9,7,4]):
      print("Yes")
    else:
      print("No")

Submission status: Runtime Error

Solution code:
if set(input().split())==aet([1,9,7,4]):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
s1, s2, s3, s4 = input().split()
aru = "NO"
for junjo in permutations((s1, s2, s3, s4)):
  if junjo[0] + junjo[1] + junjo[2] + junjo[3] == "1974":
    aru = "YES"
    break
  
print(aru)

Submission status: Runtime Error

Solution code:
print('YES' if input().split().sort()==['1','4','7','9'])

Submission status: Runtime Error

Solution code:
a=[int(i) for i in input().split(" ")]
kouho=[1,9,7,4]
for k in a:
	if k in kouho:
        kouho.pop(k)
if kouho==[]:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
int aa[10];
int a,b,c,d;
signed main()
{
	rep(i,4){
		cin>>aa[i];
		if(aa[i]==1){
			a++;
		}elif(aa[i]==4){
			b++;
		}elif(aa[i]==7){
			c++;
		}elif(aa[i]==9){
			d++;
		}
	}
	if(a==1&&b==1&&c==1&&d==1){
		cout<<"YES";
	}else{
		cout<<"NO";
	}
}

Submission status: Runtime Error

Solution code:
get=input()
get = get.split(" ")
flg=0
get=list(set(get))
for a in :
  if int(a) in[1,9,7,4]:
    flg+=1
    
if flg==4:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
get=input()
flg=0
get = list(set(get))
for a in get.split(" "):
  if int(a) in[1,9,7,4]:
    flg+=1
    
if flg==4:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
get=input()
flg=0
for a in get.split():
  if int(a) in[1,9,7,4]
	flg+=1

 if flg==4:
  print("YES")
 else:
  print("NO")

Submission status: Runtime Error

Solution code:
get=raw_input()
print("YES")

Submission status: Runtime Error

Solution code:
if list(map(int,inpust().split())).sort()==[1,4,7,9]:print("YES")
else:print("NO")

Submission status: Runtime Error

Solution code:
import sys

"""テンプレ"""

# 高速
input = sys.stdin.readline

# 1行を空白でリストにする(int)
def intline():
    return list(map(int, input().split()))


# 上のstrヴァージョン
def strline():
    return list(map(str, input().split()))


# 1列に並んだ数
def intlines(n):
    return [int(input() for _ in range(n))]


# 上の文字列ヴァージョン
def lines(n):
    return [input() for _ in range(n)]
    

"""ここからメインコード"""

k = intline().sort()
if k = [1, 4, 7, 9]:print("YES")
else:print("NO")

Submission status: Runtime Error

Solution code:
def data_input():
    a,b,c,d = input().split(' ')
    a = int(a)
    b = int(b)
    c = int(c)
    d = int(d)
    return (a,b,c,d)
def answer():
    a,b,c,d = data_input()
    s = '1974'
    return a in s and b in s and c in s and d in s
answer()

Submission status: Runtime Error

Solution code:
def data_input():
    a,b,c,d = input().split(' ')
    a = int(a)
    b = int(b)
    c = int(c)
    d = int(d)
    return (a,b,c,d)

def answer():
    a,b,c,d = data_input()
    s = '1974'
    return if a in s and b in s and c in s and d in s

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys

class YearNumberJudger:

    def __init__(self):
        self.input_num_list = []

    def input(self, num):
        self.input_num_list.append(num)

    def result(self):
        if len(self.input_num_list) != 4:
            return 'NO'
        input_map = {}
        for num in self.input_num_list:
            input_map[num] = True
        if 1 not in input_map:
            return 'NO'
        if 9 not in input_map:
            return 'NO'
        if 7 not in input_map:
            return 'NO'
        if 4 not in input_map:
            return 'NO'
        return 'YES'

if __name__ == "__main__":
    year_number_judger = YearNumberJudger()
    for i in range(4):
        num = int(input())
        year_number_judger.input(num)
    print(year_number_judger.result())

Submission status: Runtime Error

Solution code:
if {input().split()} == {"1", "9", "7", "4"}:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
output_word = "YES"
set_1974 = (1,9,7,4)

for i in range(4):
  if int(input()) not in set_1974:
	output_word = "NO"
    
print(output_word)

Submission status: Runtime Error

Solution code:
l = map(int, raw_input().split())
set_1974 = (1,9,7,4)

output_word = "YES"
for i in l:
  if i not in set_1974:
    output_word = "NO"
print(output_word)

Submission status: Runtime Error

Solution code:
N = set(input())
A = set('1974')
print('YES if N==A else 'NO')

Submission status: Runtime Error

Solution code:
s = list(map(int, input()))
if list(sorted(s)) == [1, 4, 7, 9]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
s = list(map(int, input()))
if sorted(s) == [1, 4, 7, 9]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
s = list(map(int, input()))
if s == [1, 4, 7, 9]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
s = list(map(int, input()))
t = [1, 4, 7, 9]
[t.pop() for i in sorted(s) if i in t]
if len(t) == 4:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
a = [False,False,False,False]
for x in input().split():
  if(x == 1):
    a[0] =True
  else if(x == 9):
    a[1] = True
  else if(x == 4):
    a[2] = True
  else if(x == 7):
    a[3] = True

all = True
for x in a:
  all &= x

print('YES' if all else 'NO')

Submission status: Runtime Error

Solution code:
N = int(input())
A =  []
l1 = input().split()
for i in l1:
    A.append(int(i))
B = []
l2 = input().split()
for i in l2:
    B.append(int(i))
if sum(A) < sum(B):
    print(-1)
else:
    z = 0
    ar1 = []
    ar2 = []
    for i in range(N):
        if A[i] < B[i] :
            ar1.append(B[i] - A[i])
        if A[i] > B[i]:
            ar2.append(A[i] - B[i])
    if len(ar1) == 0:
        print(0)
    else:
        s = sum(ar1)
        ar2.sort(reverse = True)
        temp = 0
        b = 0
        for  i in range(len(ar2)):
            temp += ar2[i]
            if temp >= s:
                b = i+1
                break
        print(len(ar1)+b)

Submission status: Runtime Error

Solution code:
N = int(input())
A =  []
l1 = input().split()
for i in l1:
    A.append(int(i))
B = []
l2 = input().split()
for i in l2:
    B.append(int(i))
if sum(A) < sum(B):
    print(-1)
else:
    z = 0
    ar1 = []
    ar2 = []
    for i in range(N):
        if A[i] < B[i] :
            ar1.append(B[i] - A[i])
        if A[i] > B[i]:
            ar2.append(A[i] - B[i])
    if len(ar1) == 0:
        print(0)
    else:
        ar2.sort(reverse = True)
        temp = 0
        b = 0
        for  i in range(len(ar2)):
            temp += ar2[i]
            if temp >= sum(ar1):
                b = i+1
                break
        print(len(ar1)+b)

Submission status: Runtime Error

Solution code:
N = int(input())
A =  []
l1 = input().split()
for i in l1:
    A.append(int(i))
B = []
l2 = input().split()
for i in l2:
    B.append(int(i))
if sum(A) < sum(B):
    print(-1)
else:
    z = 0
    ar1 = []
    ar2 = []
    for i in range(N):
        if A[i] < B[i] :
            ar1.append(B[i] - A[i])
        if A[i] > B[i]:
            ar2.append(A[i] - B[i])
    ar1.sort(reverse = True)
    ar2.sort(reverse = True)
    b = 0
    for a in ar1:
        while a > ar2[b]:
            ar2[b] = 0
            a -= ar2[b]
            b += 1
        ar2[b] -= a
        ar2.sort(reverse = True)
        if a == ar1[-1] and ar2[b] != 0:
            z = 1
    ans = 0
    for i in ar2:
        if i == 0:
            z +=1
    ans = len(ar1) + z
    print(ans)

Submission status: Runtime Error

Solution code:
L = list(map(int, input().split()))
L.sort()
if L == [1, 4, 7, 9]:
  print(YES)
else:
  print(NO)

Submission status: Runtime Error

Solution code:
L = list(map(int, input().split()))
L.sort()
if L == [1, 4, 7, 9]:
	print(YES)
else:
  	print(NO)

Submission status: Runtime Error

Solution code:
s = set(list(map(int, input().split(' '))))
if s == set([1,9,7,4]):
    print(YES)
else:
    print(NO)

Submission status: Runtime Error

Solution code:
import numpy as np

N, M = list(map(int, input().split(" ")))
A_list = np.sort(np.asarray(list(map(int, input().split(" ")))))[::-1]
B_list = np.sort(np.asarray(list(map(int, input().split(" ")))))[::-1]

out = 1
a_next_i = 0
b_next_i = 0
for x in range(N*M, 1, -1):
    cond1 = a_next_i < N and x == A_list[a_next_i]
    cond2 = b_next_i < M and x == B_list[b_next_i]
    if cond1 and cond2:
        kosuu = 1
        a_next_i += 1
        b_next_i += 1
    elif cond1:
        kosuu = b_next_i
        a_next_i += 1
    elif cond2:
        kosuu = a_next_i
        b_next_i += 1
    else:
        kosuu = a_next_i * b_next_i - (N * M - x)
    out *= kosuu
    out = out % 1000000007
   
print(out)

Submission status: Runtime Error

Solution code:
import numpy as np

InputData1 = input()
InputData2 = input()

Lines = [data.split(" ") for data in [InputData1, InputData2]]
InputNumbers = [int(numbers) for line in Lines for numbers in line]

N = InputNumbers[0]
D = InputNumbers[1]
A = InputNumbers[2:]
# print(N, D, A)


def NetworkMatrix(Num, vector):
    matrix = np.empty((Num, Num))
    for i in range(Num):
        ai = np.empty(Num)
        for j in range(Num):
            if i < j:
                aij = (j-i)*D + vector[i] + vector[j]
            else:
                aij = 0
            ai[j] = aij
        matrix[i] = ai
    return matrix

def Explore(Num, matrix):
    ResultMatrix = matrix
    for i in range(Num):
        # ResultVector[i] = min(matrix.T[i])
        for j in range(Num):
            for k in range(Num):
                if i < j and j < k and min([matrix[i,j], matrix[j,k], matrix[i,k]]) != 0:
                    if matrix[i,j] >= matrix[j,k] and matrix[i,j] >= matrix[i,k]:
                        ResultMatrix[i,j] = 0
                    elif matrix[j,k] > matrix[i,j] and matrix[j,k] >= matrix[i,k]:
                        ResultMatrix[j,k] = 0
                    elif matrix[i,k] > matrix[i,j] and matrix[i,k] > matrix[j,k]:
                        ResultMatrix[i,k] = 0
    if np.sum(ResultMatrix != matrix) != 0:
        ResultMatrix = Explore(Num, matrix)
    return ResultMatrix

    



Matrix = NetworkMatrix(N, A)
# print(Matrix)
# Raveled = Matrix.ravel()
# Answer = sum(sorted(Raveled)[:N-1])
AnswerMatrix=Explore(N, Matrix)
# print(AnswerMatrix)
print(int(np.sum(AnswerMatrix)))

Submission status: Runtime Error

Solution code:
import operator

def solve(A, B):
  diff = list(map(operator.sub, A, B))
  shortage  = list(filter(lambda d: d < 0, diff))
  remainder = list(filter(lambda d: d > 0, diff))
  remainder.sort(reverse=True)
  short_sum = sum(shortage)
  if short_sum == 0: return 0
  counter = len(shortage)
  for r in remainder:
    short_sum += r
    counter += 1
    if short_sum >= 0: return counter
  return -1

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

print(solve(A, B))

Submission status: Runtime Error

Solution code:
#問題D
M,N = list(map(int,input().split())) 
ROW = list(map(int,input().split())) 
COL = list(map(int,input().split())) 
#M= 3
#N= 3 
#ROW = [8,9,7]
#COL = [6,9,8]
#N,M = 14,13
#ROW = [158, 167, 181, 147, 178, 151, 179, 182, 176, 169, #180, 129, 175, 168]
#COL = [181, 150, 178, 179, 167, 180, 176, 169, 182, 177, #175, 159, 173]
import numpy as np
row = 0
col = 0
nums = np.arange(1,M*N+1)[::-1]
pattern = np.zeros(M*N)
ans = 1
#print(nums)
for i in nums:
    if i in ROW and i in COL:
        row += 1
        col += 1
#        pattern[i-1] = 1
    elif i in ROW and i not in COL:
        row += 1
#        pattern[i-1] = col
        ans *= col
    elif i not in ROW and i in COL:
        col += 1
#        pattern[i-1] = row
        ans *= row

    elif i not in ROW and i not in COL:
#        pattern[i-1] = row * col - (M*N-i)
        ans *= (row * col - (M*N-i))
       
        if row * col - (M*N-i) <= 0:
            ans = 0
            break
    ans %= (10**9+7)
#    print(i,row,col,pattern[i-1])
#print(pattern)
#ans = int(pattern.prod())
#ans = ans % (10**9+7)
print(ans)

Submission status: Runtime Error

Solution code:
import math
a = 0
input_str = input()
input_str_list = []
for x in input_str:
    try:
       input_str_list.append(int(x))
    except:
       pass
if len(input_str_list) == 4:
  pass
else:
  print("NO")
  exit()

if math.modf(float(input_str))[0] == 0.0:
  pass
else:
  print("NO")
  exit()
  

for i in range(len(input_str)):
  if input_str[i] == '1':
    a+=1
  elif input_str[i] == '9':
    a+=1
  elif input_str[i] == '7':
    a+=1
  elif input_str[i] == '4':
    a+=1
if a==4:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline

N = list(map(int, input().split())).sorted()
if N[0] == 1 and N[1] == 4 and N[2] == 7 and N[3] == 9:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
import math 

a = 0
input_flo = float(input())
if math.modf(input_flo)[0] == 0.0:
  if len(str(int(input_flo))) == 4:
    input_str=str(int(input_flo))    
  else:
    print("NO")
    exit()
else:
  print("NO")
  exit()

for i in range(len(input_str)):
  if input_str[i] == '1':
    a+=1
  elif input_str[i] == '9':
    a+=1
  elif input_str[i] == '7':
    a+=1
  elif input_str[i] == '4':
    a+=1
    
if a==4:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
num_list=(1479,1497,1749,1794,1947,1974,4179,4197,4719,4791,4917,4971,7149,7194,7419,7491,7914,7941,9147,9174,9417,9471,9714,9741)
n="N1"+"N2"+"N3"+"N4"
for i in num_list:
   if n=i:
      print("yes")
   if n!=i:
      print("no")

Submission status: Runtime Error

Solution code:
from bisect import bisect
def inpl(): return list(map(int, input().split()))
MOD = 10**9 + 7
N, M = inpl()
A = sorted(inpl())
B = sorted(inpl())

A_set = set(A)
B_set = set(B)

ans = 1
for x in range(N*M, 0, -1):
    if (x in A_set) and (x in B_set):
        tmp = 1
    elif x in A_set:
        tmp = max(M - bisect(B, x), 0)%MOD
    elif x in B_set:
        tmp = max(N - bisect(A, x), 0)%MOD
    else:
        a = bisect(A, x)
        b = bisect(B, x)
        tmp = max(x - N*b - M*a + a*b, 0)%MOD
    ans = (tmp*ans)%MOD

print(ans)

Submission status: Runtime Error

Solution code:
import random
N1=random.choice(0,1,2,3,4,5,6,7,8,9)
N2=random.choice(0,1,2,3,4,5,6,7,8,9)
N3=random.choice(0,1,2,3,4,5,6,7,8,9)
N4=random.choice(0,1,2,3,4,5,6,7,8,9)
list_1=(N1,N2,N3,N4)
number=(1,4,7,9)
for i in number:
   if i in list_1:
      an="yes"
   if i not in list_1:
      an="no"
print(an)

Submission status: Runtime Error

Solution code:
import numpy as np

N = int(input())

A = np.array(list(map(int, input().split())))
B = np.array(list(map(int, input().split())))

c = np.sort(A) > np.sort(B)
if np.sum(c) != N:
  print("NO")
else:
  print("YES")

Submission status: Runtime Error

Solution code:
a = 0
input_str = input()
if int(input_str)//10000 >=1:
  print("NO")
  exit()
for i in range(len(input_str)):
  if input_str[i] == '1':
    a+=1
  elif input_str[i] == '9':
    a+=1
  elif input_str[i] == '7':
    a+=1
  elif input_str[i] == '4':
    a+=1
if a==4:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
import numpy as np
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A = np.array(A)
B = np.array(B)
if np.sum(A) < np.sum(B):
    print(-1) 
else:
    sub_a_b = A-B
    p_sub = sorted(list(sub_a_b[sub_a_b>0]),reverse = True)
    # print(p_sub)  
    m_sub = list(sub_a_b[sub_a_b<0])
    max_counter = p_sub[0]
    m_sub_sum = abs(sum(m_sub))
    count = 1 + len(m_sub) 
    # print(p_sub[0:1])
    for i in range(len(p_sub)):
        if max_counter >= m_sub_sum:
            print(count)
            exit()
        else:
            max_counter += p_sub[i+1]
            count += 1

Submission status: Runtime Error

Solution code:
str_input_list = input().rstrip().split(' ')
int_input_list = []
for a in str_input_list:
    int_input_list.append(int(a))
    
keyence_list = [1, 9, 7, 4]

for a in range(4):
    if keyence_list[a] in int_input_list:
        keyence_list.remove(keyence_list[a])
        int_input_list.remove(keyence_list[a])

if keyence_list == []:
    print('YES')
else:
    print('NO')