akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
using namespace std;
typedef long long ll;

const int INF = 1001001001;

struct UnionFind {
    vector<int> parent;
    UnionFind (int n) : parent(n) {
        for(int i = 0; i < n; i++) parent[i] = i;
    }

    int root (int x) {
        if (parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

    void unite (int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        parent[rx] = ry;
    }

    bool same_root(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int n, m; cin >> n >> m;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }

    UnionFind tree(n);
    for (int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        x--; y--;
        tree.unite(x, y);
    }

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if(tree.same_root(i, p[i])) ans++;
    }
    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();

        long min = Long.MAX_VALUE;
        for (int i = 0; i < 5; i++) {
            min = Math.min (min, sc.nextLong());
        }
        // calculate how much travels need with smallest occupy(it's 1 move) + 4 moves more = 5 moves between 6 cities
        // 1 => 2 => 3 => 4 => 5 => 6  = 5 moves 
        System.out.println((long) Math.ceil(1.0 * n / min) + 4);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int n,a[1010],ans=0;
int main()
{
	cin>>n;
	n*=2;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i+=2)
		ans+=a[i];
	cout<<ans<<endl;
	return 0;
 }

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    set<ll> s;
    rep(i,3){
        ll a; cin>>a;
        s.insert(a);
    }
    cout<<s.size()<<endl;
    return 0;
}

Measured memory_bytes: 3572
from collections import deque

n = int(input())

List = deque()

for i in range(n):
  order = input()
  if order == "deleteFirst":
    List.popleft()
  elif order == "deleteLast":
    List.pop()
  else:
    order,x = order.split()
    if order == "insert":
      List.appendleft(x)
    else:
      try:
        List.remove(x)
      except ValueError:
        pass

print(" ".join(List))


Measured memory_bytes: 69732
// C++ program to illustrate Edge Coloring
#include <bits/stdc++.h>
using namespace std;

// function to determine the edge colors
void colorEdges(int ptr, vector<vector<pair<int, int> > >& gra,
                vector<int>& edgeColors, bool isVisited[])
{
    queue<int> q;
    int c = 0;

    set<int> colored;

    // return if isVisited[ptr] is true
    if (isVisited[ptr])
        return;

    // Mark the current node visited
    isVisited[ptr] = 1;

    // Traverse all edges of current vertex
    for (int i = 0; i < gra[ptr].size(); i++) {
        // if already colored, insert it into the set
        if (edgeColors[gra[ptr][i].second] != -1)
            colored.insert(edgeColors[gra[ptr][i].second]);
    }

    for (int i = 0; i < gra[ptr].size(); i++) {
        // if not visited, inset into the queue
        if (!isVisited[gra[ptr][i].first])
            q.push(gra[ptr][i].first);

        if (edgeColors[gra[ptr][i].second] == -1) {
            // if col vector -> negative
            while (colored.find(c) != colored.end())

                // increment the color
                c++;

            // copy it in the vector
            edgeColors[gra[ptr][i].second] = c;

            // then add it to the set
            colored.insert(c);
            c++;
        }
    }

    // while queue's not empty
    while (!q.empty()) {
        int temp = q.front();
        q.pop();

        colorEdges(temp, gra, edgeColors, isVisited);
    }

    return;
}

// Driver Function
int main()
{
    set<int> empty;

    // declaring vector of vector of pairs, to define Graph
    vector<vector<pair<int, int> > > gra;

    vector<int> edgeColors;

    bool isVisited[100000] = { 0 };

    // Enter the Number of Vertices
    // and the number of edges
    int ver;cin>>ver;
    int edge = ver-1;

    gra.resize(ver);
    edgeColors.resize(edge, -1);

    // Enter edge & vertices of edge
    // x--; y--;
    // Since graph is undirected, push both pairs
    // (x, y) and (y, x)
    // graph[x].push_back(make_pair(y, i));
    // graph[y].push_back(make_pair(x, i));
    for(int i=0;i<edge;i++)
    {
        int x,y;
        cin>>x>>y;
        x--;y--;
        gra[x].push_back(make_pair(y,i));
        gra[y].push_back(make_pair(x,i));
    }

    colorEdges(0, gra, edgeColors, isVisited);
    map<int,int>m;
    for(int i=0;i<edgeColors.size();i++)
    {
        m[edgeColors[i]]++;
    }
    cout<<m.size()<<endl;
    for (int i = 0; i < edge; i++)
             cout<< edgeColors[i] + 1 << "\n";

    return 0;
}


Measured memory_bytes: 60416
//************************************************************************//
//*Author : Handsome How                                                 *//
//************************************************************************//
//#pragma comment(linker, "/STA    CK:1024000000,1024000000")
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <ctime>
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define foreach(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define fur(i,a,b) for(int i=(a);i<=(b);i++)
#define furr(i,a,b) for(int i=(a);i>=(b);i--)
#define cl(a) memset((a),0,sizeof(a))
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#ifdef HandsomeHow
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define dbg(x) cerr << #x << " = " << x << endl
#else
#define debug(...)
#define dbg(x)
#endif
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
const int inf=0x3f3f3f3f;
const double eps=1e-8;
const int mod=1000000007;
const double pi=acos(-1.0);
inline void gn(long long&x){
    int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
    while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
ll gcd(ll a,ll b){return a? gcd(b%a,a):b;}
ll powmod(ll a,ll x,ll mod){ll t=1ll;while(x){if(x&1)t=t*a%mod;a=a*a%mod;x>>=1;}return t;}
// (づ°ω°)づe★
//-----------------------------------------------------------------
char s[15];
int main(){
#ifdef HandsomeHow
    //freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
    time_t beginttt = clock();
#endif
	s[0] = '0';
	cin>>s+1;
	ll ans = 0;
	int len = strlen(s);
	for(int i = 0; i < len-1; ++i){
		for(int j = i+1; j < len; ++j){
			ll tmp = 0;
			for(int k = i+1; k <= j; ++k) tmp = tmp * 10 + s[k]-'0'; 
			ll l = (1ll<<max(0,i-1)), r = 1ll<<max(0,len-2-j);
			ll v = l*r*tmp;
			ans+=v;
		}
	}
	cout<<ans<<endl;
#ifdef HandsomeHow
	time_t endttt = clock();
    debug("time: %d\n",(int)(endttt - beginttt));
#endif
	return 0;
}


Measured memory_bytes: 256
from fractions import gcd
from itertools import accumulate

# 入力
N = int(input())
A = list(map(int, input().split()))

# 先頭から連続する要素の最大公約数の列
L = list(accumulate(A, gcd))
# 末尾から連続する要素の最大公約数
R = list(accumulate(reversed(A), gcd))

# Aの各要素について、それを使用しない場合の最大公約数の最大値をL, Rを用いて求める
ans = max(
    L[-2],
    R[-2],
    max(
        (
            gcd(L[k], R[-(k + 3)])
            for k in range(N - 2)
        ),
        default=L[-1]
    )
)

# 出力
print(ans)


Measured memory_bytes: 16148
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main() {
  int a,b;
  cin >> a >> b;
  if((a * b) % 2) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

namespace ALDS1_2_D {
    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            List<int> A = new List<int>();
            for (int i = 0; i < n; i++) {
                A.Add(int.Parse(Console.ReadLine()));
            }

            ShellSort(A, n);

            StringBuilder sb = new StringBuilder();
            foreach (int a in A) {
                sb.AppendLine(a.ToString());
            }
            Console.Write(sb);
        }

        static void ShellSort(List<int> A, int n) {
            int cnt = 0;
            List<int> G = new List<int>();
            for (int h = 1; h <= n; h = 3 * h + 1) {
                G.Insert(0, h);
            }

            foreach (var g in G) {
                cnt += InsertionSort(A, n, g);
            }

            Console.WriteLine(G.Count);
            Console.WriteLine(ListToString(G));
            Console.WriteLine(cnt);
        }

        static int InsertionSort(List<int> A, int n, int g) {
            int cnt = 0;
            for (int i = g; i < n; i++) {
                int v = A[i];
                int j = i - g;
                while (j >= 0 && A[j] > v) {
                    A[j + g] = A[j];
                    j -= g;
                    cnt++;
                }
                A[j + g] = v;
            }
            return cnt;
        }

        static string ListToString(List<int> nums) {
            StringBuilder sb = new StringBuilder();
            foreach (int n in nums) {
                sb.Append(" " + n);
            }
            return sb.ToString().TrimStart();
        }
    }
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pll> vp;
typedef vector<ll> vll;

const int MAX_N = 16;
const int inf = 1e8;

int dp[1<<MAX_N];

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

    int N;
    while (cin >> N && N) {
        vector<vi> t(N, vi(N + 1));
        rep(i, N) rep(j, N + 1) cin >> t[i][j];

        rep(i, 1<<N) dp[i] = inf;
        dp[0] = 0;

        // bitDP
        // i: state(1 = visited stage)
        rep(i, 1<<N) {
            // if this state is not searched, then skip
            if (dp[i] == inf) continue;
            // j: nxt stage
            rep(j, N) {
                // if j has already been visited in state i, then skip
                if ((i>>j) & 1) continue;
                // search for minimum available t[j][?]
                int mint = t[j][0];
                rep(k, N) {
                    // if k is already visited in state i, then we can use item k
                    if ((i >> k) & 1) mint = min(mint, t[j][k + 1]);
                }
                dp[i | (1<<j)] = min(dp[i | (1<<j)], dp[i] + mint);
            }
        }

        cout << dp[(1<<N) - 1] << endl;
    }

}

Measured memory_bytes: 3384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <vector>
#include <queue>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <cstring>
#include <random>
#include <chrono>
#include <bitset>
#include <fstream>
#include <sstream>

using namespace std;

typedef long long ll;
typedef long double ld;

ll big = 1000000007ll;
float likeabutterfly;
string likeabee;
ll n,m,q,h,k,w;
ll T;

vector<ll> L;
vector<ll> R;


bool fail = 0;

pair<ll,ll> intersect(ll a1, ll b1 , ll a2, ll b2){
ll a = max(a1,a2);
ll b = min(b1,b2);
pair<ll,ll> ans;
ans.first = a;
ans.second = b;
return ans;
}

int main()
{
    ll c1,c2,c3,c4,c5,c6;
    ll a,b,d,e,g,c;
    ll x,y,z;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    cin >> n;

    ll prev = -1;

    for(c1 = 0; c1 < n; c1++){

    cin >> a;
    if(a > prev){
        L.push_back(a);
        R.push_back(a);
    }
    else{

        L.push_back(1);
        R.push_back(a);

    }

    prev = a;

    }

    vector<ll> B;

    for(c1 = 0; c1 < n; c1++){

        cin >> a;
        B.push_back(a);

    }
    prev = -1;
    for(c1 = n-1; c1 >= 0; c1--){

        a = B[c1];

        if(a > prev){

        pair<ll,ll> P = intersect(L[c1] , R[c1] , a , a);
        L[c1] = P.first;
        R[c1] = P.second;

    }
    else{

        pair<ll,ll> P = intersect(L[c1] , R[c1] , 1 , a);
        L[c1] = P.first;
        R[c1] = P.second;

    }

    prev = a;

    }


    ll ans = 1;

    for(c1 = 0; c1 < n; c1++){

        if(R[c1] < L[c1]){ans = 0;}
        else{

            ans *= R[c1]-L[c1]+1;
            ans %= big;

        }

    }

    cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3308
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

template <class T>
std::vector<T> enum_div(T n) {
    std::vector<T> ret;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

bool isPrime(ll num) {
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    for (ll i = 3; i * i <= num; i += 2) {
        if (num % i == 0) { return false; }
    }

    return true;
};

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
bool is_integer(T x) {
    return std::floor(x) == x;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    string S;
    cin >> S;

    int ans = 0;
    REP(i, N - 2) {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') { ans++; }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// Undone
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;
public class Program {
  public static void Main() {
    int N = cin();
    int ans = 0, max = 0;
    for (int i = 0; i < N; i++) {
      int H = cin();
      ans += (max <= H) ? 1 : 0;
      max = Math.Max(max, H);
    }
    Console.WriteLine(ans);
  }

  private static List<int> _var;
  public static int cin() { if (_var == null || _var.Count() == 0) { _var = Console.ReadLine().Split(' ').Select(int.Parse).ToList<int>(); } int ans = _var[0]; _var.RemoveAt(0); return ans; }
  public static void Swap<T>(ref T a, ref T b) {T temp = a;a = b;b = temp;}
  public static string ReadStr() { return Console.ReadLine(); }
  public static int ReadInt() { return int.Parse(Console.ReadLine()); }
  public static double ReadDouble() { return double.Parse(Console.ReadLine()); }
  public static long ReadLong() { return long.Parse(Console.ReadLine()); }
  public static char ReadChar() { return Console.ReadLine()[0]; }
  public static string[] ReadStringArray() { return Console.ReadLine().Split(' '); }
  public static int[] ReadIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
  public static double[] ReadDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
  public static long[] ReadLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
  public static char[] ReadCharArray() { return Console.ReadLine().ToArray(); }
  public static string[] ReadCharStringArray() { return Console.ReadLine().ToCharArray().Select(c => c.ToString()).ToArray(); }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,i,c;
    scanf("%d",&a);
    if(a==4||a==6||a==9||a==14||a==21||a==22||a==25||a==26)
    {
        printf("2\n");
    }
    else if(a==8||a==12||a==18||a==20||a==27)
    {
        printf("5\n");
    }
    else if(a==28||a==30)
    {
        printf("4\n");
    }
    else if(a==32)
    {
        printf("51\n");
    }
     else if(a==16)
    {
        printf("14\n");
    }
     else if(a==24)
    {
        printf("15\n");
    }
     else
    {
        printf("1\n");
    }

}


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

void solve(long long N, vector<long long> A){
	map<long long, long long> m;
	long long c = 0;
	for (int i = 0; i < N; i++)	{
		if (m[A[i]] > 0) {
			m[A[i]]--;
			c--;
		} else {
			m[A[i]]++;
			c++;
		}
	}
	cout << c << endl;
		
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}



Measured memory_bytes: 8064
n=int(input())
a=[0]+[int(x) for x in input().split()]
boal=[0]*(n+1)
m=0
ans=[]
for i in range(n,0,-1):
    k=1
    sum_boal=0
    while i*k<n+1:
        sum_boal+=boal[i*k]
        k+=1
    if sum_boal%2!=a[i]:
        boal[i]+=1
        m+=1
        ans.append(i)
print(m)
print(*ans)

Measured memory_bytes: 101300
#include <bits/stdc++.h>
#define MAX_N 200000
#define mid ((l+r)>>1)
using namespace std;
int n, a[MAX_N+5];
bool chk(int x) {
	map <int, int> c; if (x == 1) return is_sorted(a+1, a+n+1);
	for (int i = 1, v; i <= n; i++) if ((v = a[i]) <= a[i-1]) {
		c[v]++, c.erase(c.upper_bound(v), c.end());
		while (v && c[v] == x) c.erase(v), c[--v]++;
		if (!v) return false;
	}
	return true;
}
int bi_search(int l, int r) {
	int ret = n;
	while (l <= r)
		if (!chk(mid)) l = mid+1;
		else ret = mid, r = mid-1;
	return ret;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", a+i);
	return printf("%d\n", bi_search(1, n)), 0;
}

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

int main(){
  int n;
  cin>>n;
  
  int a[n],b[n],c[n-1];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  for(int i=0;i<n-1;i++){
    cin>>c[i];
  }
  
  int point=0;
  for(int i=0;i<n;i++){
    point+=b[i];
  }
  
  for(int i=1;i<n;i++){
    if(a[i]-a[i-1]==1){
      point+=c[a[i]-2];
    }
  }
  
  cout<<point<<endl;
}

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

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			int s = Integer.parseInt(br.readLine());
			int ss = s % 60;
			int mm = s / 60 % 60;
			int hh = s / 3600;

			System.out.println(hh + ":" + mm + ":" + ss);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24232
#include <iostream>
#include <deque>

using namespace std;

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

    deque<int> s;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        s.push_back(x);
    }

    cin >> n;
    deque<int> t;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        t.push_back(x);
    }

    int sameNumCount = 0;
    for (auto numT : t) {
        for (auto numS : s) {
            if (numT == numS) {
                sameNumCount++;
                break;
            }
        }
    }

    cout << sameNumCount << endl;

    return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int N;
  cin >> N;
  int x = N * 800;
  int y = (N / 15) * 200;
  cout << (x - y) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 10000005
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
typedef long long ll;
ll cnt[N];
int main()
{
    FAST;
    ll n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        for(int j=i;j<=n;j=j+i)
        {
            cnt[j]++;
        }
    }
    ll ans=0LL;
    for(ll i=1;i<=n;i++) ans += (i*cnt[i]);
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 81724
n = int(input())
l = [ list(map(int, input().split())) for _ in range(n) ]
c = 0
l.sort(key=lambda x: x[1])
for i in range(n):
  c += l[i][0]
  if c > l[i][1]:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 53728
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;

int main() {
    ll n; cin >> n;
    string s; cin >> s;
    n = s.size();
    map<char,int> a;
    for (int i = 0; i < n; ++i) {
        a[s[i]]++;
    }
    int m = a.size();
    vector<int> b(m);
    int i = 0;
    for(auto it : a){
        b[i] = it.second;
        i++;
    }
    ll ans = 1;
    rep(i,m) {
        ans *= b[i] + 1;
        ans %= mod;
    }
    print(ans % mod - 1);
}


Measured memory_bytes: 512
#define P(x) cout << #x " = " << x << endl
#define PP(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define PPP(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl

#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<queue>

using namespace std;
using ll = long long;

ll x[3][1000];
int n[3];
int k;
priority_queue<ll, vector<ll>, greater<ll>> cand;
vector<ll> buf;
void push(ll v) {
    cand.push(v);
    if (cand.size() > k) cand.pop();
}

int main()
{
    for (int i = 0; i < 3; ++i) {
        cin >> n[i];
    }
    cin >> k;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < n[i]; ++j) {
            cin >> x[i][j];
        }
        sort(x[i], x[i] + n[i], greater<ll>());
    }
    for (int i = 0; i < n[0]; ++i) {
        for (int j = 0; j < n[1]; ++j) {
            cand.push(x[0][i] + x[1][j]);
            if (cand.size() > k) cand.pop();
        }
    }
    while(!cand.empty()) {
        buf.push_back(cand.top());
        cand.pop();
    }
    // for (ll bufi: buf) {
    //     cout << bufi << endl;
    // }
    for (ll bufi : buf) {
        for (int j = 0; j < n[2]; ++j) {
            cand.push(bufi + x[2][j]);
            if (cand.size() > k) cand.pop();
        }
    }
    buf.clear();
    while(!cand.empty()) {
        buf.push_back(cand.top());
        cand.pop();
    }
    reverse(buf.begin(), buf.end());
    for (ll bufi: buf) {
        cout << bufi << endl;
    }
}

Measured memory_bytes: 1016
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#つまりlist[i] < x となる i の個数
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#つまりlist[i] <= x となる i の個数
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！

n = I()
l = LI()
c = itertools.combinations(l, 3)
ans = 0
def check(i,j,k):
    if abs(i-j) < k < i+j and abs(i-k) < j < i+k and abs(k-j) < i < k+j:
        return True
    else:
        return False
for k in c:
    if check(k[0],k[1],k[2]):
        if k[0] != k[1] and k[1] != k[2] and k[2] !=  k[0]:
            ans += 1
print(ans)


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

using namespace std;
using ll = long long;

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s[m];
  rep(i, m) {
    int k;
    cin >> k;
    s[i].resize(k);
    rep(j, k) {
      cin >> s[i][j];
      --s[i][j];
    }
  }
  int p[m];
  rep(i, m) cin >> p[i];

  int ans = 0;
  rep(si, 1 << n) {
    int now = 0;
    rep(i, m) {
      int cnt = 0;
      for (auto j : s[i]) {
        if (si >> j & 1) ++cnt;
      }
      if (cnt % 2 == p[i]) ++now;
    }
    if (now == m) ++ans;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 998244353
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   


int main() 
{ 
    fastio
    ld a, b;
    cin>>a>>b;
    cout<<(ll)(a*b)<<endl;
} 

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for (ll i=0;i<(n);i++)
typedef long long ll;
bool aaa[11111111];
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 
int main() {
  ll n,c,aan,m,w,memo=0,sx=0,sy=1,ans=0,gx,gy;
  string ka,ss;
  bool flag=true,flag1=false;
  cin>>n;
  n=n%1000;
  ans=1000-n;
  if(ans==1000)ans=0;
  vector<int> kosuu(n);
  
  cout<<ans<<endl;
}

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

using namespace std;

int main(void) {
	int num, i = 0, ans1, ans2;
	double v;
	cin >> num;
	vector<int> d(num), a(num);
	for (; i < num; i++) {
		scanf("%d", &d[i]);
		a[i] = d[i];
	}
	sort(d.begin(), d.end());
	ans1 = d[num / 2 - 1];
	ans2 = d[num / 2];
	v = (double)(ans1 + ans2) / 2;
	for (i = 0; i < num; i++) {
		if (a[i] > v)
			printf("%d\n", ans1);
		else
			printf("%d\n", ans2);
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  int k;
  cin >> k;
  int sum = 0;
  rep(i,k)rep(j,k)rep(l,k){
    int p =__gcd(i+1,j+1);
    sum += __gcd(p,l+1);
  }
  cout << sum << endl;
}






Measured memory_bytes: 3580
import java.util.*;

class Main{
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String S = sc.next();
	int cnt = 0;
	for ( int i = 0; i < S.length(); i++ ) {
	    if ( S.charAt(i) == '2' ) cnt++;
	}
	System.out.println(cnt);
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define w(x) int x;cin>>x;while(x--)
#define ll long long
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define vi vector<int>
#define fr(a,b) for(int i=a;i<=b;i++)
#define inf 1e18
#define mod 1000000007

int main()
{   
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r",stdin);
	freopen("output.txt", "w",stdout);
#endif*/
	fast;
	ll n;
	cin>>n;
	ll a[n+1];
	ll b[n+1];
	for(int i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		a[i]=x+y;
		b[i]=x-y;
	}
	sort(a,a+n);
	sort(b,b+n);
	cout<<max(a[n-1]-a[0],b[n-1]-b[0])<<"\n";
	
	return 0;

}

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

int main() {
    int x, a;
    cin >> x >> a;
    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
    return 0;
}

Measured memory_bytes: 3596
N = int(input())

for i in range(N) :
    a, b, c = map(int, input().split())
    L = [a, b, c]
    
    m = L.pop(L.index(max(L)))
    s = L[0] ** 2 + L[1] ** 2
    
    if m ** 2 == s :
        print("YES")
    else :
        print("NO")



Measured memory_bytes: 5596
/*author : Yashvardhan
Saturday, June 27, 2020
5:34 PM
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

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

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << 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

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}

const int N = 2e5 + 5;

int pref1[N];
int pref2[N];

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n,m,k;
	cin >> n >> m >> k;

	for(int i = 1; i <= n; i++){
		int x;
		cin >> x;
		pref1[i] = pref1[i - 1] + x;		
	} 

	for(int i = 1; i <= m; i++){
		int x;
		cin >> x;
		pref2[i] = pref2[i - 1] + x;
	}

	int ind = 1; 
	while(ind <= n && pref1[ind] <= k) ind++;

	ind--;

	int ans = 0;

	int j = 1;
	for(int i = ind; i >= 0; i--){
		int rem = k - pref1[i];	
		while(j <= m && pref2[j] <= rem) j++;
		j--;
		ans = max(ans, i + j);
	}
	cout << ans << endl;

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 6768
package main

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

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func main() {
	scanner.Split(bufio.ScanWords)
	k := scanInt()
	queue := make([]int, 10, 100001)
	for i := 1; i < 10; i++ {
		queue[i] = i
	}

	ans := 0
	for i := 1; i <= k; i++ {
		ans = queue[i]
		for j := -1; j < 2; j++ {
			m := ans%10 + j
			if m < 0 || m > 9 {
				continue
			}
			n := (ans * 10) + m
			queue = append(queue, n)
		}
	}

	fmt.Println(ans)
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanText(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func scanTexts(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanText()
	}
	return s
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}


Measured memory_bytes: 10752
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  cin >> n;
  vecint table(1e6 + 1, 0);
  vecint a(n, 0);
  REP(i, n) {
    cin >> a[i];
    table[a[i]]++;
  }
  sort(all(a), greater<int>());
  // REPe(e, a) cout << e << endl;
  int ans = 0;
  REP(i, n) {
    if (table[a[i]] > 1) continue;
    bool ok = true;
    for (int j = 1; j * j <= a[i]; j++) {
      if (a[i] % j == 0) {
        if (j != a[i] && table[j] > 0) {
          ok = false;
          break;
        }
        if (j != 1 && table[a[i] / j] > 0) {
          ok = false;
          break;
        }
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  // vecint a(n, 0);
  // REPe(e, a) cin >> e;
  // sort(all(a));
  // if (a[0] == 1) {
  //   if (n > 1 && a[1] == 1) {
  //     cout << 0 << endl;
  //     return 0;
  //   } else {
  //     cout << 1 << endl;
  //     return 0;
  //   }
  // }
  // vecint impossible(n, 0);
  // int ans = 0;
  // REP(i, n) {
  //   if (impossible[i]) continue;
  //   bool ok = true;
  //   FOR(j, i + 1, n) {
  //     if (a[j] % a[i] == 0) {
  //       impossible[j] = 1;
  //     }
  //     if (a[i] % a[j] == 0) {
  //       ok = false;
  //       impossible[i] = 1;
  //       break;
  //     }
  //   }
  //   if (ok) ans++;
  // }
  // cout << ans << endl;
}


Measured memory_bytes: 7932
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int main(){
  int N;
  scanf("%d",&N);
  std::vector<std::vector<long long> > table(10, std::vector<long long > (10,0));
  for (int i=1; i<10; i++){
    for (int j=1; j<10; j++){
      // 1桁の数
      if (i==j){
        if (N>=i){
          table[i][j]++; //i
        }
      }
      // 2桁の数
      if (N>=10*i+j){
        table[i][j]++;
      }
      // 3桁の数
      for (int k=0; k<10; k++){
        if (N>=100*i+10*k+j){
          table[i][j]++;
        }
      }
      // 4桁の数
      for (int k=0; k<10; k++){
        for (int l=0; l<10; l++){
          if (N>=1000*i+100*k+10*l+j){
            table[i][j]++;
          }
        }
      }
      // 5桁の数
      for (int k=0; k<10; k++){
        for (int l=0; l<10; l++){
          for (int h=0; h<10; h++){
            if (N>=10000*i+1000*k+100*l+10*h+j){
              table[i][j]++;              
            }
          }
        }
      }
      // 6桁の数
      if (i>2){
        continue;
      }
      for (int k=0; k<10; k++){
        for (int l=0; l<10; l++){
          for (int h=0; h<10; h++){
            for (int m=0; m<10; m++){
              if (N>=100000*i+10000*k+1000*l+100*h+10*m+j){
                table[i][j]++;              
              }
            }
          }
        }
      }
    }
  }

  long long ans = 0;
  for (int i=1; i<10; i++){
    for (int j=1; j<10; j++){
      //printf("ans+=table[%d][%d]*table[%d][%d]=%lld\n",i,j,j,i,table[i][j]*table[j][i]);
      ans+=table[i][j]*table[j][i];
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<unordered_set>
#define PI acos(-1)
#define pb push_back
#define all(x) x.begin(),x.end()
#define INF 0x3f3f3f3f
#define dd(x) cout<<#x<<" = "<<x<<","
#define de(x) cout<<#x<<" = "<<x<<"\n"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a;
}


Measured memory_bytes: 3632
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a,b;
    cin >> a >> b;
    cout << a*b - a - b +1<<endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 int main(){
  int a,b,c=0,ans=0;
   cin>>a>>b;
   c=a;
   while(1){
    ans++;
     if(c>=b){
      break;
     }
     c+=a-1;
   }
   if(b==1)ans=0;
   cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Program

{
    public Program() { }
    public static int Main()
    {
        cin = new Scanner();
        new Program().calc();
        return 0;
    }
    static Scanner cin;

    void calc()
    {
        long X;

        X = cin.nextLong();



        
        for(long i = -1000; i < 1000; i++)
        {
            long pA5 = X + i*i*i*i*i;
            long pA = (long)Math.Pow(pA5, 0.2);
            if (pA5 == pA * pA * pA * pA * pA)
            {
                Console.WriteLine($"{pA} {i}");
                return;
            }
        }


    }



}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


class XRand
{
    uint x, y, z, w;


    public XRand()
    {
        init();
    }

    public XRand(uint s)
    {
        init();
        init_xor128(s);
    }

    void init()
    {
        x = 314159265; y = 358979323; z = 846264338; w = 327950288;

    }

    public void init_xor128(uint s)
    {
        z ^= s;
        z ^= z >> 21; z ^= z << 35; z ^= z >> 4;
        z *= 736338717;
    }

    uint next()
    {
        uint t = x ^ x << 11; x = y; y = z; z = w; return w = w ^ w >> 19 ^ t ^ t >> 8;
    }

    public long nextLong(long m)
    {
        return (long)((((ulong)next() << 32) + next()) % (ulong)m);
    }

    public int nextInt(int m)
    {
        return (int)(next() % m);
    }

    public int nextIntP(int a)
    {
        return (int)Math.Pow(a, nextDouble());
    }

    public int nextInt(int min, int max)
    {
        return min + nextInt(max - min + 1);
    }


    public double nextDouble()
    {
        return (double)next() / uint.MaxValue;
    }

    public double nextDoubleP(double a)
    {
        return Math.Pow(a, nextDouble());
    }
}

Measured memory_bytes: 27892
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 


int main(){
  int N;
  cin >> N;
  
  vector<int> d(N);
  rep(i, N) cin >> d.at(i);
  
  sort(d.begin(), d.end());
  
  int res = 0;
  int instance = 0;
  
  rep(i, N){
    if(d.at(i) != instance){
      res++;
      instance = d.at(i);
    }
  }
  
  cout << res;
      
 
  
  
  
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  long long x;
  cin >> x;
  string ss = "";
  if (x<=26){
  	ss = (x-1)+'a';
  }
  else{
  	while (x>=1){
  		char ch = (x-1)%26+'a';
  		if (ch==0){
  			 ch='z';
  		}
  		if (x%26==0) x--;
  		x /= 26;
  		ss = ch + ss;
  	}
  }
  cout << ss << endl;
}

Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef vector<int> vi;
const int mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>> n;
    vector<double> x(n);
    vector<S> u(n);
    double ans=0;
    for(int i=0;i<n;i++){
        cin >> x[i] >> u[i];
        ans += (u[i]=="JPY"?x[i]:x[i]*380000.0);
    }
    cout <<setprecision(20) <<  ans << endl;
    return 0;
}


Measured memory_bytes: 256