akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
using namespace std;


int main(void){
    int n;
    cin >> n;
    int maxv = 0;
    int a;
    int count = 0;
    int countmax = 0;
    vector<int> color(8);
    rep(i,n){
      cin >> a;
      if(1 <= a && a <= 399 && !color[0]){
           color[0] = 1;
           count++;
      }
      if(400 <= a && a <= 799 && !color[1]){
           color[1] = 1;
           count++;
       }
      if(800 <= a && a <= 1199 && !color[2]){
           color[2] = 1;
           count++;
       }
      if(1200 <= a && a <= 1599 && !color[3]){
           color[3] = 1;
           count++;
       }
      if(1600 <= a && a <= 1999 && !color[4]){
           color[4] = 1;
           count++;
       }
      if(2000 <= a && a <= 2399 && !color[5]){
           color[5] = 1;
           count++;
       }
      if(2400 <= a && a <= 2799 && !color[6]){
           color[6] = 1;
           count++;
       }
      if(2800 <= a && a <= 3199 && !color[7]){
           color[7] = 1;
           count++;
      }
      if(a >= 3200){
         maxv++;
      }
    }
    if(!count) cout << 1 << " " << maxv << endl;
    else cout << count << " " << count + maxv << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

int main() {
    std::string x, y;
    std::cin >> x;
    std::cin >> y;

    std::vector< std::vector<int> > dp;
    dp.resize(x.length() + 1);
    for(auto itr = dp.begin(); itr < dp.end(); itr++) {
        itr->resize(y.length() + 1);
    }

    for(int xIndex = 0; xIndex <= x.length(); xIndex++) {
        for(int yIndex = 0; yIndex <= y.length(); yIndex++) {
            if(xIndex == 0 && yIndex == 0) {
                dp[xIndex][yIndex] = 0;
                continue;
            }

            if(xIndex == 0) {
                dp[xIndex][yIndex] = dp[xIndex][yIndex - 1] + 1;
                continue;
            }

            if(yIndex == 0) {
                dp[xIndex][yIndex] = dp[xIndex - 1][yIndex] + 1;
                continue;
            }

            int top, topleft, left;
            top = dp[xIndex - 1][yIndex];
            left = dp[xIndex][yIndex - 1];
            topleft = dp[xIndex - 1][yIndex - 1];

            if(x[xIndex - 1] == y[yIndex - 1]) {
                dp[xIndex][yIndex] = topleft;
            } else {
                topleft++; left++; top++;
                int smallest = topleft < left ? topleft : left;
                smallest = smallest < top ? smallest : top;
                dp[xIndex][yIndex] = smallest;
            }
        }
    }

    std::cout << dp.back().back() << std::endl;

    return 0;
}

Measured memory_bytes: 4956
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	int i, j, c[3], box[10], count;

	while(scanf("%d%d%d", &c[0], &c[1], &c[2]) != EOF){
		
		for(j=0; j<10; j++)
			box[j] = j+1;
		count = 0;

		for(i=0; i<3; i++){
			for(j=0; j<10; j++){
				if(c[i] == j+1)
					box[j] = 0;
			}
		}
		
		for(j=0; j<10; j++){
			if(box[j] != 0){
				if(20 - c[0] - c[1] >= box[j])
					count++;
			}
		}

		if(count >= 4)
			printf("YES\n");
		else
			printf("NO\n");

	}
	return 0;
}
	

Measured memory_bytes: 580
from math import log2

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

def f(n):
    return sum(n^i for i in A)

K += 1

if K == 1:
    print(f(0))
else:
    mb = int(log2(K))
    hN = N / 2

    s = 0
    A_ = A.copy()
    for i in range(mb+1):
        s += (0 if sum(i &0x01 for i in A_) >= hN else 1) * (1 << i)
        A_ = [i >> 1 for i in A_]

    if s >= K:
        def g(i, n, k):
            mask = (2**i) - 1
            s_ = (s & mask) | (k - (k & mask))
            s_ -= (s_ & (1 << i))
            return s_

        gl = [g(i, s, K) for i, b in enumerate("{:b}".format(K)[::-1]) if b == "1"]
        fl = [f(i) for i in gl]
        print(max(fl))
    else:
        print(f(s))


Measured memory_bytes: 16412
def rotate(p, comm):
    if comm==0:
        p[0],p[1],p[2], p[27],p[28],p[29] = p[27],p[28],p[29], p[0],p[1],p[2]
        p[14], p[15] = p[15], p[14]
        p[18], p[20] = p[20], p[18]
    elif comm==1:
        p[2],p[5],p[8], p[21],p[24],p[27] = p[21],p[24],p[27], p[2],p[5],p[8]
        p[11], p[18] = p[18], p[11]
        p[12], p[14] = p[14], p[12]
    elif comm==2:
        p[6],p[7],p[8], p[21],p[22],p[23] = p[21],p[22],p[23], p[6],p[7],p[8]
        p[12], p[17] = p[17], p[12]
        p[9], p[11] = p[11], p[9]
    elif comm==3:
        p[0],p[3],p[6], p[23],p[26],p[29] = p[23],p[26],p[29], p[0],p[3],p[6]
        p[9], p[20] = p[20], p[9]
        p[15], p[17] = p[17], p[15]
def all_eq(A, left, right):
    return all(A[i]==A[left] for i in xrange(left, right))
def is_correct(p):
    return all_eq(p, 9, 12) and all_eq(p, 12, 15) and all_eq(p, 15, 18) and all_eq(p, 18, 21) and all_eq(p, 0, 9) and all_eq(p, 21, 30)
ans = 8
def dfs(p, cnt, f):
    global ans
    if cnt>ans:
        return
    if is_correct(p):
        ans = cnt
        return
    for k in xrange(4):
        if k==f:
            continue
        rotate(p, k)
        dfs(p, cnt+1, k)
        rotate(p, k)

n = input()
for _ in xrange(n):
    p = map(int, raw_input().split())
    ans = 8
    dfs(p, 0, -1)
    print ans

Measured memory_bytes: 4424
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string res="";
	string s,t;
	cin>>s>>t;
	int n=s.length();
	int m=t.length();
	vector<vector<int>>lcs(n+1,vector<int>(m+1,0));
	int len=0;
	for(int i=1;i<n+1;i++)
	{
		for(int j=1;j<m+1;j++)
		{
			
			if(s[i-1]==t[j-1])
			{
				lcs[i][j]=lcs[i-1][j-1]+1;
				
			}
			else
			{
				lcs[i][j]=max(lcs[i-1][j],lcs[i][j-1]);
			}
		}
	}

	int i=n;
	int j=m;
	while(i>0 and j>0)
	{
		if(lcs[i][j]==lcs[i][j-1])
		{

			j-=1;
		}
		else if(lcs[i][j]==lcs[i-1][j])
		{
			i-=1;
		}
		else
		{
			res=s[i-1]+res;
			i-=1;
			j-=1;
		}
	}	
cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 35584
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;

namespace atcoder
{
    class Solver
    {
        //Solve
        public void Solve()
        {
            cin = new Scanner();
            int n = cin.nextint;

            Console.WriteLine(n*n*n);
        }


        //Main
        public Solver() { }
        Scanner cin;
        public static int Main()
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Solver().Solve();
            Console.Out.Flush();
            return 0;
        }

        //Util
        static bool IsOdd(long num) { return (num & 1) == 1; }
        static bool IsEven(long num) { return (num & 1) == 0; }
        static long GCD(long a, long b) { return b != 0 ? GCD(b, a % b) : a; }
    }

    class Scanner
    {
        string[] s; int i;
        readonly char[] cs = new char[] { ' ' };
        public Scanner() { s = new string[0]; i = 0; }
        public string[] scan => Console.ReadLine().Split();
        public int[] scanint => Array.ConvertAll(scan, int.Parse);
        public long[] scanlong => Array.ConvertAll(scan, long.Parse);
        public double[] scandouble => Array.ConvertAll(scan, double.Parse);
        public string next
        {
            get
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next;
            }
        }
        public int nextint => int.Parse(next);
        public long nextlong => long.Parse(next);
        public double nextdouble => double.Parse(next);
    }

    class Node<T>
    {
        private int m_height;
        private Node<T> m_parent;
        public T Item { get; private set; }
        public Node(T item)
        {
            m_height = 0;
            m_parent = this;
            Item = item;
        }
        public Node<T> Find()
        {
            if (m_parent == this) { return this; }

            Node<T> parent = m_parent.Find();
            m_parent = parent;
            return parent;
        }
        public static void Unite(Node<T> a, Node<T> b)
        {
            Node<T> p = a.Find();
            Node<T> q = b.Find();
            if (p.m_height < q.m_height)
            {
                p.m_parent = q;
                q.m_height = Math.Max(p.m_height + 1, q.m_height);
            }
            else
            {
                q.m_parent = p;
                p.m_height = Math.Max(q.m_height + 1, p.m_height);
            }
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl

//毎回変える場所
#define N_MAX 200


//問題文のとおり
string A;
int alpha[26];
int temp;
LL ans=0;

int main() {
	cin>>A;
	REP(i, A.size()) {
		temp = A.c_str()[i]-'a';
		//cout<<temp<<" ";
		ans += (i - alpha[temp]);
		alpha[temp]++;
	}
	cout<<ans+1<<endl;
	cin>>A;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

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

    int x,y;
    cin >> x >> y;

    int a=((4*x)-y)/2;
    int b=(y-(2*x))/2;

    if ((a<0)||(b<0))
    {
        cout << "No" << endl;
        return 0;
    }

    if (((a+b)==x)&&(((2*a)+(4*b))==y))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;

int main() {
    cin.tie(0)->sync_with_stdio(false);

    ll a, b, c;
    cin >> a >> b >> c;

    ll ans = 0;
    if (a + b >= c) ans = b + c;
    else ans = a + b + b + 1;

    cout << ans << '\n';
    return 0;
}


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

int N,M;
vector< vector<int> > v;
vector<bool> flag;
int64_t ans=0;

void visit(int i){
  static int count=0;
  count++;
  flag.at(i)=true;
  if(count==N){
    ans++;
  }
  for(auto j : v.at(i)){
    if(!flag.at(j)){
      visit(j);
    }
  }
  count--;
  flag.at(i)=false;
}

int main(){
  cin >> N >> M;
  v.resize(N+1);
  flag.resize(N+1);
  for(int i=0;i<M;i++){
    int a,b;
    cin >> a >> b;
    v.at(a).push_back(b);
    v.at(b).push_back(a);
  }
  visit(1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

string S;

ll solve(){
    ll sum=0;
    for(int bit=0; bit < ( 1<<S.size()-1 ); bit++){
        ll cnt=1;
        sum += S[0] - '0';
        for(int i=0; i<S.size()-1; i++){
            if(bit & (1<<i)){
                cnt = 1;
                sum += S[i+1] - '0';
            }
            else{
                cnt *= 10;
                sum += cnt * ( S[i+1] - '0' );
            }
        }
    }
    return sum;
}

int main() {
    cin >> S;
    reverse(S.begin(), S.end());
    cout << solve() << endl;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
s = nsn(n)

print(len(set(s)))

Measured memory_bytes: 35760
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

ll p[8];
ll table[8][8] = { { 1, 2, 1, 2, 1, 4, 1, 4 }, { 1, 2, 1, 4, 1, 4, 1, 2 },
{ 1, 4, 1, 2, 1, 2, 1, 4 }, { 1, 4, 1, 4, 1, 2, 1, 2 },
{ 2, 1, 2, 1, 4, 1, 4, 1, }, { 2, 1, 4, 1, 4, 1, 2, 1 },
{ 4, 1, 2, 1, 2, 1, 4, 1 }, { 4, 1, 4, 1, 2, 1, 2, 1 } };
ll ans[8];

int main(){
	while (cin>>p[0]){
		FOR(i, 1, 8)cin >> p[i];
		ll MIN= INF;
		REP(i,8){
			int n = 0;
			REP(j, 8){
				if (table[i][j] < p[j]){
					n += p[j] - table[i][j];
				}
			}
			if (n < MIN){
				REP(j, 8)ans[j] = table[i][j];
				MIN = n;
			}
		}
		REP(i, 8){
			if (i == 7)cout << ans[i] << endl;
			else cout << ans[i] << " ";
		}
	}
}

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

int selectionSort(int A[],int N){
    int sw=0,minj;
    for (int i=0;i<N-1;i++){
        minj = i;
        for(int j = i;j<N;j++){
            if(A[minj]>A[j])minj = j;
        }
        swap(A[i],A[minj]);
        if(i!=minj)sw++;
    }
    return sw;
}

int main(void){
    int A[100],N,sw;
    cin>>N;
    for(int i=0;i<N;i++)cin>>A[i];
    
    sw=selectionSort(A,N);
    
    for(int i=0;i<N;i++){
        if(i)cout<<" ";
        cout<<A[i];
    }
    cout<<endl;
    cout<<sw<<endl;
    
    return 0;
}

Measured memory_bytes: 3088
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main(void){
  string str;
  string match[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  cin >> str;
  int i;
  for (i=0;i<7;i++){
      if (match[i]==str) break;
  }
  cout << 7-i << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
using vi = vector<int>;
using vll = vector<ll>;
ll fast_exp(ll base,ll e){
    ll r=1;
    while(e>0){
        if(e%2)r=(r*base);
        base=base*base;
        e/=2;
    }
    return r;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}

int main(){
    int n;cin>>n;
    vector<int> v(n);for(int i=0;i<n;i++)cin>>v[i];
    vector<vector<ll> > dp(n+1,vector<ll>(n+1,0));
    for(int i=n-1;i>=0;i--){
    	for(int j=i;j<n;j++){
    		if(i==j)dp[i][j]=v[i];

    		else dp[i][j]=max(v[i]-dp[i+1][j],v[j]-dp[i][j-1]);
    	}
    }
    cout<<dp[0][n-1];

}

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i = 0;i < n;i++)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()

template<class T> bool chmax(T& a,T b){ if(a < b){ a = b; return true; }else return false; }
template<class T> bool chmin(T& a,T b){ if(a > b){ a = b; return true; }else return false; }
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
using vpi = vector<Pi>;
using vpl = vector<Pl>;
 
#define debug(arr) cout << #arr << " = " << arr << '\n'
#define debug2(a,b) cout << "[" << #a << "," << #b << "] = " << "[" << a << "," << b << "]" << '\n'
template<class T> ostream &operator << (ostream& out, const vector<T>& arr) {
	cout << "{"; for (int i = 0; i < arr.size(); i++)cout << (!i ? "" : ", ") << arr[i]; cout << "}";
	return out;
}
template<class T> ostream &operator << (ostream& out, const vector<vector<T> >& arr) {
	cout << "{\n"; for (auto& vec : arr)cout << "  " << vec << ",\n"; cout << "}";
	return out;
}
template<class S,class T> ostream &operator << (ostream& out, const pair<S,T>& p){
  cout << "{" << p.first << "," << p.second << "}" << '\n';
  return out;
}
template<class T> istream &operator >> (istream& in, vector<T>& arr) {
	for (auto& i : arr)cin >> i; return in;
}

/////////////////////////////////////////////////////////////////////////
int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(20);
  
  int n;cin >> n;
  vector<Pi> a(n);
  REP(i,n)cin >> a[i].first >> a[i].second;
  int tmp = 0;
  REP(i,n){
    if(a[i].first == a[i].second){
      tmp++;
      if(tmp >= 3){
        cout << "Yes" << '\n';
        return 0;
      }
    }else{
      tmp = 0;
    }
  }
  if(tmp >= 3) cout << "Yes" << '\n';
  else cout << "No" << '\n';
  return 0;
}


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

using namespace std;

const int N = 1e5;
vector<pair<int, int>> g[N];
int ans[N], k = 0;

void dfs(int v, int p = -1, int c = -1) {
  int ptr = 1;
  k = max(k, (int)g[v].size());
  for (auto pr : g[v]) {
    int to = pr.first, i = pr.second;
    if (ptr == c) {
      ++ptr;
    }
    if (to == p) {
      continue;
    }
    ans[i] = ptr++;
    dfs(to, v, ptr - 1);
  }
}

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

  int n;
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    g[u - 1].emplace_back(v - 1, i);
    g[v - 1].emplace_back(u - 1, i);
  }
  dfs(0);
  cout << k << '\n';
  for (int i = 0; i < n - 1; ++i) {
    cout << ans[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 9344
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
ans = 1
# exit()
A.sort()
# print(A)
for a in A:
    ans *= a
    if ans > 10 ** 18:
        print(-1)
        exit()
else:

    print(ans)

Measured memory_bytes: 23592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
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;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(void)
{
    char c;
    cin >> c;
    printf("%c\n", c+1);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
const long long INF = numeric_limits<long long>::max();
int main()
{
    long long N, M;
    vector<long long> H;
    cin >> N >> M;
    vector<bool> v(N, true);
    REP(i, N) {
        long long h;
        cin >> h;
        H.push_back(h);
    }
    REP(i, M) {
        long long a, b;
        cin >> a >> b;
        if (v[a-1]) {
            if (H[a-1] <= H[b-1]) {
                v[a-1] = false;
            }
        }
        if (v[b-1]) {
            if (H[a-1] >= H[b-1]) {
                v[b-1] = false;
            }
        }
    }
    v.erase(remove(v.begin(), v.end(), false), v.end());
    cout << v.size() << endl;
    return 0;
}

Measured memory_bytes: 4332
#include <stdio.h>
#include <stdlib.h>

bool is_operator(char* s){
    if(s[0] == '+' || s[0] == '-' || s[0] == '*'){
        return true;
    }else{
        return false;
    }
}

int pop(int* A, int* cnt){
    (*cnt)--;
    return A[*cnt];
}

void push(int* A, int* cnt, int value){
    A[*cnt] = value;
    (*cnt)++;
}

int main(void){
    int A[200];
    char s[20];
    int cnt = 0;

    while(scanf("%s", s) != -1){
        if(is_operator(s)){
            int a = pop(A, &cnt);
            int b = pop(A, &cnt);
            if(s[0] == '+'){
                push(A, &cnt, b + a);
            }else if(s[0] == '-'){
                push(A, &cnt, b - a);
            }else if(s[0] == '*'){
                push(A, &cnt, b * a);
            }
        }else{
            push(A, &cnt, atoi(s));
        }
    }
    printf("%d\n", A[0]);
}



Measured memory_bytes: 2756
#ABC077C
import bisect
def main():
    n=int(input())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    c=list(map(int,input().split()))
    if n==1:
        if a<b and b<c:
            print(1)
        else:
            print(0)
    else:
        a.sort()
        b.sort()
        c.sort()
        aList=[0]*n
        bList=[0]*n
        bListSum=[0]*n
        for i in range(n):
            aList[i]=bisect.bisect_right(b,a[i])
            bList[i]=n-bisect.bisect_right(c,b[i])
        bListSum[n-1]=bList[n-1]
        for i in range(n-2,-1,-1):
            bListSum[i]=bListSum[i+1]+bList[i]
        ans=0
        for i in range(n):
            if aList[i]<n:
                ans+=bListSum[aList[i]]
        print(ans)
if __name__=="__main__":
    main()

Measured memory_bytes: 28364
#include <stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int a[10000];
    for(int i=0;i<n;i++) scanf("%d",&a[i]);

    int ans=0;
    for(int i=0;i<n;i++)
    {
        while(1)
        {
            if(a[i]%2)
            {
                break;
            }
            else
            {
                ans++;
                a[i]/=2;
            }
            
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 256
n,m,l=map(int,input().split())
A=[]
B=[]
C=[]
for i in range(n):
    A.append(list(map(int,input().split())))
for j in range(m):
    B.append(list(map(int,input().split())))
for i in range(n):
    for j in range(l):
        c=0
        for k in range(m):
            c+=A[i][k]*B[k][j]
        C.append(c)
for i in range(0,n*l,l):
    print(*C[i:i+l:1])


Measured memory_bytes: 7056
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::cmp;
use std::collections::HashSet;

struct Scanner<'a> {
    cin : StdinLock<'a>,
}


impl<'a> Scanner<'a> {
    fn new(cin : StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

fn main(){
    loop{
        let cin = stdin();
        let cin = cin.lock();
        let mut sc = Scanner::new(cin);
        let n : usize = sc.read();
        if n == 0 { break; }
        let mut edges : Vec<HashSet<usize>> = Vec::with_capacity(n);
        for _ in 0..n {
            let m : usize = sc.read();
            let mut e = HashSet::new();
            for _ in 0..m { e.insert(sc.read()); }
            edges.push(e);
        }
        let k = sc.read();
        let mut t = HashSet::new();
        for _ in 0..k { t.insert(sc.read()); }
        let mut idx : usize = 0;
        let mut cnt = 0;
        for x in edges.iter().enumerate(){
            if x.1.is_superset(&t) { cnt = cnt + 1; idx = x.0 }
        }
        match cnt {
            1 => println!("{}", idx+1),
            _ => println!("{}", -1),
        };
    }
}




Measured memory_bytes: 5060
#include "bits/stdc++.h"
using namespace std;

#define say(obj) (cout << (obj) << endl)
#define endline (cout << endl)
#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "yes" << endl) : (cout << "no" << endl))
#define Yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to, cost;
	edge_(ll to, ll cost) : to(to), cost(cost) {}
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr int		INF = (int)1e7;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template <typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template <typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template <typename T>
ostream& operator << (ostream& os, const vector<vector<T>>& mat) {
	for (const vector<T>& m : mat) os << m << endl;
	return os;
}

template <typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template <typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template <typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	string S;
	cin >> S;

	int ans = 0;
	for (int i = 0; i < S.length() - 1; i++)
		if (S[i] != S[i + 1])
			ans++;

	say(ans);

	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int fie[5][5];
int o_fie[5][5]={
	-1,-1,0,-1,-1,
	-1,1,2,3,-1,
	4,5,6,7,8,
	-1,9,10,11,-1
	-1,-1,0,-1,-1,
};

int ox[12],oy[12],zx[2],zy[2],zcnt;
int res;
bool flag;

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

void dfs(int v,int dist,int pd,int pu){
	if(dist==0){
		flag=true;
		res=min(res,v);
		return;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<2;j++){
			if(pu==j && (pd+2)%4==i)continue;
			int nx=zx[j]+dx[i],ny=zy[j]+dy[i];
			if(nx>=0 && nx<5 && ny>=0 && ny<5){
				if(fie[nx][ny]<=0)continue;
				int ch=fie[nx][ny];
				int ndist=dist;
				ndist-=abs(ox[ch]-nx)+abs(oy[ch]-ny);
				swap(fie[nx][ny],fie[zx[j]][zy[j]]);
				ndist+=abs(ox[ch]-zx[j])+abs(oy[ch]-zy[j]);
				zx[j]+=dx[i];
				zy[j]+=dy[i];
				if(v+1+ndist<=res)dfs(v+1,ndist,i,j);
				zx[j]-=dx[i];
				zy[j]-=dy[i];
				swap(fie[nx][ny],fie[zx[j]][zy[j]]);
			}
		}
	}
}
int dist;

int main(void){
	for(int i=0;i<5;i++){
		for(int j=abs(2-i);j<=4-abs(2-i);j++){
			ox[o_fie[i][j]]=j;
			oy[o_fie[i][j]]=i;
		}
	}
	while(1){
		memset(fie,-1,sizeof(fie));
		dist=0;
		zcnt=0;
		for(int i=0;i<5;i++){
			for(int j=abs(2-i);j<=4-abs(2-i);j++){
				scanf("%d",&fie[j][i]);
				if(fie[j][i]==-1)return 0;
			}
		}
		for(int i=0;i<5;i++){
			for(int j=abs(2-i);j<=4-abs(2-i);j++){
				int v=fie[j][i];
				if(v==0){
					zx[zcnt]=j;
					zy[zcnt++]=i;
				}else dist+=abs(ox[v]-j)+abs(oy[v]-i);
			}
		}
		if(dist>20){
			printf("NA\n");
		}else{
			int i=0;
			flag=false;
			res=20;
			dfs(0,dist,-1,-1);
			if(flag){
				printf("%d\n",res);
			}
			if(!flag)printf("NA\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1040
/*
    Mbak Rose Dong
*/
#include<bits/stdc++.h>
using namespace std;
vector<string> vi;
int k[30], p[30], s[30][30];
void dfs(string a, int take, int batas)
{
    if(take == batas)
    {
        vi.push_back(a);
        return;
    }
    dfs(a+"0", take+1, batas);
    dfs(a+"1", take+1, batas);
}
int main()
{
    int n,i,j,x,y,ans,curr,temp,m,h;
    cin >> n >> m;
    for(i=1;i<=m;i++)
    {
        cin >> k[i];
        for(j=1;j<=k[i];j++)
            cin >> s[i][j];
    }
    for(i=1;i<=m;i++)
        cin >> p[i];
    dfs("",0,n);
    int rose = vi.size();
    for(auto x : vi)
    {
        int cnt[n+1];
        memset(cnt, 0, sizeof(cnt));
        for(j=0;j<x.length();j++)
        {
            cnt[j+1] = (x[j] == '1');
        }
        bool can = 1;
        for(i=1;i<=m;i++)
        {
            int sum = 0;
            for(j=1;j<=k[i];j++)
            {
                sum += cnt[s[i][j]];
            }
            if(sum % 2 != (p[i] % 2))
            {
                can = 0;
                break;
            }
        }
        if(can == 0)
            rose--;
    }
    cout << rose << endl;
    return 0;
}


Measured memory_bytes: 256
s = input().rstrip()
t = input().rstrip()

pushable = [1] * (len(s) - len(t) + 1) 
for i in range(len(s) - len(t) + 1):
    for j in range(len(t)):
        if s[i+j] != t[j] and s[i+j] != "?":
            pushable[i] = 0
            break

if 1 not in pushable:
    print("UNRESTORABLE")
    exit()

ans = []
for i, p in enumerate(pushable):
    cand = s
    if p:
        for j in range(len(t)):
            cand = cand[:i+j] + t[j] + cand[i+j+1:]
        for j in range(len(s)):
            if cand[j] == "?":
                cand = cand[:j] + "a" + cand[j+1:]
        ans.append(cand)

print(sorted(ans)[0])


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Satoshi
{
	class Node
	{
		public int id = -1;
		public int left = -1;
		public int right = -1;
		public int parent = -1;
		public Node(int id, int left, int right)
		{
			this.id = id;
			this.left = left;
			this.right = right;
		}
	}

	class Program
	{
		public static int[] preorderId, inorderId, postorderId;
		public static int precount, incount, postcount;
		public static Node[] nodes;

		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			preorderId = new int[n];
			inorderId = new int[n];
			postorderId = new int[n];
			nodes = new Node[n];
			string[] tmp;
			for (int i = 0; i < n; i++)
			{
				tmp = Console.ReadLine().Split(' ');
				int id = int.Parse(tmp[0]);
				nodes[id] = new Node(int.Parse(tmp[0]), int.Parse(tmp[1]), int.Parse(tmp[2]));
			}
			for (int i = 0; i < n; i++)
			{
				int id = nodes[i].id;
				int left = nodes[i].left;
				int right = nodes[i].right;
				if(left != -1)
					nodes[left].parent = id;
				if(right != -1)
					nodes[right].parent = id;
			}
			int rootId = 0;
			foreach (Node x in nodes)
			{
				if (x.parent == -1)
				{
					rootId = x.id;
				}
			}
			Preorder(nodes[rootId]);
			Inorder(nodes[rootId]);
			Postorder(nodes[rootId]);
			Console.WriteLine("Preorder");
			for (int i = 0; i < n; i++)
			{
				Console.Write(" ");
				Console.Write(preorderId[i]);
			}
			Console.WriteLine();
			Console.WriteLine("Inorder");
			for (int i = 0; i < n; i++)
			{
				Console.Write(" ");
				Console.Write(inorderId[i]);
			}
			Console.WriteLine();
			Console.WriteLine("Postorder");
			for (int i = 0; i < n; i++)
			{
				Console.Write(" ");
				Console.Write(postorderId[i]);
			}
			Console.WriteLine();
		}

		public static void Preorder(Node node)
		{
			preorderId[precount] = node.id;
			precount++;
			if (node.left != -1)
				Preorder(nodes[node.left]);
			if (node.right != -1)
				Preorder(nodes[node.right]);
		}

		public static void Inorder(Node node)
		{
			if (node.left != -1)
			{
				Inorder(nodes[node.left]);
			}
			inorderId[incount++] = node.id;
			if (node.right != -1)
				Inorder(nodes[node.right]);
		}

		public static void Postorder(Node node)
		{
			if (node.left != -1)
			{
				Postorder(nodes[node.left]);
			}
			if (node.right != -1)
			{
				Postorder(nodes[node.right]);
			}
			postorderId[postcount++] = node.id;
		}
	}
}

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
set<char> st;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    st.insert('q');
    st.insert('w');
    st.insert('e');
    st.insert('r');
    st.insert('t');
    st.insert('a');
    st.insert('s');
    st.insert('d');
    st.insert('f');
    st.insert('g');
    st.insert('z');
    st.insert('x');
    st.insert('c');
    st.insert('v');
    st.insert('b');
    while(true) {
        string S;
        cin >> S;
        if(S == "#") break;
        int ans = 0;
        for(int i = 1; i < S.size(); i++) {
            if((st.find(S[i-1]) == st.end()) ^ (st.find(S[i]) == st.end())) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main(){
  string s,t;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;
  string u;
  cin >> u;
  if (s==u){
    cout << a-1 << " " << b;
  }
  else{
    cout << a << " " << b-1;
  }
}

Measured memory_bytes: 256
my %D;
$D{'SUN'} = 7;
$D{'MON'} = 6;
$D{'TUE'} = 5;
$D{'WED'} = 4;
$D{'THU'} = 3;
$D{'FRI'} = 2;
$D{'SAT'} = 1;
my $S = glob <>;
print $D{$S};

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
	long long int n;
	cin >> n;
	vector<long long int> a(n);
	for (long long int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<long long int>());
	long long int aa, bb;
	aa = bb = 0;
	for (long long int i = 0; i+1 < n; i++) {
		if (a[i] == a[i + 1]) {
			if (aa == 0) {
				aa = a[i];
				i++;
			}
			else if (bb == 0) {
				bb = a[i];
			}
		}
	}
	cout << aa*bb << endl;
	return 0;
}

Measured memory_bytes: 1024
// @zekkiyoumachine
#include <stdio.h>

int max( int x, int y ){
	return x>y ? x : y;
}

int main()
{
	int N, A, B, C, D;
	scanf("%d %d %d %d %d", &N, &A, &B, &C, &D);
    A--; B--; C--; D--;
	char S[N];
	scanf("%s", S);
	
	int k;
	int hs = 0;
	int hsr = 0;
	int pn = 0;
	int pnr = 0;
	
    // 元コード: for(k=0; k<N; k++) ...
	for(k=A; k<=max(C, D); k++){
		if(S[k] == '#'){
			hs++;
			if(hs > hsr) hsr = hs;
		}
		else hs=0;
	}
	
	if(hsr >= 2) printf("No");
	else if(C < D) printf("Yes");
  
	else{
		// 元コード: for(k=0; k<N; k++) ...
      	for(k=B-1; k<=D+1; k++){
			if(S[k] == '.'){
				pn++;
				if(pn > pnr) pnr = pn;
			}
			else pn=0;
		}
      
		if( pnr >= 3 ){
            // if(S[B] == '#' && S[D-2] == '#') printf("No");
            printf("Yes");
		} else printf("No");		
    
    }
		
		return 0;
}


Measured memory_bytes: 384
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
//const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int N,MOD;
vector<int> G[100010];
int DP[100010];
map<int,int> VI[100010];
vector<int> SDP[100010];

void dfs1(int idx,int par)
{
	int res=1;
	int cnt=0;
	vector<int> sv;
	for(auto e:G[idx])
	{
		if(e==par)continue;
		dfs1(e,idx);
		VI[idx][e]=cnt;
		sv.push_back(e);
		res*=(DP[e]+1);
		res%=MOD;
		cnt++;
	}
	DP[idx]=res;
	vector<int> LV(SZ(sv),1),RV(SZ(sv),1);
	rep(i,0,SZ(sv))
	{
		LV[i]=(LV[i]*(DP[sv[i]]+1))%MOD;
		if(0<i)LV[i]=(LV[i]*LV[i-1])%MOD;
	}
	rrep(i,0,SZ(sv))
	{
		RV[i]=(RV[i]*(DP[sv[i]]+1))%MOD;
		if(i<SZ(sv)-1)RV[i]=(RV[i]*RV[i+1])%MOD;
	}
	rep(i,0,SZ(sv))
	{
		int t=1;
		if(0<i)t=(t*LV[i-1])%MOD;
		if(i<SZ(sv)-1)t=(t*RV[i+1])%MOD;
		SDP[idx].push_back(t);
	}
}

void dfs2(int idx,int par)
{
	if(par!=-1)
	{
		DP[idx]=(DP[idx]*(SDP[par][VI[par][idx]]+1))%MOD;
		for(auto& v:SDP[idx])
		{
			v=(v*(SDP[par][VI[par][idx]]+1))%MOD;
		}
	}
	for(auto e:G[idx])
	{
		if(e==par)continue;
		dfs2(e,idx);
	}
}

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

	cin>>N>>MOD;
	int x,y;
	rep(i,0,N-1)
	{
		cin>>x>>y;
		x--,y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}

	dfs1(0,-1);
	dfs2(0,-1);

	rep(i,0,N)cout<<DP[i]<<endl;

	return 0;
}

Measured memory_bytes: 33664
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;

  int st = 0;
  int lcnt = 0;

  for(int i=0;i<N;i++){
    if(S[i] == '(') st++;
    else st--;

    if(st < 0){
      lcnt++;
      st = 0;
    }
  }

  for(int i=0;i<lcnt;i++){
    cout << '(';
  }
  cout << S ;
  for(int i=0;i<st;i++){
    cout << ')';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> myds;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define F first
#define S second
#define vec(x) vector<x> 
#define pi(x,y) pair<x,y>
#define pqq(x) priority_queue<x> 
#define min_heap(x) priority_queue<x, vector<x>, greater<x> >
#define all(x) x.begin(),x.end()
#define rep(i,x,y) for(int i=x;i<y;i++)
#define repd(i,x,y,k) for(int i=x;i<y;i+=k)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define rev(x) reverse(all(x))
#define uniq(x) x.resize(distance(x.begin(),unique(all(x))))
#define full(x,a) memset(x,a,sizeof(x))
#define lcm(x,y) ((x*y)/__gcd(x,y))
#define mod 1000000007
#define bitcount __builtin_popcountll
#define pb push_back
#define indexof order_of_key
#define valueat find_by_order

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

int gcdextended(int a,int b,int &x,int &y){if(!a){x=0,y=1;return b;}int x1,y1;int ans=gcdextended(b%a,a,x1,y1);x=y1-(b/a)*x1;y=x1;return ans;}
int inv(int a){int x,y;int ans=gcdextended(a,mod,x,y);return(x%mod+mod)%mod;}
int nCr(int n,int k){int res=1;k=(k>n-k)?n-k:k;rep(i,0,k){res*=(n-i);res/=(i+1);}return res;}
int POW(int x,int y){int res=1;x=x%mod;while(y>0){if(y&1)res=(res%mod*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
//void seive(){prime[0]=0;prime[1]=0;rep(i,2,10002)prime[i]=1;for(int i=2;i*i<=10000;i++){if(prime[i]){for(int j=i*i;j<=10000;j+=i)prime[j]=0;}}} 

int n;

void input(){
	cin>>n;
}

void solve(){
	rep(i,1,10){
		if(n%i==0 && n/i<=9){
			cout<<"Yes"<<endl;
			return;
		}
	}
	cout<<"No"<<endl;
}

main(){
	fastio;
	int t;
	t=1;
	while(t--){
		input();
		solve();
	}
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(void){
	ll N, fumi=0;
	cin >> N;
	ll A[N];
	for(int i=0; i<N; i++){
      cin >> A[i];
    }
  	ll fr, cur, dif;
  	for(int i=1; i<N; i++){
      fr = A[i-1]; cur = A[i];
      dif = (fr > cur)*(fr-cur);
      A[i] += dif;
      fumi += dif;
    }
    
  	cout << fumi << endl;
  
	return 0;
}

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

class Main {
	double[][] p = new double[2][6];

	void run() {
		Scanner sc = new Scanner(System.in);
		int Na = sc.nextInt();
		int Nb = sc.nextInt();
		long[] xa = new long[Na];
		long[] ya = new long[Na];
		long[] xb = new long[Nb];
		long[] yb = new long[Nb];
		for (int i = 0; i < Na; ++i) {
			xa[i] = sc.nextLong();
			ya[i] = sc.nextLong();
		}
		for (int i = 0; i < Nb; ++i) {
			xb[i] = sc.nextLong();
			yb[i] = sc.nextLong();
		}

		double ans = Double.MAX_VALUE / 3;
		for (int t = 0; t < 2; ++t) {
			for (int i = 0; i < Na; ++i) {
				for (int j = 0; j < Na; ++j) {
					if (cross(xa[0], ya[0], xa[i], ya[i], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					if (cross(xa[i], ya[i], xa[j], ya[j], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					if (cross(xa[j], ya[j], xa[1], ya[1], xb[0], yb[0], xb[1], yb[1])) {
						continue;
					}
					ans = Math.min(ans, dist(xa[0], ya[0], xa[i], ya[i]) + dist(xa[i], ya[i], xa[j], ya[j])
							+ dist(xa[j], ya[j], xa[1], ya[1]) + dist(xb[0], yb[0], xb[1], yb[1]));
				}
			}
			Na ^= Nb;
			Nb ^= Na;
			Na ^= Nb;
			long[] tmp = new long[Na];
			tmp = Arrays.copyOf(xa, xa.length);
			xa = Arrays.copyOf(xb, xb.length);
			xb = Arrays.copyOf(tmp, tmp.length);
			tmp = Arrays.copyOf(ya, ya.length);
			ya = Arrays.copyOf(yb, yb.length);
			yb = Arrays.copyOf(tmp, tmp.length);
		}
		System.out.println(ans >= Double.MAX_VALUE / 4 ? "-1" : ans);
	}

	double dist(long xa, long ya, long xb, long yb) {
		long dx = xa - xb;
		long dy = ya - yb;
		return Math.sqrt(dx * dx + dy * dy);
	}

	boolean cross(long xa1, long ya1, long xb1, long yb1, long xa2, long ya2, long xb2, long yb2) {
		long v = f(xa1, ya1, xb1, yb1, xa2, ya2) * f(xa1, ya1, xb1, yb1, xb2, yb2);
		long u = f(xa2, ya2, xb2, yb2, xa1, ya1) * f(xa2, ya2, xb2, yb2, xb1, yb1);
		return v <= 0 && u <= 0;
	}

	long f(long xa, long ya, long xb, long yb, long x, long y) {
		return (ya - yb) * (x - xa) - (y - ya) * (xa - xb);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 36504
#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()
{
	int n;
	map<int,int>mp;
	rep(i,4){
		cin >> n;
		mp[n]++;
	}
	if(mp[1]==1 && mp[4]==1 && mp[7]==1 && mp[9]==1) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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


int main() {
    string a, b, s1, s2;
    int na, nb;
    cin >> a >> b;
    na = atoi(a.c_str());
    nb = atoi(b.c_str());
    FOR(i, nb) s1 += a;
    FOR(i, na) s2 += b;
    if (s1 <= s2) cout << s1 << endl;
    else cout << s2 << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
l_ls = list(map(int, input().split()))
l_ls.sort()
stick_count = [0] * (10**3+1)
stick_csum = [0] * (10**3+1)
for i in range(n):
    stick_count[l_ls[i]] += 1
now = 0
for i in range(10**3+1):
    now += stick_count[i]
    stick_csum[i] = now

ans = 0
for first_i in range(n):
    for second_i in range(first_i+1, n):
        #境界は含まない
        greater_than = abs(l_ls[first_i] - l_ls[second_i])
        smaller_than = min(10**3+1,l_ls[first_i] + l_ls[second_i])
        num_canmake = max(0, stick_csum[smaller_than-1] - stick_csum[greater_than])
        if greater_than < l_ls[first_i] < smaller_than:
            num_canmake -= 1
        if greater_than < l_ls[second_i] < smaller_than:
            num_canmake -= 1
        num_canmake = max(0,num_canmake)
        ans += num_canmake
print(ans//3)




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

int main(){
  ll K,sum=0;
  cin>>K;
  for(int i=1; i<=K; i++){
    for(int j=1; j<=K; j++){
      for(int l=1; l<=K; l++){
        sum+=gcd(gcd(i,j),l);
      }
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 3604
import java.util.*;

class Main{
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
	int b = sc.nextInt();
	int c = sc.nextInt();
	int d = sc.nextInt();
	int[] e = {a + c, a + d, b + c, b + d};
	int ans = 2000;
	for(int i = 0; i < 4; i++) {
		ans = Math.min(ans, e[i]);
	}
	System.out.println(ans);
}
}

Measured memory_bytes: 21588