akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(i, vec.size()) cout << vec[i] << " "; print("");
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

ll modpow(ll a, ll n){
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % INF;
        a = a * a % INF;
        n >>= 1;
    }
    return res;
}

void Main(){

	ll N;
	cin >> N;
	vl v(N);
	rep(i, N) cin >> v[i];
	
	map<ll, ll> mp;
	rep(i, N) mp[v[i]] += 1;
	
	ll flg = 1;
	if(N % 2 == 1){
		if(mp[0] != 1) flg = 0;
		for(ll i = 2; i <= N - 1; i += 2) if(mp[i] != 2) flg = 0;	
	}
	if (N % 2 == 0){
		for(ll i = 1; i <= N; i += 2) if(mp[i] != 2) flg = 0;
	}
	
	ll ans = 0;
	if(flg) ans = modpow(2, N / 2);
	print(ans);		
	
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	Main();
    
	return 0;
	
}





Measured memory_bytes: 9000
package main

import "fmt"

const mod int = 1e9 + 7

func main() {
	var n int
	fmt.Scan(&n)

	a := make([][]int, n)
	for i := 0; i < n; i++ {
		a[i] = make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Scan(&a[i][j])
		}
	}

	dp := make([]int, 1<<uint(n))
	dp[0] = 1

	for bit := 0; bit < (1<<uint(n))-1; bit++ {
		k := bitCount(bit)
		for i := 0; i < n; i++ {
			if (bit>>uint(i))&1 == 0 {
				if a[i][k] == 1 {
					nbit := bit | (1 << uint(i))
					dp[nbit] = (dp[nbit] + dp[bit]) % mod
				}
			}
		}
	}

	fmt.Println(dp[1<<uint(n)-1])
}

func bitCount(bit int) int {
	c := 0
	for i := bit; i > 0; i = i >> 1 {
		c += i & 1
	}
	return c
}


Measured memory_bytes: 17536
<?php
    $array = explode(" ", trim(fgets(STDIN)));
    $r = (int)$array[0];
    $d = (int)$array[1];
    $x = (int)$array[2];
    $ans = 0;

    for($i=1; $i<11; $i++){
        $ans = $r * $x - $d;
        echo "{$ans}\n";
        $x = $ans;
        $ans = 0;
    }

?>

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

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

  while( t-- ) {
    int X, Y, W, H;
    cin >> X >> Y >> W >> H;

    int N;
    cin >> N;

    int cnt = 0;
    for(int i=0; i<N; i++) {
      int x, y;
      cin >> x >> y;
      if( X <= x && x <= X+W && Y <= y && y <= Y+H ) cnt++;
    }

    cout << cnt << endl;
  }
}

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

using namespace std;
typedef long long ll;

// #define DEBUG

class Unionfind
{
    vector<int> p;

public:
    int find(int x);
    void unite(int x, int y);
    Unionfind(int n);
};

Unionfind::Unionfind(int n)
{
    for (int i = 0; i < n; i++)
    {
        p.push_back(i);
    }
}
int Unionfind::find(int x)
{
    while (p[x] != x)
    {
        p[x] = p[p[x]];
        x = p[x];
    }
    return x;
}

void Unionfind::unite(int x, int y)
{
    x = Unionfind::find(x);
    y = Unionfind::find(y);
    if (x != y)
    {
        p[x] = y;
    }
}


int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif
    vector<tuple<int,int,int>> egde;
    int n, e, a, b, c;
    ll ans = 0;
    cin >> n >> e;
    for (int i = 0; i < e; i++){
        cin >> a >> b >> c;
        egde.push_back(make_tuple(c, a, b));
    }
    sort(egde.begin(), egde.end());

    Unionfind node(n);
    for (int i = 0; i < e; i++){
        a = get<1>(egde[i]), b = get<2>(egde[i]);

        if (node.find(a) != node.find(b)){
            node.unite(a, b);
            ans += get<0>(egde[i]);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4540
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n, k = MAP()
d = LIST()
for i in range(n, n * 10):
    y = list(str(i))
    flag = True
    for j in d:
        if str(j) in y:
            flag = False
            break
    if flag:
        print(i)
        exit()


Measured memory_bytes: 62312
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    int w;
    cin>>s>>w;
    int l=s.size();
    for(int i=0;i<l;i++){
        if(i%w==0)cout<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;

int main()
{
 int n;
 cin >> n;
 int a[n],a1[n];
 int f,s;
 for(int i=1;i<n+1;i++){
   cin >> a[i];
   a1[i]=a[i];
 }
 a[0]=0;
 a1[0]=0;
 sort(a1, a1+n+1, greater<int>());
 for(int i=1;i<n+1;i++){
   if(a[i]==a1[0]) cout << a1[1] << endl;
   else cout << a1[0] << endl;
 }
  return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 400005;

int n;
char a[N];

int dp[N][2];

void solv()
{
    scanf(" %s", a);
    n = strlen(a);
    for (int i = 0; i < n; ++i)
        dp[i][0] = dp[i][1] = -N;
    if (a[0] == 'P')
    {
        dp[0][0] = 0;
    }
    else if (a[0] == 'D')
    {
        dp[0][1] = 1;
    }
    else
    {
        dp[0][0] = 0;
        dp[0][1] = 1;
    }
    for (int i = 1; i < n; ++i)
    {
        if (a[i] == 'P')
        {
            dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]);
        }
        else if (a[i] == 'D')
        {
            dp[i][1] = max(dp[i - 1][0] + 2, dp[i - 1][1] + 1);
        }
        else
        {
            dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]);
            dp[i][1] = max(dp[i - 1][0] + 2, dp[i - 1][1] + 1);
        }
    }
    int z;
    if (dp[n - 1][0] > dp[n - 1][1])
        z = 0;
    else
        z = 1;
    for (int i = n - 1; i >= 0; --i)
    {
        if (z == 0)
            a[i] = 'P';
        else
            a[i] = 'D';
        if (z == 0)
        {
            if (dp[i - 1][0] > dp[i - 1][1])
                z = 0;
            else
                z = 1;
        }
        else
        {
            if (dp[i - 1][0] + 2 > dp[i - 1][1] + 1)
                z = 0;
            else
                z = 1;
        }
    }
    printf("%s\n", a);
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    //ios_base::sync_with_stdio(false);
    //cin.tie(0);
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 5432
#include <algorithm>
#include <climits>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int N;
vector<long long> A;

int main() {
  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  int abs_min_idx = 0;
  long long abs_min = LONG_LONG_MAX;
  for (int i = 0; i < N; i++) {
    if (abs_min > abs(A[i])) {
      abs_min_idx = i;
      abs_min = abs(A[i]);
    }
  }

  for (int i = 0; i < abs_min_idx; i++) {
    if (A[i] < 0) {
      A[i] = -A[i];
      A[i + 1] = -A[i + 1];
    }
  }
  for (int i = N - 1; i > abs_min_idx; i--) {
    if (A[i] < 0) {
      A[i] = -A[i];
      A[i - 1] = -A[i - 1];
    }
  }

  cout << accumulate(A.cbegin(), A.cend(), 0LL) << endl;
  return 0;
}

Measured memory_bytes: 4016
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int a = Integer.parseInt(stdIn.next());
        int b = Integer.parseInt(stdIn.next());

        int pl = 0;
        int pr = 1250;
        do {
            int pc = (pl + pr) / 2;
            if ((int)(pc * 0.08) == a && (int)(pc * 0.1) == b) {
                while ((int)(pc * 0.08) == a && (int)(pc * 0.1) == b) {
                    pc--;
                }
                pc++;
                System.out.println(pc);
                return;
            } else if ((int)(pc * 0.08) < a || (int)(pc * 0.1) < b) {
                pl = pc + 1;
            } else if ((int)(pc * 0.08) > a || (int)(pc * 0.1) > b) {
                pr = pc - 1;
            }
        } while (pl <= pr);

        System.out.println(-1);
    }
}


Measured memory_bytes: 25172
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

const ll mod = static_cast<ll>(1e9) + 7;

int main()
{
    ll N;
    cin >> N;

    vector<ll> A(N), B(N);
    rep (i, N) { cin >> A[i]; B[i] = A[i]; }

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

    rep (i, N)
    {
        const bool isMax = A[i] == B[N - 1];
        cout << (isMax ? B[N - 2] : B[N - 1]) << endl;
    }

    return 0;
}


Measured memory_bytes: 4736
#include<iostream>
#include<math.h>
#include<string>
using namespace std;



int main(){
    int A,B,C,K;
    cin >> A >> B >> C >> K;
  	if(A>K){
      cout << 1*K <<endl;
    }else if(A+B>K){
      cout << 1*A + 0*(K-A) <<endl;
    }else{
      cout << 1*A + 0*B + (-1)*(K-A-B) << endl;
    }
}

Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var H = int.Parse(Console.ReadLine());

            // 1オリジンにするために先頭にj[0 ]を追加している
            var A = ("0 " + Console.ReadLine()).Split().Select(int.Parse).ToArray();

            for (var i = 1; i <= H; i++)
            {
                Console.Write($"node {i}: key = {A[i]}, ");
                if (Parent(i) >= 1) Console.Write($"parent key = {A[Parent(i)]}, ");
                if (Left(i) <= H) Console.Write($"left key = {A[Left(i)]}, ");
                if (Right(i) <= H) Console.Write($"right key = {A[Right(i)]}, ");
                Console.WriteLine();
            }
        }

        static int Parent(int i) { return i / 2; }
        static int Left(int i ) { return 2 * i; }
        static int Right(int i) { return 2 * i + 1; }

    }
}



Measured memory_bytes: 20424
import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()
    T = input().rstrip()

    N = len(S)
    ans = "No"
    for i in range(N):
        if S[N - i:] + S[:N - i] == T:
            ans = "Yes"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
#include <climits>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

vector<int> V[110000];
int C[110000];
void dfs(int x){
    C[x]=1;
    for(int i=0;i<(int)V[x].size();i++){
        if(C[V[x][i]]) continue;
        dfs(V[x][i]);
    }
}

int main(){
    int N,M,x,y,z;
    cin>>N>>M;
    for(int i=0;i<M;i++){
        cin>>x>>y>>z;
        x--; y--;
        V[x].push_back(y);
        V[y].push_back(x);
    }
    int count=0;
    for(int i=0;i<N;i++){
        if(C[i]!=0) continue;
        count++;
        dfs(i);
    }
    cout<<count<<endl;
}


Measured memory_bytes: 9472
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cmath>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>

#define pb push_back
#define ppb pop_back
#define nd second
#define st first
#define ll long long
#define pi 3.1415926535897932384626433832795028841971

using namespace std;

int n; 
string s; 
int ea, wa; 
int er, wl; 
int ans = 12345678; 

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin >> n; 
	cin >> s; 
	
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'E') ea++; 
		else wa++; 
	}
	
	er = ea; 
	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'E') er--; 
		ans = min(ans, er + wl); 
		if (s[i] == 'W') wl++; 
	}
	
	cout << ans << endl; 
	
	return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int MAXN = 505;

int n;
lint sum[MAXN][MAXN], dp[MAXN][MAXN];

lint gs12117(int sx, int ex, int sy, int ey){
	return sum[ex][ey] - sum[sx-1][ey] - sum[ex][sy-1] + sum[sx-1][sy-1];
}

int main(){
	scanf("%d",&n);
	lint dn = 0;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=n; j++){
			int x = 0;
			if(i != j) scanf("%d",&x);
			if(i < j) dn += x;
			sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + x;
		}
	}
	memset(dp, 0x3f, sizeof(dp)); 
	for(int i=1; i<n; i++) dp[1][i] = 0;
	for(int i=1; i<=n; i++){
		for(int j=1; j<=i; j++){
			for(int k=i+1; k<=n; k++){
				dp[i+1][k] = min(dp[i+1][k], 
				dp[j][i] - gs12117(j, i, i + 1, n) + gs12117(k + 1, n, j, i));
			}
		}
	}
	lint dap = 1e18;
	for(int j=2; j<=n; j++){
		dap = min(dap,dn + dp[j][n]);
	}
	cout << dap << endl;
}


Measured memory_bytes: 4224
#include <stdio.h>
#include <math.h>

int main() {
    int i, n;
    char s[10001];
    scanf("%d%s", &n, s);
    for (i=0; s[i] ;i++)
        printf("%c", 'A'+(n+s[i]-'A') % ('Z'-'A'+1));
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if n==1:
    print(int(a==b))
    exit()
mod=10**9+7
INF=10**9+1 
u=[INF]*n
d=[1]*n
u[0]=a[0]
d[0]=a[0]
for i in range(1,n):
    if a[i]-a[i-1]:
        d[i]=a[i]
    u[i]=a[i]
u[-1]=b[-1]
d[-1]=b[-1]
for i in range(n-2,-1,-1):
    if b[i]-b[i+1]:
        if b[i]<d[i] or b[i]>u[i]:
            print(0)
            exit()
        d[i]=b[i]
    u[i]=min(b[i],u[i])
ans=1
for i in range(n):
    ans=ans*(u[i]-d[i]+1)%mod
print(ans)

Measured memory_bytes: 18884
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>

using namespace std;

int main(void) {
	set<int> s;
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int d;
		cin >> d;
		s.insert(d);
	}
	cout << s.size() << endl;

	return 0;
}

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

using namespace std;

int main() {
	int a, b, base, r;
	string s = "";
	cin >> a >> b;
	if (a <= b) {
		base = a;
		r = b;
	} else {
		base = b;
		r = a;
	}
	for(int i = 0; i < r; i++)
		s += to_string(base);
	cout << s << endl;
	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  int a,b,h,m;cin>>a>>b>>h>>m;
  double thm=2*3.1415926535*m/60.;
  double thh=2*3.1415926535*h/12.+thm/12.;
  double ax=a*sin(thh); double ay=a*cos(thh);
  double bx=b*sin(thm); double by=b*cos(thm);
  double dx=ax-bx;
  double dy=ay-by;
  cout<<fixed;
  cout<<setprecision(10)<<sqrt(dx*dx+dy*dy)<<endl;
  return 0;
}


Measured memory_bytes: 4100
//Created Time:2020年03月22日 星期日 20时16分29秒
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 6005

using namespace std;

int n, mod;
int f[N][N << 1], inv[N];

int main(){
	cin >> n >> mod; n = n * 3;
	int fac = 1; inv[1] = 1;
	for(int i = 1; i <= n; ++i)
		fac = 1ll * fac * i % mod;
	for(int i = 2; i <= n; ++i)
		inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
	f[0][n] = 1;
	for(int i = 0; i <= n; ++i)
		for(int j = 0; j <= n * 2; ++j){
			int w = f[i][j]; if(!w) continue;
			(f[i + 1][j + 1] += 1ll * w * inv[i + 1] % mod) %= mod;
			(f[i + 2][j - 1] += 1ll * w * inv[i + 2] % mod) %= mod;
			(f[i + 3][j] += 1ll * w * inv[i + 3] % mod) %= mod;
		}
	int res = 0;
	for(int j = n; j <= n * 2; ++j) (res += f[n][j]) %= mod;
	res = 1ll * res * fac % mod;
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 279936
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>

template<typename T>
T euclidean_gcd(T a, T b){
    if(a == 0)return b;
    while(a){
        ::std::swap(a, b);
        a %= b;
    }
    return b;
}

int main(){
    using namespace std;
    using bigint = boost::multiprecision::cpp_int;
    constexpr unsigned long MOD = 1000000007;
    bigint lcm{1}, b{0};
    unsigned long N;
    cin >> N;
    for(unsigned long i{0}, A; i < N; ++i){
        cin >> A;
        auto t = euclidean_gcd<unsigned long>(::boost::multiprecision::integer_modulus(lcm, A), A);
        (b *= (A / t)) += lcm /= t;
        lcm *= A;
    }
    cout << ::boost::multiprecision::integer_modulus(b, MOD) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
signed main(){
	int n,ans=1;
	string s;
	cin>>n>>s;
	f(i,n){
		if(i&&s[i]!=s[i-1])ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int n, i, j;
	int table[10] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};
	int ans[10];
	
	while (scanf("%d", &n) != EOF){
		for (i = 0; i < 10; i++){
			ans[i] = 0;
		}
		
		j = 0;
		for (i = 9; i >= 0; i--){
			if (n - table[i] == 0){
				ans[j++] = table[i];
				break;
			}
			else if (n - table[i] > 0){
				n -= table[i];
				ans[j++] = table[i];
			}
		}
		
		while (0 < ans[j - 2] && ans[j - 2] < 513){
			printf("%d ", ans[--j]);
		}
		printf("%d\n", ans[--j]);
	}
	
	return 0;
}

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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  n *= 3;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  reverse(a, a + n);
  long long res = 0;
  for (int i = 1; i < n / 3 * 2; i += 2) res += a[i];
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 2560
A, B, K = map(int, input().split(' '))
canA = []
canB = []
for i in range(1, A+1):
    if(A%i == 0):
        canA.append(i)
for i in range(1, B+1):
    if(B%i == 0):
        canB.append(i)
        
same = list(set(canA) & set(canB))
same.sort()
print(same[-K])

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

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	if ((N * A) - B == 0)
		cout << N * A << endl;
	if ((N * A) - B < 0)
		cout << N * A << endl;
	if ((N * A) - B > 0)
		cout << B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main(int argc, const char * argv[]) {
    int N; cin >> N;
    vector<int> a(N, 0);
    for(int i = 0; i < N; i++) cin >> a[i];
    map<int, int> mp;
    for (int i = 0; i < N; i++) mp[a[i]]++;
    
    int cnt = 0;
    for(auto ia : mp) {
        if(ia.first <= ia.second) {
            cnt += ia.second - ia.first;
        } else {
            cnt += ia.second;
        }
    }
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 5120
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
a = [list(map(int,input().split())) for i in range(n)]
cnt = 0
for i in range(n):
  cc = 0
  for j in range(m):
    cc += b[j]*a[i][j]
  if cc + c > 0:
    cnt += 1
print(cnt)

Measured memory_bytes: 3060
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll x;
ll powll(ll k){
    return k*k*k*k*k;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> x;
    for(ll i=-1000;i<=1000;i++){
        for(ll j=-1000;j<=1000;j++){
            if(powll(i)-powll(j)==x)return cout<<i<<" "<<j<<"\n",0;
        }
    }
}


Measured memory_bytes: 3616
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn           printf("\n")
#define nl           cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S       second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define mod     1000000007
#define Inf     1000000000000000
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/
    
    lli N,i;
    cin>>N;
    
    lli cnt_4=0,cnt_Odd=0,cnt_2=0;
    
    rep(i,0,N)
    {
        lli x;
        cin>>x;
        
        if(x%2)
        {
            cnt_Odd++;
        }
        else
        {
            if(x%4)
            {
                cnt_2++;
            }
            else
            {
                cnt_4++;
            }
        }
    }
    
    if(!cnt_2)
    {
        if(cnt_Odd-1<=cnt_4)
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }
    }
    else
    {
        if(cnt_Odd<=cnt_4)
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }
    }
    
    
    




 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const long inf=1e11;
int main(){
	int N;long W;cin>>N>>W;
	long w[N],v[N];
	rep(i,0,N) cin>>w[i]>>v[i];
	long dp[N+1][size+1];
    rep(i,0,N+1)rep(j,0,size+1) dp[i][j]=inf;
    dp[0][0]=0;
	rep(i,1,N+1){
		rep(j,0,size+1){
			dp[i][j]=dp[i-1][j];
            if(j>=v[i-1]) dp[i][j]=min(dp[i][j],dp[i-1][j-v[i-1]]+w[i-1]);
		}
	}//pprint(dp,,N+1,40);
	int ans=0;
	rep(j,0,size+1){
		if(dp[N][j]<=W) ans=max(ans,j);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 79104
n,m = map(int,input().split())
n=min(n,m)
x = list(map(int,input().split()))

x = sorted(x)

#print("x",x)

y = []

for i in range(m-1):
    y.append(x[i+1]-x[i])

y = sorted(y, reverse=True)

#print("y",y)

skip = 0
for i in range(n-1):
    skip += y[i]

print(max(x)-min(x)-skip)


Measured memory_bytes: 83304
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func stringLineScan() string {
	sc.Scan()
	return sc.Text()
}

var ans int

func main() {
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(stringLineScan())
	m, _ := strconv.Atoi(stringLineScan())
	s := make([]int, m)
	c := make([]int, m)
	for i := 0; i < m; i++ {
		s[i], _ = strconv.Atoi(stringLineScan())
		c[i], _ = strconv.Atoi(stringLineScan())
	}
	ans := -1
	for i := 0; i < 1000; i++ {
		x := strconv.Itoa(i)
		f := true
		if len(x) == n {
			for j := 0; j < m; j++ {
				y, _ := strconv.Atoi(string(x[s[j]-1]))
				if y != c[j] {
					f = false
				}
			}
		} else {
			f = false
		}
		if f == true {
			ans = i
			break
		}
	}
	fmt.Println(ans)
}


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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/

//MODでわる

const int MAX = 5100000;

const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void Cinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  ll x,y;
  cin >> x >> y;
  
  Cinit();
  
  if(((2 * y - x) % 3 == 0) && ((2 * x - y) % 3 == 0) && (2 * y - x >= 0) && (2 * x - y >= 0)){
    ll a = (2 * y - x) / 3;
    ll b = (2 * x - y) / 3;
    
    cout << COM(a + b,min(a,b))<< endl;
    
  }else{
    cout << 0 << endl;
  }
    
    
}

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

int main() {
  int N, L;
  cin >> N >> L;

  int m = 300;
  for (int i=0; i<N; ++i) {
    m = abs(m) <= abs(L+i) ? m : L+i;
  }
  cout << L * N + N * (N - 1) / 2 - m << "\n";
}


Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datH, datW) = readLine.split(" ").map(_.toInt)
    val board = for(i <- 1 to datH) yield readLine.split("").filterNot(_ == "").map(_(0))
    val board2 = board.map( Array('*') ++ _ ++ Array('*') )
    // board2.foreach(a=> println("DEBUG: " + " " + a.length + " " + a.mkString))

    def searchMine(x: Int, y: Int): Char = {
      if( board2(y)(x) == '#' ) '#'
      else if( board2(y)(x) == '*' ) '*'
      else {
        val upperline = if (y - 1 < 0) 0 else
          (if (board2(y - 1)(x - 1) == '#') 1 else 0) +
          (if (board2(y - 1)(x    ) == '#') 1 else 0) +
          (if (board2(y - 1)(x + 1) == '#') 1 else 0)
        val centerline =
          (if (board2(y    )(x - 1) == '#') 1 else 0) +
          (if (board2(y    )(x + 1) == '#') 1 else 0)
        val lowerline = if (y + 1 >= datH) 0 else
          (if (board2(y + 1)(x - 1) == '#') 1 else 0) +
          (if (board2(y + 1)(x    ) == '#') 1 else 0) +
          (if (board2(y + 1)(x + 1) == '#') 1 else 0)
        // println(s"DEBUG: $x $y $upperline $centerline $lowerline")
        (upperline + centerline + lowerline + '0').toChar
      }
    }
    val board3 = for(y <- 0 until datH ; x <- 1 to datW) yield searchMine(x, y)
    val board4 = board3.grouped(datW)
    board4.foreach (a => println( a.mkString ))
  }
}


Measured memory_bytes: 25524
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        List<Integer> red = new ArrayList<Integer>();
        List<Integer> green = new ArrayList<Integer>();
        List<Integer> white = new ArrayList<Integer>();
        for (int i=0; i<A; i++) {
            red.add(sc.nextInt());
        }
        for (int i=0; i<B; i++) {
            green.add(sc.nextInt());
        }
        for (int i=0; i<C; i++) {
            white.add(sc.nextInt());
        }
        Collections.sort(red, Collections.reverseOrder());
        Collections.sort(green, Collections.reverseOrder());
        Collections.sort(white, Collections.reverseOrder());
        List<Integer> all = new ArrayList<Integer>();
        all.addAll(red.subList(0, X));
        all.addAll(green.subList(0, Y));
        all.addAll(white);
        Collections.sort(all, Collections.reverseOrder());
        long sum = 0;
        for (int x: all.subList(0, X+Y)) {
            sum += (long)x;
        }
        System.out.println(sum);
    }
}

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

#define F(i,a,b) for(long long  i =a; i<b; i++)
#define rF(i,a,b) for(long long i=a-1; i>=b;i--)
#define endl "\n"
#define min1(x,y,z) min(x, min(y,z))
#define max1(x,y,z) max(x, max(y,z))
#define input_vector(v,n,type) vector<type> v;for(int i=0;i<n;i++){type x;cin>>x;v.push_back(x);}
#define IOS ios_base::sync_with_stdio(false);  cin.tie(NULL);  cout.tie(NULL);
#define int long long
#define inf (1LL<<61)
typedef pair<int,int> ii;
typedef vector<pair<int,int>> vii;
typedef vector<int> vi;



int32_t main()
{
      IOS;

            
      int a, b, m;
      cin>>a>>b>>m;

      vector<int> A(a), B(b);
      int mina = inf, minb = inf;
      for (int i = 0; i < a; i++) {
            cin>>A[i];
            mina = min (mina, A[i]);
      }
      for (int j = 0; j < b; j++) {
            cin>>B[j];     
            minb = min (minb, B[j]);
      }


      int ans = mina+minb;
      for (int i = 0; i < m; i++) {
            int x, y, c;
            cin>>x>>y>>c;
            ans = min (ans, A[x-1]+B[y-1]-c);
      }
      cout<<ans<<endl;


            



      


        
























            return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++) cout << 'x';
    cout << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
typedef pair<ll, ll> P;
map<P, int> thth;
ll A[100005], B[100005];
ll H, W, N;
ll ans[10];
int vx[9] = {0,0,1,1,1,0,-1,-1,-1};
int vy[9] = {0,-1,-1,0,1,1,1,0,-1};
ll zero;

int main(){
  FOR(i,0,10) ans[i] = 0;
  cin >> H >> W >> N;
  FOR(i,0,N) scanf("%lld %lld", A+i, B+i);
  zero = (W-2)*(H-2);
  FOR(i,0,N){
    ll a = A[i], b = B[i];
    FOR(j,0,9){
      ll aa = a + vy[j], bb = b + vx[j];
      if(aa <= 1 || aa >= H || bb <= 1 || bb >= W) continue;
      thth[P(aa, bb)]++;
    }
  }
  // 個数
  for(auto itr = thth.begin(); itr != thth.end(); itr++){
    ans[itr->second]++;
  }
  ans[0] = zero;
  FOR(i,1,10){
    ans[0] -= ans[i];
  }
  FOR(i,0,10){
    cout << ans[i] << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;

const ll INF = 1LL << 60;

vector<vector<pair<ll,ll>>> to;
vector<ll> dist;

int main(){
ll N,M; cin >> N >> M; to.resize(N);
  dist = vector<ll> ( N , INF);
  for(ll i = 0; i < M; i++){
    ll a,b,c; cin >> a >> b >> c; a--; b--; c *= -1;
    to[a].push_back(make_pair(b,c));}
  
  dist[0] = 0;
  
  for(ll j = 0; j < 2* N - 2; j++){
    //0~ N - 2までは最小値検索、　N - 1から 2* N - 3までは閉路検出
    for(ll k = 0; k < N; k++){
      if( dist[k] == INF){ continue;}
      for(auto ne: to[k]){
        //ノードkに着目して、distを更新していく
        //第一成分がkから繋がるノード、第二成分がkと第一成分との距離
        ll p = ne.first; ll q = ne.second;
        if( dist[p] > dist[k] + q){ 
          if(  p == N - 1 && j >= N - 1 ){ cout << "inf" << endl; return 0;}
          dist[p] = dist[k] + q; }
      }}}
  
  cout << -dist[N-1] << endl; return 0;}
         

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

int main() {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int dx, dy;
	dx = x1-x2;
	dy = y1-y2;

	cout << x2 + dy << " " << y2 - dx << " " << x1 + dy << " " << y1 -dx << endl;
	return 0;
}

Measured memory_bytes: 256
def warshall_floyd(d):
    n = len(d)
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


H, W = map(int, input().split())
c = []
for _ in range(10):
    c.append(list(map(int, input().split())))

d = warshall_floyd(c)
ans = 0
for _ in range(H):
    line = map(int, input().split())
    for v in line:
        if v != -1:
            ans += d[v][1]


print(ans)


Measured memory_bytes: 41324
<?php
  fscanf(STDIN, "%d", $n);
  for ($i=1; $i<=$n; $i++) {
    fscanf(STDIN, "%d", $talk_c);
    for ($j=1; $j<=$talk_c; $j++) {
      fscanf(STDIN, "%d %d", $h, $tf);
      $a[$i][$j] = ['h' => $h, 'tf' => $tf];
    }
  }

  for ($i=pow(2, $n)-1; $i>=0; $i--) {
    $pattern[] = str_pad(decbin($i), $n, 0, STR_PAD_LEFT);
  }

  foreach ($pattern as $temp) {
    foreach ($a as $key => $shougen_s) {
      $temp_point[$key] = substr($temp, -$key, 1);
      if ($temp_point[$key] == 0) {
        continue;
      }
      foreach ($shougen_s as $shougen) {
        if (substr($temp, -$shougen['h'], 1) != $shougen['tf']) {
          continue 3;
        }
      }
    }
    $result[] = substr_count($temp, 1);
  }
rsort($result);
echo $result[0];

Measured memory_bytes: 8952
#include <stdio.h>
int main(void){
    int m, f, r;
    
    while(1){
    scanf("%d %d %d", &m, &f, &r);

    if(m == -1 && f == -1 && r == -1) break;

    if(m==-1||f==-1){
        printf("F\n");
    }
    else if(m+f>=80){
        printf("A\n");
    }
    else if(m+f>=65&&m+f<80){
        printf("B\n");
    }
    else if(m+f>=50&&m+f<65){
        printf("C\n");
    }
    else if(m+f>=30&&m+f<50&&r>=50){
        printf("C\n");
    }
    else if(m+f>=30&&m+f<50){
        printf("D\n");
    }
    else if(m+f<30){
        printf("F\n");
    }
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int N; scanf("%d", &N);
  vector<vector<pair<int, ll>>> adj(N + 5, vector<pair<int, ll>>());
  for (int i = 0; i < N - 1; ++i) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    adj[a].push_back(make_pair(b, c));
    adj[b].push_back(make_pair(a, c));
  }

  int Q, K;
  scanf("%d %d", &Q, &K);
  vector<ll> dist(N + 5, numeric_limits<ll>::max());
  dist[K] = 0;
  priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> que;
  que.push(make_pair(0, K));
  while (not que.empty()) {
    pair<ll, int> p = que.top(); que.pop();
    ll d = p.first;
    int u = p.second;
    if (d > dist[u]) { continue; }
    for (pair<ll, int> p : adj[u]) {
      int v = p.first;
      ll cost = p.second;
      if (d + cost < dist[v]) {
        dist[v] = d + cost;
        que.push(make_pair(dist[v], v));
      }
    }
  }
  for (int i = 0; i < Q; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    printf("%lld\n", dist[x] + dist[y]);
  }
  return 0;
}


Measured memory_bytes: 11120
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;
vector<int> A;

void solve(){
	sort(A.begin(), A.end());
	cout << A[N - 1] - A[0] << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	A.resize(N);
	rep(i, N) {
		cin >> A[i];
	}
		solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n;cin>>n;
  bool ans=n%10==9;
  n/=10;
  ans=ans||n%10==9;
  cout<<btos(ans)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    ll N;
    cin >> N;
    map<ll, ll> mii;
    REP(i, N) {
        ll A;
        cin >> A;
        mii[A]++;
    }
    ll ans = 0;
    for (auto p : mii) {
        ans += p.first * p.second;
    }

    ll Q;
    cin >> Q;
    REP(i, Q) {
        ll B, C;
        cin >> B >> C;
        ll cnt = mii[B];
        mii[C] += cnt;
        mii[B] = 0;
        ans += (C - B) * cnt;
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (a==b && b==c) cout << 1 << endl;
  else if (a==b || b==c || c==a) cout << 2 << endl;
  else cout << 3 << endl;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int32 N;
	cin >> N;
	vector<string> s(N*2);
	REP(i, N){
		cin >> s[i];
		s[i] += s[i];
		s[N+i] = s[i];
	}
	vector<vector<int32>> r(2*N, vector<int32>(2*N, 0));
	REP(i, 2*N){
		REP(j, 2*N){
			int32 cnt = 0;
			for(int32 k = 0;i+k < 2*N && j+k < 2*N;k++){
				if(s[i][j+k] == s[i+k][j]) cnt++;
				else break;
			}
			r[i][j] = cnt;
		}
	}
	int64 res = 0;
	REP(i, N){
		REP(j, N){
			int64 mini = INF;
			for(int32 k = N-1;k >= 0;k--){
				int64 x = r[i+k][j+k];
				mini = min(mini, x+(int64)k);
			}
			if(mini >= N) res++;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 3456
N ,K, Q =map(int, input().split())
Player = [K-Q]*N

for i in range(Q):
    Answerer = int(input())-1
    #回答者をプラス
    Player[Answerer] = Player[Answerer]+1

for i in range(N):
    if Player[i]>0:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 6584
n,T=map(int,input().split())
t=[int(i) for i in input().split()]
ans=0
pre=t[0]
for i in range(1,n):
    c=t[i]
    if c-pre>T:
        ans+=T
    else:
        ans+=c-pre
    pre=c
print(ans+T)

Measured memory_bytes: 85456
while True:
    n=int(input())
    if n==0:
        break
    x=[]
    for i in range(n):
        y=int(input())
        x.append(y)
    x.sort()
    x.pop(n-1)
    x.pop(0)
    b=sum(x)//len(x)
    print(b)


Measured memory_bytes: 5596
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//#include <bits/stdc++.h>


int main() {
	int n,y;
	cin >> n;
	string s;
	
	y = 0;
	rep(i, n) {
		cin >> s;
		if (s == "Y") {
			printf("Four\n");
			break;
		}
		else {
			y++;
		}
	}
	if (y == n )
		printf("Three\n");
	return 0;
}


Measured memory_bytes: 3604
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    a, b, c = map(int, input().split())
    k = int(input())
    i = k+1
    for p in range(i):
        for q in range(i-p):
            for r in range(i-p-q):
                aa, bb, cc = a, b, c
                for k in range(p):
                    aa*=2
                for k in range(q):
                    bb*=2
                for k in range(r):
                    cc*=2
                if aa < bb < cc:
                    print("Yes")
                    exit()
    print("No")
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 10396
s=input()
t=input()
u=[0]*(len(s)-len(t)+1)

for i in range(len(s)-len(t)+1):
    c=0
    for j in range(len(t)):
         if s[i+j]==t[j]:
            c+=1
    u[i]=c
print(len(t)-max(u))
    
    

Measured memory_bytes: 9044
import sys
import collections
import bisect
import math
readline = sys.stdin.readline


def main():
    n = int(readline().rstrip())
    A = sorted(list(map(int, readline().rstrip().split())))
    a = sorted(A[0:n-1] * 2, reverse=True)
    print(max(A) + sum(a[0:n-2]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 32348
# 2019/08/15

n=int(input())
f=[[]]*n
for i in range(n):
    f[i]=int(input().replace(' ',''),2)

p=[[]]*n
for i in range(n):
    p[i]=list(map(int,input().split()))

res=float('-inf')
for i in range(1,2**10):
    cnt=0
    for j in range(n):
        idx=bin(i&f[j]).count('1')
        cnt+=p[j][idx]
    res=max(res,cnt)
print(res)

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

void Main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.rbegin(), A.rend());

  queue<int> score;
  score.push(A[0]);

  long long ans = 0;
  for (int i = 1; i < N; i++) {
    ans += score.front(); score.pop();
    score.push(A[i]);
    score.push(A[i]);
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 4760
#include<stdio.h>
int main(){
  int n,i;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    int id,m;
    int s1,s2,max=-1;
    for(i=0;i<n;i++){
      scanf("%d %d %d",&id,&s1,&s2);
      if(max<s1+s2){
	max=s1+s2;
	m=id;
      }
    }
    printf("%d %d\n",m,max);
  }
  return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

class hawawa
{
  static Printer sw = new Printer(Console.OpenStandardOutput()) { AutoFlush = false };

  static void Main()
  {
    Console.SetOut(sw);
    solve();
    Console.Out.Flush();
  }

  static string target;

  static void solve()
  {
    Scanner scanner = new Scanner();
    target = scanner.next();
    Console.WriteLine(dfs(target) ? "Yes" : "No");
  }

  static bool dfs(string str)
  {
    if (set.Contains(str)) return false;
    if (str == "ABC") return true;
    set.Add(str);
    int size = str.Count();
    for (char c = 'A'; c <= 'C'; c++)
    {
      int num = size - str.Replace(c.ToString(), "").Count();
      if (size - str.Replace("ABC", "").Count() == num * 3 && dfs(str.Replace("ABC", c.ToString())))
      {
        return true;
      }
    }
    return false;
  }
  static List<string> set = new List<string>();

}

class Scanner
{
  string[] s;
  int i;


  char[] cs = new char[] { ' ' };

  public Scanner()
  {
    s = new string[0];
    i = 0;
  }

  public string next()
  {
    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()
  {
    return int.Parse(next());
  }

  public long nextLong()
  {
    return long.Parse(next());
  }

  public double nextDouble()
  {
    return double.Parse(next());
  }

}


class Printer : StreamWriter
{
  public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
  public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
  public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { }
}



Measured memory_bytes: 33880