akhauriyash/Code-Regression huggingface dataset:
n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==1:
    b=[i for i in range(2,n,2)]
    b=b*2
    b.sort()
    #print(a,b)
    b=[0]+b
    if a==b:
        print(2**(n//2)%(10**9+7))
    else:
        print(0)
elif n%2==0:
    b=[i for i in range(1,n,2)]
    b=b*2
    b.sort()
    if a==b:
        print(2**(n//2)%(10**9+7))
    else:
        print(0)



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

ll gcd(ll a,ll b){
	if(b==0)return a;return gcd(b,a%b);
}
ll expo(ll base,ll pow){
    ll ans = 1;
    while(pow!=0){
        if(pow&1==1){ans = ans*base;}
        base *= base;pow/=2;}return ans;
}
ll inv(ll x){return expo(x,mod-2);}

int vis[123];

void dfs(vector <vector <int> > vec, int n, pair <int,int> p1){
     vis[n] = 1;
     for(int i = 0; i < vec[n].size(); i++){
         int x = vec[n][i];
         pair <int,int> p2 = make_pair(x, n);
         pair <int,int> p3 = make_pair(n, x);
         if(p1 == p2 || p1 == p3) continue;
         if(!vis[x]){
            dfs(vec, x, p1);
         }
     }
}

int main(){
    //freopen("ip.txt", "rt", stdin);
    //freopen("op.txt", "wt", stdout);
    int n, m;
    cin >> n >> m;
    vector <vector <int> > vec(n+1);
    vector <pair<int,int> > vec1;
    for(int i = 0; i < m; i++){
        int u, v;
        cin >> u >> v;
        vec1.push_back({u,v});
        vec[u].push_back(v);
        vec[v].push_back(u);
    }
    int ans = 0;
    for(int i = 0; i < m; i++){
        for(int i = 1; i <= n; i++) vis[i] = 0;
        dfs(vec, vec1[i].first, vec1[i]);
        int cond = 0;
        for(int i = 1; i <= n; i++) if(vis[i] == 0) cond = 1;
        ans += cond;
        //cout << vec1[i].first << " " << vec1[i].second << " "<< ans << endl;
    }
    cout << ans;
}


Measured memory_bytes: 384
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
// static const int max_n = 110;
// static const llong max_cost = 2000000000000000;
// // vector<vector<llong>> matrix(max_n, vector<llong>(max_n, 0));
// // vector<vector<llong>> adj_matrix(max_n, vector<llong>(max_n, max_cost));
// vector<vector<pair<llong, int>>> adj_list(max_n);
// vector<llong> distance_table(max_n, max_cost);
// set<pair<llong, int>> points_sort_x;
// set<pair<llong, int>> points_sort_y;

// int N;



int main(){
    // int u, v;
    // bool updated = false;
    ll N, M, cost, total_num;
    scanf("%lld", &N);
    total_num = N / 500 * 1000;
    total_num += ((N % 500) / 5) * 5;

    printf("%lld\n", total_num);


    return 0;

}

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

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

    vector<int> a(M);
    vector<int> b(M);
    vector<int> result(N);

    for(int i = 0; i < M; i++){
        cin >> a.at(i) >> b.at(i);

        result.at(a.at(i)-1)++;
        result.at(b.at(i)-1)++;
    }

    for(int i = 0; i < N; i++){
        cout << result.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);

    rep(i, n)
    {
        cin >> a[i];
    }

    int result = numeric_limits<int>::max();
    for (int i = -100; i <= 100; i++) {
        int cost = 0;
        rep(j, n)
        {
            int b = a[j] - i;
            cost += b * b;
        }
        result = min(result, cost);
    }
    cout << result << endl;

    return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    // vector<int> a(n);
    map<int, int> mp;
    long long ans = 0;

    for (int i = 0; i < n; ++i){
        int a, sa, wa;
        cin >> a;
        sa = i - a;
        wa = i + a;
        ans += mp[sa];
        mp[wa]++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 20660
n,c,k = list(map(int, input().split()))
t = [int(input()) for _ in range(n)]
t.sort()

ans = 0
time = 0
j = c
for i in t:
    if time>=i and j>0:
        j -= 1
    else:
        ans += 1
        j = c-1
        time = i+k

print(ans)

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

int n;
int a,b;
int h[100001];

bool ok(ll x) {
  ll c=0;
  for (int i=0; i<n; i++) {
    ll p=1LL*h[i]-1LL*x*b;
    if (p<=0) continue;
    c+=p/a;
    if (p%a) c++;
  }
  return c<=x;
}

int main() {
  cin>>n>>a>>b;
  a-=b;
  rep(i, n) cin>>h[i];

  int left=0;
  int right=1000000005;
  while (right-left>1) {
    ll mid=(right+left)/2;
    if (ok(mid)) right=mid;
    else left=mid;
  }
  cout<<right<<endl;
}


Measured memory_bytes: 640
N, M = map(int, input().split())
py_list = [[int(py) for py in input().split()] for i in range(M)]
order_city = [[] for _ in range(N)]
for i, py in enumerate(py_list):
    order_city[py[0]-1].append((i, py[1]))

ans_list = [None]*M

for p, cities in enumerate(order_city):
    for i, city in enumerate(sorted(cities, key=lambda x: x[1])):
        ans_list[city[0]] = "{0:06d}{1:06d}".format(p+1, i+1)

ans = ""
for i in ans_list:
    ans += i+"\n"
 
print(ans[:-1])

Measured memory_bytes: 54696
#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define MAX 200005
#define MAX_VAL 100005
#define INF 50000000
vector<int> C;
bool v[MAX];
int A[MAX];
int indices[MAX];
int main()
{
    int N,i;
    long long K;
    scanf("%d %lld",&N,&K);
    for(i=0;i<N;i++)
    {
        scanf("%d",&A[i]);
        A[i]--;
    }
    long long j;
    int current=0;
    for(j=0;j<K&&(!v[current]);j++)
    {
        v[current]=true;
        indices[current]=C.size();
        C.push_back(current);
        current=A[current];
    }
    if(j==K)
    {
        printf("%d",current+1);
    }
    else
    {
        int len=C.size();
        len=len-indices[current];
        //printf("CSz=%d,%d\n",len,indices[current]);
        K=K-indices[current];
        long long I=K%len;
        i=(int) (I+indices[current]);
        printf("%d",C[i]+1);
    }
    return 0;
}


Measured memory_bytes: 6112
my $X = <STDIN>;
chomp $X;
$X = abs($X);

my @data;#5乗のDB
my $n = 0;
while(){
  my $cal = $n ** 5;    
  $data[$n] = $cal;
  for(my $i=0;$i<$#data;$i++){
    if( ($cal - $data[$i]) == $X ){
        print "$n $i"; exit;
    }elsif( ($cal + $data[$i]) == $X ){
        print "$n -$i"; exit;
    }
  }
  $n++;
  #if($n > 10){exit;};
}

Measured memory_bytes: 4724
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;

void swap(int* x, int* y){
  int tmp = *x;
  *x = *y;
  *y = tmp;
}

struct union_find{
  private:
  vector<int> parent;
  vector<int> rank;
  public:
      int tree_num;
      void init(int nodenum){
        parent.resize(nodenum, 0);
        REP(i,nodenum) parent[i]=i;
        rank.resize(nodenum,0);
        tree_num = nodenum;
      }
      int find(int x){
        if (parent[x] == x) return x;
        parent[x] = find(parent[x]);
        return parent[x];
      }
      void unite(int x, int y){
        x = find(x);y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) swap(&x,&y);
        rank[x]++;
        rank[y] = rank[x];
        parent[y] = x;
        tree_num--;
        return;
      }
};

int main(int argc, char const *argv[])
{
  union_find uf;
  int n, m;
  cin >> n >> m;
  uf.init(n);
  int x,y,z;
  REP(i,m){
    cin >> x >> y >> z;
    uf.unite(x-1,y-1);
  }
  cout << uf.tree_num << endl;

  return 0;
}


Measured memory_bytes: 1024
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
const    ld   PI=3.14159265359;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}



int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{


int n,l;
cin>>n>>l;

int sum=0;

int a[n];
for(int i=0;i<n;i++)
{a[i]=i+l;
sum+=a[i];
}

int mi=ima;
int ans=imi;
for(int i=0;i<n;i++)
{
	if(abs(a[i])<mi)
	{
		mi=abs(a[i]);
		ans=sum-a[i];
	}
}

cout<<ans;









}return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max(max(a*c, b*d), max(a*d, b*c)) << endl;
  return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;

string S;

int main() {
    cin >> S;
    string res = (S[0] - 'a' < 0) ? "A" : "a";
    cout << res << endl;
    return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  int a[N]={};
  for(int i=0;i<M;i++){
    int x,y;
    cin >> x >> y;
    a[x-1]++;
    a[y-1]++;
  }
  for(int i=0;i<N;i++){
    cout << a[i] << endl;
  }
}




Measured memory_bytes: 256
#include <stdio.h>

int gcd(int a,int b){
  int r;
  while(b != 0){
    r = a%b;
    a = b;
    b = r;
  }
  return a;
}

int main(void){
  int a,b,temp;

  scanf("%d%d", &a, &b);
  
  if(a<b){
    temp = a;
    a = b;
    b = temp;
  }
  
  printf("%d\n",gcd(a,b));

  return 0;
}

Measured memory_bytes: 592
module mod_stack
  implicit none
  type t_node
    private
    integer :: item
    type(t_node), pointer :: prev => null()
    type(t_node), pointer :: next => null()
  end type t_node
  type t_stack
    private
    integer :: num = 0
    type(t_node), pointer :: head => null()
    type(t_node), pointer :: tail => null()
  contains
    procedure :: push => push
    procedure :: pop => pop
    procedure :: peek => peek
    procedure :: clear => clear
    procedure :: size => size_of
  end type t_stack
contains
  function new_node(item) result(node)
    integer, intent(in) :: item
    type(t_node), pointer :: node
    allocate(node)
    node%item = item
  end
  subroutine push(this,item)
    class(t_stack), intent(inout) :: this
    integer, intent(in) :: item
    type(t_node), pointer :: node
    node => new_node(item)
    if (associated(this%head)) then
      node%prev => this%tail
      this%tail%next => node
    else
      this%head => node
    end if
    this%tail => node
    this%num = this%num+1
  end
  function pop(this) result(item)
    class(t_stack), intent(inout) :: this
    integer :: item
    type(t_node), pointer :: node
    item = this%tail%item
    node => this%tail%prev
    deallocate(this%tail)
    this%tail => node
    if (associated(node)) then
      node%next => null()
    else
      this%head => null()
    end if
    this%num = this%num-1
  end
  function peek(this) result(item)
    class(t_stack), intent(in) :: this
    integer :: item
    item = this%tail%item
  end
  subroutine clear(this)
    class(t_stack), intent(inout) :: this
    type(t_node), pointer :: node, prev
    if (.not.associated(this%tail)) return
    node => this%tail
    do while (associated(node%prev))
      prev => node%prev
      deallocate(node)
      node => prev
    end do
    this%head => null()
    this%tail => null()
    this%num = 0
  end
  integer function size_of(this)
    class(t_stack), intent(in) :: this
    size_of = this%num
  end
end module mod_stack
program unification
  use mod_stack
  implicit none
  character(100000) :: s
  integer :: n, i, d
  type(t_stack) :: stack
  read(*,*) s
  n = len_trim(s)
  do i = 1, n
    d = ichar(s(i:i))-48
    if (stack%size() == 0 .or. stack%peek() == d) then
      call stack%push(d)
    else
      d = stack%pop()
    end if
  end do
  write(*,'(i0)') n-stack%size()
end program unification

Measured memory_bytes: 3492
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  long long n;
  cin >> n;
  long long a[n];
  long long b[n];
  rep(i,n){
    long long w;
    cin >> w;
    a[i]=w+i+1;
    b[i]=w-i-1;
  }
  long long k[2*n];
  long long ans=0;
  rep(i,2*n)k[i]=0;
  rep(i,n-1){
    long long o=a[i];
    if(o<2*n){
      k[o]++;
    }
    long long p=b[i+1];
    if(p<1&&p>-2*n){
      ans+=k[-p];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 9888
#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for ( int i = 0; i < n1; i++) L[i] = A[left + i];
    for ( int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for ( int k = left; k < right; k++ ) {
	cnt++;
	if ( L[i] <= R[j] ) {
	    A[k] = L[i++];
	} else {
	    A[k] = R[j++];
	}
    }
}

void mergeSort(int A[], int n, int left, int right) {
    if ( left+1 < right ) {
	int mid = (left + right) / 2;
	mergeSort(A, n, left, mid);
	mergeSort(A, n, mid, right);
	merge(A, n, left, mid, right);
    }
}

int main() {
    int A[MAX], n, i;
    cnt = 0;

    cin >> n;
    for ( i = 0; i < n; i++) cin >> A[i];

    mergeSort(A, n , 0, n);

    for (i = 0;i < n; i++) {
	if (i) cout << " ";
	cout << A[i];
    }
    cout << endl;

    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 6904
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

vector<vector<int> > intlis;
int h, w, k;

int main(){
    cin >> h >> w >> k;
    int f = 0;
    int ans = 100000;
    vector<string> lis(h);
    for(int i = 0; i < h; i++){
        cin >> lis[i];
    }
    for(int a = 0; a < (1 << h-1); a++){
        //cout << a << endl;
        int count = __builtin_popcount(a);
        vector<int> cnt(h, 0), id(h, 0);
        for(int i = 0; i < h-1; i++){
            if((a >> i) & 1 == 1){
                id[i+1] = id[i] + 1;
            }else{
                id[i+1] = id[i];
            }
            //cout << id[i];
        }
        //cout << id[h-1] << "#" << endl;
        vector<int> flag(3000, 0);
        vector<int> addlis(10, 0);
        for(int i = 0; i < w; i++){
            flag[i]++;
            for(int l = 0; l < h; l++){
                if(lis[l][i] == '1'){
                    addlis[id[l]]++;
                    if(addlis[id[l]] > k){
                        count++;
                        if(flag[i] == 1){
                            i--;
                        }else if(flag[i] >= 3){
                            f = 1;
                            i = w;
                            break;
                        }
                        for(int j = 0; j < 10; j++){
                            //cout << addlis[j];
                            addlis[j] = 0;
                        }
                        break;
                    }
                }
            }
        }
        if(f == 1){
            break;
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
int main(){
    lint n,k;
    cin >> n >> k;
    cout << lint(k * pow(k - 1, n - 1) )<< endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
 
k = int(input())
q = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])
 
for i in range(k):
  a = q.popleft()
  if a % 10 == 0:
    q.append(10*a)
    q.append(10*a + 1)
  elif a % 10 == 9:
    q.append(10*a + 8)
    q.append(10*a + 9)
  else:
    q.append(10*a + a%10 - 1)
    q.append(10*a + a%10)
    q.append(10*a + a%10 + 1)
else:
  print(a)


Measured memory_bytes: 40816
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
// #define DEBUGGING

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename Head, typename... Tail> const Head& var_min(const Head &head, const Tail&... tail) { return min(head, var_min(tail...)); }
template <typename Head, typename... Tail> const Head& var_max(const Head &head, const Tail&... tail) { return max(head, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(0);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll N;
    cin >> N;
    V<ll> A(N);
    for(ll &e : A) cin >> e;

    sort(ALL(A));

    ll ans = 1;
    for(ll i = 0; i <= 1; i++) {
        ll e = A[i];
        for(ll j = 1; j * j <= e; j++) {
            if(e % j) continue;
            for(ll d : { j, e / j }) {
                ll cnt = 0;
                for(ll k = 0; k < N; k++) cnt += !!(A[k] % d);
                if(cnt <= 1) chmax(ans, d);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
let () =
  let open Queue in
  let que = create () in
  let (n, q) = Scanf.scanf "%d %d\n" (fun n q -> (n, q)) in
  let rec read i =
    if i < n then (Scanf.scanf "%s %d\n" (fun s t -> add (s, t) que); read (i + 1))
  in
  read 0;
  let rec doit cnt =
    if not (is_empty que) then begin
      let (s, t) = take que in
      let rest = t - q in
      if rest <= 0 then (let x = cnt + t in Printf.printf "%s %d\n" s x; doit x)
      else (add (s, rest) que; doit (cnt + q))
    end
  in
  doit 0

Measured memory_bytes: 13072
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

min_transporter = min([A, B, C, D, E])
if min_transporter >= N:
  print(5)
else:
  print((N + min_transporter - 1) // min_transporter + 4)


Measured memory_bytes: 3060
#include <stdio.h>

int N;
int A[16][16];
long long dp[1 << 16];
long long G[1 << 16];

void to(long long *x, long long y) {
    if (*x < y) *x = y;
}

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            scanf("%d", &A[i][j]);
        }
    }
    for (int i = 1; i < 1 << N; i++) {
        dp[i] = -2e18;
        for (int j = 0; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                if ((i >> j & 1) && (i >> k & 1)) {
                    G[i] += A[j][k];
                }
            }
        }
    }
    for (int i = 0; i < (1 << N); i++) {
        int s = ((1 << N) - 1) ^ i;
        for (int j = s; j != 0; j = (j - 1) & s) {
            to(&dp[i | j], dp[i] + G[j]);
        }
    }
    printf("%lld\n", dp[(1 << N) - 1]);
    return 0;
}



Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

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

		    int n = sc.nextInt();
		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    if(a*n>=b) {
		    	System.out.println(b);
		    }else {
		    	System.out.println(a*n);
		    }
		    sc.close();
	}
}

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

int N;

void out(int* arr){
	for(int i=0; i<N; i++) {
		cout << arr[i];
		if(i!=N-1) cout << " ";
	}
	cout << endl;
}

int main(){
	cin >> N;
	int* A = new int[N];

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

//bubble sort
	int tmp, count=0;;
	bool flag=true;

	while(flag){
		flag=false;
		for(int j=N-1;j>=1;j--){
			if(A[j]<A[j-1]){
				count++;
				tmp=A[j];
				A[j]=A[j-1];
				A[j-1]=tmp;
				flag=true;
			}
		}
	}
	out(A);
	cout << count << endl;
	return 0;
}



Measured memory_bytes: 3088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var S = GetStr();
            var a = int.Parse(S.Substring(0, 2));
            var b = int.Parse(S.Substring(2, 2));
            string ans = "";
            if (0 < a && a < 13)
            {
                if (0 < b && b < 13)
                {
                    ans = "AMBIGUOUS";
                }
                else
                {
                    ans = "MMYY";
                }
            }
            else
            {
                //aはMMでない
                if (0 < b && b < 13)
                {
                    ans = "YYMM";
                }
                else
                {
                    ans = "NA";
                }
            }


            Console.Write(ans);
        }



        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 11092
n = gets.chomp.to_i
v = gets.chomp.split(' ').map(&:to_i)
c = gets.chomp.split(' ').map(&:to_i)

sum = (0..n-1).inject(0) do |s, i|
  v[i] > c[i] ? s + v[i] - c[i] : s
end
puts sum


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

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

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int h, w; std::cin >> h >> w;
  int sx, sy; std::cin >> sx >> sy; sx--, sy--;
  int gx, gy; std::cin >> gx >> gy; gx--, gy--;
  std::vector<std::string> G(h);  rep(i,h) std::cin >> G[i];

  std::vector<std::vector<int>> U(h, std::vector<int>(w, 0));
  int g = 1;
  rep(i,h) rep(j,w) {
    if ( G[i][j] == '#' ) continue;
    if ( U[i][j] != 0 ) continue;
    using P = std::pair<int,int>;
    std::queue<P> q;
    q.push( P(i,j) );
    U[i][j] = g;
    while( !q.empty() ){
      P cur = q.front(); q.pop();
      for( auto dir : { P(1,0), P(-1,0), P(0,1), P(0,-1) } ) {
        P next = P(cur.first + dir.first, cur.second + dir.second);
        if ( next.first < 0 || next.first >= h || next.second < 0 || next.second >= w ) continue;
        if ( G[next.first][next.second] == '#' ) continue;
        if ( U[next.first][next.second] != 0 ) continue;
        U[next.first][next.second] = g;
        q.push(next);
      }
    }
    g++;
  }


  std::vector<std::set<int>> GP(g);
  rep(i,h) rep(j,w) {
    if ( G[i][j] == '#' ) continue;
    for( auto x : { -2, -1, 0, 1, 2 } ) for( auto y : { -2, -1, 0, 1, 2 } ) {
      auto cx = i+x;
      auto cy = j+y;
      if ( cx < 0 || cx >= h || cy < 0 || cy >= w ) continue;
      if ( G[cx][cy] == '#' ) continue;
      GP[ U[i][j]-1 ].insert( U[cx][cy] -1 );
      GP[ U[cx][cy]-1].insert( U[i][j]-1 );
    }
  }


  int sg = U[sx][sy]; sg--;
  int gg = U[gx][gy]; gg--;
  std::vector<int> used(g,-1);
  used[sg] = 0;
  std::queue<int> que;
  que.push(sg);
  while( !que.empty() ){
    int cur = que.front(); que.pop();
    for(auto&& n : GP[cur]) {
      if ( used[n] != -1 ) continue;
      used[n] = used[cur]+1;
      que.push(n);
    }
    if ( cur == gg ) {
      std::cout << used[cur] << std::endl;
      return 0;
    }
  }
  std::cout << -1 << std::endl;
  return 0;
}



Measured memory_bytes: 40068
#include <iostream>
#include<cmath>
#include<vector>
#include<tuple>
#include <ctime>
#include<algorithm>
#include <initializer_list>
#include <cstring> 
 
#define tii tuple<int,int>
#define vi vector<int>
#define vii vector<vi>
#define ll long long
#define vl vector<ll>
#define vll vector<vl>
 
#define mymod 1000000007
#define mx 99999999
#define mn -99999999
#define sz 101
 
using namespace std;

int main() {
    clock_t tstart = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // Start
    vi v(3);
    for(auto&x:v) cin>>x;
    sort(v.begin(),v.end());
    if(v[0]==5 && v[1]==5 && v[2]==7){
        cout<<"YES";
    }
    else cout<<"NO";
    // cout<<"\n\nTotal Time Taken : "<<(double)(-tstart + clock())/CLOCKS_PER_SEC<<"sec\n\n";
    return 0;
}
 


Measured memory_bytes: 3588
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	var input int
	for i := 0; i <= 0; i++ {
		sc.Scan()
		input, _ = strconv.Atoi(sc.Text())
	}

	callTarget := 0
	if input < 10 {
		callTarget = input
	} else if input < 100 {
		callTarget = input - (input / 10 * 10)
	} else {
		callTarget = input - (input / 10 * 10)
	}
	judge(callTarget)
}

func judge(callTarget int) {
	if callTarget == 3 {
		fmt.Println("bon")
	} else if callTarget == 0 || callTarget == 1 || callTarget == 6 || callTarget == 8 {
		fmt.Println("pon")
	} else if callTarget == 2 || callTarget == 4 || callTarget == 5 || callTarget == 7 || callTarget == 9 {
		fmt.Println("hon")
	}
}


Measured memory_bytes: 1756
#include<stdio.h>
#include<string.h>
struct Index {
	char word[31];
	int page;
};
int main(void) {
	int n = 0,i,j;
	struct Index index_data[100], *p,temp;

	p = index_data;

	while (scanf("%s %d", index_data[n].word, &index_data[n].page) != EOF) {
		n++;
	}
		for (i = 0; i < n; i++) {
			for (j = i+1; j < n; j++){
				if (strcmp((p + i)->word,(p + j)->word)==0) {
					if ((p + i)->page > (p + j)->page) {
						temp = *(p + i);
						*(p + i) = *(p + j);
						*(p + j) = temp;
 					}
				}
				else if (strcmp((p + i)->word, (p + j)->word) > 0) {
					temp = *(p + i);
					*(p + i) = *(p + j);
					*(p + j) = temp;
				}
			}
		}
		for (i = 0; i < n; i++) {
			printf("%s\n%d",(p+i)->word,(p+i)->page);
			for (j = i+1; j < n; j++) {
				if (strcmp((p+i)->word,(p+j)->word) == 0) {
					printf(" %d", (p + j)->page);
					i++;
				}
			}
			printf("\n");
		}
	return 0;
}

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

int main(){
  int A,B; cin >> A >> B;
  A--;
  B--;
  string s; cin >> s;
  
  bool OK = true;
  for(int i = 0; i < s.size(); i++){
    if(i == A+1 && s.at(i) != '-') OK = false;
    if(i != A+1 && !('0' <= s.at(i) && s.at(i) <= '9') ) OK = false;
  }
  if(OK) cout << "Yes" << endl;
  else cout << "No" << endl;
}



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

int n;
vector<int> digits;

int main(void){
    // Here your code !
    scanf("%d", &n);
    while(n) {digits.push_back(n % 10)
      ; n /= 10;}
    for (int i = 0; i < digits.size(); ++i) {if (digits[i] == 9) {printf("Yes\n"); return 0;}}
    printf("No\n");
    return 0;
}


Measured memory_bytes: 256
n = int(input())
w = list(map(int, input().split()))
min = 10000000000
s1 = 0
s2 = 0
for i in range(n-1):
    s1 = sum(w[:i+1])
    s2 = sum(w[i+1:])
    if abs(s1 - s2) < min:
        min = abs(s1 - s2)
print(min)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int ans = (x / 500) * 1000 + ((x % 500) / 5) * 5;
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
//#define mod 1000000007
#define N 500055
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,nxt[N],t,nxt2[N],ans;
char str[N];
signed main(){
	scanf("%s",str+1);
	n=strlen(str+1);
	nxt[1]=t=0;
	F(i,2,n){
		while (str[i]!=str[t+1]&&t) t=nxt[t];
		if (str[i]==str[t+1]) t++;
		nxt[i]=t;
	} 
	int num=n-nxt[n];
	if (n%num==0&&num!=n){
		if (num==1){
			wrn(n);wrn(1);return 0;
		}
		wrn(2);
		t=n+1;nxt2[n]=n+1;
		D(i,n-1,1){
			while (str[i]!=str[t-1]&&t<=n) t=nxt2[t];
			if (str[i]==str[t-1]) t--;
			nxt2[i]=t;
		}
		F(i,1,n-1){
			if ((i<=1||(i%(i-nxt[i])!=0||nxt[i]==0))&&(i>=n||((n-i)%(n-i-(n+1-nxt2[i+1]))!=0||(nxt2[i+1]==n+1)))) ans++;
//			wrn((n-i)%(n-i-(n+1-nxt2[i+1]))!=0);
		}
		wrn(ans);
	}
	else{
		wrn(1);wrn(1);
	}
	return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

ll mod(ll a) {
  return (a % 2 + 2) % 2;
}

ll dif(ll x1, ll y1, ll x2, ll y2){
  return abs(x1-x2)+abs(y1-y2);
}
int main(){
  ll n;cin>>n;
  vector<ll> x(n),y(n);

  rep(i,n){
    cin>>x[i]>>y[i];
  }

  FOR(i,1,n){
    if(mod(x[i]+y[i])!=mod(x[i-1]+y[i-1])){
      cout<<-1<<endl;
      return 0;
    }
  }

  vector<ll> v;
  ll m=32;
  if(mod(x[0]+y[0])==0){
    m++;
  }
  cout<<m<<endl;
  rep(i,32){
    cout<<ll(pow(2,31-i))<<" ";
    v.pb(ll(pow(2,31-i)));
  }
  if(mod(x[0]+y[0])==0){
    cout<<1<<" ";
    v.pb(1);
  }
  cout<<endl;

  ll now_x,now_y,next_x,next_y,min_dif=INF;
  string c;
  rep(i,n){
    now_x=0,now_y=0;
    rep(j,v.size()){
      min_dif=1e10;
      if(min_dif>dif(now_x+v[j],now_y,x[i],y[i])){
        next_x=now_x+v[j];
        next_y=now_y;
        min_dif=dif(now_x+v[j],now_y,x[i],y[i]);
        c='R';
      }
      if(min_dif>dif(now_x-v[j],now_y,x[i],y[i])){
        next_x=now_x-v[j];
        next_y=now_y;
        min_dif=dif(now_x-v[j],now_y,x[i],y[i]);
        c='L';
      }
      if(min_dif>dif(now_x,now_y+v[j],x[i],y[i])){
        next_x=now_x;
        next_y=now_y+v[j];
        min_dif=dif(now_x,now_y+v[j],x[i],y[i]);
        c='U';
      }
      if(min_dif>dif(now_x,now_y-v[j],x[i],y[i])){
        next_x=now_x;
        next_y=now_y-v[j];
        min_dif=dif(now_x,now_y-v[j],x[i],y[i]);
        c='D';
      }
      now_x=next_x;
      now_y=next_y;
      cout<<c;
    }
    cout<<endl;
  }
   
  return 0;
}

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

int main() {
  int N,A,B,keta,sum=0,s,t,u,v,w;
  cin >> N >> A >> B;
  
  for(int i=1;i<=N;i++){
    s = i/10000;
    t = (i-s*10000)/1000;
    u = (i-s*10000-t*1000)/100;
    v = (i-s*10000-t*1000-u*100)/10;
    w = (i-s*10000-t*1000-u*100-v*10)/1;
    keta = s+t+u+v+w;
    if(A<=keta && keta<=B)
      sum += i;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define db long double
# define scn(x) scanf("%I64d",&x)
# define scan(x) scanf("%d",&x)
# define print(x) printf("%d ",x)
# define prnt(x) printf("%I64d ",x);
# define eol printf("\n")
# define IOS ios_base :: sync_with_stdio(0)
# define pe "Possible"
# define ie "Impossible"
# define halt(...) {fo << (__VA_ARGS__) << '\n';exit(0);}
# define rep1(n) for (int qwerty = 1;qwerty <= n;++qwerty)
# ifdef CF
# define DEBUG
# endif // CF
# ifdef DEBUG
# define pp(n) cerr << #n << " = " << n << '\n'
# define ppp(v) for (auto it : v) cerr << it << ' ';cerr << '\n'
# define aprint(x,y,z) for (int i = x;i <= y;++i) cerr << z[i] << ' ';cerr << '\n'
# else
# define pp(n) ;
# define ppp(v) ;
# define aprint(x,y,z);
# endif // DEBUG
# define rep(n) for (int i = 1;i <= n;++i)
const int mod = 1e9 + 7;
ll f(ll a,ll b)
{
    if (a > b) swap(a,b);
    return (!a || !b) ? 0 : 2 * (b / a) * a - ((b % a) == 0) * a + f(b % a,a);
}
int main(void)
{
    # ifdef CF
    freopen("input","r",stdin);
    # endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    ll n,x;
    fi>>n>>x;
    fo << (n + f(n - x,x)) << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <stdio.h>
#include <cmath>
#include <vector>  

using namespace std;

int main() {
    string N, HOGE;
    cin >> N;
    for(int i = 0; i < N.size(); ++i){
        if(i % 2 == 0){
            HOGE += N[i];
        }
    }
    cout << HOGE << endl;
}

Measured memory_bytes: 512
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

#define REP(i, a, b) for(int i = a; i <= b; ++i)
#define DEC(i, a, b) for(int i = a; i >= b; --i)
#define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define FI first
#define SE second
#define SZ(x) ((int)(x).size())
#define MP make_pair
#define PB push_back
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pii > VPI;
typedef vector<pll > VPL;
const int mod = 1000000007;

int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int k;
    cin >> k;
    cout << A[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
import Data.List.Split
import Control.Monad

rate :: Double
rate = 380000

bitToJPY :: Double -> Double
bitToJPY bit = do
  bit * rate


sumup :: [(Double, String)] -> Double
sumup tuples = do
  let func = \tuple -> case snd tuple　of
                    "BTC" -> bitToJPY $　fst tuple
                    "JPY" -> fst tuple
  let result = map func tuples
  sum result
  
convert :: String -> (Double, String)
convert string = do
  let ws = words string
  let price = read $ head ws :: Double
  let moneyType = head $ tail ws
  (price, moneyType)


main = do
  n <- readLn
  ss <- replicateM n getLine
  let tuples = map convert ss
  putStrLn $ show $ sumup tuples


Measured memory_bytes: 636
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#pragma GCC optimize ("O2")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class A9x9 {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int A, B;
        in>>A>>B;
        if(A<10 and B<10) out<<A*B<<'\n';
        else out<<"-1\n";
    }
};


int main() {
	A9x9 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <numeric>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s);i<(e);i++)
#define rep(i,n) REP(i,0,n)

vector<vector<int>> G;
vector<int> visited;
int N, M;

void solve(int n) {
  visited[n] = 1;
  for (auto nn : G[n]) {
    if (visited[nn] != 0) continue;
    solve(nn);
  }
}

int main(void) {
  cin >> N >> M;
  G.resize(N);
  visited.resize(N);

  rep(i, M) {
    int x, y, z;
    cin >> x >> y >> z;
    x--; y--;
    G[x].push_back(y);
    G[y].push_back(x);
  }

  int ans = 0;
  rep(i, N) {
    if (visited[i] != 0) continue;
    solve(i);
    ans++;
  }

  cout << ans << endl;
}


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

int main() {
  string S;
  cin >> S;
  int k = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'x') k++;
  }
  if (k >= 8) cout << "NO" << endl;
  else cout << "YES" << endl;
}

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

int main(void)
{
    int  n;
    cin >> n;
    vector<int> h(n);
    for(auto i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    
    int maxh = 0;
    int count = 0;

    for(int i = 0; i < n; i++)
    {
        if (h[i] >= maxh) {
            count++;
            maxh = h[i];
        }
    }
    
  
    cout << count << endl;
    return 0;
}

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

int main()
{
	int ch, cm, cs, gh, gm, gs;
	int ah, am, as;
	int i;

	for (i = 0; i < 3; i++)
	{
		cin >> ch >> cm >> cs >> gh >> gm >> gs;

		ah = gh - ch;

		am = gm - cm;
		if (am < 0)
		{
			ah--;
			am += 60;
		}

		as = gs - cs;
		if (as < 0)
		{
			am--;
			if (am < 0)
			{
				ah--;
				am += 60;
			}
			as += 60;
		}

		printf("%d %d %d\n", ah, am, as);
	}

	return 0;
}

Measured memory_bytes: 3228
s = gets.chomp.chars
[["+","+","+"],["+","+","-"],["+","-","+"],["+","-","-"],["-","+","+"],["-","+","-"],["-","-","+"],["-","-","-"]].each{|a|
  f = s[0]+a[0]+s[1]+a[1]+s[2]+a[2]+s[3]
  if 7 == (eval f)
    puts f+"=7"
    exit
  end
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long

int main(void)
{
    ll n;
    cin>>n;
    ll ans=1;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        if(a[i]==0){
            ans=0;
            cout<<ans<<endl;
            return 0;
        }
    }

    rep(i,n){
        if(ans>1000000000000000000/a[i]){
            ans=-1;
            break;
        }
        ans*=a[i];
    }
    cout<<ans<<endl;
    return 0;
} 

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

#define ll long long

ll gcd(ll a, ll b) {
    ll r, temp;

    while(1) {
        if(a < b) {
            temp = a;
            a = b;
            b = temp;
        }
        if(b < 1) continue;

        while((r = a % b) != 0) {
            a = b;
            b = r;
        }
        return b;
    }
}

ll lcm(ll a, ll b) {
    return a*b/gcd(a, b);
}

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll CD = lcm(C, D);

    ll bika = B - B/C - B/D + B/CD;
    ll amiman = (A - 1) - (A - 1)/C - (A - 1)/D + (A - 1)/CD;
    cout << bika - amiman << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100100];
int sum = 0;

void solution() {
	for (int i = 1; i <= n; ++i) {
		int temp = sum;
		temp -= abs(a[i] - a[i - 1]);
		temp -= abs(a[i + 1] - a[i]);
		temp += abs(a[i + 1] - a[i - 1]);
		printf("%d\n", temp);
	}
}

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		sum += abs(a[i] - a[i - 1]);
	}
	sum += abs(a[n]);
	solution();
	return 0;
}


Measured memory_bytes: 1664
#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);
  }
  
  int x = 1;
  int sum = 0;
  
  while (x != 2) {
    x = vec.at(x - 1);
    sum++;
    if (sum == 100000) {
      break;
    }
  }
  
  if (sum == 100000) {
    cout << "-1" << endl;
  }
  
  else {
    cout << sum << endl;
  }
  
    
}


Measured memory_bytes: 640
N = input()
n = []
for i in range(N):
    n.append(raw_input())
M = input()
m = []
for i in range(M):
    m.append(raw_input())

result = [n.count(a) - m.count(a) for a in n]
max_ = max(result)
if max_ < 0:
    print(0)
else:
    print(max_)

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

int main(){
	long long int test=1;
	//cin>>test;
	while(test--){
	    int n;
	    cin>>n;
	    int cc[n+1]={0};
	    int a[n];
	    for(int i=1;i<n;i++){
	        cin>>a[i];
	        cc[a[i]]++;
	    }
	    for(int i=1;i<=n;i++){
	        cout<<cc[i]<<"\n";
	    }
	}
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  set<string> S;
  rep(i, n){
    string s;
    cin >> s;
    S.insert(s);
  }
  cout << S.size() << endl;
  return 0;
}


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

int main(){
  int n,counter=0;
  vector<int> s;

  cin >> n;
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    auto it = find_if(s.begin(), s.end(),
                      [x](int a){return (x <= a);});
    if(it == s.end()){
      s.push_back(x);
    }else{
      s.insert(it,x);
    }
  }

  cin >> n;
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    if(binary_search(s.begin(),s.end(),x)){
      counter++;
    }
  }

  cout << counter << endl;  
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  int a[3];
  for (int i = 0; i < 3; ++i) {
    cin >> a[i];
  }
  sort(a, a+3);
  if (a[0] == a[1] && a[1] != a[2]) {
    cout << "Yes" << nl;
  } else if (a[0] != a[1] && a[1] == a[2]) {
    cout << "Yes" << nl;
  } else {
    cout << "No\n";
  }
  return 0;
}



Measured memory_bytes: 256