akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>
#include <string.h>

using namespace std;

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

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

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

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

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

bool prime(int n) {
  for (int i = 2; i <= sqrt(n); ++i) {
    if (n % i == 0) { return false; }
  }
  return n != 1;
}

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

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

ll powmod(ll x, ll n) { // like pow(x, n)
  ll r = 1;
  while (n) {
    if (n & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return r;
}

const int COM_MAX = 500010;
ll fac[COM_MAX], facinv[COM_MAX], inv[COM_MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  facinv[0] = facinv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < COM_MAX; ++i) {
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    facinv[i] = facinv[i-1] * inv[i] % MOD;
  }
}

ll COM(ll n, ll k) {
  return (fac[n] * facinv[k] % MOD) * facinv[n-k] % MOD;
}

ll PERM(ll n, ll k) {
  return (fac[n] * facinv[k] % MOD);
}

class UnionFind {
public:
  UnionFind(int size) : par(size, -1), rnk(size, 0) {}

  bool same(int x, int y) {
    return root(x) == root(y);
  }
  void unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return;

    if (rnk[x] < rnk[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rnk[x] == rnk[y]) { ++rnk[x]; }
    }
  }
  int root(int x) {
    if (par[x] < 0) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }

private:
  vector<int> par;
  vector<int> rnk;
};


int main(int argc, char** argv) {
  ll N, M, Q;
  cin >> N >> M >> Q;

  UnionFind tree(N);
  vector<P> edges; // different edges.
  rep(i, Q) {
    ll A, B, C;
    cin >> A >> B >> C;
    if (C == 0) {
      tree.unite(A, B);
    } else {
      edges.emplace_back(A, B);
    }
  }

  if (M == N - 1) { // G must be a tree.
    if (edges.size() == 0) {
      cout << "Yes" << endl;
      return 0;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }

  // Check different edges
  for (auto e : edges) {
    if (tree.same(e.first, e.second)) {
      cout << "No" << endl;
      return 0;
    }
  }

  set<int> st;
  rep(i, N) {
    int r = tree.root(i);
    st.insert(r);
  }
  ll K = st.size(); // the number of connected components.

  // H must be lower than or equals to (N-K) + K*(K-1)/2 = N + K(K-3)/2
  if (M <= N + K * (K - 3) / 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

#define MAXN 110000

ll n,m;
vector<vector<int>>edges(MAXN);

ll dp1[MAXN];
ll dp2[MAXN];
void dfs1(int x=1, int p =-1){
  dp1[x]=1;
  for(auto c: edges[x]){
    if(c==p)continue;
    dfs1(c, x);
    dp1[x] *= dp1[c];
    dp1[x] %= m;
  }
  dp1[x]++;
  dp1[x] %= m;
}

void dfs2(int x=1, int p=-1){
  if(p==-1)dp2[x]=1;

  int ec = edges[x].size();
  vector<ll>lprod(ec, 1);
  rep(i, ec){
    int c = edges[x][i];
    if(i)lprod[i] *= lprod[i-1];
    if(c==p)continue;
    lprod[i] *= dp1[c];
    lprod[i] %= m;
  }

  vector<ll>rprod(ec, 1);
  rrep(i, ec){
    int c = edges[x][i];
    if(i<ec-1)rprod[i] *= rprod[i+1];
    if(c==p)continue;
    rprod[i] *= dp1[c];
    rprod[i] %= m;
  }

  rep(i, ec){
    int c = edges[x][i];
    if(c==p)continue;
    dp2[c]=dp2[x];
    if(i)dp2[c] *= lprod[i-1];
    dp2[c] %= m;
    if(i<ec-1)dp2[c] *= rprod[i+1];
    dp2[c] %= m;
    dp2[c] = (dp2[c] + 1) % m;
    dfs2(c, x);
  }
}

vector<ll>ans(MAXN);
void dfs3(int x=1, int p=-1){
  ans[x] = dp2[x];
  for(auto c: edges[x]){
    if(c==p)continue;
    ans[x] *= dp1[c];
    ans[x] %= m;
    dfs3(c, x);
  }
}

int main(){
  cin>>n>>m;
  rep(i, n-1){
    int x,y;cin>>x>>y;
    edges[x].push_back(y);
    edges[y].push_back(x);
  }

  dfs1();
  dfs2();
  dfs3();

  rep1(i, n)cout<<ans[i]<<endl;

  return 0;

rep1(i, n)cout<<dp1[i]<<' ';cout<<endl;
rep1(i, n)cout<<dp2[i]<<' ';cout<<endl;

  return 0;
}

Measured memory_bytes: 22612
#include<stdio.h>
#include<limits.h>
#define MAX 105

int main(){

	int d[MAX],S[MAX],Pass[MAX],c[MAX][MAX];
	int i,j,next,n,u,k,v;
	int total=0,count=1,min;

	scanf("%d",&n);
	for(i = 0; i < n; i++){
		for(j = 0; j < n; j++){
			c[i][j] = -1;
		}
	}
	for(i = 0; i < n; i++){
		scanf("%d%d",&u,&k);
		for(j = 0; j < k; j++){
			scanf("%d",&v);
			scanf("%d",&c[i][v]);
		}
		d[i] = INT_MAX;
		S[i] = 0;
	}
	d[0] = 0;
	S[0] = 1;
	Pass[0] = 0;
	while(1){
		min=INT_MAX;
		for(i = 0; i < count; i++){
			for(j = 0; j < n; j++){
				if(S[Pass[i]] == 0 || S[j] == 0){
					if(c[Pass[i]][j] != -1 && d[j] >= c[Pass[i]][j] + d[Pass[i]]){
						d[j] = c[Pass[i]][j] + d[Pass[i]];
						if(d[j] <= min){
							next = j;
							min = d[j];
						}
					}
				}
			}
		}
		count++;
		S[next] = 1;
		Pass[i] = next;
		if(count > n) break;
	}

	for(i = 0; i < n; i++){
		printf("%d %d\n",i,d[i]);
	}
	return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'R'){
            r++;
        }
    }
    int cnt = 0;
    for(int i = 0; i < r; i++){
        if(s[i] == 'W'){
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3716
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,m;
int p[100000],y[100000];
vector<int> yd[100001];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d",&p[i],&y[i]);
		yd[p[i]].push_back(y[i]);
	}
	for(int i=0;i<n;i++) sort(yd[i+1].begin(),yd[i+1].end());
	for(int i=0;i<m;i++){
		printf("%012lld\n",ll(p[i])*1000000+int(lower_bound(yd[p[i]].begin(),yd[p[i]].end(),y[i])-yd[p[i]].begin())+1);
	}
}


Measured memory_bytes: 7680
S = input()
T = "keyence"
lens = len(S)
if lens == 7:
    if S == "keyence": print("YES")
    else: print("NO")
else:
    insert = lens - 7
    for i in range(8):
        if S[:i] == T[:i] and S[insert+i:] == T[i:]:
            print("YES")
            break
    else: print("NO")


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")

#include <cstdio>

//using namespace std;

using int64 = long long;

class Combination {
 public:
  constexpr Combination() { Build(); }
  static constexpr int mod_ = 1000000007;
  static constexpr int n_ = 700000;
  class LookupTable {
   public:
    int64 factorial_[n_];
    int64 inverse_[n_];
    int64 finverse_[n_];
  };
  LookupTable lt{};
  // return nCk
  constexpr int64 Get(int n, int k) const noexcept {
    if (n < k || n < 0 || k < 0) return 0;
    return lt.factorial_[n] * (lt.finverse_[k] * lt.finverse_[n - k] % mod_) %
           mod_;
  }

 private:
  constexpr void Build() noexcept {
    lt.factorial_[0] = 1;
    lt.factorial_[1] = 1;
    lt.finverse_[0] = 1;
    lt.finverse_[1] = 1;
    lt.inverse_[1] = 1;
    for (int i = 2; i < n_; ++i) {
      lt.factorial_[i] = lt.factorial_[i - 1] * i % mod_;
      lt.inverse_[i] = mod_ - lt.inverse_[mod_ % i] * (mod_ / i) % mod_;
      lt.finverse_[i] = lt.finverse_[i - 1] * lt.inverse_[i] % mod_;
    }
  }
};

template<typename T> inline void fastin(T &num) {
  T c;
  num = 0;
  c = getchar_unlocked();
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
}

Combination com;

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

  if ((x + y) % 3 != 0) {
    printf("%d", 0);
    return 0;
  }
 
  int nn = (x + y) / 3;
  int r = x - nn;
 
  int64 ans = com.Get(nn, r);
  printf("%lld", ans);

  return 0;
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	int N, K;
	cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++)
    {
        cin >> h[i];
    }
    sort(h.begin(),h.end());
    vector<int> d(N);
    d[0] = 0;
    for (int i = 1; i < N; i++)
    {
        d[i]=d[i-1]+h[i]-h[i-1];
    }
    int res = 1000000001;
    for (int i = 0; i < N-K+1; i++)
    {
        res=min(res, d[i+K-1]-d[i]);
    }

    cout << res << endl;
    
}

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define lp(i, a, b) for (int i=a; i<(b); i++)
#define lpd(i,a,b) for (int i = (b)-1; i >= a; i--)
	
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;

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

    int N;
    cin>>N;
    const int mod = 1e9 + 7;

    int dp[N][4][4][4];
    memset(dp, 0, sizeof(dp));

    lp(j, 0, 4) lp(k, 0, 4) lp(l, 0, 4){
        string s = to_string(j) + to_string(k) + to_string(l);
        if (s=="021" || s=="012" || s=="201") continue;
        dp[2][j][k][l] = 1;
    }

    lp(i, 3, N){
        lp(j, 0, 4)
            lp(k, 0, 4)
                lp(l, 0, 4)
                    lp(m, 0, 4){
                        string s = to_string(l)+to_string(k)+to_string(j);
                        string s1 = to_string(m)+to_string(l)+to_string(j);
                        string s2 = to_string(m)+to_string(k)+to_string(j);

                        if (s=="021" || s=="012" || s=="201") continue;
                        if (s1 == "021" || s2 == "021") continue;
                        dp[i][l][k][j] += dp[i-1][m][l][k];
                        dp[i][l][k][j] %= mod;
                    }
    }

    int sum = 0;
    lp(j, 0, 4)
        lp(k, 0, 4)
            lp(l, 0, 4){
                sum += dp[N-1][j][k][l];
                sum %= mod;
            }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 1e5 + 5;
typedef long long ll;
const ll INF = 1e16; 
using namespace std;

int n, m, a[N], c[N]; 
ll ans = INF, f[N]; 
struct node
{
	ll a0, d;
	node(ll a = 0, ll b = 0) { a0 = a, d = b; }
	node operator + (const node &p) const
		{
			return node(a0 + p.a0, d + p.d); 
		}
};
struct SegTree
{
	struct Tree { node x; } t[N << 2];
	void pushdown(int p, int l, int r)
		{
			if(t[p].x.a0 || t[p].x.d)
			{
				int mid = (l + r) >> 1;
				t[p << 1].x = t[p << 1].x + t[p].x;
				t[p << 1 | 1].x = t[p << 1 | 1].x + node(t[p].x.a0 + (mid + 1 - l) * t[p].x.d, t[p].x.d);
				t[p].x = node(0, 0); 
			}
		}
	void modify(int p, int l, int r, int ql, int qr, node y)
		{
			if(ql > qr) return; 
			if(ql <= l && r <= qr)
			{
				y = node(y.a0 + (l - ql) * y.d, y.d); 
				t[p].x = t[p].x + y; return; 
			}
			pushdown(p, l, r); int mid = (l + r) >> 1; 
			if(ql <= mid) modify(p << 1, l, mid, ql, qr, y); 
			if(mid < qr) modify(p << 1 | 1, mid + 1, r, ql, qr, y); 
		}
	void query(int p, int l, int r)
		{
			if(l == r) return (void) (f[l] = t[p].x.a0); 
			pushdown(p, l, r); int mid = (l + r) >> 1;
			query(p << 1, l, mid), query(p << 1 | 1, mid + 1, r); 
		}
} T; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	n = read <int> (), m = read <int> ();
	for(int i = 1; i <= n; i++) a[i] = read <int> (); 
	for(int l, r, i = 2; i <= n; i++)
	{
		l = a[i - 1], r = a[i];
		if(a[i] >= a[i - 1])
		{
			T.modify(1, 1, m, l + 1, r, node(r - l, -1)); 
			T.modify(1, 1, m, 1, l, node(r - l, 0));
			T.modify(1, 1, m, r + 1, m, node(r - l, 0));
		}
		else
		{
			T.modify(1, 1, m, l + 1, m, node(r + m - l, -1));
			T.modify(1, 1, m, 1, r, node(r, -1));
			T.modify(1, 1, m, r + 1, l, node(r + m - l, 0));
		}
	}
	T.query(1, 1, m);
	for(int i = 1; i <= m; i++) ans = min(ans, f[i]);
	printf("%lld\n", ans); 
	return 0; 
}


Measured memory_bytes: 8360
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();

		Set<Integer>list = new TreeSet<Integer>();

		if (B-A+1<K) {
			K=B-A+1;
		}
		for (int i = A; i < A+K; i++) {
			list.add(i);
		}
		for (int i = B-K + 1; i <= B; i++) {
			list.add(i);
		}
		for (Integer integer : list) {
			System.out.println(integer);
		}

	}


}



Measured memory_bytes: 36016
/*
Author : N_o_o_B
Created : March 14 2020 17:29:31 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    vi a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    --k;
    cout << a[k] << endl;




    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(_,a,b) for(int _=a;_<b;_++)
#define per(_,a,b) for(int _=b-1;_>=a;_--)
typedef long long ll;

const int N=200020;
vector<int> cv[N];
int ans[N],vis[N];
void bfs(){
    queue<int> q;
    q.push(1);
    while(q.size()){
        auto t=q.front();
        q.pop();
        for(int g:cv[t]){
            if(!vis[g]){
                q.push(g);
                vis[g]=1;
                ans[g]=t;
            }
        }
    }
}
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    rep(i,0,m){
        int a,b;
        scanf("%d%d",&a,&b);
        cv[a].push_back(b);
        cv[b].push_back(a);
    }
    bfs();
    rep(i,2,n+1){
        if(!ans[i]){
            printf("No");
            return 0;
        }
    }
    printf("Yes\n");
    rep(i,2,n+1){
        printf("%d\n",ans[i]);
    }
}


Measured memory_bytes: 13384
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli x;
    cin >> x;
    YN(x >= 30);
}

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

typedef long long lint;
typedef long double louble;

#define so(a) ((int)((a).size()))

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

const char lf = '\n';

namespace ae86
{
	const int bufl = 1 << 15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0;int b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 2007;

inline int gcd(int a,int b){return __gcd(a,b);}

vector<int> e[_],via[_];

int n,val[_],ed[_]={0},ind[_]={0};

void dfs(int x)
{
	ed[x]=1;
	for(auto b:e[x])if(!ed[b])via[x].emplace_back(b),ind[b]++,dfs(b);
}

int main()
{
	ios::sync_with_stdio(0),cout.tie(nullptr);

	n=ty();
	for(int i=1;i<=n;i++)val[i]=ty();
	sort(val+1,val+n+1);

	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(gcd(val[i],val[j])!=1)e[i].emplace_back(j),e[j].emplace_back(i);

	for(int i=1;i<=n;i++)sort(e[i].begin(),e[i].end());

	for(int i=1;i<=n;i++)if(!ed[i])dfs(i);

	priority_queue<int> q;
	for(int i=1;i<=n;i++)if(!ind[i])q.emplace(i);

	while(!q.empty())
	{
		int a=q.top();q.pop();
		cout<<val[a]<<' ';
		for(auto b:via[a])q.emplace(b);
	}
	cout<<lf;
	
	return 0;
}


Measured memory_bytes: 17792
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

using namespace std;

long long PRIME = 1000000007;


struct info{
    long long b;
    long long l;
    long long u;
    long long d_max;
};


bool comp(const info& l, const info& r){
    return l.d_max > r.d_max;
}


vector<info> info_vec;
vector<long long> sum_vec;
long long X;
long long N;


long long checkX(long long S){
    long long num = S / X;
    long long rest = S % X;

    if(rest == 0){
        return sum_vec[num];
    }

    long long ret = -1;

    for(int i = 0; i < N; ++i){
        long long val;

        if(i < num){
            val = sum_vec[num + 1];
            val -= info_vec[i].d_max;
        }
        else{
            val = sum_vec[num];
        }

        if(rest < info_vec[i].b){
            val += info_vec[i].l * rest;
        }
        else{
            val += info_vec[i].l * info_vec[i].b + info_vec[i].u * (rest - info_vec[i].b);
        }

        ret = max(ret, val);
    }

    return ret;
}


int main(int argc, char* argv[]){
    cin >> N >> X;

    info_vec.resize(N);
    sum_vec.resize(N + 1);

    long long b;
    long long l;
    long long u;

    long long cost_zero = 0;

    for(int i = 0; i < N; ++i){
        cin >> b >> l >> u;

        info_vec[i].b = b;
        info_vec[i].u = u;
        info_vec[i].l = l;
        info_vec[i].d_max = (X - b) * u + b * l;

        cost_zero -= l * b;
    }

    if(cost_zero == 0){
        cout << 0;
        return 0;
    }
    
    std::sort(info_vec.begin(), info_vec.end(), comp);

    sum_vec[0] = cost_zero;
    for(int i = 1; i <= N; ++i){
        sum_vec[i] = sum_vec[i-1] +info_vec[i-1].d_max;
    }

    long long min_X = 0;
    long long max_X = X * N;
    long long mid_X;
    long long cost;

    while(max_X - min_X > 1){
        mid_X = (min_X + max_X) / 2;

        cost = checkX(mid_X);

        if(cost < 0){
            min_X = mid_X;
        }
        else{
            max_X = mid_X;
        }
    }

    cout << max_X;

}


Measured memory_bytes: 4096
#include<stdio.h>

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

	while (1) {
		C -= B;
		if (C <= 0) {
			printf("Yes");
			break;
		}

		A -= D;
		if (A <= 0) {
			printf("No");
			break;
		}
	}
	return 0;
}

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

int main(){
  int N,X;
  cin >> N >> X;
  vector<int> m(N);
  for(int i=0;i<N;i++){
    cin >> m.at(i);
  }
  sort(m.begin(),m.end());
  int sum = 0;
  for(int i=0;i<N;i++){
    sum+=m.at(i);
  }
  cout << N+(X-sum)/m.at(0);
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Usize1;
use std::cmp::{Reverse, min};
use std::collections::BinaryHeap;

struct Path {
    node: usize,
    cost: usize,
    time: u64,
}

impl Clone for Path {
    fn clone(&self) -> Path {
        Path{node: (&self).node, cost: (&self).cost, time: (&self).time}
    }
}

fn main() {
    input!{
        n: usize,
        m: usize,
        s: usize,
        edges: [(Usize1, Usize1, usize, u64); m],
        ex_infos: [(usize, u64);n],
    }
    
    let mut graph: Vec<Vec<Path>> = vec![vec![]; n];
    let mut all_cost = 0;
    for (u, v, cost, time) in edges {
        graph[u].push(Path{node: v, cost, time});
        graph[v].push(Path{node: u, cost, time});
        all_cost += cost;
    }

    solve(graph, ex_infos, s, all_cost);
}

fn solve(graph: Vec<Vec<Path>>, exchange: Vec<(usize, u64)>, s: usize, max_cost: usize) -> () {
    let max_time = std::u64::MAX;
    let s = min(max_cost, s);
    let n = graph.len();
    let mut dp = vec![vec![max_time; max_cost + 1]; n];
    let mut is_fixed = vec![vec![false; max_cost + 1]; n];

    // heap(所要時間, 所持銀貨, 都市)
    let mut r_heap: BinaryHeap<(Reverse<u64>, usize, usize)> = BinaryHeap::new();
    
    r_heap.push((Reverse(0), s, 0));
    while !r_heap.is_empty() {
        let (Reverse(time), poss, node) = r_heap.pop().unwrap();
        if is_fixed[node][poss] {continue};
        
        // 確定
        dp[node][poss] = time; 
        is_fixed[node][poss] = true;

        // 両替
        let (rate, ex_time) = exchange[node];
        let (exd_poss, exd_time) = (min(poss + rate, max_cost), time + ex_time);
        if !is_fixed[node][exd_poss] {
            r_heap.push((Reverse(exd_time), exd_poss, node));
        }
        
        // 移動
        for next in &graph[node] {
            let next_time = next.time + dp[node][poss];
            if next.cost > poss 
                || is_fixed[next.node][poss - next.cost] {continue;} 
            r_heap.push((Reverse(next_time), poss - next.cost, next.node));

        }
    }

    let ans: Vec<_> = dp.iter().map(|v| v.iter().min().unwrap()).collect();
    for a in &ans[1..] {
        println!("{}", a);
    }
}

Measured memory_bytes: 7032
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for (ll i=0;i<(n);i++)
typedef long long ll;
bool aaa[11111111];
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 
int main() {
  ll n,c,aan,m,w=0,memo=0,sx=0,sy=1,ans=0,gx,gy;
  string ka,ss;
  bool flag=true,flag1=false;
  cin>>ka;
  rep(i,3){
    if(ka[i]=='R')memo++;
    }
    if(ka=="RSR")memo=1;
cout<<memo<<endl;
  vector<int> yoko(n);
  vector<int> tate(c);
  

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    map<string, int> mp;
    while(N--){
        string s;
        cin >> s;
        mp[s]++;
    }
    for(string s : {"AC", "WA", "TLE", "RE"}) cout << s << " x " << mp[s] << endl;
    return 0;
}

Measured memory_bytes: 3640
IDENTIFICATION DIVISION.
       PROGRAM-ID. test1.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 INP PIC X.
       PROCEDURE DIVISION.
       MAIN.
       	ACCEPT INP.
      	IF INP = 'a' THEN
      		DISPLAY "vowel"
      	ELSE IF INP = 'i' THEN
      		DISPLAY "vowel" 
      	ELSE IF INP = 'u' THEN
      		DISPLAY "vowel"
      	ELSE IF INP = 'e' THEN
      		DISPLAY "vowel"
      	ELSE IF INP = 'o' THEN
      		DISPLAY "vowel"
      	ELSE
      		DISPLAY "consonant"
      	END-IF.
        STOP RUN.


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

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))

int lcm(int, int);
map<int,int> GetPrimeFactors(int);
bool IsPrime(int);
int Factorial(int);
int npr (int, int);
int ncr (int, int);

/***** MAIN *****/
void Main() {
  int l;
  cin >> l;
  if(l%3 == 0) {
    long double ans = pow(l/3, 3);
    cout << ans;
  } else {
    long double ans = pow(double(l)/3, 3);
    cout << ans;
  }
  
  cout << "\n";
}
/***** MAIN *****/

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

int lcm(int a, int b) { return a / __gcd(a,b) * b;}

map<int,int> GetPrimeFactors(int n) {
  map<int,int> mp;
  // dived by 2, 3, 5, ...
  for(int i=2; i*i<=n; i+=2) {
    if(i==4) i = 3;
    while(n%i == 0) {
      ++mp[i];
      n /= i;
    }
  }
  if(n!=1) ++mp[n];

  return mp;
}

bool IsPrime(int a) {
  if(a <= 1) return false;
  if(a == 2) return true;
  if(a%2 == 0) return false;
  for(int i = 3; i*i <= a; i+=2) {
    if(a%i==0) return false;
  }
  return true;
}

int Factorial(int n){
  int ans = 1;
  while(n > 1){
    ans *= n;
    --n;
  }
  return ans;
}

int npr(int n, int r) {
  return Factorial(n)/Factorial(n-r);
}

int ncr (int n, int r){
  return npr(n,r)/Factorial(r);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll mod_pow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x, ll mod) {
    return mod_pow(x, mod - 2, mod);
}

ll comb(ll n, ll r, ll mod) {
    ll dividend = 1, divisor = 1;
    for (ll i = 1; i <= r; i++) {
        dividend = dividend * (n + 1 - i) % mod;
        divisor = divisor * mod_inv(i, mod) % mod;
    }
    return dividend * divisor % mod;
}

int main()
{
    ll x, y; cin >> x >> y;
    ll cnt = 0;
    for (int a = 0; a <= x; a++) {
        if ((x - a) % 2) continue;
        int b = (x - a) / 2;
        if (2 * a + b == y) {
            cnt = cnt + comb(a + b, min(a, b), (ll)(1e9+7)) % (ll)(1e9+7);
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
int a,b,sum=0,a1,a2,a4,a5,i;
  cin>>a>>b;
  i=a;
  while(i<=b){
   a1=i%10;
    a2=(i/10)%10;
    a4=(i/1000)%10;
    a5=i/10000;
    if(a1==a5 && a2==a4)sum++;
    i++;
    
 }
cout<<sum<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt(),
			b=sc.nextInt(),
			rad=sc.nextInt();
		double s,l,h,c,a2,b2,min,r=0.0;
		
		a2=Math.pow(a, 2.0);
		b2=Math.pow(b, 2.0);
		r=Math.cos(((double)rad/180.0)*Math.PI);
		min=(2.0*a*b)*r;
		
		c = Math.sqrt(a2+b2-min);
		l = a+b+c;
		
		s=a*b;
		s=s*Math.sin((double)rad/180.0*Math.PI);
		s=s/2;
		
		h=(2*s)/a;
		
		System.out.printf("%f\n%f\n%f\n",s,l,h);
	}

}


Measured memory_bytes: 26340
R=0..18
d=R.map{[0]*19}
gets
p$<.sum{|b|a=(b.to_f*1e10).round
i,j=[2,5].map{|g|R.find{(a/=g)%g>0}||18}
d[..i].sum{_1[..j].sum}+0*d[~i][~j]+=1}

Measured memory_bytes: 14416
n = int(input())

def Check(x):
    cont= 0
    while x > 0:
        x = x//10
        cont += 1
    return cont

a = []
for i in range(1, int(n**0.5)+1):
    if n % i == 0:
        a.append(i)

a = max(a)
b = n//a

print(max(Check(a), Check(b)))

Measured memory_bytes: 3064
io = STDIN
n=io.gets.to_i
a=[]
a<<io.gets.split.map(&:to_i)
a<<io.gets.split.map(&:to_i)
ans=0
if n==1
  ans=a[0][0]+a[1][0]
else
  (1...n).each do |i|
    ans=[a[0][0...i].inject(:+)+a[1][(i-1)...n].inject(:+),ans].max
  end
end
puts ans


Measured memory_bytes: 1788
import java.util.*;
public class Main{
	static int a[],n,i,j,ans[],cnt;
	private static Scanner sc=new Scanner(System.in);
	public static void main(String[] args) {
		while (sc.hasNextInt()){
			int n=sc.nextInt();
			int a[]=new int[n];
			if(n==0)break;
			int max = Integer.MIN_VALUE;
			for( i=0;i<n;i++){
				a[i]=sc.nextInt();
			}
			for(int i=0;i<n;i++){
				int sum = 0;
				for(int j = i; j < n; j++) {
					sum += a[j];
					if(sum > max) max = sum;
				}
			}


			System.out.println(max);
		}

	}
}

Measured memory_bytes: 26464
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
	int N, P;
	string S;
	cin >> N >> P >> S;

	if (P == 2 or P == 5) {
		int ans = 0;
		for (int r = 0; r < N; r++) {
			if ((S[r] - '0') % P == 0) {
				ans += r + 1;
			}
		}
		cout << ans << endl;
		return 0;
	}

	// 各桁の数値のMODをとる
	vector<int> d(N+1);
	int ten = 1;
	for (int i = N - 1; i >= 0; i--) {
		int num = (S[i] - '0') * ten;
		d[i] = num % P;
		ten *= 10;
		ten %= P;
	}

	// 累積和をとる
	for (int i = N - 1; i >= 0; i--) {
		d[i] += d[i+1];
		d[i] %= P;
	}

	int ans = 0;
	map<int, int> mp;
	mp[0] = 1;
	for (int i = N - 1; i >= 0; i--) {
		ans += mp[d[i]];
		mp[d[i]]++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 2564
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = INT_MAX / 2;

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    vector<pair<int, int>> p(M);
    for (int i = 0; i < M; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
        p[i] = make_pair(a, b);
    }

    int ans = 0;
    for (int i = 0; i < M; i++)
    {
        queue<int> pos;
        pos.push(0);
        vector<int> dist(N, INF);
        dist[0] = 0;
        int cnt = 0;
        while (!pos.empty())
        {
            int from = pos.front(); pos.pop();
            cnt++;
            for(int to : G[from]){
                if(dist[to]!=INF || (from==p[i].first&&to==p[i].second) ||  (to==p[i].first&&from==p[i].second) ) continue; 
                pos.push(to);
                dist[to] = dist[from] + 1;
            }
        }
        if(cnt!=N) ans++;
    }
    cout << ans << endl;        
}

Measured memory_bytes: 256
#include <stdio.h>

#define DEF_ELEM_MAX 100001

int S[DEF_ELEM_MAX];
int N;
int ans = 0;

/////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
int binarySearch(int *A, int n, int key)
{
	int mid;
	int left = 0;
	int right = n;

	while (left < right) {
		mid = (left + right) / 2;
		if (A[mid] == key) {
			return mid;
		} else if (key < A[mid]) {
			right = mid;
		} else {
			left = mid + 1;
		}
	}
	return -1;
}
/////////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////
int main(void)
{
	int i;
	int Q;
	int key;

//
	scanf("%d", &N);
	for ( i = 0 ; i < N ; i++ ) {
		scanf("%d", &S[i]);
	}

	scanf("%d", &Q);
	ans = 0;
	for ( i = 0 ; i < Q ; i++ ) {
		scanf("%d", &key);
		if (binarySearch(S, N, key) >= 0) {
			ans++;
		}
	}

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

	return 0;
}

Measured memory_bytes: 988
#include <iostream>

using namespace std;


int main(){

    int antnnasCount = 5;

    int l, i=0, a[antnnasCount + 1], k;
    bool canCommunicate = true;

    for (int i = 0; i < antnnasCount+1 ; i++)
    {
        cin >> l;
        a[i] = l;
    }

    k = a[antnnasCount];


    for(int i=0; i < antnnasCount; i++)
    {
        for (int j = i+1; j < antnnasCount; j++)
        {
            if (a[j] - a[i] > k)
            {
                canCommunicate = false;
                break;
            }
        }
        if (canCommunicate == false)
        {
            break;
        }
        
        
    }

    
    if(canCommunicate)
    {
        cout << "Yay!";
    } 
    else 
    {
        cout << ":(";

    }



    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <sstream>

using namespace std;

int main(){
    int n,a[10000],b[101];
    cin>>n;
    for(int i=0;i<n;++i) cin>>a[i];
    sort(a,a+n);
    n=min(n,10);
    int cnt=0;
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            if(i==j) continue;
            stringstream ss;ss<<a[i]<<a[j];
            string s=ss.str();
            b[cnt++]=atoi(s.c_str());
        }
    }
    sort(b,b+cnt);
    cout<<b[2]<<endl;
    return 0;
}

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

typedef long long lli;

const lli MAXN = 1000005;
const lli INF = 1LL<<60;
lli N, V;
lli A[MAXN], B[MAXN], dp[MAXN], num[MAXN], cost[MAXN], depth[MAXN];

int main() {
  for(; cin >> N;) {
    V = 2 * N - 1;
    for(lli i = 0, leaf = N - 1; i < N - 1; ++i) {
      cin >> A[i] >> B[i];
      --A[i]; --B[i];
      if(A[i] == N-1) A[i] = leaf++;
      if(B[i] == N-1) B[i] = leaf++;
      depth[A[i]] = depth[i] + 1;
      depth[B[i]] = depth[i] + 1;
    }
    for(lli i = V - 1; i >= 0; --i) {
      if(i >= N - 1) {
        num[i] = 1;
        cost[i] = depth[i];
        continue;
      }
      lli &res = dp[i];
      const lli &a = A[i];
      const lli &b = B[i];
      num[i] += num[a] + num[b];
      cost[i] += cost[a] + cost[b];
      res = dp[a] + dp[b] + depth[i] + 2;
      res = min(res, cost[a] - num[a] * depth[i] + dp[b] + 1);
      res = min(res, dp[a] + cost[b] - num[b] * depth[i] + 1);
    }
    cout << dp[0] << endl;
  }
  return 0;
}

Measured memory_bytes: 42112
#include <iostream>
#include <vector>
using namespace std;
int gcd(int x, int y){
    if(x < y) swap(x, y);
    if(x % y == 0) return y;
    return gcd(y, x % y);
}
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    int g = A[0];
    for(int i = 1; i < N; i++){
        g = gcd(g, A[i]);
    }
    cout << g << endl;
}

Measured memory_bytes: 3716
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define REP(i, vec) for(auto i = vec.begin(); i != vec.end(); ++i)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T> inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T> inline T LCM(T a, T b) { return (a + (b - 1)) / b; }

int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	cout << a * b - (a + b - 1) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		    String moji = scanner.next();
		   String[] array = moji.split(""); 
		    int w = scanner.nextInt();
		    
		    for(int i = 0; i * w < moji.length();  i++) 
		    {
		    	System.out.print(array[i * w]);
		    }
        	scanner.close();}
		  }

Measured memory_bytes: 23892
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000009
using namespace std;

int main(void) {
	int n,p;
	cin >> n >> p;
	vector<int> a(n);
	int odd=0,even=0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		if(a[i]%2==1)odd++;
		else even++;
	}
	long long ans=1;
	if(odd==0){
		if(p==0)for(int i=0; i<n; i++)ans*=2;
		else ans=0;
	}else for(int i=0; i<n-1; i++)ans*=2;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import itertools
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
import bisect
import sys
import math
sys.setrecursionlimit(10**9)

def main():
    N,K = map(int,input().split())

    kashi = []
    for i in range(K):
        d = int(input())
        A = list(input().split())
        for a in A:
            if not a in kashi:
                kashi.append(a)


    print(N-len(kashi))


if __name__ == "__main__":
  main()

Measured memory_bytes: 27212
#include <iostream>
#include <stdio.h>
#include <array>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <algorithm>
#include <map>
#include <cmath>
#include <stdlib.h>
#include <string.h>
#include <stack>
#include <bitset>

using namespace std;

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;

int a, b;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
#define MAX(a,b) a>b? a:b
#define MIN(a,b) a>b? b:a


const int MOD = 1e9 + 7;
const ll INF=1e10;
const db PI = acos(-1.0);
const db EPS = 1e-10;


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


/*ll MAXX(vector<ll> a,ll k) {
	ll max = 0;
	REP(i, k) {
		if (a[i] >= max) max = a[i];
	}
	return max;
}*/

/*ll MINN(vector<ll> a,ll k) {
	ll min = INF;
	REP(i, k) {
		if (a[i] <= min)min = a[i];
	}
	return min;
}*/

/*ll SUM(vector<ll> a, ll k) {
	ll sum = 0;
	REP(i, k) {
		sum += a[i];
	}
	return sum;
}*/

/*db AVE(vector<ll> a, ll k) {
	db ave = SUM(a,k)/(db)k;
	return ave;
}*/

/*db VAR(vector<ll> a, ll k) {
	db ave,ave2,var;
	db sum = 0;
	REP(i, k) {
		sum += a[i] * a[i];
	}
	ave2 =sum/ k;
	ave = AVE(a,k);
	ave = pow(ave,2);
	var = ave2 - ave;
	return var;
}*/


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


/*void prime(int k) {
	int cnt = 0;
	for (int i = 2;i<k;i++) {
		if (k % i == 0) { cnt++; }
	}
	if (cnt == 0) cout << k << "は素数です。" << endl;
	else cout << k << "は素数ではありません。" << endl;
}*/



int main() {
	int a, b,wa,sa,seki,max=-10000;
	cin >> a >> b;
	wa = a + b;
	sa = a - b;
	seki = a * b;
	if (max < wa) max = wa; 
	if (max < sa) max = sa; 
	if (max < seki) max = seki;
  	cout<<max<<endl;
	return 0;
}

Measured memory_bytes: 256
class SegmentTree:
    def __init__(self, data, default=0, func=max):
        self._default = default
        self._func = func
        self._len = len(data)
        self._size = _size = 1 << (self._len - 1).bit_length()
        self.data = [default] * (2 * _size)
        self.data[_size:_size + self._len] = data
        for i in reversed(range(_size)):
            self.data[i] = func(self.data[i + i], self.data[i + i + 1])
    def __delitem__(self, idx):
        self[idx] = self._default
    def __getitem__(self, idx):
        return self.data[idx + self._size]
    def __setitem__(self, idx, value):
        idx += self._size
        self.data[idx] = value
        idx >>= 1
        while idx:
            self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
            idx >>= 1
    def __len__(self):
        return self._len
    def query(self, start, stop):
        start += self._size
        stop += self._size
        res_left = res_right = self._default
        while start < stop:
            if start & 1:
                res_left = self._func(res_left, self.data[start])
                start += 1
            if stop & 1:
                stop -= 1
                res_right = self._func(self.data[stop], res_right)
            start >>= 1
            stop >>= 1
        return self._func(res_left, res_right)
    def __repr__(self):
        return "SegmentTree({0})".format(self.data)

import sys
input=sys.stdin.readline
n,k=map(int,input().split())
M=1048576
s=SegmentTree([0]*M)
for i in range(n):
    a=int(input())
    s[a]=1+s.query(max(a-k,0),a+k+1)
print(s.query(0,M))

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

struct Triangle {
    int parent;
    vector<int> children;
};

class Tree {
    vector<vector<int>> edges;
public:
    Tree(int n) : edges(n) {}

    void edge(int i, int j) {
        edges[i].push_back(j);
        edges[j].push_back(i);
    }

    void root(int r, vector<Triangle> &leafs) {
        queue<int> vs;
        vs.push(r);
        vector<bool> check(edges.size(), false);
        check[r] = true;
        while (!vs.empty()) {
            int k = vs.front();
            Triangle triangle;
            triangle.parent = k;

            for (int i : edges[k]) {
                if (check[i]) continue;
                check[i] = true;
                triangle.children.push_back(i);
                vs.push(i);
            }
            vs.pop();
            leafs.push_back(triangle);
        }
//        reverse(leafs.begin(), leafs.end());
    }
};

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

    Tree tree(n);
    vector<P> edges(n - 1);
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        tree.edge(a, b);
        edges[i].first = a;
        edges[i].second = b;
    }


    vector<int> parent_colors(n, -1);
    map<int, map<int, int>> edge_colors;

    vector<Triangle> leafs;
    tree.root(0, leafs);


    for (Triangle &t : leafs) {
        int color = 0;
        for (int child : t.children) {
            if (color == parent_colors[t.parent]) color++;
            parent_colors[child] = color;
            edge_colors[t.parent][child] = color;
            edge_colors[child][t.parent] = color;
            color++;
        }
    }

    int cc = *max_element(parent_colors.begin(), parent_colors.end());
    cc++;
    cout << cc << endl;

    for (P p : edges) {
        cout << edge_colors[p.first][p.second] + 1 << endl;
    }

}


Measured memory_bytes: 32364
#include<stdio.h>

int main() {
  char n[4];
  int c=0;
  for(int i = 0; i < 4; ++i)
    n[i] = getchar();
  for (int i = 0; i < 4; ++i) {
    if (n[i] == '2')
      ++c;
  }
  printf("%d",c);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std ;
 
int main(){
    int N;cin>>N;
    vector<pair<int,int>> A;
    for(int i=0;i<N;i++){
        int a,b;
        cin>>a>>b;
        A.emplace_back(b,a);
    }
    sort(A.begin(),A.end());

 
    int judge=0,sum=0;
    for(int i=0;i<N;i++){
        sum+=A[i].second;
        if(A[i].first>=sum) judge+=1;
    }
    if(judge==N) cout << "Yes" <<endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 5340