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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int,P> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 301010

struct BIT{
	ll bit[MAX_N];

	void init(){
		memset(bit,0,sizeof(bit));
	}

	ll sum(int i){
		ll s=0;
		while(i>0){
			s+=bit[i];
			i-=i&-i;
		}
		return s;
	}

	void add(int i,ll v){
		while(i<=MAX_N){
			bit[i]+=v;
			i+=i&-i;
		}
	}
};


struct RangeSumQuery{
	BIT bit0, bit1;

	RangeSumQuery(){}

	void init() {
		bit0.init();
		bit1.init();
	}

	ll sum(int from, int to) {
		return (bit0.sum(to)+bit1.sum(to)*to) - (bit0.sum(from)+bit1.sum(from)*from);
	}

	void add(int from, int to, ll value) {
		bit0.add(to, to * value);
		bit0.add(from, - from * value);
		bit1.add(from, value);
		bit1.add(to, -value);
	}
};

int n;
int m;
vector<PPI> rs;
RangeSumQuery rsq;

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>m;
	rep(i,n){
		int l,r;
		cin>>l>>r;
		rs.pb(PPI(r-l+1,P(l,r+1)));
	}
	sort(all(rs));
	int l=0;
	repl(d,1,m+1){
		int res=0;
		while(l<n&&rs[l].fi<d){
			rsq.add(rs[l].se.fi,rs[l].se.se,1);
			l++;
		}
		for(int i=0;i<=m;i+=d){
			res+=rsq.sum(i,i+1);
		}
		res+=n-l;
		cout<<res<<endl;
	}
	return 0;
}


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

int main() {
    int K;
    cin>>K;
    string s = "ACL";
    string s1 = s;
    for(int i = 1; i < K; ++i){
        s += s1;
    }
    cout<<s<<endl;
    return 0;
}


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

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

  int ans[N];
  ans[0] = 0;
  for(int i = 1; i < N; i++) {
    if(S[i] == 'E') ans[0]++;
  }
  for(int i = 1; i < N; i++) {
    ans[i] = ans[i-1];
    if(S[i-1] == 'W') ans[i]++;
    if(S[i] == 'E') ans[i]--;
  }
  for(int i = 0; i < N; i++) {
    if(ans[0] >= ans[i]) {
      ans[0] = ans[i];
    }
  }
  cout << ans[0] << endl;
  return 0;
}


Measured memory_bytes: 1796
n = int(input())
a = [int(i) for i in input().split()]
d = dict()
ans = 0
for i in a:
    if i not in d.keys():
        d[i] = 0
    d[i] += 1
for x, c in d.items():
    if c < x:
        ans += c
    else:
        ans += c - x
print(ans)


Measured memory_bytes: 18172
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner s=new Scanner(System.in);
        String po=s.nextLine();
        char a[]=po.toCharArray();
        int high[]=new int[20001];
        int mizu[]=new int[10001];
        int i=0;
        for(char a1 : a){
            i++;
            if(a1=='/') high[i]=high[i-1]+1;
            else if(a1=='_') high[i]=high[i-1];
            else high[i]=high[i-1]-1;
        }
        int j=0,tmp=0,cnt=0;
        while(j<i){
            if(high[j]>high[j+1]){
                int m=j;
                while(m<i){
                    m++;
                    if(high[j]==high[m]){
                        mizu[cnt]=menseki(high,j,m);
                        tmp+=mizu[cnt];
                        cnt++;
                        j=m-1;
                        break;
                    }
                }
            }
            j++;
        }
        System.out.println(tmp);
        System.out.print(cnt);
        for(i=0;i<cnt;i++){
            System.out.print(" "+mizu[i]);
        }
        System.out.println("");

    }
    public static int menseki(int[] high,int first,int last){
        int s=0;
        for(int i=first;i<last;i++){
            if(high[i]>high[i+1]){
                s+=((high[first]-high[i+1])*2-1);
            }else if(high[i]==high[i+1]){
                s+=(high[first]-high[i])*2;
            }else{
                s+=((high[first]-high[i])*2-1);
            }
        }
        return s/2;
    }
}


Measured memory_bytes: 29456
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int x,n;
    cin >> x >> n;
    map<int,bool> mp;
    for (int i=0; i<n; i++) {
        int p;
        cin >> p;
        mp[p] = true;
    }

    int ans = 0;
    int sa = INT_MAX;
    for (int i=-100; i<110; i++) {
        if (mp[i]) continue;
        if (sa > abs(i - x)) {
            sa = abs(i-x);
            ans = i;
        }
    }

    cout << ans << endl;
}

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

int main(void) {
	int A, B;
	cin >> A >> B;
	int ans = 1;
	bool flag = false;
	if (B == 1) {
		ans = 0;
		flag = true;
	} else if (B <= A) {
		ans = 1;
		flag = true;
	}

	while (!flag) {
		ans++;
		if (A*ans - (ans - 1) >= B) {
			flag = true;

		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<vector<bool>> g(n,vector<bool>(n));
	vector<int> a(m), b(m);
	rep(i,m){
		cin >> a.at(i) >> b.at(i);
		a.at(i)--;b.at(i)--;
		g[a.at(i)][b.at(i)] = true;
		g[b.at(i)][a.at(i)] = true;
	}
	int ans = 0;
	queue<int> q;
	rep(i,m){
		g[a.at(i)][b.at(i)] = false;
		g[b.at(i)][a.at(i)] = false;
		bool ok = true;
		vector<bool> visited(n);
		visited.at(0) = true;
		q.push(0);
		while(!q.empty()){
			int cur = q.front();q.pop();
			rep(j,n){
				if(g[cur][j] && !visited.at(j)){
					visited.at(j) = true;
					q.push(j);
				}
			}
		}
		rep(j,n) if(!visited.at(j)) ok = false;
		if(!ok) ans++;
		g[a.at(i)][b.at(i)] = true;
		g[b.at(i)][a.at(i)] = true;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

const int MAXH = 10000;
const int MAXN = 1000;
vector<vector<int>> dp(MAXN+1, vector<int>(MAXH+1, INF));

int main() {
	int H, N;
	cin >> H >> N;
	vector<int> A(N), B(N);
	int mxa=0, mxb=1000;
	rep(i,N) {
		cin >> A[i] >> B[i];
		if (A[i]*mxb > mxa*B[i]) {
			mxa = A[i];
			mxb = B[i];
		}
	} 
	rep(i,N+1) {
		dp[i][0] = 0;
	}
	rep(i,N) {
		rep(j,H+1) {
			if (j >= A[i]) {
				dp[i+1][j] = min(dp[i][j], dp[i+1][j-A[i]] + B[i]);
			} else {
				dp[i+1][j] = min(dp[i][j], (j+A[i]-1)/A[i]*B[i]);
			}
		}
	}
	cout << dp[N][H] << endl;
	return 0;
}


Measured memory_bytes: 39424
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<ll> A;
void input(){
    fast_io();
    cin >> N;
    A = fetch_vec<ll>(N);
}

int solve(){
    ll ans = 0;
    while(*max_element(A.begin(),A.end())>=N){
        for (int i = 0; i < N; i++)
        {
            ll x = A[i]/N;
            if(x){
                ans += x;
                A[i] -= x*N;
                for (int j = 0; j < N; j++)
                {
                    if(i!=j)A[j]+=x;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Here your code !

import math

def minmax_n(n):
    return sum(i for i in range(0,n)), sum(i for i in range(9,9-n,-1))

def saiki(n, s, ls):
    ans = 0
    if n==1:
        if s in ls:
            return 1
        else:
            return 0
    if s < minmax_n(n)[0] or s > minmax_n(n)[1]:
        return 0
    for l in ls:
        ls_ = ls[:]
        ls_.remove(l)
        ans += saiki(n-1, s-l, ls_)
    return ans

while(1):
    str = raw_input()
    n, s = map(int, str.split(' '))
    
    if n==0 and s==0:
        break
    if s < minmax_n(n)[0] or s > minmax_n(n)[1]:
        print 0
    else:
        print saiki(n, s, range(10))/math.factorial(n)

Measured memory_bytes: 6460
#include<bits/stdc++.h>
//using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb emplace_back
#define mp std::make_pair
//
#define endl "\n"
//using std::endl;
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
//
constexpr ll MOD=1e9+7;
//constexpr ll MOD=998244353;
//constexpr ll MOD=10000000;
//constexpr ll MOD=1e5;
constexpr ll MAX=1e7;
constexpr ll INF=(1ll<<62);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
const ll N=26;
ll solve(ll D,vii &A,vi &C,vi &S){
    vi last(N,-1);
    ll a=0;
    rep(i,0,D){
        ll memo; memo=S[i];
        last[memo]=i;
        a+=A[i][memo];
        rep(j,0,N) a-=(i-last[j])*C[j];
    }
    return a;
}
int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    srand((unsigned)time(NULL));
    ll D; cin>>D;
    vi C(N);
    rep(i,0,N) cin>>C[i];
    vii A(D,vi(N));
    rep(i,0,D){
        rep(j,0,N) cin>>A[i][j];
    }
    vi last(N,-1);
    vi ans(D);
    rep(i,0,D){
        ll max=0,memo=0;
        rep(j,0,N){
            if(max<A[i][j]+(i-last[j])*C[j]){
                max=A[i][j]+(i-last[j])*C[j];
                memo=j;
            }
        }
        last[memo]=i;
        ans[i]=memo;
    }
    ll max=solve(D,A,C,ans);
    rep(_,0,45){
        if(_%3==0||_%2==0){
            rep(i,0,D){
                rep(j,0,N){
                    vi S=ans;
                    S[i]=j;
                    ll X=solve(D,A,C,S);
                    if(max<X){
                        max=X;
                        ans[i]=j;
                    }
                }
            }
        }
        else{
            per(i,D-1,0){
                rep(j,0,N){
                    vi S=ans;
                    S[i]=j;
                    ll X=solve(D,A,C,S);
                    if(max<X){
                        max=X;
                        ans[i]=j;
                    }
                }
            }
        }
    }
    rep(i,0,D) cout<<ans[i]+1<<endl;
}


Measured memory_bytes: 3692
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	cm := m * (m - 1) / 2
	cn := n * (n - 1) / 2

	var cnt int
	if n <= 1 {
		cnt = cm
	} else if m <= 1 {
		cnt = cn
	} else {
		cnt = cn + cm
	}

	fmt.Print(cnt)
}


Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=1050;
//ここまでテンプレ
//整数a,bの最大公約数を返す
//ユークリッドの互除法
long long gcd(long long a,long long b){
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}
int main(){
	int T;
	cin>>T;
	while(T--){
		ll A,B,C,D;
		cin>>A>>B>>C>>D;
		if(A<B){
			cout<<"No"<<endl;
			continue;
		}
		if(D<B){
			cout<<"No"<<endl;
			continue;
		}
		if(C>=B){
			cout<<"Yes"<<endl;
			continue;
		}
		//ここからは、かならず補充量のほうが買う量より多く、補充の条件が買う量より少ない
		ll G=gcd(B,D);
		ll E=A%B;
		E%=G;
		E=(E+B-G)%B;
		if(E>C)
			cout<<"No"<<endl;
		else
			cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
l = [
    [1, 3, 5, 7, 8, 10, 12],
    [4, 6, 9, 11],
    [2]
]

g1 = g2 = -1

for i in range(3):
    if x in l[i]:
        g1 = i
    
    if y in l[i]:
        g2 = i

print('Yes' if g1==g2 else 'No')

Measured memory_bytes: 38256
from collections import deque

H, W = map(int, input().split())

s = ['1'*(W+2)]
cntw = 0

for i in range(H):
    a = input()
    a = a.replace('.', '0').replace('#', '1')
    cntw += a.count('0')
    s.append('1'+a+'1')
s.append('1'*(W+2))

visited = [[0] * (W+2) for _ in range(H+2)]
visited[1][1] = 1
temp = deque([[1, 1, 0]])
ans = 0

while temp:
    p = temp.popleft()
    if p[0:2] == [H, W]:
        ans= p[2]
        break
    else:
        for k in [[1, 0], [-1, 0], [0, 1],[0, -1]]:
            if s[p[0]+k[0]][p[1]+k[1]] == '0' and visited[p[0]+k[0]][p[1]+k[1]] == 0:
                temp.append([p[0]+k[0], p[1]+k[1], p[2]+1])
                visited[p[0]+k[0]][p[1]+k[1]] = 1
    
print(cntw- (ans + 1) if ans!=0 else -1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, res = 2147483647;
  cin >> N >> K;
  for(int i = 1; i <= N; i++) {
    int c = 1;
    for(int j = 1; j <= i; j++) {
      c *= 2;
    }
    for(int j = 1; j <= N - i; j++) {
      c += K;
    }
  if(c < res) res = c;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){

  int N, M; cin >> N >> M;

  vector <bool> red(N);
  red[0] = true;
  
  vector <int> cnt(N);
  for(int i = 0; i < N; i++) cnt[i] = 1;

  for (int i = 0; i < M; i++){
    int X, Y; cin >> X >> Y;
    X--; Y--;
    if (red[X] == true){
      if (cnt[X] == 1){
        red[X] = false;
      }
      red[Y] = true;
    }
    cnt[X]--; cnt[Y]++;
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++){
    if (red[i] == true) ans++;
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl;
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2



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

	for (ll n = 1; n <= 3500; n++) {
		for (ll h = 1; h <= 3500; h++) {
			if (4 * n*h - N * n - N * h > 0) {
				if (N*h*n % (4 * n*h - N * n - N * h) == 0) {
					cout << h << " " << n << " " << N * h*n / (4 * n*h - N * n - N * h) << endl;
					return 0;
				}
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

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

    ll ans = 0;

    for(int i=0; i<N; i++) {
        sum -= A[i];
        ans += A[i] * (sum %(1000000000 + 7));
        ans %= (1000000000 + 7);
    }
    cout << ans;
}

Measured memory_bytes: 4772
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

// Extended Print Func
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& input){
    os << "[ ";
    REP(i, input.size()){
        os << input[i];
        if (i < input.size()-1) { os << " "; }
    }
    os << " ]";
    return os;
}
void print() { std::cout << "\n"; }
template<class T, class... A> void print(const T& first, const A&... rest) { std::cout << first << " "; print(rest...); }
template<class... A> void print(const A&... rest) { print(rest...); }



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N){ cin >> A[i]; }

  REP(i, N){
      if (A[i]%2 == 0){
          if (A[i]%3 > 0 & A[i] % 5 > 0){
              std::cout << "DENIED" << "\n";
              return 0;
          }
      }
  }

  std::cout << "APPROVED" << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

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

    bool is_ok = false;
    rep(i, 3) {
        if (n % 10 == 7) is_ok = true;
        n /= 10;
    }
    if (is_ok) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using longlong=long long;

void err(){std::cout<<"No" << std::endl; exit(0); }

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    int a,b;std::cin>>a>>b;
    std::string s;std::cin>>s;
    if(s[a]!='-')err();
    s.erase(s.begin()+a);
    for(char c:s){
        if(!std::isdigit(c))err();
    }
    std::cout<<"Yes"<<std::endl;
}

Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,r=LI()
  if 10<=n:
    return r
  return r+100*(10-n)

# main()
print(main())


Measured memory_bytes: 5972
package main

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

const VMAX = 100000

func main() {
	fmt.Printf("%d\n", answer(os.Stdin))
}

func answer(r io.Reader) int {
	sc := bufio.NewScanner(r)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	A := make([]int, n)
	s := VMAX
	for i := 0; i < n; i++ {
		sc.Scan()
		A[i], _ = strconv.Atoi(sc.Text())
		s = min(s, A[i])
	}
	return minCostSort(A, n, s)
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func minCostSort(A []int, n, s int) int {
	ans := 0
	B, T := make([]int, n), make([]int, VMAX)
	V := make([]bool, n) // all elements are "false".
	copy(B, A)
	sort.Slice(B, func(i, j int) bool {
		return B[i] < B[j]
	})
	for i := 0; i < n; i++ {
		T[B[i]] = i
	}
	for i := 0; i < n; i++ {
		if V[i] {
			continue
		}
		cur := i
		// S is sum of elements.
		S := 0
		// m is minimum value of elements.
		m := VMAX
		// an is answer in cycle.
		an := 0
		for {
			V[cur] = true
			an++
			v := A[cur]
			m = min(m, v) // minimum element.
			S += v        // Sum of elements.
			cur = T[v]
			if V[cur] {
				break
			}
		}
		ans += min(S+(an-2)*m, m+S+(an+1)*s)
	}
	return ans
}



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

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

	vector<pair<int, int>> id;
	vector<vector<pair<int, int>>> province(n + 1);

	for (int i = 0; i < m; i++) {
		int p, y;
		cin >> p >> y;
		id.push_back({ p,y });
		province[p].push_back({ y,i });
	}

	for (int i = 0; i < province.size(); i++) {
		sort(province[i].begin(), province[i].end());	
		for (int j = 0; j < province[i].size(); j++) {
			id[province[i][j].second].second = j + 1;
		}
	}

	for (int i = 0; i < id.size(); i++) {
		cout << setw(6) << setfill('0') << id[i].first << setw(6) << id[i].second << endl;
	}

	return 0;
}

Measured memory_bytes: 7796
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mkp make_pair
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
#define lg 18
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    int arr[n];
    rep(i,0,n)cin>>arr[i];

    ll dp[n][n][2];//mx,mn

    int len;
    rep(len,1,n+1)
    {
        rep(i,0,n+1-len)
        {
            j=i+len-1;
            if(len==1)
            {
                dp[i][j][0]=arr[i];
                dp[i][j][1]=-arr[i];
            }
            else
            {
                dp[i][j][0]=max(dp[i+1][j][1]+arr[i],arr[j]+dp[i][j-1][1]);
                dp[i][j][1]=min(dp[i+1][j][0]-arr[i],-arr[j]+dp[i][j-1][0]);
            }
        }
    }
    cout<<dp[0][n-1][0];
    return 0;
}



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

#define PI 3.14159265359
#define INF 1000000009
#define LINF 1000000000000000009
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

int main(void)
{   
    string s;
    cin >> s;
    int n = s.size();
    
    v_int a(n, 0);
    irep(i, n) {
        if(s[i] == 'W') {
            a[i] = 1;
        }
    }

    ll ans = 0;
    ll white = 0;
    irep(i, n) {
        if(a[i] == 0) {
            while(i < n && a[i] == 0) {
                i++;
            }
        } 
        if(a[i]) {
            ans += (i - white);
            white++;
        }
    }
    cout << ans << endl;
    return 0;
}
/** tcoder **/


Measured memory_bytes: 1412
#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, n;
    cin >> k >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    int m = 0;
    for (int i = 0; i < n-1; i++) {
        m = max(m, a.at(i+1) - a.at(i));
    }
    m = max(m, k - (a.back() - a.front()));
    cout << k-m << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================



	int N;
	cin >> N;

	cout << (N+1)/2;









}


Measured memory_bytes: 256
import java.util.Scanner;
class newclass{
	int x;
	int y;
}

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int n= sc.nextInt();
			if(n==0)break;
			newclass[] box = new newclass[n];
			for(int i=0;i<n;i++)
				box[i] = new newclass();
			
			box[0].x=0;
			box[0].y=0;
			
			int xx = 0;
			int xy = 0;
			int nx= 0;
			int ny = 0;
			for(int i=1;i<n;i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				if(b==0) {
					box[i].x = box[a].x-1;
					box[i].y = box[a].y;
				}
				if(b==1) {
					box[i].y = box[a].y-1;
					box[i].x = box[a].x;
				}
				if(b==2) {
					box[i].x = box[a].x+1;
					box[i].y = box[a].y;
				}
				if(b==3) {
					box[i].y = box[a].y+1;
					box[i].x = box[a].x;
				}
				xx = Math.max(box[i].x,xx);
				xy = Math.max(box[i].y,xy);
				nx = Math.min(box[i].x,nx);
				ny = Math.min(box[i].y,ny);
			}
			int h = xx+1+Math.abs(nx);
			int w = xy+1+Math.abs(ny);
			System.out.println(h+" "+w);
			
		}
	}

}



Measured memory_bytes: 41752
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
#include <cmath>
#include <climits>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

ll gmin = LLONG_MAX;

vector<pair<ll, ll>> searched;

void df(ll x, ll y, const vector<ll> & n, int index)
{
	//debug(x);
	//debug(y);
	//debug(index);
	if (index == n.size())
	{
		chmin(gmin, x + y);
		return;
	}
	//debug(n[index]);

	if (gmin <= x + y)
	{
		return;
	}

	if (std::find(searched.begin(), searched.end(), pair<ll, ll>(x, y)) != searched.end())
	{
		return;
	}

	searched.push_back(pair<ll, ll>(x, y));
	df(x * n[index], y, n, index + 1);
	df(x, y * n[index], n, index + 1);
}

int main()
{
	ll N;
	cin >> N;
	vector<ll> yaku;
	ll n = N;
	ll ans;
	ll sq = sqrt(N);
	for (ll i = 2; n > 1 && i <= sq; i++)
	{
		while (n % i == 0 && i != 1)
		{
			yaku.push_back(i);
			n /= i;
		}
	}
	yaku.push_back(n);

	df(1, 1, yaku, 0);
	ans = gmin - 2;

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


Measured memory_bytes: 384
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
for i in range(1, 3501):
    for j in range(i, 3501):
        a = 4 * i * j - (i + j) * n
        b = i * j * n
        if a != 0:
            k = b // a
            if k > 0 and 4 * i * j * k == n * (i * j + j * k + k * i):
                print(i, j, k)
                exit()

Measured memory_bytes: 62056
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
    int num, counter_ac = 0, counter_wa = 0, counter_tle = 0, counter_re = 0;
    char result[10];
    
    scanf("%d", &num);
    
    int i = 0;
    while(i < num){
        scanf("%s", result);
        if(strcmp(result, "AC") == 0){
            counter_ac++;
        } else if(strcmp(result, "WA") == 0){
            counter_wa++;
        } else if(strcmp(result, "TLE") == 0){
            counter_tle++;
        } else{
            counter_re++;
        }
        i++;
    }
    i = 0;
    
    printf("AC x %d\n", counter_ac);
    printf("WA x %d\n", counter_wa);
    printf("TLE x %d\n", counter_tle);
    printf("RE x %d\n", counter_re);
}


Measured memory_bytes: 1720
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>b)
    {
        printf("a > b\n");
    }
    else if(a<b)
    {
        printf("a < b\n");
    }
    else
    {
        printf("a == b\n");
    }
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  string s1,s2;
  cin >> s1 >> s2;
  vector<vector<int>> dp(s1.size()+1,vector<int>(s2.size()+1,0));
  REP(i,s1.size()+1)dp[i][0] = i;
  REP(i,s2.size()+1)dp[0][i] = i;

  REP(i,s1.size()){
    REP(j,s2.size()){
      int tmp = 1;
      if(s1[i] == s2[j])tmp = 0;
      dp[i+1][j+1] = min(dp[i][j] + tmp, min(dp[i][j+1],dp[i+1][j])+1);
    }
  }

  cout << dp[s1.size()][s2.size()] << endl;
  return 0;
}

Measured memory_bytes: 6888
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    double L;
    cin >> L;
    cout << setprecision(10) << L*L*L/27 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int d;

int f(int x) {
    return x*x*d;
}

int main() {
    while (cin >> d) {
        int ans = 0;
        for (int i = d; i < 600; i += d) {
            ans += f(i);
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){;
	string s;
	long long int a,ans=0;
	int k[10];
	cin>>a;
	s=to_string(a);
	for(int i=s.size()-1;i>=0;i--){
		k[i]=a%10;
		a=(a-(a%10))/10;
	}
	int c=s.size()-1;
	for(int i=0;i<s.size();i++){
		for(int j=s.size()-1-i;j>=0;j--){
			ans+=k[j]*pow(2,c)*pow(10,i);
	
			if(j+i==s.size()-1){
				c--;
			}

		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
nm=[int(x) for x in input().split()]
x=[int(y) for y in input().split()]
margin=[]
sort_x=sorted(x)
for p in range(nm[1]-1):
    margin.append(sort_x[p+1]-sort_x[p])
sort_mar=sorted(margin)
if(nm[0]>=nm[1]):
    print(0)
else:
    print(sum(sort_mar[:nm[1]-nm[0]]))

Measured memory_bytes: 13840
#include<iostream>

using namespace std;

int main()
{
    int i =0;
    string s;
    cin >> s;
    bool flag = true;
    while(i<s.length())
    {
        if(s[i]=='e')
        {
            if(i+5<s.length()&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e'&&s[i+5]=='r')
            {
                i+=6;
            }
            else if(i+4<s.length()&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e')
            {
                i+=5;
            }
            else if(i+1<s.length()&&s[i+1]=='r'&&i>1&&s[i-1]=='m')
            {
                i+=2;
            }
            else{
                flag = false;
                break;
            }
        }
        else if(s[i]=='d')
        {

            if(i+4<s.length()&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m')
            {
                i+=5;
            }
            else{
                flag = false;
                break;
            }
        }
        else{
            flag = false;
            break;
        }
    }
    flag?cout<<"YES"<<endl:cout<<"NO"<<endl;
    return 0;
}




Measured memory_bytes: 512
#include <cstdio>
 
int main(void){
    int n;
    long a, max=-1000000, min=1000000, sum=0;
 
    scanf(" %d", &n);
    for(int i=0; i<n; ++i){
        scanf(" %ld", &a);
        if(a>max) max = a;
        if(a<min) min = a;
        sum+=a;
    }
 
    printf("%ld %ld %ld\n", min, max, sum);
 
    return 0;
}


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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, ans = 0;
    cin >> n;
    ans = n * n * n;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import math
x=int(input())
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
for i in range(x,100004):
    if is_prime(i):
        print(i)
        break

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

int main(void)
{
    int N;
    cin >> N;

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

    int sumPower = 0;
    int minPower = INT_MAX;
    for (int p = 1; p <= 100; p++) {
        sumPower = 0;
        for (int i = 0; i < N; i++) {
            sumPower += pow(X[i] - p, 2);
        }
        if (minPower > sumPower) {
            minPower = sumPower;
        }
    }

    cout << minPower << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

void solve() {
    string s;
    int n;
    cin >> n >> s;
    for (auto &c: s) {
        if (c + n > 'Z') cout << char(c + n - 26);
        else cout << char(c + n);
    }
    cout << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin >> a>> b;
	cout << a*b-a-b+1 << endl;
	
	return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x = 0) : x((x % mod + mod) % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
    mint operator()(int n) { return fact[n]; }
};

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    mint total = mint(2).pow(n) - 1;
    d(total.x);

    // nCa を求めたい．nが大きい
    mint A = 1;
    rep(i, a) { A *= mint(n - i) / mint(a - i); }

    mint B = 1;
    rep(i, b) { B *= mint(n - i) / mint(b - i); }

    total -= A.x + B.x;

    d(A.x);
    d(B.x);

    cout << total.x << endl;

    return 0;
}

Measured memory_bytes: 3620
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let n = nextInt()
    let c = next().split("")
    let l = 0
    let r = c.length-1
    let cnt = 0
    while(l <= r){
        if(c[l] == "W" && c[r] == "R"){
            c[l] == "R"
            c[r] == "W"
            cnt++
            l++
            r--
            continue
        }
        if(c[l] == 'R'){
            l++
        }
        if(c[r] == 'W'){
            r--
        }
    }
    console.log(cnt)
}
Main()



Measured memory_bytes: 34888
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    // Your code here!
    
    //入力
    int a, b, c, d, e;
    int k;
    cin >> a >> b >> c >> d >> e;
    cin >> k;
    
    //処理
    vector<int> v = {a, b, c, d, e};
    bool ok = true;
    for (int i = 0; i < v.size(); i++){
        for (int j = 0; j < v.size(); j++){
            if (v[j] - v[i] > k) {
                ok = false;
            }
        }
    }
    string ans = "";
    if (ok) ans = "Yay!";
    else ans = ":(";
    
    //出力
    cout << ans << endl;
    
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,k;
  cin >> n >> k;
  vector<ll> cost(n+10,INT_MAX);
  vector<ll> height(n+10);
  rep(i,n) cin>>height[i+1];
  cost[1]=0;
  
  for(ll i=1;i<=n;i++){
    for(ll j=i+1;j<=i+k;j++){
      if(j<=n) cost[j]=min(cost[i]+abs(height[j]-height[i]),cost[j]);
    }
  }
  cout << cost[n] <<endl;
}

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        SemiCommonMultiple solver = new SemiCommonMultiple();
        solver.solve(1, in, out);
        out.close();
    }

    static class SemiCommonMultiple {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long m = in.nextLong();

            long x = 1;
            long div_num = -1;
            for (int i = 0; i < n; i++) {
                long a = Long.parseLong(in.next()) / 2;
                x = lcm(x, a);

                if (m < x) {
                    out.print(0);
                    return;
                }

                long dnum = 0;
                while (true) {
                    if (a % 2 == 0) {
                        dnum++;
                        a /= 2;
                    } else {
                        break;
                    }
                }
                if (div_num == -1) {
                    div_num = dnum;
                } else {
                    if (div_num != dnum) {
                        out.print(0);
                        return;
                    }
                }
            }

            out.print((m / x + 1) / 2);
        }

        static long lcm(long a, long b) {
            return a * b / gcd(a, b);
        }

        static long gcd(long a, long b) {
            return b == 0 ? a : gcd(b, a % b);
        }

    }
}



Measured memory_bytes: 58604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%lld",&x);
int main(){
    ll n,x,ans = 0,tmp; sc(n)
    map<ll,ll> mp;
    queue<ll> q;
    for (int i = 0; i < n; i++){
        sc(x)
        ++mp[x];
        q.push(x);
    }
    for (const auto &x : mp){
        ans += (x.second) * (x.second - 1) / 2ll;
    }
    while (!q.empty()){
        x = q.front(); q.pop();
        tmp = (mp[x] - 1ll) * mp[x] / 2ll - (mp[x] - 2ll) * (mp[x] - 1ll) / 2ll;
        cout << ans - tmp << endl;
    }
    return 0;
}

Measured memory_bytes: 11136