akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=500010;

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

	int n,m;
	cin>>n>>m;
	if(n==1&&m==0){cout<<"0";return 0;}
	vector<int> ar(n,-1);
	int f=1;

	for(int i=0;i<m;++i)
    {
        ll idx,c;
        cin>>idx>>c;
        --idx;
        if(ar[idx]==-1){ar[idx]=c;}
        if(ar[idx]!=c){f=0;}
    }

    if(ar[0]==0&&n!=1){f=0;}
    if(f==0){cout<<"-1";return 0;}

    if(ar[0]==-1){ar[0]=1;}
    for(int i=0;i<n;++i)
    {
        if(ar[i]==-1){ar[i]=0;}
        cout<<ar[i];
    }

	return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include "/Users/student/Documents/Sublime/stdc++.h"

using namespace std;

double arr[4*10000][2];

int main() {
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> arr[i][0] >> arr[i][1];
    }
    if(n == 2){
        double ans =  sqrt((arr[0][0]-arr[1][0])*(arr[0][0]-arr[1][0])+(arr[0][1]-arr[1][1])*(arr[0][1]-arr[1][1]));
        printf("%.9f", ans);
    }
    else{
        double ans = 0, total = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(i != j){
                    total += sqrt((arr[i][0]-arr[j][0])*(arr[i][0]-arr[j][0])+(arr[i][1]-arr[j][1])*(arr[i][1]-arr[j][1]))/n;
                }
            }
            ans += total;
            total = 0;
        }
        printf("%.9f", ans);
    }

}



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

int main() {
  int N[3], K;
  cin >> N[0] >> N[1] >> N[2] >> K;
  int max = 0;
  for (int i = 0; i < 3; i++) {
    if (N[i] > max) { max = N[i]; }
  }

  for (int i = 0; i < 3; i++) {
    if (max == N[i]) {
      for (int j = 0; j < K; j++) { N[i] *= 2; }
      break;
    }
  }
  int ans = 0;
  for (int i = 0; i < 3; i++) {
    ans += N[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main(){
    int h, w;
    cin >> h >> w;

    vector<vector<char>> a(h, vector<char>(w));
    queue<pair<int,int>> q;
    vector<vector<int>> d(h, vector<int>(w, INF));

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> a[i][j];
            if(a[i][j] == '#'){
                q.push({i,j});
                d[i][j] = 0;
            }
        }
    }

    vector<int> dx = {1, 0, -1, 0};
    vector<int> dy = {0, 1, 0, -1};

    while(q.empty() == false){
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        for(int i=0; i<4; i++){
            if(0 <= x + dx[i] && x + dx[i] < h
            && 0 <= y + dy[i] && y + dy[i] < w
            && d[x+dx[i]][y+dy[i]] == INF){
                d[x+dx[i]][y+dy[i]] = d[x][y] + 1;
                q.push({x+dx[i], y+dy[i]});
            }
        }
    }

    int ans = 0;
    for(int x=0; x<h; x++){
        for(int y=0; y<w; y++){
            ans = max(ans, d[x][y]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16072
import java.math.BigInteger;

public class Main {

  private static void solve() {
    long a = nl();
    long b = nl();
    long c = nl();

    BigInteger y =
        BigInteger.valueOf(4).multiply(BigInteger.valueOf(a)).multiply(BigInteger.valueOf(b));
    // a + b + 2√ab < c
    // c-b-a > 2√ab
    BigInteger x = BigInteger.valueOf(c - (a + b));
    if (x.compareTo(BigInteger.valueOf(0)) >= 0 && x.multiply(x).compareTo(y) > 0) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }


  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 23380
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define oo 0x3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	int a, b, c;
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << ' ' << ' ' << b << ' ' << c;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int N,A,B;
	scanf("%d %d %d",&N,&A,&B);
	int plan1=N*A;
	int plan2=B;
	if(plan1<plan2)
	{
		printf("%d",plan1);
	}
	else
	{
		printf("%d",plan2);
	}
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	string s; cin >> s;
	// いれかわる数
	char pre = s.front();
	int ans = 0;
	FOR(i, 0, SZ(s)) {
		if (pre == s[i])continue;
		else pre = s[i], ans++;
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 512
import java.math.*;
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String s = sc.next();
        if(s.contains("AB")||s.contains("BA")){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
	}
}

Measured memory_bytes: 21460
import java.util.*;

class Main{
	static int a;
	static int b;
	static int c;
	static int d;
	static int e;
	static int p;
	static double f;
	static int g;
	static int h;
	static int i;
	static int j;
	static int k;
	static int l;
	static int m;
	static int o;
	static int q;
	static double r;
	static int s;
	static int t;
	static int u;
	static double x;
	static double y;
	private static Scanner sc;
	public static void main(String[]agrs){
		sc=new Scanner(System.in);
		r =sc.nextDouble();
		x=r*r*(Math.PI);
		y=2*r*(Math.PI);
		System.out.printf("%f %f",x,y);
		
		
	}
}

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

using namespace std;

int main(int argc, char** argv) {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }

  int fst = -1;
  int snd = -1;

  for (int i = 0; i < n; ++i) {
    if (fst < a[i]) {
      snd = fst;
      fst = a[i];
    } else if (snd < a[i]) {
      snd = a[i];
    }
  }

  for (int i = 0; i < n; ++i) {
    if (a[i] == fst) {
      cout << snd << endl;
    } else {
      cout << fst << endl;
    }
  }
}


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

#include <string>
#include <vector>
#include <algorithm>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

llong greedy(vector<llong> A, llong x) {
   int N = A.size();
   llong res = 0;
   for (int i = 1; i < N; ++i) {
      llong d = (A[i] + A[i-1]) - x;
      if (d > 0) {
         res += d;
         llong t = min(d, A[i]);
         A[i] -= t;
         A[i-1] -= d-t;
      }
   }
   return res;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(NULL);

   int N;
   llong x;
   cin >> N >> x;
   vector<llong> A(N);
   for (int i = 0; i < N; ++i)
      cin >> A[i];

   llong res = greedy(A, x);

/*
   reverse(A.begin(), A.end());
   res = min(res, greedy(A, x));
*/
   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll a,b,c;
  std::cin>>a>>b>>c;
  ll k;
  std::cin>>k;

  ll cnt=0;

  while(a>=b){
    cnt++;
    b*=2;
  }
  while(b>=c){
    cnt++;
    c*=2;
  }

  if(cnt<=k)std::cout<<"Yes\n";
  else std::cout<<"No\n";

  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;
int n, m;

int main(){
	IOS
	cin >> n >> m;
	int nugas=0;
	while(m--){
		int a;
		cin >> a;
		nugas+=a;
	}
	if(nugas>n){
		cout << -1 << '\n'; return 0;
	}
	if(nugas==n){
		cout << 0 << '\n'; return 0;
	}
	cout << n-nugas << '\n';
}

Measured memory_bytes: 3604
X0,Y0,X1,Y1 = (int(x) for x in input().split())
s = ""
for i in range(Y1-Y0):
    s += "U"
for i in range (X1-X0):
    s += "R"
for i in range(Y1-Y0):
    s += "D"
for i in range(X1-X0+1):
    s += "L"
for i in range(Y1-Y0+1):
     s += "U"
for i in range (X1-X0+1):
    s += "R"
s += "DR"
for i in range(Y1-Y0+1):
    s += "D"
for i in range(X1-X0+1):
    s += "L"
s += "U"
print(s)

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

int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for(int x = 0; x <= K; ++x){
    for(int y = 0; y <= K; ++y){
      int z = S - x - y;
      if(0 <= z && z <= K){
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}

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

void solve()
{
	int k,ans,val;
	cin>>k;
	queue<int> q;
	for(int i=1;i<10;i++)
		q.push(i);
	while(k--)
	{
		ans=q.front();
		q.pop();
		//cout<<k<<" "<<ans<<endl;
		val=ans;
		int x=val%10;
		if(x>0)	q.push(val*10+x-1);
		q.push(val*10+x);
		if(x<9)	q.push(val*10+x+1);
	}
	cout<<ans<<endl;
}

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

Measured memory_bytes: 1792
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
max_x = max(x)
min_y = min(y)
Z = min(min_y, Y)
if X < Z and max_x < Z:
	print("No War")
else:
	print("War")


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

ll powmod(ll a, ll e) {
  ll sum = 1;
  ll cur = a;
  while (e > 0) {
    if (e % 2) {
      sum = sum * cur % mod;
    }
    cur = cur * cur % mod;
    e /= 2;
  }
  return sum;
}

const int N = 123456;
ll fact[N];

ll comb(int x, int y) {
  if (y < 0 || y > x) {
    return 0;
  }
  return fact[x] * powmod(fact[y] * fact[x - y] % mod, mod - 2) % mod;
}

void init(void) {
  fact[0] = 1;
  REP(i, 1, N) {
    fact[i] = fact[i - 1] * i % mod;
  }
}

// n + 1, dup elems at x and y
void calc(int n, int x, int y) {
  REP(k, 1, n + 2) {
    ll tot = comb(n + 1, k);
    tot -= comb(n - y + x, k - 1);
    tot += mod;
    tot %= mod;
    cout << tot << endl;
  }
}

int main(void){
  init();
  int n;
  cin >> n;
  VI a(n + 1);
  int dup = -1;
  set<int> seen;
  REP(i, 0, n + 1) {
    cin >> a[i];
    if (seen.count(a[i])) {
      dup = a[i];
    }
    seen.insert(a[i]);
  }
  VI pos;
  REP(i, 0, n + 1) {
    if (a[i] == dup) {
      pos.push_back(i);
    }
  }
  assert (pos.size() == 2);
  calc(n, pos[0], pos[1]);
}


Measured memory_bytes: 7296
gets.to_i
mons = gets.split.map(&:to_i)
heros = gets.split.map(&:to_i)
ans = 0

heros.each_with_index do |hero, i|
  if mons[i] >= hero
    ans += hero
    next
  end

  ans += mons[i]
  hero -= mons[i]

  if hero >= mons[i+1]
    ans += mons[i+1]
    mons[i+1] = 0
  else
    ans += hero
    mons[i+1] -= hero
  end
end

puts ans

Measured memory_bytes: 24648
#include <stdio.h>

int		main(void)
{
	int	a, b;
	scanf("%d %d", &a, &b);

	if (a < b)
		printf("%s", "a < b\n");
	else if (a > b)
		printf("%s", "a > b\n");
	else if (a == b)
		printf("%s", "a == b\n");

	return (0);
}



Measured memory_bytes: 2116
-- https://atcoder.jp/contests/abc175/submissions/15992319 の改変
import qualified Data.Vector.Unboxed as V
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

main = do
  [n,k] <- getIntList
  p <- V.fromList . map (+(-1)) <$> getIntList
  c <- V.fromList <$> getIntList
  let acc i = tail $ scanl' (+) 0 $ map ((c V.!).(p V.!)) $ takeWhile (/=i) (iterate (p V.!) (p V.! i)) ++ [i] -- O(n)
      ans i = -- O(n)
        if val > 0
          then
            if rem /= 0
              then num * val + maximum (take (fromIntegral rem) list)
              else (num-1) * val + maximum list
          else maximum list
        where list = acc i
              val = last list
              len = fromIntegral $ length list
              num = k `div` len
              rem = k `mod` len
  print $ maximum $ map ans [0..n-1] -- n * O(n) = O(n^2)


Measured memory_bytes: 6028
#include <bits/stdc++.h>
using namespace std;
char str[200];
int main()
{
	fgets(str,199,stdin);
	int l(strlen(str));
	for(register char *p=str;*p;++p)
		if(*p=='C')
			for(register char *pl=++p;*pl;pl++)
			{
				if(*pl=='F')
				{
					fwrite("Yes",3,1,stdout);
					return 0;
				}
			}
	fwrite("No",2,1,stdout);
}

Measured memory_bytes: 384
fun main(args: Array<String>) {
    val (a,b) = readIntList()
    val aa = StringBuilder()
    val bb = StringBuilder()
    repeat(a) {
        bb.append(b)
    }
    repeat(b) {
        aa.append(a)
    }
    if (aa.toString() < bb.toString()) println(aa.toString())
    else println(bb.toString())
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 35892
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			int m = cin.Int();
			int q = cin.Int();

			var lr = new int[n + 1, n + 1];
			for (int i = 0; i < m; i++) {
				int l = cin.Int();
				int r = cin.Int();
				lr[l, r]++;
			}

			for (int i = 1; i < n + 1; i++) {
				for (int j = 1; j < n + 1; j++) {
					lr[i, j] = lr[i, j] + lr[i - 1, j] + lr[i, j - 1] - lr[i - 1, j - 1];
				}
			}

			var sb = new StringBuilder();
			for (int i = 0; i < q; i++) {
				int pp = cin.Int() - 1;
				int qq = cin.Int();
				int temp = lr[qq, qq] - lr[qq, pp] - lr[pp, qq] + lr[pp, pp];
				sb.AppendLine(temp.ToString());
			}

			Console.Write(sb.ToString());
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private readonly Func<string> reader_;
		private string[] buf_;
		private int index_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

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

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

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

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 18720
def main(a, b,c,k):

    m = 0
    if k <=a:
        m = k
    elif k <=(a+b):
        m = a
    elif k <= a+b+c:
        m = (a-(k-(a+b)))
    return m
a, b, c , k = map(int, input().split())
print(main(a,b,c,k))

Measured memory_bytes: 9136
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
a = []
correct_num = 0
for i in range(N):
    a.append(list(map(int, input().split())))
    sum = 0
    for j in range(M):
        sum += a[i][j] * B[j]
    if sum + C > 0:
        correct_num += 1
    else:
        pass
print(correct_num)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
string s;
int n;
int used[300][300];
int dp[300][300];
int dfs(int p,int d){
  if(used[p][d]) return dp[p][d];
  used[p][d]=1;
  int res=-(1LL<<55LL),op=0;
  int j;
  for(j=p-1;j>=0;j--) if(s[j]=='+'||s[j]=='-') break;
  if(j>=0&&s[j]=='-') op=1;
  int x=((d+op)%2?-(s[p]-'0'):(s[p]-'0'));
  for(j=p+1;j<n;j++) if(isdigit(s[j])) break;
  if(j==n){
    //cout<<p<<" "<<d<<":"<<res<<"/"<<x<<endl;
    return dp[p][d]=x;
  }
  if(p<1||s[p-1]!='(') res=max(res,dfs(j,d)+x);
  if(p+1<n&&s[p+1]!=')') res=max(res,dfs(j,d+op)+x);
  if(d>0&&p-1>=0&&s[p-1]!='(') res=max(res,dfs(j,d-1)+x);
  //cout<<p<<" "<<d<<":"<<res<<"/"<<x<<endl;
  return dp[p][d]=res;
}
signed main(){
  cin>>s;
  n=s.length();
  int j;
  for(j=0;j<n;j++) if(isdigit(s[j])) break;
  cout<<dfs(j,0)<<endl;
  return 0;
}

Measured memory_bytes: 4020
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
const int M = 100007;
const double INF = 1e50;

struct PT {double x, y;};
bool cmp(PT a, PT b)
{
	return a.x < b.x || (a.x == b.x && a.y < b.y);
}
bool cmp_y(PT a, PT b)
{
	return a.y < b.y;
}
PT a[M];
double Dis(PT a, PT b)
{
	double x = b.x - a.x;
	double y = b.y - a.y;
	return sqrt(x*x + y*y);
}

double Closest_pair(PT *a, int n)
{
	if (n == 1)  return INF;
	
	double d = INF;
	int m = n/2;
	d = min(Closest_pair(a, m), Closest_pair(a+m, n-m));
	
	// 接下来讨论在中间的情况
	double mx = a[m].x;
	vector<PT> b;
	for (int i = m; i >= 0; --i)
	{
		if (fabs(a[i].x - mx) > d) 	break;
		else 						b.push_back(a[i]);
	}
	for (int i = m+1; i < n; ++i)
	{
		if (fabs(a[i].x - mx) > d)	break;
		else 						b.push_back(a[i]);
	}
	sort(b.begin(), b.end(), cmp_y);
	
	for (int i = 0; i < b.size(); ++i)
	{
		for (int j = i+1; fabs(b[j].y - b[i].y) < d && j < b.size(); ++j)
		{
			double dis = Dis(b[i], b[j]);
			if (dis < d) d = dis;
		}
	}
	
	
	return d;
}

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%lg %lf", &a[i].x, &a[i].y);
	
	sort(a, a+n, cmp);
	printf("%7f", Closest_pair(a, n));
	return 0;
}


Measured memory_bytes: 6988
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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


fn solve(ma: usize, mb: usize, ns: Vec<(usize, usize, usize)>) -> i64 {
    let len = ns.len();
    let mut dp = vec![vec![vec![std::usize::MAX - 1000; 411]; 411]; len+1];
    dp[0][0][0] = 0;
    for i in 1..len+1 {
        let (a, b, c) = ns[i-1];
        for j in 0..401 {
            for k in 0..401 {
                dp[i][j][k] = std::cmp::min(dp[i-1][j][k], dp[i][j][k]);
                dp[i][j+a][k+b] = std::cmp::min(dp[i][j+a][k+b], dp[i-1][j][k] + c);
            }
        }
    }

    let mut res = std::usize::MAX;
    for i in 1..401 {
        for j in 1..401 {
            if i * mb != j * ma {
                continue;
            }
            if dp[len][i][j] < res {
                res = dp[len][i][j];
            }
        }
    }
    if res >= std::usize::MAX - 1000 {
        -1
    } else {
        res as i64
    }

}



fn main() {
    input!{
        n: usize,
        ma: usize,
        mb: usize,
        ns: [(usize, usize, usize); n],
    }
   println!("{}", solve(ma, mb, ns));
}


Measured memory_bytes: 65788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    long double N, K;
    cin >> N >> K;
    vector<ll> cnt(N+1,0);
    for(ll i = 1; i <= N; i++){
        ll tmp = i;
        while(tmp < K){
            tmp <<= 1;
            cnt[i]++;
        }
    }
    ll maxx = *max_element(all(cnt));
    if(maxx == 0){
        cout << 1 << endl;
        return 0;
    }
    long double ans = 0;

    // calc
    for(int i = 1; i <= N; i++){
        ans += bit(maxx - cnt[i]);
    }
    //
    ans /= bit(maxx);
    ans /= N;
    cout << ans << endl;
}


Measured memory_bytes: 4088
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    	Scanner std = new Scanner(System.in);
        
    	int x,i;
    	for(i=1;i <= 10000;i++){
    		x=std.nextInt();
    		if(x==0)
    		break;
        System.out.println("Case"+" "+i+":"+" "+x);
    	}
        std.close();
}
}



Measured memory_bytes: 42804
n = int(input())
p = list(map(int,input().split()))
x = 0
for i in range(n-2):
  if (p[i]<=p[i+1] and p[i+1]<=p[i+2]) or (p[i]>=p[i+1] and p[i+1]>=p[i+2]):
    x += 1
print(x)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    string S;
    cin >> S;
    int Q;
    cin >> Q;
    int cnt = 0;
    string a = "";
    string b = "";
    for(int i = 0;i < Q;i++) {
        int A;
        cin >> A;
        if(A == 1) {
            cnt = (cnt + 1) % 2;
        }
        else {
            int B;
            char C;
            cin >> B >> C;
            if((cnt + B) % 2 == 1) {
                a += C;
            }
            else {
                b += C;
            }
        }
    }
    if(cnt == 0) {
        reverse(a.begin(),a.end());
        cout << a << S << b << endl;
    }
    else {
        reverse(b.begin(),b.end());
        reverse(S.begin(),S.end());
        cout << b << S << a << endl;
    }
}

Measured memory_bytes: 1088
n, k, q = map(int, input().split())
a = []
for i in range(q):
    a.append(int(input()) - 1)
score = [0 for _ in range(n)]

for a_i in a:
    score[a_i] += 1

for i in range(n):
    result = k - q + score[i]
    print("Yes" if result > 0 else "No")


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

bool pal(string s) {
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}

int main() {
  string S;
  cin >> S;
  int N = S.size();

  if (!pal(S)) return cout << "No" << "\n", 0;
  string s = S.substr(0, N / 2);
  string t = S.substr((N + 3) / 2 - 1);
  cout << ((pal(s) && pal(t)) ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
#!/usr/bin/perl
my ($n,$m,$xx,$yy) = map { $_ - 0 } split(/\s+/,<STDIN>);
my @x = map { $_ - 0 } split(/\s+/,<STDIN>);
my @y = map { $_ - 0 } split(/\s+/,<STDIN>);

$x[$n] = $xx;
$y[$m] = $yy;

my @s_x = sort { $a <=> $b } @x;
my @s_y = sort { $a <=> $b } @y;

my $res = 'War';

my $min_y = $s_y[0];
my $max_x = $s_x[$n];

$res = 'No War' if $max_x < $min_y;

print "$res\n";



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

using namespace std ;

int main ()
{

	char str [100] ;
	while (scanf ("%s",str) !=EOF ) 
	{
	int len = strlen (str ) ;

	if (len == 1) printf ("%s\n",str);

	else 
	{
		int flag = 1 ;
		for (int i= 1 ; i<len ; i++ ) 
		{
			if (str[i] !='9' ){flag = 0;  break ;}
		}
		if (flag ) printf ("%d\n",str[0]-'0'+(len-1)*9) ;
		else 
		{
		int ans = (len-1 )*9;
		ans += str [0]-'0'-1;
		printf ("%d\n",ans) ;
		}
	}


	}

	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
        int N;
        cin >> N;

        int cur;
        vector<int> arr;
        for (int i = 0; i < N; i++) {
                cin >> cur;
                arr.push_back(cur);
        }

        sort(arr.begin(), arr.end());
        int answer = 0;
        for (int j = 0; j < N; j++) {
                if (j == (N - 1)) {
                        answer += (arr[j] / 2);
                } else {
                        answer += arr[j];
                } 
        }
        cout << answer << endl;
        return 0;
}


Measured memory_bytes: 256
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    int a, b, h;

    AtCoder(FastScanner sc) {
        a = sc.nextInt();
        b = sc.nextInt();
        h = sc.nextInt();
    }

    void solve(PrintWriter out) {
        out.println((a + b) * h / 2);
    }

}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 23380
N, A, B, C, D = map(int,input().split())
S = input()
# ふぬけ が すぬけ より前にいる
if C < D:
    S_cut = S[A-1:D]
    num = S_cut.count("##")
    # print(S_cut)
    if num > 0:
        print("No")
    else:
        print("Yes")
# すぬけ が ふぬけ より前にいる
else:
    S_cut1 = S[A-1:C]
    # 飛び越えられる
    flg1 = (S_cut1.count("##") == 0)
    S_cut2 = S[max(0,B-2):D+1]
    # S_cut2 = S[A-1:D+1]    
    # 抜く場所
    flg2 = (S_cut2.count("...")>=1)
    if flg1 and flg2:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef map <ll,ll> mm;
typedef vector <ll> mv;
typedef pair <ll,ll> mp;
typedef set <ll> ms;
typedef queue <ll> mq;
typedef deque <ll> mdq;
typedef stack <ll> mst;
typedef priority_queue <ll> mpq;
typedef priority_queue <ll, vector<ll>, greater<ll> > mmh;
typedef complex<double> cd; 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define flush cout.flush();
#define all(v) v.begin(),v.end()
#define pb(v) push_back(v)
#define cn continue
#define forl(i,n) for(ll i=0;i<n;i++)
#define forlr(i,n) for(ll i=n-1;i>=0;i--)
#define rev(s) reverse(s.begin(),s.end())
void swap(ll &a,ll &b)
{
	ll tmp=a;
	a=b;
	b=tmp;
}
ll atoistring(string s)
{
	stringstream lol(s);
	ll x;
	lol>>x;
	return x;
}
void pv(mv v)
{
	forl(i,v.size())
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
void pa(ll *v,ll size)
{
	forl(i,size)
	{
		cout<<v[i]<<" ";
	}
	cout<<"\n";
}
// ll nck(ll N,ll K,ll mod)
// {
// 	if(N<K)
// 	{
// 		return 0;
// 	}
// 	return (((facs[N]*facsinv[N-K])%mod)*facsinv[K])%mod;
// }
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;
}
void checkmod(ll &x,ll mod)
{
	if(x>=mod)
	{
		x%=mod;
	}
}
ll sumofgp(ll a,ll n,ll m)
{
	// n = number of terms - 1
	if(n<0)
	{
		return 0;
	}
	if(n==0)
	{
		return 1;
	}
	if(n==1)
	{
		return (1+a)%m;
	}
	ll ans;
	if(n%2)
	{
        ans=(1+a)*sumofgp((a*a)%m,(n-1)/2,m);
	}
    else
    {
        ans=1+((a*(1+a))%m)*sumofgp((a*a)%m,n/2-1,m);
    }
    return ans%m;
}
// void checktime()
// {
// 	struct timespec ts;
// 	printf("Running Program\n");
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double st=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	// Call Funcn Here
// 	clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
// 	long double en=ts.tv_nsec/(1e9)+ts.tv_sec;
// 	printf("Program ended\nTime = %Lf\n",en-st);
// }
mp arr[1003];
ll dp[10004];
ll n;
ll findans(ll h)
{
	if(dp[h]!=-1)
	{
		return dp[h]; 
	}
	ll x = 1e18;
	forl(i,n)
	{
		if(h-arr[i].first<=0)
		{
			x = min(x,arr[i].second);
			cn;
		}
		x = min(x,arr[i].second+findans(h-arr[i].first));
	}
	return dp[h] = x;
}
int main(void)
{
	fastio
	ll h;
	cin>>h>>n;
	forl(i,n)
	{
		cin>>arr[i].first>>arr[i].second;
	}
	forl(i,10004)
	{
		dp[i] = -1;
	}
	cout<<findans(h)<<"\n";
	return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
#include<string.h>

int main(void){
	char ring[101];		  // input; ring string, 1<=s<=100
	char target[101];         // input; target string, 1<=p<=s
	int r_size=0, t_size=0;	  // ring_size, target size
	char* r_p;		  // pointer; point ring
	int ans=0, cheak=0;	  // answer flag, cheak flag
	int i=0, j=0;		  // loop index

	gets(ring);
	gets(target);
	r_size = strlen(ring);
	t_size = strlen(target);

	for(i=0;i<r_size;i++){
		r_p = &ring[i];
		cheak = 1;
		for(j=0;j<t_size;j++){
			if(*r_p != target[j]){
				cheak = 0;
				break;
			}
			if(*(r_p + 1) == '\0') r_p = ring;
			else r_p++;
		}
		if(cheak){
			ans = 1;
			break;
		}
	}

	if(ans) printf("Yes\n");
	else printf("No\n");

	return 0;
}

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

int main() {

	int S, h, m, s;

	cin >> S;

	h = S / 3600;
	m = (S % 3600) / 60;
	s = (S % 3600) % 60;

	cout << h << ':' << m << ':' << s << endl;

	//system("pause");
	return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < static_cast<int>(b); i++)
#define FORR(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) FOR (i, 0, n)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
template <typename T>
void print(const vector<vector<T>> matrix);
template <typename T>
void print(const vector<T> vec);
template <typename Arg>
void print(const Arg arg);
template <typename Head, typename... Args>
void print(const Head head, const Args... args);
template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
using ll = long long;

typedef pair<int, int> P;

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

    int a, b;
    cin >> a >> b;
    print(a * b - a - b + 1);

    return 0;
}

//---------------------------------------------
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    repall (i, vec)
        cout << i << ' ';
    cout << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}


Measured memory_bytes: 256
#include <stdio.h>


int main(void)
 {

	int W,H,x,y,r;

	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);



	if(x >= r && x + r <= W && y >= r && y + r <= H){

		printf("Yes\n");

	}



	else{
	printf("No\n");
	}

	return 0;

}

Measured memory_bytes: 584
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        char[] data = S.toCharArray();
        int[] a1 = new int[data.length+1];
        for (int i = 0; i < data.length; i++) {
            if (i == 0) {
                if (data[i] == '<') {
                    a1[0] = 0;
                    a1[1] = 1;
                }
                continue;
            }
            if (data[i-1] == '>' && data[i] == '<') {
                a1[i] = 0;
                a1[i+1] = 1;
                continue;
            }
            if (data[i-1] == '<' && data[i] == '<') {
                a1[i+1] = a1[i]+1;
            }
        }
        int[] a2 = new int[data.length+1];
        for (int i = data.length-1; 0 <= i; i--) {
            if (i == data.length-1) {
                if (data[i] == '>') {
                    a2[i+1] = 0;
                    a2[i] = 1;
                }
                continue;
            }
            if (data[i] == '>' && data[i+1] == '<') {
                a2[i] = 1;
                a2[i+1] = 0;
                continue;
            }
            if (data[i] == '>' && data[i+1] == '>') {
                a2[i] = a2[i+1]+1;
            }
        }
        long[] a = new long[data.length + 1];
        for (int i = 0; i < data.length + 1; i++) {
            a[i] = Math.max(a1[i], a2[i]);
        }
        System.out.println(Arrays.stream(a).sum());
    }
}


Measured memory_bytes: 40832
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  ll N;
  ll K;
  cin >> N >> K;
  ll A[N];
  ll b[N];
  ll c[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
    b[i] = -1;
  }
  ll now = 0;
  ll loop = 0;
  ll back = 0;
  ll start = 0;
  b[0] = 0;
  for(int i=1;i<N+1;i++){
    if(b[A[now]-1]!=-1){
      loop = i - b[A[now]-1];
      start = A[now]-1;
      back = b[A[now]-1]+1;
      break;
    }
    b[A[now]-1] = i;
    now = A[now]-1;
  }
  ll ans = 0;
  if(K>=back){
    ll p = (K-back)%loop;
    ans  = A[start];
    for(ll j=1;j<=p;j++){
      ans = A[ans-1];
    }
  }else{
    ans = A[0];
    for(ll j=1;j<K;j++){
      ans = A[ans-1];
    }   
  }
  cout << ans << endl;
}


Measured memory_bytes: 6316
#include <bits/stdc++.h>
using namespace std;
int main (){
  int N;
  cin>>N;
  vector<int> r(N);
  for(int i=0;i<N;i++){
    cin>>r.at(i);
  }
  sort(r.begin(),r.end());
  for(int i=0;i<N-1;i++){
    if(r.at(i)==r.at(i+1)){
      for(int j=i;j<N-1;j++){
        r.at(j)=r.at(j+1);
      }
      r.pop_back();
      N--;
      i--;
    }
  }
  cout<<r.size()<<endl;
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];

    long long res = 0;
    map<int, int> P;
    for(int j=0; j<N; ++j) {
        if(P.count(j - A[j])) {
            res += P[j - A[j]];
        }
        P[A[j] + j] += 1;
    }

    cout << res << '\n';
}

Measured memory_bytes: 13136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin>>n;
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<a[n-1]<<endl;

}



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

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

  int n, m;
  cin >> n >> m;
  int a[200000], b[200000];
  bool to[200000], from[200000];
  rep(i, m) {
    cin >> a[i] >> b[i];
    if (a[i] == 1) {
      to[b[i]-1] = true;
    } 
    if (b[i] == n) {
      from[a[i]-1] = true;
    }
  }

  rep(i, n) {
    if (to[i] && from[i]) {
      puts("POSSIBLE");
      return 0;
    }
  }
  puts("IMPOSSIBLE");
}

Measured memory_bytes: 2176