akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};

// const int C ;
// const int M = 1000000007;

int N;
int a[100010];
int b[100010];

int count(int k) {
  int ans = 0;
  while (k != 0) {
    if ((k & 1) == 1) {
      ans++;
    }
    k = (k >> 1);
  }
  return ans;
}

int main () {
  cin >> N;
  for (auto i = 0; i < N; i++) {
    cin >> a[i];
    b[i] = (a[i] ^ (a[i] - 1));
    // cerr << b[i] << endl;
  }
  int x = 0;
  for (auto i = 0; i < N; i++) {
    x = x ^ a[i];
  }
  vector<int> V;
  if (x == 0) {
    cout << 0 << endl;
    return 0;
  }
  while (x != 0) {
    V.push_back(x & 1);
    x = (x >> 1);
  }
  bool visited[100];
  fill(visited, visited+100, true);
  int need = 0;
  for (auto i = 0; i < (int)V.size()-1; i++) {
    if (V[i+1] != V[i]) {
      need++;
      visited[i] = false;
    }
  }
  if (!V.empty()) {
    visited[(int)V.size()-1] = false;
    need++;
  }
  for (auto i = 0; i < N; i++) {
    visited[count(b[i])-1] = true;
  }
  for (auto i = 0; i < 100; i++) {
    if (!visited[i]) {
      cout << "-1" << endl;
      return 0;
    }
  }
  cout << need << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int A ,B ,C;
int main() {
	cin >> A >> B >> C;
  if (A * B < C  ) {
    cout << A*B << endl;
  }else if (A * B > C){
	cout << C << endl;
  }else{
    cout << A*B << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const ll INF = 100000000000000000;
typedef pair<ll, ll> P;

ll n, m, k, s, p, q, c, a, b;

vector<ll> G[100000];
ll isDanger[100000]; // 1 - s: danger / s+1: cannot move / 0: safe
ll d[100000];

ll dijkstra() {
  for (ll i = 0; i < n; i++) d[i] = INF;
  d[0] = 0;
  priority_queue<P, vector<P>, greater<P> > que;
  que.push(P(0, 0));
  while (!que.empty()) {
    P temp = que.top(); que.pop();
    ll cost = temp.first, num = temp.second;
    if (d[num] < cost) continue;
    for (ll i = 0; i < G[num].size(); i++) {
      ll to = G[num][i];
      if (isDanger[to] == s + 1) continue;
      ll newcost = cost;
      if (to == n - 1) ;
      else if (isDanger[to] == 0) newcost += p;
      else newcost += q;
      if (d[to] > newcost) {
        d[to] = newcost;
        que.push(P(newcost, to));
      }
    }
  }
  return d[n - 1];
}

int main() {
  scanf("%lld%lld%lld%lld%lld%lld", &n, &m, &k, &s, &p, &q);
  for (ll i = 0; i < n; i++) isDanger[i] = 0;
  priority_queue<P> que;
  for (ll i = 0; i < k; i++) scanf("%lld", &c), c--, isDanger[c] = s + 1, que.push(P(s + 1, c));
  for (ll i = 0; i < m; i++) scanf("%lld%lld", &a, &b), a--, b--, G[a].push_back(b), G[b].push_back(a);
  while (!que.empty()) {
    P temp = que.top(); que.pop();
    ll cost = temp.first, num = temp.second;
    if (isDanger[num] > cost) continue;
    cost--;
    for (ll i = 0; i < G[num].size(); i++) {
      ll to = G[num][i];
      if (isDanger[to] < cost) isDanger[to] = cost, que.push(P(cost, to));
    }
  }
  printf("%lld\n", dijkstra());
}



Measured memory_bytes: 13232
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

template<class T> vector<int> z_algorithm(const T& s) {
  vector<int> prefix(s.size());
  prefix[0] = s.size();
  int i = 1, len = 0;
  while (i < s.size()) {
    while (i + len < s.size() && s[i + len] == s[len]) ++len;
    prefix[i] = len;
    if (!len) { ++i; continue; }
    int j = 1;
    while (i + j < s.size() && prefix[j] < len - j) {
      prefix[i + j] = prefix[j];
      ++j;
    }
    i += j;
    len -= j;
  }
  return prefix;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  rep(i, n) {
    string str = s.substr(i);
    vector<int> prefix = z_algorithm(str);
    rep(j, str.size())
      chmax(ans, min(prefix[j], j));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int R, res;
  rd(R);
  res = 3*R*R;
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// {
//   int R, res;
//   rd(R);
//   res = 3R*R;
//   wt(res);
// }


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

int main()
{
	int a, b, c, x, y;
	std::cin >> a >> b >> c >> x >> y;
	long long all_each = a * x + b * y;
	long long all_half = 2 * c * std::max(x, y);
	int half, single, p;
	if (x < y)
	{
		half = x;
		single = y;
		p = b;
	}
	else
	{
		half = y;
		single = x;
		p = a;
	}
	long long mixed = 2 * c * half + p * (single - half);
	std::cout << std::min(std::min(all_each, all_half), mixed) << '\n';
	return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,g;
    cin >> n;
    g=n%10;
    if(g==2 || g==4 || g==5 || g==7 || g==9)
        cout << "hon";
    else if(g==0 || g==1 || g==6 || g==8)
        cout << "pon";
    else
        cout << "bon";
}


Measured memory_bytes: 3552
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int c[10] = {6,2,5,5,4,5,6,3,7,6};
vector<int> a;

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i,m) cin >> a[i];
  sort(a.rbegin(),a.rend());

  vector<int> dp(n+1,-1e9);
  dp[0] = 0;
  rep(mi,m){
    int d = a[mi];
    rep(i,n-c[d]+1){
      dp[i+c[d]] = max(dp[i+c[d]],dp[i]+1);
    }
  }
  vector<int> ans;
  while(n>0){
    rep(i,m){
      int d = a[i];
      while(n>=c[d] && dp[n]-1 == dp[n-c[d]]){
        ans.push_back(d);
        n -= c[d];
      } 
    }
  }
  sort(ans.rbegin(),ans.rend());
  rep(i,ans.size()) cout << ans[i]; cout << endl;
}

Measured memory_bytes: 384
import math


def submit():
    a, b, x = map(int, input().split())

    if x >= a*a*b/2:
        c = (2*x - a*a*b)/(a*a)
        if b == c:
            beta = 90
        else:
            beta = math.degrees(math.atan(a/(b-c)))
    else:
        d = 2*x/(a*b*b)
        beta = math.degrees(math.atan(d))
    
    print(90 - beta)
    

if __name__ == "__main__":
    submit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;

const int INF = 1001001001;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int main() {
    int h, w;
    cin >> h >> w;
    int ci, cj, di, dj;
    cin >> ci >> cj >> di >> dj;
    ci--; cj--; di--; dj--;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    VVI dp(h, VI(w, INF));
    dp[ci][cj] = 0;
    priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> q;
    q.emplace(0, ci, cj);
    while(!q.empty()) {
        auto t = q.top(); q.pop();
        int cost, x, y;
        tie(cost, x, y) = t;
        //cout << x << y << endl;
        if (cost != dp[x][y]) continue;
        rep(k, 4) {
            int ni = x + dx[k], nj = y+dy[k];
            if (!(0 <= ni && ni < h && 0 <= nj && nj < w)) continue;
            if (s[ni][nj] == '#') continue;
            if (cost < dp[ni][nj]) {
                dp[ni][nj] = cost;
                q.emplace(cost, ni, nj);
            }
        }
        for(int i = max(0, x - 2); i <= min(h-1, x + 2); i++) {
            for(int j = max(0, y - 2); j <= min(w-1, y + 2); j++) {
            //    cout << x << y << i << j << endl;
                if (s[i][j] == '#') continue;
                if (cost + 1 < dp[i][j]) {
                    dp[i][j] = cost + 1;
                    q.emplace(cost + 1, i, j);
                }
            }
        }
    }
    int ans = dp[di][dj];
    if (ans == INF) ans = -1;
    cout << ans << endl;
}


Measured memory_bytes: 9568
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=998244353;
const int INF=2e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int n,k;
    cin >> n >> k;
    vector<int> a(100010);
    vector<vector<P>> b(k);
    rep(i,n) {
        int s,t,c;
        cin >> s >> t >> c;
        b[c-1].push_back({s,t});
    }
    rep(i,k) {
        if (b[i].size()>0) {
            sort(b[i].begin(),b[i].end());
            ++a[b[i][0].first-1];
            rep(j,b[i].size()-1) {
                if (b[i][j].second<b[i][j+1].first) {
                    --a[b[i][j].second];
                    ++a[b[i][j+1].first-1];
                }
            }
            --a[b[i][b[i].size()-1].second];
        }
    }
    int ans=0;
    rep(i,100009) {
        a[i+1]+=a[i];
        ans=max(ans,a[i+1]);
    }
    cout << ans << endl;
     
    return 0;   
}

Measured memory_bytes: 4856
import java.util.*;
import java.io.*;

class Main{
  public static void main(String[] args) throws IOException {
    PrintWriter out = new PrintWriter(System.out);
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st  = new StringTokenizer(br.readLine());

    int h = Integer.parseInt(st.nextToken());
    int w = Integer.parseInt(st.nextToken());
    int m = Integer.parseInt(st.nextToken());

    HashSet<String> targets = new HashSet();
    int[] rows = new int[h];
    int[] cols = new int[w];
    int rowBest = 0, colBest = 0;
    for (int i=0; i<m; i++) {
      st  = new StringTokenizer(br.readLine());
      int a = Integer.parseInt(st.nextToken())-1;
      int b = Integer.parseInt(st.nextToken())-1;
      rows[a]++;
      cols[b]++;
      targets.add(a+","+b);
      rowBest = Math.max(rowBest, rows[a]);
      colBest = Math.max(colBest, cols[b]);
    }

    if ((rowBest!=0 && colBest==0) || (rowBest==0 && colBest!=0)) {
      out.println(rowBest==0?colBest:rowBest);
    }

    
    else {
      List<Integer> rs = new ArrayList();
      List<Integer> cs = new ArrayList();

      for (int i=0; i<h; i++) {
        if (rows[i]==rowBest) {
          rs.add(i);
        }
      }

      for (int i=0; i<w; i++) {
        if (cols[i]==colBest) {
          cs.add(i);
        }
      }
      int ans = colBest+rowBest-1;
      boolean flag = false;
      for (int rr: rs) {
        for (int cc: cs) { 
          if (!targets.contains(rr+","+cc)) {
            ans++;
            flag = true;
            break;
          }
        }
        if (flag) {
          break;
        }
      }

      out.println(ans);
    }

    out.close();
  }

}

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

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int f1 = a * b;
    int f2 = c * d;
    if(f1 > f2){
        cout << f1 << endl;
    }
    else{
        cout << f2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

typedef struct testimony {
  int x;
  int y;
} T;

int factorial(int x, int n) {
  if(n == 1) return x;
  return x * factorial(x, n - 1);
}
int digit_sum(int x, int n) {
  int result = 0;
  for(int i = 0; i < n; i++) {
    if(((x >> i) & 1) == 1) result++;
  }
  return result;
}

typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<T> testimonies[n];
  for(int i = 0; i < n; i++) {
    int a;
    cin >> a;
    for(int j = 0; j < a; j++) {
       int x, y;
       cin >> x >> y;
       T t = {x - 1, y};
       testimonies[i].push_back(t);
    }
  }
  int max = factorial(2, n);
  int result = 0;
  for(int i = 1; i < max; i++) {
    int dig = digit_sum(i, n);
    if(dig <= result) continue;
    bool noerror = true;
    for(int j = 0; j < n; j++) {
      if(((i >> j) & 1) == 0) continue;
      vector<T> v = testimonies[j];
      for(int k = 0; k < v.size(); k++) {
        int x = v[k].x;
        int y = v[k].y;
        if (((i >> x) & 1) != y) {
          noerror = false;
          break;
        }
      }
      if(!noerror) break;
    }
    if(noerror) {
      result = dig;
    }
  }
  cout << result << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int A, B, C; cin >> A >> B >> C;
    cout << (A + B >= C ? B + C : B * 2 + A+1) << endl;
}

Measured memory_bytes: 3592
#include <iostream>

int
main(int argc, char** argv) {
    int W, H, x, y;
    std::cin >> W >> H >> x >> y;

    double a = (double)W*H/2.0;
    int div = 0;
    if ( ((2 * x) == W) && ((2 * y) == H) ) {
        div = 1;
    }
    std::printf("%lf %d\n",a, div);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

  int pay = A + B;
  int possible = C - pay;
  if ( possible > 0 ) {
    std::cout << "No" << std::endl;
  } else {
    std::cout << "Yes" << std::endl;
  }

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<tuple<string,int,int>> t;
  
  for(int i=0;i<N;i++){
    string s;
    int a;
    cin >> s >> a;
    t.push_back(make_tuple(s,-1*a,i+1));
  }

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

  for(int i=0;i<N;i++){
    cout << get<2>(t.at(i)) << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<cmath>

using namespace std;

int main(void){

    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int total = a + b + c;

    int temp = max({a, b, c});
    total -= temp;

    temp *= pow(2, k);

    total += temp;

    cout << total << endl;



    return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int v[] = new int[n];
    int c[] = new int[n];
    int ans = 0;
    for(int i=0 ; i<n ; i++){
      v[i] = sc.nextInt();
    }
    for(int i=0 ; i<n ; i++){
      c[i] = sc.nextInt();
    }

    for(int i=0 ; i<n ; i++){
      if(v[i]>c[i]){
        ans = ans + v[i] - c[i];
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23252
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
b=[]
sum=0
for i in range(m):
    b.append(list(map(int,input().split())))
b.sort(key=lambda x: x[1])
B=len(b)
b1=b[B-1][0]
b2=b[B-1][1]
b3=0
for i in range(n):
    if a[i]<b2 and b3==0:
        sum+=b2
        b1-=1
    else:
        sum+=a[i]
    if b1==0:
        B-=1
        if B==0:
            b3=1
        b1=b[B-1][0]
        b2=b[B-1][1]
print(sum)

Measured memory_bytes: 32976
/*
Author: Babin Dutta
*/
 
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define inf 1e18
#define mm 998244353
#define ft first
#define se second
#define pp pair<ll,ll>
 
ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

void solve(){
	int a,b; cin>>a>>b;
	cout<<a*b<<endl;
}
 
int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 3640
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    Array.Sort(nums);
    long answer = 0;
    for(int i = 1; i < n-1; i++)
    {
      answer += Math.Abs(nums[i]);
    }
    if(nums[0] > 0 || nums[n-1] < 0)
    {
      answer -= nums[0];
      answer += nums[n-1];
    }else
    {
      answer += Math.Abs(nums[0]) + Math.Abs(nums[n-1]);
    }
		Console.WriteLine(answer);

    long minusCount = 0;
    long minusMemo = nums[n-1];
    long plusMemo = nums[0];
    
    for(int i = 1; i < n-1; i++)
    {
      if(nums[i] >= 0) break;
      minusCount++;
    }

    for(int i = 0; i < minusCount; i++)
    {
      Console.WriteLine(minusMemo+" "+nums[i+1]);
      minusMemo -= nums[i+1];
    }
    for(int i = 0; i < n-2-minusCount; i++)
    {
      Console.WriteLine(plusMemo+" "+nums[minusCount+1+i]);
      plusMemo -= nums[minusCount+1+i];
    }
    Console.WriteLine(minusMemo+" "+plusMemo);
	}
}

Measured memory_bytes: 30280
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int maxm = 100100;
const int maxn = 300100;
int m;
namespace BIT
{
	int v[maxm];
	int lowbit(int x)
	{
		return x & -x;
	}
	void add(int pos, int a)
	{
		for(int i = pos; i <= m; i += lowbit(i))
			v[i] += a;
	}
	int sum(int pos)
	{
		int ans = 0;
		for(int i = pos; i; i -= lowbit(i))
			ans += v[i];
		return ans;
	}
}
struct segment
{
	int l, r;
	bool operator<(const segment &a) const
	{
		return r - l + 1 < a.r - a.l + 1;
	}
}s[maxn];
int n;
int main()
{
	std::ios::sync_with_stdio(false);
	using namespace BIT;
	cin >> n >> m;
	for(int i = 1; i <= n; i ++)
		cin >> s[i].l >> s[i].r;
	sort(s + 1, s + n + 1);
	int j = 1;
	for(int i = 1; i <= m; i ++)
	{
		for(; j <= n && s[j].r - s[j].l + 1 < i; j ++)
		{
			add(s[j].l, 1);
			add(s[j].r + 1, -1);
		}
		int ans = 0;
		for(int j = 0; j <= m; j += i)
			ans += sum(j);
		cout << ans + n - j + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::cmp;
use std::f64::consts;

fn main() {
    let n: i32 = read();
    let mut vec: Vec<i32> = Vec::new();

    let mut n_six = 6;
    while n_six <= n {
        vec.push(n_six);
        n_six *= 6;
    }

    let mut n_nine = 9;
    while n_nine<=n{
        vec.push(n_nine);
        n_nine *= 9;
    }

    vec.sort();

    let mut ans = [0; 100001];

    for j in 1..n+1 {
        let mut min = ans[(j-1) as usize]+1;
        for &v in vec.iter() {
            if j >= v {
                min = cmp::min(min, ans[(j-v) as usize]+1);
            }
        }
        ans[j as usize] = min;
    }

    println!("{:?}", ans[n as usize]);
}

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

// 最大公約数
fn gcd(a: i32, b: i32) -> i32 {
    match b {
        0 => a,
        _ => gcd(b, a % b)
    }
}

// 最小公倍数
fn lcm(a: i32, b: i32) -> i32 {
    a * b / gcd(a, b)
}

// 階乗
fn kaijou(n: i32)->i32 {
    if n == 1 {
        return n;
    }
    return n * kaijou(n-1);
}

Measured memory_bytes: 4732
#include <iostream>
#include <vector>
using namespace std;

typedef long long ll;

const ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

mint dp[64][2][2] = {};

int main(){
    ll L,R;
    cin >> L >> R;
    int NR = 0,NL = 0;
    for(int i=0;i<63;i++){
        if(R&(1LL<<i)) NR = i;
        if(L&(1LL<<i)) NL = i;
    }
    auto flagR = [&](int i){
        return R&(1LL<<i); 
    };
    auto flagL = [&](int i){
        return L&(1LL<<i);
    };
    for(int i=NR;i>=0;i--){
        if(NL<=i){
            bool y = (i!=NR),x = (i!=NL);
            dp[i][y][x] += 1;
        }
        if(i==0) continue;
        for(int y=0;y<2;y++) for(int x=0;x<2;x++){
            for(int a=0;a<2;a++) for(int b=0;b<2;b++){
                if(a<b) continue;
                bool ny = true,nx = true;
                if(a==1 && !flagR(i-1) && y==0) continue;
                if(a==1 && flagR(i-1) && y==0) ny = false;
                if(a==0 && !flagR(i-1) && y==0) ny = false;
                if(b==0 && flagL(i-1) && x==0) continue;
                if(b==1 && flagL(i-1) && x==0) nx = false;
                if(b==0 && !flagL(i-1) && x==0) nx = false;
                dp[i-1][ny][nx] += dp[i][y][x];
            }
        }
    }
    mint ans = 0;
    for(int i=0;i<2;i++) for(int j=0;j<2;j++){
        ans += dp[0][i][j];
    }
    cout << ans.x << endl;
}

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

int powercount(int x, int N) {
  int counter = 0;
  while(x < N) {
    counter++;
    x *= 2;
  }
  return counter;
}

int main() {
  double N, K;
  cin >> N >> K;
  // 表を出し続けて得点をK以上にすれば勝ち
  double possibility = 0;
  // 出た目それぞれについて調べる
  for (int i=1; i<=N; i++) {
    possibility += 1/N*pow(1.0/2.0, powercount(i, K));
  }
  cout << fixed << setprecision(12);
  cout << possibility << endl;
}

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

int main() {
	
	int n, k; cin >> n >> k;
	vector<bool> have(n, false);
	for (int i = 0; i < k; i++) {
		int d; cin >> d;
		for (int j = 0; j < d; j++) {
			int a; cin >> a;
			have[--a] = true;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (!have[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
typedef long long ll;

int main(void){
    ll n, a[100010];
    cin >> n;
    ll k = 0, sm = 0, mn = 1e9;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sm += abs(a[i]);
        mn = min(mn, abs(a[i]));
        if (a[i] <= 0) k++;
    }
    
    if (k % 2 == 0) cout << sm << endl;
    else cout << sm - 2*mn << endl;
    
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,ans;
string s="-+",t;
int main()
{
	getline(cin,t);
	a=t[0]-'0',b=t[1]-'0',c=t[2]-'0',d=t[3]-'0';
    for(int i=0;i<=1;i++)
	{
		for(int j=0;j<=1;j++)
		{
			for(int k=0;k<=1;k++)
			{
				ans=a;
				if(i==1)
				ans+=b;
				if(i==0)
				ans-=b;
				if(j==1)
				ans+=c;
				if(j==0)
				ans-=c;
				if(k==1)
				ans+=d;
				if(k==0)
				ans-=d;
				if(ans==7)
				{

					cout<<a<<s[i]<<b<<s[j]<<c<<s[k]<<d<<"=7";
					return 0;
				}
			}
		}
	}
	return 0;
}

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

int main()
{
  ll N, K;
  cin >> N >> K;
  if (K % 2 != 0) {
    ll ans = pow(N / K, 3);
    cout << ans << endl;
    return 0;
  }
  ll ans = pow(N / K, 3);
  ans += pow((N - (K / 2)) / K + 1, 3);
  if (N * 2 < K) {
    ans = 0;
  }
  cout << ans << endl;
}


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

int main()
{
    int n, m, k, ans = 0;
    ll a[300000], b[300000];

    cin >> n >> m >> k;
    rep(i, n) cin >> a[i + 1], a[i + 1] += a[i];
    rep(i, m) cin >> b[i + 1], b[i + 1] += b[i];

    for (int i = 0, j = m; i <= n; i++)
    {
        if (a[i] > k)
            break;
        while (a[i] + b[j] > k)
            j--;

        ans = max(i + j, ans);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6660
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <string>
#include <fstream>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  VE V;
  V.PB(A);
  V.PB(B);
  V.PB(C);
  sort(V.begin(),V.end());
  A=V[0];B=V[1];C=V[2];
  int ans=0;
  if((B-A)%2){
    ans++;
    B++;C++;
  }
  ans+=(B-A)/2;
  ans+=C-B;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def ap(a) a.each{|u| p u} end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
n,m =inp
t = inp
ind = t.index(1)
pt = m-1
p (n+pt-2)/pt

Measured memory_bytes: 8724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const ll INF = 1e18;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

const ll MAX_V = 53;
const ll MAX_S = 2509;

struct edge{
    ll to, coin, cost;
    edge(ll to, ll coin, ll cost):to(to), coin(coin), cost(cost){}
};

struct Data{
    int vertex, money;
    ll dist;
    Data(int vertex, int money, ll dist):vertex(vertex), money(money),dist(dist){}
    bool operator<(const Data& a) const {
        return dist > a.dist;
    }
};

vector<edge> g[MAX_V];
ll dp[MAX_V][MAX_S+5];

int main(){
    ll n, m, s;
    cin >> n >> m >> s;
    rep(i,m){
        ll u, v, a, b;
        cin >> u >> v >> a >> b;
        u--;v--;
        g[u].emplace_back(v,a,b);
        g[v].emplace_back(u,a,b);
    }
    vector<ll> c(n), d(n);
    rep(i,n) cin >> c[i] >> d[i];
    repn(i,n)repn(j,MAX_S) dp[i][j] = INF;
    s = min(s, MAX_S);
    priority_queue<Data> q;
    dp[0][s] = 0;
    
    q.emplace(0,s,0);
    while(!q.empty()){
        Data p = q.top();
        q.pop();
        ll vertex = p.vertex;
        ll money = p.money;
        ll dist = p.dist;
        if(dp[vertex][money] < dist) continue;
      

        ll nmoney = min(money+c[vertex], MAX_S);
        if(dp[vertex][nmoney] > dp[vertex][money] + d[vertex]){
            dp[vertex][nmoney] = dp[vertex][money] + d[vertex];
            q.emplace(vertex, nmoney, dp[vertex][nmoney]);
        }

        for(auto e : g[vertex]){
            ll t = e.to;
            ll m = money - e.coin;
            if(m < 0) continue;
            if(dp[t][m] > dp[vertex][money] + e.cost){
                dp[t][m] = dp[vertex][money] + e.cost;
                q.emplace(t, m, dp[t][m]);
            }
        }

        
    }
     srep(i,1,n){
       ll ans = INF;
       repn(j,MAX_S){
         chmin(ans, dp[i][j]);
       }
       cout << ans << endl;
     }
}

Measured memory_bytes: 6340
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
vector<int> i;
vector<int> u;
vector<int> o;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double a=0,b,c,d=0,e=0,f=0,g;
  string s;
  cin >>a;
  for(int n=0;n<a;n++){
    cin >>b;
    d+=1/b;
  }
  d=1/d;
  cout <<fixed<<d<<'\n';
  return (0);
}


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

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

int main() {
  int K, X;
  cin >> K >> X;
  for(int i = (X - K + 1); i < X + K; i++) {
    if (i < X + K - 1) {
      cout << i << ' ';
    } else {
      cout << i;
    }
  }
}


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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

ll n, m;

void read(){
	cin>>n>>m;
}

ll check(ll x, ll y){
	ll tot = 0;
	while (x){
		tot += x % y;
		x /= y;
	}
	return tot;
}

void solve(){
	ll b = (int)(sqrt(n + 0.5)) + 1;
	for(ll i = 2; i <= b; i++){
		if (check(n, i) == m){
			cout<<i<<endl;
			return ;
		}
	}
	ll ans = -1;
	for(ll x = 1; x <= b && x <= m; x++){
		ll y = m - x;
		if (n >= m + x && (n - y) % x == 0){
			ll z = (n - y) / x;
			if (y < z && (ans == -1 || ans > z)){
			//	cout<<x<<' '<<y<<' '<<z<<' '<<n<<' '<<m<<endl;
				ans = z;
			}
		}
	}
	if (n == m && ans == -1)
		ans = n + 1;
	cout<<ans<<endl;
}

void printans(){

}
	

int main(){
	int T = 1;
//	cin>>T;
	while(T--){
		read();
		solve();
		printans();
	}
	return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pld pair<long double, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define ff first
#define ss second
#define SZ(x) ((int)(x).size())
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll a, b, c, d;

void read(){
    cin >> a >> b >> c >> d;
}

void solve(){
    read();
    ll ans = max({a*c, a*d, b*c, b*d});
    cout << ans;
}

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

Measured memory_bytes: 3648
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 $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")
    };
}

fn main() {
    input! {
    n: usize
    }
    let ret = calc(n);
    if ret == 0 {
        println!(":(")
    } else {
        println!("{}", ret);
    }
}

fn calc(n: usize) -> usize {
    let cand_upper = f32::ceil((n as f32)/(1.08)) as usize;
    let cand_lower = f32::floor((n as f32)/(1.08)) as usize;
    if ((cand_upper as f32) * 1.08) as usize == n {cand_upper}
    else if ((cand_lower as f32) * 1.08) as usize == n {cand_lower}
    else {0}
}

Measured memory_bytes: 4352
#include<stdio.h>

#define MAX 100000

int parent(int i){
    return i/2;
}

int left(int i){
    return 2*i;
}

int right(int i){
    return 2*i+1;
}


int main(){
    int H, A[MAX+1];
    int i;

    scanf("%d", &H);
    
    for(i=1; i<H+1; i++){
        scanf("%d", &A[i]);
    }

    for(i=1; i<H+1; i++){
        printf("node %d: key = %d, ", i, A[i]);

        if(parent(i) > 0){
            printf("parent key = %d, ", A[parent(i)]);
        }
        if(left(i) < H+1){
            printf("left key = %d, ", A[left(i)]);
        }
        if(right(i) < H+1){
            printf("right key = %d, ", A[right(i)]);
        }
        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 2044
S = str(input())

R=[len(s) for s in S.split('L') if len(s)>0]
L = [len(s) for s in S.split('R') if len(s) > 0]
R.append(0)
L.append(0)

targ = R[0] - 1
j = 0
fl=1

for i in range(len(S)):
    if i == targ:
        if fl>0:
            pr = (R[j] + (R[j] % 2)) / 2 + (L[j] - (L[j] % 2)) / 2
            targ=targ+1
        else:
            pr = (L[j] + (L[j] % 2)) / 2 + (R[j] - (R[j] % 2)) / 2
            targ = targ+L[j]+R[j+1]-1
            j = j + 1
        print(int(pr), end=' ')
        fl=-fl
    else:
        print(0, end=' ')


Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,B;
  cin >> N >> A >> B;
  int aplan;
  aplan = N * A;
  
  if (aplan >= B){
    cout << B << endl;
  }else{
    cout << aplan << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

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

  for (int i=0; i<=n; i++) {
    int cnt = 0;
    int tmp = i;

    while (tmp>0) cnt+=tmp%6, tmp/=6;
    tmp = n-i;
    while (tmp>0) cnt+=tmp%9, tmp/=9;

    ans = min(ans,cnt);
  }

  cout << ans << endl;
}

Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(){
    string a, b;
    cin >> a >> b;
    string c = a+ b;
    int output = stoi(c);

    bool flag = false;
    for (int i = 0; i < output; i++)
    {
        if(i*i == output){
            flag = true;
        }
    }
    if(flag == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	int a, b, c, n;
	string s, s1, s2, s3;
  cin>>a>>b;
  cout<<(a-1)*(b-1)<<endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,q,ans=1e9,t[2005],a[2005],b[2005],c[2005];
void cal(int m)
{
	int i,l=1,r=1;
	b[0]=0;
	while(l<=n)
	{
		c[0]=0;
		while(a[l]<m&&l<=n)l++;
		r=l;
		while(a[r]>=m&&r<=n)r++;
		for(i=l;i<r&&i<=n;i++)
			c[++c[0]]=a[i];
		if(c[0]>=k)
		{
			sort(c+1,c+c[0]+1);
			for(i=1;i<=c[0]-k+1;i++)
				b[++b[0]]=c[i];
		}
		l=r;
	}
	sort(b+1,b+b[0]+1);
	if(b[0]>=q)ans=min(ans,b[q]-b[1]);
}
int main()
{
	int i;
	cin>>n>>k>>q;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		t[i]=a[i];
	}
	sort(t+1,t+n+1);
	for(i=1;i<=n;i++)
		cal(t[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3672
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::Read;
#[allow(dead_code)]
fn getline() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok().unwrap();
    ret
}
fn get_word() -> String {
    let mut stdin = std::io::stdin();
    let mut u8b: [u8; 1] = [0];
    loop {
        let mut buf: Vec<u8> = Vec::with_capacity(16);
        loop {
            let res = stdin.read(&mut u8b);
            if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        if buf.len() >= 1 {
            let ret = String::from_utf8(buf).unwrap();
            return ret;
        }
    }
}

#[allow(dead_code)]
fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn tbl(s: &[u8]) -> Vec<i32> {
    let n = s.len();
    let mut ret = vec![0; n + 1];
    for i in 0 .. n {
        let tmp = (s[i] - b'A') as i32 + 1;
        ret[i + 1] = (ret[i] + tmp) % 3;
    }
    ret
}

fn solve() {
    let s: Vec<u8> = get_word().bytes().collect();
    let t: Vec<u8> = get_word().bytes().collect();
    // A = 1, B = 2, mod 3
    let mut acc1 = tbl(&s);
    let mut acc2 = tbl(&t);
    let q = get();
    for _ in 0 .. q {
        let a = get::<usize>() - 1;
        let b: usize = get();
        let c = get::<usize>() - 1;
        let d: usize = get();
        let sum1 = (acc1[b] + 2 * acc1[a]) % 3;
        let sum2 = (acc2[d] + 2 * acc2[c]) % 3;
        println!("{}", if sum1 == sum2 { "YES" } else { "NO" });
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8828
#include <iostream>

using namespace std;

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


Measured memory_bytes: 3100
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(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())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
int modpow(int x, int k) { int a = 1;
  while (k > 0) {
    if (k & 1) a = (1LL*a*x) % MOD;
    x = (1LL*x*x) % MOD;
    k >>= 1;
  }
  return a;
}

const int B = 12345;
//const int B = 100;
int pB[(int)(1e6+1)], pBinv[(int)(1e6+1)];
struct Hash {
  string S;
  int X[(int)(1e6+1)];
  Hash(string s) : S(s) {
    rep(i, S.length()) X[i] = (1LL*(S[i]-'a')*pB[i])%MOD;
    rep(i, (int)S.length()-1) X[i+1] =(X[i+1]+ X[i])%MOD;
  }
  int f(int l, int r) {
    int s = (X[r]+MOD-(l>0?X[l-1]:0))%MOD;
    return (1LL*s*pBinv[l])%MOD;
  }
};

string S;
int N;
Hash hs(""), hs_rev("");
void go(int len) {
  int T = hs.f(0, len-1);
  int revT = hs_rev.f(N-len, N-1);
  int p = 0;
  bool flip = false;
  for (; p+len-1<N; p+=len-1) {
    if (!flip && T != hs.f(p, p+len-1)) return;
    if ( flip && revT != hs.f(p, p+len-1)) return;
    flip ^= 1;
  }
  int rest = N-p;
  if (!flip && hs.f(0, rest-1) != hs.f(p, N-1)) return;
  if ( flip && hs_rev.f(N-len, N-len+rest-1) != hs.f(p, N-1)) return;
  cout << len << "\n";
  exit(0);
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  cin >> S;
  pB[0] = 1; for (int i=1; i<=N; i++) pB[i] = (1LL*pB[i-1]*B)%MOD;
  int inv = modpow(B, MOD-2);
  pBinv[0] = 1; for (int i=1; i<=N; i++) pBinv[i] = (1LL*pBinv[i-1]*inv)%MOD;

  hs = Hash(S);
  reverse(all(S));
  hs_rev = Hash(S);
  reverse(all(S));
  for (int i=2; i<=N; i++) go(i);
  return 0;
}



Measured memory_bytes: 26436
#include <iostream>
using namespace std;
 
int main(void) {
 
    int n;
    cin >> n;
 
    int b,f,r,v;
    int a[4][3][10] = {};
 
    for(int i=0;i<n;i++) {
        cin >> b >> f >> r >> v;
        a[b-1][f-1][r-1] += v;
    }
 
    for(int i=0;i<4;i++) {
        for(int j=0;j<3;j++) {
            for(int k=0;k<10;k++) {
                cout << " " << a[i][j][k];
            }
            cout << endl;
        }
        if(i != 3) {
            cout << "####################" << endl;
        }
 
    }
 
    return 0;
}	

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

int main() {
    for(int i=0; ; i++) {
        int x, y; cin >> x >> y;
        if(x == 0 && y == 0) break;
        cout << min(x, y) << " " << max(x, y) << endl;
    }
}


Measured memory_bytes: 3080
A,B,C,K=[int(s) for s in input().split()]

def solve(A,B,C,K):
    remain=K
    answer=0
    answer+=1*min(remain,A)
    remain-=A
    if remain<=0:
        return answer
    remain-=B
    if remain<=0:
        return answer
    answer-=remain
    return answer

out=solve(A,B,C,K)
print(out)

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;

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

    int A[3][3], N;
    static bool isok[3][3];
    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 3; ++j)
            cin >> A[i][j];
    cin >> N;

    static int hcnt[3], vcnt[3], ncnt[2];
    for (int i = 0; i < N; ++i) {
        int b;
        cin >> b;
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (A[j][k] == b && !isok[j][k]) {
                    isok[j][k] = true;
                    hcnt[j]++;
                    vcnt[k]++;
                    if (j == k)
                        ncnt[0]++;
                    if (j + k == 2)
                        ncnt[1]++;
                }
            }
        }
    }

    for (int i = 0; i < 3; ++i) {
        if (hcnt[i] == 3 || vcnt[i] == 3) {
            cout << "Yes" << endl;
            return 0;
        }
        if (i < 2 && ncnt[i] == 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define lson l,mid,p<<1
#define rson mid+1,r,p<<1|1
#define pb push_back
#define ll long long
using namespace std;
const int inf=1e9;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
char s[55];
int main(){
	//ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n>>s;
	int ans=0;
	for(int i=0;i+2<n;i++){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256