akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

fn main() {
    input! {
        n: usize,
        mat: [[i32; 3]; n],
    }

    
    //let mut dp = Box::new([[0; 3]; 100000]);
    let mut dp = vec![vec![0; 3]; 100000];

    dp[0][0] = mat[0][0];
    dp[0][1] = mat[0][1];
    dp[0][2] = mat[0][2];

    for i in 1..n {
        let t = i - 1;
        dp[i][0] = cmp::max(dp[t][1], dp[t][2]) + mat[i][0];
        dp[i][1] = cmp::max(dp[t][0], dp[t][2]) + mat[i][1];
        dp[i][2] = cmp::max(dp[t][0], dp[t][1]) + mat[i][2];
    }

    let ans = cmp::max(cmp::max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]);

    println!("{}", ans);
    
}


Measured memory_bytes: 14588
k=int(input())
if k==7 or k==1:
    print(1)
else:
    a=7
    for i in range(1,10**6):
        a=10*a+7
        if a%k==0:
            print(i+1)
            break
        else:
            a=a%k
    else:
        print(-1)

Measured memory_bytes: 9176
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

struct Node;
struct Edge{
	Node *from, *to;
	ll limit, rem;
    Edge(){ }
	Edge(Node* from, Node* to, ll limit = 1): from(from), to(to), limit(limit), rem(limit){ }
    ll remain(bool rev = false){
        return rev ? limit - rem : rem;
    }
    void pour(ll f, bool rev = false){
        rem -= rev ? - f : f;
    }
};
int numNodes = 0;
struct Node{
    int id;
	vector<Edge*> inEdges, outEdges;
    Node(): id(numNodes++){ }
    Edge* add(Edge* e){
        outEdges.push_back(e);
        e->to->inEdges.push_back(e);
        return e;
    }
};
ll flow(Node* start, Node* goal, vector<char>& visited, ll cur){
	if(start == goal){ return cur; }
    prints(start->id, start->outEdges);
    auto _flow = [&](Node* Edge::* to, vector<Edge*> Node::* edges, bool rev = false){
        for(Edge* e : start->*edges){
            Node* v = e->*to; 
            if(!e->remain(rev) || visited[v->id]){ continue; }
            visited[v->id] = true;
            ll lim = min(cur, e->remain(rev));
            if((lim = flow(v, goal, visited, lim))){
                e->pour(lim, rev);
                prints("pour", lim);
                return lim;
            }
        }
        return 0ll;
    };
    ll ret = 0;
    if((ret = _flow(&Edge::to, &Node::outEdges)) ||
       (ret = _flow(&Edge::from, &Node::inEdges, true))){
        return ret;
    }
	return ret;
}
ll maxFlow(Node* start, Node* goal){
	if(start == goal){ exit(1); }
	ll ret = 0;
    while(1){
        vector<char> visited(numNodes);
        ll f;
		if(!(f = flow(start, goal, visited, MLL))){
            break;
        }
        ret += f;
	}
	return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<Node> nodes(n + 1);
    Node sn, tn;
    vector<Edge> edges(10 * n);
    int eidx = 0;
    ll sum = 0;
    for(int i = 1; i <= n; i++){
        int a; cin >> a;
        if(a > 0){
            sum += a;
            edges[eidx] = Edge(&nodes[i], &tn, a);
            nodes[i].add(&edges[eidx]);
            eidx++;
        }else{
            edges[eidx] = Edge(&sn, &nodes[i], - a);
            sn.add(&edges[eidx]);
            eidx++;
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = i + i; j <= n; j += i){
            edges[eidx] = Edge(&nodes[i], &nodes[j], MLL);
            nodes[i].add(&edges[eidx]);
            eidx++;
        }
    }
    ll mi = maxFlow(&sn, &tn);
    cout << sum - mi << '\n';
}


Measured memory_bytes: 256
#[test]
fn check_solve() {
    println!(
        "input:\n2 3\n1 2 3\n0 1 1\n\noutput:\n{}",
        solve("2 3\n1 2 3\n0 1 1\n")
    );
    println!(
        "input:\n3 2\n1 0\n2 1\n1 0\n\noutput:\n{}",
        solve("3 2\n1 0\n2 1\n1 0\n")
    );
    println!(
        "input:\n1 5\n9 9 9 9 9\n\noutput:\n{}",
        solve("1 5\n9 9 9 9 9\n")
    );
}
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let h: usize = sc.read();
    let w: usize = sc.read();
    let a: Vec<Vec<usize>> = (0..h)
        .map(|_| (0..w).map(|_| sc.read()).collect())
        .collect();

    let nxt = |i, j| {
        if i & 1 == 0 {
            if j == w - 1 {
                (i + 1, j)
            } else {
                (i, j + 1)
            }
        } else {
            if j == 0 {
                (i + 1, j)
            } else {
                (i, j - 1)
            }
        }
    };

    let mut ret = String::new();
    use std::fmt::Write;

    let mut i = 0;
    let mut j = 0;
    let mut hav = 0;
    let mut n = 0;
    loop {
        let (ni, nj) = nxt(i, j);
        if ni >= h {
            break;
        }
        if a[i][j] % 2 != hav {
            hav = 1;
            n += 1;
            writeln!(&mut ret, "{} {} {} {}", i + 1, j + 1, ni + 1, nj + 1).unwrap();
        } else {
            hav = 0;
        }
        i = ni;
        j = nj;
    }

    format!("{}\n{}", n, ret)
}
fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


Measured memory_bytes: 10492
use std::io::*;
use std::str::*;

fn read<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok()
}

fn main() {
    let n: u64 = read().unwrap();

    if n == 1 {
        println!("{}", 1);
        return;
    }

    let mut prepre = 2;
    let mut pre = 1;

    let mut ans: u64 = 0;
    for _ in 2..n + 1 {
        ans = pre + prepre;
        prepre = pre;
        pre = ans;
        //        println!("{}, {}, {}", ans, pre, prepre);
    }

    println!("{}", ans);

}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

// find_by_order(k) returns the iterator to the kth largest element (start from 0)
// order_of_key(k) returns the number of elements in the set which are strictly less than the value k

using namespace std;
using namespace __gnu_pbds;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define rightmostbit(x) __builtin_ffsll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout << fixed; cout << setprecision(x); cout << y;
#define pi              3.141592653589793238
#define mk(a,n)         int n;cin>>n;vi a(n);for(int i=0;i<n;i++) cin>>a[i]
#define w(x)            int x; cin>>x; while(x--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

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

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

void g_b()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
// 1, 1, 2, 5, 14, 42, 132, 429, 1430, CATALAN NUMBER
int m[1000001];
int32_t main()
{
	g_b();
	int tot;
	mk(a, n);
	string ans = "not coprime";
	for (auto x : a) m[x]++;
	bool f = 0;
	for (int i = 2; i <= 1000000; i++)
	{
		int c = 0;
		for (int j = i; j <= 1000000; j += i) {c += m[j];}
		if (c > 1) {f = 1; break;}
	}
	if (!f)
	{
		cout << "pairwise coprime";
		return 0;
	}
	int res = a[0];
	for (int i = 1; i < n; ++i)
	{
		res = __gcd(res, a[i]);
	}
	if (res == 1) ans = "setwise coprime";
	cout << ans;
	return 0;
}


Measured memory_bytes: 18688
#include<bits/stdc++.h>
#define ll double
#define fr(a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define triplet pair<int,pair<int,int>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

ll dp[301][301][301];
ll solve(int one, int two, int three, int& n)
{
    if(one < 0 || two < 0 || three < 0)
        return 0;
    if(three == 0 && two == 0 && one == 0)
        return 0;

    if(dp[one][two][three] > 0)
        return dp[one][two][three];

    int remaining = one + two + three;
    ll exp_val = n+one*solve(one-1,two,three,n) + two*solve(one+1,two-1,three,n) +
                    three*solve(one,two+1,three-1,n);

    return dp[one][two][three] = exp_val/remaining;
}

int main(){
    int i,j,t,n,m,p,k;
    //fast_io;
    //cin>>t;
    t=1;
    while(t--)
    {
        cin>>n;
        int one=0,two=0,three=0;

        fr(0,n){
            int x;
            cin >> x;
            if(x == 1)one++;
            else if(x == 2)two++;
            else three++;
        }

        memset(dp, -1, sizeof dp);
        cout<<fixed<<setprecision(9)<<solve(one,two,three,n);
    }
    return 0;
}


Measured memory_bytes: 213376
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
	int t=1;
	//cin >> t;
	while(t--){
		ll int a=0,b=0,c=0,count=0;
      	cin >> a >> b >> c;
      	if(a%c==0){count++;}
      	cout << b/c - a/c +count<<endl;
	}
}

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

int main( void )
{
    int n;
    cin >> n;
    
    if ( n % 10 == 9 || n / 10 == 9 )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int A[21], B[21], C[21];
    int N;
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> A[i];
    }
    for(int i = 1; i <= N; i++){
        cin >> B[i];
    }
    for(int i = 1; i < N; i++){
        cin >> C[i];
    }
    int ans = 0;
    for(int i = 1; i <= N; i++){
        ans += B[A[i]];
        if(A[i]+1 == A[i+1]) {
            ans += C[A[i]];
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
    int n, k,ans=1;
    cin>>n>>k;
    for (int i=0; i<n; i++)
    {
        ans=min(ans+k, ans*2);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
max_cnt = 0
max_num = 1

#1からnまでの数を調べる
for i in range(1, n + 1):
    count = 0
    num = i
    #iが2で割りきれるまで割る
    while i % 2 == 0 :
        count += 1
        i = i//2
    
    #割り切れる回数を更新
    if max_cnt < count :
        max_cnt = count
        max_num = num

print(max_num)

Measured memory_bytes: 9184
#include <iostream>
using namespace std;
int* scan(int);
int main(void){
    int N = 0;
    int* V;
    int* C;
    cin >> N;
    V = scan(N);
    C = scan(N);
    int v_c = 0;
    for(int i = 0;i < N;i++){
        if(V[i] - C[i] > 0) v_c += (V[i]-C[i]);
    }
    printf("%d\n",v_c);
}

int* scan(int N){
    int* s = new int[N];
    for(int i = 0;i < N;i++){
        cin >> s[i];
    }
    return s;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

    static int L;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        L = sc.nextInt();

        PrintWriter pw = new PrintWriter(System.out);
        List<Edge> es = solve();
        pw.println(20 + " " + es.size());
        for (Edge e : es) {
            pw.println(e.a + " " + e.b + " " + e.d);
        }
        pw.flush();
    }

    static List<Edge> solve() {
        List<Edge> edges = new ArrayList<>();
        int cur = 20;

        while( L > 0 ) {
            if( L % 2 == 0 ) {
                int M = L / 2;
                int next = L == 2 ? 1 : cur-1;
                edges.add(new Edge(next, cur, M));
                edges.add(new Edge(next, cur, 0));
                cur = next;
                L = M;

            } else {
                if( L != 1 ) {
                    edges.add(new Edge(1, cur, L-1));
                }
                L--;
            }
        }
        return edges;
    }

    static class Edge {
        int a, b, d;

        public Edge(int a, int b, int d) {
            this.a = a;
            this.b = b;
            this.d = d;
        }
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  for (int x = 1; x <= 1250; x++) {
    if (x + A == (int)(x * 1.08) && x + B == (int)(x * 1.1)) {
      cout << x;
      return 0;
    }
  }
  cout << -1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, ans=0;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> C.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    ans += B.at(i);
  }
  
  for (int i = 0; i < N-1; i++) {
    if ( A.at(i) + 1 == A.at(i+1) ){
      ans += C.at( A.at(i)-1 );
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int H = Integer.parseInt(in.next());
            int W = Integer.parseInt(in.next());
            char[][] S = new char[H][W];
            for (int i = 0; i < H; i++) {
                S[i] = in.next().toCharArray();
            }
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    int mine = 0;
                    if (S[i][j] == '.') {
                        if (i > 0) {
                            if (j > 0) if (S[i - 1][j - 1] == '#') mine++;
                            if (S[i - 1][j] == '#') mine++;
                            if (j < W - 1) if (S[i - 1][j + 1] == '#') mine++;
                        }
                        if (i < H - 1) {
                            if (j > 0) if (S[i + 1][j - 1] == '#') mine++;
                            if (S[i + 1][j] == '#') mine++;
                            if (j < W - 1) if (S[i + 1][j + 1] == '#') mine++;
                        }
                        if (j > 0 && S[i][j - 1] == '#') mine++;
                        if (j < W - 1 && S[i][j + 1] == '#') mine++;
                        String temp = "" + mine;
                        char[] temp2 = temp.toCharArray();
                        S[i][j] = Character.valueOf(temp2[0]);

                    }
                }
            }

            // 出力
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    out.print(S[i][j]);

                }
                out.println();
            }

        }

    }
}



Measured memory_bytes: 23892
#include <iostream>

int main(void) {
    u_int d;
    auto f_x = [](const int x){ return x*x; };

    while (std::cin >> d) {
        u_int sum = 0;
        for (u_int i = 0; i + d <= 600; i += d) {
            sum += f_x(i) * d;
        }
        std::cout << sum << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const double PI = 3.14159265358979323846;

int main() {
  string s;
  cin >> s;
  string f = s.substr(0, 5);
  string S= s.substr(6, 7);
  string t = s.substr(14, 5);
  cout << f << " " << S << " " << t << endl;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <random>
#include <vector>
//#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
 
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) (a).begin(), (a).end()
#define cae cout<<ans<<endl
 
int main()
{
	int n,m,x;
	cin>>n>>m>>x;
	vi a(m);
	rep(i,m){
		cin>>a.at(i);
	}
	vi c(n+1,0);
	rep(i,m){
		c.at(a.at(i))=1;
	}
	vi sum(n+1,0);
	rep(i,n){
		sum.at(i+1)=sum.at(i)+c.at(i);
	}
	int ans=min(sum.at(x)-sum.at(0),sum.at(n)-sum.at(x));
	cae;
	return 0;
}

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

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int first = in.nextInt();
        final int second = in.nextInt();
        System.out.println(first * second);
    }
}


Measured memory_bytes: 35820
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  int i,j,k=0;
  long long int x;

  scanf("%lld",&x);

  for(i=-118;i<=119;i++)
  {
    for(j=-119;j<i;j++)
    {
      if(pow(i,5)-pow(j,5)==x)
      {
        printf("%d %d\n",i,j);
        k=1;
        break;
      }
      if(k==1) break;
    }
  }

  return 0;
}

Measured memory_bytes: 2472
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}
func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 100000007)
	sc.Split(bufio.ScanWords)
	a, _ := strconv.Atoi(Scanner())
	b, _ := strconv.Atoi(Scanner())
	c, _ := strconv.Atoi(Scanner())
	a, b = b, a
	a, c = c, a
	fmt.Println(a, b, c)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int n,a,f,ans;
map<int,int> m;

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    for(int i=0;i<n;i++){
      cin>>a;
      if(m.find(a)==m.end())m[a]=1;
      else m[a]++;
    }
    f=0;
    map<int,int>::iterator ite;
    for(ite=m.begin();ite!=m.end();ite++){
      if((*ite).second>n/2){
	f=1;
	ans=(*ite).first;
	break;
      }
    }
    if(f)cout<<ans<<endl;
    else cout<<"NO COLOR"<<endl;
    m.clear();
  }
  return 0;
}

Measured memory_bytes: 2732
// Problem: Bite Eating
// Contest: Virtual Judge - AtCoder
// URL: https://vjudge.net/problem/AtCoder-abc131_b
// Memory Limit: 1048 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//
//#include <immintrin.h>
//#include <emmintrin.h>

#include <bits/stdc++.h>
//#pragma GCC optimize("O2")
#define vi vector<int>
#define pii pair<int, int >
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define LL long long
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define all(x) (x).begin(), (x).end()
#define all2(x,n) (x+1), (x+1+n)
#define sz(x) ((int)(x).size())
#define mod(x) ((x)%MOD)
#define debug(x) cerr<<#x<<" : "<<x<<endl
#define mt make_tuple
#define eb emplace_back
#define o(X) (1<<(X))
#define oL(X) (1LL<<(X))
#define contain(S,X) (((S)&o(X))!=0)
#define containL(S,X) (((S)&oL(X))!=0)
#define ppt(x) __builtin_popcount(x)
using namespace std;
const int INF=0x3f3f3f3f,N=5e6+5,MOD=1e9+7;
const LL INF_LL=0x3f3f3f3f3f3f3f3fLL;
inline int getplc(int x,int y) { return (x>>y)&1; }
template<typename T>
T square(T x) {return x*x;}
LL qpow(LL a,LL b=MOD-2,LL _MOD=MOD){
	LL res=1;
	for(;b;b>>=1,a=a*a%_MOD){
		if(b&1)res=res*a%_MOD;
	}
	return res;
}
// Smax
//int Smax() { return -INF; }
template <typename T>
T Smax(T x) { return x; }
template<typename T, typename... Args>
T Smax(T a, Args... args) { return max(a, Smax(args...)); }
// Smin
template <typename T>
T Smin(T x) { return x; }
template<typename T, typename... Args>
T Smin(T a, Args... args) { return min(a, Smin(args...)); }
template <typename T>
// erro
#define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); errl(_it, args); }

void errl(istream_iterator<string> it) {}
template<typename T, typename... Args>
void errl(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	errl(++it, args...);
}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl;}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << "=" << a << " # ";
	err(++it, args...);
}
void Solve();
int main() {
#ifndef ONLINE_JUDGE
//	freopen("in.txt","r",stdin);
//    freopen("o1.txt","w",stdout);
#endif
	ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
	Solve();
	return 0;
}

//////////////////////////////////////////////////////////////////


void Solve(){
  int ans=0,n,l;
  cin>>n>>l;
  if(l>=0)ans=l;
  else if(n+l-1<=0)ans=n+l-1;
  else ans=0;
  ans=(l+n+l-1)*n/2-ans;
  cout<<ans<<endl;
} 


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

int main(){

    while(1){
        int n; cin >> n;
        if(n == 0) break;

        vector<string> s(n);
        for(int i = 0; i < n; i++){
            cin >> s[i];
            s[i] = 'a' + s[i];
        }

        int ans = 0;
        bool flag1 = true;
        for(int k = 1; k < 110; k++){

            vector<string> b(n);

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

                int idx = 0;
                for(int j = 0; j < s[i].size() - 1; j++){
                    
                    if(idx == k) break;                
                    
                    if(s[i][j] == 'a' || s[i][j] == 'i' || s[i][j] == 'u' || s[i][j] == 'e' || s[i][j] == 'o'){
                        b[i] += s[i][j + 1];
                        idx++;
                    }

                }

            }

            bool flag = false;

            for(int i = 0; i < n; i++){
                for(int j = i + 1; j < n; j++){
                    //cout << i << " " << j << " " << b[i] << " " << b[j] << endl;
                    if(b[i] == b[j]){
                        flag = true;
                        break;
                    }

                    if(flag) break;
                }
            }

            if(!flag){
                cout << k << endl;
                flag1 = false;
                break;
            }
        }

        if(flag1) cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C;
  int ans;
  cin >> A >> B >> C;
  ans = max({A,B,C});
  if(ans==A){
  	cout << (ans*10)+B+C << endl;
  }
  else if(ans==B){
   	cout << (ans*10)+A+C << endl;
  }
  else{
    cout << (ans*10)+A+B << endl;
  }
}

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

int main(){
  ll n,a,b; cin >> n >> a >> b;
  ll ret=0;
  if(n<a) {
    ret=n;cout << ret; return 0;
  }
  ll sho = n/(a+b);
  ll ama = n%(a+b);
  ret = a*sho + min(a, ama);
  
  
  cout << ret;

}

Measured memory_bytes: 256
// Problem : F - Division or Subtraction
// Contest : AtCoder - AtCoder Beginner Contest 161
// URL : https://atcoder.jp/contests/abc161/tasks/abc161_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long

int n;

bool check(int n, int k){
    while(n%k == 0) n /= k;
    return n%k == 1;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    cin>>n;
    if(n == 2) return cout<<1, 0;
    int ans = 0;
    n--;
    for(int i=1;i*i<=n;i++){
        if(n%i == 0){
            if(i==1 || i==n/i) ans++;
            else ans += 2;
        }
    }
    n++;
    for(int i=1;i*i<=n;i++){
        if(n%i == 0){
            if(i==1 || i==n/i){
                if(check(n,n/i)) ans++;
            } else {
                if(check(n,i)) ans++;
                if(check(n,n/i)) ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3564
#include <iostream>
using namespace std;
#include <string>
#include <algorithm>

int main(){
    int n;
    cin >> n;
    string ans;
    for(int i = 0; n != 0; i++){
        if(n % 2 == 0){
            ans += '0';
        }else{
            ans += '1';
            n--;
        }
        n /= -2;
    }
    reverse(ans.begin(), ans.end());
    if(ans.empty()){
        ans = "0";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define Rep(i,a,b) for(register int i=(a),i##end=(b);i<=i##end;++i)
#define Repe(i,a,b) for(register int i=(a),i##end=(b);i>=i##end;--i)
#define For(i,a,b) for(i=(a),i<=(b);++i)
#define Forward(i,a,b) for(i=(a),i>=(b);--i)
#define Chkmax(a,b) a=a>b?a:b
#define Chkmin(a,b) a=a<b?a:b
template<typename T>inline void read(T &x)
{
	T f=1;x=0;char c;
	for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-1;
	for(;isdigit(c);c=getchar())x=x*10+(c^48);
	x*=f;
}
using namespace std;
const int MAXN=111;
static int n;
inline void init()
{
	read(n);
}
static long long ans=0,su=1e9;
inline void solve()
{
	static int u,v,flag=false;
	Rep(i,1,n)
	{
		read(u);read(v);
		if(u^v)flag=true;
		ans+=u;
		if(u>v)Chkmin(su,v);
	}
	printf("%lld\n",!flag?0:ans-su);
}
int main()
{
	init();
	solve();
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        HGrid1 solver = new HGrid1();
        solver.solve(1, in, out);
        out.close();
    }

    static class HGrid1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int h = in.nextInt();
            int w = in.nextInt();
            char[][] c = new char[h][w];
            ModInt[][] m = new ModInt[h][w];
            for (int i = 0; i < h; i++) {
                c[i] = in.next().toCharArray();
            }

            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    m[i][j] = new ModInt(0);
                }
            }

            m[0][0] = new ModInt(1);

            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (c[i][j] == '.') {
                        if (i > 0) {
                            // 左からこれる
                            m[i][j] = m[i][j].add(m[i - 1][j]);
                        }
                        if (j > 0) {
                            m[i][j] = m[i][j].add(m[i][j - 1]);
                        }
                    }
                }
            }

            out.println(m[h - 1][w - 1].getVal());


        }

    }

    static class ModInt {
        long val;
        int MOD = (int) 1e9 + 7;

        public ModInt(long i) {
            this.val = (int) ((i + MOD) % MOD);
        }

        public ModInt add(ModInt m) {
            return new ModInt(this.val + m.getVal());
        }

        public long getVal() {
            return val;
        }

    }
}



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

int main(){
  int N;
  cin >> N;
  long double ans = 0;
  for(int i = 0; i < N; ++i){
    long double a;
    cin >> a;
    ans += 1/a;
  }
  ans = 1/ans;
  cout << fixed << setprecision(12) << ans << endl;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n+1,0);
    rep(i,n){
        cin >> a.at(i+1);
        --a.at(i+1);
    }
    for(i = 0;i < n;++i){
        a.at(i+1) += a.at(i);
        a.at(i+1) %= k;
    }
    map<ll, vector<ll>> spare;
    for(i = 0;i <= n;++i){
        spare[a.at(i)].push_back(i);
    }
    ll ans = 0;
    for(auto x:spare){
        ll m = x.second.size();
        for(i = 0;i < m;++i){
            ll now = x.second.at(i);
            ll ind = lower_bound(all(x.second), now + k) - x.second.begin() - 1;
            ans += ind - i;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 26692
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
typedef pair<ll,ll> Pair;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }

const ll INF=99999999999999;
const ll MOD=1000000007;
ll accXOR(ll n){
  if(n <= 0) return 0;
  ll arr[4] = {n,1,n+1,0};
  return arr[n%4];
}
 
int main() {
  ll a,b;
  cin >> a >> b;
  ll x = accXOR(a-1)^accXOR(b);
  cout << x;
  
  

 return 0;
}

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

int main(){

    static int ans = 7;
    int result = 0;
    string equation = "";
    string s;
    cin >> s;

    
    for (int i = 0; i < (int)pow(2, 3); i++){

        result = (int)(s[0] - '0');
        equation = s[0];

        for (int j = 0; j < 3; j++){
            
            if((i & (int)pow(2,j))!= 0){
                equation += '+';
                result += (int)(s[j+1] - '0');
                equation += s[j + 1];
            }else{
                equation += '-';
                result -= (int)(s[j + 1] - '0');
                equation += s[j + 1];
            }
        }
        if(result == ans){
            cout << equation + "=7" << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
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 fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
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

A, B = MAP()
S = input()

flag = True
for i in range(len(S)):
    if i == A:
        if S[i] != '-':
            flag = False
    else:
        if not S[i].isdigit():
            flag = False
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 27220
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
using namespace std;

int main() {

	vector<int> ans;
	int a, b;
	//int cnt = 0;

	while (1) {
		cin >> a >> b;
		if (cin.eof()) { break; }
		ans.push_back(a + b);
	}

	for (int i = 0; i < ans.size(); i++)
	{
		string str = to_string(ans[i]);
		cout << str.size() << endl;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}


int main() {
    ll n,m; cin >> n >> m;

    if(n*2 <= m) {
        ll tmp = m - (n*2);
        cout << n + (tmp/4) << endl;
        return 0;
    } else {
        cout << m/2 << endl;
        return 0;
    }

}


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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int n;cin>>n;
    ll su=0;
    vector<ll> a(n+1,0);
    for(int i=1;i<=n;i++){
        cin>>a[i];
        su+=abs(a[i]-a[i-1]);
    }
    su+=abs(a[n]);
    for(int i=1;i<n;i++){
        cout<<su-(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))+abs(a[i+1]-a[i-1])<<endl;
    }
    cout<<su-abs(a[n]-a[n-1])-abs(a[n])+abs(a[n-1])<<endl;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define print(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
bool dp[81][81][12801] = {};

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
    int h, w;
    cin >> h >> w;
    READMAT(p, h, w);
    READMAT(q, h, w);
    dp[1][0][0] = dp[0][1][0] = 1;
    
    FOR (i, 1, h)
        FOR (j, 1, w)
            FOR (k, 0, 12800)
            {
                int a = abs(k + p[i][j] - q[i][j]);
                int b = abs(k + q[i][j] - p[i][j]);
                dp[i][j][k] = (dp[i - 1][j][a] || dp[i - 1][j][b]) || (dp[i][j - 1][a] || dp[i][j - 1][b]);
            }
    
    FOR (i, 0, 12800) 
        if (dp[h][w][i]) {cout << i; return 0;}
}

Measured memory_bytes: 81408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,n,m,i,j,k,a,b,c,x,y;
    cin>>a>>b>>c>>k;
    if(k<a)
        cout<<k;
    else if(k<=(a+b))
        cout<<a;
    else
        cout<<((k-a-b)*(-1))+a;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long mul(long long x,long long y)
{
    return ((x%mod)*(y%mod))%mod;
}
int main()
{
    int n;
    cin>>n;
    string s1,s2;
    cin>>s1>>s2;
    int i=0;
    long long ans;
    char pre;
    if(s1[i]==s2[i]){
        ans=3;
        pre='v';
    }
    else{
        ans=6;
        pre='h';
        ++i;
    }
    ++i;
    for(;i<s1.length();)
    {
        if(s1[i]==s2[i]){
            if(pre=='v')ans=mul(ans,2);
            pre='v';
        }
        else{
            if(pre=='v')ans=mul(ans,2);
            else ans=mul(ans,3);
            pre='h';
            ++i;
        }
        ++i;
    }
    cout<<ans;
    return 0;
}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    REP(i,N) cin >> S[i];
    // 文字列の種類を取得
    set<string> st(ALL(S));

    // mapの初期化
    map<string,int> mp;
    for(const auto& it:st) mp.insert(make_pair(it,0));

    // 文字列のカウント
    for(const auto& it_s:S) mp[it_s]++;

    // 最も書かれた回数の多い数を取得
    int maxi = 0;
    for(const auto& it:mp) chmax(maxi,it.second);

    // 最も書かれた回数の多い文字列なら出力(mapはキー昇順になる様にソートされているので初めから辞書順になっている。)
    for(const auto& it: mp) if(maxi == it.second) cout << it.first << endl;

    return 0;
}


Measured memory_bytes: 36096
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int N;
	cin >> N;
	map<long long, int> m;
	for (auto i = 0; i < N; ++i)
	{
		long long a;
		cin >> a;
		auto it = m.find(a);
		if (it != m.end())
		{
			it->second += 1;
		}
		else
		{
			m[a] = 1;
		}
	}

	auto result = 0;
	for (auto it : m)
	{
		auto n = it.first;
		auto c = it.second;
		if (n < c)
		{
			result += c - n;
		}
		else if (n > c)
		{
			result += c;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 6272
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return


ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }


/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){

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

    P(lcm(a,b));
    return  0;
}


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

typedef long long ll;
const int N = 200005;

vector<int> adj[N];
int n,m;

bool vstd[N];

int cnt = 0;
void dfs(int x){
	cnt++;
	vstd[x] = true;
	for(int y:adj[x]){
		if(!vstd[y])dfs(y);
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	int ans = 1;
	
	for(int i=1;i<=n;i++){
		if(!vstd[i]){
			cnt = 0;
			dfs(i);
			ans = max(ans,cnt);
		}
	}
	
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 21016
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1005

int len_A,len_B;
char A[NUM],B[NUM];

int main(){

	scanf("%s",A);
	scanf("%s",B);

	for(len_A = 0; A[len_A] != '\0'; len_A++);
	for(len_B = 0; B[len_B] != '\0'; len_B++);

	bool FLG;
	for(int i = 0; i+len_B <= len_A; i++){
		FLG = true;

		for(int k = 0; k < len_B; k++){
			if(B[k] == '_')continue;
			if(B[k] != A[i+k]){
				FLG = false;
				break;
			}
		}

		if(FLG){
			printf("Yes\n");
			return 0;
		}
	}


	printf("No\n");

	return 0;
}



Measured memory_bytes: 3156