akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;
use std::cmp::min;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let a: Vec<u64> = (0..9).into_iter().map(|_| read()).collect();
    let mut filled: Vec<bool> = (0..9).into_iter().map(|_| false).collect();
    let n: u64 = read();
    for _ in 0..n {
        let b: u64 = read();
        for i in 0..9 {
            if a[i] == b {
                filled[i] = true;
            }
        }
    }

    let mut ret = false;
    for i in 0..3 {
        let mut tmp = true;
        for j in 0..3 {
            if !filled[i * 3 + j] {
                tmp = false;
            }
        }
        if tmp {
            ret = true;
        }
        tmp = true;
        for j in 0..3 {
            if !filled[j * 3 + i] {
                tmp = false;
            }
        }
        if tmp {
            ret = true;
        }
    }

    let mut tmp = true;
    for i in 0..3 {
        if !filled[i * 4] {
            tmp = false;
        }
    }
    if tmp {
        ret = true;
    }

    tmp = true;
    for i in 0..3 {
        if !filled[i * 2 + 2] {
            tmp = false;
        }
    }

    if tmp {
        ret = true;
    }

    if ret {
        println!("Yes");
    } else {
        println!("No");
    }
}
// 2 4 6


Measured memory_bytes: 4352
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    ls = []
    for i in range(n):
        ka = list(map(int, input().rstrip('\n').split()))
        for j in range(1, ka[0] + 1):
            ls.append(ka[j])
    ls = collections.Counter(ls)
    cnt = 0
    for k, v in ls.items():
        if v == n:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

bool isleft(string s, int m){
	int n = s.length();
	int x = 0, y = 0;
	REP(i,m) if (s[i] == '>') x++;
	FOR(i,m+1,n-1) if (s[i] == '<') y++;
	if (s[m] == '>') return y > x;
	else return y >= x;
}

int calc(string s, int m){
	int n = s.length();
	int res1 = 0, res2 = 0;
	if (m >= 0){
		int x = 0;
		REP(i,m+1) if (s[i] == '>') x++;
		int y = 0;
		if (s[m] == '<') y = -1;
		for (int i = m; y < x; i++){
			if (s[i] == '<') y++;
			if (y >= x){
				res1 = i+1;
				break;
			}
		}
	}
	m++;
	if (m < n){
		int x = 0;
		FORR(i,n-1,m) if(s[i] == '<') x++;
		int y = 0;
		if (s[m] == '>') y = -1;
		for (int i = m; y < x; i--){
			if (s[i] == '>') y++;
			if (y >= x){
				res2 = n-i;
				break;
			}
		}
	}

	return max(res1, res2);
}

int main(){
	int n;
	string s;
	cin >> n >> s;

	int l = -1, r = n;
	while (r - l > 1){
		int m = (l+r)/2;
		if (isleft(s, m)) l = m;
		else r = m;
	}

	cout << calc(s, l) << endl;

    return 0;
}

Measured memory_bytes: 3280
import collections

words = []
number = int(input())
for i in range(number):
    word = input()
    words.append(word)
new = collections.Counter(words)
most = max(new.values())
ans = new.most_common()
answer = []
for i in ans:
    if i[1] >= most:
        answer.append(i[0])
    else:
        pass
answer.sort()
for i in answer:
    print(i)

Measured memory_bytes: 47668
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

template<int mod>
struct mint {
private:
    long long x;
public:
    mint(long long x = 0) :x(x%mod) {}
    mint(std::string s) {
        long long z = 0;
        REP(i, s.size()) {
            z *= 10;
            z += s[i] - '0';
            z %= mod;
        }
        this->x = z;
    }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    friend std::ostream& operator<<(std::ostream& os, const mint& n) {
        return os << n.x;
    }
    bool operator==(const mint a) const {
        return this->x == a.x;
    }
};

//pow
template<typename T, typename U>
T pow(T k, U n, T unity = 1) {
    while (n > 0) {
        if (n & 1) {
            unity *= k;
        }
        k *= k;
        n >>= 1;
    }
    return unity;
}

int main() {
    string s; cin >> s;
    int n = s.size();
    const int mod = 1e9 + 7;
    vector<mint<mod>> a(n+1,0), b(n+1,0), c(n+1,0);
    int cnt = 0;
    REP(i, n) {
        if (s[i] == 'A') {
            a[i + 1] = a[i] + pow(mint<mod>(3), cnt);
            b[i + 1] = b[i];
            c[i + 1] = c[i];
        }
        else if (s[i] == 'B') {
            a[i + 1] = a[i];
            b[i + 1] = a[i] + b[i];
            c[i + 1] = c[i];
        }
        else if (s[i] == 'C') {
            a[i + 1] = a[i];
            b[i + 1] = b[i];
            c[i + 1] = c[i] + b[i];
        }
        else {
            a[i + 1] = a[i] * 3 + pow(mint<mod>(3), cnt);
            b[i + 1] = a[i] + b[i] * 3;
            c[i + 1] = b[i] + c[i] * 3;
            cnt++;
        }
    }
    cout << c[n] << endl;
    return 0;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    int N;
    cin >> N;
    double ans = (N%2) ? N/2 + 1 : N/2;
    cout << setprecision(10) << ans/(double)N << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define eps LDBL_EPSILON
#define moder 1000000007
#define int long long
#define ll long long
#define double long double
#define INF LLONG_MAX/10000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
signed main() {
	string s;
	cin >> s;
	int a = stoi(s.substr(0, 2)), b = stoi(s.substr(2, 2));
	if ((a > 12 || a == 0) && (b > 12 || b == 0))puts("NA");
	else if ((a <= 12 && a != 0) && (b <= 12 && b != 0))puts("AMBIGUOUS");
	else if ((a > 12 || a == 0) && (b <= 12 && b != 0))puts("YYMM");
	else puts("MMYY");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int c = sc.nextInt();
      int k = sc.nextInt();
      int[] t = new int[n];
      for(int i = 0;i < n;i++)t[i]=sc.nextInt();
      Arrays.sort(t);
      int cnt = 0;
      int sum = 0;
      for(int i = 0;i < n;){
        cnt = 0;
        int time = t[i];
      	while(i<n&&time+k>=t[i]&&cnt<c){
        	i++;
            cnt++;
        }
        sum++;
      }
      System.out.println(sum);
    }
}

Measured memory_bytes: 50380
#include<iostream>
#include<string>
using namespace std;
int c[1000005];
int s1[1000005];
int s2[1000005];
int main()
{
    string s;
    cin>>s;
    int ls=s.length();
    for(int i=0;i<ls;i++)
    {
        c[i]=s[i]-'0';
        s1[i]=i%2;
        s2[i]=(i+1)%2;
    }
    int n1=0,n2=0;
    for(int i=0;i<ls;i++)
    {
        if(c[i]!=s1[i]) n1++;
        if(c[i]!=s2[i]) n2++;
    }
    if(n1>n2) cout<<n2<<endl;
    else cout<<n1<<endl;
}


Measured memory_bytes: 9088
#include<stdio.h>

int main(){
	int a,b,i;
	char s[11];
	scanf("%d%d",&a,&b);
	scanf("%s",s);
	for(i=0;i<a;i++){
		if(s[i]!='0' && s[i]!='1' && s[i]!='2' && s[i]!='3' && s[i]!='4' && s[i]!='5' && s[i]!='6' && s[i]!='7' && s[i]!='8' && s[i]!='9'){
			printf("No\n");
			return 0;
		}
	}
	if(s[i]!='-'){
		printf("No\n");
			return 0;
	}
	for(i=1;i<=b;i++){
		if(s[a+i]!='0' && s[a+i]!='1' && s[a+i]!='2' && s[a+i]!='3' && s[a+i]!='4' && s[a+i]!='5' && s[a+i]!='6' && s[a+i]!='7' && s[a+i]!='8' && s[a+i]!='9'){
			printf("No\n");
			return 0;
		}
	}
	
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long arr[1000007];
long long cs[1000007];
long long ps[1000007];

int main()
{
    int n;
    cin>>n;

    for(int i=1; i<=n; i++)
    {

        cin>>arr[i];
    }
    sort(arr+1,arr+1+n);
    int cnt=0;

    for(int i=1; i<=n; i++)
    {
        for(int j=i+1; j<=n; j++)
            for(int k=j+1; k<=n; k++)
            {
                if(arr[i]!=arr[j] && arr[j]!=arr[k] && arr[i]!=arr[k])
                {
                    if(arr[i]+arr[j]>arr[k])
                        cnt++;
                }

            }
    }

    cout<<cnt<<endl;


    return 0;

}












Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> k(M);
    vector<vector<int>> s(M);
    for(int i=0; i<M; ++i) {
        cin >> k[i];
        s[i].resize(k[i]);
        for(int j=0; j<k[i]; ++j) {
            cin >> s[i][j];
            --s[i][j];
        }
    }
    vector<int> p(M);
    for(int i=0; i<M; ++i) cin >> p[i];

    int res = 0;
    for(int sw = 0; sw < (1 << N); ++sw) {
        ++res;
        for(int i=0; i<M; ++i) {
            int on = 0;
            for(int j=0; j<k[i]; ++j) {
                on += (sw >> s[i][j]) & 1;
            }
            if(on % 2 != p[i]) {
                --res;
                break;
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;

template <class T>
int numLT(const vector <T>& v, T x)
{
	return lower_bound(v.begin(), v.end(), x) - v.begin();
}

int main()
{
	int n;

	cin >> n;

	vector <int> p(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> p[i];
	}

	sort(p.begin(), p.end());

	int cnt = 0;
	for (int i = 1; i <= 100000 ; ++i)
	{
		if (numLT(p, i) == n / 2)
		{
			cnt++;
		}
	}


	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main (){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x-r<0 || x+r>W || y-r<0 || y+r>H){ printf("No\n");
  }else{printf("Yes\n");}
  return 0;
}

Measured memory_bytes: 584
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int x = in.nextInt();
        int sum = 0;
        for (int i = 0; i <= a; i++){
            for (int j = 0; j <= b; j++){
                for (int l = 0; l <= c; l++){
                    if (i*500 + j*100 + l*50 == x){
                        sum++;
                        break;
                    }
                }
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 23252
c11,c12,c13 = map(int,input().split())
c21,c22,c23 = map(int,input().split())
c31,c32,c33 = map(int,input().split())
count = 0
if c21 - c11 == c22 - c12 == c23 - c13:
  count += 1
if c31 - c21 == c32 - c22 == c33 - c23:
  count += 1
if c12 - c11 == c22 - c21 == c32 - c31:
  count += 1
if c13 - c12 == c23 - c22 == c33 - c32:
  count += 1
if count == 4:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    String key = "keyence";
    int i = 0;

    while (i < 7) {
      if (s.charAt(i) == key.charAt(i)) {
        i++;
      } else {
        break;
      }
    }

    int rest = 7 - i;

    while (rest > 0) {
      if (s.charAt(s.length() - rest) == key.charAt(key.length() - rest)) {
        rest--;
      } else {
        System.out.println("NO");
        return;
      }
    }

    System.out.println("YES");

  }
}

Measured memory_bytes: 35812
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#include<string>
#define ll long long
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<ll>
#define el printf("\n")
#define N 100001
using namespace std;



int main()
{   IOS;
cout.precision(30);
    ll n;
    cin >> n;
    vector<ll> L1,L;
    for(int i=0;i<n;i++)
    {
        ll x;
        cin >> x;
        L.push_back(x);
    }
    L1=L;
    sort(L1.begin(),L1.end());
    ll res=0;
    for(int i=0;i<n;i++)
        {
            if (L[i]!=L1[n-1])
                cout << L1[n-1];
            else if(L[i]==L1[n-1] )
                cout << L1[n-2];

            cout << "\n";
        }



    return 0;
}


Measured memory_bytes: 4848
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
--import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Fixed
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import Text.Printf
import System.IO
-- import System.IO.Unsafe
 
-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
whenM :: Monad m => m Bool -> m () -> m ()
whenM c a = c >>= flip when a
unconsU :: [a] -> (a, [a])
unconsU (x:xs) = (x, xs)
-- templete


main = do
    [n,k] <- getInts
    unless (n==0 && k==0) $ do
    ss <- getInts
    bsum <- foldl1 (zipWith (+)) <$> replicateM n getInts
    putStrLn $ cond "Yes" "No" $ and $ zipWith (>=) ss bsum
    main


Measured memory_bytes: 8228
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String SandT[] = br.readLine().split(" ");
	String S = SandT[0];
	String T = SandT[1];
	String AandB[] = br.readLine().split(" ");
	int A = Integer.parseInt(AandB[0]);
	int B = Integer.parseInt(AandB[1]);
	String U = br.readLine();
	if (U.equals(S))
	    System.out.println((A - 1) + " " + B);
	else if (U.equals(T))
	    System.out.println(A + " " + (B - 1));
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 998244353;

int D[1000010], DB[1000010];

int main() {
	for (int i = 0;i < 1000010;i++)D[i] = DB[i] = 0;
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
		D[A[i]]++;
	}

	for (int i = 1;i < 1000010;i++) {
		for (int j = i;j < 1000010;j += i) {
			DB[j] += D[i];
		}
	}

	int cnt = 0;
	for (int i = 0;i < N;i++) {
		if (DB[A[i]] == 1)cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 11872
#include <bits/stdc++.h>
using namespace std;

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int x, y;
    cin >> x >> y;
    for (int i=0; i<=x; ++i) {
        int j=x-i;
        if (i*2+j*4==y) {
            cout << "Yes";
            return 0;
        }
    }

    cout << "No";

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vint;
#define rep(i,n) for(ll i=0;i<n;i++)


int main(){
    cout<<fixed<<setprecision(10);

    ll n;cin>>n;
    
    bool exist[4][13];
    rep(i,4)rep(j,13)exist[i][j] = false;
    
    map<char, ll> m;
    m['S'] = 0;
    m['H'] = 1;
    m['C'] = 2;
    m['D'] = 3;
    
    char i2c[] = {'S', 'H', 'C', 'D'};
    
    rep(i,n){
        char c; cin>>c;
        ll x; cin>>x;
        
        exist[m[c]][x-1] = true;
    }
    
    rep(i,4)rep(j,13){
        if(!exist[i][j]) cout<<i2c[i]<<" "<<j+1<<endl;
    }

    

    return 0;
}







Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<algorithm>
#include<assert.h>

using namespace std;
#define int long long
const int mod=1e9+7;
int memo[100005];
int fact[100005];

int powpow(int x, int n){
    if(n==0) return 1;
    else if(n%2==0) return powpow(x*x%mod, n/2)%mod;
    else if(n%2==1) return x*powpow(x, n-1)%mod;
}

int makeinv(int x, int p){
    return powpow(x, p-2);
}
int comb(int n, int r){
    return (fact[n]%mod*memo[n-r]%mod*memo[r]%mod)%mod;
}

#define repeat(i,n) for(int i=0; i<(n); i++)

void comb_init(){

    fact[0]=1;
    for(int i=1; i<100005; i++){
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
    }
    for(int i=0; i<100005; i++){
        memo[i]=makeinv(fact[i], mod);
        memo[i]%=mod;
    }

}

signed main(){

    int N;
    cin>> N;
    vector<int> a(N+1);
    repeat(i, a.size()) cin>> a[i];

    vector<int> cnt(N+1, 0);
    for(int e: a) cnt[e]++;
    int b=0;
    repeat(i, cnt.size())if(cnt[i]==2)b=i;

    assert(b!=0);

    int l=N+1, r=-1;
    repeat(i, a.size())if(a[i]==b){l=i;break;}
    for(int i=N; i>=0; i--)if(a[i]==b){r=i;break;}

    assert(l!=N+1);
    assert(r!=-1);

    comb_init();
    int m=l+(N-r);
    for(int k=1; k<=N+1; k++){
        int ans=0;
        if(k-1<=m){
            ans+=(comb(N+1, k)-comb(m, k-1)+mod)%mod;
            ans%=mod;
        }else{
            (ans+=comb(N+1, k))%=mod;
        }
    cout<< ans<< endl;
    }


    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    string S;
    string T = "ABC";

    cin >> N >> S;

    int ans = 0;
    rep(i, N - 2) {
        bool flag = true;
        rep(j, 3) {
            if (T[j] != S[i + j]) {
                flag = false;
                break;
            }
        }
        if (flag) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e5 , limit = 1e17 , MOD=1e9+7;


#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int ans =0 ;
vector < pair < pair < int ,int > , pair < int, int >  >  >  v;
int n , m , q;
void dfs(int len , vector<int>v1){
    
    if(len == n){
        
        int val = 0;
     //   for(int i=0;i<n;i++){
       //     cout<<v1[i]<<" ";
        //}nl;
        for(int i=0;i<v.size() ;i++){
            
            int i1=v[i].se.se;
            int i2=v[i].se.fi;
            if(v1[i1-1]-v1[i2-1] == v[i].fi.se)
                val+=v[i].fi.fi;
        
            
        }
        ans = max(ans,val);
            
        
        return ;    
    }
    
    int p=1;
   
   if(len == 0)
     p=1;
    else
        p = v1[len-1];
        
        for(int i=p; i<= m ;i ++ ){
                
                v1[len]=i;
                dfs(len+1 , v1);
               
        }
    
    
    
}
        
string binary(int n, int k){
    string q="";
    int cp=0;
    while(n){
        if(n%2)q+='1';
        else q+='0';
        
        cp+=n%2;
        n/=2;
        
    }
    
    if(cp == k)
        return q;
    else{
        q="NA";
        return q;
    }
}

int32_t main(){
    boost;
    cin>>n>>m>>q;
        
        int arr[n+1];
        memset(arr,-1,sizeof(arr));
        for(int i  =0 ;  i < q ; i ++ ){
            int a,b,c,d;
            cin>>a>>b>>c>>d;
            v.pb(mp(mp(d,c),mp(a,b)));
        }
        vector<int>v1(n);
        dfs(0,v1);
        cout<<ans<<endl;
      
        
    
        
        
     
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int N;
	long long K;
	cin >> N >> K;
	vector<int> P( N );
	for( int i = 0; i < N; i++ ) {
		int p;
		cin >> p;
		p--;
		P[i] = p;
	}
	vector<long long> C( N );
	for( int i = 0; i < N; i++ ) {
		cin >> C[i];
	}

	long long ans = INT64_MIN;
	set<int> st;
	for( int j = 0; j < N; j++ ) {
		if( st.count( j ) ) continue;
		vector<int> vi;
		int now = j;
		long long sum = 0;
		set<int> st1;
		for( int i = 0; i < N * 2; i++ ) {
			if( st1.count( now ) ) {
				st.insert( st1.begin(), st1.end() );
				break;
			}
			st1.insert( now );
			now = P[now];
			sum += C[now];
			vi.push_back( now );
		}
		int n = vi.size();
		long long ma = 0;
		long long k = K;
		if( k / n > 1 ) {
			if( sum > 0 ) ma += sum * (k / n - 1);
			k -= (k / n - 1) * n;
		}
		for( int j = 0; j < n; j++ ) {
			long long aa = 0;
			for( int l = 0; l < k; l++ ) {
				aa += C[ vi[(j + l) % n] ];
				ans = max( ans, ma + aa );
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 4180
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

ll dp[3001][3001],a[3001];

ll fun(int s, int e){
	if(s>e)	return 0;
	if(s==e)	return a[s];
	if(dp[s][e]!=-1)	return dp[s][e];
	ll a1=min(fun(s+1,e-1)+a[s]-a[e], fun(s+2,e)+a[s]-a[s+1]);
	ll a2=min(fun(s+1,e-1)+a[e]-a[s], fun(s,e-2)+a[e]-a[e-1]);
	dp[s][e]=max(a1,a2);
	return dp[s][e];
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,i,j;	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			dp[i][j]=-1;
		}
	}
	cout<<fun(1,n)<<endl;
	return 0;
}

Measured memory_bytes: 70784
#include<stdio.h>
#include<stdlib.h>
typedef long long ll;
int main(void){
    char S[1][3];
    scanf("%s",S[0]);
    int ans = 0;
    if(S[0][0]=='S'&&S[0][1]=='U'&&S[0][2]=='N') ans = 7;
    else if(S[0][0]=='M'&&S[0][1]=='O'&&S[0][2]=='N') ans = 6;
    else if(S[0][0]=='T'&&S[0][1]=='U'&&S[0][2]=='E') ans = 5;
    else if(S[0][0]=='W'&&S[0][1]=='E'&&S[0][2]=='D') ans = 4;
    else if(S[0][0]=='T'&&S[0][1]=='H'&&S[0][2]=='U') ans = 3;
    else if(S[0][0]=='F'&&S[0][1]=='R'&&S[0][2]=='I') ans = 2;
    else if(S[0][0]=='S'&&S[0][1]=='A'&&S[0][2]=='T') ans = 1;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream> // includes cin to read from stdin and cout to write to stdout
using namespace std; // since cin and cout are both in namespace std, this saves some text

int main()
{
    int N;
    cin >> N;
    
    if (N < 1000)
    {
        cout << "ABC" << endl;
    }
    else
    {
        cout << "ABD" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (n, d) = parse_line!(u32, u32);
    let mut cnt = 0;
    let i = 1;
    let mut sum = 0;
    while (sum < n) {
        sum += d + i + d;
        cnt = cnt + 1;
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void){
	int H,W,i,j,a;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0){
			break;
		}
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				if((i+j)%2==1){
					printf(".");
				}else{
					printf("#");
				}
			}
			printf("\n");
			}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
	char c;
	cin >> c;
	if(c=='A') cout << "T\n";
	else if(c=='T') cout << "A\n";
	else if(c=='G') cout << "C\n";
	else cout << "G\n";
	return 0;
}

Measured memory_bytes: 256
x,y,a,b,c=map(int,input().split())
p=sorted([int(i) for i in input().split()],reverse=True)[:x]
q=sorted([int(i) for i in input().split()],reverse=True)[:y]
r=sorted([int(i) for i in input().split()],reverse=True)
pq=sorted(p+q)
for i in range(min(x+y,a+b,c)):
    if pq[i]<r[i]:
        pq[i]=r[i]
print(sum(pq))

Measured memory_bytes: 22560
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int a,b,c,k,maxn=-1;
	scanf("%d %d %d",&a,&b,&c);
	scanf("%d",&k);
	maxn=max(maxn,a);
	maxn=max(maxn,b);
	maxn=max(maxn,c);
	if(maxn==a)
	{
		a*=powf(2,k);
	}
	else if(maxn==b)
	{
		b*=powf(2,k);
	}
	else if(maxn==c)
	{
		c*=powf(2,k);
	}
	printf("%d\n",a+b+c);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;

int main(void)
{
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long ans = b * d;
    long long preans = b * d;
    if (a * c > preans)
    {
        ans = a * c;
        preans = a * c;
    }
    if (a * d > preans)
    {
        ans = a * d;
        preans = a * d;
        
    }
    if (b * c > preans)
    {
        ans = b * c;
        preans = b * c;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
import java.lang.Math.abs

fun main(args:Array<String>):Unit {
    val arg = readLine()!!.trim().split(' ').map(String::toInt)
    val (r, c) = arg.take(2)
    val (ax, ay, bx, by) = arg.drop(2)
    val mod = 100000007L
    val memoFactorial = LongArray(1001){-1}
    factorial(1000, mod, memoFactorial)
    val memoInverse = memoFactorial.map{power(it, mod - 2, mod)}.toLongArray()
    val combination:(Int, Int) -> Long = fun(n:Int, r:Int):Long{ return (((memoFactorial[n] * memoInverse[r]) % mod) * memoInverse[n - r]) % mod}
    val dx = abs(ax - bx)
    val dy = abs(ay - by)
    val diffX = minOf(dx, r - dx)
    val diffY = minOf(dy, c - dy)
    println((combination(diffX + diffY, diffX) * (if (dx * 2 == r) 2 else 1) * if (dy * 2 == c) 2 else 1) % mod)
}
fun factorial(n:Int, mod:Long, memo:LongArray):Long {
    if (memo[n] >= 0) return memo[n]
    memo[n] = when(n){
        0 -> 1
        else -> (n * factorial(n - 1, mod, memo)) % mod
    }
    return memo[n]
}
fun power(base:Long, exp:Long, mod:Long):Long {
    return when(exp){
        0L -> 1
        else -> (power(base, exp / 2, mod).let{if (exp % 2 == 0L) it * it else it * it} % mod * if (exp % 2 == 0L) 1 else base) % mod
    }
}



Measured memory_bytes: 34668
#include<bits/stdc++.h>

using namespace std;

#define ll long long 
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ff first
#define ss second
#define endl "\n"
#define MOD 1000000007
#define MOD1 998244353
#define inf 1e18

ll GCD(ll x,ll y){if(y==0)return x;return GCD(y,x%y);}
ll LCM(ll x,ll y){return (x*y)/(GCD(x,y));}
ll LOGK(ll x,ll k){if(x>=k)return 1+LOGK(x/k,k);return 0;}
ll MPOW( ll a, ll b, ll m) { if(b==0) return 1; ll x=MPOW(a,b/2,m); x=(x*x)%m; if(b%2==1) x=(x*a)%m; return x;}
ll MINV(ll a,ll m) {return MPOW(a,m-2,m);}

class pnc{
  ll FACT_MAX,MODU;
  vector<ll> fact;
public:
  pnc( ll n, ll m) { FACT_MAX = n; fact.resize(FACT_MAX); MODU = m; MFACT_INIT(MODU);}
  void MFACT_INIT( ll m) { fact[0]=1; for(ll i=1;i<FACT_MAX;++i) fact[i]=(i*fact[i-1])%MODU;}
  ll MFACT( ll n) { return fact[n];}
  ll PERM( ll n, ll r) { return (fact[n]*::MINV(fact[n-r],MODU))%MODU;}
  ll COMB( ll n , ll r) { return (PERM(n,r)*::MINV(fact[r],MODU))%MODU;}
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    

    ll test=1;
    // cin>>test;
    while(test--)
    {
        ll n,m,k;
        cin>>n>>m>>k;

        char mat[n][m];

        for(ll i=0;i<n;i++)
        {
            string str;
            cin>>str;
            for(ll j=0;j<m;j++)
            {
                mat[i][j]=str[j];
            }
        }

        ll ans=0;

        char mat2[n][m];
        char mat3[n][m];

        for(ll rc=0;rc<pow(2,n);rc++)
        {
            for(ll i=0;i<n;i++)
            for(ll j=0;j<m;j++)
            mat2[i][j]=mat[i][j];

            vector<ll> row;

            ll num=rc;

            for(ll j=0;j<6;j++)
            {
                if(num&1)
                row.pb(j);

                num>>=1;
            }

            for(auto i:row)
            {
                for(ll j=0;j<m;j++)
                {
                    mat2[i][j]='r';
                }
            }

            for(ll cc=0;cc<pow(2,m);cc++)
            {
                for(ll i=0;i<n;i++)
                for(ll j=0;j<m;j++)
                mat3[i][j]=mat2[i][j];

                vector<ll> col;

                ll num2=cc;

                for(ll j=0;j<6;j++)
                {
                    if(num2&1)
                    col.pb(j);

                    num2>>=1;
                }

                for(auto i:col)
                {
                    for(ll j=0;j<n;j++)
                    {
                        mat3[j][i]='r';
                    }
                }

                ll cnt=0;

                for(ll i=0;i<n;i++)
                {
                    for(ll j=0;j<m;j++)
                    {
                        if(mat3[i][j]=='#')
                        cnt++;
                    }
                }

                if(cnt==k) 
                {
                    ans++;
                }
            }
        }

        cout<<ans;

    }
}

Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  
  int num=0;
  int n = s.size();
  for(int i=0; i<n; i=i+2){
  if(s[i]!='L'){
  num++;
  }
  }
   for(int j=1; j<n; j=j+2){
     if(s[j]!='R'){
       num++;
     }
  }
  
  if(num==n){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3624
const main = (input: string) => {
  const YY = parseInt(input.slice(0, 2));
  const MM = parseInt(input.slice(2, 4));
  let answer: string = "NA";
 
  if (MM > 0 && MM <= 12 && YY > 0 && YY <= 12) {
    answer = "AMBIGUOUS";
  } else if (MM > 0 && MM <= 12) {
    answer = "YYMM";
  } else if (YY > 0 && YY <= 12) {
    answer = "MMYY";
  }
 
  console.log(answer);
};
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;

int main(){
  int Nlen,P;
  string S;
  cin >> Nlen >> P >> S;

  if(P==2 || P==5){
    int64_t ans= 0;
    for(int i=Nlen; i>0; i--){
      int dig_i= S.at(i-1)- '0';
      if(dig_i % P==0){
        ans+= (int64_t) i;
      }
    }

    cout << ans << endl;
    return 0;
  }
  else{
    int64_t ans= 0;
    vector<vector<int64_t>> mod(P);
    int modP= 0;
    mod.at(modP).emplace_back(Nlen+ 1);
    for(int i=Nlen, t=1; i>0; i--, t= t*10 % P){
      int dig_i= S.at(i-1)- '0';
      modP= (modP+ t*dig_i) % P;
      mod.at(modP).emplace_back(i);
    }

    for(int i=0; i<P; i++){
      int64_t sz= mod.at(i).size();
      ans+= sz*(sz-1)/2;
    }

    cout << ans << endl;
    return 0;
  }
}

Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;

#define deb(x) cout << #x << " " << x << "\n";
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)
#define endl "\n"
#define ll long long
#define vi vector<int>

// memset(arr, value, size);


int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif

	ios::sync_with_stdio(0);
	cin.tie(0);

	long t, i, count = 0;
	map<long, long> l, r;
	cin >> t;
	fo(i, t) {
		long a;
		cin >> a;
		r[i - a]++;
		l[i + a]++;
	}

	for (auto el : l) {
		count += el.second * r[el.first];
	}

	cout << count;
	return 0;
}

Measured memory_bytes: 37932
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    long long n;
    cin>>n;

    string s;

    while(n>0){

        int x = n%26;

        if(x==0)
            s+='z';
        else s+=(char)(96+x);

        n = (n-1)/26;
    }

    reverse(s.begin(),s.end());

    cout<<s<<endl;

}


Measured memory_bytes: 3628
#include <iostream>
#include <cstdlib>
using namespace std;

int main(){

  cin.tie(0);
  ios::sync_with_stdio(0);

  int W, a, b, tmp;

  cin >> W >> a >> b;

  if(b < a){
    tmp = a;
    a = b;
    b = tmp;
  }
  tmp = a + W;
  if(tmp >= b){
    cout << '0' << endl;
  }else{
    cout << abs(tmp - b) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int main() {
	cin >> n;
	vector<int> x(n);
	for (int i = 0; i < n; i++) cin >> x[i], x[i]--;
	vector<pair<int, int> > z(n);
	for (int i = 0; i < n; i++) z[i] = make_pair(x[i], i + 1);
	sort(z.begin(), z.end());
	vector<int> xinv(n);
	for (int i = 0; i < n; i++) xinv[i] = z[i].second;
	vector<int> a(n * n, -1);
	for (int i = 0; i < n; i++) a[x[i]] = i + 1;
	int pos = 0;
	for (int i = 0; i < n; i++) {
		for (int cnt = 0; cnt < xinv[i] - 1 && pos < n * n;) {
			if (a[pos] == -1) a[pos] = xinv[i], cnt++;
			pos++;
		}
	}
	int revpos = n * n - 1;
	for (int i = n - 1; i >= 0; i--) {
		for (int cnt = n - 1; cnt > xinv[i] - 1 && revpos >= 0;) {
			if (a[revpos] == -1) a[revpos] = xinv[i], cnt--;
			revpos--;
		}
	}
	vector<vector<int> > v(n);
	for (int i = 0; i < n * n; i++) v[a[i] - 1].push_back(i);
	bool flag = true;
	for (int i = 0; i < n; i++) {
		if (v[i].size() != n) {
			flag = false; break;
		}
		if (v[i][i] != x[i]) {
			flag = false; break;
		}
	}
	if (flag) {
		cout << "Yes" << endl;
		for (int i = 0; i < n * n; i++) {
			if (i) cout << ' ';
			cout << a[i];
		}
		cout << endl;
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(void)
{
    int n; cin >> n;
    map<int, int> mp;

    irep(i, n) {
        int tmp;
        cin >> tmp;
        mp[tmp]++;
    }

    for(auto mp_i : mp) {
        if(mp_i.second != 1) {
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}
/** atcoder **/


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    vector<int> v(4);
    for (int i=0; i<4; i++) {
	cin>>v[i];
    }
    vector<int> w={1,9,7,4};

    sort(v.begin(), v.end());
    sort(w.begin(), w.end());

    cout<<(v==w ? "YES\n" : "NO\n");
    
    
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
using namespace std;

const int maxn = 10000 + 5;

struct Node {
	int father;
	int deep;
	int Child_number;
	int Height;
	int Left_Child,Right_Child;
	Node():father(-1),deep(0),Child_number(0),Height(0),Left_Child(-1),Right_Child(-1){}
}tree[maxn];

int n;

int max(int a,int b){
	return a > b ? a : b;
}

int solver(int node,int deep){
	if(node == -1)return 0;
	tree[node].deep = deep;
	if(tree[node].Left_Child == -1 && tree[node].Right_Child == -1)return 0;
	int Left_Child = solver(tree[node].Left_Child,deep+1);
	int Right_Child = solver(tree[node].Right_Child,deep+1);
	if(tree[node].Left_Child != -1 && tree[node].Right_Child != -1)tree[node].Child_number = 2;
	else if(tree[node].Left_Child != -1 || tree[node].Right_Child != -1)tree[node].Child_number = 1;
	else tree[node].Child_number = 0;
	tree[node].Height = max(Left_Child+1,Right_Child+1);
	return tree[node].Height;
}

int Get_sibling(int node){
	int father = tree[node].father;
	if(tree[father].Left_Child == node)return tree[father].Right_Child;
	else return tree[father].Left_Child;
}

int main(){
	scanf("%d",&n);
	for(int i = 1;i <= n; i++){
		int node;
		scanf("%d",&node);
		int Left_Child,Right_Child;
		scanf("%d%d",&Left_Child,&Right_Child);
		tree[Left_Child].father = node;
		tree[Right_Child].father = node;
		tree[node].Left_Child = Left_Child;
		tree[node].Right_Child = Right_Child;
	}
	int root;
	for(int i = 0;i < n; i++){
		if(tree[i].father == -1){
			root = i;
			break;
		}
	}
	/*printf("root = %d\n",root);
	for(int i = 0;i < n; i++){
		printf("node %d: Left_Child = %d,Right_Child = %d\n",i,tree[i].Left_Child,tree[i].Right_Child);
	}*/
	solver(root,0);
	for(int i = 0;i < n; i++){
		printf("node %d: ",i);
		printf("parent = %d, ",tree[i].father);
		if(i == root)printf("sibling = -1, ");
		else printf("sibling = %d, ",Get_sibling(i));
		printf("degree = %d, ",tree[i].Child_number);
		printf("depth = %d, ",tree[i].deep);
		printf("height = %d, ",tree[i].Height);
		if(i == root)printf("root\n");
		else if(tree[i].Left_Child != -1 || tree[i].Right_Child != -1)printf("internal node\n");
		else printf("leaf\n");
	}
}

Measured memory_bytes: 3432
#include <stdio.h>

void uneven(int& N)
{
    int oddDigitNums = 0;

    for (int i = 1; i <= N; i++)
    {
        if (i < 10) oddDigitNums++;
        else if (i >= 100 && i < 1000) oddDigitNums++;
        else if (i >= 10000 && i < 100000) oddDigitNums++;
    }

    printf("%d\n", oddDigitNums);
}

int main()
{
    int N;

    scanf("%d", &N);

    uneven(N);

    return 0;
}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created by Reopard on 2014/06/26.
 */
public class Main{
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args){
        int[] a, accend, decend;
        int a_first, L, max, min, j, hoge;
        while((a_first = sc.nextInt()) != 0 | (L = sc.nextInt()) != 0){
            hoge = 0;
            j = 0;
            a = new int[21];
            a[0] = a_first;
            accend = new int[L];
            decend = new int[L];
            outer:
            while(true){
                max = 0;
                min = 0;
                if(j > 0) a_first = a[j];
                for(int i = 0; i < L; i++){
                    accend[i] = a_first%10;
                    a_first /= 10;
                }
                Arrays.sort(accend);
                for(int i = 0; i < L; i++) decend[i] = accend[L - (i + 1)];
                for(int i = 0; i < L; i++){
                    min += accend[i]*Math.pow(10, L - (i + 1));
                    max += decend[i]*Math.pow(10, L - (i + 1));
                }
                a[++j] = max - min;
                for(int i = 0; i < j; i++){
                    if(a[j] == a[i]){
                        hoge = i;
                        break outer;
                    }
                }
            }
            System.out.println(hoge + " " + a[j] + " " + (j - hoge));
        }
    }
}

Measured memory_bytes: 20444
#include <bits/stdc++.h>

using namespace std;
#define sz(x) (int)((x).size())
#define forn(i,n) for (int i=0; i < n; i++)
#define forse(i,s,e) for (int i=s; i < e; i++)
#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define time() ((double)clock() / CLOCKS_PER_SEC)

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

double PI=3.141592653589793;

const int P = 998244353;
//Modular arithmetic
class mint{
	public:
		static int init_siz;
		static vector<mint> inverse,factorial;
		static int mintP;
		int n;
		static mint exp(mint a, long long e) {
			mint res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
			return res;
		}
		static void init(int n){
			init_siz=n;
			inverse.resize(n+1);factorial.resize(n+1);
			factorial[0] = 1;
			for (int i = 1; i <= n; i++) factorial[i] = factorial[i - 1] * i;
			inverse[n]=exp(factorial[n],mintP-2);
			for (int i = n-1; i>=0; i--) inverse[i] = inverse[i+1] * (i+1);
		}
		static mint inv(mint const& a){return (init_siz>=a.n? inverse[a.n]*(a.n>1?fac(a-1):1):exp(a,mintP-2));}
		static mint cinv(mint const& a){return (init_siz>=a.n? inverse[a.n]:exp(fac(a),mintP-2));}
		static mint fac(mint const& a){
			if(init_siz>=a.n) return factorial[a.n];
			else{
				mint out=1;
				for(int i=0;i<a.n;i++) out*=(i+1);
				return out;
			}
		}
		mint(long long val = 0) {n=val%mintP;if(n<0) n+=mintP;}
		mint& operator+=(mint const& b) {n += b.n; if (n >= mintP) n -= mintP; return *this;}
		mint& operator-=(mint const& b) {n -= b.n; if (n < 0) n += mintP;return *this;}
		mint& operator*=(mint const& b) {n = (long long)n * b.n % mintP;return *this;}
		mint exp(long long e) {return exp(*this,e);}
		mint inv(){return inv(*this);}
		mint& operator/=(mint const& b){ return *this *=inv(b);}	
		friend std::ostream& operator<<(std::ostream& os,mint const& a) {return os << (a.n<0?a.n+mintP:a.n);}
		friend mint operator+(mint a, mint const b) { return a += b; }
		friend mint operator-(mint a, mint const b) { return a -= b; }
		friend mint operator-(mint const a) { return 0 - a; }
		friend mint operator*(mint a, mint const b) { return a *= b; }
		friend mint operator/(mint a, mint const b) { return a /= b; }
		friend bool operator==(mint const& a, mint const& b) {return a.n == b.n;}
		friend bool operator!=(mint const& a, mint const& b) {return a.n != b.n;}
};
int mint::init_siz=0;
int mint::mintP=P;
vector<mint> mint::factorial,mint::inverse;

const int mx=3001;
mint dp[2][mx];

void solve(){
	int n,s;
	cin >> n >> s;
	vector<int> a(n);
	forn(i,n) cin >> a[i];
	mint inv=mint(1)/2;
	forn(i,n){
		int c=i&1,b=c^1;
		forn(j,s+1) dp[c][j]=dp[b][j];
		if(a[i]<=s) dp[c][a[i]]+=inv;
		forn(j,s+1){
			if(j+a[i]<=s) dp[c][j+a[i]]+=dp[b][j]*inv;
		}
//		forn(i,s+1) cout << dp[c][i] << ' ';
//		cout << endl;
	}
	mint ans=dp[(n-1)&1][s]*mint::exp(2,n);
	cout << ans;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int T=1;
//	cin >> T;
	forse(c,1,T+1){
	//	cout << "Case #" << cid << ": ";
		solve();
	}
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>

#define fi first
#define se second
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

using namespace std;
using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;

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

	ll x; cin>>x;
	ll ans=0, i=100;

	while(i<x)
	{
		i+=i/100;
		ans++;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 3652