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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define PI (acos(-1))
#define EPS (1e-7)

#define INF (1LL<<50)

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


void func(long long K, long long N, std::vector<long long> A){
    ll length = 0;
    length = max(length,K-abs(A[0]-A[N-1]));

    for(ll i=1;i<N;i++){
        length = max(length,abs(A[i]-A[i-1]));
    }
    cout<<K-length<<endl;
}

int main(){
    // cout << fixed << setprecision(5);

    long long K;
    scanf("%lld",&K);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    func(K, N, std::move(A));
    return 0;
}


Measured memory_bytes: 1920
L = input()
MOD = 10**9+7

num_ab = [1]
for i in range(1, len(L)+1):
    num_ab.append((num_ab[-1] * 3) % MOD)

ans, m = 0, 1
while True:
    if '0' not in L:
        ans = (ans + (m * num_ab[len(L)]) % MOD) % MOD
        print(ans)
        exit()
    elif '1' not in L[1:]:
        ans = (ans + ((m * num_ab[len(L) - 1]) % MOD + (2 * m) % MOD) % MOD) % MOD
        print(ans)
        exit()
    else:
        ans = (ans + (m * num_ab[len(L) - 1]) % MOD) % MOD
        L = L[L[1:].index('1') + 1:]
        m = (2 * m) % MOD

Measured memory_bytes: 7160
#include <iostream>

using namespace std;

int main() 
{
   int a, b, c;
   cin>>a>>b>>c;
   if(a<=c&&c<=b)
       cout<<a<<" "<<c<<" "<<b<<endl;
    else if(a>=b&&b>=c)
       cout<<c<<" "<<b<<" "<<a<<endl;
    else if(b<=c&&c<=a)  
       cout<<b<<" "<<c<<" "<<a<<endl;
   else if(c>=b&&b>=a)
       cout<<a<<" "<<b<<" "<<c<<endl;
    else if(b<=a&&a<=c)
       cout<<b<<" "<<a<<" "<<c<<endl;
    else
       cout<<c<<" "<<a<<" "<<b<<endl;
}


Measured memory_bytes: 3096
Imports System.Console
Imports System.Environment
Module Module1
    Sub Main()
        Dim X As Integer = ReadLine()
        Dim a As Integer = X
        Dim K As Integer
        Do Until a = 0
            K += 1
            a += X
            a = a Mod 360
        Loop
        WriteLine(K + 1)
    End Sub

End Module

Measured memory_bytes: 28356
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	string s;
	for (; getline(cin, s); )
	{
		stringstream ss;
		ss << s;

		vector<int> l(10);
		int v0, v1;

		for (int i = 0; i < 10; i++)
		{
			ss >> l.at(i);
			ss.ignore();

			l.at(i) *= 1000;
		}

		int d0 = 0;
		int d1 = accumulate(l.begin(), l.end(), 0);

		ss >> v0;
		ss.ignore();

		ss >> v1;

		for (; d0 < d1;)
		{
			d0 += v0;
			d1 -= v1;
		}

		int ll = 0;
		int x = 0;
		for (int i = 0; i < 10; i++)
		{
			ll += l.at(i);
			if (ll >= d0)
			{
				x = i + 1;
				break;
			}
		}

		cout << x << endl;
	}
}


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

const int MAX_V = 50;
const int MAX_S = MAX_V * 50 + 5;
const ll INF = 1e18;

struct Edge {
    int to, a, b;
    Edge(int to, int a, int b)
        : to(to)
        , a(a)
        , b(b)
    {
    }
};

struct Data {
    int v, s;
    ll x;
    Data(int v, int s, ll x)
        : v(v)
        , s(s)
        , x(x)
    {
    }
    bool operator<(const Data& a) const
    {
        return x > a.x;
    }
};

vector<Edge> g[MAX_V];
ll dist[MAX_V][MAX_S + 5];

int main()
{
    int n, m, s;
    cin >> n >> m >> s;
    rep(i, m)
    {
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        --u;
        --v;
        g[u].emplace_back(v, a, b);
        g[v].emplace_back(u, a, b);
    }
    rep(i, n) rep(j, MAX_S + 5) dist[i][j] = INF;
    s = min(s, MAX_S);
    priority_queue<Data> q;
    auto push = [&](int v, int s, ll x) {
        if (s < 0)
            return;
        if (dist[v][s] <= x)
            return;
        dist[v][s] = x;
        q.emplace(v, s, x);
    };
    vector<int> c(n), d(n);
    rep(i, n) cin >> c[i] >> d[i];
    push(0, s, 0);
    while (!q.empty()) {
        Data hoge = q.top();
        q.pop();
        int v = hoge.v, s = hoge.s;
        ll x = hoge.x;
        if (dist[v][s] != x)
            continue;
        int ns = min(s + c[v], MAX_S);
        push(v, ns, x + d[v]);
        for (Edge e : g[v]) {
            push(e.to, s - e.a, x + e.b);
        }
    }
    for (int i = 1; i < n; ++i) {
        ll ans = INF;
        rep(j, MAX_S + 5)
        {
            ans = min(ans, dist[i][j]);
        }
        cout << ans << endl;
    }
    return 0;
}


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

typedef long long ll;

const int N = 1e3 + 5;
const int mod = 1e9 + 7;
int n;
int a[N];
ll cnt[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    ll ans = 1;
    for (int i = 2; i <= n; ++i) {
        int temp = i;
        for (int j = 2; j <= n; ++j) {
            while (temp % j == 0) {
                temp /= j;
                ++cnt[j];
            }
            if (temp == 1)
                break;
        }
    }
    for (int i = 2; i < N; ++i) {
        ans = ans * (cnt[i] + 1) % mod;
    }
    cout << ans << endl;


    return 0;
}



Measured memory_bytes: 3648
import java.util.*;

class Main {
    public static void main (String [] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        int x = a * b;
        int y = ( a + b ) * 2;

        System.out.println( x + " " + y );
    }
}

Measured memory_bytes: 12000
import sys
import numpy as np


def solve(inp):
    def bit_length(x):
        ret = 0
        while x:
            x >>= 1
            ret += 1
        return ret

    n = 300001
    ide_ele = 0
    num = 1 << bit_length(n)
    seg = [ide_ele] * 2 * num

    def segfunc(x, y):
        return max(x, y)

    def init(init_arr):
        for i in range(n):
            seg[i + num - 1] = init_arr[i]
        for i in range(num - 2, -1, -1):
            seg[i] = segfunc(seg[2 * i + 1], seg[2 * i + 2])


    def update(k, x):
        k += num - 1
        seg[k] = x
        while k:
            k = (k - 1) // 2
            seg[k] = segfunc(seg[k * 2 + 1], seg[k * 2 + 2])


    def query(p, q):
        if q <= p:
            return ide_ele
        p += num - 1
        q += num - 2
        res = ide_ele
        while q - p > 1:
            if p & 1 == 0:
                res = segfunc(res, seg[p])
            if q & 1 == 1:
                res = segfunc(res, seg[q])
                q -= 1
            p = p // 2
            q = (q - 1) // 2
        if p == q:
            res = segfunc(res, seg[p])
        else:
            res = segfunc(segfunc(res, seg[p]), seg[q])
        return res


    N = inp[0]
    d = inp[1]
    A = inp[2:]
    arr = np.zeros(n, dtype=np.int64)
    init(arr)

    for a in A:
        l = max(0, a - d)
        r = min(a + d + 1, n)
        v = query(l, r)
        update(a, v + 1)
    return query(0, n)


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8[:],)')(solve)
    cc.compile()
    exit()

from my_module import solve

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
ans = solve(inp)
print(ans)


Measured memory_bytes: 40976
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int s[4][4005],a[4005];
int n,i,j,k;
ll ans;
string t;
int main()
{
	cin>>n>>t;
	for(int i=1;i<=n;i++)
	{
		if(t[i-1]=='R')a[i]=0;
		if(t[i-1]=='G')a[i]=1;
		if(t[i-1]=='B')a[i]=2;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<3;j++)s[j][i]=s[j][i-1];
		s[a[i]][i]=s[a[i]][i-1]+1; 
	}
	for(i=1;i<=n;i++)
	  for(j=i+1;j<=n;j++)
	  {
	  	  if(a[i]==a[j])continue;
	  	  ans+=s[3-a[i]-a[j]][n]-s[3-a[i]-a[j]][j];
	  	  if(2*j-i<=n&&a[2*j-i]==3-a[i]-a[j])ans--;
	  }
	  cout<<ans;
    return 0;
}

Measured memory_bytes: 3652
#include<stdio.h>
#include<math.h>

int main(void){
	int A,B,C1,C2,D1,D2,E1,E2,i,j,ans;
	double F1,F2;
	scanf("%d%d",&A,&B);
	C1=A*100/8;
	F1=A*100.0/8.0;
	C2=(A+1)*100/8;
	F2=(A+1.0)*100.0/8.0;
	D1=B*100/10;
	D2=(B+1)*100/10;
	if(fmod(F1,1)!=0)C1++;
	if(fmod(F2,1)!=0)C2++;
	if(C1<D1){
		E1=C1;
		E2=C2;
		C1=D1;
		C2=D2;
		D1=E1;
		D2=E2;
	}
	for(i=D1;i<D2;i++){
		for(j=C1;j<C2;j++){
			if(i==j){
				ans=i;
				j=C2;
				i=D2;
			}
		}
	}
	if(i==D2){
		ans=-1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    int ac = 0, wa = 0, tle = 0, re = 0, n = 0;

    scanf("%d", &n);

    for (int i = 0; i < n; i++)
    {
        char temp[10] = {
            0,
        };

        scanf("%s", temp);

        if (temp[0] == 'A')
            ac++;
        else if (temp[0] == 'W')
            wa++;
        else if (temp[0] == 'T')
            tle++;
        else
            re++;
    }

    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", ac, wa, tle, re);
    return 0;
}

Measured memory_bytes: 1732
import sys
from math import floor

if __name__ == "__main__":
	N, K = map(int,input().split())

	if K == 1 or (N % K) == 0:
		print(0)
		sys.exit()
	elif N > K:
		N = N % K

	for _ in range(K):
		if abs(N - K) < N:
			N = abs(N - K)
		else:
			print(N)
			break

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using node = tuple<int, int, int>;
const int inf = numeric_limits<int>::max()/3;
const ll mod = 1e9+7;

int main(void){
  int n,k;
  map<int,int> m;
  cin >> n >> k;
  for(int i = 0;i < n;++i){
    int a; cin >> a;
    ++m[a];
  }
  priority_queue<int,vector<int>,greater<int>> que;
  for(auto p : m){
    que.push(p.second);
  }
  int res = 0;
  int size = (int)m.size();
  for(int i = size;i > k;--i){
    res += que.top();
    que.pop();
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 10748
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String s = br.readLine();
    StringBuilder sb = new StringBuilder(s);
    int q = Integer.parseInt(br.readLine());
    int reverse = 0;
    for (int i = 0; i < q; i++) {
      String[] query = br.readLine().split(" ");
      if ("1".equals(query[0])) {
        reverse = (reverse + 1) % 2;
      } else {
        if (("1".equals(query[1]) && reverse == 0) || ("2".equals(query[1]) && reverse == 1)) {
          sb.insert(0, query[2]);
        } else {
          sb.append(query[2]);
        }
      }
    }
    br.close();
    System.out.println( reverse == 0 ? sb.toString() : sb.reverse().toString());
  }
}

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

using namespace std;

string solve(vector<int> a) {
    int tmp = 0;
    sort(a.begin(), a.end());
    for (auto& ai : a) {
        if (tmp == ai)
            return "NO";
        else
            tmp = ai;
    }
    return "YES";
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; ++i)
        cin >> a.at(i);

    cout << solve(a);
}


Measured memory_bytes: 1792
// In The Name Of God
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define for2(a,b,c) for(int a = b; a < c; a++)
#define setp cout << fixed << setprecision(7)
#define endl "\n"
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define error(x) cerr << #x << " = " << (x) << endl;

const ll inf = ~0ull/4;
const int maxn = 210000;

/////////////////////////////////////////////////////////////////////

Vec adj[maxn];
string ans[2] = {"IMPOSSIBLE","POSSIBLE"};

int32_t main()
{
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int n,m; cin >> n >> m;
	for2(i,0,m){
		int a,b; cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	bool ok = 0;
	for2(i,2,n){
		bool f,l;
		f = l = 0;
		for(auto x : adj[i]){
			if(x == 1) f = 1;
			if(x == n) l = 1;
		}
		if(f and l ) ok = 1;
	}
	cout << ans[ok] << endl;
	return 0;
}

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

int main (void){
  string s;
  cin >> s;
  if(s[0] != s[1] && s[1] != s[2] && s[2] != s[0]){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <stdint.h>
using namespace std;

template <class T>
T gcd(const T &a, const T &b)
{
  if (b == 0) return a;
  return gcd(b, a % b);
}

template <class T>
T lcm(const T &a, const T &b)
{
  T g = gcd(a, b);
  return a / g * b;
}

int main()
{
  for (int64_t a, b; cin >> a >> b; ) {
    cout << gcd(a, b) << " " << lcm(a, b) << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll n,m;
vector<int> G[100001];
int color[100001];
ll cnt=0;
bool f;

bool dfs(int v,int c){
	color[v]=c;
	cnt++;
	for(int i=0;i<G[v].size();i++){
		if(color[G[v][i]]==c)f=false;
		if(color[G[v][i]]==0 && !dfs(G[v][i],-c))f=false;
	}
	return f;
}

int main(void){
	scanf("%lld%lld",&n,&m);
	for(int i=0;i<m;i++){
		int f,t;
		scanf("%d%d",&f,&t);
		f--;
		t--;
		G[f].push_back(t);
		G[t].push_back(f);
	}
	memset(color,0,sizeof(color));
	ll res=0,one=0,two=0,other=0;
	for(int i=0;i<n;i++){
		if(color[i]==0){
			cnt=0;
			f=true;
			dfs(i,1);
			if(cnt==1)one++;
			if(f && cnt>1)two++;
			if(!f && cnt>1)other++;
		}
	}
	res=(one*one)+(2LL*one*(n-one));
	res+=(2LL*two*two)+(2LL*two*other)+other*other;
	printf("%lld\n",res);
	return 0;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int64_t,int64_t> pll;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
const long double PI = acos(-1);
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

double dp[3000]={1};

void solve() 
{
    int n;cin>>n;
    double p;
    REP(i,n){
        cin>>p;
        for(int j=i+1;j>0;j--)
            dp[j] += (dp[j-1] - dp[j])*p;
        //REP(j,i+2)cout<<dp[j]<<" ";cout<<endl;
    }
    cout<<fixed<<setprecision(10)<<dp[(n+1)/2]<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>

const int MOD = (int)1e9 + 7;
const int kN = 70 + 1;
const int kM = 10000;
int n, k;
char s[kN];
int Inv[kM], F[kM], Finv[kM];

int binom(int a, int b)
{
    if (b < 0 || b > a) return 0;
    return F[a] * 1LL * Finv[b] % MOD * Finv[a - b] % MOD;
}

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

std::vector<int> vec; // 每段B的数量

int getBound(const std::vector<int> &vec)
{
    std::vector<int> used(k);
    int j = 0, pa = 0;
    for (int i = 0; i < k; ++ i) {
        if (s[i] == 'r') {
            if (pa < vec.size())
                used[i] = -1, ++ pa;
        } else if (j < pa) {
            used[i] = 1;
            ++ j;
        }
    }
    if (j != vec.size()) return -1;
    int left[2] = {};
    j = 0;
    for (int i = k - 1; i >= 0; -- i) {
        if (used[i] == 0) {
            left[s[i] == 'b'] ++;
        } else if (used[i] > 0) {
            int c = vec[j ++] - 1;
            for (int w = 1; w >= 0; -- w) {
                int tmp = std::min(left[w], c);
                c -= tmp;
                left[w] -= tmp;
            }
            if (c > 0) return -1;
        }
    }
    return left[0];
}

int calc(const std::vector<int> &vec)
{
    int bound_a = getBound(vec);
    if (bound_a < 0) return 0;
    int ret = 0;
    for (int a = 0; a <= bound_a; ++ a) {
        int segc = vec.size() + a;
        if (segc == 0) {
            add(ret, 1); continue;
        }
        int pre = ret;
        int len = a;
        int hole = 1 + a * 2;
        int ops = a;
        for (int x : vec) len += x * 2 - 1, hole += x * 2 + 1 + 1, ops += x + 1;
        if (ops > k || segc - 1 + len > n) break;
        int coef = F[segc] * 1LL * Finv[a] % MOD;
        for (int i = 0, j = 0; i < vec.size(); i = j ++) {
            while (j < vec.size() && vec[j] == vec[i]) ++ j;
            coef = coef * 1LL * Finv[j - i] % MOD;
        }
        add(ret, binom(n - len - segc + 1 + hole - 1, hole - 1) * 1LL * coef % MOD);
    }
    return ret;
}

int search(int at, int segc, int len, int ops)
{
    int ret = calc(vec);
    if (ret == 0) return 0;
    for (int i = at; ; ++ i) {
        if (k < ops + i + 1 || n < segc + len + i * 2 - 1) break;
        int h = vec.size();
        for (int j = 1; ; ++ j) {
            if (k < ops + (i + 1) * j || n < segc + j - 1 + len + (i * 2 - 1) * j) break;
            vec.emplace_back(i);
            add(ret, search(i + 1, segc + j, len + (i * 2 - 1) * j, ops + (i + 1) * j));
        }
        vec.resize(h);
    }
    return ret;
}

int main()
{
    Inv[1] = 1;
    for (int i = 2; i < kM; ++ i)
        Inv[i] = (MOD - MOD / i) * 1LL * Inv[MOD % i] % MOD;
    F[0] = Finv[0] = 1;
    for (int i = 1; i < kM; ++ i) {
        F[i] = F[i - 1] * 1LL * i % MOD;
        Finv[i] = Finv[i - 1] * 1LL * Inv[i] % MOD;
    }
    scanf("%d%d%s", &n, &k, s);
    printf("%d\n", search(1, 0, 0, 0));
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<=(ll)n;i++)
#define rep(i,x,y) for(ll i=(ll)x;i<=(ll)y;i++)
#define reprev(i,n) for(ll i=(ll)n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

const int mod = 1e9+7;
const long double pi = acos(-1);

ll power(ll x, ll y){
	x %= mod;
	ll ans = 1;
	while(y){
		if(y&1) ans = (ans*x)%mod;
		y /= 2;
		x = (x*x)%mod;
	}
	return ans;
}

void solve(){

	ll n,k;
	cin >> n >> k;
	ll ans = 0;
	vector <int> a(k+1,0);
	rep1(i,k) a[i] = i;
	rep1(i,k){
		for(int j=1;j*j<=i;j++){
			if(i%j==0){
				if(j!=i) a[i] -= a[j];
				if(j!=i/j && i/j!=i) a[i] -= a[i/j];
			}
		}
	}
	rep1(i,k){
		ll tmp = power((k/i),n);
		tmp = (a[i]*tmp)%mod;
		ans = (ans+tmp)%mod;
	}
	cout << ans;

	return;
}

int main(){

	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 3856
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a,b,i,k;
	cin>>a>>b>>k;
	if(b-a+1<=k)
	{
		for(int i=a;i<=b;i++)
			cout<<i<<endl;
		return 0;
	}
	if(a+k-1>=b-k+1)
	{
		for(int i=a;i<=b;i++)
			cout<<i<<endl;
		return 0;
	}
	for(int i=a;i<=a+k-1;i++)
		cout<<i<<endl;
	for(int i=b-k+1;i<=b;i++)	
		cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 int a[] ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
  int b;
 cin>>b;
 cout<<a[b-1]<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

const int MAX_N = 110;
const ll INF = 1e12;

vector<pair<ll, ll> > g[MAX_N]; // firstに最短距離, secondに頂点番号
ll d[MAX_N];
int n; // 頂点数

bool used[MAX_N][MAX_N];

int pr[MAX_N]; // 最短路の直前の頂点

// bellman ford法で負辺がない場合。計算量はO(|E|log|V|)
void dijkstra(int s){
  priority_queue<pair<ll, ll>, vector<pair<ll, ll> >, greater<pair<ll, ll> > > PQ;
  for(int i=1;i<=n;i++) d[i] = INF;
  for(int i=1;i<=n;i++) pr[i] = -1;
  d[s] = 0;
  PQ.push(make_pair(0, s));

  while(!PQ.empty()){
    pair<ll, ll> p = PQ.top(); PQ.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(auto gvi: g[v]){
      ll cost = gvi.first;
      int u = gvi.second;
      if(d[u] > d[v] + cost){
        d[u] = d[v] + cost;
        PQ.push(make_pair(d[u], u));
        pr[u] = v;
      }
    }
  }
}

// 頂点tへの最短路
void get_path(int t){
  while(1){
    if(pr[t] == -1) break;
    used[t][pr[t]] = true;
    used[pr[t]][t] = true;
    t = pr[t];
  }
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int m; cin >> n >> m;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
      used[i][j] = true;
    }
  }
  for(int i=0;i<m;i++){
    int a, b;
    ll c; cin >> a >> b >> c;
    g[a].push_back(make_pair(c, b));
    g[b].push_back(make_pair(c, a));
    used[a][b] = false;
    used[b][a] = false;
  }
  for(int i=1;i<=n;i++){
    dijkstra(i);
    for(int j=i+1;j<=n;j++){
      // cout << i << " " << j << " " << d[j] << endl;
      get_path(j);
    }
  }
  int cnt = 0;
  for(int i=1;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      if(used[i][j] == false) cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */
/* main */
int main(){

    int n, m;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++) cin >> A[i];
    cin >> m;
    vector<int> B(m);
    for (int i = 0; i < m; i++) cin >> B[i];

    cout << lexicographical_compare(A.begin(), A.end(), B.begin(), B.end()) << '\n';
}



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


int main() {
  int K;
  string S,T,U;
  ll ans=0, anst=0, ansu=0;
  cin >> S >> K;
  T = U = S;
  for(int i=1; i<S.size(); i++){
    if(S.at(i)==S.at(i-1)){ans++; S.at(i) = '#';}
  }

  if(T.at(0)==S.at(S.size()-1)){anst++; T.at(0) = '#';}
  for(int i=1; i<T.size(); i++){
    if(T.at(i)==T.at(i-1)){anst++; T.at(i) = '#';}
  }
  
  if(U.at(0)==T.at(T.size()-1)){ansu++; U.at(0) = '#';}
  for(int i=1; i<U.size(); i++){
    if(U.at(i)==U.at(i-1)){ansu++; U.at(i) = '#';}
  }
  
  
  if(anst==ansu){
    cout << ans+anst*(K-1) << endl; return 0;
  } else {
    K--;
    cout << ans+anst*(K-K/2)+ansu*(K/2) << endl; return 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define maxn 400005
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int L,n;
int x[maxn];
ll suml[maxn],sumr[maxn];
ll calc_l(int l,int r){
	if(r >= l + 1) return (sumr[r] - sumr[r - l - 1]) + suml[l];
	return sumr[r] + (suml[l] - suml[l - r]);
}
ll calc_r(int l,int r){
	if(l >= r + 1) return (suml[l] - suml[l - r - 1]) + sumr[r];
	return suml[l] + (sumr[r] - sumr[r - l]);
}
int main(){
	scanf("%d%d",&L,&n);
	for(int i=1;i<=n;i++) scanf("%d",&x[i]);
	for(int i=1;i<=n;i++) sumr[i] = sumr[i - 1] + x[i];
	for(int i=1;i<=n;i++) suml[i] = suml[i - 1] + (L - x[n + 1 - i]);
	ll ans = 0;
	for(int i=n;i>=1;i--){
		ans = max(ans,calc_l(i - 1,n - i) * 2 + (L - x[n + 1 - i]));
	}
	for(int i=1;i<=n;i++){
		ans = max(ans,calc_r(n - i,i - 1) * 2 + x[i]);
	}
	printf("%lld\n",ans);
	return 0;
}


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

class UnionFind {
public:
    int n;
    vector<int> par, rank, sz;

    UnionFind(int n) : n(n), par(n), rank(n), sz(n) {
        for (int i=0; i<n; ++i) {
            par[i] = i;
            rank[i] = 0;
            sz[i] = 1;
        }
    }

    int find(int x) {
        if (par[x] == x) {
            return x;
        }
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x != y) {
            if (rank[x] > rank[y]) swap(x, y);
            par[x] = y;
            sz[y] += sz[x];
            if (rank[x] == rank[y]) ++rank[y];
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return sz[find(x)];
    }
};

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

    int N, M;
    cin >> N >> M;

    vector<int> A(M), B(M);
    for (int i=0; i<M; ++i) {
        cin >> A[i] >> B[i];
        A[i] --;
        B[i] --;
    }
    
    UnionFind uf(N);
    long long pa = 0;

    vector<long long> ans(M);
    ans[M-1] = (long long)N * (N-1) / 2;

    for (int i=M-1; i>0; --i) {
        pa += ( ! uf.same(A[i], B[i])) ? (long long)uf.size(A[i]) * uf.size(B[i]) : 0;
        uf.unite(A[i], B[i]);
        ans[i-1] = ans[M-1] - pa;
    }

    for (int i=0; i<M; ++i) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int a, b, c;
    int num[10] = {0};

    cin >> a >> b >> c;
    num[a]++; num[b]++; num[c]++;

    if (num[5] == 2 && num[7] == 1) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<int,int>;
typedef unsigned long long ull;
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 ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  cin >> n;
  vector<int>c(n-1);
  vector<int>s(n-1);
  vector<int>f(n-1);
  
  rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
  rep(i,n-1){
    int t=s[i]+c[i];
    for(int j=i+1;j<n-1;j++){
      int k=max(0,(t-s[j]+f[j]-1)/f[j]);
      t=s[j]+k*f[j]+c[j];
    }
    cout << t << endl;
  }
  cout << 0 << endl;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
#include<chrono>
using namespace std;
using namespace std::chrono;
//using namespace __gnu_pbds;
#define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fi         first
#define se         second
#define int         long long
#define pb         push_back
#define emp        emplace_back
#define vv(x)      vector<x>
#define mp(x,y)    map<x,y>
#define dq(x)      deque<x>
#define pql(x)     priority_queue<x>
#define pqs(x)     priority_queue<x,vv(x),greater<x> >
#define mod         1000000007
#define forf(i,a,b) for(int i=a;i<b;i++)
#define it(x)      x::iterator
#define ll         long long
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
#define vii        vector<int>
#define big        3e18
#define sm         -2e9
#define mkr        make_pair
#define vpi        vector<pair<int,int> >
#define pii        pair<int,int>
#define rng        500005
#define sz(x)      (int)x.size()
#define rv(x)      reverse(x.begin(),x.end())
#define out(x)     cout<<x.fi<<" "<<x.se<<endl;
 
//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
 
void pr_init()
{
 
#ifndef ONLINE_JUDGE
  freopen("gin.txt", "r", stdin);
  freopen("gout.txt", "w", stdout);
 
#endif
}
int Mxn = 2e6;

int rs(int m,int k)
{
    int an = 1,a=10;
    while(m>0)
    {
        if(m%2!=0) an = ((an%k) * a%k)%k;
        m/=2;
        a = ((a%k) * a%k)%k;
    }
    return an;
}
void solve()
{
  int k,an=-1;
  cin >> k;
  
  k/=__gcd(k,(int)7);
  forf(i,1,Mxn)
  {
   
    if(rs(i,9*k)==1)
    {
        an = i;
        break;
    }
  }

  cout<<an;
}
 
 
int32_t main()
{
  pr_init();
  fastio;
 
  auto start = high_resolution_clock::now();
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start);
  // cout << "Time taken by function: "
  //       << duration.count() << " microseconds" << endl;
 
}
 


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
char c;
cin>>c;
set<char> vowel={'a','i','u','e','o'};

string ans;
if(vowel.count(c)==1) ans ="vowel";
else ans = "consonant";
cout<<ans<<endl;
//system("pause");
return 0;
}

Measured memory_bytes: 256
/*
lakshaygpt28
Lakshay Gupta
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
using vll = vector < ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;


#ifndef ONLINE_JUDGE
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif

#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

int n, K;
int dp[N][2], a[105];
bool solve(int k, bool turn);

int main() {
    fast_io();
    cin >> n >> K;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << (solve(0, 0) ? "First\n" : "Second\n");
    return 0;
}

bool solve(int k,bool turn) {
    auto& ans = dp[k][turn];
    if (ans != -1) {
        return ans;
    }
    ans = 0;
    if (k == K) {
        ans = 0;
        // debug(k, turn, ans);
        return ans;
    }
    for (int i = 0; i < n; i++) {
        if (k + a[i] <= K) {
            ans |= (solve(k + a[i], turn ^ 1) ^ 1);
        }
    }
    // debug(k, turn, ans);
    return ans;
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int X = N * A;
  
  if (X > B) {
    cout << B << endl;
  }
  else if (X <= B){
    cout << X << endl;
  }
  
     
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if((a+b)%2==0){
    cout << (max(a,b)-min(a,b))/2+min(a,b) << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char s[4];
    int i;
    int j;
    int judge[4];

    for(i = 0; i < 4; i++){
        judge[i] = 0;
    }

    scanf("%s", s);

    for(i = 0; i < 4; i++){
        for(j = 0; j < 4; j++){
            if(s[i] == s[j]){
                judge[i]++;
            }
        }
    }

    for(i = 0; i < 4; i++){
        if(judge[i] != 2){
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int a,b,c;
           cin>>a>>b>>c;
           cout<<(a+b)*c/2<<endl;
}

Measured memory_bytes: 3544
import bisect
N = int(input())
A = sorted(list(map(int,input().split())))
B = list(map(int,input().split()))
C = sorted(list(map(int,input().split())))
ans = 0
for i in range(N):
  ans += bisect.bisect_left(A,B[i]) * (N - bisect.bisect_right(C,B[i]))
print(ans)

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

int main() {
  int n, m;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  cin >> m;
  vector<string> t(m);
  rep(i, m) cin >> t[i];

  int max_score = 0;
  for (int i = 0; i < n; i++) {
    int score = 1;
    for (int j = i + 1; j < n; j++) {
      if (s[i] == s[j]) 
        score++;
    }
    for (int j = 0; j < m; j++) {
      if (s[i] == t[j]) 
        score--;
    }
    max_score = max(max_score, score);
  }

  cout << max_score << endl;
  
  return 0;
}


Measured memory_bytes: 256
N,M = [int(i) for i in input().split()]
PY = []
for m in range(M):
    PY.append([int(i) for i in input().split()])
    PY[-1].append(m)
PY.sort(key=lambda x:(x[0],x[1]))
ans = []
pre = 0
cnt = 0
for py in PY:
    if pre == py[0]:
        cnt+=1
    else:
        cnt = 1
    ans.append([str(py[0]).zfill(6) + str(cnt).zfill(6),py[2]])
    pre = py[0]
ans.sort(key=lambda x:x[1])
for a in ans:
    print(a[0])

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

#define fast                     ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll                       long long 
#define mk                       make_pair
#define pb                       push_back
#define pob                      pop_back
#define pii                      pair<int,int>
#define vi                       vector<int>
#define vii                      vector<pii>
#define mi                       map<int,int>
#define mii                      map<pii,int>
#define all(a)                   (a).begin(),(a).end()
#define x                        first
#define y                        second
#define sz(x)                    (int)x.size()
#define endl                     '\n'
#define MOD                      1000000007
#define loop(i,a,b)              for(int (i)=(a);(i)<(b);(i)++)
#define rloop(i,a,b)             for(int (i)=(a);(i)>=(b);(i)--)
#define Unique(A)                (A).resize(distance((A).begin(),unique(all((A)))));
#define mxe(A)                   *max_element(all(A))
#define mne(A)                   *min_element(all(A))
#define debv(x)                  for(auto i : (x)) cout << i << ' ';cout << endl;
#define SP(x,y)                  cout << fixed << setprecision((y)) << (x) << endl;
#define setBits(x)               __builtin_popcountll(x)
#define zroBits(x)               __builtin_ctzll(x)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define Max(x,y,z)               max(x,max(y,z))
#define Min(x,y,z)               min(x,min(y,z))
#define clr(x)                   memset(x,0,sizeof(x)) // not sure work for 2D arrya or not

using namespace std;

const int N = 1e6+77;
int A[N] , n , k , dp[N];

int main(){
    cin >> n >> k;
    loop(i,0,n+1) dp[i] = 0x3f3f3f3f;
    loop(i,0,n) cin >> A[i];
    dp[0]=0;
    loop(i,0,n){
        loop(j,1,k+1){
            if(i+j<n) dp[i+j] = min(dp[i+j],dp[i]+abs(A[i]-A[i+j]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 4736
program main;
var x, y, a, b : longint;
    t : real;
    r : boolean;

begin
  readln(x,y);
  r := true;
  t := (y-2*x) / 2;
  if (frac(t) = 0) and (t >= 0) then
    b := trunc(t)
  else 
    r := false;
  a := x - b;
  if a < 0 then
    r := false;
  if r then
    writeln('Yes')
  else
    writeln('No');
end.

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	if(a > 9 or b > 9) cout << -1;
	else cout << a*b;
	cout << endl;
	return 0;
} 

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

public class Main {
    static final int[] R_OFFSETS = { -1, -1, 0, 1, 1, 1, 0, -1 };
    static final int[] C_OFFSETS = { 0, 1, 1, 1, 0, -1, -1, -1 };

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

        int H = sc.nextInt();
        int W = sc.nextInt();
        char[][] grid = new char[H][W];
        for (int r = 0; r < H; ++r) {
            String line = sc.next();
            for (int c = 0; c < W; ++c) {
                grid[r][c] = line.charAt(c);
            }
        }

        System.out.println(solve(grid));

        sc.close();
    }

    static String solve(char[][] grid) {
        int row = grid.length;
        int col = grid[0].length;

        for (int r = 0; r < row; ++r) {
            for (int c = 0; c < col; ++c) {
                if (grid[r][c] == '.') {
                    grid[r][c] = '0';

                    for (int i = 0; i < R_OFFSETS.length; ++i) {
                        int adjR = r + R_OFFSETS[i];
                        int adjC = c + C_OFFSETS[i];

                        if (adjR >= 0 && adjR < row && adjC >= 0 && adjC < col && grid[adjR][adjC] == '#') {
                            ++grid[r][c];
                        }
                    }
                }
            }
        }

        return Arrays.stream(grid).map(String::valueOf).collect(Collectors.joining("\n"));
    }
}

Measured memory_bytes: 30036
#include <bits/stdc++.h>
#define REP(i, x, y) for (ll i = x; i <= y; i++)
#define BIT(t) (1ll << t)
#define PER(i, y, x) for (ll i = y; i >= x; i--)
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pll pair<ll, ll>
#define SIZE(v) ll(v.size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
//        ios::sync_with_stdio(false);
//        cin.tie(nullptr);

int main(){
        ll n,m,x,y;
        cin >> n >> m >> x >> y;
        ll maxx = x;
        ll miny = y;
        REP(i,1,n){
                ll t;
                cin >> t;
                maxx = max(maxx, t);
        }
        REP(i,1,m){
                ll t;
                cin >> t;
                miny = min(miny, t);
        }
        if(maxx < miny){
                cout << "No War" << endl;
        }else{
                cout << "War" << endl;
        }

}

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

int main()
{
  ll n;
  cin>>n;
  vector<ll> v(n);
  for(int i=0;i<n;i++)
    cin>>v[i];
  ll sum=0;
  for(int i=0;i<n-1;i++)
    for(int j=i+1;j<n;j++)
      sum+=v[i]*v[j];
  cout<<sum<<"\n";
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
L=[]
R=[]
for i in range(m):
  l,r=map(int,input().split())
  L.append(l)
  R.append(r)
  
ans=min(R)-max(L)+1
if ans>=0:
  print(ans)
else:
  print(0)


Measured memory_bytes: 11000
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  
  if (A+B <= C*2) {
    //AとBを買ったほうが安い場合
    //cout << "A:";
    cout << A*X + B*Y << endl;
  }
  else {
    //Cを買ったほうが安い場合
    int total = 0;
    if (X>=Y) total = min(X,Y)*2*C + (X-Y)*A;
    else total = min(X,Y)*2*C + (Y-X)*B;
    //cout << "B:";
    cout << min(total,max(X,Y)*2*C) << endl;
  }
  return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> people(n);
    for (int i = 0; i < n; ++i) {
        cin >> people.at(i);
    }
    int ans = 0;
    for (int j : people) if (j >= k) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 640
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 5 2019
 * 
 */

#include <bits/stdc++.h>

#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    string s;

    cin>>s;

    int z=0 , o=0;

    for(int i=0; i<s.size(); ++i){
        z+=(s[i]=='1');
        o+=(s[i]=='0');
    }

    cout<<min(z, o)*2<<endl;



    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("cin","r",stdin);
    freopen("cout","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#define FUP(i,x,y) for(int i=(x);i<=(y);i++)
#define FDW(i,x,y) for(int i=(x);i>=(y);i--)
#define MAXN 100010
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define ll long long
#define db double
using namespace std;
int read(){
    int w=0,flg=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')flg=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){w=w*10-'0'+ch,ch=getchar();}
    return w*flg;
}
int sum;
char s[200010];
int main(){
	scanf("%s",s+1);
	int len=strlen(s+1);
	FUP(i,1,len) sum+=s[i]-'0';
	sum%9==0?puts("Yes"):puts("No");
    return 0;
}

Measured memory_bytes: 3836