akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll a,av,b,bv,t;
  cin >> a >> av >> b >> bv >> t;
  if(av>bv) {
    ll v=av-bv;
    if((abs(a-b)+v-1)/v<=t) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
int main(void) {
  int N, M;
  cin >> N >> M;

  vector <vector<int>> route(N+1);
  for (int i = 0; i < M; i++) {
    int room[2];
    cin >> room[0] >> room[1];
    route[room[0]].push_back(room[1]);
    route[room[1]].push_back(room[0]);
  }

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

  ans[1] = 0;
  depth[1] = 0;

  queue <int> search;
  search.push(1);

  while (search.size() > 0) {
    int room = search.front();
    search.pop();


    for (int i = 0; i < route[room].size(); i++) {
      int next = route[room][i];
      if (ans[next] != -1) continue;

      ans[next] = room;
      depth[next] = depth[room]+1;
      search.push(next);
    }
  }


  bool checker = true;

  // output
  if (checker) {
    cout << "Yes" << endl;
    for (int i = 2; i <= N; i++) {
      cout << ans[i] << endl;
    }
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 10744
#include <iostream>

using namespace std;

int main() {
	int a, b, c, n;
	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> a >> b >> c;
		a *= a; b *= b; c *= c;
		if(a+b==c || b+c==a || c+a==b)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int V,E;
struct edge
{
	int from,to,cost;
	edge(int _from,int _to,int _cost){
		from =_from;
		to =_to;
		cost =_cost;
	}
};
vector<edge> G;

//trueなら負の閉路が存在するd[i]=0と初期化して発見する
int d[120];//最短距離
bool find_negative(){
	memset(d, 0, sizeof(d));
	for(int i =0;i <V;i++){
		for(int j =0;j <E;j++){
			edge e =G[j];
			if(d[e.to] >d[e.from]+e.cost){
				d[e.to] =d[e.from]+e.cost;
			//もしn回目に更新があるなら負の閉路が存在する
				if(i==V-1){
					return true;
				}
			}
		}
	}
	return false;
}

int main(){
	cin>>V>>E;
	for(int i =0;i <E;i++){
		int s,t;
		cin>>s>>t;
		G.push_back(edge(s,t,-1));
	}
	if(find_negative()){
		cout <<1<<endl;
	}else{
		cout <<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ALL(A) (A).begin(),(A).end()
int main(void){
	int N;
	cin >> N;
	vector<ll> A(N);
	for(int i=0;i<N;i++)cin >> A[i];
	sort(ALL(A));
	ll max = A[N-1];
	ll min = A[0];
	ll ans = A[N-1]-A[0];
	for(int i=1;i<N-1;i++){
		ans += abs(A[i]);
	}
	cout << ans << endl;
	for(int i=1;i<N-1;i++){
		if(A[i]<0){
			printf("%lld %lld\n",max,A[i]);
			max -= A[i];
		}else{
			printf("%lld %lld\n",min,A[i]);
			min -= A[i];
		}
	}
	printf("%lld %lld\n",max,min);
}

Measured memory_bytes: 2688
#include<iostream>
#include<deque>
#include<iterator>
#include<list>
#include<queue>
#include<stack>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<math.h>
#include<utility>
#include<functional>
const int MOD = 1e9 + 7;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;

int main() {
    int N;
    cin >> N;
    string S,T;
    vector<string> vec(2 * N);
    cin >> S >> T;
    int k = 0;
    for (int i = 0; i < 2 * N; i+=2) {
        int j = i + 1;
        vec.at(i) = S.at(k);
        vec.at(j) = T.at(k);
        k++;
        if (j == 2 * N -1) {
            break;
        }
    }
    for (int i = 0; i < 2 * N; i++) {
        cout << vec.at(i);
        if (i == 2 * N -1) {
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
/* Atcoder abc120a
 * See tasks at: https://atcoder.jp/contests/abc120/tasks/abc120_a
 */
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
int main()
{
    int32_t a, b, c;
    cin >> a >> b >> c;

    if (b / a > c)
    {
        cout << c;
    }
    else
    {
        cout << b / a;
    }
    
    return 0;
}


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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> f(N+1);
    for (int x=1;x<=100;x++){
        for (int y=1;y<=100;y++){
            for (int z=1;z<=100;z++){
                int p = x*x+y*y+z*z+x*y+y*z+z*x;
                if (p<=N) f[p]++;
            }
        }
    }
    for (int n=1;n<=N;n++){
        cout << f[n] << "\n";
    }
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

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

  string s;
  cin >> s;

  bool ok = true;

  for (int i = 0; i < a+b+1 && ok; ++i) {
    if (i != a) {
      if (s.at(i) == '-') {
        ok = false;
      }
    } else {
      if (s.at(i) != '-') {
        ok = false;
      }
    }
  }

  if (ok) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  cout << endl;
  return 0;
}


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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

string s;
int k;
ll dp[105][5][2];
void solve() {
    cin >> s >> k;

    int n = sz(s);
    dp[0][0][0] = 1;
    rep(i, n) rep(j, k + 1) rep(l, 10) {
        if (l == 0) {
            if (s[i] == '0') {
                dp[i + 1][j][0] += dp[i][j][0];
                dp[i + 1][j][1] += dp[i][j][1];
            }
            else {
                dp[i + 1][j][1] += dp[i][j][0];
                dp[i + 1][j][1] += dp[i][j][1];
            }
        }
        else if (l < s[i] - '0') {
            dp[i + 1][j + 1][1] += dp[i][j][0];
            dp[i + 1][j + 1][1] += dp[i][j][1];
        }
        else if (l == s[i] - '0') {
            dp[i + 1][j + 1][0] += dp[i][j][0];
            dp[i + 1][j + 1][1] += dp[i][j][1];
        }
        else {
            dp[i + 1][j + 1][1] += dp[i][j][1];
        }
    }

    cout << dp[n][k][0] + dp[n][k][1] << endn;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!(s: String, t: String);
    let vs: Vec<char> = s.chars().collect();
    let vt: Vec<char> = t.chars().collect();

    let mut count_min = vt.len();

    for i in 0..(vs.len() - vt.len() + 1) {
        let mut count = 0;
        for j in 0..vt.len() {
            if vs[i + j] != vt[j] {
                count += 1;
            }
        }
        if count < count_min {
            count_min = count;
        }
    }
    println!("{}", count_min);
}


Measured memory_bytes: 2204
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    ll H; cin >> H;
    if (H == 1) {
        cout << 1 << endl;
        return 0;
    }
    ll i = 2;
    while(i <= H) {
        i *= 2;
    }
    cout << (i - 1) << endl;
}


Measured memory_bytes: 256
N = gets.to_i
s = []
N.times{ s << gets.to_i }
s.sort!

sum = s.inject(:+)

if sum % 10 != 0
  
  puts sum
  
else
  
  t = []
  s.each{ |x| t << x if x % 10 != 0 }
  
  if t.size == 0
    puts 0
  else
    puts sum - t[0]
  end
end


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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
using Graph = vector<vector<char>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}


int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<int>> masu(H, vector<int>(W));
  rep(i,H){
    rep(j,W){
      cin >> masu[i][j];
    }
  }
  int c = 0;
  vector<vector<int>> ans(H*W+100);
  for(int i = 0;i<=H-2;i++){
    for(int j = 0;j<W;j++){
      if(masu[i][j]%2){
        
        ans[c].push_back(i+1);
        ans[c].push_back(j+1);
        ans[c].push_back(i+2);
        ans[c].push_back(j+1);
        c++;
        //cout << i+1 << " " << j+1 << " " << i+2 << " " << j+1 << endl;
        masu[i+1][j]++;
      }
    }
  }
  for(int j = 0;j<=W-2;j++){
    if(masu[H-1][j]%2){
      
      ans[c].push_back(H);
      ans[c].push_back(j+1);
      ans[c].push_back(H);
      ans[c].push_back(j+2);
      c++;
      //cout << H << " " << j+1 << " " << H << " " << j+2 << endl;
      masu[H-1][j+1]++;
    }
  }
  cout << c << endl;
  //出力の各行の最後に余計な空白を入れないようにする
  for(int i = 0;i<=c-1;i++){
    for(int j = 0;j<4;j++){
      if(j <= 2){
      cout << ans[i][j] << " ";
      }
      else cout << ans[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 12928
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define All(x) (x).begin(),(x).end()
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
const int maxn=3e3+5,mod=1e9+7;
int n,m,ans;
int f[maxn][maxn][2];
void upd(int &x,int y){
	x=(x+y)%mod;
}
int main(){
	read(n);read(m);
	rep(j,1,n)f[0][j][0]=1;f[0][0][1]=1;
	rep(i,0,m-1)rep(j,0,n)rep(k,0,1){
		if(j){
			upd(f[i+1][j][k||(j==1)],f[i][j][k]);
			upd(f[i+1][j-1][k||(j==1)],f[i][j][k]);
		}
		if(j<n){
			upd(f[i+1][j][k],f[i][j][k]);
			upd(f[i+1][j+1][k],f[i][j][k]);
		}
	}
	rep(j,0,n)upd(ans,f[m][j][1]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 70656
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
p=n1()
q=n1()

import itertools
ite=list(itertools.permutations(range(1,n+1)))
a=ite.index(tuple(p))
b=ite.index(tuple(q))
print(abs(a-b))

Measured memory_bytes: 8052
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long
#define endl "\n"
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(a,b,c) for(int a=b; a<c; a++)
#define frr(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define pii pair<int,int>
#define R(a) ll a; cin >> a;
#define RS(a) string  a; cin >> a;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

#define RA(a, n) ll a[(n) + 1] = {}; fr(i, 1, (n)+1) {cin >> a[i];}
#define RM(a, n, m) int a[n + 1][m + 1] = {}; fr(i, 1, n+1) {fr(j, 1, m+1) cin >> a[i][j];}
#define reset(X) memset(X, 0, sizeof(X))
using vi=vector<int>;
const int inf = 1e18;
const int mod=1e9+7;
unsigned int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isPrime(int n)
{   if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}
const int maxn=2e3+1;
int f[maxn];
int nCr(int n,int r)
{
    int ans=f[n];
    ans=(ans*modInverse(f[r],mod))%mod;
    ans=(ans*modInverse(f[n-r],mod))%mod;
    return ans;
}
signed main()
{
    fastio;
    R(n);
    int ans=power(10,n,mod);
    int sub=power(8,n,mod);
    int sub2=(2*power(9,n,mod)-sub+mod)%mod;
    ans=(ans-sub2+mod)%mod;
    cout<<ans<<endl;

}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double INF = 1e9;
const double EPS = 1e-9;

struct point { 
	double x, y;
	point() : x(0), y(0) {}
	point(double _x, double _y) : x(_x), y(_y) {}
	
	friend ostream& operator<<(ostream& os, point p){
      return os << "<" << p.x << ", " << p.y << ">" << endl;
	}
	friend istream& operator>> (istream& in, point &p){
      in >> p.x;
      in >> p.y;
      return in;
	}
	bool operator == (point other) const {
	   return (fabs(x-other.x) < EPS && (fabs(y-other.y) < EPS));
	}
};

double norm_q(point a) {
	return sqrt((a.x * a.x) + (a.y * a.y));
}

int main() {
	int n;
	double d;
	cin >> n >> d;
	vector<point> p(n);
	int cnt = 0;
   for(auto &x : p){ 
      cin >> x;
      if (norm_q(x) <= d) {
         cnt ++;
      }
   }
   cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 6440
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main()
{
	int N, Q; cin >> N >> Q;
	string s; cin >> s;
	vector<pair<char, char>>pi;
	for (int i = 0; i < Q; i++)
	{
		char t, d; cin >> t >> d;

		pi.push_back(make_pair(t, d));
	}

	int cnt = 0;

	int index;
	int pre;

	index = N-1;
	pre = -1;
	for (int i = Q - 1; i >= 0; i--)
	{
		if (index >= 0 && s[index] == pi[i].first && pi[i].second == 'R')
		{
			pre = s[index];
			index--;
			cnt++;
		}
		if (pre == pi[i].first && pi[i].second == 'L')
		{
			index++;
			cnt--;
			if (index < N-1)pre = s[index + 1];
			else pre = -1;
		}
	}
	cerr<<cnt<<endl;
	index = 0;
	pre = -1;
	for (int i = Q - 1; i >= 0; i--)
	{
		if (index < N && s[index] == pi[i].first && pi[i].second == 'L')
		{
			pre = s[index];
			index++;
			cnt++;
		}
		if (pre == pi[i].first && pi[i].second == 'R')
		{
			index--;
			cnt--;
			if (index)pre = s[index - 1];
			else pre = -1;
		}
	}
	cerr<<cnt<<endl;
	cout<<N-cnt<<endl;

	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int minCostbu(int arr[],int n,int k){
  int dp[n+1] = {0};
  dp[1] = 0;
  for(int i=2;i<=n;i++){
        dp[i] = INT_MAX;
     for(int j=i-1;j>=i-k&&j>=1;j--){
        dp[i] = min(abs(arr[i-1]-arr[j-1])+dp[j],dp[i]);

     }
  }
 /* for(int i=1;i<=n;i++){
    cout<<dp[i]<<" ";
  }
  cout<<endl;*/
  return dp[n];
}
int main(){
 int n,k;
 cin>>n>>k;
 int arr[n+1]={0};
 for(int i=0;i<n;i++){
    cin>>arr[i];
 }
 cout<<minCostbu(arr,n,k);
}


Measured memory_bytes: 1024
#include <stdio.h>

char int2char(int a) {
    char b = '0' + a;
    return b;
}

int cal_dig(int n) {
    int count=0;
    if(n/100) {
        count = 3;
        return count;
    } else {
        if(n/10) {
            count = 2;
            return count;
        } else {
            count = 1;
            return count;
        }
    }
}

int main() {
    char s[102];
    int i, num;
    for(i=0; i<34; i++) {
        s[i] = ' ';
        s[i+34] = ' ';
        s[i+68] = ' ';
    }
    scanf("%s", s);
    // printf("%s", s);

    char ans[6]={};
    int count=1, j=1, k;
    ans[0] = s[0];

    for(i=0; i<102; i++) {
        if(s[i]==' ') {
            i -= 1;
            // printf("%d\n", i);
            // printf("%d\n", count);
            num = i;
            i -= 2;
            for(k=0; k<cal_dig(num-2)-1; k++) {
                count *= 10;
            }
            for(k=0; k<cal_dig(num-2); k++) {
                ans[k+1] = int2char(i/count);
                i -= (i/count)*count;
                count /= 10;
            }
            ans[k+1] = s[num-1];
            break;
        }
    }

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

    return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<map>
using namespace std;
int n;
string s[50];
string get()
{
	string s;cin>>s;
	string t="";t+=s[0];
	for(int i=0;i+1<s.size();i++)if(s[i]=='a'||s[i]=='i'||s[i]=='u'||s[i]=='e'||s[i]=='o')t+=s[i+1];
	return t;
}
main()
{
	while(cin>>n,n)
	{
		int ml=0;
		for(int i=0;i<n;i++)
		{
			s[i]=get();
			ml=ml<s[i].size()?s[i].size():ml;
		}
		int k;
		for(k=1;k<=ml;k++)
		{
			bool f=1;
			map<string,int>M;
			for(int i=0;i<n;i++)f&=!M[s[i].substr(0,k)]++;
			if(f)break;
		}
		cout<<(k<=ml?k:-1)<<endl;
	}
}



Measured memory_bytes: 3216
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int sum = 0;
    rep(i, n) {
        sum += (s[i] - '0');
    }
    if (sum % 9 == 0) cout << "Yes" << endl;
    else              cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define ll long long
#define WEIGHTSUM weight + i
#define VALUESUM maxValue[i] + value
using namespace std;
ll maxValue[100005];
 
int main() {
	ll n, w, weight, value, result = 0;
 
	cin >> n >> w;
	for (int i = 1; i <= n; i++) {
		cin >> weight >> value;
 
		for (int i = w; i >= 1; i--)
			if (maxValue[i] && WEIGHTSUM <= w) {
				maxValue[WEIGHTSUM] = max(maxValue[WEIGHTSUM], VALUESUM);
				result = max(result, VALUESUM);
			}
 
		maxValue[weight] = max(maxValue[weight], value);
		result = max(result, value);
	}
 
    cout << result;
 
	return 0;
}

Measured memory_bytes: 4288
#include <iostream>
using namespace std;
 
int main() {
	int N;
	cin>>N;
	if(N>999){return 0;}
	int p=N%10;
	if(p==3){cout<<"bon"<<endl;}
	else if(p==0||p==1||p==6||p==8){cout<<"pon"<<endl;}
	else{cout<<"hon"<<endl;}
	
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

constexpr ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

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

    auto prime = [](int x){
        unordered_map<int,int> mp;
        int n = x;
        for(int i=2;i*i<=x;i++){
            while(n%i==0){
                mp[i]++;
                n /= i;
            }
        }
        if(n!=1) mp[n]++;
        return mp;
    };

    vec<unordered_map<int,int>> mps;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        mps.push_back(prime(a));
    }

    unordered_map<int,int> pmax;
    for(auto& mp:mps){
        for(auto& x:mp){
            if(!pmax.count(x.first)) pmax[x.first] = x.second;
            else pmax[x.first] = max(pmax[x.first],x.second);
        }
    }

    mint ans = 0;
    for(auto& mp:mps){
        mint now = 1;
        for(auto& p:pmax){
            mint num = p.first;
            if(!mp.count(p.first)) now *= num.pow(p.second);
            else now *= num.pow(p.second-mp[p.first]);
        }
        ans += now;
    }
    cout << ans << endl;
}


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


int main() {
    int a, b;
    cin >> a >> b;
    string ans = "";
    if (a <= b) {
      char a2 = '0' + a;
      ans = std::string(b, a2);
    }
    else {
      char b2 = '0' + b;
      ans = std::string(a, b2);
    }
    cout << ans << endl;
}

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

using namespace std;
vector<int>v;
int a[200005],num[200005];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	int kind=1;
	for(int i=1;i<n;i++){
		if(a[i]!=a[i-1])kind++;
	}
	for(int i=0;i<n;i++)num[a[i]]++;
	for(int i=0;i<200000;i++)if(num[i]!=0)v.push_back(num[i]);
	sort(v.begin(),v.end());
	int o=max(0,kind-k);
	int ans=0;
	for(int i=0;i<o;i++)ans+=v[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2936
fn main() {
    let n = read();
    let neighbors = {
        let mut neighbors = vec![Vec::new();n];
        for _ in 0..n-1 {
            let (u, v, w): (i32,i32,i32) = read_triple();
            let (u, v) = ((u-1)as usize, (v-1)as usize);
            neighbors[u].push((v, w));
            neighbors[v].push((u, w));
        }
        neighbors
    };
    let depth = {
        let mut depth = vec![-1; n];
        let mut stack = vec![0];
        depth[0] = 0;
        while let Some(v) = stack.pop() {
            for &(neighbor, len) in &neighbors[v] {
                if depth[neighbor] != -1 {continue}
                depth[neighbor] = depth[v] + len;
                stack.push(neighbor);
            }
        }
        depth
    };
    for v in 0..n {
        println!("{}", depth[v]&1);
    }
}

fn get_line() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_owned()
}
fn read<T: std::str::FromStr>() -> T{
    get_line().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T>{
    get_line().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_triple<T: std::str::FromStr + Copy>() -> (T,T,T){
    let v:Vec<T> = read_vec(); (v[0], v[1], v[2])
}

Measured memory_bytes: 14716
#include <iostream>

using namespace std;
int main(){
	long long n,a,b;
	cin >> n >> a >> b;
	if(!((b - a)&1)){
		cout << (b - a)/2 << endl;
	}else{
		cout << (b - a + 1)/2 + min(a - 1,n - b) << endl;
	}
}

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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	int l, r, d;
	cin >> l >> r >> d;

	int ans = 0;
	for(int i = l;i <= r;i++){
		if(i % d == 0) ans++;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
 
int main() {
    long long int a, b, c, d, e, f, g, h;
    cin >> a >> b >> c >> d;
    e = a * c;
    f = a * d;
    g = b * c;
    h = b * d;
    if (e < f) {
        if (g < h)
        {
            if (f < h) cout << h;
            else cout << f;
        }
        else
        {
            if (f < g) cout << g;
            else cout << f;
        }   
    }
    else
    {
        if (g < h)
        {
            if (e < h) cout << h;
            else cout << e;
        }
        else
        {
            if (e < g) cout << g;
            else cout << e;
        }
    }
    
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define POL_MAX 200
#define N_MAX 1000000
using namespace std;

int N;
int dp[N_MAX+1];
int odd_dp[N_MAX+1];
const int INF = INT_MAX / 3;

int main(){

	int n=1;
	int value=0;
	vector<int> pol, kisu_pol;
	while(true) {
		value = n*(n+1)*(n+2) / 6;
		if (value >= N_MAX) { break; }
		pol.push_back(value);
		if (value % 2 != 0) { kisu_pol.push_back(value); }
		n++;
	}

	rep(j, N_MAX+1) { dp[j] = j; }
	REP(j, 1, N_MAX+1) {
		REP(i, 1, pol.size()) {
			if(j<pol[i]) break;
			dp[j] = min(dp[j], dp[j-pol[i]] + 1);
		}
	}
	
	rep(j, N_MAX+1) { odd_dp[j] = j; }
	REP(j, 1, N_MAX+1) {
		REP(i, 1, kisu_pol.size()) {
			if(j<kisu_pol[i]) break;
			odd_dp[j] = min(odd_dp[j], odd_dp[j-kisu_pol[i]] + 1);
		}
	}
	
	while(cin >> N) {
		if (N == 0) { break; }
		cout << dp[N] << " " << odd_dp[N] << endl;
	}

	return 0;
}

Measured memory_bytes: 9032
import java.util.*;
import java.awt.Point;
import static java.lang.Math.*;

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

		while(true){
			int w = sc.nextInt(), h = sc.nextInt();
			if(w==0 && h==0) break;

			int[][] map = new int[h][w];
			int[] cost = new int[4];

			for(int i=0;i<h;i++){
				for(int j=0;j<w;j++){
					map[i][j] = sc.nextInt();
				}
			}
			for(int i=0;i<4;i++){
				cost[i] = sc.nextInt();
			}

			State st = null;
			Queue<State> open = new PriorityQueue<State>();
			Map<State, State> closed = new HashMap<State, State>();

			open.add(new State(0,new Robot(1,0,0)));

			int ans = Integer.MAX_VALUE;
			while(!open.isEmpty()){
				st = open.poll();
				if(closed.get(st) != null) continue;
				closed.put(st, st);
				if(st.ans(w,h)){
					ans = st.cost;
					break;
				}
				open.addAll(st.nexts(map,cost));
			}
			System.out.println(ans);
		}
	}
}

class State implements Comparable< State >{
	int cost;
	Robot robot;

	public State(int cost, Robot robot){
		this.cost = cost;
		this.robot = robot;
	}

	public List<State> nexts(int[][] map, int cost[]){
		List<State> next = new ArrayList<State>();
		int turn = map[this.robot.p.y][this.robot.p.x];

		for(int i=0;i<4;i++){
			Robot r = this.robot.copy();
			if(r.move(i,map)){
				int c = this.cost;
				if(turn != i){
					c += cost[i];
				}
				next.add(new State(c, r));
			}
		}

		return next;
	}

	public boolean ans(int w, int h){
		if(robot.p.x == w-1 && robot.p.y == h-1)
			return true;
		else
			return false;
	}

	public int compareTo(State st){
		return this.cost - st.cost;
	}

	public boolean equals(Object anObject){
		State st = (State)anObject;
		return this.robot.p.equals(st.robot.p) && this.robot.d==st.robot.d;
	}

	public int hashCode(){
		return robot.p.x + robot.p.y;
	}
}

class Robot{
	int d;
	Point p;

	public Robot(int d, int x, int y){
		this.d = d;
		this.p = new Point(x,y);
	}

	public boolean move(int turn, int[][] map){
		int w = map[0].length;
		int h = map.length;

		d = (d+turn) % 4;

		switch(d){
		case 0: p.y--; break;
		case 1: p.x++; break;
		case 2: p.y++; break;
		case 3: p.x--; break;
		}

		if(p.x < 0) return false;
		if(p.x >= w) return false;
		if(p.y < 0) return false;
		if(p.y >= h) return false;

		return true;
	}

	public Robot copy(){
		Robot copy = new Robot(d, p.x, p.y);
		return copy;
	}
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
void read() {}
template<class T, class... Arg>
void read(T &x, Arg&&... args) {
	cin >> x;
	read(args...);
}
void print_err() {
	cerr << "\n";
}
template <class T, class... Arg>
void print_err(T x, Arg&&... args) {
	cerr << x << " ";
	print_err(args...);
}
template<class T>
void print_container(T &cont) {
	for (auto iter : cont) {
		cerr << iter << " ";
	}
	cerr << "\n";
}
#ifdef local
#define debug(...) print_err(__VA_ARGS__)
#define debug_c(container) print_container(container)
#else
#define debug(...)
#define debug_c(container)
#endif
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mod 1000000007
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define vl vector<ll>
#define vpll vector<pair<ll,ll>>
#define mll map<ll,ll>
#define mllrev map<ll,ll,greater<int>>
#define ps(x,y) fixed<<setprecision(y)<<x//it will give upto y decimal places
#define w(t) ll t;cin>>t;while(t--)
#define fo(i,n) for(ll i=0;i<n;++i)
#define foab(i,a,b) for(ll i=a;i<b;++i)
#define inp cin>>
#define pr cout<<
#define pqb priority_queue<ll>//max heap
#define pqs priority_queue<ll,vl,greater<int>>//min heap
#define mk(arr,n,type) type *arr=new type[n];
#define all(A) (A).begin(),(A).end()
#define fastio ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define mem(a,val) memset(a,val,sizeof(a))
template<class T>
void debug_arr(T arr, ll st, ll en) {
	foab(i, st, en) {
		cerr << arr[i] << " ";
	}
	cerr << endl;
}
template<class T>
void read_arr(T arr, ll n) {
	fo(i, n) {
		cin >> arr[i];
	}
}
template<class T>
void read_c(T &arr, ll n) {
	fo(i, n) {
		cin >> arr[i];
	}
}
void CP() {
	fastio
#ifdef local
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
	return;
}
char* stringTOCharArray(string str) {
	ll n = str.length();
	mk(ch, n + 1, char);
	strcpy(ch, str.c_str());
	return ch;
}
class Graph {
public:
	list<ll> *adj_list;
	ll v;
	Graph(ll v) {
		this->v = v;
		adj_list = new list<ll>[v];
	}
	void add_edge(ll u, ll v, bool bidirectional = true) {
		adj_list[u].push_back(v);
		if (bidirectional) {
			adj_list[v].push_back(u);
		}
	}
	void print();
	void connected_compo();
	void dfs(vector<vector<ll>> vect, ll k1, ll k2, ll n);
	void bfs(ll v, bool visited[]);
};
const int d4i[4] = { -1, 0, 1, 0}, d4j[4] = {0, 1, 0, -1};
const int d8i[8] = { -1, -1, 0, 1, 1, 1, 0, -1}, d8j[8] = {0, 1, 1, 1, 0, -1, -1, -1};
void solve() {
	string str;
	read(str);
	ll ans = 0;
	fo(i, str.length()) {
		ans += (str[i] - '0');
	}
	ans % 9 == 0 ? cout << "Yes\n" : cout << "No\n";
	return ;
}
int main() {
	CP();
	// w(t) {
	solve();
	// }
	return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <sstream>
// #include <cmath>
// #include <map>
// #include <set>
// #include <deque>
// #include <stack>
// #include <vector>
using namespace std;
#define debug freopen("in.txt","r",stdin),freopen("out.txt","w",stdout);
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
// #define PI acos(-1)
typedef long long ll;
const ll mod=1e9+7;

int d[200000];
int main()
{
	//debug;
	ios;
	ll n;
	cin>>n;
    d[0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=i-3;j++)
        {
            d[i]+=d[j];
            d[i]%=mod;
        }
    }
    cout<<d[n];
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    reverse(bit.begin(), bit.end());
    return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> u(N-1), v(N-1);
    REP(i, N-1){
        cin >> u[i] >> v[i];
    }

    ll res = 0;
    REP(i, N){
        res += (i+1) * (N-i);
    }

    REP(i, N-1){
        if(u[i]>v[i]) swap(u[i], v[i]);
        res -= u[i] * (N-v[i]+1);
    }
    cout << res << endl;

    return 0;
}

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

using namespace std;
#define int long long
typedef long long ll;

std::vector<std::string> split(const std::string &str, char sep)
{
    std::vector<std::string> v;
    std::stringstream ss(str);
    std::string buffer;
    while( std::getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

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

    auto mx = min(a, b) - (n - max(a, b));

    cout << min(a, b) << " " << (mx >= 0 ? mx : 0);
}



Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

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

  int D;
  cin>>D;
  
  int C[27];
  int S[366][27];
  int last[366][27];

  for(int d=1;d<=26;d++) cin>>C[d];
  for(int d=1;d<=D;d++){
    for(int i=1;i<=26;i++) cin>>S[d][i];
  }

  for(int d=1;d<=D;d++){
    int mi=1;
    int max=-1e9;
    for(int i=1;i<=26;i++){
      int tmp=S[d][i];
      for(int j=1;j<=26;j++){
        if(j!=i) tmp-=C[j]*(d-last[d-1][j]);
      }
      if(max<tmp){
        max=tmp;
        mi=i;
      }
    }
    for(int i=1;i<=26;i++) last[d][i]=last[d-1][i];
    last[d][mi]=d;
    cout<<mi<<endl;
  }

  return 0;
}

Measured memory_bytes: 3720
#include <stdio.h>
#include <math.h>

const double PI = 3.14159265359;

int main() {
  int a, b, C;
  scanf("%d%d%d", &a, &b, &C);

  double rad = PI * C / 180;
  double S = a * b * sin(rad) / 2;
  double d = sqrt(a*a + b*b - 2*a*b*cos(rad));
  double L = a + b + d;
  double h = b * sin(rad);

  printf("%.6lf\n", S);
  printf("%.6lf\n", L);
  printf("%.6lf\n", h);
  
  return 0;
}


Measured memory_bytes: 2096
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int T1, T2, R1, R2;

  cin >> T1 >> T2 >> R1 >> R2;

  if (R1 == -1 || R2 == -1) {
    R1 = -T1; R2 = -T2;
  }

  puts( R1 > R2 ? "Alice" : R1 < R2 ? "Bob" : "Draw");

  return 0;
}



Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

// ??????g ????????????????????\?????????
void insertionSort(int A[], int n, int g) {
  for ( int i = g; i < n; i++ ) {
    int v = A[i];
    int j = i - g;
    while ( j >= 0 && A[j] > v ) {
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }
    A[j + g] = v;
  }
}

void shellSort(int A[], int n) {
  // ??°???G = {1, 4, 13, 40, 121, 364, 1093, ...} ?????????
  for ( int h = 1; ;  ) {
    if ( h > n ) break;
    G.push_back(h);
    h = 3*h + 1;
  }

  for ( int i = G.size()-1; i >= 0; i-- ) { // ?????????G[i] = g ?????????
    insertionSort(A, n, G[i]);
  }
}

int main() {
  cin >> n;
  // ??????????????\???scanf ??¢??°????????¨
  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);
  cnt = 0;

  shellSort(A, n);

  cout << G.size() << endl;
  for ( int i = G.size() - 1; i >= 0; i-- ) {
    printf("%d", G[i]);
    if ( i ) printf(" ");
  }
  printf("\n");
  printf("%d\n", cnt);
  for ( int i = 0; i < n; i++ ) printf("%d\n", A[i]);

  return 0;
}

Measured memory_bytes: 5196
h, w = map(int, input().split())
A = [list(map(int, input().split())) for i in range(h)]
B = [list(map(int, input().split())) for i in range(h)]

C = [[0]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        C[i][j] = abs(A[i][j]-B[i][j])

import numpy as np
dp = [[0]*(w+1) for _ in range(h+1)]
import numpy as np
d = 80*(h+w-1)+1
D = 2*d+1
dp[0][0] = np.zeros(D, np.bool)
dp[0][0][C[0][0]+d] = 1
#dp[0][0][-C[0][0]+d] = 1
for i in range(h):
    for j in range(w):
        c = C[i][j]
        if i == 0 and j == 0:
            continue
        elif i == 0:
            b = np.zeros(D, np.bool)
            b[c:] |= dp[i][j-1][:D-c]
            b[:D-c] |= dp[i][j-1][c:]
        elif j == 0:
            b = np.zeros(D, np.bool)
            b[c:] |= dp[i-1][j][:D-c]
            b[:D-c] |= dp[i-1][j][c:]
        else:
            b = np.zeros(D, np.bool)
            b[c:] |= dp[i][j-1][:D-c]
            b[:D-c] |= dp[i][j-1][c:]
            b[c:] |= dp[i-1][j][:D-c]
            b[:D-c] |= dp[i-1][j][c:]
        dp[i][j] = b
#print(dp[h-1][w-1])
ans = float('inf')
for i in range(D):
    if dp[h-1][w-1][i]:
        #print(abs(i-d))
        ans = min(ans, abs(i-d))
print(ans)


Measured memory_bytes: 172564
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

vector<int> bfs(int node, vector<string> &a) {
    int n = a.size();
    vector<int> d(n, n + 1);
    vector<int> color(n, -1);
    d[node] = 0;
    color[node] = 0;

    queue<int> q;
    q.push(node);

    while(!q.empty()) {
        int node = q.front();
        q.pop();
        rep(i, n) {
            if (a[node][i] == '1') {
                if (d[i] >= n) {
                    d[i] = d[node] + 1;
                    color[i] = 1 - color[node];
                    q.push(i);
                }
                if (color[i] != 1 - color[node]) {
                    return vector<int> ();
                }
            }
        }
    }
    return d;
}

int main() {
    int n;
    cin >> n;
    vector<string> mat(n);
    rep(i, n) {
        cin >> mat[i];
    }
    int ans = -1;
    rep(i, n) {
        auto d = bfs(i, mat);
        if (d.empty()) {
            cout << -1 << endl;
            return 0;
        }
        ans = max(ans, *max_element(d.begin(), d.end()));
    }
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 3692
//Reference https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
use std::cmp::{min, max};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        S:chars,
    }
    let mut ans = "Good";
    for i in 1..4{
        if(S[i - 1] == S[i]){
            ans = "Bad";
        }
    }
    println!("{}", ans);
}

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

int main() {
  int S;
  int A,B,C,D;
  cin >> S;
  D=S%10,S/=10;
  C=S%10,S/=10;
  B=S%10,S/=10;
  A=S%10;
  
  if(A-B-C-D==7){
    cout << A << "-" << B << "-" << C << "-" << D << "=7" << endl;
  }
  else if(A-B-C+D==7){
    cout << A << "-" << B << "-" << C << "+" << D << "=7" << endl;
  }
  else if(A-B+C-D==7){
    cout << A << "-" << B << "+" << C << "-" << D << "=7" << endl;
  }
  else if(A-B+C+D==7){
    cout << A << "-" << B << "+" << C << "+" << D << "=7" << endl;
  }
  else if(A+B-C-D==7){
    cout << A << "+" << B << "-" << C << "-" << D << "=7" << endl;
  }
  else if(A+B-C+D==7){
    cout << A << "+" << B << "-" << C << "+" << D << "=7" << endl;
  }
  else if(A+B+C-D==7){
    cout << A << "+" << B << "+" << C << "-" << D << "=7" << endl;
  }
  else if(A+B+C+D==7){
    cout << A << "+" << B << "+" << C << "+" << D << "=7" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
    int to;
    T cost;
    Edge() {};
    Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
    int n;
    bool directed;
    vector<vector<Edge<T>>> edges;
public:

    Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)){};
    Graph() {};

    void add(int from,int to, T cost) {
        edges[from].emplace_back(to, cost);
        if(!directed){
            edges[to].emplace_back(from,cost);
        }
    }

    int size() {
        return n;
    }
};


int main() {

    int N;

    cin >> N;

    vector<vi> C(10,vi(10));

    REP(i,10)REP(j,10){
        C[i][j] = 0;
    }

    FOR(i,1,N+1){
        int num = i;
        int b,e = num%10;
        while(num >= 10){
            num /= 10;
        }
        b = num;
        C[b][e]++;
    }

    int ans = 0;

    REP(i,10)REP(j,10){
        ans += C[i][j]*C[j][i];
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256