akhauriyash/Code-Regression huggingface dataset:
node_num, l_connected_node, g_connected_node = [int(n) for n in input().rstrip().split()]

l_connected_node-=1
g_connected_node-=1

count=[0]*node_num

for i in range(node_num-1):
    for j in range(i+1, node_num):
        count[min(j-i, abs(i-l_connected_node)+abs(j-g_connected_node)+1)]+=1

for x in range(1, node_num):
    print(count[x])


Measured memory_bytes: 3444
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
using namespace std;

const double PI=acos(-1);

int main(){
    int a, b, c = 1, d = 0;
    cin >> a >> b;

    while(c < b){
        c += a-1;
        d++;
    }
    
    cout << d << endl;
    return 0;
}

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

/* {{{ */
#define PI(N) ((M_PI * (N)) / 180) //角度をラジアンに変換する
#define CL(N) (cout << (N) << endl)
#define DCT(N) (cout << "debug " << (N) << endl)
#define REP(i, N) for (int i = 0; i < (N); i++)
/* }}} */

int main()
{
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    a * b > c * d ? CL(a * b) : CL(c * d);

    return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define maxn 1010
using namespace std;
int a[maxn][3],n,m,mx=0;
main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
		for(int j=0;j<3;j++)
			cin>>a[i][j];
	for(int i=0;i<8;i++)
	{
		vector<int> val;
		for(int k=0;k<n;k++)
		{
			int all=0;
			for(int j=0;j<3;j++)
			{
				if(i&(1<<j))
					all+=a[k][j];
				else
					all-=a[k][j];
			}
			val.push_back(all);
		}
		sort(val.rbegin(),val.rend());
		int sm=0;
		for(int j=0;j<m;j++)
			sm+=val[j];
		mx=max(mx,sm);
	}
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)



int main(void){
	int n,m;
	cin>>n>>m;
	ll x,y,z;
	//do[i][j][000]:= i番目のお菓子まで見て、すでにM個食べている時の[綺麗さ、美味しさ、人気の]をそれぞれ最大1or最小0にしたいときのMAXvalue
	ll dp[1005][1005][8];
	rep(i,1005){
		rep(j,1005){
			rep(k,8){
				dp[i][j][k] = -LINF;
			}
		}
	}
    rep(i,8){
      dp[0][0][i] = 0;
    }
    rep(i,1005){
    	rep(j,8){
    		dp[i][0][j] = 0;
    	}
    	
    }
	
	rep(i,n){
		cin>>x>>y>>z;
		rep(s,m){
			rep(j,2){
				rep(k,2){
					rep(l,2){
						dp[i+1][s+1][4*j+2*k+1*l] = max(dp[i][s+1][4*j+2*k+1*l], dp[i][s][4*j+2*k+1*l] + x*(j==0?-1:1)+y*(k==0?-1:1)+z*(l==0?-1:1));

					}
				}
			}
		}
	}
	ll ans = -LINF;
	rep(i,8){
		ans = max(ans,dp[n][m][i]);
	}
	if(m == 0){
		cout<<0<<endl;
		return 0;
	}
	cout<<ans<<endl;
	return 0;
}


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

int n,k;

int main()
{
    cin>>n>>k;
    int x,maxn=0,gcd=0;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        gcd=__gcd(gcd,x);
        maxn=max(maxn,x);
    }
    if(k%gcd==0&&k<=maxn)
        cout<<"POSSIBLE";
    else
        cout<<"IMPOSSIBLE";
}


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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;
char c ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>c ;
	if(c >= 'A' && c <= 'Z')
		cout<<'A' ;
	else
		cout<<'a' ;
	return 0 ;
}		

Measured memory_bytes: 3648
def run():
    n = int(input())
    nls = sorted([int(i) for i in input().split()])
    result = []
    for i in range(1, nls[0] + 1):
        flag = 1
        for j in nls:
            if j % i:
                flag = 0
                break
            else:
                continue
        if flag:
            result.append(i)
    for i in result:
        print(i)

if __name__ == '__main__':
    run()


Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

// http://drken1215.hatenablog.com/entry/2019/03/28/014100

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) { cin >> A[i]; }
    int res = 0;
    REP(i, N) {
        while(i + 1 < N and A[i] == A[i + 1]) {
            i++;
        }
        // up
        if(i + 1 < N && A[i] < A[i + 1]) {
            while(i + 1 < N && A[i] <= A[i + 1])
                ++i;
        }
        // down
        else if(i + 1 < N && A[i] > A[i + 1]) {
            while(i + 1 < N && A[i] >= A[i + 1])
                ++i;
        }
        res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
//	freopen("1.txt","r",stdin);
	scanf("%d",&n);
	if (n<1200) printf("ABC\n");
	else if (n<2800) printf("ARC\n");
	else printf("AGC\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 
 int a,b,c;
 cin >> a >> b >> c;

 if(a+b==c||a==b+c||a+c==b){
   cout << "Yes" << endl;
 }
 else{
   cout << "No" << endl;
 }
 
}

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

using namespace std;

constexpr int N = 1e5 + 10;
constexpr int MOD = 1e9 + 7;

long long n, a[N], ans = 1e9;

int calc (int x) {
    int ret = 0;
    while (x) {
        ret += x % 10;
        x /= 10;
    }
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 0; i <= n; i++) {
        a[i] = calc (i);
    }
    for (int i = 1; i < n; i++) {
        ans = min (ans, a[i] + a[n - i]);
    }
    cout << ans << "\n";
    return 0;
}


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


int main(){
    int n;
    cin >> n;
    int l = 1e9;
    int ans = 0;
    rep(i,n){
        int p;
        cin >> p;
        l = min(l,p);
        if(p <= l) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int d;
int x[12][12];

int is_integer(int i, int j) {
  int dist = 0, inc = 1;
  rep (k, d) dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
  rep (inc, 4005) if (inc * inc == dist) return 1;
  return 0;
}

int main() {
  int n;
  cin >> n >> d;
  int ans = 0;
  rep (i, n) rep (j, d) cin >> x[i][j];
  rep (i, n) rep (j, i) ans += is_integer(i, j);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
const int INF = 1000000009;

int main()
{
    string number;
    cin >> number;

    int N = number.size();
    // initialize dp
    vector<vector<int>> dp(N+1, vector<int>(2, INF));
    dp[0][0] = 0;
    for (int i=0; i<N; ++i)
    {
        int num_same = number[i]-'0';
        int num_over = (10-(number[i]-'0'))%10;
        dp[i+1][0] = min(dp[i+1][0], dp[i][0]+num_same);
        dp[i+1][0] = min(dp[i+1][0], dp[i][1]+num_same);
        dp[i+1][1] = min(dp[i+1][1], dp[i][0]+num_over+1);

        int prev_fact = -1;
        if (number[i]=='0') prev_fact = 0;
        debug(dp[i][1], prev_fact, num_over);
        if (!(i>0 and number[i]>'0' and number[i-1]=='0'))
            dp[i+1][1] = min(dp[i+1][1], dp[i][1]+prev_fact+num_over);

        // if (i>0 and number[i-1]=='9')
        //     dp[i+1][1] = min(dp[i+1][1], dp[i][1]-1+num_over);
        debug(i, num_same, num_over, dp[i+1][0], dp[i+1][1]);
    }

    // output result
    int res = min(dp[N][0], dp[N][1]);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 55940
# -*- coding: utf-8 -*-
N = int(input())
A = list(map(int, input().split()))

flg = True
for i in range(N):
    if A[i] % 2 == 1:
        continue
    else:
        if A[i] % 3 == 0 or A[i] % 5 == 0:
            continue
        else:
          flg = False
          break

if flg:
    print("APPROVED")
else:
    print("DENIED ")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define PI 3.141592653589793
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    ll H,W,N;
    cin >> H >> W >> N;
    ll m = max(H,W);
    cout << (N+m-1)/m << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long   int a,b,c,d,e;
 long long   int r[2000];
   string s,t;
   while(cin>>a)
   {
       d=1;
       e=0;

       double u,y;
       u=1;
       y=0;
       for(b=1;b<=a;b++)
       {
           cin>>r[b];
          u=u*r[b];
       }
       for(b=1;b<=a;b++)
       {
           y+=(double)u/r[b];
       }
       y=(double)u/y;
       cout<<y<<endl;

   }




    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a[4];
	for(int i = 0; i < 100000; ++i) putchar('(');
	while(1){
    	for(int i = 0; i < 4; ++i){
        	scanf("%d", &a[i]);
    	}
        if(a[0] == 0){ break; }
        
		printf("%d+%d+%d+%d", a[0], a[1], a[2], a[3]);
		putchar('\n');
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<tuple<string, int, int>> data(N);
  for(int i=0; i<N; i++){
  	string adress;
  	int score;
  	cin >> adress >> score;
  	data.at(i)= make_tuple(adress, -score, i+1); // adressは昇順, scoreは降順でソートする為にscoreの符号を反転させる
  }

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

  for(auto p:data){
  	int idx;
  	tie(ignore, ignore, idx)= p;
  	cout << idx << endl;
  }
}

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

int main(){
  cout << setprecision(9);
  int n; ll h; cin >> n >> h;
  vector<pair<ll, bool>> c;
  rep(i, n) {
    ll a, b; cin >> a >> b;
    c.push_back(make_pair(a, 1));
    c.push_back(make_pair(b, 0));
  }
  sort(all(c));
  reverse(all(c));
  ll cur = 0;
  ll i=0;
  while(h > 0) {
    if(c[i].second) {
      double x = (double) h / (double) c[i].first;
      cur += ceil(x);
      break;
    }
    h -= c[i].first;
    cur++;
    i++;
  }
  cout << cur << endl;
}

Measured memory_bytes: 6256
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s; cin >> s;
    deque<char> c(all(s));
    bool f = 0;
    int op; cin >> op;
    rep(i, op) {
        int v; cin >> v;
        if(v == 1) {
            f = !f;
        } else {
            int r; char x; cin >> r >> x;
            if(f) r = 3-r;
            if(r == 1) c.push_front(x);
            else c.push_back(x);
        }
    }
    if(f) reverse(all(c));
    for(char& C:c) cout << C;
    cout << endl;
}



Measured memory_bytes: 976
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val d = sc.nextInt()
    val n = sc.nextInt()
    println(problem100b(d, n))
}

fun problem100b(d: Int, n: Int): Int {
    val list = mutableListOf<Int>()
    for (i in 1..Int.MAX_VALUE) {
        var count = 0
        var num = i
        while (num % 100 == 0) {
            num /= 100
            count++
        }
        if (count == d) list.add(i)
        if(list.size >= n) {
            break
        }
    }
    return list.last()
}

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

long long int c[55][55];

long long com(long long n){
    for (int i = 0; i < n; i++) {
        c[i][0] = 1;
        c[i][i] = 1;
    }
    for (int j = 1; j < n; j++) {
        for (int k = 1; k < j; k++) {
            c[j][k] = (c[j - 1][k - 1] + c[j - 1][k]);
        }
    }
}

int main(void){
    long long int n, a, b, v[55], cnt=0, ans=0;
    cin >> n >> a >> b;
    com(55);
    for(long long int i=0;i<n;++i){
        cin >> v[i];
    }
    sort(v, v+n, greater<long long int>());
    double sum = 0;
    for(long long int i=0;i<a;++i){
        sum += v[i];
    }
    double ave = sum/a;
    printf("%.6f\n",ave);
    if(ave!=v[0]){
        long long int pre;
        for(long long int i=0;i<n;++i){
            if(v[i]==v[a-1]) ++cnt;
            if(i==a-1) pre = cnt;
        }
        ans = c[cnt][pre];
    }else{
        for(long long int i=0;i<n;++i){
            if(v[i]==v[0]) ++cnt;
        }
        if(b <= cnt){
            for(long long int i=a;i<=b;++i){
                ans += c[cnt][i];
            }
        }else{
            for(long long int i=a;i<=cnt;++i){
                ans += c[cnt][i];
            }
        }
    }
    cout << ans << endl;
}

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

void dfs(ll s, vector<bool> &flg, vector<vector<pair<ll, ll>>> &g, vector<ll> &cost) {
    flg[s] = true;
    for ( auto u : g[s] ) {
        ll to = u.first;
        ll len = u.second;
        if ( cost[to] == 1e18 ) {
            cost[to] = cost[s] + len;
        }
        if ( cost[to] != cost[s] + len ) {
            cout << "No" << endl;
            exit(0);
        }
        if ( !flg[to] ) {
            dfs(to, flg, g, cost);
        }
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<pair<ll, ll>>> g(n);
    vector<bool> flg(n, false);
    vector<ll> cost(n, 1e18);
    rep(i, m) {
        ll l, r, d;
        cin >> l >> r >> d;
        --l, --r;
        g[l].push_back(make_pair(r, d));
        g[r].push_back(make_pair(l, -d));
    }
    rep(i, n) {
        if ( !flg[i] ) {
            cost[i] = 0LL;
            dfs(i, flg, g, cost);
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 18304
import collections
n = int(input())
a = list(map(int,input().split()))
p = [0 for i in range(max(a)+3)]

for i in range(n):
    p[a[i]] += 1
    p[a[i] + 1] += 1
    p[a[i] + 2] += 1

print(max(p))

Measured memory_bytes: 14344
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    int M=gi();
	    int[][] S=new int[M][N];
	    int[] k=new int[M];
	    int[] p=new int[M];

	    for (int i=0; i<M;i++) {
	    	k[i]=gi();
	    	for (int j=0; j<k[i];j++) {
	    		S[i][j]=gi();
	    	}
	    }
	    for (int i=0; i<M;i++) {
	    	p[i]=gi();
	    }
	    
	    int c=0;
	    for (int i=0; i<Math.pow(2, N);i++) {
	    	boolean f=true;
	    	for (int j=0; j<M;j++) {
	    		int q=0;
	    		for (int l=0; l<k[j];l++) {
	    			if((i>>(S[j][l]-1) & 1)==1) q++;
	    		}
	    		if(q%2!=p[j]) {
	    			f=false;
	    			break;
	    		}
	    	}
	    	if(f)c++;
	    }

        System.out.println(c);
	}
	// ｎ個の中からm個選ぶ組み合わせの数
	public static long combi(long n, long m) {
		if (n<m) return 0;
		long c=Math.min(m, n-m);
		long ckaijo=kaijo(c);
		long v=1;
		while(c!=0) {
			c--;
			v*=n;
			n--;
		}
		return v/ckaijo;
	}

	// ｎ個の中からm個選ぶ組み合わせの数
	public static long kaijo(long n) {
	    if(n<=1) return 1;

	    return n* kaijo(n-1);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35856
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF (1LL<<31)-1
typedef struct RAQ{
ll n;
	vector<ll> a;
	//vector<bool> f;
	void init(int size){
		n = 1;
		while(n<size) n*=2;
		a = vector<ll> (2*n-1,0);
		//f = vector<bool> (2*n-1,true);
	}
	
	void init(vector<ll> &b){
		int size = b.size();
		n = 1;
		while(n<size)n*=2;
		a = vector<ll> (2*n-1,0);
		//f = vector<bool> (n,true);
		for(int i=0;i<size;i++) a[i+n-1] = b[i];
	}
	//
	void update(ll aa,ll b ,ll k,ll l,ll r ,ll x){
		if(r<= aa|| b<= l)return ;
		if(aa<=l && r<=b ) a[k] += x*(r-l);
		else{
			a[k*2+1] += a[k]/2;
			a[k*2+2] += a[k]/2;
			a[k] = 0;
			update(aa,b,k*2+1,l,(l+r)/2,x);
			update(aa,b,k*2+2,(l+r)/2,r,x);
		}
		return ;
	}
	ll find(ll aa,ll b,ll k,ll l,ll r){
		if(r<=aa|| b<=l) return 0;
		if(aa<=l && r<= b) return a[k];
		a[k*2+1] += a[k]/2;
		a[k*2+2] += a[k]/2;
		a[k] = 0;
		return find(aa,b,k*2+1,l,(l+r)/2) + find(aa,b,k*2+2,(l+r)/2,r) ;
	}
	//[s,t]
	void update(ll s,ll t,ll x){
		update(s,t+1,0,0,n,x);
	}
	ll find(ll s){
		return find(s,s+1,0,0,n);
	}
	
}RAQ;



int main(){
	ll n,q;
	cin>>n>>q;
	RAQ seg;
	seg.init(n);
	//cout<<seg.a.size()<<endl;
	for(ll i=0;i<q;i++){
		ll d,s,t,x;
		cin>>d;		
		if(d==0){
			cin>>s>>t>>x;
			s--,t--;
			seg.update(s,t,x);
		}else{
			cin>>s;
			s--;
			cout<<seg.find(s)<<endl;
		}
	}

	return 0;
}



Measured memory_bytes: 7024
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<complex>

#define INF 1000000000
#define MOD 1000000007
#define EPS 1e-8

#define REP(i, m) for(long long i = 0; i < m; ++i)
#define FOR(i, n, m) for(long long i = n; i < m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	ll k;
	cin>>k;
	ll r = k % 50;
	ll m = k / 50;
	vector<ll> a(50, 49 + m - r);
	if(r <= 19) {
		a[0] = (49 + m) + r * 50;
	} else if(r <= 38) {
		a[0] = (49 + m) + (r / 2) * 49;
		a[1] = (49 + m) + (r / 2) * 49;
		if(r % 2 == 1) {
			--a[1];
			a[0] += 50;
		}
	} else {
		a[0] = (49 + m) + (r / 3) * 48;
		a[1] = (49 + m) + (r / 3) * 48;
		a[2] = (49 + m) + (r / 3) * 48;
		if(r % 3 == 1) {
			a[1] -= 1;
			a[2] -= 1;
			a[0] += 50;
		} else if(r % 3 == 2) {
			a[1] -= 2;
			a[2] -= 2;
			a[0] += 2 * 50;
		}
	}
	cout<<50<<endl;
	REP(i, 50) {
		cout<<a[i];
		if(i != 49) cout<<" ";
		else cout<<endl;
	}
}


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

int main() {
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    vector<ll> s((3*n-1)/2);
    s[0]=0;
    rep(i,(3*n-1)/2){
        s[i+1]=s[i]+2*a[(2*i+1+n)%n];
    }
    rep(i,n){
        if(i%2==0){
            cout<<sum-s[i/2+(n-1)/2]+s[i/2]<<" ";
        }else{
            cout<<sum-s[(i-1)/2+n]+s[(i-1)/2+(n+1)/2]<<" ";
        }
    }
    cout<<endl;
}


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

bool solve(int X, int Y){
    return ((Y-2*X)%2 == 0) && ((Y-2*X)/2 >= 0) && (X-(Y-2*X)/2 >= 0);
}

int main(){
    int X, Y;
    cin >> X >> Y;
    if(solve(X, Y)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main()
{
    int k,s,x,y,z,c=0;
    while(scanf("%d%d",&k,&s)!=EOF)
    { c=0;
        for(x=0;x<=k;x++)
        {
            for(y=0;y<=k;y++)
            {
                z=s-x-y;
                if(z>=0&&z<=k){c++;}
            }
        }
        printf("%d",c);
    }
    return 0;
}


Measured memory_bytes: 128
w, h, n = map(int, input().split())
cnt = 0
for i in range(n):
	if i==0:
		f = list(map(int, input().split()))
		continue
	t = list(map(int, input().split()))
	x, y = t[0]-f[0], t[1]-f[1]
	if x*y>0:
		cnt += max(abs(x), abs(y))
	else:
		cnt += abs(x)+abs(y)
	f = t[:]
print(cnt)



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

using namespace std;

int p, q, a, n;

int dfs(int x, int y, int d, int last, int l)
{
	if (l < 0 || x * q > y * p) return (0);
	if (x * q == y * p) return (1);

	int ret = 0;
	for (int i = last; d * i <= a; i++){
		if (d * i <= a) ret += dfs(x * i + y, y * i, d * i, i, l - 1);
	}
	return (ret);
}

int main()
{
	while (scanf("%d %d %d %d", &p, &q, &a, &n) && n){
		printf("%d\n", dfs(0, 1, 1, 1, n));
	}

	return (0);
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m);i<(n);i++)
#define FOP(i,m,n) for (int i=(m)-1;i>=(n);--i)
#define test(x) cout << #x << ' ' << x << endl;
#define eb emplace_back
#define pb push_back
#define mp make_pair 
#define pii pair<int,int>
#define pli pair<lli,int> 
#define X first
#define Y second

const int K = 707, N = 500087, NN = 1e6 + 87;

struct Query {
    int l, r, idx, k;
    bool operator < (const Query &other) {
        if (l / K == other.l / K) return r < other.r;
        return l / K < other.l / K;
    }
};
int ans = 0, pos[NN];

void add(int k) {
    pos[k]++;
    ans += (pos[k] == 1);
}

void sub(int k) {
    pos[k]--;
    ans -= (pos[k] == 0);
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    scanf("%d %d", &n, &q);
    vector <Query> Q(q);
    vector <int> input(n+1);
    fop (i,0,n) scanf("%d", &input[i]);
    vector <int> v = input;
    fop (i,0,q) scanf("%d %d", &Q[i].l, &Q[i].r), Q[i].l--, Q[i].r--, Q[i].idx = i;
    sort(Q.begin(), Q.end());
    int l = 0, r = -1;
    fop (i,0,NN) pos[i] = 0;
    vector <lli> anss(q);
    fop (i,0,q) {
        while (r < Q[i].r) {
            r++;
            add(input[r]);
        }
        while (r > Q[i].r) {
            sub(input[r]);
            r--;
        }
        while (l > Q[i].l) {
            l--;
            add(input[l]);
        }
        while (l < Q[i].l) {
            sub(input[l]);
            l++;
        }
        anss[Q[i].idx] = ans;
    }
    fop (i,0,q) cout << anss[i] << '\n';
}

Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  string str;cin>>str;
  str[3]='8';
  cout<<str<<endl;
  return 0;
}


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

#include <set>
#include <iterator>
using namespace std;
// using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF (ll)1e17
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
// typedef tree<pll, null_type, less<pll>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
const int  N=2e5 +10, M=(ll)1e9+1 ;
const int mod =(ll)1e9+7 , MAX=(ll)1e6+10;
string fir="Monocarp",sec="Bicarp";

map<string,ll> m;

void work(){
	ll x;
	cin >> x;
	// cout << fir;
	for(ll a=-200;a<=200;a++){
		for(ll b=-200;b<=200;b++){
			ll d=a*a*a*a*a - b*b*b*b*b;
			if(x==d){
				cout << a << " " << b ;
				return;
			}
		}
	}
	return;
	
}

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	// precomp();
	ll t;
	// cin >> t;
	t=1;
	while(t--){
	        work();
	
	}

	return 0;
}
	

Measured memory_bytes: 3668
#include <iostream>
    #include <stdio.h>
    #include <string>
    #include <math.h>
    #include<algorithm>
    #include <numeric>
    using namespace std;
 
    int main(){
      int N,Y;
      cin >> N >> Y;
      Y/=1000;
      int ans1=-1,ans2=-1,ans3=-1;
      for(int i=0;i<=Y/10+1;i++){
       for(int j=0;j<=Y/5+1;j++){
        if(10*i+5*j+(N-i-j)==Y && N>=i+j){
          ans1=i;
          ans2=j;
          ans3=N-i-j;
        }
       }
      }
       cout << ans1 << ' ' << ans2 << ' ' << ans3 << endl; 
      return 0;}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <array>
bool checkVal(int a,int b,int c)
{
	return a < b && b < c;
}

bool rec(int a, int b, int c, int deep,int max)
{
	if (deep > max)
	{
		return false;
	}
	if (checkVal(a, b, c))
	{
		return true;
	}
	deep++;
	bool result = rec(a * 2, b, c, deep, max) || rec(a, b * 2, c, deep, max) || rec(a, b, c * 2,deep,max);
	return result;
}
bool operate(int a, int b, int c, int max)
{
	return rec(a, b, c, 0, max);
}
int main()
{
	int a, b, c;

	std::cin >> a >> b >> c;
	int n;
	std::cin >> n;

	
	if (operate(a, b, c, n))
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No"<< std::endl;
	}
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstring>

using namespace std;

const int mod=1e9+7;
const int N=2010;
int dp[N];

int main(){
    int n;
    scanf("%d",&n);
    if(n<3){
        printf("0\n");
        return 0;
    }
    dp[3]=1;
    dp[4]=1;
    dp[5]=1;
    for(int i=6;i<=n;++i){
        for(int j=3;j<=i-3;++j){
            dp[i]=(dp[i]+dp[j])%mod;
        }
        dp[i]+=1;
    }
    cout<<dp[n]%mod<<endl;
    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int mod = int(1e+9) + 7;


int main() {
  int n;
  cin >> n;
  int sum = 0;
  if (n % 2 == 0) {
    sum = 1 + n;
  } else {
    sum = n;
  }

  int num = 0;
  vector<pair<int, int>> ans;
  for (int i = 1; i < n; i++) {
    for (int j = i+1; j <= n; j++) {
      if (i + j == sum) continue;
      num++;
      ans.emplace_back(i, j);
    }
  }

  cout << num << endl;
  for (auto& p : ans) {
    cout << p.first << " " << p.second << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

V<string> ans;
ll n;

void dfs(ll i, ll ms, V<int> tmp) {
    if (i == n) {
        string tmps(n, '.');
        for (ll i = 0; i < n; i++) tmps[i] = (char)('a' + tmp[i] - 1);
        ans.emplace_back(tmps);
    } else {
        for (ll j = 1; j <= ms + 1; j++) {
            tmp.emplace_back(j);
            dfs(i + 1, max(ms, j), tmp);
            tmp.pop_back();
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    dfs(0, 0, V<int>());
    for (int i = 0; i < ans.size(); i++) cout << ans[i] << '\n';
    return 0;
}


Measured memory_bytes: 7796
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    vector<int> a(3);
    for (int i=0;i<3;i++) cin >> a[i];
    sort(a.begin(),a.end());
    if ((a[0]==a[1] || a[1]==a[2]) && a[0]!=a[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())

MOD = 10 ** 9 + 7

def combination(n, r):
    a = b = 1
    for i in range(1, min(r, n - r) + 1):
        a = a * (n + 1 - i) % MOD
        b = b * i % MOD
    return a * pow(b, MOD - 2, MOD) % MOD

ans = pow(2, n, MOD) - 1
ans -= combination(n, a)
ans %= MOD
ans -= combination(n, b)
ans %= MOD

print(ans)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define int         int64_t
#define ii          pair<int,int>
#define dd          pair<double,double>
#define vi          vector<int>
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define checkBit(v, p)      (v&(1LL << p))
#define loop(i,a,b) for(int i = a;i < int(b);i++)
#define x           first
#define y           second
using namespace std;
int inf = 4e18, mod = 1e9 + 7;


int32_t main()
{
    ios_base::sync_with_stdio(false); cout << fixed <<setprecision(0);
    int n, m; cin >> n >> m;
    int maxi = 0;
    vi pos(n), add(n,0);
    vector<vi> mat(n,vi(m)), dp(n,vi(m));
    pos[0] = 0;
    for(int i=1;i<n;i++) cin >> pos[i], pos[i] += pos[i-1];
    for(auto &v:mat) for(auto &c:v) cin >> c;
    for(int j=0;j<m;j++){
        int ind;
        for(int i=n-1;i >= 0;dp[i][j] = ind, --i)
            for(ind = i+1; ind < n && mat[ind][j] <= mat[i][j]; ind = dp[ind][j]) ;
        ind = 0;
        for(int last = mat[0][j]; ind < n; last = mat[ind][j], ind = dp[ind][j]) add[ind] += mat[ind][j] - last;
    }
    for(int l=0;l<n;++l){
        int val = 0;
        for(auto &c:mat[l]) val += c;
        for(int r=l;r<n;++r) val += add[r], maxi = max(maxi, val - (pos[r] - pos[l]));
        if(l == n-1) break;
        for(int j=0;j<m;j++){
            if(dp[l][j] < n) add[dp[l][j]] -= mat[dp[l][j]][j] - mat[l][j];
            for(int last = mat[l+1][j], ind = l+1; ind < n && ind <= dp[l][j]; last = mat[ind][j], ind = dp[ind][j])
                add[ind] += mat[ind][j] - last;
        }
    }
    cout << maxi << endl;
    return 0;
}


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

int main(){
  int n;
  char x[1001],y[1001];
  int dp[1002][1002];
  
  //initialize
  for(int i=0;i<1002;i++){
    for(int j=0;j<1002;j++){
      dp[i][j]=0; 
    }
  }

  //load n;
  cin >>n;
  for(int i=0;i<n;i++){
    //load string
    scanf("%s",x);
    scanf("%s",y);
    //dp
    for(int j=0;j<strlen(x);j++){
      for(int k=0;k<strlen(y);k++){
	if(x[j]==y[k]){
	  dp[j+1][k+1]=dp[j][k]+1;
	}

	else{
	  if(dp[j][k+1]>dp[j+1][k]){
	    dp[j+1][k+1]=dp[j][k+1];
	  }

	  else{
	    dp[j+1][k+1]=dp[j+1][k];
	  }
	}
      }
    }

    //print
    cout <<dp[strlen(x)][strlen(y)]<<endl;
  }



  return 0;
}

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

const int INF = (1LL<<31)-1;

class SparseTable{
private:
    int N;
    int H;
    vector<vector<int>> data;
    vector<int> rdata;
    
public:
    SparseTable(vector<int> rdata): rdata(rdata){
        N = rdata.size();
        H = log2(N);
        
        data.resize(H+1);
        for(int i=0; i<N; i++){
            data[0].push_back(i);
        }
        int l = 1;
        for(int h=1; h<=H; h++){
            for(int i=0; i+l*2<=N; i++){
                int idx = -1;
                if(rdata[data[h-1][i]] < rdata[data[h-1][i+l]])
                    idx = data[h-1][i];
                else
                    idx = data[h-1][i+l];
                data[h].push_back(idx);
            }
            l <<= 1;
        }
    }
    int find(int a, int b){
        int h = log2(b-a);
        if(rdata[data[h][a]] < rdata[data[h][b-(1<<h)]])
            return data[h][a];
        else
            return data[h][b-(1<<h)];
    }
};

void euler_tour(vector<vector<int>> &G, int u, int d, vector<int> &tour, vector<int> &depth){
    tour.push_back(u);
    depth.push_back(d);
    for(auto v: G[u]){
        euler_tour(G, v, d+1, tour, depth);
        tour.push_back(u);
        depth.push_back(d);
    }
}

int main(){
    int N; cin >> N;
    vector<vector<int>> G(N);
    
    for(int i=0; i<N; i++){
        int k; cin >> k;
        for(int j=0; j<k; j++){
            int c; cin >> c;
            G[i].push_back(c);
        }
    }
    
    vector<int> tour, depth;
    euler_tour(G, 0, 0, tour, depth);
    vector<int> rightmsot(N);
    for(int i=0; i<tour.size(); i++)
        rightmsot[tour[i]] = i;
    
    SparseTable st(tour);
    
    int Q; cin >> Q;
    for(int i=0; i<Q; i++){
        int u, v; cin >> u >> v;
        int ru = rightmsot[u], rv = rightmsot[v];
        if(ru > rv)
            swap(ru, rv);
        rv++;
        int d = st.find(ru, rv);
        cout << tour[d] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 32012
#include<iostream>
#include<algorithm>
using namespace std;
 
int main() {
    unsigned long N, K;
    cin >> N >> K;
    unsigned long x,y;
  
    if (N % K){
      x = N/K + 1;
    }else{
      x = N/K;
    }
    y = N - x*K;
    cout << min(-y, y + K) << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

void solve() {
    for (;;) {
        string s;
        cin >> s;
        int ans = 0;
        rep(i, s.size()) { ans += (int)(s[i] - '0'); }
        if (ans == 0) {
            break;
        }
        cout << ans << "\n";
    }
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


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

int main()
{
  int n,q,r;
  cin>>n;
  if(n%2==0)
  {
	cout<<n/2<<endl;
  }
  else
  {
	q = n/2;
    r = n%2;
    cout<<q+r<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n, m, l, r, flag[100000];
	for (int i = 0; i < 100000; ++i) flag[i] = 0;
	cin >> n >> m;
	for (int i = 1; i <= m; ++i) {
		cin >> l >> r;
		flag[l - 1] += 1;
		flag[r] -= 1;
	}
	int sum = 0,cnt=0;
	for (int i = 0; i < n; ++i) {
		sum += flag[i];
		if (sum == m) ++cnt;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
using namespace std;

int N; vector<int> C,S,F;
void input()
{
    cin >> N;
    C.resize(N); S.resize(N); F.resize(N);
    for (int i = 0; i < N-1; ++i){
        cin >> C[i] >> S[i] >> F[i];
    }   
}

void solve()
{
    vector<int> dep_time(N-1);
    for (int i = 0; i < N-1; ++i){
        dep_time[i] = S[i];
        for (int j = i+1; j < N-1; ++j){
            if (dep_time[j-1] + C[j-1] <= S[j]) dep_time[j] = S[j];
            else {
                if ((dep_time[j-1] + C[j-1]) % F[j] == 0) dep_time[j] = dep_time[j-1] + C[j-1];
                else dep_time[j] = ((dep_time[j-1] + C[j-1]) / F[j] + 1) * F[j];
            }
        }
        cout << dep_time[N-2] + C[N-2] << endl;
    }
    cout << 0 << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;


int main(){

  int n;
  int k[1000];
  string s;
  string str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";


  while(1){

    cin>>n;
    if(!n)
      break;

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

    cin>>s;

    int count = -1;

    for(int i = 0; i < s.size(); i++){
      int a;
      count++;
      count = count % n;
      for(int j = 0; j < 52; j++){
	if(s[i] == str[j]){
	  a = j;
	}
      }
      a += 104;
      //cout<<"a= "<< a << endl;
      //cout<<"k= "<< k[count] << endl;
      //cout<<"a - k= "<< a - k[count] << endl;
      cout << str[(a - k[count]) % 52];
    }
    cout<<endl;

  }
  return 0;
}



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

int main() {
    int A, B; cin >> A >> B;
    if (A>9 | B>9) {
        cout << -1 << endl;
    } else {
        cout << A*B << endl;
    }
    return 0;
}

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

long long n, a[200003], dp[200003][4]; // 0:all 2, 1: one 3, 2: two 3, 3: one 4

int main(){
	cin >> n;
	for (int i=0;i<n;i++) cin >> a[i];
	for (int i=0;i<n;i++){
		for (int j=0;j<4;j++){
			dp[i][j]=-1e15;
		}
	}
	if (n%2==0){
		for (int i=0;i<n;i++){
			dp[i][0]=a[i];
			if (i-2>=0) dp[i][0]+=dp[i-2][0];
			if (i-3>=0){
				dp[i][1]=a[i];
				dp[i][1]+=max(dp[i-2][1],dp[i-3][0]);
			}
		}
		long long ans=dp[n-1][0];
		ans=max(ans,dp[n-2][0]);
		ans=max(ans,dp[n-1][1]);
		cout << ans << "\n";
	}
	else{
		for (int i=0;i<n;i++){
			dp[i][0]=a[i];
			if (i==2) dp[i][1]=a[i];
			if (i==3) dp[i][3]=a[i];
			if (i-2>=0) dp[i][0]+=dp[i-2][0]; // tipe 0
			if (i-3>=0){ // tipe 1
				dp[i][1]=a[i];
				dp[i][1]+=max(dp[i-3][0],dp[i-2][1]);
			}
			if (i-4>=0){ // tipe 3
				dp[i][3]=a[i];
				dp[i][3]+=max(dp[i-4][0],dp[i-2][3]);
			}
			if (i-5>=0){ // tipe 2
				dp[i][2]=a[i];
				dp[i][2]+=max(dp[i-3][1],dp[i-2][2]);
			}
		}
//		cout << dp[n-1][0] << " " << dp[n-2][0] << " " << dp[n-2][1] << " " << dp[n-1][2] << " " << dp[n-1][3] << "\n";
		long long ans=dp[n-1][0];
		ans=max(ans,dp[n-2][0]);
		ans=max(ans,dp[n-2][1]);
		ans=max(ans,dp[n-1][2]);
		ans=max(ans,dp[n-1][3]);
		ans=max(ans,dp[n-1][1]);
		cout << ans << "\n";
	}
}

Measured memory_bytes: 11448
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<set>
#include<cstring>
#include<climits>
#include<queue>
using namespace std;

static string s1, s2;

int main()
{
	while (cin >> s1 >> s2)
	{
		string s = s1 + s2;
		int x = atoi(s.c_str());
		int q = static_cast<int>(sqrt(x));
		 
		printf(q*q == x ? "Yes\n" : "No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
const ll N=1e5+9;
pair<ll,ll> p[N];
int main()
{
	ll n,m,a,b;
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>a>>b;
		p[i].first=a;
		p[i].second=b;
	}
	sort(p,p+n);
	ll sum=0;
	for(int i=0;i<n;i++)
	{
		sum+=p[i].second;
		if(sum>=m)
		{
			cout<<p[i].first<<endl;
			break;
		}
		
		
	}
	
	return 0;
	
}


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

#define all(x) (x).begin(), (x).end()
#define inf (sizeof(int) == 4 ? (int)1E9 : (int)1E18)

template<class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}

void _main() {
        string str; cin >> str;
        int ans = 0;
        for (int i = 0; i < (str.size() + 1) / 2; i++) {
                ans += str[i] != str[str.size() - i - 1];
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 3632
// Author: Mohammad Faisal
#include<iostream>
using namespace std;

int main()
{
  int n;
  cin >> n;
  double ans =0;
  for(int i=0;i<n;i++)
  {
    double x;
    cin >> x;
    ans +=(1/x);
  }
  
  ans = (1/ans);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;


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


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<bitset>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

int main(){
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    unsigned long a;
    bitset<32> aa = 0;
    vector<unsigned long> vb;
    rep(n){
        cin >> a;
        aa ^= bitset<32>(a);
        vb.push_back(a^(a-1));
    }
    sort(rall(vb));
    unique(all(vb));
    int i = 31, ans = 0;
    for(auto bb_n : vb){
        bitset<32> bb = bitset<32>(bb_n);
        // cout << aa << endl;
        while(i >= 0 && !aa.test(i)) i--;
        if(i == -1) break;
        if(aa.test(i) && bb.test(i) && !bb.test(i+1)){
            aa ^= bb;
            ans++;
        }
    }
    if(aa.any()) ans = -1;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define mod 1000000007

int fact[1000005];

void pre()
{
    fact[0]=1;
    fact[1]=1;
    for(int i=2;i<=1000000;i++)
    {
        fact[i]=(fact[i-1]*i)%mod;
    }
}
int power(int a,int b)
{
    if(b==0)
    return 1;
    if(b==1)
    return a;
    int ans=power(a,b/2);
    if(b%2==0)
    return (ans*ans)%mod;
    else
    return (((ans*ans)%mod)*a)%mod;
}
void solve()
{
 int n;cin>>n;
 if(n<=1)
    cout<<0<<endl;
 else if(n==2)
    cout<<2<<endl;
 else
 {
     int ans=(power(10,n)%mod -(power(9,n)*2)%mod  + power(8,n)%mod + mod)%mod;
     cout<<ans%mod<<endl;
 }
}

int32_t main() 
{
    rapido;
    pre();
    int t;
    // cin>>t;
     t=1;
    while(t--)
    solve();
    return 0;
}




Measured memory_bytes: 11448
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  P(min(a, b) + min(c, d));

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;

int power(int x, int y) 
{ 
    int res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = x*x;  // Change x to x^2 
    } 
    return res; 
}

signed main()
{
    fast;
    int h;
    cin>>h;
    int c = 0;
    while( h > 0 )
    {
        c++;
        h /= 2;
    }

    cout<<power(2,c)-1<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//素数判定
//#include <cmath>
bool is_prime(long long n) {
	if (n == 1) return false;
	if (n == 2) return true;
	if (n % 2 == 0) return false;
	ll m = sqrt(n);
	for (long long i = 3; i <= m; i += 2) {
		if (n % i == 0) return false;
	}
	return true;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;

	unordered_map<ll, ll> mp;
	if (n % 2 == 0) {
		ll cnt = 0;
		while (n % 2 == 0) {
			n /= 2;
			cnt++;
		}
		mp[2] += cnt;
	}
	for (ll i = 3; i <= n; i += 2) {
		if (i % (ll)1e6 == 1) {
			if (is_prime(n)) {
				mp[n]++;
				break;
			}
		}
		if (n % i) continue;
		ll cnt = 0;
		while (n % i == 0) {
			n /= i;
			cnt++;
		}
		mp[i] += cnt;
	}

	ll ans = 0;
	for (auto i : mp) {
		ll x = i.second, y = 1;
		while (x >= y) {
			ans++;
			x -= y;
			y++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3664