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

using namespace std;

typedef long long ll;

#define sz(a) ((int)(a).size())

const int INF = 1e9;

struct UFnode
{
  string value_;
  int rank_, p_, index_, size_;
  UFnode(string value) : value_(value), rank_(0), p_(-1), size_(1) {}
  int size() const { return size_; }
};

struct UF
{
  vector<UFnode> ufnodes_;
  // mapping a value to its index in vector
  map<string, int> value_to_index_;
  // the number of components
  int size_;

  UF() : size_(0) {}
  int size() const { return size_; }
  // Returns the number of nodes in the tree in which value resides
  int tree_size(string value)
  {
    if (value_to_index_.count(value) == 0) { return 0; }
    int pix = ufnodes_[value_to_index_[value]].p_;
    return ufnodes_[pix].size();
  }

  void make_set(string value)
  {
    UFnode node(value);
    ufnodes_.push_back(node);
    int ix = ufnodes_.size() - 1;
    ufnodes_[ix].index_ = ufnodes_[ix].p_ = value_to_index_[value] = ix;
    ++size_;
  }

  // Return index of the root of the tree to which value belongs.
  int find_set(string value, int index = -1)
  {
    if (index == -1) {
      if (value_to_index_.count(value) == 0) { return -1; }
      index = value_to_index_[value];
    }
    if (ufnodes_[index].p_ != index) {
      ufnodes_[index].p_ = find_set(ufnodes_[ufnodes_[index].p_].value_, ufnodes_[index].p_);
    }
    return ufnodes_[index].p_;
  }

  void unite(string x, string y)
  {
    int s1 = find_set(x), s2 = find_set(y);
    if ((s1 == s2) || (s1 == -1) || (s2 == -1)) { return; }
    if (ufnodes_[s1].rank_ > ufnodes_[s2].rank_) {
      // connect ufnodes_[s2] to ufnodes_[s1]
      ufnodes_[s2].p_ = s1;
      ufnodes_[s1].size_ += ufnodes_[s2].size_;
    }
    else {
      // connect ufnodes_[s1] to ufnodes_[s2]
      ufnodes_[s1].p_ = s2;
      ufnodes_[s2].size_ += ufnodes_[s1].size_;
      if (ufnodes_[s1].rank_ == ufnodes_[s2].rank_) { ++ufnodes_[s2].rank_; }
    }
    --size_;
  }

  bool is_connected(string x, string y) { return find_set(x) == find_set(y); }
};

int main()
{
  vector<string> stuff;
  vector<int> prices;
  int n = 0;
  UF uf;
  fscanf(stdin, "%d", &n);
  for (int i = 0; i < n; ++i) {
    string s;
    int p;
    cin >> s >> p;
    prices.push_back(p);
    stuff.push_back(s);
    uf.make_set(s);
  }
  int m = 0;
  fscanf(stdin, "%d", &m);
  for (int i = 0; i < m; ++i) {
    string s, t;
    cin >> s >> t;
    uf.unite(s, t);
  }
  vector<int> min_prices(n, INF);
  for (int i = 0; i < sz(stuff); ++i) {
    int r = uf.find_set(stuff[i]);
    min_prices[r] = min(min_prices[r], prices[i]);
  }
  int ans = 0;
  for (int i = 0; i < sz(stuff); ++i) {
    int r = uf.find_set(stuff[i]);
    ans += min_prices[r];
  }
  fprintf(stdout, "%d\n", ans);
  return 0;
}

Measured memory_bytes: 3888
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
using namespace std;
typedef long long ll;

int main(){
  int n, d;
  cin >> n >> d;
  int ans = 0;
  for(int i = 1; i <= n; i++){
    if(n <= (d * 2 + 1) * i){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;
int main() {
  string a;
  cin >> a;
  bool n = find(a.begin(), a.end(), 'N') != a.end();
  bool e = find(a.begin(), a.end(), 'E') != a.end();
  bool w = find(a.begin(), a.end(), 'W') != a.end();
  bool s = find(a.begin(), a.end(), 'S') != a.end();
  cout << (n == s && e == w ? "Yes" : "No") << endl;
}


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

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    
    class Solve
    {
        const int mod = 1000000007;
        
        
        static void Main(string[] args)
        {

            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int X = input[0];
            int Y = input[1];
            int Z = input[2];
            int K = input[3];
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var b = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var c = Console.ReadLine().Split().Select(long.Parse).ToArray();
            Array.Sort(a);
            Array.Reverse(a);
            Array.Sort(b);
            Array.Reverse(b);
            Array.Sort(c);
            Array.Reverse(c);

            List<long> AB = new List<long>();
            
            for(var i = 0; i < X; i++)
            {
                for(var j = 0; j < Y; j++)
                {
                    AB.Add(a[i] + b[j]);
                }
            }
            AB.Sort();
            AB.Reverse();
            

            List<long> ans = new List<long>();
            for(var i = 0; i < Z; i++)
            {
                for (var j = 0; j < Math.Min(K, X * Y); j++) 
                {
                    ans.Add(AB[j] + c[i]);
                }
            }

            ans.Sort();
            ans.Reverse();

            for(var i = 0; i < K; i++)
            {
                Console.WriteLine(ans[i]);
            }

            Console.Out.Flush();

        }

        
    }

    public class Calculation
    {

    }

    public class Graph
    {
        
    }
}




Measured memory_bytes: 63132
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

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

  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  a.push_back(10000009);

  int l = 0, r = 0, ans = 0;
  while (l <= r) {
    while (r + 1 <= n && a[r] - a[l] <= 2) {
      r++;
    }
    ans = max(ans, r - l);
    l++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
using namespace std;
int main () {
	int a, b, c, x, i, j, k, cnt=0;
	scanf("%d%d%d%d", &a, &b, &c, &x);
	for (i=0; i <= a && 500*i<=x; i++)
		for (j=0; j <= b && 100*j+500*i<=x; j++)
			for (k=0; k <= c && 50*k+100*j+500*i<=x; k++)
				if (500*i+100*j+50*k==x)
					cnt++;
	printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
#define mod int(1e9+7)
#define N int(2e5+100)
#define ll long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define si second
using namespace std;
int find(vector<int>v,int x){
   int l=0,u=v.size()-1,mid;
   while(l<u){
      mid=l+(u-l)/2;
      if(v[mid]<=x){
         l=mid+1;
      }else
         u=mid;
   }
   if(l==v.size()||v[l]<=x)
      return (v.size());
   return l;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	string s;
	cin>>n>>s;
	vector<int>r,g,b;
	ll ans=0*1ll;
	for(int i=0;i<n;i++){
	   if(s[i]=='R')
         r.pb(i);
      if(s[i]=='G')
         g.pb(i);
      if(s[i]=='B')
         b.pb(i);
   }
   for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++){
         if(s[i]==s[j])
            continue;
         if(s[i]!='R'&&s[j]!='R'){
            ans+=1ll*(r.size()-find(r,j));
            if((2*j-i)<n&&s[2*j-i]=='R')
               ans--;
         }
         if(s[i]!='G'&&s[j]!='G'){
            ans+=1ll*(g.size()-find(g,j));
            if((2*j-i)<n&&s[2*j-i]=='G')
               ans--;
         }
         if(s[i]!='B'&&s[j]!='B'){
            ans+=1ll*(b.size()-find(b,j));
            if((2*j-i)<n&&s[2*j-i]=='B')
               ans--;
         }
      }
   cout<<ans<<'\n';
   return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#include <vector>
using namespace std;
 
int main(){
  //入力
  int X,Y;
  cin>>X>>Y;
  int ans=0;
  if(X==3){
    ans+=100000;
  }else if(X==2){
    ans+=200000;
  }else if(X==1){
    ans+=300000;
  }else{
    ans+=0;
  }
  if(Y==3){
    ans+=100000;
  }else if(Y==2){
    ans+=200000;
  }else if(Y==1){
    ans+=300000;
  }else{
    ans+=0;
  }
  if(X==1 && Y==1){
    ans+=400000;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int cnt = 0;
	for (char c : s) {
		if (c == 'o') {
			cnt++;
		}
	}
	if (15-s.size() + cnt >= 8) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
#define fst first
#define snd second
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}
inline int Log2(ll x) {int k; for(k=0; x>0; ++k) x>>=1; return k;} // number of binary digits
template<typename T> inline int count_between(vector<T>& a, T l, T r) {
  return lower_bound(all(a), r) - lower_bound(all(a), l); // [l, r)
}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {
  rep(i, v.size()) is >> v[i]; return is;
}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
  rep(i, v.size()) os << v[i] << " "; return os;
}
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n, m; cin >> n >> m;
  Vll a(n); cin >> a;
  sort(all(a));
  ll sum = 0;
  rep(i, n) sum += a[i];

  ll k = count_between(a, (sum + 4*m-1)/(4*m), INFll);
  cout << (k >= m ? "Yes" : "No") << endl;
  return 0;
}


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

using namespace std;

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

  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  for (auto &e : a)
    cin >> e;
  for (auto &e : b)
    cin >> e;
  for (auto &e : c)
    cin >> e;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  vector<uint64_t> bcnt(n);
  for (int i = 0; i < n; ++i) {
    auto m = upper_bound(c.begin(), c.end(), b[i]);
    bcnt[i] = distance(m, c.end());
  }
  for (int i = n-2; 0 <= i; --i) {
    bcnt[i] += bcnt[i+1];
  }

  uint64_t ans = 0;
  for (int i = 0; i < n; ++i) {
    auto m = upper_bound(b.begin(), b.end(), a[i]);
    int pos = distance(b.begin(), m);
    ans += bcnt[pos];
  }
  cout << ans << "\n";
}


Measured memory_bytes: 2176
from collections import defaultdict
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

n = getN()
nums = getlist()

kazu = defaultdict(int)
for i in nums:
    kazu[i] += 1

ans = 0
for x in kazu.keys():
    if kazu[x] >= x:
        ans += kazu[x] - x
    else:
        ans += kazu[x]

print(ans)

Measured memory_bytes: 18676
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int oo = 1000000001;
const int N = 200011;

ll res = 0;
ll freq[30];
string s;

int main() {
	//freopen("input.txt", "r", stdin);
	cin >> s;
	for (int i = 0; i < s.size(); ++i){
		freq[s[i]-'a']++;
	}
	ll len = s.size();
	res = (len * (len-1))/2+len+1;
	for (int i = 0; i < s.size(); ++i){
		res -= freq[s[i]-'a'];
		freq[s[i]-'a']--;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  char c1,c2,c3;
  int num=3;
  cin>>c1>>c2>>c3;
  if(c1=='7'||c2=='7'||c3=='7')
  {
    cout<<"Yes";
  }
  else
    cout<<"No";
  return 0;
}


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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> d(N);
  
  for (int i=0; i<N; i++)
    cin >> d.at(i);
  
  sort (d.begin(), d.end());
  
  int n=1;
  for (int i=0; i<N-1; i++){
    
    if (d.at(i) != d.at(i+1))
      n++;
    
  }
  
  cout << n << endl;
  
}

Measured memory_bytes: 256
n = list(map(int, input().split()))
for i in range(1, 1000000):
  if n[i-1]%2 == 0:
    n.append(n[i-1]//2)
  else:
    n.append(3*n[i-1]+1)
  if n[i] in n[:i]:
    print(i+1)
    break

Measured memory_bytes: 2940
#include <iostream>
#include <vector>

using namespace std;

int main() {
    string first, second;
    cin >> first >> second;
    int first_num, second_num;
    cin >> first_num >> second_num;
    string first_or_second;
    cin >> first_or_second;

    if (first == first_or_second)
        first_num--;
    else
        second_num--;

    cout << first_num << " " << second_num << endl;

    return 0;
}


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

int main() {
 int H1, M1, H2, M2, K, ans;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  ans = (H2 * 60 + M2) - (H1 * 60 + M1) -K;
  cout << ans << endl;
}



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

long long bitcount(long long X, int digit) {
    if (X < 0) return 0;
    long long per = 1LL << (digit+1);
    long long bit = 0;
    bit += ((X+1) - ((X+1) % per)) / 2;
    bit += max(((X+1) % per) - per / 2, 0LL);
    return bit;
}

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

    long long A, B;
    cin >> A >> B;

    long long ans = 0;
    for (int i=60; i>=0; --i) {
        long long t = bitcount(B, i) - bitcount(A-1, i);
        if (t % 2 == 1) {
            ans |= 1LL << i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
class Die
  def initialize(men)
    @t, @s, @e, @w, @n, @b = men
  end

  def top; @t; end
  def right; @e; end

  def move(d)
    case d
    when 'N'
      @t, @s, @b, @n = @s, @b, @n, @t
    when 'W'
      @w, @b, @e, @t = @t, @w, @b, @e
    when 'E'
      @w, @b, @e, @t = @b, @e, @t, @w
    when 'S'
      @t, @s, @b, @n = @n, @t, @s, @b
    end
  end

  def make_top(num)
    3.times do
      move 'N'
      return if @t == num
      move 'E'
      return if @t == num
    end
    raise "#{num} is not found"
  end

  def rotate
    @n, @w, @s, @e = @w, @s, @e, @n
  end

  def rotate_until(num)
    4.times do
      rotate
      return if @s == num
    end
    raise "#{num} is not found"
  end
end

d = Die.new(gets.split)
gets.to_i.times do
  top, front = gets.split
  d.make_top(top)
  d.rotate_until(front)
  puts d.right
end



Measured memory_bytes: 6872
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

bool used[30][30];
int mv[4][2]={{0,1},{0,-1},{1,0},{-1,0}};

bool check(int n){
	int m;
	int i,j,k;
	int a,b,c,d;
	char ca;
	memset(used,false,sizeof(used));
	for(i=0;i<n;i++){
		cin>>a>>b;
		used[a][b]=true;
	}
	a=10,b=10;
	cin>>m;
	for(i=0;i<m;i++){
		cin>>ca>>d;
		if(ca=='N')c=0;
		if(ca=='S')c=1;
		if(ca=='E')c=2;
		if(ca=='W')c=3;
		for(j=0;j<d;j++){
			a+=mv[c][0],b+=mv[c][1];
			if(used[a][b])n--,used[a][b]=false;
		}
	}
	if(n)return false;
	return true;
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	while(cin>>n){
		if(n==0)return 0;
		if(check(n))cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}


Measured memory_bytes: 3092
import java.io.*;
import java.util.*;
import java.math.*;


class Main{

  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    Integer[] nk = Arrays.stream(in.readLine().split(" ")).map(Integer::parseInt).toArray(Integer[]::new);
    BigInteger[] values = Arrays.stream(in.readLine().split(" ")).map(s -> new BigInteger(s)).toArray(BigInteger[]::new);
    Arrays.sort(values);
    if(nk[1]<values[0].longValue()||nk[1]>values[nk[0]-1].longValue()){
      System.out.println("IMPOSSIBLE");
      return;
    }
    BigInteger v = values[0];
    for(int j=1;j<nk[0];j++){
      v = v.gcd(values[j]);
    }
    if((BigInteger.valueOf(nk[1]).mod(v)).equals(BigInteger.ZERO)){
      System.out.println("POSSIBLE");
      return;
    }

    System.out.println("IMPOSSIBLE");
    return;
  }
}


Measured memory_bytes: 59712
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll A, B, C, X, Y;
ll ans = INF;

int main()
{
  std::cin >> A >> B >> C >> X >> Y;

  rep( c, std::max(X,Y)+1 )
  {
    ll p = 2*c*C+std::max(0ll,A*(X-c))+std::max(0ll,B*(Y-c));

    chmin( ans, p );
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
static const int INFTY = 2501;
string imap[51];
string str;
int d[51][51];
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
int h, w;
int x, y;

int bfs(const int &idx) {
    for (int i = 0; i < h; i++) fill(d[i], d[i]+w, INFTY);
    queue<pair<int, int> > q;
    pair<int, int> p;
    d[x][y] = 0;
    int nx, ny, sum = 0;
    q.push({x, y});
    while (!q.empty()) {
        p = q.front(); q.pop();
        if (imap[p.first][p.second] == str[idx]) { x = p.first, y = p.second; sum = d[p.first][p.second]; break; }
        for (int i = 0; i < 4; i++) {
            nx = p.first+dx[i], ny = p.second+dy[i];
            if (nx >= 0 && nx < h && ny >= 0 && ny <= w && d[nx][ny] == INFTY) {
                d[nx][ny] = d[p.first][p.second]+1;
                q.push({nx, ny});
            }
        }
    }
    return sum;
}



int main(void){
    for(; ;) {
        cin >> h >> w;
        if (h == 0 && w==0) break;
        for (int i = 0; i < h; i++) {
            cin >> imap[i];
        }
        cin >> str;
        x = y = 0;
        int sum = 0;

        for (int i = 0; i < str.size(); i++) {
            if (str[i] != imap[x][y]) sum+=bfs(i)+1;
            else sum+=1;
        }
        printf("%d\n", sum);
    }
    return 0;
}



Measured memory_bytes: 3356
object Main extends App {
  import scala.io.StdIn._
  val n = readInt
  val names = Array.fill(n){readLine.trim}.filter(name ⇒ "MARCH".contains(name.head)).groupBy(_.head).mapValues(_.length.toLong).withDefault(_ ⇒ 0L)
  println("MARCH".combinations(3).map{str ⇒ str.map(names).product}.sum)
}

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

int main(){
	int a, b, c, d;
	cin >> a >> b;
	if(a < 1200) cout << "ABC" << endl;
	else cout << "ARC" << endl;
}

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

int main()
{
	int n;
    cin>>n;
    int a[n],k=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
   for(int i=1;i<=n;i++)
   {
       if(i%2!=0 && a[i]%2!=0)
           k++;
   }
    cout<<k;
	return 0;
}

Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b,c;
    char d,e;
  	string s;
  	cin>>a>>b>>c;
 cout<<max({a,b,c})-min({a,b,c})<<endl;
  /* 
 if(a>=1200&&a<2800)
    cout<<"ARC"<<endl;
 else if(a>=2800)
   cout<<"AGC"<<endl;
 else
   cout<<"ABC"<<endl;
  else if(a==23)
    cout<<"Christmas Eve Eve"<<endl;
  else
    cout<<"Christmas Eve Eve Eve"<<endl;
  */
 return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    string s;
    cin >> s;
    ll num0=0,num1=0;
    for(ll i;i<s.size();i++){
      if(s[i]=='0')num0++;else num1++;
    }
    cout << 2*min(num0,num1);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair

using namespace std;
int count(unsigned long long int num, unsigned long long int pos)//1~30
{
	num++;
	unsigned long long int l = (unsigned long long int)1 << (pos-1);
	unsigned long long int s = (unsigned long long int)1 << pos;
	unsigned long long int sub = num % s;
	if(sub <= l)
		return (unsigned long long int)(num/s)*l;
	return (unsigned long long int)(num/s)*l  +  (sub-l);
}
int main()
{
	unsigned long long int i,j,k;
	unsigned long long int A,B;
	scanf("%lld %lld",&A,&B);
	unsigned long long int ans = 0;
	unsigned long long int app = 1;
	//cout << A << " " << B << endl;
	for(i=0;i<40;i++)
	{
		j = count(B, i+1);
		k = count(A-1, i+1);
		//cout << j << " " <<  k << endl;
		if(((j-k)&1) == 1)
		{
			ans |= app;
		}
		app<<=1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
        M: usize,
        X: [i32; M],
    }

    if M as i32 - N as i32 <= 0 {
        println!("0");
        return
    }

    X.sort();
    let mut dist = Vec::with_capacity(M-1);

    for ind in 1..M {
        dist.push(X[ind] - X[ind - 1]);  
    }

    dist.sort();

    let mut sum = 0;
    for ind in 0..M-N {
        sum += dist[ind];
    }
    println!("{}", sum);
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main()
{
    long long a,b,k,ansA=0,ansB=0;
    cin>>a>>b>>k;
    if(k<=a)
    {
        ansA=a-k;
        ansB=b;
    }
    else if(k<=a+b)
    {
        ansA=0;
        ansB=a+b-k;
    }
    else
    {
        ansA=0;
        ansB=0;
    }
    cout<<ansA<<" "<<ansB<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int k,x,s=0,g=0;
  scanf("%d %d",&k,&x);
  s=x-k+1;
  g=x+k-1;
  while(s<=g){
    printf("%d ",s);
    s++;
  }
  return 0;
}

Measured memory_bytes: 128
/**
*    created: 06.05.2020 02:24:30
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, u) for (int i = 0; i < (int)(u); i++)
const int inf =1000000000;

int n,q,m;
vector<int> a,b,c,d;
int ans ;


void dfs(vector<int> A){
    if(A.size()==n+1){
        int g = 0;
        rep(i,q){
            if(A[b[i]]-A[a[i]]==c[i]){
                 g+=d[i];
            }
        }
        ans = max(ans, g);
        return;
    }
/*
    A.push_back(A.back());
    while(A.back()<=m){
        dfs(A);
        A.back()++;
    }
*/


    int prb = A.back();
    for(int i=prb;i<=m;i++)
    {
        A.push_back(i);
        dfs(A);
        A.pop_back();
    }

}

int main() {
    
    cin >> n;

   cin >> m >> q;
    a.resize(q), b.resize(q), c.resize(q), d.resize(q);
    rep(i, q)
     {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
   // vector<int> fr(1, 1);
     //dfs(fr);
    dfs(vector<int>(1,1));
    cout << ans << endl;
}


Measured memory_bytes: 3612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(br.readLine());
        double[] value = new double[N];
        String[] type = new String[N];
        for (int i=0; i<N; i++) {
            StringTokenizer st = new StringTokenizer(br.readLine());
            value[i] = Double.parseDouble(st.nextToken());
            type[i] = st.nextToken();
        }
        double out = 0;
        for (int i=0; i<N; i++) {
            if (type[i].equals("JPY")) {
                out += value[i];
            } else {
                out += value[i]*380000;
            }
        }
        System.out.println(out);
    }
}


Measured memory_bytes: 24532
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

typedef struct {
    int *que;
    int front;
    int rear;
    int size;
    int num;
} Que;

bool initQue(Que *q, int size) {
    if((q->que = malloc(size * sizeof(int))) == NULL) {
        return false;
    }

    q->front = q->rear = q->num = 0;
    q->size = size;
    return true;
}

bool isEmptyQue(Que *q) {
    return q->num <= 0;
}

bool isFullQue(Que *q) {
    return q->num >= q->size;
}

int nextPtr(int ptr, int size) {
    return (ptr + 1) % size;
}

bool enQue(Que *q, int p) {
    if(isFullQue(q)) {
        return false;
    }

    q->que[q->rear] = p;
    q->rear = nextPtr(q->rear, q->size);
    q->num++;

    return true;
}

bool deQue(Que *q, int *p) {
    if(isEmptyQue(q)) {
        return false;
    }

    *p = q->que[q->front];
    q->front = nextPtr(q->front, q->size);
    q->num--;

    return true;
}

void terminateQue(Que *q) {
    free(q->que);
    q->front = q->rear = q->num = q->size = 0;
}

int **graph;
int n;
int *d;

bool isVisited(int u) {
    return d[u] != -1;
}

bool isAdjacent(int u, int v) {
    return graph[u][v];
}

void bfs(int bgn) {
    Que que;

    initQue(&que, n);

    enQue(&que, bgn);
    d[bgn] = 0;
    while(!isEmptyQue(&que)) {
        int u;
        deQue(&que, &u);
        for(int i = 0; i < n; i++) {
            if(!isVisited(i) && isAdjacent(u, i)) {
                d[i] = d[u] + 1;
                enQue(&que, i);
            }
        }
    }
}

int main(void) {

    scanf("%d", &n);
    graph = malloc(n * sizeof(int*));
    for(int i = 0; i < n; i++) {
        graph[i] = malloc(n * sizeof(int));
        memset(graph[i], 0, n * sizeof(int));
    }
    d = malloc(n * sizeof(int));
    memset(d, -1, n * sizeof(int));

    for(int i = 0; i < n; i++) {
        int uIdx;
        int deg;
        scanf("%d %d", &uIdx, &deg);
        for(int j = 0; j < deg; j++) {
            int vIdx;
            scanf("%d", &vIdx);
            graph[uIdx - 1][vIdx - 1] = 1;
        }
    }

    bfs(0);

    for(int i = 0; i < n; i++) {
        printf("%d %d\n", i + 1, d[i]);
    }

    for(int i = 0; i < n; i++) {
        free(graph[i]);
    }
    free(graph);
    return 0;
}


Measured memory_bytes: 2112
l, r = map(int, input().split())
diff = r - l
l = l % 2019
r = l + diff
a = 2019
for x in range(l, r):
  for y in range(x + 1, r + 1):
    a = min(a, (x * y) % 2019)
    if a == 0:
      break
  else:
    continue
  break
print(a)

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

inline int readInt(){
  int ret = 0;
  char c;
  //  while((c=getchar()) && '0' <= c && c <= '9'){
  while((c=getchar()) && isdigit(c)){
    ret = ret * 10 + (c-'0');
  }
  return ret;
}

main(){
  int n,s;
  int r[101]={0};
  while(true){
    n = readInt();
    if (n==0)break;
    s = readInt();
    for(int i=0;i<n;i++){
      int tmp;tmp=readInt();r[tmp]++;
    }
    int ans = 0;
    for(int i=1;i != 101;i++){
      if (r[i] && i+i > s)ans += r[i]*(r[i]-1)/2;
      if (!r[i])continue;
      for(int j=i+1;j != 101;j++){
	if (i+j > s)ans += r[i]*r[j];
      }
      r[i] = 0;
    }
    printf("%d\n",ans);
  }
}

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

using namespace std;
using ll = long long;

int main(void)
{
    int                         n, m, ai;
    multiset<int, greater<int>> s;

    cin >> n >> m;

    for (int i = 0; i < n; ++i)
        cin >> ai, s.insert(ai);

    while (m--)
    {
        int biggest = *s.begin();
        if (biggest == 0)
            break;
        s.erase(s.begin());
        s.insert(biggest / 2);
    }

    cout << accumulate(s.begin(), s.end(), (ll)0) << endl;

    return 0;
}


Measured memory_bytes: 8264
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int n,k; cin>>n>>k;
    vector<long long> v(n);
    for(int i=0; i<n; ++i)cin>>v[i];
    int r = min(n,k);
    long long ans = 0;
    for(int a = 0; a <= r;++a){
        for(int b = 0; b <= r-a; ++b){
            long long temp = 0;
            vector<long long> minus;
            for(int i = 0; i < a; ++i){
                temp += v[i];
                if(v[i]<0)minus.push_back(v[i]);
            }
            for(int i = 0; i < b; ++i){
                temp += v[n-i-1];
                if(v[n-i-1]<0)minus.push_back(v[n-i-1]);
            }
            sort(minus.begin(), minus.end());
            int x = minus.size();
            int d = min(k-a-b, x);
            for(int i = 0; i < d; ++i){
                temp -= minus[i];
            }
            ans = max(ans, temp);
        }
    }
    cout<<ans<<endl;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cout.precision(12);
    cout << fixed;
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    int cnt = 1;
    int j = n-1;
    long long ans = 0;
    for (int i = 0; i < n-1; i++) {
        ans += v[j];
        cnt++;
        if (cnt == 2) {
            j--;
            cnt = 0;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main(){

    int H,W;

    while(true){
        scanf("%d%d",&H,&W);
        if(H == 0 && W == 0){
            break;
        }
        for(int j=0;j<H;j++){
            for(int i = 0;i<W;i++){
                if((i==0) || (i==W-1) || (j == 0) || (j == H-1)){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }


    return 0;
}



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

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

    int ans = 0;
    rep(i, n) {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }

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


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

int main(){
  int N;cin>>N;
  vector<long> L(87);
  L.at(0)=2;
  L.at(1)=1;
  for(int i=2;i<=86;i++){
    L.at(i)=L.at(i-1)+L.at(i-2);
  }
  cout<<L.at(N)<<endl;
}



Measured memory_bytes: 3544
#include <iostream>

using namespace std;

int main(){
  int N, L;
  cin >> N >> L;
  int sum = 0;
  for(int i=0; i<N; i++){
    sum += L + i;
  }
  int ans;
  int diff = 1000000;
  for(int i=0; i<N; i++){
    int tmp = 0;
    for(int j=0; j<N; j++){
      if(i == j) continue;
      tmp += L + j;
    }
    if(abs(sum - tmp) < diff){
      ans = tmp;
      diff = abs(sum - tmp);
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

#pragma region Debug
void debug_out() { cout << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cout << H << " ";
	debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
#pragma endregion

// コンパイル時、エイリアス「debug」を使用 --> マクロが使えるように

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	
	int N;
	cin >> N;
	cpp_int ans;
	cin >> ans;
	bool flg = false;
	rep(i,N-1){
		cpp_int a;
		cin >> a;
		if(!a){
			cout << 0 << endl;
			return;
		}
		if(flg) continue;
		ans = ans * a;
		if(ans > 1000000000000000000){
			flg = true;
		}
	}
	if(flg) cout << -1 << endl;
	else cout << ans << endl;
	
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
  ll N  ;
  cin >> N ;
  vector<ll> A(5) ;
  rep(i,5) cin >> A.at(i) ;
  ll ans = 10e16 ;
  rep(i,5) ans = min( ans , A.at(i) ) ;
  cout << 5 + (N-1)/ans  << endl ;
  //else cout << 5 + (N-1)/ans << endl ;
}

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

int main() {
  int count;
  int add;
  int value = 1;
  int index;
  
  cin >> count;
  cin >> add;
  
  for (index = 0; index < count; index++)
  {
    if ((value * 2) < (value + add))
    {
      value *= 2;
    }
    else
    {
      value += add;
    }
  }
  
  cout << value << endl;
}


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

int main() {
  string N;
  cin >> N;
  if(N.at(0)=='7'||N.at(1)=='7'||N.at(2)=='7'){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3624
/*
 * atcoder/abc131/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

struct Dat {
  ll a, b;
};
bool comp(const Dat& lh, const Dat& rh) {
     return lh.b < rh.b;
}
int N;
vector<Dat> A;
void solve() {
  cin >> N;
  ll a, b;
  loop(n,0,N) {
    cin >> a >> b;
    A.push_back({a, b});
  }
  sort(A.begin(), A.end(), comp);
  ll t = 0;
  for (auto&& x: A) {
    t += x.a;
    if (t > x.b) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


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

using namespace std;

int main()
{
  int D, G; cin >> D >> G;
  vector<int> p(D), c(D);
  for (int i = 0; i < D; ++i) cin >> p[i] >> c[i];

  int ans = 1e9;
  for (int bit = 0; bit < 1 << D; ++bit) {
    int sum = 0, num = 0;
    for (int i = 0; i < D; ++i) {
      if (bit >> i & 1) {
        sum += 100*(i+1)*p[i]+c[i];
        num += p[i];
      }
    }
    // printf("i: %d, sum: %d, num: %d\n", bit, sum, num);

    if (sum >= G) {
      ans = min(ans, num);
      continue;
    }

    for (int i = D-1; i >= 0; --i) {
      if (bit >> i & 1) continue;
      for (int j = 0; j < p[i]; ++j) {
        if (sum < G) {
          sum += 100*(i+1);
          num++;
        }
      }
    }
    ans = min(ans, num);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, l;
  cin >> N;
  int as[N]={0};
  for(int i=1;i<N;i++){
    cin >> l;
    as[l-1]++;
  }
  for(int i=0;i<N;i++){
    cout << as[i] << endl;
  }
}

Measured memory_bytes: 4396
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
int main() {
    string s;
    ll k;
    cin>>s>>k;
    for(int i=0; i<s.size(); i++){
        int t=26-(s[i]-'a');
        if(t<=k&&t<26){
            k-=t;
            s[i]='a';
        }
    }
    s[s.size()-1]=(char) ( (k+s[s.size()-1]-'a')%26 + 'a' ) ;
    cout<<s<<endl;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int n,m,i;
  int a_score = 0;
  int c = 0;
  int bkb;
  int a[101] = {};
  scanf("%d %d", &n, &m);
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
    a_score += a[i];
  }
  for(i=0;i<n;i++){
    bkb = a[i]*4*m;
    if(bkb >= a_score)
      c++;
  }
  if(c >= m){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main(){
	cin>>a;
	b=a;
	reverse(a.begin(),a.end());
	for(int i=0;i<a.length();i++){
		if(a[i]=='b')a[i]='d';
		else if(a[i]=='d')a[i]='b';
		else if(a[i]=='p')a[i]='q';
		else if(a[i]=='q')a[i]='p';
	}
	if(a==b)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 512
import sys
readline = sys.stdin.buffer.readline

N, K, Q = list(map(int, readline().split()))
A = []
for a in range(Q):
    A.append(int(readline()))

points = [0] * N

for i in range(Q):
    points[A[i] - 1] += 1

for p in points:
    score = K - Q + p
    print("Yes" if score > 0 else "No")

Measured memory_bytes: 8588
#include <stdio.h>

int main(){
  while(1){
    int w, h;
    scanf("%d%d", &w, &h);
    if(w == 0 && h == 0) break;
    for(int i = 0; i < w; i++){
      for(int j = 0; j < h; j++){
        if(i == 0 || j == 0 || i == w - 1 || j == h - 1) printf("#");
        else printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
}



Measured memory_bytes: 2580
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int a, b;
  cin >> a >> b;
  int area = a*b;
  area -= a+b;
  area += 1;
  cout << area << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
		int[] d = {Math.abs(a - b), Math.abs(b - c), Math.abs(c - a)};
		Arrays.sort(d);
		System.out.println(d[0] + d[1]);
	}
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main()
{
	double a,b,c,d,e,f;
	while(cin>>a>>b>>c>>d>>e>>f)
	{
		double x = (c*e-f*b)/(a*e-b*d);
		double y = (c*d-f*a)/(b*d-a*e);
		printf( "%.3f %.3f\n",x+1e-10,y+1e-10);
	}
	return 0;
}

Measured memory_bytes: 0
N,S=*$<
t=1
"RGB".chars{|c|t*=S.count c}
N.to_i.times{|i|0.upto(i/2){|j|a,b,c=S[i],S[i-j],S[i-j*2]
a!=b&&b!=c&&c!=a&&t-=1}}
p t

Measured memory_bytes: 14348
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        a: usize,
        b: usize,
    }
    println!("{}", 6 - a - b);
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl '\n'

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int , int> pi;

void solve()
{
	int x, y;
	cin>>x>>y;
	if(y % 2 == 0 && y >= 2*x && y <= 4*x) cout<<"Yes\n";
	else cout<<"No\n";
	
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	//cin>>t;
	t = 1;
	while(t--)
	{
		solve();
	}
	return 0;
}


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

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

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

ll n, m;
vll a;
V< V<int> > edges;

V<int> col;
void dfs(int i, int p, int c) {
    if (col[i] != -1) return;
    col[i] = c;
    for (int e: edges[i]) {
        if (e == p) continue;
        if (col[e] == -1) dfs(e, i, c);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    a.resize(n), edges.resize(n);
    for (ll i = 0; i < n; i++) cin >> a[i];
    for (ll i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        edges[x].emplace_back(y);
        edges[y].emplace_back(x);
    }

    if (n - m == 1) cout << 0 << '\n';
    else if (n > 2 * (m + 1)) cout << "Impossible\n";
    else {
        col.resize(n, -1);
        int c = 0;
        for (int i = 0; i < n; i++) {
            if (col[i] == -1) {
                dfs(i, -1, c);
                c++;
            }
        }

        vvll aset(c);
        for (int i = 0; i < n; i++) {
            aset[col[i]].emplace_back(a[i]);
        }

        ll ans = 0;
        priority_queue<ll> pq;
        for (int i = 0; i < c; i++) {
            sort(ALL(aset[i]));
            ans += aset[i][0];
            for (int j = 1; j < aset[i].size(); j++) {
                pq.push(-(aset[i][j]));
            }
        }

        for (int i = 0; i < 2 * (n - m - 1) - c; i++) {
            ans += -pq.top();
            pq.pop();
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 9600
#include<cstdio>
#include<cstdlib>
#include<algorithm>

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

using namespace std;

typedef long long ll;

const ll INF=1LL<<61;

// x0 に降りて、最後に x_last まで行くときの x 方向の総コスト
ll f(int x0,int x_last,int n,const int *x,const ll *x_sum){
	int p=lower_bound(x,x+n,x0)-x;
	ll res=0;
	res+=(ll)p*x0-x_sum[p];                // x0 より左にある家のコスト
	res+=(x_sum[n]-x_sum[p])-(ll)(n-p)*x0; // x0 より右にある家のコスト
	return 2*res-abs(x_last-x0);
}

void solve(int n,const int *x,int *x0,ll *ans){
	static int x_sorted[100000];
	rep(i,n) x_sorted[i]=x[i];
	sort(x_sorted,x_sorted+n);

	static ll x_sum[100001];
	rep(i,n) x_sum[i+1]=x_sum[i]+x_sorted[i];

	rep(i,n){
		int lo=x_sorted[0],hi=x_sorted[n-1];
		while(lo<hi){
			int mi1=(lo+hi)/2,mi2=mi1+1;
			if(f(mi1,x[i],n,x_sorted,x_sum)>f(mi2,x[i],n,x_sorted,x_sum)) lo=mi1+1; else hi=mi2-1;
		}
		x0[i]=lo;
		ans[i]=f(lo,x[i],n,x_sorted,x_sum);
	}
}

int main(){
	int n; scanf("%*d%*d%d",&n);
	static int x[100000],y[100000];
	rep(i,n) scanf("%d%d",x+i,y+i);

	// x0[i] := ( 最後に家 i を訪れるとしたときの、最適な降りる位置の x 座標 )
	// ans_x[i] := ( 最後に家 i を訪れるとして、x0[i] に降りたときの x 方向の総コスト )
	static int x0[100000],y0[100000];
	static ll ans_x[100000],ans_y[100000];
	solve(n,x,x0,ans_x);
	solve(n,y,y0,ans_y);

	static ll ans[100000];
	rep(i,n) ans[i]=ans_x[i]+ans_y[i];

	int i_ans=0;
	rep(i,n){
		if(ans[i_ans]>ans[i]
		|| ans[i_ans]==ans[i] && x0[i_ans]>x0[i]
		|| ans[i_ans]==ans[i] && x0[i_ans]==x0[i] && y0[i_ans]>y0[i]) i_ans=i;
	}
	printf("%lld\n%d %d\n",ans[i_ans],x0[i_ans],y0[i_ans]);

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

const int N = 2e5;
const int INF = 1e9;

int n, mx;
vector <int> g[N];
int col[N], d[N];
queue <int> q;

bool dfsC(int v, int pr, int x) {
	col[v] = x;
	
	if(x == 1) x = 2;
	else x = 1;
	
	for(int to : g[v]) {
		if(to == pr) continue;
		if(!col[to] && (dfsC(to, v, x))) {
			return 1;
		}
		else if(col[to] && col[v] == col[to]) {
			return 1;
		}
	}
	return 0;
}

int main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	fo(i, 1, n, 1) {
		fo(j, 1, n, 1) {
			char is;
			cin >> is;
			if(is == '1') {
				//cout << i <<' '<< j <<'\n';
				g[i].pb(j);
			}
		}
	}	
	if(dfsC(1, -1, 1)) {
	//	for(int i = 1; i <= n; ++i)
	//		cout << col[i] <<' ';
	//	cout << '\n';
		cout << -1;
		return 0;
	}
	//for(int i = 1; i <= n; ++i)
	//	cout << col[i] <<' ';
	//cout << "okkk\n";
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j)
			d[j] = INF;
		d[i] = 0;
		q.push(i);
		while(sz(q)) {
			int v = q.front();
			q.pop();
			for(int to : g[v]) {
				if(d[to] > d[v] + 1) {
					d[to] = d[v] + 1;
					mx = max(d[to], mx);
					q.push(to);
				}
			}
		}
	}
	cout << mx + 1;
	return 0;
}

Measured memory_bytes: 5120