akhauriyash/Code-Regression huggingface dataset:
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    string s; cin >> s;
    int N = s.length();
    vector<int> cnt(26);

    int ans = 1;
    for(int i=N-1; i>=0; i--) {
        int sum = N-1 - i, c = s[i] - 'a';
        ans += sum - cnt[c];
        cnt[c]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <string>
#include <utility> //swap
#include <cassert> //assert
using namespace std;
using ll=long long;



ll gcd(ll a, ll b){
  if(a <= b) swap(a,b);
  if(b==0)return a;
  else return gcd(b,a%b);
}

int main() {
  ll a,b,k;

  cin >> a >> b >> k;

  ll max = gcd(a,b);
  int i = 0, n = 0;
  for(;n<k;){
    i++;
    if (max%i == 0) n++;
  }
  cout << max/i << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;
const string nyan("(=^・ω・^=)");

int N, M, Q, S, T, a, b, c, uf[4000], r[4000], d[4000][2][15];
priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>>q;
vector<pair<int, int>>v[4000];
ll e;

int t(int x) {
	if (uf[x] < 0)return x;
	return uf[x] = t(uf[x]);
}

bool u(int x, int y) {
	x = t(x);
	y = t(y);
	if (x == y)return false;
	if (uf[x] < uf[y]) {
		uf[x] += uf[y];
		uf[y] = x;
	}
	else {
		uf[y] += uf[x];
		uf[x] = y;
	}
	return true;
}

void dfs(int x) {
	for (auto p : v[x]) {
		if (!r[p.second]) {
			r[p.second] = r[x] + 1;
			d[p.second][0][0] = p.first;
			d[p.second][1][0] = x;
			dfs(p.second);
		}
	}
}

int calc(int x, int y) {
	int m = 0;
	if (r[x] < r[y]) {
		for (int i = 14; i >= 0; --i) {
			if (r[x] + (1 << i) <= r[y]) {
				m = max(m, d[y][0][i]);
				y = d[y][1][i];
			}
		}
	}
	if (r[x] > r[y]) {
		for (int i = 14; i >= 0; --i) {
			if (r[y] + (1 << i) <= r[x]) {
				m = max(m, d[x][0][i]);
				x = d[x][1][i];
			}
		}
	}
	if (x != y) {
		for (int i = 14; i >= 0; --i) {
			if (d[x][1][i] != d[y][1][i]) {
				m = max(m, d[x][0][i]);
				m = max(m, d[y][0][i]);
				x = d[x][1][i];
				y = d[y][1][i];
			}
		}
		m = max(m, d[x][0][0]);
		m = max(m, d[y][0][0]);
	}
	return m;
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		cin >> a >> b >> c;
		q.push(mkp(c, mkp(a - 1, b - 1)));
	}
	memset(uf, -1, sizeof uf);
	while (!q.empty()) {
		if (u(q.top().second.first, q.top().second.second)) {
			v[q.top().second.first].push_back(mkp(q.top().first, q.top().second.second));
			v[q.top().second.second].push_back(mkp(q.top().first, q.top().second.first));
			e += q.top().first;
		}
		q.pop();
	}
	r[0] = 1;
	dfs(0);
	for (int i = 0; i < 14; ++i) {
		for (int j = 0; j < N; ++j) {
			d[j][0][i + 1] = max(d[j][0][i], d[d[j][1][i]][0][i]);
			d[j][1][i + 1] = d[d[j][1][i]][1][i];
		}
	}
	cin >> Q;
	while (Q--) {
		cin >> S >> T;
		cout << e - calc(S - 1, T - 1) << endl;
	}
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define en '\n'
#define fs first
#define sd second

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k;
    cin >> k;
    string s;
    cin >> s;
    if(s.length() <= k){
        cout << s << en;
    }else{
        string s1(s.begin(), s.begin()+k);
        cout << s1 << "..." << en;
    }
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int n;cin>>n;
  printf("%.6lf\n",n*2*3.1415926535897932384626433832795028841);
  return 0; 
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin>>n;
	int h[n]; rep(i,n) cin>>h[i];
	for(int i=n-2;i>=0;--i){
		if(h[i]>h[i+1]){
			h[i]--;
			if(h[i]>h[i+1]){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 640
N = int(input())
W = [input()for i in range(N)]

tmp = 'a'
ans = 'Yes'
for i in range(N):
    word = list(W[i])
    if (i > 0) and  (word[0] != tmp):
        ans = 'No' 
    #print(ans)
    tmp = word[len(word)-1]

for i in range(N):
    for j in range(i+1,N):
        if W[j] == W[i]:
            ans = 'No'

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    ll x;cin >> x;
    ll res = 0;
    ll co500 = x/500;
    x = x-co500*500;
    ll co5 = x/5;
    cout << 1000*co500 + 5*co5 << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2000000001)

def solve(n,k,ar,dp,x):
	ab = abs; mn = min
	if x>=n-2: return dp[x]
	if not dp[x] is -1: return dp[x]
	dp[x] = mn(map(lambda i:ab(ar[x]-ar[i])+solve(n,k,ar,dp,i), range(x+1,mn(n,x+k+1))))
	return dp[x]

def main():
	I = lambda:map(int,sys.stdin.readline().split())
	pr = lambda x:sys.stdout.write(f'{x}\n')
	n,k, ar = *I(), [*I()]
	dp = [-1]*(n-2) + [abs(ar[-2]-ar[-1]),0]
	pr(solve(n,k,ar,dp,0))

main()

Measured memory_bytes: 374284
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int n,k,t;
  cin >> n >> k;
  for (int i=0; i<n; i++){
    int a;
    cin >> a;
    t += (k/2<a)?(k-a)*2:a*2;
  }
  cout << t << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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()
{   
    int h,w; cin >> h >> w;
    int row = 10,col = 10;
    vector<vector<int> > c(10,vector<int>(10));
    //vector<vector<int> > a(h,vector<int>(w));
    rep(i,10)rep(j,10) cin >> c[i][j];
    //rep(i,h)rep(j,w)cin >> a[i][j];

    //ワーシャルフロイド法を用いて最短距離を求める
    rep(k,10){
        rep(i,row){
            rep(j,col){
                chmin(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }
    ll res = 0;
    rep(i,h){
        rep(j,w){
            int a;cin >> a;
            if(a==-1)continue;
            res += c[a][1];
        }
    }
    cout << res << endl;
}


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

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

	int A, B, C;
	cin >> A >> B >> C;
	if (A == C) {
		cout << B;
		return 0;
	}
	if (A == B) {
		cout << C;
		return 0;
	}
	cout << A;
}

Measured memory_bytes: 256
<?php
$to_i = function($s){return (int)$s;};
for(;;) {
    $d = array_map($to_i, explode(" ", (fgets(STDIN))));
    if($d == array(0, 0)) break;
    sort($d);
    echo(implode(" ", $d));
    echo("\n");
}


Measured memory_bytes: 9276
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n; cin >> n;
  set<char> st;
  while (n--) {
    char s; cin >> s;
    st.emplace(s);
  }
  cout << (st.size() == 3 ? "Three\n" : "Four\n");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
void output(int array[],int array2[],int number){
    int num = 0;
    for(int j = 0;j<number;j++){
        num = num + array[j]*array2[j];               
    }
    cout<<num<<endl;
}

int main(){
    int r,c;
    int number;
    int array[101][101];
    cin>>r>>c;
    int sum = 0;
    for(int i = 0;i < r;i++){
        for(int j = 0;j<c;j++){
            cin>>number;
            array[i][j] = number;
            sum = sum + number;
            if(j == c-1){
                array[i][j+1] = sum;
            }
        }
        sum = 0;
    }
    sum = 0;
    for(int i = 0;i < c+1;i++){
        for(int j = 0;j<r;j++){
            sum = sum + array[j][i];
            if(j == r-1){
                array[j+1][i] = sum;
                sum = 0;
            }
        }       
    }
    for(int i = 0;i < r+1;i++){
        for(int j = 0;j < c+1;j++){
            if(j < c){
                cout<<array[i][j]<<" "; 
            }else{
                cout<<array[i][j]<<endl;
            }
            
        }
    }
    return 0;
}


Measured memory_bytes: 3128
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<cstdio>
using namespace std;
#pragma warning(disable:4996)
int c[1000], n;
int main() {
	cin >> n;
	for (int i = 0; i < 2 * n; i++)cin >> c[i];
	sort(c, c + (2 * n));
	int sum = 0;
	for (int i = 0; i < 2 * n; i += 2)sum += c[i];
	cout << sum << endl;
	return 0;
}

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

int main(){
	string s;
  	cin>>s;
  	int start,end;
  	for(int i=0;i<s.size();i++){
    	if(s.at(i)=='A'){
        	start=i;
          	break;
        }
    }
  
  	for(int i=s.size()-1;i>=0;i--){
    	if(s.at(i)=='Z'){
        	end=i;
          	break;
        }
    }
  cout<<end-start+1<<endl;
}    

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int> a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(), (a).end()

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

ll gcd(ll a, ll b)
{
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

ll keta(ll n)
{
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1, 0, -1, 0};
const int dw[4] = {0, 1, 0, -1};

struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
//using P = pair<ll, int>;

class UnionFind
{
public:
  vi Parent;
  UnionFind(int n)
  {
    Parent = vi(n, -1);
  }

  int root(int a)
  {
    if (Parent[a] < 0)
      return a;
    else
      return Parent[a] = root(Parent[a]);
  }

  int size(int a)
  {
    return -Parent[root(a)];
  }

  bool merge(int a, int b)
  {
    a = root(a);
    b = root(b);
    if (a == b)
      return false;

    if (size(a) < size(b))
      swap(a, b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial
{
public:
  vl Fac;
  Factrial(int MAX)
  {
    Fac = vl(MAX + 1);
    rep(i, MAX)
    {
      if (i == 0)
        Fac[i + 1] = 1;
      else
        Fac[i + 1] = ((i + 1) * Fac[i]) % MOD;
    }
  }
};

const int N = 10010001; //10^7

bool is_prime[N];
vi P;
void Eratosthenes(int N)
{
  is_prime[0] = false;
  is_prime[1] = false;
  for (int i = 2; i < N; i++)
    is_prime[i] = true;
  for (int i = 2; i <= N; i++)
  {
    if (is_prime[i])
    {
      P.emplace_back(i);
      for (int j = 2 * i; j <= N; j += i)
      {
        is_prime[j] = false;
      }
    }
  }
}

int main(){
  int X; cin >> X;
  Eratosthenes(N);

  for(auto num : P) {
    if(num >= X){
      cout << num << endl;
      return 0;
    }
  }
}

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

using namespace std;

void solve()
{
	int M, N;
	cin >> M >> N;
	vector< vector<char> > Data(M);
	for(int i = 0; i < M; ++i)
	{
		Data[i].resize(N);
		for(int j = 0; j < N; ++j)
		{
			cin >> Data[i][j];
		}
	}
	vector<int> sum(M);
	for(int i = 0;i  < M; ++i)
	{
		for(int j = 0; j < N; ++j)
		{
			if(Data[i][j] == '1')
			{
				sum[i]++;
			}
		}
	}
	int max = 0;
	for(int i = 0; i < M; ++i)
	{
		if(sum[i] > max)
		{
			max = sum[i];
		}
	}
	cout << max << endl;


}

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

Measured memory_bytes: 0
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def main():
    N, K = read_values()
    res = 0
    P = K // 2 if K % 2 == 0 else K
    for a in range(P, N + 1, P):
        k = a // K + 1
        l = (N + a) // K
        res += (l - k + 1) ** 2

    print(res)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        int k = int.Parse(Console.ReadLine());
        var curDig = new List<long>(Enumerable.Range(1, 9).Select(x => (long)x));
        var res = new List<long>(curDig);
        while (res.Count < k)
        {
            var next = new List<long>();
            foreach (var item in curDig)
            {
                var lastDig = item % 10;
                if (lastDig != 0) next.Add(item * 10 + lastDig - 1);
                next.Add(item * 10 + lastDig);
                if (lastDig != 9) next.Add(item * 10 + lastDig + 1);
            }
            res.AddRange(next);
            curDig = next;
        }
        Console.WriteLine(res[k - 1]);
    }
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
ll const inf = LLONG_MAX / 2;

int main() {
  int N; cin >> N;
  vector<ll> A(N), sum(N); cin >> A;
  sort(A.begin(), A.end());
  rep(i, N) sum[i] += (i ? sum[i - 1] : 0) + A[i];
  rep(i, N) sum[i] *= 2;
  int p = 0;
  REP(i, 1, N - 1) {
    if (sum[i - 1] < A[i]) {
      p = std::max(p, i);
    }
  }
  cout << N - p << "\n";
}


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

int main(){
#ifdef _DEBUG
	freopen("in" , "r", stdin );
	freopen("out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	string s; cin >> s >> s;
	cout << 'A' << s[0] << 'C' << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int n, m, ma = 0;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    for(int i = 0;i < n;i++){
        b[i] = max(a[i], ma);
        ma = max(a[i], ma);
    }
    ma = 0;
    for(int i = n - 1;i >= 0;i--){
        c[i] = max(a[i], ma);
        ma = max(a[i], ma); 
    }

    for(int i = 0;i < n;i++){
        if(i == 0){
            cout << c[i + 1] << "\n";
        }
        else if(i == n - 1){
            cout << b[i - 1] << "\n";
        }
        else{
            m = max(b[i - 1], c[i + 1]);
            cout << m << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 3968
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;double a,b,x;cin>>a>>b>>x;
	//x=x/a;
	if(x>a*a*b/2){
		//cout << atan(2*(a*b-x/a)/(a*a))*(180.0/3.14159265359) << endl;
		printf("%.10f\n", atan(2*(a*b-x/a)/(a*a))*(180.0/3.14159265359));
	}else{
		//cout << atan((b*b*a)/(2*x))*(180.0/3.14159265359) << endl;
		printf("%.10f\n", atan((b*b*a)/(2*x))*(180.0/3.14159265359));
	}
	return 0;
}


Measured memory_bytes: 512
A, B, C, X, Y = map(int, input().split())

cost = 10**9
for i in range(2*10**5+1):
    if i%2==0:
        a_num = X-int(0.5*i)
        b_num = Y-int(0.5*i)
        if a_num < 0 and b_num < 0:
            break
        cost = min(cost, A*max(a_num, 0)+B*max(b_num, 0)+C*i)

print(cost)

Measured memory_bytes: 3064
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse = True)

s = []
i = 0
while i < N - 1:
    if A[i] == A[i + 1]:
        s.append(A[i])
        if len(s) == 2:
            print(s[0] * s[1])
            break
        i += 2
    else:
        i += 1
else:
    print(0)

Measured memory_bytes: 20144
#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462
typedef long long ll;
typedef double db;
ll mod=1e9+7,p1[2000005],p2[2000005],p26[2000005],p25[2000005];
ll qpow(ll a,ll b){ll res=1;while(b){if(b&1) res=res*a%mod;a=a*a%mod;b/=2;}return res%mod;}
ll C(ll a,ll b){
    return (p1[a]%mod*p2[b]%mod*p2[a-b]%mod)%mod;
}
int main(){
    ll k,ans=0;cin>>k;
    string s;cin>>s;
    ll n=s.length();
    p1[0]=1;p2[0]=1;p26[0]=1;p25[0]=1;
    for(ll i=1;i<=2000000;i++){
        p1[i]=(p1[i-1]%mod*i%mod)%mod;
        p2[i]=qpow(p1[i],mod-2);
        p26[i]=(p26[i-1]%mod*26)%mod;
        p25[i]=(p25[i-1]%mod*25)%mod;
    }
    k=k+n;
    for(int i=n;i<=k;i++){
        ll num=(C(i-1,n-1)%mod*p26[k-i]%mod*p25[i-n]%mod)%mod;
        ans=(ans%mod+num%mod)%mod;
    }
    cout<<ans%mod<<endl;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;
set<char> bo = {'a', 'i', 'u', 'e', 'o'};

class Solver {
  public:
    bool solve() {
        int N; cin >> N;
        if(N == 0) return 0;
        vector<string> S(N); cin >> S;
        auto get = [&](string s, int k) {
            string res;
            bool flg = true;
            for(char c : s) {
                if(flg) {
                    res.push_back(c);
                    if(res.size() == k) return res;
                }
                flg = bo.count(c);
            }            
            return res;
        };
        for(int k = 1; k <= 50 ;k++) {
            set<string> used;
            rep(i, N) {
                auto s = get(S[i], k);
                if(used.count(s)) goto FAIL;
                used.insert(s);
            }
            cout << k << endl;
            return 1;
      FAIL:;
        }
        cout << -1 << endl;
        return 1;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(Solver().solve());
    return 0;
}

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

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

using ll = long long;

const std::string RGB = "RGB";

ll N;
std::string S;
ll sum[4010][3];
ll ans;

int main()
{
  std::cin >> N >> S;

  ll L = S.size();

  rep( i, L )
  {
    ll kind = RGB.find(S[i]);

    rep( j, 3 )
      sum[i+1][j] = sum[i][j]+(j==kind?1:0);
  }

  rep( j, L )
  {
    ll sj = RGB.find(S[j]);

    rep( k1, 3 ) rep( k2, 3 )
    {
      if( k1 == k2 )
        continue;
      
      if( k1 == sj || k2 == sj )
        continue;

      ll ret = sum[j][k1]*(sum[L][k2]-sum[j+1][k2]);

      rep( d, L )
      {
        if( j-d < 0 || j+d >= L )
          continue;

        if( RGB.find(S[j-d]) == k1 && RGB.find(S[j+d]) == k2 )
          --ret;
      }

      ans += ret;
    }
  }

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

  return 0;
}

Measured memory_bytes: 3292
S = input()

S_list = list(S)
N = len(S_list)
#print(N)
no_flag = 0

for i in range(N//2):
    if S_list[i] != S_list[N-i-1]:
        no_flag = 1

for i in range(int((N-1)/2)//2):
    #print(S_list[i], S_list[(N-1)//2-i-1])
    if S_list[i] != S_list[(N-1)//2-i-1]:
        no_flag = 1

for i in range((N-3)//2):
    #print(S_list[(N+3)//2+i-1], S_list[N-1-i])
    if S_list[(N+3)//2+i-1] != S_list[N-1-i]:
        no_flag = 1

if no_flag == 1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int ans = 0;
  
  for(int i=1;i<N+1;i++){
    if(i%2==1){
    int x = 0;
    for(int j=1;j<=i;j++){
      if(i%j==0) x++;
    }
    if(x==8) ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>

typedef long long ll;
using namespace std;

typedef pair<int,int> P;

int main()
{

	int a;
	map<int,int> num;
	queue<int> que;
	while(~scanf("%d",&a)){
		num[a]++;
	}

	int max_freq = -1;

	for(map<int,int>::iterator it=num.begin(); it != num.end(); it++){
		if(it->second == max_freq){
			que.push(it->first);
		}
		else if(it->second > max_freq){
			while(!que.empty()){
				que.pop();
			}
			max_freq = it->second;
			que.push(it->first);
		}
		
	}

	while(!que.empty()){
		cout << que.front() << endl;
		que.pop();
	}

}

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

#define MAX(a,b) ((a)>(b)?(a):(b))

int main(void){
    char input[500000];
    scanf("%s",input);
    int inp_len = strlen(input);
    int  lt_c[inp_len],gt_c[inp_len];
    for(int i = 0;i < inp_len;i++){
        lt_c[i] = 0;
        gt_c[i] = 0;
    }
    if(input[0] == '<')lt_c[0] = 1;
    if(input[inp_len-1] == '>')gt_c[inp_len-1] = 1;
    for(int i = 1;i < inp_len;i++)if(input[i] == '<')lt_c[i] = lt_c[i-1]+1;
    for(int i = inp_len-2;i >= 0;i--)if(input[i] == '>')gt_c[i] = gt_c[i+1]+1;
    long ans = 0;
    ans += MAX(0,gt_c[0]);
    for(int i = 0;i < inp_len-1;i++)ans += MAX(lt_c[i],gt_c[i+1]);
    ans += MAX(0,lt_c[inp_len-1]);
    printf("%ld",ans);
    return 0;
}

Measured memory_bytes: 4608
#include <iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n,k;
llong T[MAX];

int check(llong P){
  int i=0;
  for(int j=0;j<k;j++){
    llong s=0;
    while(s+T[i]<=P){
      s+=T[i];
      i++;
      if(i==n)return n;
    }
  }
  return i;
}

int solve(){
  llong left=0;
  llong right=100000*10000;
  llong mid;
  while(right-left>1){
    mid=(left+right)/2;
    int v=check(mid);
    if(v>=n)right=mid;
    else left=mid;
  }
  return right;
}

int main(){
  cin>>n>>k;
  for(int i=0;i<n;i++)cin>>T[i];
  llong ans=solve();
  cout<<ans<<endl;
}



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

void solve_1(){//
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int button_id = 0;
    rep(i,n)
    {
        button_id = a[button_id] - 1;
        if (button_id == 1)
        {
            cout << i + 1 << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main(){
    solve_1();
    return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
double exp(double p){
    double sum=((1+p)*p)/2;
    sum/=p;
    return sum;
}
int main(){
    cout << fixed << setprecision(12);
    int n,k;cin >> n >> k;
    vector<double> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
        p[i]=exp(p[i]);
    }
    double ans=0;
    for(int i=0; i<k; i++) ans+=p[i];
    double maxx=ans;
    for(int i=0; i<n-k; i++){
        if(maxx<ans-p[i]+p[i+k]) {
            maxx=ans-p[i]+p[i+k];
        }
        ans=ans-p[i]+p[i+k];
    }
    cout << maxx << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

ll g(ll x){
	ll ret = 0;
	REP(i, 40){
		if(i == 0){
			if(x%4==1 || x%4==2) ret++;
		} else {
			ll p = 1LL<<(i+1);
			ll q = x%p;
			if(q >= p/2 && q%2==0) ret+=1LL<<i;
		}
	}
	return ret;
}

int main(){
	ll a, b; scanf("%lld%lld", &a, &b);
	printf("%lld\n", g(max(a-1, 0LL))^g(b));
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    long long n, l; std::cin >> n >> l;
    std::vector<long long> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    for (int i = 0; i < n - 1; i++) {
        if (a[i] + a[i + 1] >= l) {
            std::cout << "Possible" << std::endl;
            for (int j = 1; j <= i; j++) std::cout << j << std::endl;
            for (int j = n - 1; j >= i + 1; j--) std::cout << j << std::endl;
            return 0;
        }
    }
    std::cout << "Impossible" << std::endl;
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

void print(int id, std::vector<int> tree) {
    std::cout << "node " << id << ": key = " << tree[id-1] << ", ";
    if (id/2 > 0) {
        std::cout << "parent key = " << tree[id/2-1] << ", ";
    }
    if (2*id <= tree.size()) {
        std::cout << "left key = " << tree[2*id-1] << ", ";
    }
    if (2*id+1 <= tree.size()) {
        std::cout << "right key = " << tree[2*id] << ", ";
    }
    std::cout << "\n";
}

int main() {
    int n, h;
    std::cin >> n;
    std::vector<int> tree;
    for (int i=0; i<n; i++) {
        std::cin >> h;
        tree.push_back(h);
    }

    for (int i=1; i<=n; i++) {
        print(i, tree);
    }

    return 0;
}


Measured memory_bytes: 3132
S = input()

aa = S[0:2]
bb = S[2:4]


def isYY(yy):
    if 0 <= int(yy) and int(yy) <= 99:
        return True
    else:
        return False


def isMM(mm):
    if 1 <= int(mm) and int(mm) <= 12:
        return True
    else:
        return False


ans = []
if isYY(aa) and isMM(bb):
    # YYMM
    ans.append('YYMM')
if isMM(aa) and isYY(bb):
    # MMYY
    ans.append('MMYY')

if len(ans) >= 2:
    print('AMBIGUOUS')
elif len(ans) == 1:
    print(ans[0])
else:
    print('NA')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define double long double
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  string s;
  ll k, n;
  
  cin >> k >> n;
  
  ll ans = -1;
  
  vector<ll> a(n);
  rep(i, 0, n) cin >> a[i];
  rep(i, 1, n) {
    ans = max((int)(ans), (int)(a[i] -a[i-1]));
  }
  ans = max((int)(ans), (int)(a[0] -a[n-1] +k));
  
  cout << k -ans << "\n";

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define p pair<int, ll>
#define INF 1e18 + 7
#define MAX 100005
using namespace std;

vector<p> edge[MAX];
ll dist[MAX];

void dijkstra(int k){
  priority_queue<p, vector<p>, greater<p> > que;
  bool color[MAX];
  for(int i = 0; i < MAX; i++){
    dist[i] = INF;
    color[i] = false;
  }
  dist[k] = 0;
  que.push(p(k, 0));
  while(!que.empty()){
    p f = que.top(); que.pop();
    int v = f.first;
    color[v] = true;
    if(dist[v] < f.second) continue;
    for(int i = 0; i < edge[v].size(); i++){
      p e = edge[v][i];
      if(color[e.first] == true) continue;
      if(dist[e.first] > dist[v] + e.second){
        dist[e.first] = dist[v] + e.second;
        que.push(p(e.first, dist[e.first]));
      }
    }
  }
}

int main(){
  int n, a, b;
  int q, k, x, y;
  ll c;
  cin >> n;
  for(int i = 0; i < n - 1; i++){
    cin >> a >> b >> c;
    a--; b--;
    edge[a].push_back(p(b, c));
    edge[b].push_back(p(a, c));
  }
  cin >> q >> k;
  dijkstra(k - 1);
  for(int i = 0; i < q; i++){
    cin >> x >> y;
    x--; y--;
    cout << dist[x] + dist[y] << endl;
  }
  return 0;
}

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

#define ll long long
#define db double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

int n;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	vector <int> ans;
	while (!a.empty()) {
		n = a.size();
		bool ok = false;
		for (int j = n - 1; j >= 0; j--) {
			if (a[j] == j + 1) {
				ans.pb(a[j]);
				a.erase(a.begin() + j);
				ok = true;
				break;
			}
		}
		if (!ok) {
			cout << -1;
			return 0;
		}
	}
	reverse(all(ans));
	for (int i : ans) {
		cout << i << '\n';
	}
}


Measured memory_bytes: 256
S = input()

def isKaibun(s):
    l = len(s)
    return all(s[i] == s[-1-i] for i in range(l))
    #return s[:l//2] == s[-1:l//2:-1]

if isKaibun(S) and isKaibun(S[:(len(S)-1)//2]) and isKaibun(S[(len(S)+3)//2-1:]):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
ans1 = 0
ans2 = 0

for i in range(x, n):
    if i in a:
        ans1 += 1
for i in range(1, x):
    if i in a:
        ans2 += 1
print(min(ans1, ans2))


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

int n, k, s;
int ans;

void dfs(int i, int k, int s){
    if(k == 0){
        if(s == 0)  ans++;
        return;
    }

    if(i > n || i > s)   return;

    dfs(i+1, k-1, s-i);
    dfs(i+1, k, s);
}

int main(){
    while(cin >> n >> k >> s, n+k+s){
        ans = 0;
        dfs(1, k, s);
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    if ((B - A) % 2 == 0) {
        cout << (B - A) / 2 << endl;
    }
    else {
        ll m = std::min((B - 1), (N - A));
        ll a = ((B - A) - 1) / 2 + A;
        ll b = (N - (A + (N - B + 1))) / 2 + (N - B + 1);
        cout << std::min(m, std::min(a, b)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,num,v,res;
vector<int>d[15];
int cal(int x,int y)
{
	int ans=0;
	for(int i=0;i<num;++i)
	{
		int v=(d[x][i]-d[y][i]);
		ans+=v*v;
	}
	return ans;
}
int main()
{
	scanf("%d%d",&n,&num);
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=num;++j)
		{
			scanf("%d",&v);
			d[i].push_back(v);
		}
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=i+1;j<=n;++j)
		{
			int v=cal(i,j);
			int sq=sqrt(v+0.5);
			if(sq*sq==v)res++;
		}
	}
	printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long ul;
// #define int long long

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング

// func declaration
template <class T> void print2DVec(vector< vector<T> >&);
template <class T> void calcVec(vector<T>&, int, char);
int char_to_int(const char);

// const
const int INF = 10000000;

/*MEMO
・辞書順
abc < abcd, atcoder < atlas
・イテレータ
std::vector<int>::iterator とタイプするのは面倒なので、
 通常は型推論の auto を使用する。
 auto iter = max_element(ALL(vec));
・2次元配列
vector<vector<int>> vec = {{1, 2, 3}, {4, 5, 6}}
・20×10の配列
vector<vector<int>> vec(20, vector<int>(10, 0));
・(n, m)の多次元配列
vector< vector<int> > vec(n, vector<int>(m, 0))  // 0で初期化
*/

int main() {
    cin.tie();
    ios::sync_with_stdio(false);
    
    // input
    int x, y;
    cin >> x >> y;
    
    cout << (x-1)*(y-1) << "\n";
    
    return 0;
}


// function
template <class T> void print2DVec(vector< vector<T> >& vec) {
    REP(i, vec.size()) {
        REP(j, vec.front().size()) {
            cout << vec.at(i).at(j);
        }
        cout << endl;
    }
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}

int char_to_int(const char c) {
    if('0' <= c && c <= '9') return (c - '0');
    return -1;
}


Measured memory_bytes: 256
N, A, B = list(map(int, input().split()))
x = (B-A)
if x%2 == 0:
    print(x//2)
else:
    if B-1 > N-A:
        y = N-B
        AA = A+y+1
        print((N-AA)//2 + y+1)
    else:
        y = A-1
        BB = B-y-1
        print((BB-1)//2 + y+1)

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

using namespace std;

int main(void){
    string str; cin >> str;
    if(str[2] == str[3] && str[4] == str[5]){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;

int main() {
	string s;
	cin >> s;
	while(s != "0") {
		int size = s.size();
		int sum = 0;
		for(int i = 0; i < size; i++) {
			sum += (int)(s[i] - '0');
		}
		cout << sum << "\n";
		cin >> s;
	}
}


Measured memory_bytes: 3196
C=[]
for i in range(3):
    c=input().split()
    C.append([int(i) for i in c])
    
ans="No"    
if C[0][2]+C[2][0]-C[0][0]-C[2][2]==0:
    if C[0][2]+C[1][1]-C[0][1]-C[1][2]==0:
        if C[2][0]+C[1][1]-C[1][0]-C[2][1]==0:
            ans="Yes"
            
print(ans)
    


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

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

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"

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 ctoi(const char c);

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    string n;
    cin >> n;
    ll ba = 0;
    REP(i,n.length()){
        ba += ctoi(n[i]);
    }
    if(ba % 9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

Measured memory_bytes: 3736
n=int(input())
s=[str(input()) for i in range(n)]
m=int(input())
t=[str(input()) for i in range(m)]

mny_l=[]

for i in range(n):
    mny=0
    for j in range(n):
        if s[i]==s[j]:
            mny+=1
    for j in range(m):
        if s[i]==t[j]:
            mny-=1
    mny_l.append(mny)
ans=max(0,max(mny_l))
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define forinc(i,a,b) for(int i=a;i<=b;i++)
#define fordec(i,a,b) for(int i=a;i>=b;i--)
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
#define mod 1000000007
#define st first
#define nd second
#define mid (l+r)/2
#define int long long
#define bit(x,i) ((x>>(i))&1)
#define batbit(x,i) (x|(1<<(i)))
#define tatbit(x,i) (x&~(1<<(i)))
#define pii pair<int,int>
#define pb push_back
using namespace std;
int const N=5e5+29;
string S;
int x[N],cl[N];
set<int> p[N];
vector<int> ke[N];
void dfs(int u)
{
    cl[u]=1;
    for(auto v:ke[u])
    {
        if(!cl[v])
        {
            if(p[u].count(v)) x[v]=max(x[v],x[u]+1);
            dfs(v);
            if(!p[u].count(v)) x[u]=max(x[v]+1,x[u]);
        }
    }
}
main()
{
    //freopen("A.inp","r",stdin);
    cin>>S;
    forinc(i,0,S.size()-1)
    {
        if(S[i]=='>')
        {
            p[i+2].insert(i+1);
            ke[i+1].pb(i+2);
            ke[i+2].pb(i+1);
        }
        else
        {
            p[i+1].insert(i+2);
            ke[i+2].pb(i+1);
            ke[i+1].pb(i+2);
        }
    }
    forinc(i,1,S.size()+1)
    if(p[i].empty())
    {
        dfs(i);
    }
    int kq=0;
    forinc(i,1,S.size()+1) kq+=x[i];
    cout<<kq;
}


Measured memory_bytes: 114052
using System;

namespace dot
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            Console.WriteLine(Math.Max(a+b, Math.Max(a-b, a*b)));
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
int main()
{
	int a,b,x,y,z,temp;
	scanf("%d %d",&a,&b);
	x=a+b;
	y=a-b;
	z=a*b;
	if(x<y){ temp=x; x=y; y=temp; }
	if(y<z){ temp=y; y=z; z=temp; }
	if(x<y){ temp=x; x=y; y=temp; }
	printf("%d\n",x);
}

Measured memory_bytes: 1728
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

    if (a == b && a == c) {
      System.out.println("No");
    } else if (a != b && a != c && b != c) {
      System.out.println("No");
    } else if (a == b) {
      System.out.println("Yes");
    } else if (b == c) {
      System.out.println("Yes");
    } else if (a == c) {
      System.out.println("Yes");
    }
  }
}


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

int main(){
	double n;
	cin >> n;
	int m = n / 1.08;
	if(m == n / 1.08) cout << m << endl;
	else if(m < n / 1.08){
		m++;
		if((int)(m*1.08)==n) cout << m << endl;
		else cout << ":(" << endl;
	}
	return 0;
}

Measured memory_bytes: 256