akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
	int a, b;
	int ans;
	cin >> a >> b;
	ans = a * b;
	if (ans % 2 == 0) {
		cout << "Even" << endl;
	}
	else if(ans % 2 == 1){
		cout << "Odd" << endl;
	}
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){  
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  a.push_back(0);
  sort(all(a));
  vector<ll>count(n+1,0);
  for(int i=0;i<n;i++){
    count[i+1]=a[i+1]-a[i];
  }
  ll num=0;
  rep(i,count.size()){
    if(count[i]%2)num^=i;
  }
  cout<<(num==0  ? "second" : "first")<<endl;
  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stack>
#include<vector>

using namespace std;

int main() {
  int sum = 0;
  char c;
  stack<int> A;
  stack<pair<int, int> > S;

  for( int i = 0; scanf("%c", &c) != EOF; i++ ) {
    if (c == '\\') A.push(i);
    else if ( c == '/') {
      if (A.empty()) continue;
      int corressponding = A.top(); A.pop();
      int cv = i - corressponding;
      sum += cv;
      while(!S.empty() && S.top().first > corressponding) {
        cv += S.top().second;
        S.pop();
      }
      S.push(make_pair(corressponding, cv));
    }
  }

  printf("%d\n", sum);

  vector<int> B;
  while(!S.empty()) {
    B.push_back(S.top().second);
    S.pop();
  }

  printf("%lu", B.size());

  for(vector<int>::reverse_iterator ri = B.rbegin(); ri != B.rend(); ++ri ) {
    printf(" %d", *ri);
  }

  printf("\n");

  return 0;
}



Measured memory_bytes: 2856
N = int(input())
A = [int(input()) for i in range(N)]

def insertion_sort(A, N, diff, cnt):
    for i in range(diff, N):
        tmp_num = A[i]
        j = i - diff
        while j >= 0 and A[j] > tmp_num:
            A[j+diff] = A[j]
            j = j - diff
            cnt += 1
        A[j+diff] = tmp_num
    return cnt

if __name__ == "__main__":
    cnt = 0
    divide_cnt = 0
    diffs = []
    if N == 1:
        diffs.append(1)
        divide_cnt += 1
    else:
        quotient = N
        while quotient != 1:
            quotient = quotient // 2
            diffs.append(quotient)
            divide_cnt += 1
    for diff in diffs:
        cnt = insertion_sort(A, N, diff, cnt)
    print(divide_cnt)
    print(" ".join(map(str, diffs)))
    print(cnt)
    for num in A:
        print(num)



Measured memory_bytes: 45520
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>

using namespace std;


int N;
int c[20], v[20];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> c[i];
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (c[i] < v[i]) {
			ans += v[i] - c[i];
		}
	}


	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}

ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  string A, B, C; cin >> A >> B >> C;
  if(A[A.size()-1] == B[0] && B[B.size()-1] == C[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

}


Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let s: String = sc.cin();
    let a = s.chars().filter(|&c| c == 'S').count() > 0;
    let b = s.chars().filter(|&c| c == 'N').count() > 0;
    let c = s.chars().filter(|&c| c == 'E').count() > 0;
    let d = s.chars().filter(|&c| c == 'W').count() > 0;
    put!(if !(a^b)&&!(c^d) { "Yes" } else { "No" })
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
6
1 2 2 3
2 2 3 4
3 1 5
4 1 6
5 1 6
6 0

output:
1 1 12
2 2 11
3 3 8
4 9 10
5 4 7
6 5 6
"""
import sys

UNVISITED, VISITED_IN_STACK, POPPED_OUT = 0, 1, 2


def generate_adj_matrix(v_info):
    for v_detail in v_info:
        v_index, adj_num, *adj_list = map(int, v_detail)
        # assert len(adj_list) == adj_num
        init_adj_table[v_index].extend(sorted(adj_list, reverse=True))
    return init_adj_table


def graph_dfs(v_init):
    global time

    # init the first node of overall graph iterations(times >= 1)
    stack.append(v_init)
    d_time[v_init] += time
    # init end

    while stack:
        current = stack[-1]
        v_table = adj_table[current]
        color[current]=VISITED_IN_STACK
        # if adj is None, current's adj(s) have been all visited
        adj = v_table.pop() if v_table else None

        if adj:
            if color[adj] is UNVISITED:
                color[adj] = VISITED_IN_STACK
                time += 1
                d_time[adj] += time
                stack.append(adj)
        else:
            stack.pop()
            color[current] = POPPED_OUT
            time += 1
            f_time[current] += time

    return None


def dfs_start():
    global time
    for i in range(vertices):
        if color[i + 1] == UNVISITED:
            # print('round: ', i + 1)
            graph_dfs(i + 1)
            time += 1


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices = int(_input[0])
    v_info = map(lambda x: x.split(), _input[1:])
    init_adj_table = tuple([] for _ in range(vertices + 1))
    # assert len(vertex_info) == vertex_num

    # config length = (vertex_num + 1)
    stack = []
    color = [UNVISITED] * (vertices + 1)
    d_time, f_time = ([0] * (vertices + 1) for _ in range(2))

    adj_table = generate_adj_matrix(v_info)
    # timing start from 1
    time = 1
    dfs_start()

    for index, v in enumerate(zip(d_time[1:], f_time[1:]), 1):
        print(index, *v)

Measured memory_bytes: 7796
//Practice more and more
//learn for better
#define bn begin()
#define en end()
#define mx 5000010
#define pb push_back
#define PI (2.0*acos(0.0))
#define ALL(a) a.begin(),a.end()
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rep(a,b) for(int a=0;a<b;++a)
#define fastio ios::sync_with_stdio(false)
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int>  vi;
typedef vector<ll>   vll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
vll v1,v2;
v1.pb(0),v2.pb(0);
	ll a,b,n,m,i,t,tmp,k;
	cin>>n>>m>>k;
	ll sum=0;
	for(i=0;i<n;i++)
	{
		cin>>a;
		sum+=a;
		v1.pb(sum);
	}
	sum=0;
for(i=0;i<m;i++)
{
	cin>>a;
	sum+=a;
	v2.pb(sum);
}
ll cnt=0;
for(i=0;i<=n;i++)
{
	ll low=0,high=m,mid;
	while(1)
	{
		if(low>high)
		break;
	mid=low+(high-low)/2;
	if(v1[i]+v2[mid]<=k)
	{
		if(cnt<mid+i)
		{
			cnt=mid+i;
		}
			low=mid+1;
	}
	else
	{
		high=mid-1;
		}	
	}
}
cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 7876
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const int MAX = 1e7;

//mod(1e9+7)
const int mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x = 0) : x(x % mod){}
    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
};

int main() {
    int n, k; cin >> n >> k;
    mint sum = 0;
    for (ll i = k; i <= n+1; i++) {
        ll x = (1+i-1)*(i-1)/2;
        sum += (ll)i*n-x-x+1;
    }
    cout << sum.x << endl;
}

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

int main(void){
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	int cnt = 0;
	for (int i = 0; i < n; i++){
		if (i+1== a[a[i]-1] && a[i] != -1){
			cnt++;
			a[a[i]-1] = -1;
			a[i] = -1;
			
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 640
#![allow(non_snake_case)]

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let H:usize = sc.read();
    let W:usize = sc.read();
    let A:Vec< Vec< i64>> = (0..H).map(|_| sc.vec(W)).collect();
    let B:Vec< Vec< i64>> = (0..H).map(|_| sc.vec(W)).collect();
    let mut C:Vec< Vec<i64>> = vec![vec![0; W]; H];
    for i in 0..H{
        for j in 0..W{
            C[i][j] = A[i][j] - B[i][j];
        }
    }
    let R:usize = 2*(80+80)*80+1;
    let M:i64 = (80+80)*80;

    let mut ANS:Vec<Vec< Vec< bool>>> = vec![vec![vec![false; R]; W]; H];
    ANS[0][0][(C[0][0]+M) as usize] = true;
    for i in 0..H{
//        println!("b {}", i);
        for j in 0..W{
            for k in 0..R{
                if !ANS[i][j][k] {
//                    println!("{}", j);
                    continue
                }
//                println!("{} {}", i, j);
                if i + 1 < H{
//                    println!("hoge");
                    ANS[i+1][j][((k as i64) + C[i+1][j]) as usize] = true;
                    ANS[i+1][j][((k as i64) - C[i+1][j]) as usize] = true;
                }
                if j + 1 < W{
//                    println!("a{} {}",i, j );
                    ANS[i][j+1][((k as i64) + C[i][j+1]) as usize] = true;
                    ANS[i][j+1][((k as i64) - C[i][j+1]) as usize] = true;
//                    println!("hee");
                }
            }
        }
    }
//    println!("hoge");
//         for k in 0..R{
// //            println!("hoge");
//             if !ANS[i][k]{
//                 continue
//             }
//             println!("{} {}",i, k as i64 - M as i64);
//             for j in 0..W{
//                 ANS[i+1][((k as i64) + C[i][j]) as usize] = true;
//             }
//         }
//     }
//     let M:i64 = M as i64;

    let mut ans:i64 = R as i64;
    for i in 0..R{
        if ANS[H-1][W-1][i]{
//            println!("{}", i as i64 - M);
            if ((i as i64) - M).abs() < ans{
                ans = ((i as i64) - M).abs();
            }
        }
    }

    println!("{}", ans);


}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}




Measured memory_bytes: 215292
loop{
a, op, b = STDIN.gets.split(' ')
a = a.to_i
b = b.to_i
  case op
  when '+' then
    puts a+b
  when '-' then
    puts a-b
  when '/' then
    puts a/b
  when '%' then
    puts a%b
  when '*' then
    puts a*b
  else
    break
  end
}

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

using namespace std;

int main() {
  int n; cin >> n;
  vector <int> a(n), b(n), c(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for(int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for(int i = 0; i < n; i++) {
    cin >> c[i];
  }
  int sum = 0;
  for(int i = 0; i < n; i++) {
    sum += b[a[i] - 1];
  }
  for(int i = 0; i < n - 1; i++) {
    if(a[i] + 1 == a[i + 1]) {
      sum += c[a[i] - 1];
    }
  }
  cout << sum << '\n';
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[500][500] = {0};

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0) return 0;
		for(int i=0; i<500; i++)
			for(int j=0;j<500; j++){ a[i][j]=-1;}
		int x = 250, y = 250;
		a[x][y] = 0;
		for(int i = 1; i < n; i++){
			int dc = 0, dr = 0;
			cin >> dc >> dr;
			for(int j =0; j<500; j++){
				for(int k = 0; k < 500; k++){
					if(a[j][k] == dc){
						if(dr == 0){
							a[j-1][k] = i;
						}
						if(dr == 1){
							a[j][k-1] = i;
						}
						if(dr == 2){
							a[j + 1][k] = i;
						}
						if(dr == 3){
							a[j][k+1]=i;
						}
					}
				}
			}
		}
		int mi1 = 505, ma1 = 0;
		for(int i = 0; i < 500; i++){
			for(int j =0; j<500; j++){
				if(a[i][j] >= 0) mi1 = min(mi1, j);
			}
			for(int j = 499; j>=0; j--){
				if(a[i][j] >= 0) ma1 =max(ma1, j);
			}
		}
		int mi2 = 505, ma2 = 0;
		for(int j = 0; j < 500; j++){
			for(int i = 0; i < 500; i++){
				if(a[i][j] >= 0) mi2 = min(mi2, i);
			}
			for(int i = 499; i >= 0; i--){
				if(a[i][j] >= 0) ma2 = max(ma2, i);
			}
		}
		cout << ma2-mi2+1<<" "<<ma1-mi1+1<<endl;
	}
}


Measured memory_bytes: 4064
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>

using namespace std;

bool is753(int n) {
	vector<int> cnt(3);
	while (n) {
		if (n % 10 == 0) {
			return false;
		}
		cnt[((n % 10) - 3) / 2]++;
		n /= 10;
	}
	for (int i = 0; i < 3; i++) {
		if (!cnt[i]) {
			return false;
		}
	}
	return true;
}

int main() {
	int n;
	cin >> n;
	int dig = 0;
	{int tmp = n;
	while (tmp) {
		dig++;
		tmp /= 10;
	}
	}
	
	int ans = 0;
	if (dig >= 3) {

		
		
		for (int i = 0; i < (1 << (2 * dig)); i++) {
			long long num = 0;
			
			for (int d = 0; d < dig; d++) {
				int tmp = ((i >> (2 * d))&3);
				//cout << tmp << " "<< i<< endl;
				if (tmp == 3) {
					num = num * 10;
				}
				else {
					num = num * 10 + 2 * (tmp)+3;
				}
			}
			//cout << num << endl;
			

			if (num <=n) {
				//cout << num<< endl;
				if (is753(num)) {
					ans++;
				}
			}
		}
		
		

	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//Badwaper gg
#include<bits/stdc++.h>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define pb push_back
#define re register ll
#define fr first
#define sd second
#define FOR(i,a,b) for(re i=a;i<=b;i++)
#define REP(i,a,b) for(re i=a;i>=b;i--)
#define lowbit(x) (x&(-x))
#define Z(x) (x>=mod?x-mod:x)
#define N 11
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
int n;int t[N],vis[N];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();int T=read();while(T--)vis[read()]=1;
	FOR(i,n,inf)
	{
		int tmp=i,fl=1;while(tmp){if(vis[tmp%10]){fl=0;}tmp/=10;}
		if(fl){printf("%d\n",(int)i);return 0;}
	}
	return 0;
}


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

int main(void)
{

    int n;
    scanf("%d", &n);
    int s, sum = 0, min = 100;
     for (int i = 0; i < n; ++i){
        scanf("%d", &s);
        sum += s;
        if (s % 10 && min > s )
            min = s;
    }
    if (sum % 10)
        printf("%d\n", sum);
    else{
        if (min % 10)
            printf("%d\n", sum - min);
        else
            printf("%d\n", 0);
    }
    return 0;
}

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

int main() {

int a,b;

cin >> a >> b;

if(a<b) {cout << "a < b" << endl;}
if(a==b) {cout << "a == b" << endl;}
if(a>b) {cout << "a > b" << endl;}
}


Measured memory_bytes: 3092
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    a = int(ipt())
    print(a+a**2+a**3)

    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 68748
#include <bits/stdc++.h>
using namespace std;
						
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long

const int inf = (int)1e9;
const int N = 15, M = 1005, total = (1LL << 15);
int dp[M][total];
 
int32_t main()
{
	IOS
 
	int n, m;
	cin >> n >> m;
	int cost[m + 5], mask[m + 5];
	for (int i = 1, a, b; i <= m; i++) {
		cin >> a >> b;
		int temp = 0;
		for (int j = 1, x; j <= b; j++) {
			cin >> x;
			temp |= (1LL << (x - 1));
		}
		// cout << temp << endl;
		cost[i] = a, mask[i] = temp;
	}
	for (int i = 0; i < M; i++) 
		for (int j = 0; j < total; j++)
			dp[i][j] = inf;


	// First way
	dp[0][0] = 0;

	for (int idx = 1; idx <= m; idx++) {	
		for (int cur = 0; cur < total; cur++) {
			dp[idx][cur] = min(dp[idx - 1][cur], dp[idx][cur]);
			dp[idx][cur] = min(dp[idx - 1][cur], dp[idx - 1][cur - (cur & mask[idx])] + cost[idx]);
		}
	}
	int ans = dp[m][(1 << n) - 1];
	if (ans == inf) ans = -1;
	cout << ans << endl;
	// Second way
	// dp[1][0] = 0;
	// for (int i = 1; i <= m; i++) {
	// 	for (int cur = 0; cur < total; cur++) {
	// 		dp[i + 1][cur | mask[i]] = min(dp[i + 1][cur | mask[i]], dp[i][cur] + cost[i]);
	// 		dp[i + 1][cur] = min(dp[i + 1][cur], dp[i][cur]);
	// 	}
	// }
	// cout << dp[m + 1][(1LL << n) - 1] << endl;

	// Third way
	// int dp[total];
	// fill(dp, dp + total, inf);
	// dp[0] = 0;
	// for (int i = 1; i <= m; i++) {
	// 	cout << mask[i] << endl;
	// 	for (int j = 0; j < total; j++) {
	// 		dp[j | mask[i]] = min(dp[j | mask[i]], dp[j] + cost[i]);
	// 	}
	// }	
	// cout << dp[(1LL << n) - 1] << endl;
	// for (int i = 0; i < (1 << n); i++)
	// 	cout << dp[i] << " ";
	// 	cout << endl;

	

 
	return 0;
}

Measured memory_bytes: 257536
#include<bits/stdc++.h>
using namespace std;
int power(int e,int f)
{
    int ans=1;
    for(int k=0;k<f;k++)
        ans=ans*e;
    return ans;
}
int main()
{
    int a,b,c=0,d,s=0,i;
    cin>>a;
    for(i=a;i>0;i=i/10)
    {
        c++;
    }
    if(c==1)
        cout<<a;
    else if(c%2==0)
    {
        for(i=1;i<c;i=i+2)
        {
            s=s+9*power(10,i-1);
        }
        cout<<s;
    }
    else
    {
         for(i=1;i<c;i=i+2)
        {
            s=s+9*power(10,i-1);
        }
        d=s+(a-power(10,c-1))+1;
        cout<<d;
    }
}

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

int main(){
    int n, c=0; cin>> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin>> a[i];
        if(a[i]%2==0 && a[i]%6 && a[i]%10) c++;
    }
    (c)? cout<< "DENIED\n": cout<< "APPROVED\n";
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 24 14:53:50 2018
ITP21B
@author: maezawa
"""

from collections import deque

d = deque()

n = int(input())

for i in range(n):
    c = list(map(int, input().split()))
    if c[0] == 0:
        if c[1] == 0:
            d.appendleft(c[2])
        else:
            d.append(c[2])
    elif c[0] == 1:
        print(d[c[1]])
    else:
        if c[1] == 0:
            d.popleft()
        else:
            d.pop()




Measured memory_bytes: 21984
#include<iostream>
#include<algorithm>
//#include<functional>
//#include<vector>
//#include<cmath>
using namespace std;

//スキャン
void myscan(int *x, int n){
  for (int i=0; i<n; i++){
    cin >> x[i];
  }
//  sort(x, x+n, greater<int>());
  sort(x, x+n);
}

int main(){
  int n;
  cin >> n;
  int a[n], b[n], c[n];

  myscan(a,n);
  myscan(b,n);
  myscan(c,n);

  long ans = 0;

  for(int i=0; i<n; i++){
    int p = b[i];
    ans += distance(a, lower_bound(a, a+n, p))
      * (n - distance(c, upper_bound(c, c+n, p)));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
while True :
    H,W=map(int,input().split())
    if H==0 and W==0 :
        break
    for i in range (H):
        for j in range (W):
            if (i+j)%2 == 0 :
                print("#",end='')
            else :
                print(".",end='')
        print()
    print()



Measured memory_bytes: 7004
//A 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s;
	cin >> s;
	bool a = 0,b = 0;
	for(int i = 0;i <= 2;i++){
		if(s[i] == 'A')a = 1;
		if(s[i] == 'B')b = 1;
	} 
	if(a and b)cout << "Yes";
	else cout << "No";
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include <vector> 
#include <algorithm>
#include<iomanip>
#include<math.h>
#include<string>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
using namespace std;
struct Room {
	int *a;
	int shortest;
	int way;
	int ways;
};
//for (int x = 0; x < N; x++)room[x].a=(int*)malloc(room[x].way * sizeof(int));
int main() {
	unsigned long long A, B;
	cin >> A >> B;
	cout << A * B << endl;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) {
    cin >> a[i];
  }
  sort(all(a));
  reverse(all(a));

  ll ans = 0;
  rep(i,n-1) {
    // cout << "i:" << i << endl;
    // cout << "i+1/2:" << (i+1)/2 << endl;
    // cout << "a[(i+1)/2]:" << a[(i+1)/2] << endl;
    ans += a[(i+1)/2];
  }
  cout << ans << endl;
}


Measured memory_bytes: 4764
#include <iostream>

using namespace std;

const int MAX_N = 100;

int main(int argc, char const *argv[]) {
  int n, d, x, a[MAX_N];
  cin >> n >> d >> x;
  int ans = x;
  for (size_t i = 0; i < n; i++) cin >> a[i];

  for (size_t i = 0; i < n; i++) {
    int tempn = 0;
    for (size_t j = 0; j*a[i] + 1 <= d ; j++) {
      tempn++;
    }
    ans += tempn;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

ll now[107];

int main() {
    ll N,h[107],t=1,k,b=0;cin >> N;
    rep(i,N){
        cin >> h[i];
    }
    while(t>0){
        t=0;
        k=0;
        rep(i,N){
            if(h[i]>now[i]){
                now[i]++;
                t=1;
                if(k==0){
                    b++;
                }
                k=1;
            }
            else{
                k=0;
            }
        }
    }
    cout << b << endl;
}

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

int num(int m,vector<int>& v,int N){
	int res = 0;
	for(int i=2;i<=N;i++)if(v[i]>=m-1)res++;
	return res;
}

int main(void){
	int N;cin>>N;
	vector<int> v(N+1,0);
	for(int i=2;i<=N;i++){
		int cur = i;
		for(int j=2;j<=i;j++){
			while(cur %j==0){
				v[j]++;
				cur/=j;
			}
		}
	}
	int ans = 0;
	ans += num(75,v,N) + num(15,v,N)*(num(5,v,N)-1) +num(25,v,N)*(num(3,v,N)-1)
	+ num(5,v,N)*(num(5,v,N)-1)*(num(3,v,N)-2) /2 ;
	cout << ans << endl;
}

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

typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<ll> cost(N);
  vector<ll> dp(N,0);
  for(int i=0;i<N;i++){
    cin >> cost.at(i);
  }
  
  dp.at(0) = 0;
  dp.at(1) = abs(cost.at(1) - cost.at(0));
  for(int i=2;i<N;i++){
    dp.at(i) = min(dp.at(i-1)+abs(cost.at(i)-cost.at(i-1)),
                   dp.at(i-2)+abs(cost.at(i)-cost.at(i-2)));
  }
  cout << dp.at(N-1) << endl;
}

Measured memory_bytes: 1792
package main

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

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

func main() {
	sc.Scan()
	ab := Sliceconvtoi()
	fmt.Printf("%d %d %.5f", ab[0]/ab[1], ab[0]%ab[1], float64(ab[0])/float64(ab[1]))

}



Measured memory_bytes: 1148
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
   int N;
   std::cin >> N;
   int P[N], Q[N];
   for(int i=0; i<N; ++i) std::cin >> P[i];
   for(int i=0; i<N; ++i) std::cin >> Q[i];

   std::vector<int> v;
   for(int i=0; i<N; ++i) v.push_back(i+1);
   int a = 0;
   int b = 0;
   int count = 0;
   do{
      bool flag_p = true;
      bool flag_q = true;
      for(int i=0; i<N; ++i){
	 if(P[i]!=v[i]) flag_p = false;
	 if(Q[i]!=v[i]) flag_q = false;
      }
      if(flag_p) a = count;
      if(flag_q) b = count;
      ++count;
   }while(std::next_permutation(v.begin(),v.end()));
   std::cout << abs(a-b) << std::endl;
   return 0;
}


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

int main(void){
    vector<int> v(3);
    cin >> v.at(0) >> v.at(1) >> v.at(2);
    int k;
    cin >> k;

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

    for(int i=0; i<k; i++){
        v.at(2) *= 2;
    }

    cout << accumulate(v.begin(), v.end(), 0) << endl;

    return 0;
}

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


#define FAST_INPUT ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
using namespace std;


void solve() {
    int k;
    cin >> k;
    int val=7%k;
    int cnt=1;
    if (val==0) {
        cout << 1 << endl;
        return;
    }
    for (int i=0; i<1e7; i++) {
        val=(val*10+7)%k;
        cnt++;
        if (val==0) {
            cout << cnt << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main() {
    FAST_INPUT;
    
    solve();
    
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
using namespace std;

ll max(ll a,ll b)
{
  if (a>b) {

    return a;
  }
  return b;
}

ll min(ll a,ll b)
{
  if (a<b) {

    return a;
  }
  return b;
}

ll gcd(ll a,ll b)
{
  if (b==0) return a;
  return gcd(b,a%b);
}

ll lcm(ll a,ll b)
{
  return a/gcd(a,b)*b;
}
int main()
{
    int k,a,b;
    cin>>k>>a>>b;
    int flag=0;
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            flag=1;
        }
    }
    if(flag)
    {
        cout<<"OK"<<endl;
    }
    else
        cout<<"NG"<<endl;

    return 0;
}


Measured memory_bytes: 3636
L = list(map(int, input().split()))
N = L[0]
M = L[1]

K = []
for i in range(N):
    T = list(map(int, input().split()))
    del T[0]
    K.append(T)

# 1番目の配列に含まれる値が2番目以降の配列に含まれるか確認する
A = []
for i in range(len(K[0])):
    flag = True
    for j in range(len(K)):

        if K[0][i] not in K[j]:
            flag = False
            continue

    if flag:
        A.append(K[0][i])

print(len(A))

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

const int MAX = 510000;

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

void COMinit() {
  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;
  }
}

ll COM(int n, int 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 () {
  cin.tie(0);
  cout << setprecision(10);

  int h, w, a, b; cin >> h >> w >> a >> b;
  ll ans = 0;
  COMinit();

  REP(i, h-a) {
    ans = (ans + (COM(b-1 + i, i) * COM((w-b) + h-i - 2, h-i - 1)) % MOD) % MOD;
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 12160
# Beginners Contest (E)

import sys

# 入力取得
inp_n = int(input())

# 奇数の場合は0
if inp_n % 2 == 1:
	print(0)
	sys.exit()

# 5の倍数で割り切れる回数
result = 0
i = 1
while True:
	result += inp_n // ((5 ** i) * 2)
	i += 1
	if inp_n < ((5 ** i) * 2): break

# 結果出力
print(result)



Measured memory_bytes: 2940
/**
 *    author:  tourist
 *    created: 15.09.2018 16:44:35       
**/
#include <bits/stdc++.h>

using namespace std;

const int md = (int) 1e9 + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
  return (int) ((long long) a * b % md);
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = (int) s.size();
  vector<int> sum(n + 1);
  sum[0] = 0;
  for (int i = 0; i < n; i++) {
    sum[i + 1] = (sum[i] + (s[i] == 'a' ? 1 : 2)) % 3;
  }
  vector<vector<int>> nxt(n + 1, vector<int>(3, n + 1));
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < 3; j++) {
      nxt[i][j] = nxt[i + 1][j];
    }
    nxt[i][sum[i + 1]] = i + 1;
  }
  vector<int> eq(n + 1);
  eq[n] = n;
  eq[n - 1] = n;
  for (int i = n - 2; i >= 0; i--) {
    if (s[i] == s[i + 1]) {
      eq[i] = i + 1;
    } else {
      eq[i] = eq[i + 1];
    }
  }
  if (eq[0] == n) {
    cout << 1 << '\n';
    return 0;
  }
  vector<int> dp(n + 1, 0);
  dp[0] = 1;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int t = 1; t <= 2; t++) {
      int look = (sum[i] + t) % 3;
      if (sum[i + 1] == look) {
        add(dp[i + 1], dp[i]);
      } else {
        int pos = nxt[eq[i]][look];
        if (pos <= n) {
          add(dp[pos], dp[i]);
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (sum[i] == sum[n]) {
      add(ans, dp[i]);
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 6992
import scala.collection.mutable.ArrayBuffer

object Main extends App {
  val Array(n,m,l) = readLine.split(" ").map(_.toInt)
  val buf1 = ArrayBuffer.empty[Array[Long]]
  val buf2 = ArrayBuffer.empty[Array[Long]]

  for( i <- 0 until n) buf1 += readLine.split(" ").map(_.toLong)
  for( i <- 0 until m) buf2 += readLine.split(" ").map(_.toLong)

  val m1 = buf1.toArray
  val m2 = buf2.toArray

  val m3 = for(i <- 0 until n) yield for(j<- 0 until l)
    yield (0 until m).foldLeft(0L) { (sum,k) => sum + m1(i)(k) * m2(k)(j) }

  m3.foreach(row => println(row.mkString(" ")))
}

Measured memory_bytes: 78348
#include <cstdio>

static void kakuritu(int n);

int main(void){
  int n;
  scanf("%d", &n);
  kakuritu(n);

  return 0;
}

static void kakuritu(int n){
  int even = 0, odd = 0;
  int i=0;

  for(i = 1; i<=n; i++){
    if(i%2== 0){
      even++;
    } else {
      odd++;
    }
  }
  printf("%f", ((double)odd/(double)n));
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vpi;
typedef map<int,int> mapii;
typedef map<int,bool> mapib;
typedef map<char,int> mapci;

#define small 1e-9
#define big5 1000000005
#define big7 1000000007
#define big 1000000
#define pi 3.1415926

#define inp(arr,n) for(int i=0;i<n;i++)cin>>arr[i];
#define cum(arr,n,cumm) cumm[0]=0;for(int i=0;i<n;i++)cumm[i+1]=cumm[i]+arr[i];
#define bsdk ios_base::sync_with_stdio(false);cin.tie(NULL);
#define disp(arr) for(auto i:arr)cout<<i<<" ";cout<<"\n"
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define m1 cout<<"-1\n"
#define nl <<endl
#define hs cout<<"#"

#define fori(a, b, c) for (a = (b); (a) <= (c); ++(a))
#define ford(a, b, c) for (a = (b); (a) >= (c); --(a))
#define rep(i,n) fori(i,0,n-1)
#define rep1(i,n) fori(i,1,n)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define ub upper_bound
#define lb lower_bound
#define allv(v) v.begin(), v.end()
#define sorti(v) sort(allv(v))
/*bool isprime[big+1];
vector<int> primes;
void makesieve()
{
    ll i,j;
    rep(i,1000001)
        isprime[i]=false;
    isprime[2]=true;
    for(i=3;i<=big;i+=2)
        isprime[i]=true;
    for(i=3;i<=big;i+=2)
    {
        if(isprime[i])
            for(j=i*i;j<=big;j+=i)
            isprime[j]=false;
    }
    rep(i,big+1)
    {
        if(isprime[i])
            primes.pb(i);
    }
}
ll poww(ll n,ll m){
    if(m==0)return 1;
    if(m==1)return n;
    ll ans = poww(n,m/2);
    if(m%2==1) return (ans*ans)*n;
    else return (ans*ans);
}*/
ll dp[101][100001];
ll f(ll n,ll c,pair<ll,ll> arr[])
{
    if(n==0 || c==0)
        return 0;
    if(dp[n][c]!=-1)
        return dp[n][c];
    ll ans,a,b;
    a=b=INT_MIN;
    if(arr[n-1].fi<=c)
        a=arr[n-1].se+f(n-1,c-arr[n-1].fi,arr);
    b=f(n-1,c,arr);
    ans=max(a,b);
    dp[n][c]=ans;
    //cout<<n<<" "<<c<<" "<ans<<endl;
    return ans;
}
void solve()
{
    ll n,c,i,j;
    cin>>n>>c;
    pair<ll,ll> arr[n];
    rep(i,n)
    cin>>arr[i].fi>>arr[i].se;
    rep(i,101)
    rep(j,100001)
    dp[i][j]=-1;
    cout<<f(n,c,arr)<<endl;
}
int main()
{
    bsdk
    int t;
    //cin>>t;
    t=1;
    while(t--) solve();
    return 0;
}


Measured memory_bytes: 79232
#include<stdio.h>
 
int main()
{
    int n,count;
 
    scanf("%d",&n);

    char s[n];
    
    scanf("%s",s);
    
    count=0;

    for (int i=0;i<n-2;i++) {
        if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') {
            count++;
        }
    }
    printf("%d",count);
    return 0;
}

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

struct node{
    int item;
    struct node *left;
    struct node *right;
};

node *make_node(){
    node *d = new node;
    d -> left = NULL;
    d -> right = NULL;
    return d;
}

int number(State &begin){
    int ret = 0;
    while (isdigit(*begin)){
        ret *= 10;
        ret += *begin - '0';
        begin++;
    }
    return ret;
}

node *read(State &begin){
    node *d = make_node();
    begin++;
    if (*begin != ')'){
        d -> left = read(begin);
    }
    begin += 2;
    d -> item = number(begin);
    begin += 2;
    if (*begin != ')'){
        d -> right = read(begin);
    }
    begin++;
    return d;
}

void out(node *d1, node *d2){
    cout << "(";
    if (d1 -> left != NULL && d2 -> left != NULL) out(d1 -> left, d2 -> left);
    printf(")[%d](", d1 -> item + d2 -> item);
    if (d1 -> right != NULL && d2 -> right != NULL) out(d1 -> right, d2 -> right);
    cout << ")";
}

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    node *r1, *r2;
    State begin = s1.begin();
    r1 = read(begin);
    begin = s2.begin();
    r2 = read(begin);

    out(r1, r2);
    cout << endl;

    return 0;
}

Measured memory_bytes: 3288
def main ():
    N = int(input())
    A = list(map(int,input(). split ()))
    
    if 0 in A:
        print(0)
        return

    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
    
main ()

Measured memory_bytes: 21552
package main

import "fmt"

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

	aSlice := make([]int, n)
	for i := range aSlice {
		fmt.Scan(&aSlice[i])
	}

	ans := x
	for _, a := range aSlice {
		for i := 0; i*a+1 <= d; i++ {
			ans++
		}
	}
	fmt.Println(ans)
}


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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  lli a, b; cin>>a>>b;
  lli p = __gcd(a, b);
  lli pp = p;
  //debug(pp);
  int cnt = 0;
  for(lli i = 2; i*i<=p; i++) {
    if(pp%i == 0) {
      cnt++;
      while(pp%i == 0) pp = pp/i;
    }
  }
  if(pp != 1) cnt++;
  cout<<cnt+1<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

class HOTEL {
public:
	int hotel;
	int vote;
	bool operator< (const HOTEL& h) {
		if (vote == h.vote) {
			return hotel > h.hotel;
		} else {
			return vote < h.vote;
		}
	 }
};

int main() {
	int i, j, n, m, tmp;
	
	while (1) {
		cin >> n >> m;
		if (n == 0 && m == 0)break;
		vector<HOTEL> v;
		int hton[102] = {};
		for (i = 0; i < n; i++) {
			for (j = 1; j <= m; j++) {
				cin >> tmp;
				hton[j] += tmp;
			}
		}
		HOTEL tpair;
		for (j = 1; j <= m; j++) {
			tpair.vote = hton[j];
			tpair.hotel = j;
			v.push_back(tpair);
		}
		sort(v.begin(), v.end());

		int tans;
		for (i = m - 1; i >= 0; i--) {
			cout << v[i].hotel;
			if (i != 0)cout << " ";
		}
		cout << endl;
	}
	





	return 0;
}

Measured memory_bytes: 3160
import numpy as np
ls = np.array([[ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
         0,  0,  0,  0,  0],
       [ 0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
         0,  0,  0,  0,  0],
       [ 0,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,
        15, 16, 17, 18, 19],
       [ 0,  0,  1,  1,  2,  2,  3,  3,  4,  4,  5,  5,  6,  6,  7,  7,
         8,  8,  9,  9, 10],
       [ 0,  0,  1,  1,  1,  2,  2,  2,  3,  3,  3,  4,  4,  4,  5,  5,
         5,  6,  6,  6,  7],
       [ 0,  0,  1,  1,  1,  1,  2,  2,  2,  2,  3,  3,  3,  3,  4,  4,
         4,  4,  5,  5,  5],
       [ 0,  0,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  3,  3,  3,  3,
         3,  4,  4,  4,  4],
       [ 0,  0,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,  3,  3,
         3,  3,  3,  3,  4],
       [ 0,  0,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,  2,
         3,  3,  3,  3,  3],
       [ 0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,
         2,  2,  3,  3,  3],
       [ 0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,
         2,  2,  2,  2,  3],
       [ 0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,
         2,  2,  2,  2,  2],
       [ 0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,
         2,  2,  2,  2,  2],
       [ 0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,
         2,  2,  2,  2,  2],
       [ 0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,
         2,  2,  2,  2,  2],
       [ 0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
         2,  2,  2,  2,  2],
       [ 0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
         1,  2,  2,  2,  2],
       [ 0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
         1,  1,  2,  2,  2],
       [ 0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
         1,  1,  1,  2,  2],
       [ 0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
         1,  1,  1,  1,  2],
       [ 0,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
         1,  1,  1,  1,  1]])
A, B = map(int, input().split())
print(ls[A][B])

Measured memory_bytes: 18424