akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    static int N;
    static ArrayList<String> W;

    private static void init() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        scanner.nextLine();
        W = new ArrayList<>();
        for(int i = 0; i < N; i++) {
            W.add(scanner.nextLine());
        }
        scanner.close();
    }


    public static void main(String args[]) {
        init();

        boolean ok = true;
        char prevTail = 'a';
        for(int i = 0; i < N; i++) {
            for(int j = 0; j < N; j++) {
                if(i != j) {
                    if(W.get(i).equals(W.get(j))) {
                        ok = false;
                        break;
                    }
                }
            }

            if(i != 0 && prevTail != W.get(i).charAt(0)) {
                ok = false;
            }
            prevTail = W.get(i).charAt(W.get(i).length() - 1);
        }

        if(ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := getNextString(scanner)
	if strings.ToLower(a) == a {
		fmt.Fprintln(writer, "a")
		return
	}
	fmt.Fprintln(writer, "A")
}


Measured memory_bytes: 1820
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <sstream>
#include <vector>
#include <set>
#include <unordered_map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	string s;
	cin >> s;

	auto check = [&](int len) {
	
		unordered_map<string, int> mp;
		for (int j = 0; j <= N - len; j++) {
			string tmp = s.substr(j, len);
			auto itr = mp.find(tmp);
			if (itr == mp.end()) mp.emplace(tmp, j);
			else if (j - itr->second >= len) return true;
		}
		
		return false;
	};

	
	auto biSearch = [&](auto f) {
		
	int ng = -1;
	int ok = N;

	while (abs(ok - ng) > 1) {
		int mid = (ok + ng) / 2;

		if (!f(mid)) ok = mid;
		else ng = mid;
	}

	return ok;
	};
	
	cout << biSearch(check) - 1;
	
	return 0;
}


Measured memory_bytes: 6684
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/rope>
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
//
//template<class T> using Tree = tree<T, null_type, less<T>, rb_t_tag,t_order_statistics_node_update>;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;
//const long long mod = 998244353;

// watch this
//using ll = long long;
//typedef long long LL;
#define ll long long
#undef ll

const int mxN = 2000010;

long long pow_mod(long long base, long long power) {
	long long res = 1;
	while (power) {
		if (power & 1)
			res = res * base % mod;
		base = base * base % mod;
		power >>= 1;
	}
	return res;
}

long long fact[mxN], inv[mxN];

void init() {
	fact[0] = fact[1] = inv[0] = inv[1] = 1;
	for (int i = 2; i < mxN; i++)
		fact[i] = i * fact[i - 1] % mod, inv[i] = pow_mod(fact[i], mod - 2);
}

long long NcR(long long N, long long R) {
	if (N < R || R < 0)
		return 0;
	return (fact[N] * inv[R] % mod) * inv[N - R] % mod;
}

int main(int argc, char** argv) {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#endif

	init();

	int N;
	cin >> N;
	long long res = 0;
	long long sum = 0;
	for (int i = 1; i < N; i++) {
		long long cur = (NcR(i - 1, N - i - 1) * fact[i] % mod)
				* fact[N - 1 - i] % mod;
		cur += mod - sum;
		if (cur >= mod)
			cur -= mod;
		sum += cur;
		if (sum >= mod)
			sum -= mod;
		res = (res + i * cur) % mod;
//		cerr << res << '\n';
	}
	cout << res << '\n';
	return 0;
}


Measured memory_bytes: 31488
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;
using ll = long long;
#define max(a,b) ((a)>(b) ? (a):(b))
#define min(a,b) ((a)<=(b) ? (a):(b))
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
 
int main(){
  double N;
  cin >> N;
  cout << ceil(N/2);
  return 0;
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (max(a, c) <= min(b, d)) cout << min(b, d) - max(a, c) << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
using namespace std;
typedef long long ll;
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; }

int main() {
	int n;
	cin >> n;
	vector<int>L(n);
	rep(i, n) {
		cin >> L[i];
	}
	sort(L.begin(), L.end(), greater<int>());
	int ans = 0;
	for (int i = 0;i < n;++i) {
		for (int j = i + 1;j < n;++j) {
			for (int k = j + 1;k < n;++k) {
				int total = L[j] + L[k];
				if (L[i] < total)ans += 1;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <stack>
#include <queue>
typedef long long ll;
using namespace std;

int main(){
  ll i,j,k,n,m;
  string s;
  cin >> s;
  ll si = s.size();
  ll acnt = 0,bccnt=0;
  ll ret = 0;
  for(i=0;i<si;i++){
    if(s[i]=='A')acnt++;
    else if(s[i]=='B'&&s[i+1]=='C'){
      ret+=acnt;
      i++;
    }
    else acnt=0;
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	void solve() throws IOException {
		char[] s = ns().toCharArray();
		int ans = 0;
		for (char c : s)
			if (c == '+')
				ans++;
			else
				ans--;
		out.println(ans);
	}

	String ns() throws IOException {
		while (!tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine(), " ");
		}
		return tok.nextToken();
	}

	int ni() throws IOException {
		return Integer.parseInt(ns());
	}

	long nl() throws IOException {
		return Long.parseLong(ns());
	}

	double nd() throws IOException {
		return Double.parseDouble(ns());
	}

	String[] nsa(int n) throws IOException {
		String[] res = new String[n];
		for (int i = 0; i < n; i++) {
			res[i] = ns();
		}
		return res;
	}

	int[] nia(int n) throws IOException {
		int[] res = new int[n];
		for (int i = 0; i < n; i++) {
			res[i] = ni();
		}
		return res;
	}

	long[] nla(int n) throws IOException {
		long[] res = new long[n];
		for (int i = 0; i < n; i++) {
			res[i] = nl();
		}
		return res;
	}

	public static void main(String[] args) throws IOException {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		tok = new StringTokenizer("");
		Main main = new Main();
		main.solve();
		out.close();
	}
}

Measured memory_bytes: 20436
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

int N, A, B, C;
vector<int> l(8);

int dfs(int cur, int a, int b, int c) {
    if (cur == N) {
        if (min(min(a, b), c) > 0) {
            return abs(a - A) + abs(b - B) + abs(c - C) - 30;
            // 0+l[i]で余分に消費するMP10をa,b,cでそれぞれ引いておく
        } else {
            return 1000000;  // aかbかcがない時
        }
    }
    int ret0 = dfs(cur + 1, a, b, c);
    int ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;  // 合成するとMP10消費
    int ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
    int ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;
    return min(min(min(ret2, ret3), ret1), ret0);
}

int main() {
    cin >> N;
    cin >> A >> B >> C;
    rep(i, N)  cin >> l[i];

    print(dfs(0, 0, 0, 0));
}

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


int main(){
  int N;
  string S;
  cin>>N>>S;

  int dot=0;
  //累積和
  int dotcount[200010]={0};
  int sharpcount[200010]={0};
  for(int i=0;i<N;i++){
    if(S[i]=='.')  dot++;
    dotcount[i+1]=dot;
    sharpcount[i+1]=i+1-dot;
  }

  int ans=10e6+1;
  for(int i=0;i<=N;i++){
    
    ans=min(ans,sharpcount[i]+dotcount[N]-dotcount[i]);
  }
  cout<<ans<<endl;

  return 0;
}

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

using namespace std;

int dp[100001][3];

int main() {
    int n;
    cin >> n;
    int a[n][3];
    for(int i=0;i<n;++i) for(int j=0;j<3;++j) cin >> a[i][j];

    for(int i=0;i<n;++i) {
        for(int j=0;j<3;++j) {
            for(int k=0;k<3;++k) {
                if(j == k) continue;
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    cout << *max_element(dp[n], dp[n]+3) << "\n";
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

char a[24], x;
int main()
{
    int i;
    for(i=1; i<=19; i++) {
        cin >> a[i];
    }
    a[6] = a[14] = ' ';
    for(i=1; i<=19; i++) {
        cout << a[i];
    }
    return 0;
}


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

int table[201][201];

int  INF = 1<<29;

int main() {

    int n,m,R;

    cin >> n >> m >> R;

    vector<int> r;

    for(int i=0; i<R; i++){
        int input_r;
        cin >> input_r;
        r.push_back(input_r);
    }

    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            if(i != j) {
                table[i][j] = INF;
            }
        }
    }

    for(int i=0; i<m; i++){
        int a,b,c;
        cin >> a >> b >> c;
        if(table[a][b] > c) {
            table[a][b] = c;
            table[b][a] = c;
        }
    }

    for(int k=1; k<=n; k++){
        for(int i=1; i<=n; i++){
            for(int j=1; j<=n; j++){
                table[i][j] = min(table[i][j], table[i][k] + table[k][j]);
            }
        }
    }

    int ans = INF;
    
    sort(r.begin(),r.end());

    do{
        int tmp_ans = 0;
        for(int i=0; i<R-1; i++){
            tmp_ans += table[r[i]][r[i+1]];
        }
        ans = min(ans,tmp_ans);
    }while(next_permutation(r.begin(),r.end()));

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    int ans = 0;
    rep(i, n) {
        int tmp;
        cin >> tmp;
        if(abs(k - tmp) >= tmp){
            ans += tmp * 2;
        }else{
            ans += abs(k - tmp) * 2;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#define ll long long
ll n,a[3005],dp[3005][3005][2];
ll max(ll a,ll b)
{
	return (a>b)?a:b;
}
ll min(ll a,ll b)
{
	return (a<b)?a:b;
}

ll solve(int l,int r,int turn)
{
	if(dp[l][r][turn]!=-1)
		return dp[l][r][turn];
	if(l>r)
		return 0;
	
	if(l==r)
	{
		if(turn==0)
			return dp[l][r][turn]=a[l];
		else
			return dp[l][r][turn]=-a[l];
	}
	if(turn==0)
	{
		ll lc=a[l]+solve(l+1,r,1);
		ll rc=a[r]+solve(l,r-1,1);
		return dp[l][r][turn]=max(lc,rc);
	}
	else
	{
		ll lc=solve(l+1,r,0)-a[l];
		ll rc=solve(l,r-1,0)-a[r];
		return dp[l][r][turn]=min(lc,rc);
	}
}
	
int main()
{
	scanf("%lld",&n);
	for(int i=0;i<n;i++)
		scanf("%lld",&a[i]);
	for(int i=0;i<3005;i++)
		for(int j=0;j<3005;j++)
			for(int k=0;k<2;k++)
				dp[i][j][k]=-1;
	ll ans=solve(0,n-1,0);
	printf("%lld",ans);
	
	return 0;
}

Measured memory_bytes: 141440
N,M = map(int,input().split())
like_count = [0 for m in range(M)]
for n in range(N):
  temp = [int(i) for i in input().split()]
  for i,t in enumerate(temp):
    if i == 0:
      pass
    else:
      like_count[t-1] += 1
ans = 0
for like in like_count:
  if like == N:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#define N 101
#define whi 0
#define gra 1
#define bla 2
#define inf 10000
int main()
{
  int i,j,n,count=0;
  int G[N][N],color[N],d[N],p [N],min,q;

  scanf("%d",&n);

  for(i=0; i<n; i++)
    {
      for(j=0; j<n; j++)
	{
	  scanf("%d",&G[i][j]);
	}
      color[i]=whi;
      d[i]=inf;
      p[i]=-1;
    }

  d[0]=0;

  while(1)
    {
      min=inf;

      for(i=0; i<n; i++)
	{
	  if(color[i] != bla && d[i]<min)
	    {
	      min=d[i];
	      q=i;
	    }
	}
      if(min==inf)break;
      color[q]=bla;

      for(i=0; i<n; i++)
	{
	  if(G[q][i] != -1 && color[i] != bla && G[q][i] < d[i])
	    {
	      p[i]=q;
	      d[i]=G[q][i];
	      color[i]=gra;
	    }
	}
    }

  for(i=0; i<n; i++)
    {
      if(p[i] != -1) count += G[i][p[i]];
    }

  printf("%d\n",count);
  return 0;
}
       



Measured memory_bytes: 2108
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll K;
	string S;
	cin >> S >> K;
	ll an = 0;
	while (an<K-1&&S.at(an) == '1') {
		an++;
	}
	cout << S.at(an) << endl;
}



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

using namespace std;

#define rep(i,x) for(int i=0;i<x;++i)
#define all(a) begin(a),end(a)

signed main()
{
    int N; cin >> N;
    vector<int> a;
    int cnt[2]={};
    rep(i, N) {
        int t; cin >> t;
        cnt[t%2]++;
    }
    if (cnt[1] % 2 == 0) {
        cnt[0] += cnt[1] / 2;
        cout << (cnt[0] ? "YES" : "NO") << endl;
    } else {
        cnt[0] += cnt[1] / 2;
        cout << (cnt[0] ? "NO" : "YES") << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();//ボード数
		String sample = s.next();//s.next();//元となる文字
		char[] samples = new char[sample.length()];
		for(int i=0; i<samples.length; i++){//元となる文字を一文字ずつ配列へ
			samples[i] = sample.charAt(i);
		}
		String board = "";//看板の数
		int count=0;//何文字ごとか
		int muri = 2;
		int result = 0;
		do{//看板の数分だけループ
			board = s.next();
			N--;
		end: for(int i=0; i<board.length(); i++){
			if(samples[0]!=board.charAt(i)) continue;
			for(int j=i; j<board.length(); j++){
				if(samples[1]!=board.charAt(j)) continue;
				count = j-i;
				int flag = 2;
				muri = 2;
				a:for(int k=j+count; k<board.length();k+=count){
					if(samples[muri]!=board.charAt(k)){//一致しないなら前のループへ
						break a;
					}
					muri++;//次の文字へ
					flag++;//フラグ回収
					if(flag==sample.length()){
						result++;//一枚完成
						break end;//次の看板へ
					}
				}
			}
		}
		}while(N>0);
		System.out.println(result);
	}
}

Measured memory_bytes: 20800
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,cnt=0; cin>>n;
    set<int> m;
    rep(i,n){
        int r; cin>>r;
        if(r<3200) m.insert(r/400);
        else cnt++;
    }
    if(m.size()==0) cout<<1<<" "<<cnt<<endl;
    else cout<<m.size()<<" "<<m.size()+cnt<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,i,f=0;
  cin>>n;
  while(n>0)
  {
    if(n%10==7)
    {
      f=1;
      break;
    }
    n=n/10;
  }
  if(f==1)
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}

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

/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)

/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair 

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };  //Counterclockwise from the 9o'clock direction
//Take the x-axis downward and the y-axis right

//#define int ll
#define int long long

int n;

int f(int i, int j){
 
  string si = to_string(i);
  string sj = to_string(j);
  
  
  auto sis = si.size();
  auto sjs = sj.size();

  return max(sis,sjs);
  
  
}

  set<int> ans;
int j = 1;
    
signed main()
{
  cin >> n;
//1<<n<<10e10でsqrtに気づくべき
  for(int i = 1; i <= sqrt(n); ++i){
    //j = n/i because n = i*j
    if(n % i == 0)
     j = n/i;
    
    ans.insert(f(i,j));
  }
 /* 
  auto itr = --(ans.end());
  
  cout << *itr << endl;
  */
  
  cout << *ans.begin();
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

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

int main(void){
    int N,A,B,C;
    scanf("%d%d%d%d",&N,&A,&B,&C);

    //l[0]~l[N-1]に格納→昇順ソート
    int* l;
    NEW(l,N);
    for(int i=0;i<N;i++){
        scanf("%d",&l[i]);
    }

    int ans=1000000000;

    for(int i=0;i<(1<<(2*N));i++){
        int allocation=i;
        int aing=0;
        int bing=0;
        int cing=0;

        int mp=0;

        for(int j=0;j<N;j++){
            int c=allocation&3;

            if(c==1){
                if(aing!=0) mp+=10; 
                aing+=l[j];
            }
            else if(c==2){
                if(bing!=0) mp+=10;
                bing+=l[j];
            }
            else if(c==3){
                if(cing!=0) mp+=10;
                cing+=l[j];
            }

            allocation=(allocation-c)>>2;
        }

        if(aing==0 || bing==0 || cing==0) continue;

        mp+=abs(A-aing)+abs(B-bing)+abs(C-cing);

        if(ans>mp) ans=mp;
    }

    printf("%d\n",ans);

    return 0;
}

//Nが少ない→全探索できる
//魔法を軸に考えるのではなく、A,B,Cの材料を何にするかを考える

//stdlibには絶対値abs関数がある

Measured memory_bytes: 128
def main():
	N, M = map(int,input().split())
	V = [[] for _ in range(N+1)]
	a = [0]*M
	b = [0]*M
	for i in range(M):
		a[i], b[i] = map(int,input().split())
		V[a[i]].append(b[i])
		V[b[i]].append(a[i])
	ans = 0

	for i in range(M):
		visited = [False]*(N+1)
		stack = [1]
		while stack:
			v = stack.pop()
			if visited[v]:
				continue
			visited[v] = True
			for n in V[v]:
				if (n == a[i] and v == b[i]) or (n == b[i] and v == a[i]):
					continue
				stack.append(n)
		if not(all(visited[1:])):
			ans += 1
	print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    vector<int> S(N);
    rep(i, N) cin >> S[i];
    int Q;
    cin >> Q;
    vector<int> T(Q);
    rep(i, Q) {
        cin >> T[i];
    }

    int ans = 0;
    rep(i, Q) {
        if (*lower_bound(all(S), T[i]) == T[i]) ans++;
    }

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


Measured memory_bytes: 3348
#include <cstdio>
using namespace std;

int main(){
    int X,A,B;
    scanf("%d%*c", &X);
    scanf("%d%*c", &A);
    scanf("%d%*c", &B);
    int a = X-A;
    printf("%d\n",a % B);
    return 0;   
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N; cin>>N;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  vi B(N+1);
  rep(i,0,N){
    B[A[i]]=B[A[i]-1]+1;
  }
  int ans=0;
  REP(i,0,N) ans=max(ans,B[i]);
  cout<<N-ans<<endl;
  }


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

ll n, sz, ans = 0;

class TaskD {
public:
    void solve() {
        cin >> n;
        if (n == 1) {
            cout << n;
            return;
        }
        ll x = 1;
        while (n > 0) {
          if (n > 1) {
             n /= 2;
             if (n == 1) {
                ans += x;
                x *= 2;
                ans += x;
                n = 0;
                break;
             }
             ans += x;
             x *= 2;
          }
        }
        cout << ans;
    }
};

int main() {
    TaskD solver;
    solver.solve();
}


Measured memory_bytes: 256
N,M=map(int,input().split())
MOD=10**9+7
s=1
for i in range(2,N+1):
  s=(s*i)%MOD
t=1
for i in range(2,M+1):
  t=(t*i)%MOD
if abs(N-M)>1:
  print(0)
  exit()
if abs(N-M)==1:
  print((s*t)%MOD)
else:
  print((2*s*t)%MOD)

Measured memory_bytes: 3064
def solve(n: int, ab: 'list(Task)') -> bool:
    from operator import attrgetter
    ab.sort(key=attrgetter('limit'))
    cur = 0
    for ab_ in ab:
        cur += ab_.cost
        if cur > ab_.limit:
            return False
    return True


if __name__ == '__main__':
    from collections import namedtuple
    import sys

    input = sys.stdin.readline
    Task = namedtuple('Task', 'cost limit')
    n = int(input())
    ab = []
    for _ in range(n):
        cost_, limit_ = map(int, input().split())
        ab.append(Task(cost=cost_, limit=limit_))
    print('Yes' if solve(n, ab) else 'No')


Measured memory_bytes: 33824
H, W = map(int,input().split())
S = ["."*(W+2)]+ ["."+input()+"." for k in range(H)] + ["."*(W+2)]
ans = [[0 for k in range(W)] for l in range(H)]

for x in range(1,W+1):
    for y in range(1,H+1):
        if S[y][x] == "#":
            ans[y-1][x-1] = "#"
        else:
            c = 0
            for dx in range(-1,2):
                for dy in range(-1,2):
                    if S[y+dy][x+dx] == "#":
                        c += 1
            ans[y-1][x-1] = c

for e in ans:
    print(*e,sep="")


Measured memory_bytes: 44272
import itertools

n = int(input())
p = [int(i) for i in input().split()]
q = [int(i) for i in input().split()]

l = [i for i in range(1,n+1)]
ll = itertools.permutations(l)

for i,v in enumerate(ll):
    if list(v)==p:
        p_ind = i
    if list(v)==q:
        q_ind = i

print(abs(p_ind - q_ind))


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

int main()
{
	int n,mx = 0,s = 0;
	cin >> n;
	while(n--){
		int t;
		cin >> t;
		if(t > mx)
			mx = t;
		s += t;
	}
	s -= mx / 2;
	cout << s << endl;
	return 0;
} 

Measured memory_bytes: 256
H , W = map (int, input().split())
S = [input() for _ in range(H)]
S_prime = ['0'] * (H+2)
ans = []
for i in range(H+2):
  if i == 0 or i == H+1:
    S_prime[i] = '0' * (W+2)
  else:
    S_prime[i] = '0' + S[i-1] + '0'
def f(x, y):
  aro = [S_prime[x][y], S_prime[x][y+1], S_prime[x][y+2], S_prime[x+1][y], S_prime[x+1][y+2], S_prime[x+2][y], S_prime[x+2][y+1], S_prime[x+2][y+2]]
  t = aro.count('#') 
  return str(t)
for i in range(H):
  X = ''
  for j in range(W):
    if S[i][j] == '#':
      X = X + '#'
    else:
      X = X + f(i,j)
  ans.append(X)
for i in range(H):
	print(ans[i])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
  
using namespace std;
 
const int MAXN=2e5+5;
int a[MAXN],b[MAXN];
 
int main() 
{
    int n;
    cin>>n;
    
    for(int i=1;i<=n;++i) 
        cin>>a[i];
    
    for(int i=1;i<=n;++i) 
        cin>>b[i];
    
    reverse(b+1,b+n+1);
    
    //for(int i=1;i<=n;++i)
	//    cout<<b[i]<<" ";
		
	//cout<<'\n'; 
    
    int flag=-1;
    int l=1000,r=-1;

    for(int i=1;i<=n;++i) 
	{
        if(flag==-1&&a[i]==b[i]) 
		{ 
            flag=a[i];
            l=i;r=i;
        } 
        
		else if(flag!=-1&&a[i]==b[i]) r=i;
    }
    
    for(int i=1;i<=n;++i) 
	{
        if(flag!=a[i]&&flag!=b[i]&&l<=r){
            swap(b[i],b[l]);
            l++;
        }
    }
 
    if(l<=r){
        cout<<"No"<<'\n'; 
    } 
    
	else{
        cout<<"Yes"<<'\n';
        for(int i=1;i<=n;++i) {
            cout<<b[i]<<" ";
        }
    }
 
    return 0;
}

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

int main()
{
	long long a, b1, b2;
	scanf("%lld %lld.%lld",&a,&b1,&b2);
	auto b=b1*100+b2;
	printf("%lld",a*b/100);
	return 0;
}

Measured memory_bytes: 3820
#include <stdio.h>
#include <inttypes.h>

/*
うーん、わからん。
まーいっぱいぶん回せば、ビット的に考えてどっかで止まるんじゃね？知らんけど。
*/

int main(void) {
	uint64_t A, B, C;
	int mareitaso = 0;
	if (scanf("%" SCNu64 "%" SCNu64 "%" SCNu64, &A, &B, &C) != 3) return 1;
	while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0 && mareitaso < 1000000) {
		uint64_t na, nb, nc;
		na = B / 2 + C / 2;
		nb = A / 2 + C / 2;
		nc = A / 2 + B / 2;
		A = na;
		B = nb;
		C = nc;
		mareitaso++;
#if 0
		printf("%" PRIu64 " %" PRIu64 " %" PRIu64 "\n", A, B, C);
#endif
	}
	printf("%d\n", A % 2 != 0 || B % 2 != 0 || C % 2 != 0 ? mareitaso : -1);
	return 0;
}

/*

A                          B                          C
      B/2   +C/2    A/2         +C/2    A/2   +B/2
A/2  +B/4   +C/4    A/4   +B/2  +C/4    A/4   +B/4   +C/2
A/4  +B*3/8 +C*3/8  A*3/8 +B/4  +C*3/8  A*3/8 +B*3/8 +C/4
A*3/8+B*5/16+C*5/16 A*5/16+B*3/8+C*5/16 A*5/16+B*5/16+C*3/8

*/


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long int
using namespace std;















void solve() {
    string s;
    cin >> s;
    if (s == "ABC")
        cout << "ARC" << "\n";

    else
        cout << "ABC" << "\n";












}




int main()
{


    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}




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

using namespace std;

typedef long long ll;

int main() {
  int n,x;
  cin>>n>>x;
  int ans = 1;
  int d = 0;
  for (int i = 0; i < n; i++) {
    int l;
    cin>>l;
    d += l;
    if (d <= x) ans++;
    else break;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
  char s[128];
  scanf("%s",s);
  int len=(int)strlen(s);
  int count=0;
  if(s[0]!='A'){
    puts("WA");
    return 0;
  }
  int num=0;
  for(int i=2;i<len-1;i++){
    if(s[i]=='C'){
      count++;
      num=i;
    }
    if(count>1){
      puts("WA");
      return 0;
    }
  }
  if(count!=1){
    puts("WA");
    return 0;
  }
  for(int i=1;i<len;i++){
    if(i!=num){
      if(s[i]<0x61||s[i]>0x7A){
        puts("WA");
        return 0;
      }
    }
  }

  puts("AC");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	bool w[6]={0};
	int a;
	for(int i=0;i<5;i++)
    {
        cin>>a;
        w[a]=1;
    }
    for(int i=1;i<=5;i++)
    {
        if(!w[i])
        {
            cout<<i<<endl;
            break;
        }
    }
	return 0;
}


Measured memory_bytes: 3600
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	i64 n, t;
	cin >> n >> t;
	vector<i64> vt(n);
	for (auto& v : vt)
	{
		cin >> v;
	}

	i64 ans = 0;
	REP(i, n)
	{
		if (i == n - 1)
		{
			ans += t;
		}
		else
		{
			ans += min(vt[i + 1] - vt[i], t);
		}
	}
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 1792
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<set>
#include<string>
using namespace std;
int n,k,ma;
int main(){
    for(;;){
        int num[100001]={0},all=0;
        cin>>n>>k;
        if(n==0&&k==0)break;
        for(int i=0;i<n;i++){
            cin>>num[i];
        }
        for(int i=0;i<n-k;i++){
            if(i==0){
                for(int j=0;j<k;j++){
                    all+=num[i+j];
                    ma=all;
                }
                continue;
            }
        all=all-num[i-1]+num[i+k-1];
        ma=max(ma,all);
        }
        cout<<ma<<endl;
    }
}

Measured memory_bytes: 1560
use proconio::*;

fn run() {
    input! {
        a: [usize; 4],
        k: usize,
    }
    let s = a[0] * 60 + a[1];
    let t = a[2] * 60 + a[3];
    let ans = t - s - k;
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 2152
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
//////////////

void solve() {
	int K;
	cin >> K;
	
	vector<LL> A = { 1,2,3,4,5,6,7,8,9 };
	int L = 0;
	int R = 8;
	
	while (R+1 < K) {
		
		for (int i = L; i <= R; ++i) {
			LL ter = A[i];
			LL base = ter % 10;
			if (base - 1 >= 0) {
				A.push_back(ter * 10 + (base - 1));
			}
			A.push_back(ter * 10 + base);
			if (base + 1 <= 9) {
				A.push_back(ter * 10 + (base + 1));
			}
		}
		L = R + 1;
		R = A.size() -1;
	}
	cout << A[K - 1] << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 3700
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, M;
    cin >> N >> M;
    vec A(N);
    ll sum = 0;
    rep(i, N) cin >> A[i], sum += A[i];

    ll ans = 0;
    rep(i, N) if (4 * M * A[i] >= sum)++ ans;
    if(ans >= M) print("Yes");
    else print("No");



    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll A, B;

int main() {
	cin >> A >> B;
	cout << (A - 1) * (B - 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>

using namespace std;
int main() {
	int n;

	while (cin >> n) {
		int count = 0;
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 10; k++) {
					for (int l = 0; l < 10; l++) {
						if (i + j + k + l == n) count++;
					}
				}
			}

		}
		cout << count << endl;
	}
	
	
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
 
using namespace std;		
	
const int N = 505;

int n, p[N * N];
int v[N][N];
bool dead[N][N];

int xd[4] = {0, 0, 1, -1};
int yd[4] = {1, -1, 0, 0};

void akt(int x, int y) {
	rep(g, 0, 3) {
		int dx = x + xd[g];
		int dy = y + yd[g];
		if (v[dy][dx] == v[y][x] + 2 || (v[dy][dx] == v[y][x] + 1 && dead[dy][dx] == 1)) {
			v[dy][dx]--;
			akt(dx, dy);
		}
	}
}

void prin() {
	rep(i, 1, n) {
		rep(j, 1, n)
			printf ("%d ", v[i][j]);
		printf ("\n");
	}
	printf ("\n");
}
	
int main() {
	scanf ("%d", &n);
	rep(i, 1, n * n) scanf ("%d", p + i);
	rep(i, 1, n)
		rep(j, 1, n)
			v[i][j] = min({i, n - i + 1, j, n - j + 1});
	int answer = 0;
	rep(i, 1, n * n) {
		int x = p[i] % n;
		int y = (p[i] - 1) / n + 1;
		if (!x) x = n;
		answer += v[y][x];
		dead[y][x] = 1;
		v[y][x]--;
		akt(x, y);
		//prin();
	}
	printf ("%d\n", answer - n * n);
		
	
	return 0;
}	


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

int main(){
  string s;
  cin >> s;
  int cnt=0;
  bool flag = true;
  for (char c: s){
    if(cnt%2==0){
      if (c!='R' && c!='U' && c!='D') flag = false;
    }
    else{
      if (c!='L' && c!='U' && c!='D') flag = false;
    }
    cnt++;
  }
  string ans;
  if(flag == true) ans = "Yes";
  else ans = "No";
  cout << ans << endl;
}

        

Measured memory_bytes: 256
#include <iostream>

int main() {
    std::string s;
    std::cin >> s;
    if (s == "Sunny") {
        std::cout << "Cloudy" << std::endl;
    } else if (s == "Cloudy") {
        std::cout << "Rainy" << std::endl;
    } else {
        std::cout << "Sunny" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<cmath>

#define print(x) cout << #x << " = " << x << endl;

using namespace std;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;


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

	int S = 0;
	int buf = N;
	while (buf != 0) {
		S += buf % 10;
		buf /= 10;
	}


	if (N % S == 0) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(Solve());
        Console.Out.Flush();
    }

    static object Solve() {
        var input = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int N = input[0], A = input[1], B = input[2];
        long sum = 0;
        for (int i = 1; i <= N; i++) {
            int digitSum = 0;
            for (int x = i; x > 0; x /= 10) {
                digitSum += x % 10;
            }
            if (A <= digitSum && digitSum <= B) sum += i;
        }
        return sum;
    }
}


Measured memory_bytes: 27384
# coding: utf-8
# Your code here!
x=input().split()



if(x[0]=="0"):
    print(1)
elif(x[1]=="0"):
    print(2)
elif(x[2]=="0"):
    print(3)
elif(x[3]=="0"):
    print(4)
elif(x[4]=="0"):
    print(5)

Measured memory_bytes: 8988
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int high = -1;
    int ans = 0;
    rep(i,n){
        if(i == 0){
            ans++;
            high = v[i];
        }else{
            if(high <= v[i] ){
                ans++;
                high = max(high, v[i] );
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3548
X,Y,A,B,C=map(int, input().split())
p=list(map(int, input().split()))
q=list(map(int, input().split()))
r=list(map(int, input().split()))

p=sorted(p, reverse=True)[:X]
q=sorted(q, reverse=True)[:Y]

gocha=sorted(p+q+r, reverse=True)
#print(p,q,r,gocha)
print(sum(gocha[:(X+Y)]))

Measured memory_bytes: 114796
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
	int i, j, n;

	cin >> n;
	long *a = new long[n];
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(a, a + n);

	for (i = 1; i < n; i++) {
		if (a[i] == a[i-1]) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 1792
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  vi p(5), q(5);
  while (cin >> p[0] >> q[0], p[0]) {
    loop(i, 1, 5) cin >> p[i] >> q[i];
    vector<pair<int, string>> v(5);
    rep(i, 5) v[i] = mp(p[i] + q[i], 'A' + i);
    sort(all(v));
    cout << v.back().se << ' ' << v.back().fi << endl;
  }
}

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

public class Main {
    public static void main(String[] args) throws IOException {
        final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int n = Integer.parseInt(br.readLine());
        int[] a = new int[n];
        String[] line = br.readLine().split(" ");
        for (int i = 0; i < n; ++i) {
            a[i] = Integer.parseInt(line[i]);
        }

        int all = 0;
        for (int i: a) {
            all ^= i;
        }
        bw.write(Integer.toString(all ^ a[0]));
        for (int i = 1; i < n; ++i) {
            bw.write(' ');
            bw.write(Integer.toString(all ^ a[i]));
        }

        bw.close();
        br.close();
    }
}


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

int main(){
  vector<int> A(3);
  int five=0,seven=0;
  for(int i=0;i<3;i++){
    cin >> A.at(i);
    if(A.at(i)==5){
      five++;
    }else if(A.at(i)==7){
      seven++;
    }
  }
  if(five==2&&seven==1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

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

void out(vi &a) {
  rep(i, a.size() - 1) printf("%d ", a[i]);
  printf("%d\n", *prev(a.end()));
}

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

  vi a(n);
  rep(i, n) cin >> a[i];

  rep(i, n) {
    int v = a[i],
      j = i - 1;

    while (j >= 0 && a[j] > v) {
      a[j + 1] = a[j];
      j--;
    }

    a[j + 1] = v;
    out(a);
  }
}



Measured memory_bytes: 3220