akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

// definitions
#define __Imperial_Lord__ ONLINE_JUDGE
#define _cps CLOCKS_PER_SEC
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define high(x) __builtin_popcountll(x)
#define pb push_back
#define pf push_front
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define exec cerr<<"Time taken : "<<(ld)(clock())/_cps<<"s"<<endl
#define mod1 998244353
#define mod 1000000007
#define pi 3.1415926535897932384

using namespace std;

// alias name for common data types
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dql;
typedef deque <char> dqc;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const ll INF=1e18;

// cin and cout overloaded for vectors and sets
template<typename T>    istream& operator>>(istream& is,  vector<T>& v)
{
    for (auto& i : v) 
        is >> i;        
    return is;
}
template<typename T>             
ostream& operator<<(ostream& os,  vector<T>& v)
{
    for (auto& i : v) 
        os << i << ' '; 
        return os;
}

// code beigns in main
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    ll lol;
    while(t--)
    {
    	ll n,m,k;
    	cin >> n >> m >>k;
    	vl a(n),b(m);
    	cin >> a >>b;
    	ll ans=0,sa=0;

    	rep(i,0,n) sa+=a[i];
    	ll la=n,lb=0;
    	while(true)
    	{
    		if(sa<=k)
    		{
    			ans=max(ans,la+lb);
    			if(lb<m)
    			{
    				sa+=b[lb];
    				lb++;
    			}
    			else 
    				break;
    		}
    		else
    		{
    			if(la==0) break;
    			la--;
    			sa-=a[la];
    		}
    	}

    	cout << ans << endl;
    }
    exec;
}


Measured memory_bytes: 6348
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  k,n=LI()
  l=LI()
  a=copy.deepcopy(l)

  for x in a:
    l.append(k+x)

  ans=inf
  for i in range(n):
    ans=min(ans,l[i+n-1]-l[i])

  return ans

# main()
print(main())


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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  
  for(int i = 0;i < n;i ++){
    cin >> vec.at(i);
  }
  
  vector<int> kekka(n - 1);
  
  for(int t = 0;t < n - 1;t ++){
    int a = 0;
    int b = 0;
    for(int j = 0;j < t + 1;j ++){a += vec.at(j);}
    for(int k = t + 1;k < n;k ++){b += vec.at(k);}
    kekka.at(t) = max(a,b) - min(a,b);
  }
  sort(kekka.begin(),kekka.end());
  cout << kekka.at(0) << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int min_array(int n[],int len)
{
    int i,tmp,sum;
    tmp = n[0];
    sum=n[0];
    for(int i=1;i<len;i++){
        sum=sum+n[i];
        if(((tmp%10==0)&&(n[i]%10!=0))||((tmp > n[i])&&(n[i]%10!=0))){
            tmp = n[i];
        }
        
    }
    if(tmp%10==0)
    {
        return sum;
    }
    else{
    return tmp;
    }
}
int main()
{
    int n;
    int s[100];
    int sum = 0;
    
    cin>>n; //nの入力
    
    for(int i=0; i<n; i++){
        cin>>s[i];  //配点の入力
        sum=sum+s[i];  //最大成績の算出
    }
    
    if(sum%10==0)
    {
        sum = sum - min_array(s ,n);
    }
    cout<<sum<<"\n";
    return 0;
}

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

int main(){
  int a;
  cin>>a;
  
  int denominator;
  
  for(int i=1; i<10; i++){
      int b = (a%i == 0)? a/i : 10;
      if(b < 10){
        cout<<"Yes"<<endl;
        return 0;
      }
  }
    cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
from math import gcd

N, M = map(int, input().split())
S = input()
T = input()

x = gcd(N, M)
n = N//x
m = M//x
for i in range(x):
    if S[n*i] != T[m*i]:
        print(-1)
        break
else:
    print(N*M//x)

Measured memory_bytes: 9204
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn popcount(i: u32) -> u32 {
    let i = i - ((i >> 1) & 0x55555555);
    let i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
    (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24
}

fn main() {
    input! {
        n: usize,
        x: chars
    }
    let popcount_x = x.iter().filter(|x| **x == '1').count();
    let exp_2_mod_hi: Vec<usize> = (0..n)
        .scan(1, |state, _| {
            let current = *state;
            *state = *state * 2 % (popcount_x + 1);
            Some(current)
        })
        .collect();
    let exp_2_mod_low: Vec<usize> = if popcount_x > 1 {
        (0..n)
            .scan(1, |state, _| {
                let current = *state;
                *state = *state * 2 % (popcount_x - 1);
                Some(current)
            })
            .collect()
    } else {
        vec![]
    };
    let x_mod_hi = x.iter().rev().zip(&exp_2_mod_hi).fold(0, |acc, (x, y)| {
        (acc + y * (*x == '1') as usize) % (popcount_x + 1)
    });
    let x_mod_low = x.iter().rev().zip(&exp_2_mod_low).fold(0, |acc, (x, y)| {
        (acc + y * (*x == '1') as usize) % (popcount_x - 1)
    });
    for (c, key) in x.iter().zip((0..n).rev()) {
        let mut r = if *c == '1' {
            if popcount_x == 1 {
                println!("0");
                continue;
            }
            (x_mod_low + (popcount_x - 1) - exp_2_mod_low[key]) % (popcount_x - 1)
        } else {
            (x_mod_hi + exp_2_mod_hi[key]) % (popcount_x + 1)
        } as u32;
        let mut cnt = 1;
        while r > 0 {
            r = r % popcount(r);
            cnt += 1;
        }
        println!("{}", cnt);
    }
}


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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 2010;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


// Main Code


int arr[3][N];

int main()
{
	int n;
	cin>>n;
	repn(i, 1, n)
		cin>>arr[1][i];
	repn(i, 1, n)
		cin>>arr[2][i];
	repn(i, 1, 2)
	{
		repn(j, 1, n)
		{
			arr[i][j] += max(arr[i][j-1], arr[i-1][j]);
		}
	}
	cout<<arr[2][n]<<endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) = IO().exec {
    val n = int()
    var sum = 0
    val ret = mutableSetOf<Int>()
    for (i in 1..n) {
        sum += i
        ret.add(i)
        if (sum >= n) {
            break
        }
    }
    ret.remove(sum - n)
    for (c in ret) println(c)
}

// region template
operator fun Int.iterator() = 0.until(this).iterator()

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = java.io.PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }

    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }

    fun string(): String {
        if (!hasNext()) throw java.util.NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun long(): Long {
        if (!hasNext()) throw java.util.NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}
// endregion

Measured memory_bytes: 33608
/*
 * Author       : YangDavid
 * Created Time : 2019年12月28日 星期六 21时12分00秒
 */

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 1; i <= n; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int n;
const char* plan5[] = {"aabbc", "hii.c", "h..jd", "g..jd", "gffee"};
int main() {
	scanf("%d", &n);
	if(n == 2) puts("-1");
	else if(n == 3) {
		puts("aab");
		puts("d.b");
		puts("dcc");
	} else if(n == 5) {
		puts("aabbc");
		puts("hii.c");
		puts("h..jd");
		puts("g..jd");
		puts("gffee");
	} else if(n == 7) {
		puts("aab...g");
		puts("b.b...g");
		puts("baa...e");
		puts("...aabe");
		puts("...b.bf");
		puts("...baaf");
		puts("ggeeff.");
	} else if(n % 2 == 0) {
		for(int i = 0; i < n; i += 2) {
			string out(n, '.');
			out[i] = 'a';
			out[i+1] = 'b';
			out[(i+2)%n] = 'c';
			out[(i+3)%n] = 'c';
			cout << out << '\n';
			out[(i+2)%n] = 'd';
			out[(i+3)%n] = 'd';
			cout << out << '\n';
		}
	} else {
		for(int i = 0; i < n-5; i += 2) {
			string out(n, '.');
			out[i] = 'a';
			out[i+1] = 'b';
			out[(i+2)%(n-5)] = 'c';
			out[(i+3)%(n-5)] = 'c';
			cout << out << '\n';
			out[(i+2)%(n-5)] = 'd';
			out[(i+3)%(n-5)] = 'd';
			cout << out << '\n';
		}
		for(int i = 0; i < 5; ++i)
			cout << string(n-5, '.') << plan5[i] << '\n';
	}

    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <assert.h>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int x = in();
    cout << "ai1333" + string(x / 100, '3') << endl;

    return 0;
}


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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define VMAX(a) *max_element(ALL(a))
#define VMIN(a) *min_element(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

using ll = long long;
using namespace std;

int main() {
    ll a, b;
    string ab = "", ba = "";

    cin >> a >> b;

    REP(i, a){
        ba += '0' + b;
    }
    REP(i, b){
        ab += '0' + a;
    }

    if (ab < ba){
        cout << ab << endl;
    } else {
        cout << ba << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>

int main()
{
    int i, n, a;
    int min=INT_MAX, max=INT_MIN;
    long long sum=0;
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf("%d", &a);
        if(a<min) min=a;
        if(max<a) max=a;
        sum+=a;
    }
    printf("%d %d %lld\n", min, max, sum);
    return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
int main(){
	int a,b,i;
	scanf("%d%d",&a,&b);
	if(a==b){
		for(i=0;i<a;i++){
			printf("%c",a+'0');
		}
	}
	if(a>b){
		for(i=0;i<a;i++){
			printf("%c",b+'0');
		}
	}
	if(b>a){
		for(i=0;i<b;i++){
			printf("%c",a+'0');
		}
	}
	
}

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

int main(void)
{
	string s, t;
	cin >> s >> t;

	int sum = 0;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] != t[i])
		{
			sum++;
		}
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3920
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
#define ALL(c) (c).begin(), (c).end()

using namespace std;
using ll = long long;
using pli = pair<ll, int>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdi = pair<double, int>;
using pdd = pair<double, double>;

int main() {
	int a[3], b[3];
	for (int i = 0; i < 3; i++)
	{
		int tmpa, tmpb;
		cin >> tmpa >> tmpb;
		a[i] = tmpa;
		b[i] = tmpb;
	}
	int cnt[5] = {};
	for (int i = 0; i < 3; i++)
	{
		cnt[a[i]]++;
		cnt[b[i]]++;
	}

	bool is_ok=true;
	for (int i = 1; i <= 4; i++)
	{
		if (cnt[i] == 3)
			is_ok = false;
	}
	string ans;
	if (is_ok)
		ans = "YES";
	else
		ans = "NO";
	cout << ans << endl;
	return 0;
}


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

#define MOD 1000000007
// int dfs(int n, int N, int a, int b, int c)
// {
//     int ret = 0;
//     for (int i = 0; i < 4; i++)
//     {
//         if ((b == 0 && c == 2 && i == 1) ||
//             (b == 2 && c == 0 && i == 1) ||
//             (b == 0 && c == 1 && i == 2) ||
//             (a == 0 && c == 2 && i == 1))
//         {
//             continue;
//         }

//         if (n < N)
//         {
//             ret += dfs(n + 1, N, b, c, i);
//         }
//         else
//         {
//             ret++;
//         }
//     }
//     return ret;
// }

bool judge(int x, int y, int z)
{
    if (x == 0 && y == 2 && z == 1)
    {
        return true;
    }
    else
    {
        return false;
    }
}

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

    // cout << dfs(1, N, -1, -1, -1) << endl;

    long long ans;

    vector<vector<vector<long long>>> count(4, vector<vector<long long>>(4, vector<long long>(4, 1)));
    vector<vector<vector<long long>>> prev_count(4, vector<vector<long long>>(4, vector<long long>(4, 1)));
    count[0][2][1] = 0;
    count[0][1][2] = 0;
    count[2][0][1] = 0;

    for (int x = 0; x < N - 3; x++)
    {
        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                for (int k = 0; k < 4; k++)
                {
                    prev_count[i][j][k] = count[i][j][k];
                    count[i][j][k] = 0;
                }
            }
        }

        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                for (int k = 0; k < 4; k++)
                {
                    for (int l = 0; l < 4; l++)
                    {
                        if (judge(i, j, k) ||
                            judge(i, k, j) ||

                            judge(j, k, l) ||
                            judge(k, j, l) ||
                            judge(j, l, k) ||

                            judge(i, k, l) ||
                            judge(i, j, l))
                        {
                            continue;
                        }
                        count[j][k][l] += prev_count[i][j][k];
                        count[j][k][l] %= MOD;
                    }
                }
            }
        }
    }

    ans = 0;
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            for (int k = 0; k < 4; k++)
            {
                ans += count[i][j][k];
                ans %= MOD;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import scala.collection.mutable
import scala.util.control.Breaks
object Main extends App {
  val b = Breaks

  b.breakable {
    for (line <- io.Source.stdin.getLines()) {
      if (line.isEmpty) b.break()

      val stk = new mutable.Stack[Double]()

      for (sym <- line.split(' ')) {
        sym match {
          case "+" => {
            val x = stk.pop()
            val y = stk.pop()
            stk.push(y + x)
          }
          case "-" => {
            val x = stk.pop()
            val y = stk.pop()
            stk.push(y - x)
          }
          case "*" => {
            val x = stk.pop()
            val y = stk.pop()
            stk.push(y * x)
          }
          case "/" => {
            val x = stk.pop()
            val y = stk.pop()
            stk.push(y / x)
          }
          case _ => {
            stk.push(sym.toInt)
          }
        }
      }
      println(stk.pop())
    }
  }
}


Measured memory_bytes: 43940
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7; 

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF_INT (1<<30)
#define INF_LL (1ll<<62)

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; }

ll modpow(ll a, ll b, ll mod = 1000000007) {
   ll res = 1;
   for (a %= mod; b; a = a * a % mod, b >>= 1)
     if (b & 1) res = res * a % mod;
   return res;
 }

ll mod = 1000000007;
//---------------------------------------------------------------------------------------------------
ll f[501010], rf[501010];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}

void init() {
    f[0] = 1;
    repi(i, 1, 101010) f[i] = (f[i - 1] * i) % mod;
    repi(i, 0, 101010) rf[i] = inv(f[i]);
}

ll N,a,b,ans;

int main(){
    init();
    cin>>N>>a>>b;
    ans=modpow(2,N);
    ll now=1;
    for(int i = N; i>N-a;i--)now=(now*i)%mod;
    repi(i,1,a+1)now=(now*inv(i))%mod;
    ans=((ans+mod)-now-1)%mod;
    now=1;
    for(int i = N; i>N-b;i--)now=(now*i)%mod;
    repi(i,1,b+1)now=(now*inv(i))%mod;
    ans=((ans+mod)-now)%mod;
    out(ans);
    
    

    
    
}

Measured memory_bytes: 5120
#include <stdio.h>
int main(void)
{
  int i,n;
  int debt=100000;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++)
    {
      debt *= 1.05;

      if(debt % 1000 != 0)
	{
	  debt += 1000 - (debt % 1000);
	}
    }

  printf("%d\n",debt);
  return 0;
}

Measured memory_bytes: 0
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

A,B,C=gets.chomp.split(' ').map{|n| n.to_i}
max = [A,B,C].max
diff = (max-A)+(max-B)+(max-C)
if(diff % 2 == 0)
	puts "#{diff/2}"
else
	puts "#{diff/2 + 2}"
end



Measured memory_bytes: 2044
n = int(input())
a = [int(i) for i in input().split()]
dam = [0]*n

for i in range(n):
    if i%2 == 0:
        dam[0] += a[i]
    else:
        dam[0] -= a[i]

for i in range(1,n):
    dam[i] = a[i-1]*2-dam[i-1]

for i in range(n):
    if i < n-1:
        print(dam[i], end=" ")
    else:
        print(dam[i])

Measured memory_bytes: 14024
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;



signed main() {
    int n;
    cin >> n;
    int ans = INF;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            int j = n / i;
            int v = i + j - 2;
            ans = min(ans, v);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define N 100
#define W 0
#define G 1
#define B 2

int *data[N],d[N],f[N],t=0;

void seach(int ,int *,int *);

int main(){
  int n,i,j,p,q[N],color[N];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&p);
    color[p]=W;
      scanf("%d",&q[p]);
    data[p]=(int *)malloc(q[p]*sizeof(int));
    for(j=0;j<q[p];j++){
      scanf("%d",&data[p][j]);
    }
  }

  for(i=1;i<=n;i++){
    if(color[i]==W){
      seach(i,q,color);
    }
  }

  for(i=1;i<=n;i++){
    printf("%d %d %d\n",i,d[i],f[i]);
  }
  return 0;
}


void seach(int x,int *q,int *color){
  int i;

  color[x]=G;
  t++;
  d[x]=t;

  for(i=0;i<q[x];i++){
    if(color[data[x][i]]==W){
      seach(data[x][i],q,color);
    }
  }
  color[x]=B;
  t++;
    f[x]=t;
  }



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

int main(){
  int R,G,B,N;
  cin>>R>>G>>B>>N;
  int cnt=0;
  for(int r=0;r<=(3000/R)+1;r++){
    for(int g=0;g<=(3000/G)+1;g++){
      if((N-r*R-g*G)%B==0 && r*R+g*G<=N) cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef long double ld;
#define f first
#define s second

const int N = 2e5 + 100;
const int mod = 1e9 + 7;
const ll inf = 1e17;

vector<ll> v;

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);	
	
	ll n, l, t;
	cin >> n >> l >> t;
	ll k = 0;
	for(int i = 0; i < n; i++)
	{
		ll x, w;
		cin >> x >> w;
		
		if(w == 1)
		{
			ll y = l-x;
			ll t2 = t - y;
			if(t2 >= 0)
			{
				k += 1 + t2/l;
				k = (k + n)%n;
				//cout << i << ' ' << 1 + t2/l << endl;
			}
			v.push_back((x+t)%l);
		}
		else
		{
			ll y = x+1;
			ll t2 = t - y;
			if(t2 >= 0)
			{
				k -= 1 + t2/l;
				k = (k + n*(k/n+1))%n;
				//cout << i << ' ' << 1 + t2/l << endl;
			}
			
			ll tmp = x - t + l*(t/l + 1);
			v.push_back(tmp%l);
		}
		
	}
	
	sort(v.begin(), v.end());
	
	for(ll i = k; i < n; i++)
		cout << v[i] << endl;
	for(ll i = 0; i < k; i++)
		cout << v[i] << endl;
	
	
	
	
	
	
	return 0;
}








Measured memory_bytes: 4272
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<set>
#define MP make_pair
using namespace std;
typedef pair<pair<int, int>, int> P;
typedef pair<int, int> PP;

const int INF = 1 << 30;

const int MAX_Q = 2 * 1e5 + 2;

int ans[MAX_Q];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, Q, S, T, X;
    cin >> N >> Q;
    vector<P> events;
    for (int i = 0; i < N; i++) {
        cin >> S >> T >> X;
        events.push_back(MP(MP(S - X, 1), X));
        events.push_back(MP(MP(T - X, -1), X));
    }
    events.push_back(MP(MP(INF, INF), INF));
    vector<PP> D(Q);
    for (int i = 0; i < Q; i++) {
        cin >> D[i].first;
        D[i].second = i;
    }
    sort(events.begin(), events.end());
    sort(D.begin(), D.end());
    set<int> stop;
    int idx = 0;
    for (int i = 0; i < Q; i++) {
        while (events[idx].first.first <= D[i].first) {
            if (events[idx].first.second == 1) {
                stop.insert(events[idx++].second);
            }
            else {
                stop.erase(events[idx++].second);
            }
        }
        if (stop.empty() || events[idx].first.first == INF) ans[D[i].second] = -1;
        else ans[D[i].second] = *stop.begin();
    }
    for (int i = 0; i < Q; i++) cout << ans[i] << endl;
    return 0;
}

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

#define rep(i, n) FOR(i, 0, n)
#define FOR(i, x, n) for (int i = (x); i < (n); ++i)
#define all(v) (v).begin(), (v).end()

using ll = long long;

template<class T> void chmax(T& a, T b){ a>b?:a=b; }
template<class T> void chmin(T& a, T b){ a<b?:a=b; }

int main() {
    int h, w, k;
    string s[6];
    cin >> h >> w >> k;
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
    }
    int ans = 0;
    for (int t = 0; t < (1 << (h + w)); ++t) {
        int cnt = 0;
        for (int i = 0; i < h; ++i) {
            if (t & (1 << i))
                continue;
            for (int j = 0; j < w; ++j) {
                if (t & (1 << (h + j)))
                    continue;
                if (s[i][j] == '#')
                    cnt++;
            }
        }
        if (cnt == k)
            ans++;
    }

    cout << ans << endl;

    return 0;
}

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

map<char, int> counter(string letters){
    map<char, int> frequency;
    for (auto &s : letters){
        ++frequency[s];
    }
    return frequency;
}

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

    map<char, int> original;
    for (int i=0;i<n;i++){
        if (i == 0){
            original = counter(papers[i]);
        } else {
            auto letter_frequency_counter = counter(papers[i]);
            for (auto &item : original){
                original[item.first] = min(item.second, letter_frequency_counter[item.first]);
            }

        }
    }
    vector<char> letters;
    for (auto &item : original){
        if (item.second != 0){
            for (int i = 0; i< item.second; i++){
                letters.push_back(item.first);
            }
        }
    }
    sort(letters.begin(), letters.end());
    if (letters.size() == 0){
        cout << "";
    } else {
        for (auto &letter : letters){
            cout << letter;
        }
    }
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
while(true){
   var x=Arr.shift().split("");
   if(x[0]=="0")break;
   var y=Arr.shift().split("");
   var z=Arr.shift().split("");
   var ans="NA";
   for(var i=0;i<2;i++){
      var s=(["b","w"])[i];
      if(x[0]+x[1]+x[2]==s+s+s)ans=s;
      if(y[0]+y[1]+y[2]==s+s+s)ans=s;
      if(z[0]+z[1]+z[2]==s+s+s)ans=s;
      if(x[0]+y[0]+z[0]==s+s+s)ans=s;
      if(x[1]+y[1]+z[1]==s+s+s)ans=s;
      if(x[2]+y[2]+z[2]==s+s+s)ans=s;
      if(x[0]+y[1]+z[2]==s+s+s)ans=s;
      if(x[2]+y[1]+z[0]==s+s+s)ans=s;
   }
   console.log(ans);
}

Measured memory_bytes: 7644
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
#define INF 10000000000000000
#define MOD 1000000007
using namespace std;



int main(){
    string s;
    cin >> s;
    
    int l = s.length();
    
    if(s[0]!='A'){
        cout<<"WA"<<endl;
        return 0;
    }
    
    if(s[1]<'a' || s[l-1]<'a'){
        cout<<"WA"<<endl;
        return 0;
    }
    
    int low=0;
    int c=0;
    for(int i=2; i<l-1; i++){
        if(s[i]=='C'){
            c++;
        }
        
        if(s[i]>='a'){
            low++;
        }
    }
    if(c!=1 || low!=l-4){
        cout<<"WA"<<endl;
        return 0;
    }
    cout<<"AC"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
n,a,b = map(int, input().split())
if a > b:
    print(0)
elif n == 1:
    if a == b:
        print(1)
    else:
        print(0)
else:
    max_value = b*(n-1) + a
    min_value = b + a*(n-1)
    print(max_value-min_value+1)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int num,n,k,i,curr_pos,x,cycle_length,left_out,steps,req;
	cin >> n >> num; // Town n turns
	vector<long long int> arr(n+1),vis(n+1,-1); // 1 based indexing
	for(i=1;i<=n;i++)
		cin >> arr[i];
	k=0; // No. of jumps
	curr_pos=1; // Current position
	vis[1]=k++; // initial condition
	while(1)
	{
		x = arr[curr_pos]; // 
		if(vis[x]==-1)
		{
			// if(k==num)
			// 	cout <<"k and x "<< k <<" "<< x << endl;
			vis[x]=k++;
			curr_pos = x; 
		}
		else
		{
			cycle_length = k-vis[x];
			left_out = vis[x];
			break;
		}
	}
	//cout <<"num and left_out "<< num <<" "<< left_out << endl;
	if(num > left_out)
	{
		steps = (num-left_out)%cycle_length;
		req = steps + left_out;
	}
	else
		req = num;

	for(i=1;i<=n;i++)
	{
		if(vis[i]==req)
		{
			// cout <<"req and i " << req <<" " << i << endl;
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 6428
#include <iostream>

using namespace std;

int a, b, c, x, y;
int cost;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> b >> c >> x >> y;
    if(x < y){
        swap(x, y);
        swap(a, b);
    }
    if(a + b > 2 * c){
        cost += 2 * c * y;
    }
    else{
        cost += (a + b) * y;
    }
    if(a > 2 * c){
        cost += 2 * c * (x - y);
    }
    else{
        cost += a * (x - y);
    }
    cout << cost << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int s, n, i, x;
	while(1){
		scanf("%d",&n);
		if(!n) break;
		s = 0;
		for(i = 0;i < n / 4;i++){
			scanf("%d",&x);
			s += x;
		}
		printf("%d\n",s);
	}
	return 0;
}

Measured memory_bytes: 1028
# 全部試す
# 1つあたりO(M)
# O(M^2) = 10^6くらい
import numpy as np
from scipy.sparse.csgraph import dijkstra

N,M = map(int,input().split())
edge = [list(map(int, input().split())) for _ in range(M)]

graph = np.zeros((N+1, N+1))

for a, b in edge:
  graph[a, b] = 1
  
ans = 0
for a, b in edge:
  graph[a, b] = np.inf 
  # directed=False -> 無向グラフ
  dist = dijkstra(graph, indices=a, directed=False)
  if dist[b] == np.inf:
    ans += 1
  graph[a, b] = 1 # 元に戻す
  
print(ans)  

Measured memory_bytes: 18640
n,m=map(int,input().split())
T=[]
F=[]
for i in range(m):
    l=sorted(map(int,input().split()))
    if l[0]==1:
        T.append(l[1])
    if l[1]==n:
        F.append(l[0])
if len(set(T)&set(F))!=0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 21780
import java.util.Scanner;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        double e = 1e-8;
        while(true){
            double x = sc.nextDouble();
            double y = sc.nextDouble();
            int s = sc.nextInt();
            if(x+y+s<e)break;
            int ans=0;
            for (int i = 1; i < s; i++) {
                for (int j = 1; j < s; j++) {
                    int a = (int)(i*(100+x)/100+e);
                    int b = (int)(j*(100+x)/100+e);
                    if(a+b!=s)continue;
                    
                    a = (int)(i*(100+y)/100+e);
                    b = (int)(j*(100+y)/100+e);
//                    System.out.println(i+" "+j+" "+(a+b));
                    ans=Math.max(ans, a+b);
                }
            }
            System.out.println(ans);
        }
    }

}

Measured memory_bytes: 23304
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <functional>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }

struct dice_t { // regular hexahedron group
    //       ______
    //      \      \      4
    //     / \   c  \    2156
    //    / a \______\    3 ^
    //    \ a /    b /   ^^ |
    //     \ /   b  /    ab bottom
    //      v__b___/
    int a, b; // in [1, 6]
    int c() const {
        static const int table[6][6] = {
            { 0, 3, 5, 2, 4, 0 },
            { 4, 0, 1, 6, 0, 3 },
            { 2, 6, 0, 0, 1, 5 },
            { 5, 1, 0, 0, 6, 2 },
            { 3, 0, 6, 1, 0, 4 },
            { 0, 4, 2, 5, 3, 0 },
        };
        assert (table[a-1][b-1] != 0);
        return  table[a-1][b-1];
    }
};
dice_t rotate_up(   dice_t dice) { return (dice_t) { dice.a, 7 - dice.c() }; }
dice_t rotate_right(dice_t dice) { return (dice_t) { 7 - dice.c(), dice.b }; }
dice_t rotate_down( dice_t dice) { return (dice_t) { dice.a, dice.c() }; }
dice_t rotate_left( dice_t dice) { return (dice_t) { dice.c(), dice.b }; }

int main() {
    while (true) {
        // input
        array<int, 6> target; repeat (i, 6) scanf("%d", &target[i]);
        if (whole(count, target, 0) == 6) break;
        int p, q; scanf("%d%d", &p, &q); -- p; // [l, r)
        // solve
        string result = "impossible";
        do {
            array<int, 6> t = target;
            auto is_impossible = [&]() {
                int a = t[2 - 1] + t[5 - 1];
                int b = t[3 - 1] + t[4 - 1];
                int c = t[1 - 1] + t[6 - 1];
                if (a + b < c - 1) return true;
                if (b + c < a - 1) return true;
                if (c + a < b - 1) return true;
                return false;
            };
            string acc;
            function<bool (char, dice_t)> dfs = [&](char c, dice_t dice) {
                if (t[7 - dice.c() - 1] == 0) return false;
                t[7 - dice.c() - 1] -= 1;
                if (whole(count, t, 0) == 6) { acc += c; return true; }
                if (not is_impossible()) {
                    if (dfs('E', rotate_right(dice))) { acc += c; return true; }
                    if (dfs('N', rotate_up   (dice))) { acc += c; return true; }
                    if (dfs('S', rotate_down (dice))) { acc += c; return true; }
                    if (dfs('W', rotate_left (dice))) { acc += c; return true; }
                }
                t[7 - dice.c() - 1] += 1;
                return false;
            };
            t[6 - 1] += 1;
            dfs('$', (dice_t) { 2, 3 });
            if (acc != "") {
                acc.pop_back();
                whole(reverse, acc);
                setmin(result, acc);
            }
        } while (whole(next_permutation, target));
        if (result != "impossible") {
            result = result.substr(p, q - p);
        }
        printf("%s\n", result.c_str());
    }
    return 0;
}

Measured memory_bytes: 7508
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <iomanip>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)


int main() {
	int n,k,s;
	cin >> n >> k >> s;

	int left = s + 1;
	if (s == 1000000000) {
		left = 1;
	}


	rep(i, n) {
		if (i < k) {
			cout << s << " " << endl;
		} else {
			cout << left << " " << endl;			
		}
	}

	return 0;
}

Measured memory_bytes: 1408
#  --*-coding:utf-8-*--

def f(str):
    s = {}
    s[0] = 0
    pat = 0

    bits = [2**i for i in range(26)]
    lenOfStr = len(str)

    for c in str:
        pat ^= bits[ord(c)-97]
        s[pat] = min(
            min(s.get(pat^bit, lenOfStr) + 1 for bit in bits),
            s.get(pat, lenOfStr))

    if pat == 0:
        return 1

    return s[pat]
            
str = input()
print(f(str))



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

int main(){
  vector<int> times(3);
  cin >> times.at(0) >> times.at(1) >> times.at(2);
  sort(times.begin(), times.end());
  
  cout << times.at(0) + times.at(1) << endl;

  
  return 0; 
}


Measured memory_bytes: 256
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)
 
func run(){
	n := nextInt()
	arr := make([]int,0)
	ans := 0.0
	
	arr = readIntArray(n)
	
	for i := 0; i < n; i++ {
		ans += 1/float64(arr[i])
	}
	Println(100000000 / (ans * 100000000))
	
}
 
 
// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}

func readIntArray(n int) ([]int) {
	v := make([]int, 0)
	for i := 0; i < n; i++ {
		v = append(v, nextInt())
	}
	return v
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}

Measured memory_bytes: 2816
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define endl "\n"
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int fast_pow(int x, int y, int p);
map<int,int> mp;
int rec(int n){
    if(n==1 )return 1;
    if(mp[n])return mp[n];
    return mp[n]= 1+rec(n/2)+rec(n/2);
}
void solve() {
    int n;cin>>n;
    cout<<rec(n)<<endl;
}

int32_t main() {
    IOS;
    int test = 1;
    // cin >> test;
    while (test--) {
        solve();
    }
    return 0;
}
int fast_pow(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less

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

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cerr << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi  pair    <int,int>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define OO  (ll)1e18
#define EPS 1e-9
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
pii swapii( pii pr ){ return { pr.S , pr.F }; }
ll binEXP( ll x , ll pw , ll MOD = LLONG_MAX );
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 1e5 + 7;

string s; ll dp[MAX][14];
ll go( ll idx , ll rem , ll pw = 1 ){

    if ( idx < 0 ){
        if ( rem == 5 ) return 1;
        return 0;
    }

    ll& ret = dp[idx][rem];
    if ( ~ret ) return ret;

    if ( s[idx] != '?' ){
        return ret = go( idx-1 , (rem + ((s[idx]-'0')*pw)%13)%13 , (pw*10)%13 );
    }
    else{
        ll ans = 0;
        for ( int i = 0; i < 10; ++i ){
            ans += go(idx-1 , ( rem + (i*pw)%13 )%13 , (pw*10)%13 );
            ans %= MOD;
        }
        return ret = ans;
    }
}

int main()
{
    FASTIO //ONLINE__JUDGE();

    cin >> s; mem( dp , -1 );
    cout << go( s.L-1 , 0 );
    return 0;
}


void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}

ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 42704
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define REP1(i,n) for(long long i=1;i<=(n);i++)
#define REP2D(i,j,h,w) for(long long i=0;i<(h);i++) for(long long j=0;j<(w);j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=(h);i++) for(long long j=1;j<=(w);j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) ((a).begin()),((a).end())
#define RANGE(a) (a),((a)+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<(a)<<endl
#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << (a) << endl
#define DBSTART if(1){
#define DBEND }
#else
#define DBPRT(a) do{}while(0)
#define DBSTART if(0){
#define DBEND }
#endif
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 100000
//---------------------

ll a,b;

int main(){
	cin >> a >> b;
	if(a>9 || b>9) PRT(-1);
	else PRT(a*b);
	return 0;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define int long long
#define inf 1000000007 
#define rep(i,n) for(int i=0;i<n;i++)
signed main(){
	int a,b;
	cin>>a>>b;
	int ans=0;
	for(int i=a;i<=b;i++){
		if(i/10000==i%10&&(i%10000)/1000==(i%100)/10)ans++;
	}
	cout<<ans<<endl;
	    
}
	


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>

using namespace std;

int main(){
  int i;
  int N, L;
  //char S[110][110];                                                       
  string S[110];// = new string[110];                                       

  cin >> N; cin >>L;
  for(i = 0; i < N; i++) cin >> S[i];

  sort(S, S+N);

  string res = "";
  for(i = 0; i < N; i++) res += S[i];

  //char* res;                                                              
  //for(i = 0; i < N; i++) res = strcat(res, S[i]);                         

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int INF = 1e9;

int dp[1 << 10][10];
int V,E,s,t;
vector<vector<int> > G;

int rec(int bit = 1, int v = 0){
    if(dp[bit][v]>0) return dp[bit][v];
    if(bit == (1<<V)-1) return 1;
    int ret = 0;
    for(int nv : G[v]){
        if(bit & (1<<nv)) continue;
        ret += rec(bit | (1<<nv), nv);
    }
    return dp[bit][v] = ret;
}

int main(){
    cin >> V >> E;
    G.resize(V);
    for(int i = 0; i < E; ++i){
        cin >> s >> t;
        --s; --t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    cout << rec() << endl;
    return 0;
}



Measured memory_bytes: 256