akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cmath>
#include<array>
#include<algorithm>
#include<queue>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}
//long nHr(int n,int r) {
//	n = n + r - 1;
//	return nCr(n,r);
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI A, P;
	cin >> A >> P;
	cout << (A * 3 + P) / 2 << endl;
}


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

using namespace std;

int main(void){
    string s;
    cin >> s;
    for(int i = 0; i < s.length() - 1; i++){
        if(s[i] == s[i + 1]){
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
        if(i + 2 < s.length() && s[i] == s[i + 2]){
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}


Measured memory_bytes: 3760
#include<cstdio>
#include<algorithm>
using namespace std;
#define INF 0x3fffffff
int n,x;
int m,Min=INF;
int main() {
	scanf("%d %d",&n,&x);
	for(int i=1;i<=n;i++) {
		scanf("%d",&m);
		x-=m;
		Min=min(Min,m);
	}
	printf("%d\n",n+x/Min);
	return 0;
}

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

int main () {
    char str [222];
    scanf ("%s", str ) ;
    int n= strlen (str ) ;
    for (int i=n -2; i; i -=2) {
        if( strncmp (str , str +i/2 , i/2) ==0) {
            printf ("%d\n" ,i) ;
            return 0;
        }
    }   
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
    long long N,W,val[109],we[109],i,j;
        long long Kn[105][100007];
    void knap()
    {
        for(i=0;i<=W;i++)
            Kn[0][i]=0;
        for(i=1;i<=N;i++)
            Kn[i][0]=0;
//            cout<<"HA";
        for(i=1;i<=N;i++)
            for(j=1;j<=W;j++)
{
                if(we[i]>j) {
                        Kn[i][j]=Kn[i-1][j];
//                        cout<<i<<" "<<we[i]<<" "<<j<<" "<<Kn[i][j]<<endl;
                }
                else
                    {
                        Kn[i][j]=max(Kn[i-1][j],val[i]+Kn[i-1][j-we[i]]);
//                        cout<<we[i]<<" "<<j<<" "<<Kn[i][j]<<endl;
                    }
}
        cout<<Kn[N][W]<<endl;
    }
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>N>>W;
    for(i=1;i<=N;i++)
        cin>>we[i]>>val[i];
        knap();
//        cout<<"?";
        return 0;
}


Measured memory_bytes: 80128
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 27 20:57:36 2019

@author: Yamazaki Kenichi
"""

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

flg = 1
m = 10**9
ans = 0
for c in A:
    flg *= -1 if c < 0 else 1
    m = min(m, abs(c))
    ans += abs(c)

ans = ans - (2*m if flg < 0 else 0)

print(ans)

Measured memory_bytes: 14372
N=int(input())
I=[[] for _ in range(N)]
a=0
for i in range(N):
  A=int(input())
  for _ in range(A):
    x,y=map(int,input().split())
    I[i].append((x-1,y))

for i in range(2**N):
  f=1
  h=[]
  u=[]
  for j in range(N):
    if (i>>j)&1:
      h.append(j)
    else:
      u.append(j)
  for k in h:
    for l in I[k]:
      if l[1]==1 and l[0] in u:
        f=0
        break
      elif l[1]==0 and l[0] in h:
        f=0
        break
  if f==1:
    a=max(a,len(h))
print(a)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

int main(){
    ll n;
    cin >> n;
    ll max = 10000;
    ll f[10000+1] = {0};
    rep1(x,floor(sqrt(max-2) - 1)){
        rep1(y,floor(sqrt(max-2) - 1)){
            rep1(z,floor(sqrt(max-2) - 1)){
                ll tmp = x*x + y*y + z*z + x*y + y*z + z*x;
                if(tmp > max) continue;
                f[tmp] += 1;
            }
        }
    }

    rep1(i,n){
        cout << f[i] <<endl;
    }
    return 0;
}

Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define reverse(v) reverse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vc = vector<char>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
const ll MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
 
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n){
    if(a[i]==0) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll prod =1;
  rep(i,n){
    if(prod> ((ll)5e18)/a[i]){
      cout << -1 << endl;
      return 0;
    }
    prod *= a[i];
    if(prod > ((ll) 1e18)){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << prod << endl;
  
  return 0;
}

Measured memory_bytes: 3972
N, A, B, C, D=map(int, input().split())
S = input()
A -= 1
B -= 1
C -= 1
D -= 1

if "##" in S[A:C+1] or "##" in S[B:D+1]:
    print('No')
else:
    if C<D:
        print('Yes')
    else:
        if "..." in S[B-1:D+2]:
            print('Yes')
        else:
            print('No')


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

template <int mod = (int)(1e9 + 7)>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y)
      : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const {
    return ModInt(*this) += p;
  }
  ModInt operator-(const ModInt &p) const {
    return ModInt(*this) -= p;
  }
  ModInt operator*(const ModInt &p) const {
    return ModInt(*this) *= p;
  }
  ModInt operator/(const ModInt &p) const {
    return ModInt(*this) /= p;
  }
  bool operator==(const ModInt &p) const {
    return x == p.x;
  }
  bool operator!=(const ModInt &p) const {
    return x != p.x;
  }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t n) const {
    ModInt res(1), mul(x);
    while(n) {
      if(n & 1) res *= mul;
      mul *= mul;
      n >>= 1;
    }
    return res;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int get_mod() { return mod; }
};

struct Combination {
  vector<ModInt<>> _fact, _rfact, _inv;
  Combination(long long nsize = 5000000)
      : _fact(nsize + 1), _rfact(nsize + 1),
        _inv(nsize + 1) {
    _fact[0] = _rfact[nsize] = _inv[0] = 1;
    for(int i = 1; i <= nsize; i++)
      _fact[i] = _fact[i - 1] * i;
    _rfact[nsize] /= _fact[nsize];
    for(int i = nsize - 1; i >= 0; i--)
      _rfact[i] = _rfact[i + 1] * (i + 1);
    for(int i = 1; i <= nsize; i++)
      _inv[i] = _rfact[i] * _fact[i - 1];
  }
  inline ModInt<> fact(int k) const { return _fact[k]; }

  inline ModInt<> rfact(int k) const { return _rfact[k]; }

  inline ModInt<> inv(int k) const { return _inv[k]; }

  ModInt<> P(int n, int r) const {
    if(r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }

  ModInt<> C(int p, int q) const {
    if(q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }
  ModInt<> H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return r == 0 ? 0 : C(n + r - 1, r - 1);
  }
};

long long n;
vector<long long> v;
Combination comb;

ModInt<> solve();

int main() {
  cin >> n;
  v.resize(n);
  for(int i = 0; i < n; ++i) cin >> v[i];
  cout << solve() << endl;
  return 0;
}

ModInt<> solve() {
  ModInt<> res = 0, sum = 0;
  for(int i = 0; i < n - 1; ++i) {
    ModInt<> now = v[i + 1] - v[i];
    sum += comb.inv(i + 1);
    res += now * sum;
  }
  return res * comb.fact(n - 1);
}

Measured memory_bytes: 59648
#ABC131 D
from operator import itemgetter as ig
N = int(input())
A = [0 for i in range(N)]
B = [0 for i in range(N)]
for i in range(N):
    A[i], B[i] = (int(_) for _ in input().split())
AB = sorted([(A[i], B[i])for i in range(N)], key = ig(1))
last = 0
ans = True
for i in range(N):
    last += AB[i][0]
    if last <= AB[i][1]:
        continue
    else:
        ans = False
        break
if ans:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 36564
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define  pb(x) push_back(x)
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define mod 1000000007
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
int main()
{
	sync;
	ll n;
	string str;
	cin>>n>>str;
	if(n>=3200)
	cout<<str;
	else
	cout<<"red";
}

Measured memory_bytes: 256
def color(num: int) -> int:
    if 1 <= num <= 399:
        return 0
    if 400 <= num <= 799:
        return 1
    if 800 <= num <= 1199:
        return 2
    if 1200 <= num <= 1599:
        return 3
    if 1600 <= num <= 1999:
        return 4
    if 2000 <= num <= 2399:
        return 5
    if 2400 <= num <= 2799:
        return 6
    if 2800 <= num <= 3199:
        return 7
    if 3200 <= num:
        return 8


n = int(input())
a = list(map(int, input().split()))
arr = []
certain = 0
for num in a:
    col = color(num)
    if col == 8:
        certain += 1
    else:
        arr.append(col)

color_count = len(set(arr))
if color_count == 0:
    print(1, certain)
else:
    print(color_count, color_count + certain)


Measured memory_bytes: 38256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  string s;cin>>s;
  map<char,ll>M;
  rep(i,n)M[s[i]]++;
  ll ans=M['R']*M['G']*M['B'];
  for(ll i=0;i<n-2;i++){
    for(ll j=i+1;j+(j-i)<n;j++){
      ll k=j+(j-i);
      if(s[i]!=s[j]&&s[j]!=s[k]&&s[i]!=s[k])ans--;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>

using namespace std;
const int maxn = 20000;
int f[maxn];

int main()
{
    int n,k;
    cin >> n >> k;
    f[0] = 1;
    for(int i = 1;;i++){
        f[i] = f[i-1] * 2;
        if(f[i] > 1e6) break;
    }
    double ans = 0.0;
    for(int i = 1;i <= n;i++){
        double N = double (n);
        double now = 1.0/N;
        for(int j = 0;;j++){
            if(i * f[j] >= k){
                now  *= (1.0/f[j]);
                ans += now;
                break;
            }
        }
    }
    printf("%.11lf",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vvin=vector<vin>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   ll n,a,b;
           cin>>n>>a>>b;
           if((b-a)%2==0)cout<<abs(a-b)/2<<endl;
           else{
             ll ans=INF;
             ll c=b-a;
             ll d=min(n-b,a-1);
             ans=d+1+(b-a-1)/2;
             cout<<ans<<endl;
           }
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
int u[1100000];
vector<int> y;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e=0,f=0,g=0;
  cin >>a>>b>>c>>d;
  e=abs(b-a),g=abs(c-b);
  f=abs(c-a);
  if(f<=d||(e<=d&&g<=d)) cout <<"Yes\n";
  else cout <<"No\n";
  return (0);
}


Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");

const N = input[0].split(' ').map(item => parseInt(item))[0]
const K = input[1].split(' ').map(item => parseInt(item))[0]

const greedy = (value, n, k) => {
    if (n == 0) {
        return value
    }
    if (n > 0) {
        a = value * 2
        b = value + k
        a < b ? value = a : value = b
        return greedy(value, n - 1, k)
    }
}

console.log(greedy(1, N, K))


Measured memory_bytes: 7372
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    ll n,m; cin >> n >> m;
    ll maxL = -INF;
    ll minR = INF;
    ll L,R;
    for(ll i=0;i<m;i++){
        cin >> L >> R;
        maxL = max(L,maxL);
        minR = min(R,minR);
    }
    if(maxL <= minR)
        cout << minR-maxL+1 << endl;
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <math.h>
#include<string.h>
#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)

//	rep(i,10)cout << i << endl;
using namespace std;

int main(void){
	int n,w[101];
	cin >> n;
	int sum = 0,now = 0,ans_min =9999999;
	rep(i,n){
		cin >> w[i];
		sum += w[i];
	}
	rep(i,n-1){
		now += w[i];
		sum -= w[i];
		if(abs(sum - now) < ans_min){
			ans_min = abs(sum - now);
		}
		
		//cout << now << " " << sum << " " << ans_min <<" " << w[i]<< endl;
	}
	cout << ans_min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T> ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  LL N;
  cin>>N;
  LL mi = N-1;
  for(LL i=1;i*i<=N;i++){
    LL a= i;
    LL b=N/a;
    if(a*b==N){
      mi=min(mi, a+b-2);
    }
  }
  cout<<mi<<endl;

  return 0;
}


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

int main(){
  int n,k,q;
  cin >>n >>k >>q;
  int map[n] = {0};
  rep(i,q){
    int a;
    cin >>a;
    map[a-1]++;
  }
  rep(i,n){
    if(q-map[i]<k) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

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

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

    int n;
    cin >> n;
    vector<vector<int>> dist(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < n; j++) {
            dist[i][j] = s[j] == '1' ? 1 : 1e9;
        }
    }

    vector<int> color(n, -1);
    bool is_bip = true;
    function<void(int, int)> dfs = [&](int v, int c) {
        if (color[v] != -1) {
            if (color[v] != c) {
                is_bip = false;
            }
            return;
        }
        color[v] = c;
        for (int i = 0; i < n; i++) {
            if (dist[v][i] == 1) {
                dfs(i, !c);
            }
        }
    };
    dfs(0, 0);
    if (!is_bip) {
        cout << -1 << endl;
        return 0;
    }

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

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (dist[i][j] != 1e9) {
                ans = max(ans, dist[i][j]);
            }
        }
    }

    cout << ans + 1 << endl;
}


Measured memory_bytes: 384
#include<stdio.h>  

int main(void) {  

int a, b, c, i, s ;  

s=0 ;  

scanf("%d %d %d", &a, &b, &c) ;  

for(i= a ; i<= b ; i ++) {  

if(c%i == 0) {  

s=s+1 ;  

}  

}  

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

return 0;  

}

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

int main() {
	// your code goes here
	int n, m, t = 0; cin>>n>>m;
	for(int i =0; i < m; i++){
		int x; cin>>x;
		t += x;
	}
	cout<<(n < t ? - 1 : n - t)<<endl;
	return 0;
}

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

int main()
{
	double a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f) {
		double x = (c*e - b*f) / (a*e - b*d);
		double y = (a*f - c*d) / (a*e - b*d);
		if (x == 0.0)x = 0;
		if (y == 0.0)y == 0;
		printf("%.3f %.3f\n", x, y);
	}
    return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <iomanip>
#include <cmath>
int main()
{
	int N, K;
	std::cin >> N >> K;

	double percent{ 0.0 };

	for(int i=1; i<=N; ++i){
		int coin{ 0 };
		int score{ i };
		while (true) {
			if( score <= (K-1)) {
				++coin;
				score = 2*score;
			}
			else {
				break;
			}
		}
		percent += 1 / pow(2,coin) / N;
	}

	std::cout << std::setprecision(12) << percent << std::endl;
	return 0;
}

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

int N, M;
vector<vector<bool>> graph;
vector<bool> vertex;

void Dfs(int v) {
  vertex[v] = true;
  for (int v2 = 0; v2 < N; v2++) if (graph[v][v2] == true && vertex[v2] == false) Dfs(v2);
  return;
}

int main() {
  cin >> N >> M;
  graph.resize(N, vector<bool>(N)), vertex.resize(N);
  vector<int> a(M), b(M);
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    graph[a[i] - 1][b[i] - 1] = graph[b[i] - 1][a[i] - 1] = true;
  }

  int ans = 0;
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < N; j++) vertex[j] = false;
    graph[a[i] - 1][b[i] - 1] = graph[b[i] - 1][a[i] - 1] = false;

    Dfs(0);

    bool bridge = false;
    for (int j = 0; j < N; j++) if (vertex[j] == false) bridge = true;
    if (bridge == true) ans++;

    graph[a[i] - 1][b[i] - 1] = graph[b[i] - 1][a[i] - 1] = true;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
typedef pair<pair<int ,int>, int> P;
vector<pair<pair<int ,int>, int> > v_ans;
vector<int>v_;
vector<long int>v_ansl;
/*taro tenn,hanako_ten,sum*/

bool cmp(P h, P r){
  return h.second < r.second;
}

int v[101];
int main(){
  int D,E;
  cin >>D>>E;

  while(!(D==0 and E == 0)){
    float ans = 20000;
    for(int i = 0;i<=D;i++){
      ans = min(ans,(float)abs(sqrt(i*i+(D-i)*(D-i))-E));

    }
    cout <<ans<<endl;
    cin >>D>>E;
  }

  return 0;
}



Measured memory_bytes: 3112
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a;
  cin>>a;
  YesNo(!(a%ketawa(a)));
}


Measured memory_bytes: 640
#include<stdio.h>

int main(){
  int x,y,t;

  scanf("%d %d",&x,&y);

  while(1){
   if(x>=y) t=x%y;
   else t=y%x;

   if(t==0) break;
   else {x=y;
         y=t;
   }
  }
  printf("%d\n",y);
 
  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int h,w,m;
    cin>>h>>w>>m;
    map<pii,int> store;
    map<int,int> row,col;
    int ans = 1;
    for(int i = 0 ; i < m ; i++)
    {
        int x,y;
        cin>>x>>y;
        row[x]++;
        col[y]++;
        store[{x,y}]++;
    }
    for(auto x : store)
    {
        ans = max(ans,row[x.ff.ff]+col[x.ff.ss]-1);
    }
    vector<pii> rowhold;
    for(auto x : row)
        rowhold.pb({x.ss,x.ff});
    sort(rall(rowhold));

    for(auto x : col)
    {
        for(int i = 0 ; i < rowhold.size() ; i++)
        {
            if(store.find({rowhold[i].ss,x.ff}) == store.end())
            {
                ans = max(ans,x.ss+rowhold[i].ff);
                break;
            }
        }
    }
    cout<<ans;






    printclock;
    return 0;
}

Measured memory_bytes: 67860
# import sys
# input = sys.stdin.readline

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

n,d = mp()
cnt = 0
for i in range(n):
    x,y = mp()
    if x**2+y**2 <= d**2:
        cnt += 1
print(cnt)




Measured memory_bytes: 69824
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int i=0,j=0,k=0;
	cin>>s;
	for(;s[i]!='A';++i){
		
	}
	for(j=s.length();s[j]!='Z';j--)
	{
	}
	j++;
	cout<<j-i<<"\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
using namespace std;

signed main(){
    
    int n,m; cin>>n>>m;
    //F.F: prefecture number, F.S: year S: number
    vector<pair<P,int>> pref(m);
    rep(i,m){
        cin>>pref.at(i).F.F>>pref.at(i).F.S;
        pref.at(i).S=i;
    }
    
    sort(all(pref));
    pref.push_back(pair<P,int>(P(0,0),0));
    int cnt=0;
    rep(i,m){
        cnt++;
        pref.at(i).F.S=cnt;
        if(pref.at(i).F.F!=pref.at(i+1).F.F) cnt=0;
    }
    
    //F: prefecture number, S: number
    vector<P> ans(m);
    rep(i,m){
        ans.at(pref.at(i).S)=P(pref.at(i).F.F,pref.at(i).F.S);
    }
    
    rep(i,m){
        cout<<setfill('0')<<setw(6)<<ans.at(i).F<<setw(6)<<ans.at(i).S<<endl;
    }
    
}

Measured memory_bytes: 7404
C = [[0] * 2001 for _ in range(2001)]
C[0][0] = 1
for i in range(2000):
    for j in range(i + 1):
        C[i + 1][j] += C[i][j]
        C[i + 1][j + 1] += C[i][j]


def comb(n, k):
    return C[n][k]


def ff(n, k):
    return comb(n + k - 1, k - 1)


def f(n, k):
    if k > n:
        return 0
    if n == 0 and k == 0:
        return 1
    if 1 > k:
        return 0
    return ff(n - k, k)


def main():
    N, K = map(int, input().split())
    for i in range(1, K + 1):
        b = f(K, i)
        r = 0
        r += f(N - K, i - 1)
        r += f(N - K, i)
        r += f(N - K, i)
        r += f(N - K, i + 1)
        ans = b * r % 1000000007
        print(ans)


main()


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

#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define endl        '\n'
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define rs(v,n)     v.resize(n)
#define hell        1000000007
#define peak        9123372036854775807
#define pii         acos(-1)
#define clr(a,x)    memset(a,x,sizeof(a))
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

namespace InOp{
template<class x,class y>
istream &operator>>(istream &in,pair<x,y> &p) 
{ 
    in>>p.F>>p.S;
    return in;
}
template<class x>
istream &operator>>(istream &in,vector<x> &v) 
{
    for(auto& i:v)
        in>>i;
    return in;
}
template<class x,class y>
ostream &operator<<(ostream &out,pair<x,y> &p) 
{ 
    out<<"("<<p.F<<","<<p.S<<") ";
    return out; 
}
template<class x>
ostream &operator<<(ostream &out,vector<x> &v) 
{ 
    out<<v.size()<<endl;
    for(auto i:v)
        out<<i<<" ";
    out<<endl;
    return out; 
}
}
using namespace InOp;

namespace ModOp{
template<class x,class y,class z> z add(x a,y b,z m){return (a+b)%m;}
template<class x,class y,class z> z sub(x a,y b,z m){return (a-b+m)%m;}
template<class x,class y,class z> z mul(x a,y b,z m){return ((ll)a*b)%m;}
template<class y,class z> z expo(ll b,y e,z m){ll a=1;b%=m;while(e!=0){if((e&1)==1){a=a*b;a=a%m;}b=b*b;b%=m;e>>=1;}return a%m;}
template<class x,class z> z inv(x b,z m){return expo(b,m-2,m);}
template<class x,class y> x invGeneral(x a,y b){if(a==0)return b==1?0:-1;x m=invGeneral(b%a,a);return m==-1?-1:((1-(ll)b*m)/a+b)%b;}
template<class x,class y,class z> z div(x a,y b,z m){ll c=inv(b,m);return mul(a,c,m);}
}
using namespace ModOp;

namespace Debug{
template<class x> void deb(x a){cerr<<"a"<<": "<<a<<endl;}
template<class x,class y> void deb(x a,y b){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<endl;}
template<class x,class y,class z> void deb(x a,y b,z c){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<endl;}
template<class x,class y,class z,class xy> void deb(x a,y b,z c,xy d){cerr<<"a"<<": "<<a<<" | "<<"b"<<": "<<b<<" | "<<"c"<<": "<<c<<" | "<<"d"<<": "<<d<<endl;}
}
using namespace Debug;

#define N  1000005

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll tt=1;
    // cin>>tt;
    while(tt--)
    {
        ll i,j,k,l,r,x,y,m,n;
        string s;
        cin>>s;
        cout<<s[0]<<s[1]<<s[2];
    }

    return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n, m;
  cin >> n >> m;
  string s;
  cin >> s;

  vector<P> valid_indices;

  vector<P> dp(n+1, mp(-1, -1)); // contains the (count, prev_distance)
  ll largest_cnt = -1;
  for (int i = 1; i <= n; ++i) {
    if (s[i] == '1') {
      dp[i] = mp(-1, -1);
      continue;
    }
    // Now, s[i] == '0'
    if (i <= m) {
      dp[i] = mp(1, i);
      valid_indices.emplace_back(i, 1);
      continue;
    }

    // Now, i > m.
    // We want to find i-m <= "j in d" <= i.

    auto iter = lower_bound(all(valid_indices), mp((ll)(i-m), -1LL));
    if (iter == valid_indices.end()) {
      cout << -1 << endl;
      return 0;
    }
    ll id = (*iter).fr;
    ll cnt = (*iter).sc;
    dp[i] = mp(cnt+1, i - id);
    valid_indices.emplace_back(i, cnt+1);
  }

  // Now, dp[n] contains the result.
  if (dp[n] == mp(-1LL, -1LL)) {
    cout << -1 << endl;
    return 0;
  }

  vector<ll> ans;
  ll i = n;
  P cur = dp[n];
  rep(iter, dp[n].fr) {
    ans.push_back(cur.sc);
    i -= cur.sc;
    cur = dp[i];
  }
  reverse(all(ans));


  rep(j, ans.size()) {
    cout << ans[j] << ((j == ans.size() - 1) ? '\n' : ' ');
  }
}


Measured memory_bytes: 5440
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] n = sc.next().toCharArray();

		int cnt = 0;
		for (char c : n) {
			if (c == '2') {
				cnt++;
			}
		}

		pr.println(cnt);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


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

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n,d;
	int a[15][15];
	int sum=0;
	cin>>n>>d;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<d;j++)
		cin>>a[i][j];
	}
	int ans=0;
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			sum=0;
			for(int l=0;l<d;l++)
			{
				int t=(a[i][l]-a[j][l]);
				sum+= t*t;
			}
			int flag=0;
			for(int i=0;i*i<=sum;i++)
			{
				if(sum==i*i)
				{
					flag=1;
					break;
				}
			}
			if(flag)
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
 } 

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

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

    if (a%3==0 || b%3==0 || (a+b)%3==0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int h, w;
    cin >> h >> w;
    
    cout <<(h-1)*(w-1)<< '\n';
    return 0;
}


Measured memory_bytes: 3480
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
  ll n,k,i;cin>>n>>k;
  ll A[n],flag;
  fo(i,0,n)cin>>A[i];
  while(k--)
  {
      flag=1;
      ll l,r;
      vector<ll>R(n+2,0);
      fo(i,0,n)
      {
          l=max(1ll,i+1-A[i]);r=min(i+1+A[i],n);
          if(r-l+1>=n)
          {}
          else
          flag=0;
          R[l]++;R[r+1]--;
      }
      if(flag&&k!=0)break;
     
          A[0]=R[1];
          for(i=2;i<=n;i++)
          {R[i]+=R[i-1];A[i-1]=R[i];}
          
      if(k==0)break;
      
  }
  if(k>0)
  {
      fo(i,0,n)cout<<n<<" ";
      cout<<"\n";
  }
  else
  {
      fo(i,0,n)cout<<A[i]<<" ";
      cout<<"\n";
  }
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//If wrong on pretest 2 means logically wrong


/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 6736
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    
    if(A > B)   swap(A, B);
    for(int i = A; i <= B; ++i){
        if(abs(A - i) == abs(B - i)){
            cout << i << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE\n";
}

Measured memory_bytes: 256
n = int(input())
A = [int(input()) for i in range(n)]

if A[0] != 0:
    print(-1)
    exit()

for i in range(1, n):
    if A[i] > A[i-1]+1:
        print(-1)
        exit()

ans = 0
for i in reversed(range(1, n)):
    if A[i-1] == A[i]-1:
        ans += 1
    else:
        ans += A[i]

print(ans)


Measured memory_bytes: 57700
#import numpy as np
import math
#from fractions import gcd

def main():

    ##get int
    first_input = list(map(lambda x:int(x), input().split(" ")))
    second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    #first_input = input().split(" ")

    N = first_input[0]
    M = first_input[1]

    Nokori = N
    for a in second_input:
        Nokori = Nokori - a

    if Nokori>=0:
        print(Nokori)
    else:
        print("-1")

if __name__ == '__main__':
    main()


Measured memory_bytes: 67968
n = int(input())
h = [num for num in map(int, input().split())]

dp = [0] * n
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
  dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]))
print(dp[n-1])

Measured memory_bytes: 52208
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main(void){
    char input[1000], word[11];
    int i, w = 0;
    scanf(" %s", word);
    //printf("%s\n", word);
    while(1){
        scanf(" %s", input);
        if(strcmp(input , "END_OF_TEXT") == 0){
            break;
        }
        for(i = 0; input[i] != '\0'; i++){
            input[i] = tolower(input[i]);
        }
        //printf("%s\n", input);
        if((strcmp(input, word)) == 0){
            w++;
            //printf("++\n");
        }
    }
    printf("%d\n", w);
    return 0;
}


Measured memory_bytes: 2096
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.List             (delete, maximum, minimumBy)
import           Data.Maybe            (fromJust)
import           Data.Ord              (comparing)

main :: IO ()
main = do
  n <- readLn
  as <- getInts
  let (x, y) = solve n as
  putStrLn $ show x ++ " " ++ show y

solve :: Int -> [Int] -> (Int, Int)
solve n as = (x, y)
  where x = maximum as
        y = minimumBy (comparing (\a -> abs (a - x `div` 2))) $ delete x as

readInts :: BC.ByteString -> [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words

getInts :: IO [Int]
getInts = readInts <$> BC.getLine


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

int main()
{
	int hi = 0, ht = 0, ki = 0, kt = 0, a = 0, b = 0, c = 0, d = 0;
	int hp = 0, kp = 0;

	cin >> hi >> ht
		>> ki >> kt
		>> a >> b >> c >> d;

	hp = a * hi + b * ht + hi / 10 * c + ht / 20 * d;

	kp = a * ki + b * kt + ki / 10 * c + kt / 20 * d;


	if (hp < kp)
		cout << "kenjiro" << endl;
	else if (hp > kp)
		cout << "hiroshi" << endl;
	else
		cout << "even" << endl;

	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define erep(i,l,r) for(int (i)=(l);(i)<=(r);(i)++)
#define ll long long
using namespace std;
int main(){
    char s[3];
    cin>>s;
    int ans;
    
    if(!strcmp(s,"SAT"))ans=1;
    else if(!strcmp(s,"FRI"))ans=2;
    else if(!strcmp(s,"THU"))ans=3;
    else if(!strcmp(s,"WED"))ans=4;
    else if(!strcmp(s,"TUE"))ans=5;
    else if(!strcmp(s,"MON"))ans=6;
    else if(!strcmp(s,"SUN"))ans=7;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int x,n,k;
    cin>>n>>k;
    long long int count=0;
    int a=0,b=0;
    for(int i=1;i<=n;i++)
    {
    if(i%k==0) a++;
    if(k%2==0&&i%k==k/2) b++;
    }
    count+=pow(a,3);
    if(k%2==0)
    count+=pow(b,3);
    cout<<count;
	return 0;
}

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

typedef long long ll;
const ll D=1e9+7;
ll pow2(ll x,ll y){
    if(y==0)return 1;
    ll k=pow2(x,y/2);
    return k*k%D*(y%2==1 ? x:1)%D;
}

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

    ll aa=1;
    ll bb=1;
    ll ans=pow2(2,n)-1;

    for(i=n ; i>n-a ; i--)aa*=i,aa%=D;
    for(i=n ; i>n-b ; i--)bb*=i,bb%=D;
    ll aaa=1;
    ll bbb=1;
    for(i=1 ; i<=a ; i++)aaa=aaa*i%D;
    for(i=1 ; i<=b ; i++)bbb=bbb*i%D;
    aa*=pow2(aaa,D-2);
    aa%=D;
    bb*=pow2(bbb,D-2);
    bb%=D;
    cout<<(ans-aa-bb+2*D)%D;
    return 0;
}


Measured memory_bytes: 256
//05
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int t;
  cin>>t;
  while(t--){
    int u=0,d=0;
    int n;
    cin>>n;
    int p;
    cin>>p;
    for(int i=0;i<n-1;i++){
      int n;
      cin>>n;
      u=max(u,n-p);
      d=max(d,p-n);
      p=n;
    }
    cout<<u<<' '<<d<<endl;
  }
  return 0;
}

Measured memory_bytes: 0