akhauriyash/Code-Regression huggingface dataset:
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

vi z_algo(string s){
    vi a(s.size());
	a[0]=s.size();
	int i=1,j=0;
	while(i<s.size()){
		while(i+j<s.size()&&s[j]==s[i+j])j++;
		a[i]=j;
		if(j==0){i++;continue;}
		int k=1;
		while(i+k<s.size()&&k+a[k]<j)a[i+k]=a[k],k++;
		i+=k;j-=k;
	}
    return a;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

    int n;cin>>n;
    string s;
    cin>>s;
    vvi in(n);
    rep(i,n)in[i]=z_algo(s.substr(i));
    int out=0;
    rep(i,n)loop(j,1,in[i].size())cmax(out,min(in[i][j],j));
    cout<<out<<endl;
}


Measured memory_bytes: 98176
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
using namespace std;
typedef long long LL;

#include <complex>

typedef complex<double> P;

int N=0;
P p[302];
int CountPointsInCircle(P c){
    int cnt=0;
    for(int i=0;i<N;i++){
        if(abs(p[i]-c)<=1.0001){
            cnt++;
        }
    }
    return cnt;
}

int main(){
    while(1){
        cin>>N;
        if(N==0)break;        
        for(int i=0;i<N;i++){
            double x,y;
            cin>>x>>y;
            p[i]=P(x,y);
        }
        int ans=0;
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                P mid = P((p[i].real()+p[j].real())/2,(p[i].imag()+p[j].imag())/2);
                double dist = abs(p[i]-p[j]);
                if(dist>2.0001){
                    continue;
                }
                P n1  = ((p[i]-p[j]) *P(0, 1))/dist;
                P n2  = ((p[i]-p[j]) *P(0,-1))/dist;
                P c1= mid + n1*sqrt(1.0-dist/2.0*dist/2.0);
                P c2= mid + n2*sqrt(1.0-dist/2.0*dist/2.0);
                int ans1=CountPointsInCircle(c1);
                int ans2=CountPointsInCircle(c2);
                ans=max(ans,max(ans1,ans2));
            }
        }
        if(ans==0){
            cout<<1<<endl;
        }else{
            cout<<ans<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N;cin >> N;
  priority_queue<int> que;
  rep(i,N){
    int x;cin >> x;
    que.push(x);
  }
  int n[2] = {0,0};
  while(!que.empty()){
    n[(que.size()+N)&1]+=que.top();que.pop();
  }
  cout << n[0] - n[1] << endl;
  return 0;
}


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<int>>;

int main(){
  int N; cin >> N;
  vector<unsigned long long> A(N);
  rep(i,N) cin >> A[i];

  unsigned long long buffer=1;
  unsigned long long buffer2=1000000000000000000;
  bool flag=0;
  rep(i,N){
    if(A[i]==0){
      flag=0;
      buffer=0;
      break;
    }
    if(buffer>buffer2/A[i]) flag=1;
    //cout << buffer << " " << pow(10,18)/A[i] << endl;
    buffer = buffer*A[i];


  }


  if(buffer>buffer2) flag=1;
  if(flag) cout << -1;
  else cout << buffer;

  return 0;
}


Measured memory_bytes: 4000
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n;
  cin >> n;
  ll s = 0;
  for(ll i = 1; i <= 10000000 ; i++){
    s = (s * 10 % n + 7 % n)%n;
    if(s == 0){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        System.out.println(canObtain(str) ? "YES" : "NO");
    }

    public static boolean canObtain(String str) {
        String keyence = "keyence";
        if (str.substring(0, keyence.length()).equals(keyence)
                || str.substring(str.length()-keyence.length()).equals(keyence)) {
            return true;
        }
        for (int leftChunkSize = 1; leftChunkSize < keyence.length(); leftChunkSize++) {
            String constructedStr = str.substring(0, leftChunkSize)
                    + str.substring(str.length() - keyence.length() + leftChunkSize);
            if (constructedStr.equals(keyence)) {
                return true;
            }
        }
        return false;
    }
}


Measured memory_bytes: 22740
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <array>
#include <tuple>
#include <utility>
#include <numeric>
#include <iomanip>
#include <cctype>
#include <cmath>
#include <assert.h>
#include <cstdlib>
#include <list>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s << "[";
    for (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

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

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

    int n;
    cin >> n;

    vector<ll> a(n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    ll ans = (1LL << 60),
       x = 0;
    for (int i = 0; i < n - 1; i++) {
        x += a[i];

        ll y = sum - x;
        ans = min(ans, abs(x - y));
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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

const string YES = "Yes";
const string NO = "No";



// ***************************************

int main(){

    string S;
    cin >> S;
    for(auto& s: S){
        if (s == '7'){
            cout << YES << endl;
            return 0;
        }
    }

    cout << NO << endl;

    return 0;
}


Measured memory_bytes: 3620
# 2130~
N=int(input())
# まず素因数分解する．素因数の指数に対して-1,-2,-3と指定していき，素因数の指数が0より小さくなった時点で中止する
# それぞれの素因数についてその数を数え上げて足し算をすれば，それが最大の操作回数である
# まず素因数を求める
A = {}
while N%2 == 0:
    if not 2 in A:
        A[2]=1
    else:
        A[2]+=1
    N /= 2

f=3
while f*f <= N:
    if N % f == 0:
        if not f in A:
            A[f] = 1
        else:
            A[f] += 1
        N /= f
    else:
        f += 2

if N != 1:
    if N in A:
        A[N] += 1
    else:
        A[N] = 1

ans = 0
for k,v in A.items():
    ind = 1
    while not v<ind:
        v -= ind
        ans += 1
        ind += 1
print(ans)






Measured memory_bytes: 9304
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n, x, t;
    cin >> n >> x >> t;
    ll p = n % x == 0 ? 0 : 1;
    cout << (n / x + p) * t << endl;
}


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

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  	string s; cin >> s;
  	int n;
  	if((s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R'))
  		n = 2;
  	if((s[0]=='R' && s[2]=='R' && s[1]!='R') || (s[1]=='R' && s[0]!='R' && s[2]!='R') || (s[1]!='R' && s[0]!='R' && s[2]=='R') || (s[0]=='R' && s[1]!='R' && s[2]!='R'))
  		n = 1;
  	if(s[0]=='R' && s[1] == 'R' && s[2] == 'R')
  		n = 3;
  	if(s[0]!='R' && s[1] != 'R' && s[2] != 'R')
  	    n = 0;
  	cout << n;
  	return 0;
}

Measured memory_bytes: 3608
G=[]
for i in range(3):
    g=list(map(int, input().split()))
    G.append(g)
"""
a1=x
b1=G[0][0]-a1
b2=G[0][1]-a1
b3=G[0][2]-a1
a2=G[1][0]-b1
a3=G[2][0]-b1

G[1][1]=a2+b2=G[1][0]-G[0][0]+G[0][1]
G[1][2]=a2+b3=G[1][0]-G[0][0]+G[0][2]
G[2][1]=a3+b2=G[2][0]-G[0][0]+G[0][1]
G[2][2]=a3+b3=G[2][0]-G[0][0]+G[0][2]
"""
ok=True
if G[1][1]!=G[1][0]-G[0][0]+G[0][1]:
    ok=False

if G[1][2]!=G[1][0]-G[0][0]+G[0][2]:
    ok=False
if G[2][1]!=G[2][0]-G[0][0]+G[0][1]:
    ok=False
if G[2][2]!=G[2][0]-G[0][0]+G[0][2]:
    ok=False

if ok:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <limits>

using namespace std;

#define ll long long

#define in(x) cin >> x
#define out(x) cout << x << endl

#define PI acos(-1)
#define pp push_back

#define Yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define No cout << "No" << endl
#define NO cout << "NO" << endl

#define vec2(type) vector<vector<type>>
#define vec3(type) vector<vector<vector<type>>>

#define For(i, n) for(int i = 0; i < n; i++)

template<typename T> void input(T *data, int n){
	For(i, n){
		cin >> data[i];
	}
}

template<typename T> void input(vector<T> &vec, int n){
	T temp;
	For(i, n){
		cin >> temp;
		vec.push_back(temp);
	}
}

template<typename T> void sort(vector<T> &ary){
	sort(ary.begin(), ary.end());
}

template<typename T> void rsort(vector<T> &ary){
	sort(ary.rbegin(), ary.rend());
}

void rstring(string &str){
	string temp = str;

	For(i, (int)str.size()){
		str[i] = temp[(str.size() - 1) - i];
	}
}

struct Vec{
	int x, y;
	Vec():
	x(0), y(0){}
	Vec(int _x, int _y):
	x(_x), y(_y){}
};

template<typename T> void print(T *x, int n){
	For(i, n){
		cout << x[i] << " ";
	}
	cout << endl;
}

template<typename T> void print(vector<T> &x){
	For(i, (int)x.size()){
		cout << x[i] << " ";
	}
	cout << endl;
}

int gcd(int n, int m){
	if(n % m == 0){
		return m;
	}
	else{
		return gcd(m, n % m);
	}
}

unsigned ll func(unsigned ll n, unsigned ll i){

	n++;
	if(n >> i == 0){
		return 0;
	}
	unsigned ll num_one = (n / (2 << i)) * (1 << i);

	if((n % (2 << i)) != 0 && (n % (2 << i)) - (1 << i) > 0){
		num_one += (n % (2 << i)) - (1 << i);
	}

	return num_one;

}

int main(){

	int r, g, b, n;
	cin >> r >> g >> b >> n;

	int count = 0;

	int num1, num2;

	for(int i = 0;; i++){
		num1 = r * i;
		if(num1 > n){
			break;
		}
		for(int j = 0;;j++){
			num2 = num1 + g * j;
			if(num2 > n){
				break;
			}
			if((n - num2) % b == 0){
				count++;
			}
		}
	}

	out(count);

	return 0;

}

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

int main()
{
    long n,k; cin>>n>>k;
    vector<long> x(n); for(auto& e: x) cin>>e;

    x.push_back(0);
    sort(begin(x), end(x));
    n=x.size();

    int p=0;
    for(int i=0; i<n; ++i) if (x[i]==0) p=i;

    long res=LONG_MAX;
    if (p+k<n) res=min(res, x[p+k]);
    for(int i=1; i<k; ++i) {
        if (p+i<n && p-(k-i)>=0)
            res=min(res, 2*x[p+i]-x[p-(k-i)]);
    }
    if (p+1<n && x[p+1]==0) ++p;
    if (p-k>=0) res=min(res, -x[p-k]);
    for(int i=1; i<k; ++i) {
        if (p+k-i<n && p-i>=0)
            res=min(res, x[p+k-i]-2*x[p-i]);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long 
using namespace std ;
const int inf = 1e9+7;

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin>>n;
	int arr[n];
	for(int& i:arr) cin>>i;

	vector<int>dp(n,inf);
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int j=1;j<=2;j++){
			if(j+i<n) dp[i+j] = min(dp[i+j],dp[i]+abs(arr[i]-arr[i+j]));
		}
	}
	cout<<dp.back()<<endl;

	return 0;
}


Measured memory_bytes: 1792
#include<iostream>

int main(){
    long long a,b;
    std::cin >> a >> b;
    long long ans = 1e18;
    if(std::abs(a) == std::abs(b)){
       std::cout << 1 << std::endl;
       return 0;
    }
    if(-a < b){
      ans = std::min(ans, a + b + 1);
    }
    if(a < -b){
       ans = std::min(-a - b + 1, ans);
    }
    if(-a < -b){
        ans = std::min(ans,a - b + 2);
    }
    if(a < b){
        ans = std::min(ans, b - a);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3640
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn gcd(x: u64, y: u64) -> u64 {
    if x == 0 {
        y
    } else {
        gcd(y % x, x)
    }
}

pub fn primes(x: u64) -> Vec<u64> {
    let x_ = x as usize;
    let mut ps = vec![];
    let mut is_prime = vec![true; x_ + 1];

    if x >= 2 {
        for i in 2..x_ + 1 {
            if is_prime[i] {
                ps.push(i as u64);
            }
            if i * i <= x_ {
                for j in 2..(x_ / i) + 1 {
                    is_prime[i * j] = false;
                }
            }
        }
    }
    ps
}

use std::collections::HashSet;
fn factors(n: u64, ps: &Vec<u64>) -> u64 {
    let mut m = n;
    let mut hs = HashSet::new();
    for &p in ps {
        while m % p == 0 {
            hs.insert(p);
            m /= p;
        }

        if m == 1 {
            break;
        }
    }
    if m != 1 {
        hs.insert(m);
    }
    //println!("{}, {:?}, {:?}", n, ps, hs);
    hs.len() as u64
}

fn main() {
    let v = read_vec::<u64>();
    let a = v[0];
    let b = v[1];

    let g = gcd(a, b);
    let root_g = {
        let mut i: u64 = 1;
        while i*i < g {
            i+=1;
        }
        i
    };

    let ps = primes(root_g + 2);
    //println!("{:?}", ps);
    let ans = factors(g, &ps);
    println!("{}", ans + 1);
}


Measured memory_bytes: 6396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException  {

		BufferedReader buffReader = new BufferedReader(new InputStreamReader(System.in));

		String[] arrPos = buffReader.readLine().split(" ");

		double x1 = Double.parseDouble(arrPos[0]);
		double y1 = Double.parseDouble(arrPos[1]);
		double x2 = Double.parseDouble(arrPos[2]);
		double y2 = Double.parseDouble(arrPos[3]);

		double d1 = x1 - x2;
		double d2 = y1 - y2;

		double d3 = Math.hypot(d1, d2);

		System.out.println(d3);
	}
}

Measured memory_bytes: 24260
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int a;
	cin>>a;
	cout<<a*a;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

ll solve(ll a, ll b) {
    ll m = a * b;
    ll r = sqrt(m) - 2;
    while ( (r+1) * (r+1) < m ) r++;
    ll r2 = r * (r+1) < m ? r+1 : r;
    ll ans;
    if ( r != r2 ) {
        if ( a == r+1 && b == r+1 ) {
            ans = 2 * r;
        } else {
            ans = 2 * r - 1;
        }
    } else {
        ans = 2 * r - 2;
    }
    return ans;
}

int main() {
    ll Q, a, b;
    cin >> Q;
    for ( int q = 0; q < Q; q++ ) {
        cin >> a >> b;
        auto ans = solve(a,b);
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
def search(key, L):
    inc = -1
    exc = N
    while abs(inc-exc) > 1:
        mid = (inc+exc) // 2
        if True if L[mid] <= key else False:
            inc = mid
        else:
            exc = mid
    return exc


def main():
    ans = 0
    for a in A:
        e = search(a, B)
        if e < N:
            ans += E[e]
    print(ans)


if __name__ == "__main__":
    N = int(input())
    A = [int(a) for a in input().split()]
    B = sorted([int(b) for b in input().split()])
    C = sorted([int(c) for c in input().split()])
    E = [0]*N
    for i in range(1, N+1):
        E[-i] = (N-search(B[N-i], C)) + E[-i+1]
    main()


Measured memory_bytes: 23968
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String S[] = br.readLine().split("");
	if (S[0].equals(S[1]) && (S[1].equals(S[2]))) {
	    System.out.println("No");
	} else {
	    System.out.println("Yes");
	}
    }
}

Measured memory_bytes: 21460
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:u32 = read();
    let d:u32 = read();

    let mut x:Vec<Vec<i32>> = Vec::new();
    x.resize(n as usize, Vec::new());
    for i in 0..n {
        let i = i as usize;
        x[i] = (0..d).map(|_| read()).collect();
    }

    let mut ans:u32 = 0;
    for i in 0..n {
        for j in i+1..n {
            let i = i as usize;
            let j = j as usize;
            let dist:i32 = (0..d)
                .map(|k| {
                    let k = k as usize;
                    (x[i][k]-x[j][k]).pow(2)
                })
                .sum();
            let dist = dist as f64;
            //debug!(dist, dist.sqrt());
            if dist.sqrt().floor() == dist.sqrt() {
                ans += 1;
            }
        }
    }

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


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

int main() {
	ll n;
	cin >> n;
	ll ans = 0;
	for (ll i = 1; i <= n; ++i) {
		if (i % 3 != 0 && i % 5 != 0)ans += i;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3624
def main():
    s = input()
    t = input()
    p = 0
    for i in range(len(s)-len(t)+1):
        tmp = 0
        for j in range(len(t)):
            if s[i+j] == t[j]:
                tmp += 1
        if p < tmp:
            p = tmp
    print(len(t)-p)

if __name__ == "__main__":
    main()

Measured memory_bytes: 8988
#include<iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(){
  long long N;
  cin >> N;
  long long qmax = sqrt(N);
  long long sum = 0;
  for (long long q = 1; q <= qmax+1; q++){
    if(N%q==0){
      auto m= N / q - 1;
      
      if(m>q){
        sum = sum+m;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
#include <deque>
#include <queue>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a;
    cin >> n >> a;
    if (n % 500 <= a) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 3656
#include <algorithm>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> P;
lli MOD = 1000000007;
int main()
{
    lli n;
    cin >> n;
    int p[20005];
    int a;
    rep(i, n)
    {
        cin >> a;
        a--;
        p[a] = i + 1;
    }
    rep(i, n)
    {
        cout << (i + 1) * 30000 << ' ';
    }
    cout << endl;
    rep(i, n)
    {
        cout << (n - i) * 30000 + p[i] << ' ';
    }
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
using ll = long long;

struct eratosthenes
{
    int n;
    vector<int> f;
    vector<pair<int, int>> primes;

    eratosthenes(int n) : f(n + 1)
    {
        ll i, j;
        f[0] = f[1] = -1;
        for (i = 2; i <= n; i++)
        {
            if (!f[i])
            {
                f[i] = i;
                primes.push_back(make_pair(i, 0));
                for (j = i * i; j <= n; j += i)
                {
                    if (!f[j])
                    {
                        f[j] = i;
                    }
                }
            }
        }
    }

    vector<pair<int, int>> genosiscount(int x)
    {
        vector<pair<int, int>> gc;
        vector<int> g;

        while (x != 1)
        {
            g.push_back(f[x]);
            x /= f[x];
        }

        if (g.empty() == 1)
        {
            return {};
        }

        gc.push_back(make_pair(f[x], 0));

        for (auto &i : g)
        {
            if (gc.back().first == i)
            {
                gc.back().second++;
            }
            else
            {
                gc.push_back(make_pair(i, 1));
            }
        }

        return gc;
    }
};

ll power(ll x, ll y)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = (ans * x) % 1000000007;
        x = (x * x) % 1000000007;
        y >>= 1;
    }
    return ans;
}

int main(void)
{
    eratosthenes a(1e6 + 1);
    int N;
    int A[10010];
    int i, j;
    ll ans = 0;
    ll lcm = 1;

    cin >> N;

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

        for (auto &j : a.genosiscount(A[i]))
        {
            for (auto &k : a.primes)
            {
                if (j.first == k.first && j.second > k.second)
                {
                    k.second = j.second;
                }

                if (j.first < k.first)
                {
                    break;
                }
            }
        }
    }

    for (auto &x : a.primes)
    {
        lcm = lcm * power(x.first, x.second) % 1000000007;
    }

    for (i = 0; i < N; i++)
    {
        ll add = lcm * power(A[i], 1000000005) % 1000000007;
        ans = (ans + add) % 1000000007;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5368
import java.util.Scanner;


public class Main {
	static String[] a = new String[] {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
	static String[] b = new String[] {"D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","A","B","C"};
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int n = stdIn.nextInt();
			int m = stdIn.nextInt();
			if(n == 0 && m == 0) break;
			int[] sa = new int[n];
			int[] sb = new int[m];
			for(int i = 0; i < n; i++) {
				sa[i] = stdIn.nextInt();
			}
			for(int i = 0; i < m; i++) {
				sb[i] = stdIn.nextInt();
			}
			int ans = 9999999;
			int ansA = 0;
			int ansB = 0;
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < m; j++) {
					int[] tmpA = new int[n];
					int[] tmpB = new int[m];
					for(int k = 0; k < n; k++) {
						tmpA[k] = sa[k];
					}
					for(int k = 0; k < m; k++) {
						tmpB[k] = sb[k];
					}
					int anstmp = tmpA[i];
					anstmp += tmpB[j];
					int ansatmp = tmpA[i];
					int ansbtmp = tmpB[j];
					int tmp = tmpA[i];
					tmpA[i] = tmpB [j];
					tmpB[j] = tmp;
					int sumA = 0;
					int sumB = 0;
					for(int k = 0; k < n; k++) {
						sumA += tmpA[k];
					}
					for(int k = 0; k < m; k++) {
						sumB += tmpB[k];
					}
					if(sumA == sumB) {
						if(ans > anstmp) {
							ans = anstmp;
							ansA = ansatmp;
							ansB = ansbtmp;
						}
					}
				}
			}
			if(ans == 9999999) {
				System.out.println(-1);
			}
			else {
				System.out.println(ansA + " " + ansB);
			}
		}
		
	}
	
}

Measured memory_bytes: 35748
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
bool byme(int x,int y)
{
    return x>y;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int x,y,a,b,c;
cin>>x>>y>>a>>b>>c;
vector<int> ap;
vector<int> gr;
vector<int> co;
for(int i=0;i<a;i++)
{
    int val;
    cin>>val;
    ap.pb(val);
}

for(int i=0;i<b;i++)
{
int val;
    cin>>val;
    gr.pb(val);
}
for(int i=0;i<c;i++)
{
int val;
    cin>>val;
    co.pb(val);
}
sort(gr.begin(),gr.end(),byme);
sort(ap.begin(),ap.end(),byme);
sort(co.begin(),co.end(),byme);
int i=0,j=0,k=0;
int ans=0;
int val=0;
int cnta=0;
for(;k<c;k++)
{
    val+=co[k];
    cnta++;
    if(cnta==x)
        {
         k++;
         break;
        }
}
if(cnta<x)
{
    for(;i<a;i++)
    {
        val+=ap[i];
        cnta++;
        if(cnta==x)
        {
            i++;
            break;
        }
    }
}
int cntb=0;
while(cntb<y)
{
    if(k==c)
    {
        cntb++;
        val+=gr[j];
        j++;
        continue;
    }
    if(gr[j]>=co[k])
    {
        val+=gr[j];
        j++;
    }
    else
    {
        val+=co[k];
        k++;
    }
    cntb++;
}
ans=val;


j-=1;
k-=1;

while(i<x)
{
    val+=ap[i];
    i++;
    if(j<0)
    {
        val-=co[k];
        k--;
        ans=max(ans,val);
        continue;
    }
    else if(k<0)
    {
        val-=gr[j];
        j--;
        ans=max(ans,val);
        continue;
    }
    else
    {
        if(gr[j]<co[k])
        {
            val-=gr[j];
            j--;

        }
        else
        {
            val-=co[k];
            k--;
        }
        ans=max(ans,val);

    }
}
cout<<ans<<endl;
















    return 0;
}


Measured memory_bytes: 3316
#include <iostream>
#include <cmath>

using namespace std;

const double PI=3.14159265358979323846;

double rad2deg(double t){
    return 180*t/PI;
}

int main(){
    double a,b;
    double x; // volume
    scanf("%lf %lf %lf",&a,&b,&x);
    double h = x/(a*a);
    double s = x/a;// 側面の面積

    double t;
    if(a*b/2 <= s){
        // 最大に寝かせたときの断面は台形
        t = atan(-2*(x-a*a*b)/(a*a*a));
    }else{
        // 最大に寝かせたときの断面は三角形
        t = PI/2.0 - atan(2*x/(a*b*b));
    }
//    cout << " " << rad2deg(t) << endl;
    printf("%.10lf\n",rad2deg(t));
    return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  ll N; cin >> N;
  vector<ll> a(N); REP(i, N) cin >> a[i];
  map<int, ll> m;
  for(int i = 0; i < N; ++i) {
      for(int k = -1; k <= 1; ++k) {
          m[a[i] + k]++;
      }
  }

  ll ans = 0;
  for(auto x: m) {
      if(ans < x.second) ans = x.second;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6912
import java.util.Scanner;
public class Main {
	
	static Scanner sc = new Scanner(System.in);
	
	static double k() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		double sum = 0;
		double sumr = 0;
		
		for(int i=0; i<m; i++) {
			int v = sc.nextInt();
			double r = sc.nextDouble();
			sum += v * r;
			sumr += r;
		}
		return sum / sumr;
	}
	
	public static void main(String[] args) {
		int t = sc.nextInt();
		double max = 0;
		for(int i=0; i<t; i++) {
			max = Math.max(max, k());
		}
		if(max - k() > 0.0000001) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 40040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K,a = 1;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
  	if(a * 2 < a + K){
      a *= 2;
    } else {
      a += K;
    }
  }
  cout << a << endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define pcnt __builtin_popcount
#define pcntll(x) __builtin_popcountll(x)
#define DMAX DBL_MAX;
#define IMIN INT_MIN;
#define IMAX INT_MAX;

//const ll MOD = 1e9+7;
//const ll MOD = 998244353;
//const ll MAX = 3e5+1;
//const ll INF = 1e18;
//const ld PI = acos(-1L);

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    rep(i, 5) {
        int tmp;
        in(tmp);
        if (tmp == 0) out(i+1);
    }

    return 0;
}


Measured memory_bytes: 3604
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int A, P;
	cin >> A >> P;

	cout << (A * 3 + P)/2 << "\n";

	return 0;
}

Measured memory_bytes: 892
A=list(input())
B=list(input())
C=list(input())
p="a"
while A!=[] or B!=[] or C!=[]:
    if p=="a":
        if A==[]:
            print("A")
            exit()
        p=A[0]
        A.pop(0)
    elif p=="b":
        if B==[]:
            print("B")
            exit()
        p=B[0]
        B.pop(0)
    elif p=="c":
        if C==[]:
            print("C")
            exit()
        p=C[0]
        C.pop(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,aa=0,bb=0;
  cin >>n;
  string a,b;
  for(int i=0;i<n;i++){
    cin >>a>>b;
    if(a==b){
      aa+=1;
      bb+=1;
    }
    if(a>b){
      aa+=3;
    }
    if(a<b){
      bb+=3;
    }
  }
  cout <<aa<<" "<<bb<<endl;
  return 0;
}

Measured memory_bytes: 3156
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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

using ll = long long;

ll N;
ll A[100010];
ll dp[100010][3];

int main()
{
  scanf( "%lld", &N );

  rep( i, N )
    scanf( "%lld", A+i );

  rep( i, N+1 ) rep( j, 3 )
    dp[i][j] = 1ll<<60;

  dp[0][2] = 0;

  rep( i, N ) rep( isUp, 3 ) // Down: 0 Up: 1 Undecided: 2
  {
    chmin( dp[i+1][2], dp[i][isUp]+1 );

    if( (isUp == 1 || isUp == 2) && i && A[i] >= A[i-1] )
      chmin( dp[i+1][1], dp[i][isUp] );

    if( (isUp == 0 || isUp == 2) && i && A[i] <= A[i-1] )
      chmin( dp[i+1][0], dp[i][isUp] );
  }

  printf( "%lld\n", std::min( dp[N][0], std::min( dp[N][1], dp[N][2] ) ) );

  return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  ll A, B;
  cin >> A >> B;

  ll a = 1;
  for (ll i = 0;; i++)
  {
    if (a >= B)
      FINALANS(i);
    a += A - 1;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;cin>>n;
vector<int>isprime(100001,1);
isprime[0]=0;
isprime[1]=0;
for(int i=0;i<100001;++i) if(isprime[i])for(int j=2;i*j<100001;j++)isprime[i*j]=0;
vector<int> cnt(100001,0);
for(int i=0;i<100001;++i)if(i%2==1&&isprime[i]&&isprime[(i+1)/2])cnt[i]=1;
for(int i=0;i<100000;++i)cnt[i+1]+=cnt[i];
for(int i=0;i<n;++i){
int l,r;
cin>>l>>r;
cout<<cnt[r]-cnt[l-1]<<endl;
}
}


Measured memory_bytes: 1408
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    sx, sy, tx, ty = i_map()

    for _ in range(ty-sy):
        print('U', end='')

    for _ in range(tx-sx):
        print('R', end='')

    for _ in range(ty-sy):
        print('D', end='')

    for _ in range(tx-sx+1):
        print('L', end='')

    for _ in range(ty-sy+1):
        print('U', end='')

    for _ in range(tx-sx+1):
        print('R', end='')

    print('D', end='')
    print('R', end='')
    
    for _ in range(ty-sy+1):
        print('D', end='')

    for _ in range(tx-sx+1):
        print('L', end='')

    print('U', end='')

    print()

if __name__ == '__main__':
    main()


Measured memory_bytes: 80580
n,k=gets.split(" ").map{|i|i.to_i}
max = (n-1)*(n-2)/2

if k > max then
  puts "-1"
else
  puts "#{n-1+max-k}"
  for i in 1..n-1
    puts "1 #{i+1}"
  end
  a = max-k
  for i in 2..n-1
    for j in i+1..n
      if a > 0 then
        a -= 1
        puts "#{i} #{j}"
      else
        break
      end
    end
    if a <= 0 then
      break
    end
  end
  end

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

using namespace std;

int diff(int a, int b) {
    if (a < b) return b - a;
    return a - b;
}

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n), h(n);
    for (int i = 0; i < n; ++i) cin >> x.at(i) >> y.at(i) >> h.at(i);
    for (int cx = 0; cx <= 100; ++cx) {
        for (int cy = 0; cy <= 100; ++cy) {
            int st = 0;
            while (st < n) {
                if (h.at(st) > 0) break;
                ++st;
            }
            int ch = diff(x.at(st), cx) + diff(y.at(st), cy) + h.at(st);
            bool flag = true;
            for (int i = 0; i < n; ++i) {
                flag &= (max(ch - diff(x.at(i), cx) - diff(y.at(i), cy), 0) == h.at(i));
            }
            if (flag) {
                cout << cx << " " << cy << " " << ch << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        boolean isYes = a < 10 && b < 10;
        System.out.println(isYes ? a * b : "-1");
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 23124
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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



int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, l;
	cin >> n >> l;
	int sum = 0;
	for1(i, n)sum += (l + i - 1);
	int best, bestdiff = 6879435;
	for1(i, n){
		int csum = sum - (l + i - 1);
		if(abs(sum - csum) < bestdiff){
			bestdiff = abs(sum - csum);
			best = i;
		}
	}
	deb(best);
	cout << sum - (l + best - 1) << '\n';
	return 0;
}


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

using namespace std;

void dfs(const int& n, string s, vector<string>& ss, map<char, bool> mp, int cnt) {
    if (s.size() == n) {
        ss.push_back(s);
        return;
    }

    mp[s.back()] = true;
    for (int i=0; i<cnt; i++) {
        char next_c = 'a' + i;
        if (mp[next_c])
            dfs(n, s+next_c, ss, mp, cnt);
        else
            dfs(n, s+next_c, ss, mp, cnt+1);
    }
}

int main() {
    int n;
    cin >> n;
    vector<string> ss;
    map<char, bool> mp;
    dfs(n, "a", ss, mp, 2);

    for (auto s : ss)
        cout << s << endl;
}


Measured memory_bytes: 4336
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

template <std::int_fast64_t Modulus>
class modint
{
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept
	{
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept
	{
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept
	{
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept
	{
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept
	{
		a += rhs.a;
		if (a >= Modulus)
		{
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept
	{
		if (a < rhs.a)
		{
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept
	{
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept
	{
		u64 exp = Modulus - 2;
		while (exp)
		{
			if (exp % 2)
			{
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
typedef modint<MOD> ModInt;

ModInt mod_pow(ModInt x, ModInt n) {
	ModInt ret = 1;
	while (n.a > 0) {
		if (n.a & 1) (ret *= x);
		(x *= x);
		n.a >>= 1;
	}
	return ret;
}

lint N, M;
lint x[100000], y[100000];

int main() {
	cin >> N >> M;
	REP(i, N) {
		cin >> x[i];
	}
	REP(i, M) {
		cin >> y[i];
	}
	ModInt x_sum = 0, y_sum = 0;
	REP(i, N - 1) {
		x_sum += (x[i + 1] - x[i]) * (N - i - 1) * (i + 1);
	}
	REP(i, M - 1) {
		y_sum += (y[i + 1] - y[i]) * (M - i - 1) * (i + 1);
	}
	cout << (x_sum * y_sum).a << endl;
}

Measured memory_bytes: 5164