akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<cassert>

using namespace std;

#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define fj(a, b) for(int j=a;j<b;++j)
#define fk(a, b) for(int k=a;k<b;++k)
#define pb push_back
#define mp make_pair
typedef long long ll;
/////////////////////////

int const N = 1e3 + 41;
int const MOD = 1e9 + 7;

int n, a, b, c, d, f[N], invF[N], dp[N][N], invFd[N][N];

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

int mul(int a, int b){
	return a * 1LL * b % MOD;
}

int bp(int x, int d){
	if(!d){
		return 1;
	}
	if(d&1){
		return mul(x, bp(x, d-1));
	}
	int r = bp(x, d/2);
	return mul(r, r);
}

int getC(int k, int n){
	if(k > n){
		return n;
	}
	return mul(f[n], mul(invF[k], invF[n-k]));
}

void precalc(){
	invF[0] = f[0] = 1;
	fi(1, N){
		f[i] = mul(i, f[i-1]);
		invF[i] = bp(f[i], MOD-2);
		invFd[i][0] = 1;
		fj(1, N){
			invFd[i][j] = mul(invFd[i][j-1], invF[i]);
		}
	}
}

int fun(int k, int i, int j){
	int ret = f[i*k];
	ret = mul(ret, getC(i * k, n - j));
	ret = mul(ret, invFd[i][k]);
	ret = mul(ret, invF[k]);
	return ret; 
}

void solve(){
	precalc();
	dp[a-1][0] = 1;
	for(int i=a;i<=b;++i){
		for(int j=0;j<=n;++j){
			add(dp[i][j], dp[i-1][j]);
			for(int k=c;k<=d && k * i + j <= n;++k){
				add(dp[i][j + k * i], mul(dp[i-1][j], fun(k, i, j)));
			}
		}
	}
	printf("%d\n",dp[b][n]);
}

void read(){
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
}

void prepare(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
}

int main(){
	prepare();
	read();
	solve();


	return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
#define ll long long
#define sort(a) sort(a.begin(), a.end())
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;

int main(){
    int h, a;
    cin>>h>>a;
    if(h%a==0) cout<<h/a;
    else cout<<(h/a) + 1;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define inf 10000000LL
#define fast_io	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
#define range 100001
#define lg 22
using namespace std;

int main()
{
	ll n,x=0;
	cin>>n;
	ll A[n+1];
	ll ans[n+1];
	for(ll i=1;i<=n;i++)
	{
		cin>>A[i];
		x^=A[i];
	}
	
	for(ll i=1;i<=n;i++)
	{
		ans[i]=x^A[i];
	}
	
	for(ll i=1;i<=n;i++)
	cout<<ans[i]<<" ";

}

Measured memory_bytes: 6712
#include<stdio.h>
#define N 100

void insertionSort(int *,int);

int main(void){
  int num,A[N];
  int i;

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

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

  insertionSort(A,num);
  
  
  return 0;
}

void insertionSort(int *A, int num){
  int i,j;
  int tmp;

  for(i = 1; i < num; i++){
    tmp = A[i];
    j = i -1;
    while(j >= 0 && A[j] > tmp){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = tmp;

    for(j = 0; j < num-1; j++){
      printf("%d ",A[j]);
    }
    printf("%d\n",A[num-1]);
  }

}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> nums(N);
  for (int i=0; i<N; i++){
    cin >> nums.at(i);
  }
  int A=0;
  int B=0;
  int count=0;
  int max = 0;
  int tmp = 0;
  while (count < N){ 
    for(int i=0; i<N; i++){
      tmp = nums.at(i);
      if (tmp == 0){
        continue;
      }
      for (int j=0; j<N; j++){
        if (tmp < nums.at(j)){
          break;
        }
        if (j==N-1){
          max = tmp;
          nums.at(i) = 0;
        }
      }
      if (max > 0){
        break;
      }
    } 
    if (count % 2 == 0){
      A += max;
    }
    else{
      B += max;
    }
    max = 0;
    count += 1;
  }
  cout << A-B<<endl;
}
 

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

int main() {
	int A,B;
	cin >> A>>B;
	int ans=B;
	if (A<=12&& A>=6) {
		ans = B / 2;
	}
	else if(A<=5){
		ans = 0;
	}
	cout << ans<<endl;
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <cstring>

template <class Type> using Vec = std::vector<Type>;
template <class Type> using Wec = std::vector<Vec<Type>>;
using int64 = long long int;

constexpr int MOD = 1e9 + 7;
constexpr int MAX_SIZE = 1e5 + 1;
char str[MAX_SIZE+1];

int main(void){
    scanf("%s", str);
    const int n = strlen(str);
    /* DP[i][j] := 上から i 文字を見た時の場合数 jは未満フラグ ; L 未満確定, 0未確定 */
    Wec<int64> DP(n+1, Vec<int64>(2));
    DP[0][0] = 1; DP[0][1] = 0;
    for(int i = 0; i < n; ++i){
        if(str[i] == '1'){
            /* 確定 => 確定の A, B の一方から選ぶ, 選ばない, 未確定から選ばない
              未確定 => 未確定の A, B どちらか一方から選ぶ */
            DP[i+1][0] = (2 * DP[i][0]) % MOD;
            DP[i+1][1] = (3 * DP[i][1] + DP[i][0]) % MOD;
        }
        else{
            /* 確定 => 確定の A, B の一方から選ぶ, 選ばない
               未確定 => 未確定のどちらからも選ばない */
            DP[i+1][0] = DP[i][0];
            DP[i+1][1] = 3 * DP[i][1] % MOD;
        }
    }
    int64 res = (DP[n][0] + DP[n][1]) % MOD;
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 5760
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc160/tasks/abc160_d>
 問題文============================================================
 D - Line++
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N,X,Y; cin >> N >> X >> Y;
    map<int,int> mp;
    for(int i = 1; i <= N; i++){
        for(int j = i+1; j <= N;j++){
            int D = min(j-i,abs(X-i)+abs(Y-j)+1);
            mp[D]++;
        }
    }
    for(int k = 1; k <= N-1;k++) cout << mp[k] << endl;
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(void)
{
  int a, b;
  char  op;
  cin >> a >> op >> b;
  while (1) {
    switch (op) {
      case '+':
      cout << a + b << endl;
      break;
      case '-':
      cout << a - b << endl;
      break;
      case '*':
      cout << a * b << endl;
      break;
      case '/':
      cout << a / b << endl;
      break;
      case '?':
      return  0;
    }
    cin >> a >> op >> b;
  }
}



Measured memory_bytes: 3088
#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 s,w;
  string ans = "safe";
  cin >> s >> w;
  if (s<=w){
    ans = "unsafe";
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
num = int(input())
list = [int(item) for item in input().split()]

order = dict(zip(range(1,num+1), list))
p_order = sorted(order.items(), key=lambda x:x[1])



for i in [item[0] for item in p_order][:-1]:
    print(str(i) + ' ', end='')
print([item[0] for item in p_order][-1])

Measured memory_bytes: 26296
import sys
sys.setrecursionlimit(10**9)

def main():
    N = int(input())
    A = list(map(int,input().split()))

    s = sum(A)
    x1 = s

    for k in range(N//2):
        x1 -= 2 * A[2*k+1]

    X = [x1]
    for i in range(N):
        x = 2 * A[i] - X[i]
        X.append(x)

    print(*X[:-1])


if __name__ == "__main__":
  main()

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

using namespace std;

typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;
    cin >> n >> m;
    ll ans =0;


    ans = (n*(n-1))/2;
    ans+=(m*(m-1))/2;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var N int
	fmt.Scanf("%d", &N)

	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &A[i])
	}

	var money int = 1000
	var kabu int = 0

	for i := 0; i < N-1; i++ {
		kabu = 0
		if A[i] < A[i+1] {
			kabu = money / A[i]
		}
		money = money + kabu*(A[i+1]-A[i])
	}

	fmt.Println(money)

}


Measured memory_bytes: 1840
cin = open(0).read().strip().split('\n')
n = int(cin[0])
s = list(map(int, cin[1].split(' ')))
q = int(cin[2])
t = list(map(int, cin[3].split(' ')))

def binary_search(arr, item):
    low = 0
    high = len(arr) - 1
    while low <= high:
        mid = (low + high) // 2
        guess = arr[mid]
        if guess == item:
            return mid
        if guess > item:
            high = mid - 1
        else:
            low = mid + 1

    return None

ret = 0
for i in t:
    if binary_search(s, i) is not None:
        ret += 1

print(ret)


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string s; cin >> s;

  if(s[s.size()-1]=='s'){
    s = s+"es";
  }
  else{
    s+='s';
  }

  cout << s << endl;
  
  return 0;
}


Measured memory_bytes: 3628
def solve():
    def min2(x, y): return x if x <= y else y

    strN = '0' + input()

    Ns = list(map(int, strN))

    dp = [0, float('inf')]
    for Ni in reversed(Ns):
        dp2 = [0, 0]
        if Ni == 9:
            dp2[0] = dp[0] + Ni
        else:
            dp2[0] = min2(dp[0] + Ni, dp[1] + Ni + 1)
        dp2[1] = min2(dp[0] + 10 - Ni, dp[1] + 9 - Ni)
        dp = dp2

    print(dp[0])


solve()


Measured memory_bytes: 13552
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a):any[]=>{return Array.from(new Set(a))};
const main=()=>{
  let [n,k,q]=tnn(3)
  let ch=new Array(n)
  ch.fill(k)
  for(let i=0;i<q;i++){
    let win=tn()-1
    ch[win]++
  }
  for(let i=0;i<n;i++){
    to(ch[i]-q>0?'Yes':'No')
  }
}
main()


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

int main(){
  int N,a,b,c;
  string S;
  char s;
  cin>>N>>S>>a;
  s =S.at(a-1);
  for(int i=0;i<N;i++){
    if (S.at(i)!=s){
      S.at(i)= '*' ;
    }
  }
  cout<<S<<endl;
}


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

int main() {
	string s;
	cin>>s;
	int n=s.size();
	for(int i=n-1;i>=0;i-=2){
		
		if(s.compare(0,i/2,s,i/2,i/2)==0){
			cout<<(i/2)*2;
			return 0;
	}
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A, B = (
    zip(*(map(int, input().split()) for _ in range(N))) if N else
    ((), ())
)

a, b = zip(*sorted(zip(A, B), key=lambda t: t[1]))

t = 0
ans = 'Yes'
for x, y in zip(a, b):
    t += x
    if t > y:
        ans = 'No'

print(ans)


Measured memory_bytes: 138064
#include <stdio.h>

int main(void)
{
	int h, w, i;

	while (scanf("%d%d", &h, &w) && h != 0 && w != 0){
		while (h--){
			for (i = 0; i < w; i++){
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 572
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    
    int unha = 0;
    int ha = 0;
    for(int i = 0; i < n; i++){
        if(i == 0 && s[i] == 'L'){
            unha++;
        } else if(i == n - 1 && s[i] == 'R'){
            unha++;
        } else {
            if(s[i] == 'R'){
                if(s[i + 1] == 'L'){
                    unha++;
                } else {
                    ha++;
                }
            } else {
                if(s[i - 1] == 'L'){
                    ha++;
                } else {
                    unha++;
                }
            }
        }
    }

    cout << min(n - 1, ha + k * 2) << endl;

    
}


Measured memory_bytes: 512
#include<cstdio>
#define ll long long
const int N=2005,mo=1e9+7;
int n,m,i,j,na,a[N],f[N],ans;
int Pow(int x,int n){
	int k=1;
	for (;n;n>>=1,x=(ll)x*x%mo)
		if (n&1) k=(ll)k*x%mo;
	return k;
}
int main(){
	scanf("%d%d",&n,&m);
	for (i=1;i*i<=n;i++) if (n%i==0) a[++na]=i;
	for (i=na;i;i--) if (a[i]*a[i]!=n) a[++na]=n/a[i];
	for (i=1;i<=na;i++){
		f[i]=Pow(m,a[i]+1>>1);
		for (j=1;j<i;j++)
			if (a[i]%a[j]==0) f[i]=(f[i]-f[j])%mo;
		ans=(ans+(ll)f[i]*(a[i]&1?a[i]:a[i]>>1))%mo;
	}
	printf("%d",(ans+mo)%mo);
}

Measured memory_bytes: 128
#include <fstream>
#include <iostream>

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 1000000007
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define lli long long int
#define pii pair<int,int>
#define add(a,b) ((int) (((lli) (a) + (b))%MOD))
#define mul(a,b) ((int) (((lli) (a) * (b))%MOD))
#define PB emplace_back
#define F first
#define S second

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

int N, K;
int dp [200000];
int fact [200001];

int modexp(int a, int e) {
    int ans = 1;
    int cur = a;
    while (e) {
        if (e&1) {ans = mul(ans, cur); e--;}
        e /= 2;
        cur = mul(cur,cur);
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K;
    cin >> N >> K;
    fact[0] = 1;
    FOR(i,1,N+1) fact[i] = mul(fact[i-1], i);
    dp[0] = 1;
    FOR(i,1,N) {
        dp[i] = add(dp[i-1], dp[i]);
        dp[i] = add(dp[i], mul(mul(fact[N],modexp(mul(fact[i],fact[N-i]), MOD-2)), mul(fact[N-1],modexp(mul(fact[N-i-1],fact[i]), MOD-2))));
    }
    cout << dp[min(N-1,K)] << '\n';
}

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

int main()
{
    ll x;
    cin >> x;

    ll money;
    ll count = 0;
    money = 100;
    while (money < x) {
        long double dmoney;
        dmoney = double(money)*1.01;
        money = ll(dmoney);
        count++;
    }
    cout << count << endl;


    return 0;
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.buffer.readline

from heapq import heappush, heappop

X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

hP = []
hQ = []

P.sort(reverse = True)
Q.sort(reverse = True)

for i in range(min(A, X)):
    heappush(hP, P[i])
for _ in range(X - A):
    heappush(hP, 0)

for i in range(min(B, Y)):
    heappush(hQ, Q[i])
for _ in range(Y - B):
    heappush(hQ, 0)

for r in R:
    hp = heappop(hP)
    hq = heappop(hQ)
    if r <= hp and r <= hq:
        heappush(hP, hp)
        heappush(hQ, hq)
    else:
        if hp <= hq:
            heappush(hP, r)
            heappush(hQ, hq)
        else:
            heappush(hP, hp)
            heappush(hQ, r)
            
print(sum(hP) + sum(hQ))

Measured memory_bytes: 79836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 1e5+5;

int a[sz];

int main()
{
   int a, x, b, y, k;
   cin >> a >> x >> b >> y >> k;
   int xx = a * 60 + x;
   int yy = b * 60 + y;
   cout << yy - xx - k << endl;
}


Measured memory_bytes: 3596
N,K=map(int,input().split())
T={}
for _ in range(N):
    a,b=map(int,input().split())
    if a in T:
        T[a]+=b
    else:
        T[a]=b
U=sorted(T)

for a in U:
    if T[a]>=K:
        print(a)
        break
    else:
        K-=T[a]


Measured memory_bytes: 84620
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 
 using namespace std;
 
 int main()
 {
   int a,b;
   cin>>a>>b;
   double result=1.0*a*b/3.305785;
   printf("%.10lf\n",result);  
   //while(1);
   return 0;
 }

 

Measured memory_bytes: 3208
n = int(input())
m = int(input())
a = list(map(int,input().split()))
b = []
point = {}
for i in range(m):
    b.append(list(map(int,input().split())))
for i in range(n):
    point[i] = 0
for i in range(m):
    target = a[i]
    for j in range(n):
        if b[i][j] == target:
            point[j] += 1
        else:
            point[target - 1] += 1
for key in point:
    print(point[key])


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

int main(void) {
	int i,k,sum,tmp,ans;
	char str[100],n,*line;

	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		k=0; ans=0; sum=0; tmp=0; line=str;
		for( ;sscanf(line,"%c",&n)==1; ){
			if(n=='I')
				sum=1;
			if(n=='V')
				sum=5;
			if(n=='X')
				sum=10;
			if(n=='L')
				sum=50;
			if(n=='C')
				sum=100;
			if(n=='D')
				sum=500;
			if(n=='M')
				sum=1000;
			if(k==0){
				tmp=sum;
				ans=sum;
			}
			if(k>=1){
				if(sum>tmp)
					ans-=tmp*2;
				ans+=sum;
				tmp=sum;
			}
			line++;	k++;
		}
		printf("%d\n",ans-tmp);
	}
	return 0;
}
/*
int roman(char n){
	int sum;
	if(n=='I')
		sum=1;
	if(n=='V')
		sum=5;
	if(n=='X')
		sum=10;
	if(n=='L')
		sum=50;
	if(n=='C')
		sum=100;
	if(n=='D')
		sum=500;
	if(n=='M')
		sum=1000;
	return sum;
}*/

Measured memory_bytes: 560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
long long t[101][100001];

int  n=0,w=0;
long long int knapsack(int n,int w,int weight_array[],int value_array[]){
if(n==0||w==0)
    return 0;
if(t[n][w]!=-1)
    return t[n][w];
if(weight_array[n-1]>w)
    return t[n][w]=knapsack(n-1,w,weight_array,value_array);
else
    return t[n][w]=max(value_array[n-1]+knapsack(n-1,w-weight_array[n-1],weight_array,value_array),knapsack(n-1,w,weight_array,value_array));


}
int main() {
int testcase=1;
//cin>>testcase;
for(int p=0;p<testcase;p++){

    cin>>n>>w;
    int weight_array[n]={0};
    int value_array[n]={0};

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

       cin >>weight_array[i]>>value_array[i];
    }
    memset(t,-1,sizeof(t));
    cout<<knapsack(n,w,weight_array,value_array)<<"\n";
}
    return 0;
}


Measured memory_bytes: 79104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		Gates g = new Gates(n);
		for(int i = 0; i < m; i++){
			int l = sc.nextInt();
			int r = sc.nextInt();
			g.check(l, r);
		}
		g.printAns();
	}
}
class Gates{
	int l = 1;
	int r;
	Gates(int n){
		this.r = n;
	}
	void check(int l, int r){
		if(this.l < l){
			this.l = l;
		}
		if(this.r > r){
			this.r = r;
		}
	}
	void printAns(){
		int ans = 0;
		if(l <= r){
			ans = r - l + 1;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 62704
n = int(input())
a = map(int, input().split())

c_list = {}
for i in a:
	if i in c_list:
		c_list[i] += 1
	else:
		c_list[i] = 1

ans = 0
for k, v in c_list.items():
	_sum = c_list[k]
	if (k-1) in c_list:
		_sum += c_list[k-1]
	if (k+1) in c_list:
		_sum += c_list[k+1]
	if _sum > ans:
		ans = _sum
print(ans)


Measured memory_bytes: 16240
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

vector<vector<pair<int, ll>>> G;
vector<int> Tpl;
vector<bool> vis;
void dfs(int cur) {
  if(vis[cur]) return;
  vis[cur] = true;
  for(auto ele: G[cur]) dfs(ele.first);
  Tpl.push_back(cur);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  G = vector<vector<pair<int, ll>>>(n);
  vis = vector<bool>(n);
  rep(i, m) {
    int l, r; ll d; cin >> l >> r >> d;
    l--; r--;
    G[l].push_back({r, d});
  }
  rep(i, n) dfs(i);
  reverse(all(Tpl));
  vector<ll> D(n, -1);
  D[Tpl[0]] = 0;
  for(int i: Tpl) {
    if(D[i]==-1) {
      for(auto ele: G[i]) {
        int ne = ele.first;
        ll d = ele.second;
        if(D[ne]==-1) continue;
        D[i] = D[ne]-d;
      }
    }
    if(D[i]==-1) D[i] = 0;
    for(auto ele: G[i]) {
      int ne = ele.first;
      ll d = ele.second;
      if(D[ne]==-1 || D[ne]==D[i]+d) D[ne] = D[i]+d;
      else {
        cout << "No\n";
        return 0;
      }
    }
  }
  cout << "Yes\n";
  return 0;
}


Measured memory_bytes: 14500
#include <bits/stdc++.h>
 
//BIAR MANTAB LAH YA
#define Willy using
#define Indrayana namespace
#define Komara std
 
Willy Indrayana Komara;
 
int main()
{
    int n;
    cin >> n;
    int a;
    bool approve = true;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        if (a % 2 == 0)
        {
            if (!(a % 3 == 0 || a % 5 == 0))
            {
                approve = false;
            }
        }
    }
    if (approve)
    {
        cout << "APPROVED" << '\n';
    }
    else
    {
        cout << "DENIED" << '\n';
    }
    


}

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

using namespace std;

int sum_up1(int n) {
    return n * (n + 1) / 2;
}

bool solve(int n, int i) {
    if (n - i > i + 1) return false;
    return true;
}

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

    int sum = 0;
    for (int i = 1; ; i++) {
        if (sum + i >= x) {
            cout << i << endl;
            return 0;
        }
        sum += i;
    }

    return 0;
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    ll a, b;
    mat G(N);
    map<pair<ll,ll>,ll> I;
    REP(i,0,N-1) {
        cin >> a >> b;
        --a; --b;
        G[a].pb(b);
        G[b].pb(a);
        I[{a, b}] = i;
    }
    
    vector<bool> F(N, false);
    vec C(N-1);
    queue<pair<ll,ll>> Q;
    Q.push({0, 0});
    F[0] = true;
    while(!Q.empty()) {
        auto q = Q.front(); Q.pop();
        ll v = q.first, c = q.second, nc = 1;
        FORR(nv,G[v]) {
            if(!F[nv]) {
                if(c == nc) ++nc;
                Q.push({nv, nc});
                C[I[{v, nv}]] = nc;
                ++nc;
                F[nv] = true;
            }
        }
    }

    ll K = 0;
    REP(i,0,N-1) K = MAX(K,C[i]);
    PR(K);
    REP(i,0,N-1) PR(C[i]);

    return 0;
}

/*



*/

Measured memory_bytes: 13824
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
ld dist_between_circle(ll x1,ll y1,ll r1,ll x2,ll y2,ll r2){
    ld res=max((ld)0,(ld)sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))-r1-r2);
    return res;
}
vector<vector<ld> > cost(1010,vector<ld>(1010,(ld)0));
vector<ld> d(1010);
bool used[1010];
ll V;
void dijkstra(ll s){
    rep(i,V)d[i]=(ld)inf*inf;
    fill(used,used+V,false);
    d[s]=(ld)0;
    while(true){
        ll v=-1;
        rep(u,V){
            if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
        }
        if(v==-1)break;
        used[v]=1;
        rep(u,V){
            d[u]=min(d[u],d[v]+cost[v][u]);
        }
    }
}
int main(){
    ll xs,ys,xt,yt;
    cin>>xs>>ys>>xt>>yt;
    cin>>V;
    V+=2;
    vector<vector<ll> >c(V,vector<ll>(3));
    c[0][0]=xs,c[0][1]=ys,c[0][2]=0;
    c[1][0]=xt,c[1][1]=yt,c[1][2]=0;
    REP(i,2,V){
        rep(j,3)cin>>c[i][j];
    }
    rep(i,V){
        rep(j,V){
            cost[i][j]=dist_between_circle(c[i][0],c[i][1],c[i][2],c[j][0],c[j][1],c[j][2]);
        }
    }
    dijkstra(0);
    cout<<setprecision(11)<<d[1]<<endl;
}

Measured memory_bytes: 16384
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""

from collections import deque
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def round_up(a, b):
    """ a/b の切り上げ """
    c = (a + b - 1) / b
    return c


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def floor(a, b):
    """floor(a/b) 整数値を返す"""
    c = (a - a % b)/b
    return int(c)


def main():

    s = input()
    t = input()
    if t[:-1] == s:
        print('Yes')

    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 65444
#include <stdio.h>

int main(){
	int N;
	int K;
	int i;
	char str;
	
	scanf("%d",&N);
	
	char S[N];
	
	scanf("%s",&S);
	
	scanf("%d",&K);
	
	str=S[K-1];
	
	for(i=0;i<N;i++){
		if(S[i]!=str)	S[i]='*';
	}
	
	printf("%s",S);
	
	return 0;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    int n,m;cin>>n>>m;
    priority_queue<int> q;

    FOR(i,n){
        int x;cin>>x;
        q.push(x);
    }
    while(m && !q.empty()){
        int y=q.top();q.pop();
        y /= 2;
        if (y) q.push(y);
        --m;
    }
    ll ret=0;
    while(!q.empty()){
        ret += q.top();
        q.pop();
    }
    cout << ret;
    return 0;
}



Measured memory_bytes: 892
#!/usr/bin/env stack
-- stack --resolver lts-11.2 script

import Control.Monad ( when )
import Debug.Trace

main :: IO ()
main = do
  ns <- (map read. words) <$> getLine :: IO [Int]

  let ks = filter (\n -> n `mod` 2 /= 0) ns
      gs = filter (\n -> n `mod` 2 == 0) ns

  case length ks of
    0 -> do
      let max   = maximum gs
          toMax = map (\n -> (max-n) `div` 2) gs
      print (sum toMax)
    1 -> do
      let gs'   = map (+1) gs
          max   = maximum $ ks ++ gs'
          toMax = map (\n -> (max-n) `div` 2) $ ks ++ gs'
      print (sum toMax + 1)
    2 -> do
      let ks'   = map (+1) ks
          max   = maximum $ ks' ++ gs
          toMax = map (\n -> (max-n) `div` 2) $ ks' ++ gs
      print (sum toMax + 1)
    3 -> do
      let max   = maximum ks
          toMax = map (\n -> (max-n) `div` 2) ks
      print (sum toMax)


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n,k;
  string s;
  cin >> n >> k >> s;
  vector<int> ln; /* 偶数添字で1の連続数, 奇数添字で0の連続数を記録 */
  char buf = '1';
  int cnt = 0;
  for(int i=0;i<n;i++){
    if(buf != s[i]){
      ln.push_back(cnt);
      cnt = 1;
      buf = s[i];
    }else cnt++;
  }
  ln.push_back(cnt);
  int suml[ln.size()+1]={}; // i番目までグループまでに何人いるか
  for(int i=0;i<ln.size();i++){
    suml[i+1] = suml[i] + ln[i];
  }
  int ans = 0;
  for(int i=1;i<=ln.size();i++){
    if(i % 2 == 1){
      // i番目は1
      ans = max(ans, suml[min((int)ln.size(), i+2*k)]-suml[i-1]);
    }else{
      // i番目は0
      ans = max(ans, suml[min((int)ln.size(), i+2*k-1)]-suml[i-1]);      
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1272
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;


int main(void){
    int a,b;
    cin >> a >> b;
    a = (a - 1)%13;
    b = (b - 1)%13;
    if(a == 0){
        a = 13;
    }
    if(b == 0){
        b = 13;
    }
    if(a > b){
        cout << "Alice";
    }else if(a  == b){
        cout << "Draw";
    }else{
        cout << "Bob";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
static const int MAX=2000001;
static const int INFTY=1<<30;

int H,A[MAX];

void maxHeapify(int i) {
  int l,r,largest;
  l=2*i;
  r=2*i+1;
  if (l<=H and A[l]>A[i]) {
    largest=l;
  }
  else largest=i;
  if (r<=H and A[r]>A[largest]) {
    largest=r;
  }
  if (largest!=i) {
    swap(A[i],A[largest]);
    maxHeapify(largest);
  }
}
int extract() {
  int maxv;
  if (H<1) {
    return -INFTY;
  }
  maxv=A[1];
  A[1]=A[H--];
  maxHeapify(1);
  return maxv;
}
void increaseKey(int i,int k) {
  if (k<A[i]) {
    return ;
  }
  A[i]=k;
  while (i>1 and A[i/2]<A[i]) {
    swap(A[i],A[i/2]);
    i=i/2;
  }
}
void insert(int k) {
  H++;
  A[H]=-INFTY;
  increaseKey(H,k);
}
int main() {
  int key;
  string com;
  while (true) {
    cin>>com;
    if (com=="end") {
      break;
    }
    if (com=="insert") {
      cin>>key;
      insert(key);
    }
    else {
      cout<<extract()<<endl;
    }
  }
  return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }


void solve() {
    int N;
    cin >> N;
    for(int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            if (i * 4 + j * 7 == N) {
                cout << "Yes" << endl;
                return;
            }
        }
    }
    cout << "No" << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <cmath>

# 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() {
    ll a;
    double b;
    cin >> a >> b;

    int b_int = round(b * 100);
    ll ans = (a * b_int) / 100;
    cout << ans << endl;
}

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

typedef long long ll;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> c(m);
    for(int i=0; i<m; i++) cin >> c[i];
    
    int dp[n+1];
    for(int i=0; i<=n; i++) dp[i]=INT_MAX;
    dp[0]=0;
    dp[1]=1;
    
    for(int i=2; i<=n; i++){
        for(int j=0; j<m; j++){
            if((i-c[j])>=0) dp[i] = min(dp[i], dp[i-c[j]]+1);
        }
    }
    
    cout << dp[n] << endl;
    
}



Measured memory_bytes: 3292
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AGarden {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a, b;
	    in >> a >> b;
        out << (a-1) * (b-1) << endl;
	}
};


int main() {
	AGarden solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;

void Main() {
    long long N;
    cin >> N;
    vector<long long> A(N, 0LL);
    bool zero = false;
    for (int i = 0; i < N; ++i) {
        long long temp;
        cin >> temp;
        A[i] = temp;
        if (temp == 0LL) {
            zero = true;
        }
    }

    if (zero) {
        cout << 0 << endl;
        return;
    }

    long long ans = 1LL;
    bool over = false;
    for (long long i = 0; i < N; ++i) {
        ans *= A[i];
        if (ans > 1000000000000000000LL || ans <= 0) {
            cout << -1 << endl;
            return;
        }
    }

    if (ans )
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define rep(i, r) for (int i = 0; i < r; i++)
using namespace std;
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

int main() {
  int r; cin >> r;
  cout << r * r << endl;
  return 0;
}

Measured memory_bytes: 256
w,h,n=map(int,input().split())
x=[]
y=[]
a=[]
ax=0
ix=w
ay=0
iy=h

for i in range(n):
    x1,y1,a1=map(int,input().split())
    x.append(x1)
    y.append(y1)
    a.append(a1)

for j in range(n):
    if(a[j]==1):
        ax=max(ax,x[j])
    elif(a[j]==2):
        ix=min(ix,x[j])
    elif(a[j]==3):
        ay=max(ay,y[j])
    else:
        iy=min(iy,y[j])

if(ax>=ix or ay>=iy):
    print('0')
    exit()

else:
    print((ix-ax)*(iy-ay))

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

using namespace std;

typedef long long ll;
int main()
{
	ll n; cin >> n;
	vector<int> arr(n+1);
	for(ll i = 1; i <= n; i++){
		for(ll j = i; j <= n; j+= i){
			arr[j]++;
		}
	}
	ll ans = 0;
	for(ll i = 1; i <= n; i++){
		ans += i*arr[i];
	}
	cout << ans;
}


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


//defines...
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define in insert
#define pi 2*acos(0.0)1
#define srt(s) sort(s.begin(),s.end())
#define all(x) x.begin(),x.end()

const ll mod=1e9+7;
const ll MX=2e5+5;

//code goes from here...



int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);

    freopen("output.txt", "w", stdout);
#endif

    boost
    //---------------------------------
    int a, b , n;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int cnt=0,cn=0;
    
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='a')
        {
            cnt++;
            if(cnt<=(a+b)) cout << "Yes\n";
            else cout << "No\n";
        }
        else if(s[i]=='b')
        {
            cnt++;
            cn++;
            if(cnt<=(a+b) && cn<=b) cout << "Yes\n";
            else 
            {
                cout << "No\n";
                cnt--;
            }
            
        }
        else cout << "No\n";
    }
    
    //---------------------------------
    
    return 0;
}


Measured memory_bytes: 3796
package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
	"sort"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	abs := func(x int) int {
		if x < 0 {
			return -x
		}
		return x
	}
	type pair struct{ v, i int }
	in := bufio.NewReader(_r)
	var n int
	Fscan(in, &n)
	a := make([]pair, n)
	for i := range a {
		Fscan(in, &a[i].v)
		a[i].i = i
	}
	sort.Slice(a, func(i, j int) bool { return a[i].v > a[j].v })

	dp := make([][]int, n)
	for i := range dp {
		dp[i] = make([]int, n)
		for j := range dp[i] {
			dp[i][j] = -1
		}
	}
	var f func(int, int) int
	f = func(x, y int) (res int) {
		if x+y == n {
			return
		}
		d := &dp[x][y]
		if *d >= 0 {
			return *d
		}
		defer func() { *d = res }()
		p := a[x+y]
		f1 := f(x+1, y) + p.v*abs(x-p.i)
		f2 := f(x, y+1) + p.v*abs(n-1-y-p.i)
		if f1 > f2 {
			return f1
		}
		return f2
	}
	Fprint(_w, f(0, 0))
}

func main() { run(os.Stdin, os.Stdout) }


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

if N == 0:
    print(0)
    exit()
else:
    ans = ""
    while N != 0:
        if N % 2 == 1:
            ans = "1" + ans
            if N > 0:
                N = (N // 2) * (-1)
            else:
                N = N // (-2) + 1
        else:
            ans = "0" + ans
            N = N // (-2)

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll M=1e9+7;

vector<vector<ll>> multiply(vector<vector<ll>> a,vector<vector<ll>> b){
	vector<vector<ll>> sol=a;
	for(ll i=0;i<a.size();i++){
		for(ll j=0;j<a.size();j++){
			sol[i][j]=0;
			for(ll k=0;k<a.size();k++){
				sol[i][j]+=(a[i][k]*b[k][j])%M;
				sol[i][j]%=M;
			}
		}
	}
	return sol;
}

vector<vector<ll>> power(vector<vector<ll>> adj,ll p){
	if(p==1){
		return adj;
	}
	vector<vector<ll>> sol;
	sol=power(adj,p/2);
	sol=multiply(sol,sol);
	if(p&1){
		sol=multiply(sol,adj);
	}
	return sol;
}

int main(){
 ll n,k;
 cin>>n>>k;
 vector<vector<ll>> adj(n);
 for(ll i=0;i<n;i++){
 	for(ll j=0;j<n;j++){
 		ll d;
		 cin>>d;
		adj[i].push_back(d); 	
	}
 }
 adj=power(adj,k);
 ll sum=0;
 for(ll i=0;i<n;i++){
 	for(ll j=0;j<n;j++){
 		sum=(sum+adj[i][j])%M;	
	}
 }
 cout<<sum%M<<endl;
 return 0;
}

Measured memory_bytes: 4836
#include <bits/stdc++.h> 
#define ll long long int
#define ld long double
const double pi=3.14159265358979323846;
using namespace std;

ll ipow(ll base, ll exp)
{
    ll result = 1;
    for (;;)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        if (!exp)
            break;
        base *= base;
    }

    return result;
}

ll bigd(ll n) 
{
    ll in=1;
    for (ll i = 1; i < n; i++)
    {
        if (n % i == 0) 
        in= i;
    }   
    return in;
} 
int main()
{
    
        ll a,b;
        cin>>a>>b;
        cout<<a*b<<"\n"; 
}

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

int main()
{
    int N;
    string s;
    scanf("%d", &N);
    cin>>s;
    long long red, green, blue, result;
    red = green = blue = 0;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'R')
            red++;
        if(s[i] == 'G')
            green++;
        if(s[i] == 'B')
            blue++;
    }
    result = red * green * blue;
    for(int i = 0; i < N; i++)
    {
        for(int j = i+1; 2*j-i<N&&j < N; j++)
        {
            if(s[i] != s[j] && s[j] != s[2*j-i] && s[i] != s[2*j-i])
            {
                result--;
            }

        }
    }
    printf("%lld", result);
    return 0;
}



Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=203,INF=1<<20;
int cnt[26];
string S;
bool ok=true;

int expr(int &i){
    if('a'<=S[i]&&S[i]<='z'){
        return S[i++]-'a';
    }
    
    i++;
    int a=expr(i);
    i++;
    int b=expr(i);
    i++;
    
    //cout<<i<<endl;
    if(cnt[a]>0){
        if(cnt[b]>0) ok=false;
        cnt[a]--;
        return a;
    }else if(cnt[a]==0){
        if(cnt[b]<=0) ok=false;
        cnt[b]--;
        return b;
    }else{
        ok=false;
        return a;
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>S;
    int N=int(S.size()+3)/4;
    
    for(int i=0;i<N;i++){
        char a;int b;cin>>a>>b;
        cnt[a-'a']=b;
    }
    int i=0;
    expr(i);
    
    //cout<<ok<<endl;
    
    for(int i=0;i<26;i++){
        if(cnt[i]) ok=false;
        //cout<<cnt[i]<<endl;
    }
    
    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}




Measured memory_bytes: 3232
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<stdio.h>

using namespace std;

int main(void){

    int n, max, second, maxCount = 0;

    cin >> n;

    int list[n], temp[n];

    for(int i = 0;i < n;i++){
        cin >> list[i];
    }

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

    sort(temp, temp + n, greater<int>());

    max = temp[0];

    for(int i = 0;i < n;i++){
        if(max != temp[i]){
            second = temp[i];
            break;
        }else{
            maxCount++;
        }
    }
    

    for(int i = 0;i < n;i++){
        if(maxCount == 1){
            if(list[i] == max){
                cout << second << endl;
            }else{
                cout << max << endl;
            }
        }else{
            cout << max << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3200