akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<'\n';
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
//#define double long double

using namespace std;

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;
}

const int MOD = 1e9 + 7;
const ll INF = 1e9;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 100020;


double x[3], y[3];
double dist(double x, double y, double X, double Y) {
	return sqrt((X - x) * (X - x) + (Y - y) * (Y - y));
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	REP(i, 3) {
		cin >> x[i] >> y[i];
	}
	x[1] -= x[0]; x[2] -= x[0];
	y[1] -= y[0], y[2] -= y[0];
	x[0] = 0, y[0] = 0;
	double S = abs((x[1] * y[2]) - (x[2] * y[1])) / 2.0;
	//cout << "S:" << S << endl;
	double E[3];
	REP(i, 3) {
		E[i] = dist(x[i], y[i], x[(i + 1) % 3], y[(i + 1) % 3]);
	}
	double R = 2 * S / (E[0] + E[1] + E[2]);
	double M = max({ E[0],E[1],E[2] });
	//cout << "R:"; print(R);
	//cout << "M:"; print(M);
	double ans = M / (2 + (M / R));
	cout << setprecision(10) << ans << endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;
 
typedef pair<int,int> pii;
 
const int INF = 1000000001;
 
int main(){
  int n;
  vector<pair<int,pii> > event;
  set<int> list;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    int x1,y1,x2,y2;
    scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
    if(y1==y2){
      event.push_back(make_pair(min(x1,x2),pii(-INF,y1)));
      event.push_back(make_pair(max(x1,x2),pii(INF,y1)));
    }else if(x1==x2){
      event.push_back(make_pair(x1,pii(min(y1,y2),max(y1,y2))));
    }
  }
  sort(event.begin(),event.end());
  int ans = 0;
  for(int i=0;i<event.size();i++){
    int y1 = event[i].second.first, y2 = event[i].second.second;
    if(y1==-INF) list.insert(y2);
    else if(y1==INF) list.erase(y2);
    else ans += distance(list.lower_bound(y1),list.upper_bound(y2));
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 7576
#include <iostream>
#include <string>

using namespace std;


int main() {
	long long n;
	long long a;
	long long b;

	cin >> n >> a >> b;

	long long c = a + b;

	long long answer;
	if (a != 0) {
		long long d = (long long)(n / c);
		long long e = n % c;

		if (e < a) {
			answer = d * a + e;
		}
		else {
			answer = (d + 1) * a;
		}
	}
	else {
		answer = 0;
	}


	cout << answer;

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 1e5 + 5;
long long w[maxn], v[maxn], dp[105][maxn];
int main()
{
	int n, k; scanf("%d %d",&n, &k);
	for(int i = 1; i <= n; i++)
		scanf("%lld %lld",&w[i],&v[i]);
	for(long long int i = 1; i <= n; i++)
	{
		for(long long int j = k; j >= 0; j--)
		{
			if(j >= w[i])
			dp[i][j] = max(dp[i-1][j-w[i]] + v[i],dp[i-1][j]);
			else dp[i][j] = dp[i-1][j];
		}
	}
	printf("%lld\n",dp[n][k]);
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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 vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  string S; cin >> S; int N = S.size();
  string s1 = S.substr(0, (S.size() - 1) / 2);
  string s2 = S.substr((S.size() + 3) / 2 - 1, s1.size());
  reverse(s2.begin(), s2.end());
  string ans = "Yes";
  if(s1 != s2) ans = "No";
  reverse(s2.begin(), s2.end());
  for(int i = 0; i < s1.size(); ++i) {
    if(s1[i] != s1[s1.size() - i - 1]) ans = "No";
  }
  for(int i = 0; i < s2.size(); ++i) {
    if(s2[i] != s2[s2.size() - i - 1]) ans = "No";
  }
  cout << ans << endl;
}

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

using i64 = int64_t;

int main(){
    i64 n;
    cin >> n;
    if(n == 0){
        cout << 0 << endl;
        return 0;
    }

    string ans;
    while(n != 0){
        int r = n % 2;
        if(r < 0)r += 2;
        n = (n-r)/(-2);
        ans.push_back('0'+r);
    }
    reverse(ans.begin(), ans.end());

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1_8_A
{
    class Program
    {
        static void Main(string[] args)
        {
            //与えられた文字列の小文字と大文字を入れ替えた文字列を出力する。
            //アルファベット以外の文字はそのまま出力する。

            //文字列をchar型の配列として取得する。
            char[] cr = Console.ReadLine().ToCharArray();

            for (int i = 0; i < cr.Length; i++)
            {
                if (char.IsUpper(cr[i]))                //crが大文字かどうか調べる
                {
                    cr[i] = char.ToLower(cr[i]);        //小文字に変換する
                }
                else if (char.IsLower(cr[i]))           //crが小文字かどうか調べる
                {
                    cr[i] = char.ToUpper(cr[i]);        //大文字に変換する
                }
            }
            //char型配列をstring型文字列に変換
            //string 変数名 = new string (char型配列の変数名)
            string str = new string(cr);
            Console.WriteLine(str);

        }
    }
}



Measured memory_bytes: 17844
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//using ll=long long;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//dp注意点
//問題の種類	 初期化する値	 備考
//最小化問題 	INF	
//最大化問題	    -INF	 テーブル全体で 00 以上の値しかとらないことがわかっていれば −1−1 でもいいですし、00 でもいい場合もあります
//数え上げ問題	00	
//確率問題	      00	
//Yes/No 判定問題	False
/*-------------ここまで---------------------------------------------*/

/*signed*/int main() {
    string s, t;
    cin >> s >> t;
    int count = 0;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == t[i]) ++count;
    }
    cout << count << endl;
    return 0;
}

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

#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
#define rrep(i, a, b) for (int i = int(a) - 1; i >= b; i--)
#define sz(x) (int)(x).size()

using namespace std;
using ll = long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main() {
  ll n;
  cin >> n;
  vector<ll> yakusu;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      yakusu.emplace_back(i);
      yakusu.emplace_back(n / i);
    }
  }

  ll ans = 0;
  // amari = k torusuto
  // N = (m+1)*k toarawaseru
  rep(i, 0, sz(yakusu)) {
    if (yakusu[i] == 1)
      continue;
    if (n % (yakusu[i] - 1) == n / (yakusu[i] - 1)) {
      ans += yakusu[i] - 1;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

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

	int ans = 1e9;
	for (int i = 0; i <= 100000; i++) {
		ans = min(i * 2 * c + max(0, x - i) * a + max(0, y - i) * b, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
H,W,M = list(map(int,input().split()))

h = [0] * H
w = [0] * W

hw = defaultdict(set)

for _ in range(M):
    a,b = list(map(int,input().split()))
    h[a - 1] += 1
    w[b - 1] += 1
    hw[a - 1].add(b - 1)
    
hm = max(h)
wm = max(w)

hp = [i for i, v in enumerate(h) if v == hm]
wp = [i for i, v in enumerate(w) if v == wm]

for x in hp:
    for y in wp:
        if y not in hw[x]:
            print(hm + wm)
            exit()
else:
    print(hm + wm - 1)



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

int main()
{
	int a,b,c,r,n,t;
	while(cin >> a >> b >> c, (a||b||c))
	{
		if(a>b) swap(a,b);
		if(a>c) swap(a,c);
		if(b>c) swap(b,c);

		r = a*a + b*b;

		cin >> n;
		while(n--)
		{
			cin >> t;
			t = t*t*4;
			cout << (r<t?"OK":"NA") << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#define DEBUG printf("Passing Line %d in Function [%s].\n",__LINE__,__FUNCTION__);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const string S = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
const int L = 128;

int n;
string vec[66];

int Query(const string &s){
    cout << "? " << s << endl;
    int res;
    cin >> res;
    return res;
}

string dfs(int l,int r){
    if(l==r){
		return vec[l];
	}
	int mid=(l+r)>>1;
	string L=dfs(l,mid),R=dfs(mid+1,r),myh;
	int j=0;
	for(int i=0;i<(int)L.length();++i){
		while(j<(int)R.size()){
			string s=myh+R[j]+L.substr(i,L.length()-i);
			cout<<"? "<<s<<endl;
			int qwq;
			cin>>qwq;
			int o=L.length()+j+1;
			if(n-qwq!=o)break;
			myh+=R[j++];
		}
		myh+=L[i];
	}
	myh+=R.substr(j,R.length()-j);
	return myh;
}

int main(){
    // freopen("data.in","r",stdin);
    // freopen("data.out","w",stdout);
    int cnt=0;
    for(char c : S){
        string s(128,c);
        int num = 128 - Query(s);
        vec[cnt++]=s.substr(0,num);
        n += num;
    }
    string ans = dfs(0,cnt-1);
    cout << "! " << ans << endl;
    return 0;
}


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

#define ff first
#define ss second
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define w(x) int t; cin >> t; while(t--)
#define rep(i, a, b) for(int i = a; i <= b; i++)
#define repd(i, b, a) for(int i = b; i >= a; i--)
#define mk(arr,n,type) type* arr = new type[n];
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define um unordered_map
#define us unordered_set
#define pqm priority_queue<int>
#define pqmi priority_queue<int, vi, greater<int>>
#define lb(v, val) lower_bound(v.begin(), v.end(), val) - v.begin();
#define ub(v, val) upper_bound(v.begin(), v.end(), val) - v.begin();
#define setbits(x) __builtin_popcountll(x)
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define out(flag) flag ? cout << "NO" << endl : cout << "YES" << endl;
#define MAX 100001
#define mod 998244353
#define inf 1e18
#define PI 3.1415926535

void IO() {
	fast;
}

int main() {

	IO();

	string s, t;
	cin >> s >> t;
	int ns = s.size(), nt = t.size();
	vector<vector<int>> dp(ns + 1, vector<int>(nt + 1));
	for (int i = 1; i <= ns; i++) {
		for (int j = 1; j <= nt; j++) {
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = 1 + dp[i - 1][j - 1];
			} else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	// cout << dp[ns][nt] << endl;
	string ans = "";
	int i = ns, j = nt;
	while (i > 0 && j > 0) {
		if (dp[i][j] == dp[i][j - 1]) j--;
		else if (dp[i - 1][j] == dp[i][j]) i--;
		else {
			ans += s[i - 1];
			i--, j--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;

	return 0;
}


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

using namespace std;

int main(void)
{
    int64_t n, m;
    cin >> n >> m;
    // multimap<int64_t, int64_t> sorted_map;
    vector<pair<int64_t, int64_t>> pairs(n);
    for (size_t i = 0; i < n; i++)
    {
        int64_t a, b;
        cin >> a >> b;
        // sorted_map.insert(pair<int64_t, int64_t>(a, b));
        pairs[i] = pair<int64_t, int64_t>(a, b);
    }

    sort(pairs.begin(), pairs.end());

    int64_t total = 0;
    int64_t left = m;
    // for (auto j = sorted_map.begin(); j != sorted_map.end(); j++)
    for (auto j = pairs.begin(); j != pairs.end(); j++)
    {
        int64_t buy;
        if(j->second > left) buy = left; else buy = j->second;
        total += j->first * buy;
        if(left <= 0) break;
        left -= buy;
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 1792
/**
 *  author: MOOONI
 *  hackers are welcome!
**/
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define str string
#define pi pair
#define tup tuple
#define vec vector
#define temp template
#define tn typename

#define ff first
#define ss second
#define SZ(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rsz resize
#define ins insert
#define fr front 
#define bc back
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mk make_pair

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++) 
#define ROF(i, a, b) for (ll i = (a); i >= (b); i--)
#define trav(a, x) for (auto &a : x)
#define popcount __builtin_popcount
#define ctz __builtin_ctz
#define clz __builtin_clz
#define gcd __gcd

// DEBUG
#define ts to_string
temp<tn A, tn B> str ts(pi<A, B> p);
temp<tn A, tn B, tn C> str ts(tup<A, B, C> p);
str ts(const str& s) { return '"' + s + '"'; }
str ts(const char* s) { return ts((str) s); }
str ts(bool b) { return (b ? "true" : "false"); }
str ts(vec<bool> v) { bool f = true; str res = "{";
FOR(i, 0, static_cast<ll>(v.size()) - 1) 
{ if (!f) res += ", "; res += ts(v[i]);
f = false; } res += "}"; return res; }
temp<size_t N> str ts(bitset<N> v) { str res = "";
trav(a, v) { res += (char) ('0' + a); } return res; }
temp<tn A> str ts(A v) { bool f = true; str res = "{";
trav(x, v) { if (!f) res += ", "; res += ts(x);
f = false; } res += "}"; return res; }
temp<tn A, tn B> str ts(pi<A, B> p) { 
  return "(" + ts(p.ff) + ", " + ts(p.ss) + ")"; }
temp<tn A, tn B, tn C> str ts(tup<A, B, C> t) {
  return "(" + ts(get<0>(t)) + ", " + ts(get<1>(t)) + ", " + ts(get<2>(t)) + ")"; }
void DBG() { cerr << endl; }
temp<tn H, tn... T> void DBG(H h, T... t) { cerr << " " << ts(h); DBG(t...); }
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", DBG(__VA_ARGS__);

// INPUT AND OUTPUT
temp<tn T> void re(T& x) { cin >> x; };
temp<tn H, tn... T> void re(H& h, T&... t) { re(h); re(t...); }
temp<tn T> void pr(T x) { cout << x; };
temp<tn H, tn... T> void pr(H h, T... t) { pr(h); pr(t...); }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  re(n);
  vec<ll> a(n);
  FOR(i,0, n - 1) {
    re(a[i]);
  }
  vec<ll> g(n), f(n);
  FOR(i, 0, n - 1) {
    g[i] = -a[i] - i;
    f[i] = a[i] - i;
  }
  ll ans = 0;
  map<ll, ll> mp;
  FOR(i, 0, n - 1) {
    ans += mp[f[i]];
    ++mp[g[i]];
  }
  pr(ans, '\n');
  return 0;
}

Measured memory_bytes: 30600
#include<iostream>

using namespace std;

#define LEN 100
int num[LEN*2] = {0};

int main(void){
	int N, M;
	cin >> N >> M;
	
	int index = 0;
	for(int i=2, n=0; n<N; i+=2, n++) num[index++] = i;
	for(int j=1, m=0; m<M; j+=2, m++) num[index++] = j;
	
	int count = 0;
	for(int i=0; i<index; i++){
		for(int j=i+1; j<index; j++){
			if( (num[i]+num[j]) % 2 == 0 ){
				count++;
			}
		}
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#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;
using namespace std;
typedef long long ll;

int main()
{
  int N;
  int a[110000];
  int b[110000];
  int res=0;
  cin >> N;

  a[0]=0;
  rep(i,N) cin >> a[i+1];
  a[N+1]=0;
  int sum=0;
  int prev=a[0];
  FOR(i,0,N+1){
    b[i] = abs(a[i]-prev);
    sum += b[i];
    prev = a[i];
  }

  //  FOR(i,0,N+1)  cout << b[i] << endl;                                       

  for(int i=1;i<=N;i++){
    res = sum - b[i] - b[i+1];
    res += abs(a[i-1]-a[i+1]);
    cout << res << endl;
  }

}


Measured memory_bytes: 2048
n = int(input())
for i in range(n):
    out_count = 0
    score = 0
    runner = []
    while True:
        if out_count == 3:
            print(score)
            break
            
        events = input()
        if events == "HIT":
            if len(runner) == 3:
                score += 1
            else:
                runner.append(1)

        elif events == "HOMERUN":
            score += len(runner) + 1
            runner = []

        elif events == "OUT":
            out_count += 1

Measured memory_bytes: 7448
//BISMILLAH
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[11],b[11];
    scanf("%s",a);
    scanf("%s",b);
    int len1,len2,flag=0;
    len1=strlen(a);
    len2=strlen(b);
    for(int i=0;i<len1;i++)
    {
        if(a[i]!=b[i])
        {
            flag=1;
            break;
        }
    }
    if(flag==0) cout<< "Yes"<<endl;
    else cout<< "No"<<endl;
   return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
const ll mod=1e9+7;

int main(){
  int k;
  cin>>k;
  ll cur=0;
  ll s=7;
  int i=1;
  while(i<=k){
    cur+=s;
    cur%=k;
    s*=10;
    s%=k;
    if(cur==0) break;
    i++;
  }
  if(i==k+1) cout<<-1<<endl;
  else cout<<i<<endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

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


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;++i){
        cin>>a[i];
    }

    vector<ll> b(n, 0);
    for(ll i=0;i<n;++i){
        if(n % 2 == a[i] % 2){
            cout<<0<<endl;
            return 0;
        }
        b[a[i]]++;
        if(b[0] > 1){
            cout<<0<<endl;
            return 0;
        }
    }

    ll ans = 1;
    for(ll i=0;i<n;++i){
        if(i % 2 == n % 2)continue;
        if(b[i] == 2){
            ans *= 2;
        }else if(i == 0 and b[i] == 1){
            continue;
        }else{
            cout<<0<<endl;
            return 0;
        }
        ans %= mod;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

void solve()
{
	int N;
	while(cin >> N, N)
	{
		int lunch_count = 0, lunch_ok = 0;
		int dinner_count = 0, dinner_ok = 0;
		int midnight_count = 0, midnight_ok = 0;
		int a, b, c;
		for(int i = 0; i < N; ++i)
		{
			scanf("%d%*c%d%d",&a, &b, &c);
			if(c < b)
			{
				c += 60;
			}
			if(11 <= a && a <= 14)
			{
				++lunch_count;
				if(c - b <= 8)
				{
					++lunch_ok;
				}
			}
			else if(18 <= a && a <= 20)
			{
				++dinner_count;
				if(c - b <= 8)
				{
					++dinner_ok;
				}
			}
			else if((21 <= a && a <= 23) || a == 0 || a == 1)
			{
				++midnight_count;
				if(c - b <= 8)
				{
					++midnight_ok;
				}
			}
		}
		if(lunch_count > 0)
		{
			cout << "lunch " << lunch_ok * 100 / lunch_count << endl;
		}
		else
		{
			cout << "lunch no guest" << endl;
		}
		if(dinner_count > 0)
		{
			cout << "dinner " << dinner_ok * 100 / dinner_count << endl;
		}
		else
		{
			cout << "dinner no guest" << endl;
		}
		if(midnight_count > 0)
		{
			cout << "midnight " << midnight_ok * 100 / midnight_count << endl;
		}
		else
		{
			cout << "midnight no guest" << endl;
		}
	}
}

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

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using vvii = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int N,K; cin>>N>>K;
    vector<int> P(N);
    REP(i,N){
        cin >> P[i];
    }
    sort(ALL(P));
    int ans = 0;
    REP(i,K){
        ans += P[i];
    }
    cout << ans <<endl;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	
	int number1, number2;
	int N;
	
	cin >> N;
	
	for (int i = 1; i < 10; i++) {
		
		if ( N % i == 0) {
			number1 = i;
			number2 = N / number1;
		}
	} 
	
	if ((0 < number1) && (number1 < 10) && (0 < number2) && (number2 < 10)) { 
		
		cout << "Yes" << endl;
		
		} else {
			
			cout << "No" << endl;
			
		}
		
		return 0;
		
}

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

int main(){
    int n,t;
    cin>>n>>t;
    vector<int> a(n);
    rep(i,n) cin>>a[i];

    int mi=a[0],ma=0;
    for(int i=1;i<n;i++){
        if(a[i]>mi) ma=max(ma,a[i]-mi);
        mi=min(mi,a[i]);
    }

    int ans=0;
    mi=a[0];
    for(int i=1;i<n;i++){
        if(a[i]-mi==ma) ans++;;
        mi=min(mi,a[i]);
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3768
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  int A[N+2];
  A[0] = 0;
  A[N+1] = 0;
  int ans = 0;
  for(int i=0;i<N;++i) {
    cin>>A[i+1];
  }
  for(int i=1;i<=N+1;++i) {
    ans += abs(A[i]-A[i-1]);
  }
  int ansarr[N];
  for(int i=1;i<=N;++i) {
    if((A[i]<A[i-1] && A[i]<A[i+1]) || (A[i]>A[i-1] && A[i]>A[i+1])) ansarr[i-1] = ans - 2*min(abs(A[i]-A[i-1]), abs(A[i]-A[i+1]));
    else ansarr[i-1] = ans;
  }
  for(int i=0;i<N;++i) cout<<ansarr[i]<<endl;
}



Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
int cnt[100001]={0};
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        cnt[a-1]++;cnt[a]++;cnt[a+1]++;
    }
    sort(cnt,cnt+100000);
    
    cout<<cnt[99999]<<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
  int a,b,c,n,i;
  
  scanf("%d",&n);
  for(i=n;i>0;i++){
    a=i/100;
    b=(i%100)/10;
    c=(i%100)%10;
    if((a==b)&&(a==c))break;
  }
  printf("%d",i);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
// #define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

string S;
ll K;
const ll gosen = 5000000000000000;

ll solve() {
    for (auto s : S) {
        ll c = s - '0';
        if (c == 1) {
            K--;
            if (K == 0) return 1;
        } else {
            return c;
        }
    }
    return 0;
}

signed main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> S >> K;
    cout << solve() << "\n";
    return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] countArr = new int[n + 1];
            for (int x = 1; x <= 100; x++) {
                for (int y = 1; y <= 100; y++) {
                    for (int z = 1; z <= 100; z++) {
                        int value = x * x + y * y + z * z + x * y + x * z + y * z;
                        if (value > n) {
                            break;
                        }
                        countArr[value]++;
                    }
                }
            }

            for (int i = 1; i <= n; i++) {
                out.println(countArr[i]);
            }
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

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

    }

}

Measured memory_bytes: 34904
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;
typedef vector<ll> vel;
typedef vector<string> ves;
typedef vector<int> vei;
typedef vector<vector<ll>> vvel;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main() {
    char s;cin>>s;
    string abc="abcdefghijklmnopqrstuvwxyz",ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    rep(i,26) {
        if(s==abc[i]) {
            cout<<"a"<<endl;
            break;
        }
        else if(s==ABC[i]) {
            cout <<"A"<<endl;
            break;
        }
    }
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(i,array) for(auto& x:array)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 10000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;



int main(){
    int n,m;
    cin>>n>>m;
    vll x(m);
    vll y(m-1);
    ll sum=0;

    rep(i,m)cin>>x[i];
    sort(all(x));
    rep(i,m-1)y[i]=x[i+1]-x[i];
    sort(all(y));

    rep(i,m-n)sum+=y[i];
    cout<<sum<<endl;
    
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d;
cin >> a>> b;
int count =0;
    for(int i = a;i <=b;i++){
        c = i/1000;
        d = i%100;
        d = d/10 + (d%10)*10;
        if(c == d){
            count++;
        }
    }
    cout<<count<<endl;
}


Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    R = INT()
    print(3* R*R)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
#define all(V) V.begin(),V.end()

bool X(ll a, ll b, ll c) {
	ll d;
	while(a>0&&b>0&&c>0){
		d = a % 2 + b % 2 + c % 2;
		a /= 2;
		b /= 2;
		c /= 2;
		if (d == 1 || d == 3)
			return false;
	}
	return true;
}

int main() {
	ll N, a;
	cin >> N;
	vector<ll> A(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
	}
	sort(all(A));
	if (N % 3) {
		if (A[0] == 0 && A[N - 1] == 0) {
			cout << "Yes" << endl;
			return 0;
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	else {
		a = N / 3;
		for (int i = 1;i < a;i++) {
			if (A[i] != A[i - 1]) {
				cout << "No" << endl;
				return 0;
			}
		}
		for (int i = a + 1;i < a * 2;i++) {
			if (A[i] != A[i - 1]) {
				cout << "No" << endl;
				return 0;
			}
		}
		for (int i = 2 * a + 1;i < N;i++) {
			if (A[i] != A[i - 1]) {
				cout << "No" << endl;
				return 0;
			}
		}
		if (X(A[0],A[a],A[2*a])) {
			cout << "Yes" << endl;
			return 0;
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	 vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}
ll ans = 0;
int main() {
	ll L, R;
	cin >> L >> R;
	ll ans=2020;
	ll tmp;
	if ( R-L >= 2020) {
		for(ll i = 0; i < 2019; i++) {
			for (ll j = i + 1; j < 2019; j++) {
				ans = min(ans, (j * i)%2019);

			}

		}
		
	}
	else {
		for (int i = 0; i < R-L+1; i++) {
			for (int j = i + 1; j < R-L+1; j++) {
				ans = min(ans, (L + i) * (L + j)%2019);

			}
		}
	}
	cout <<ans;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int call(int number,int fill,int re,int digit){
	   if(fill==digit)
	      {
	      	     if(number<=re)
	      	       {   int a=0,b=0,c=0;
	      	           while(number!=0)
	      	              {   
	      	              	  int x=number%10;
	      	              	  if(x==3)a++;
	      	              	  else if(x==5)b++;
	      	              	  else if(x==7)c++;
	      	              	  number=number/10;
	      	              	
							}
					//	cout<<a<<" "<<b<<" "<<c<<endl;	
	      	       	    if(a>0&&b>0&&c>0)
	      	       	       return 1;
	      	       	       else
	      	       	        return 0;
					 }
					 else
					  return 0;
		  }
		 else
		    return call(10*number+3,fill+1,re,digit)+call(10*number+5,fill+1,re,digit)+ call(10*number+7,fill+1,re,digit);
	  
	
}

int main(){
       int n;
      	
       cin>>n;
       int m =n;int digit=0;
       while(m!=0)
         {
         	 m=m/10;  digit++;
		 }
        // cout<<digit<<" ";
        int sum=0;
         for(int i=3;i<=digit;i++)
          sum+=call(0,0,n,i);
       cout<<sum;

  
}


Measured memory_bytes: 256
//one point go in queue more than n times is bad
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
static const int MAXN = 1e4 + 10;
static const LL OO = (long long)1 << 60;
int n , m;
struct Node
{
    int x , y;
};
int q[MAXN * MAXN];
bool vis[MAXN];
int times[MAXN];
vector<Node> data[MAXN];
int pre , tail;
bool flag;
LL dis[MAXN];
LL mx;
bool first = 1;
void Spfa()
{
    q[tail++] = 1;
    times[1] = 1;dis[1] = 0;
    while(pre < tail)
    {
        int u = q[pre++];

        if(times[u] > n)
        {
            flag = 1;
            return ;
        }
        for(auto nxt:data[u])
        {
            int v = nxt.x;
            int co = nxt.y;

            if(dis[v] < dis[u] + co)
            {
                dis[v] = dis[u] + co;
                ++times[v];
                if(!vis[v])
                {
                    if(v == n && first)
                    {
                        mx = dis[n] , first = 0;
                    }
                    vis[v] = 1;
                    q[tail++] = v;
                }
            }
        }
        vis[u] = 0;
    }
}

int main()
{
    pre = tail = 0;
    scanf("%d%d" , &n , &m);
    for(int i = 0 ; i <= n ; ++i)
    {
        dis[i] = -OO;
    }
    for(int i = 1 ; i <= m ; ++i)
    {
        int a , b , c;
        scanf("%d%d%d" , &a , &b , &c);
        data[a].push_back({b , c});
    }
    Spfa();

    if(flag)
    {
        if(dis[n] == mx)
            printf("%lld" , mx);
        else
            puts("inf");
    }
    else
    {
        printf("%lld\n" , dis[n]);
    }

}


Measured memory_bytes: 6272
using System;

class Program
{
	static void Main(string[] args)
	{
		string input = Console.ReadLine();
		string[] str = input.Split(' ');

		while(true)
		{
			int n0 = 0, n1 = 0;
			int start = -1, end = -1;
			int num_count = 0;
			bool is_minus = false;
			for(int i=0; i<str.Length; i++)
			{
				int n;
				if(num_count<2 && str[i].Equals("-"))
				{
					is_minus = true;
				}
				else if(int.TryParse(str[i], out n))
				{
					n0 = n1;
					n1 = n * (is_minus ? -1 : 1);
					start = end;
					end= i;
					is_minus = false;
					num_count ++;
				}
				else if(num_count>=2 && (str[i].Equals("+") || str[i].Equals("-") || str[i].Equals("*")))
				{
					int a = 0;
					switch(str[i])
					{
						case "+":
							a = n0 + n1;
							break;
						case "-":
							a = n0 - n1;
							break;
						case "*":
							a = n0 * n1;
							break;
					}
					string[] s = new string[str.Length-2];
					for(int j=0, k=0; j<str.Length; j++, k++)
					{
						if(j == start)
						{
							s[k] = a.ToString();
						}
						else if(j==end || i==j)
						{
							k --;
							continue;
						}
						else
						{
							s[k] = str[j];
						}
					}
					str = new string[s.Length];
					Array.Copy(s, str, s.Length);
					break;
				}
			}

			if(str.Length == 1)
			{
				int output;
				if(int.TryParse(str[0], out output))
				{
					Console.WriteLine(str[0]);
					return;
				}
			}
		}
	}
}

Measured memory_bytes: 9292
# -*- coding: utf-8 -*-
from sys import stdin, stdout


def read():
    x = stdin.readline().rstrip()
    return x


def __main__():

    x, y, a, b, c = map(int, read().split())

    p = [int(i) for i in read().split()]
    q = [int(i) for i in read().split()]
    r = [int(i) for i in read().split()]

    red = [(j, 'r') for j in p]
    green = [(j, 'g') for j in q]
    white = [(j, 'w') for j in r]

    apples = red + green + white

    apples.sort(reverse=True)

    res = 0
    fl = True
    ind = 0
    number = 0
    x0 = 0
    y0 = 0

    while fl:
        ap = apples[ind]
        if ap[1] == 'r':
            if x0 < x:
                number += 1
                x0 += 1
                res += ap[0]
        elif ap[1] == 'g':
            if y0 < y:
                number += 1
                y0 += 1
                res += ap[0]
        else:
            number += 1
            res += ap[0]

        ind += 1

        if number == x + y:
            fl = False

    print(res)


__main__()

Measured memory_bytes: 121700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }




void solve() {
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;
}

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





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

public class Main {
  public static void main(String[] args) throws Exception {
    try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      String[] tmp = br.readLine().split(" ");
      int n = Integer.parseInt(tmp[0]);
      int m = Integer.parseInt(tmp[1]);

      List<List<Integer>> g = new ArrayList<>(n);
      for (int i = 0; i < n; i++) {
        g.add(new ArrayList<>());
      }

      for (int i = 0; i < m; i++) {
        tmp = br.readLine().split(" ");
        int a = Integer.parseInt(tmp[0]) - 1;
        int b = Integer.parseInt(tmp[1]) - 1;
        g.get(a).add(b);
        g.get(b).add(a);
      }

      int[] ans = new int[n];

      Queue<Integer> q = new ArrayDeque<>();
      q.offer(0);
      while (!q.isEmpty()) {
        int p = q.poll();
        for (int v : g.get(p)) {
          if (ans[v] == 0) {
            ans[v] = p + 1;
            q.add(v);
          }
        }
      }

      PrintWriter pw = new PrintWriter(System.out);
      pw.println("Yes");
      for (int i = 1; i < n; i++) {
        pw.println(ans[i]);
      }
      pw.flush();

    }
  }
}

Measured memory_bytes: 72648
A,B,C,D=map(int,input().split())
if A<C and B>=D :
  res=D-C
elif A>=C and B>=D :
  res=D-A
elif A<C and B<D :
  res=B-C
else :
  res=B-A
if res<=0 :
  print(0)
else :
  print(res)

Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef pair<pl,ll> tl;
const ll MN = 1010;
const ll MW = 10100;
tl w[MN];
ll dp[MN][MW];
int main() {
	ll n;
	cin >> n;
	for(int i=0;i<n;i++) {
		ll a,b,c;
		cin >> a >> b >> c;
		w[i] = {{a+b,b},c};
	}
	sort(w,w+n,greater<tl>());
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++) {
		ll wt = w[i].first.first-w[i].first.second;
		ll st = w[i].first.second;
		ll val = w[i].second;
		dp[i+1][st] = max(dp[i][st],val);
		for(int j=0;j<MW;j++) {
			if(dp[i][j] < 0) {continue;}
			dp[i+1][j] = max(dp[i][j],dp[i+1][j]);
			if(j >= wt) {
				ll nx = min(j-wt,st);
				dp[i+1][nx] = max(dp[i+1][nx],dp[i][j]+val);
			}
		}
	}
	ll res = 0;
	for(int i=0;i<MW;i++) {
		res = max(res,dp[n][i]);
	}
	cout << res << '\n';
}


Measured memory_bytes: 80000
#include <iostream>
using namespace std;
#define rep(i,q) for(int i = 0; q > i; i++)
int main(){
  int H,W;
  cin >> H >> W;
  rep(i,H){
    rep(j,W){
      string tmp;cin >> tmp;
      if(tmp == "snuke"){
        char arupa = 'A'-0+(j);
        cout << arupa << i+1 << endl;
      }
    }
  }
 return 0; 
}

Measured memory_bytes: 256
/* Algorithm to find articulation points on an indirected
 **/

#include<bits/stdc++.h>

using namespace std;

const int SIZE = 100013;

bool visited[SIZE], ap[SIZE];
int disc[SIZE], low[SIZE], parent[SIZE];

vector<int> G[SIZE];

void articulation(int u){
  static int time = 0;
  int children = 0;
  visited[u] = true;
  disc[u] = low[u] = ++time;
  for(int i = 0; i < G[u].size(); i++){
      int v = G[u][i];
      if(!visited[v]){
          children++;
          parent[v] = u;
          articulation(v);
          low[u] = min(low[u], low[v]);
          if(parent[u] == -1 && children > 1)
            ap[u] = true;
          if(parent[u] != -1 && low[v] >= disc[u])
            ap[u] = true;
      }
      else if(v != parent[u])
        low[u] = min(low[u], disc[v]);
  }
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  #ifdef Larra
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif
  int n,m;
  cin>>n>>m;
  for(int i = 0; i < m; i++){
      int u,v;
      cin>>u>>v;
      G[u].push_back(v);
      G[v].push_back(u);
  }
  for(int i = 0; i < SIZE; i++)
    parent[i] = -1;
  articulation(
               0);
  for(int i = 0; i < n; i++)
    if(ap[i])
      cout<<i<<"\n";
}

Measured memory_bytes: 7464
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	s <- getLine
	t <- getLine
	putStrLn $ which "Yes" "No" $ s `isPrefixOf` t

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

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

    vector<int> num(1000000);
    
    for (int i = 2; i <= n; i++) {
        int tmp_a;
        cin >> tmp_a;
        num[tmp_a]++;
    }

    for (int i = 1; i <= n ; i++) {
        cout << num[i] << endl;
    }

    return 0;

}

Measured memory_bytes: 7220