akhauriyash/Code-Regression huggingface dataset:
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int m;
  cin >> m;
  cout << (24+24-m) << endl;


return 0;
}
///....


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var s = input.ReadLine();

        if (s[0] != 'A') return "WA";

        int c = -1;
        int cc = 0;
        for(int i=2; i<s.Length-1; i++) {
            if(s[i] == 'C') {
                cc++;
                c = i;
            }
        }
        if (cc != 1) return "WA";

        for(int i=0; i<s.Length; i++) {
            var x = s[i];
            if (i == 0 || i == c) continue;
            if (!('a' <= x && x <= 'z')) {
                return "WA";
            }
        }

        return "AC";
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11092
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define BP(x) __builtin_popcountll(x)
#define PQS priority_queue <int, vector<int>, greater<int> > 
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r) {
  uniform_int_distribution<int> uid(l, r);
  return uid(rng);
}

const int INF = 1e18 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
  int r, g, b; cin >> r >> g >> b;
  int k; cin >> k;
  while(g <= r) {
    g*=2; k--;
  }
  while(b <= g) {
    b*=2; k--;
  }
  if(k >= 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

signed main() {   
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

  #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
  #endif
   int t = 1;  //cin >> t;
   for(int i = 1; i <= t; i++) {
   //  cout << "Case #" << i << ": ";
     solve();
  }
}    

/*

*/

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;


#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

struct SegTree { //せぐつりー！
	ll sz;
	vector<ll> dat;
	SegTree(ll n) {
		sz = 1;
		while (sz < n)sz *= 2;
		dat.resize(2 * sz - 1);//
	}
	void update(ll a, ll x) {
		a += sz - 1;//
		dat[a] = x;
		while (a > 0) {
			a = (a - 1) / 2;
			dat[a] = max(dat[a * 2 + 1], dat[a * 2 + 2]);//
		}
	}
	ll query(ll a, ll b, ll k = 0, ll l = 0, ll r = -1) {
		if (r < 0) r = sz;
		if (r <= a or b <= l)return 0;//
		if (a <= l and r <= b)return dat[k];//
		ll q1, q2;
		q1 = query(a, b, k * 2 + 1, l, (l + r) / 2);
		q2 = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return max(q1, q2);//
	}
};

ll n;
SegTree seg(810000);
vector<P> s;
ll debug = 0;
int main() {
	cin >> n;
	REP(i, n) {
		ll a;
		cin >> a;
		s.push_back(P(a, i));
	}
	sort(ALL(s));
	s.push_back(P((ll)1e10, (ll)1e10));
	queue<P> q;
	REP(i, n) {
		ll pos = s[i].second;
		ll dp = seg.query(0, pos) + 1;
		q.push(P(pos, dp));
		if (s[i].first != s[i + 1].first) {
			while (!q.empty()) {
				seg.update(q.front().first, q.front().second);
				q.pop();
			}
		}
	}
	cout << seg.query(0, 101000) << endl;
}
 


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

int main(){
  int N, K;
  cin >> N >> K;
  std::vector<int> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
  }
  int ans=0;
  for (int i = 0; i < N; i++) {
    if(x.at(i)<=(K/2)) ans+= 2*x.at(i);
    else ans+= 2*(K-x.at(i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int n, a, b, mod = 1e9 + 7;
vector< long long > dpw( 1e5 + 5, 1 ), dpb( 1e5 + 5, 1 );
vector< vector< int > > adj( 1e5 + 5 );

void dfs( int v, int par )
{
	for( int u : adj[ v ] )
	{
		if( u != par )
		{
			dfs( u, v );
			dpb[ v ] *= dpw[ u ];
			dpb[ v ] %= mod;
			dpw[ v ] *= ( dpw[ u ] + dpb[ u ] );
			dpw[ v ] %= mod;
		}
	}
}

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> n;
	for( int i = 1; i <= n - 1; ++i )
	{
		cin >> a >> b;
		adj[ a ].emplace_back( b );
		adj[ b ].emplace_back( a );
	}
	dfs( 1, 0 );
	cout << ( dpw[ 1 ] + dpb[ 1 ] ) % mod << "\n";
	return 0;
}

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

#define IOS cin.tie(0);ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vs      vector<string>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 200;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

signed main(){
    CIN(W,H,x,y);
    double ans=(double)W*H/2;
    printf("%.5f %d\n",ans,x*2==W&&y*2==H?1:0);

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
  int q,a,b,i,j,k,n=0,m,cent,basyo;
  char str[1001],mei[10],p[1001];
  scanf("%s",str);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%s %d %d",mei,&a,&b);
    if(strcmp(mei,"replace")==0){
      scanf("%s",p);
      for(j=a;j<=b;j++){
	str[j]=p[n];
	++n;
      }
    }
    n=0;
    if(strcmp(mei,"reverse")==0){
      cent=(b-a)/2;
      for(basyo=0;basyo<=cent;basyo++){
	m=str[a+basyo];
	str[a+basyo]=str[b-basyo];
	str[b-basyo]=m;
      }
    }
    if(strcmp(mei,"print")==0){
      for(j=a;j<=b;j++){
	printf("%c",str[j]);
	if(j==b)printf("\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

double dist(double x1, double y1, double x2, double y2) {  // (x1, y1) と (x2, y2) のユークリッド距離
    return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}

ll fact(ll n) {  // n!のmodでの剰余
    ll x = 1;   
    for(ll i = 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x;
}

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

    vector<double> x(n), y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
    }

    vl perm(n);
    rep(i, n) {
        perm[i] = i;
    }

    double ans = 0;
    do {
        rep(i, n-1) {
            ans += dist(x[perm[i]], y[perm[i]], x[perm[i+1]], y[perm[i+1]]);
        }
    } while(next_permutation(all(perm)));
    
    ans /= fact(n);
    
    exout(ans);
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define INF 1010101010
#define MOD 1000000007

int H, W;

int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());

    vector<string> words {"maerd", "remaerd", "esare", "resare"};

    while(!s.empty()) {
        bool ok = false;
        for (auto &w: words)
            if (s.substr(0, w.size()) == w) {
                s = s.substr(w.size());
                ok = true;
            }
        if (!ok) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <math.h>
#include <set>

using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
ll MOD = 1000000007;
int main() {
	ll A, B, C; cin >> A >> B >> C;
	bool X[100] = {};

	rep(i, 1, 10000) {
		ll a = A * i;
		ll r = a % B;

		if (X[r]) {
			cout << "NO" << endl;
			return 0;
			break;
		}
		if (r == C) {
			cout << "YES" << endl;
			return 0;
		}
		X[r] = true;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 255; 
int n,mod,ans,l[N*2],r[N*2],f[N][N][N];

inline int Mod(int x){
	return x>=mod?x-mod:x;
}

int main(){
	n=read(),mod=read();
	For(i,1,2*n){
		int x=max(0,n*n-(i-1)*(i-1)),y=4*n*n-(i-1)*(i-1);
		l[i]=ceil(sqrt(x)),r[i]=min(int(sqrt(y)),2*n-1);
	}
	For(i,0,n) f[n+1][0][i]=1;
	int las=2*n+1;
	Dow(i,n+1,2){
		For(j,0,n-i+1){
			int x=1,p=las;
			while (r[p-1]<l[i-1]) --p,x=1ll*x*(r[p]+1-(2*n-p+j))%mod;
			f[i-1][j][j]=(f[i-1][j][j]+1ll*f[i][j][j]*x%mod*(r[i-1]+1-(n+j+(n-i+1-j))))%mod;
			For(k,j+1,n){
				f[i-1][j+1][k]=(f[i-1][j+1][k]+1ll*f[i][j][k]*(l[i-1]-1-(j+2*n-p))%mod*x)%mod;
				f[i-1][j][k]=(f[i-1][j][k]+1ll*f[i][j][k]*(r[i-1]+1-(n+k+(n-i+1-j)))%mod*x)%mod;
			}
		}
		while (r[las-1]<l[i-1]) --las;
	}
	For(i,0,n){
		int x=1;
		FOR(j,n+1,las) x=1ll*x*(r[j]+1-(i+(2*n-j)))%mod;
		if (i&1) ans=(ans+1ll*(mod-f[1][i][i])*x)%mod;
			else ans=(ans+1ll*f[1][i][i]*x)%mod;
	}
	printf("%d\n",(ans+mod)%mod);
}

Measured memory_bytes: 35948
#include <iostream>
#include <algorithm>
#include <cstring>
#include <functional>
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> h;
int main()
{
    std::ios::sync_with_stdio(false);
    int x;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>x;
        h.push_back(x);
    }
    int d[n];
    d[n-1]=0;
    d[n-2]=abs(h[n-1]-h[n-2]);
    for(int i=n-3;i>=0;i--)
    {
        d[i]=min(abs(h[i]-h[i+2])+d[i+2],abs(h[i]-h[i+1])+d[i+1]);
    }
    cout<<d[0];
    return 0;
}


Measured memory_bytes: 1144
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

template <class... Args>
struct tuple_input_impl;
template <std::size_t i, std::size_t... tail>
struct tuple_input_impl<std::index_sequence<i, tail...>>
{
    template <class... Args>
    static void f(std::tuple<Args...>& x)
    {
        std::cin >> std::get<i>(x);
        tuple_input_impl<std::index_sequence<tail...>>::f(x);
    }
};
template <>
struct tuple_input_impl<std::index_sequence<>>
{
    static void f(...) {}
};

template <class... Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& x)
{
    tuple_input_impl<std::index_sequence_for<Args...>>::f(x);
    return in;
}
template <class T1, class T2>
std::istream& operator>>(std::istream& in, std::pair<T1, T2>& x) { return in >> x.first >> x.second; }

template <class T>
T read()
{
    T res;
    std::cin >> res;
    return res;
}
template <class T>
std::vector<T> read(std::size_t n)
{
    std::vector<T> res(n);
    for (std::size_t i = 0; i < n; ++i) std::cin >> res[i];
    return res;
}

template <class T>
void out_impl(T&& v) { std::cout << std::forward<T>(v); }
template <class T, class... Args>
void out_impl(T&& v, Args&&... args)
{
    std::cout << std::forward<T>(v) << ' ';
    out_impl(std::forward<Args>(args)...);
}
template <class... Args>
void out(Args&&... args)
{
    out_impl(std::forward<Args>(args)...);
    std::cout << '\n';
}
template <class... Args>
void out_noreturn(Args&&... args) { out_impl(std::forward<Args>(args)...); }

template <class T>
void print(const T& container)
{
    bool first = true;
    for (auto&& x : container) {
        if (!first) std::cout << ' ';
        std::cout << x;
        first = false;
    }
    std::cout << '\n';
}

void prog()
{
    std::uint64_t m, k;
    std::cin >> m >> k;
    if (k == 0) {
        for (auto i : boost::irange(0ul, (1ul << m))) {
            out_noreturn(i, "");
            out_noreturn(i, "");
        }
        return;
    }
    if (m < 2 || k >= (1ul << m)) {
        out(-1);
        return;
    }
    for (auto i : boost::irange(0ul, 1ul << m)) {
        if (i == k) continue;
        out_noreturn(i, "");
    }
    out_noreturn(0, "");
    out_noreturn(k, "");
    for (auto i : boost::irange(1ul, 1ul << m) | boost::adaptors::reversed) {
        if (i == k) continue;
        out_noreturn(i, "");
    }
    out_noreturn(k, "");
}

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


Measured memory_bytes: 1792
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys
from fractions import gcd

input = sys.stdin.readline

def main():
    A, B = map(int, input().split())
    max_n = max(A, B)
    min_n = min(A, B)
    if (max_n - min_n) % 2 == 1:
        print("IMPOSSIBLE")
        return
    else:
        print(int(min_n + (max_n - min_n) / 2))

main()


Measured memory_bytes: 66156
#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w,n;
    int a;
    int x=0,y=0,cnt=0;
    int cl[100][100];
    cin>>h>>w>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        while(cnt<a){
            cl[x][y]=i+1;
            x+=y%2==0?1:-1;
            if(x>=w||x<0){
                y++;x=y%2==0?0:w-1;
            }
            cnt++;
        }
        cnt=0;
    }
    for(int j=0;j<h;j++)
        for(int i=0;i<w;i++)
            cout<<cl[i][j]<<(i==w-1?"\n":" ");
    return 0;
}

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

using namespace std;

int main()
{
    int a,b,c;
    cin >>a;
    cin >> b;
    cin >> c;
    if(b-a == c-b)
    {
        cout <<"YES" <<endl;
    }
    else
    {
        cout << "NO" <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N;cin>>N;
    int S,d,a;a=N;
    S=0;
    while(a>0){
        d=a%10;
        S=d+S;
        a=a/10;
    }


    if(N%S==0) {
        cout << "Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}



Measured memory_bytes: 256
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    string s; cin >> s;
    rep(i, s.size())
    {
        if (s[i] != s[s.size()-1-i]) goto end;
    }
    rep(i, (s.size()-1)/2)
    {
        if (s[i] != s[(s.size()-1)/2-1-i]) goto end;
    }
    rep(i, (s.size()-1)/2)
    {
        if (s[i+(s.size()+3)/2-1] != s[s.size()-1-i]) goto end;
    }
    cout << "Yes" << endl;
    return;
    end:;
    cout << "No" << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<long long, long long>;
const int INF = numeric_limits<int>::max();
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

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

    ll ans = 0;
    rep(i,n-1) {
        sum -= a[i];
        ans += ((sum % MOD) * a[i])% MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4844
#include <stdio.h>
int main(){
  int h,w;
  char a[101];
  scanf("%d%d",&h,&w);
  for(int i=0;i<h;i++){
    scanf("%s",a);
    printf("%s\n",a);
    printf("%s\n",a);
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	string S;
	cin >> S;
	int ans = 1 << 30;
	for (int i = 0; i + 3 <= S.length(); ++i) {
		int Y = stoi(S.substr(i, 3));
		if (abs(753 - Y) < abs(753 - ans)) {
			ans = Y;
		}
	}
	cout << abs(753 - ans) << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s, t;
    cin >> n >> s >> t;
    rep(i,n){
        bool ok = true;
        rep(j,n-i){
            if(s[i+j] != t[j]) ok = false;
        }
        if(ok){
            cout << n+i << endl;
            return 0;
        }
    }
    cout << 2*n << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
//#define int long long
//#define _DEBUG
#include <queue>
#include <vector>
#include <string>
#include <utility>
using namespace std;
typedef pair<int,int> pos;
int const infty = -1, none = -9, dx[] = {1,-1,0,0}, dy[]={0,0,1,-1};
int W, H;
string Map[23]; //Map[i][j]:i行j列目
bool reached[23][23];
pos firstPos;
queue<pos> Q;
int count_reached(){
    int r = 0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(reached[i][j]) r++;
        }
    }
    return r;
}
bool valid(int x, int y){
    return x>=0 && x<W && y>=0 && y<H && Map[y][x]!='#';
}
int solve(){
    Q.push(firstPos);
    reached[firstPos.second][firstPos.first] = true;
    while(true){
        auto top = Q.front(); Q.pop();
        int x = top.first, y = top.second;
        for(int d=0; d<4; d++){
            if(valid(x+dx[d], y+dy[d]) && !reached[y+dy[d]][x+dx[d]]){
                Q.push(make_pair(x+dx[d], y+dy[d]));
                reached[y+dy[d]][x+dx[d]] = true;
            }
        }
        if(Q.empty()) break;
        //cout << x<<","<<y<<", "<< Q.size()<<endl;
    }
    return count_reached();
}
signed main(){    
    while(cin >> W >> H && W > 0){
        firstPos = make_pair(none, none);
        for(int i=0; i<H; i++){
            cin >> Map[i];
            for(int j=0; j<W; j++){
                if(Map[i][j] == '@') firstPos = make_pair(j, i);
                reached[i][j] = false;
            }
        }
        cout << solve() << endl;
#ifdef _DEBUG
        cout << firstPos.first<<firstPos.second<< endl;
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++)cout << Map[i][j];
            cout << endl;
        }
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                cout<<reached[i][j];
            }
            cout << endl;
        }
#endif
    }
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
long long bit[200002];
long long max(long long x, long long y) {
    return x > y ? x : y;
}
void update(int k, long long v) {
    for (int i = k + 1; i <= 200001; i += i & -i)
        bit[i] = max(bit[i], v);
}
long long query(int k) {
    long long res = 0;
    for (int i = k; i > 0; i -= i & -i)
        res = max(res, bit[i]);
    return res;
}
int N;
int H[200000], A[200000];;
long long dp[200001];
int main(){
	cin>>N;
	for (int i = 0; i < N; i++)  cin>>H[i];
	for (int i = 0; i < N; i++) cin>>A[i];
	for (int i = 0; i <= 200000; i++)
		dp[i] = -2e18;
    for (int i = 0; i <= 200001; i++)
        bit[i] = -2e18;
    dp[0] = 0;
    update(0, 0);
    for (int i = 0; i < N; i++) {
        dp[H[i]] = max(dp[H[i]], query(H[i]) + A[i]);
        update(H[i], dp[H[i]]);
    }
    cout<<query(N+1)<<endl;
    return 0;
}


Measured memory_bytes: 8180
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
int a[maxn],l[maxn],r[maxn]; 
int gcd(int a,int b){
	int t;
	if(a<b){
		t=a;
		a=b;
		b=t;
	}
	if(b==0)
	return a;
	for(;;){
		int tmp;
		tmp=b;
		b=a%b;
		a=tmp;
		if(b==0)
		return a;
	}
}
int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	
		for(int i=1;i<=n;i++){
			l[i]=gcd(l[i-1],a[i]);
			}
	    for(int i=n;i>=1;i--){
	    	r[i]=gcd(r[i+1],a[i]);
		}
			int ans=0;
			for(int i=1;i<=n;i++){
				ans=max(ans,gcd(l[i-1],r[i+1]));
				
			}
		
	   //存储下来 不然会TLE 
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    if(a*c<=b){
        cout << c << endl;
    }
    else cout << b/a << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>

using namespace std;

int main(void)
{
	array<int, 3> abc;
	for (int i = 0; i < 3; i++) cin >> abc[i];
	sort(abc.begin(), abc.end());
	cout << abc[0] + abc[1] << endl;
	return (0);
}

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

using namespace std;

#define LL long long
#define u64 unsigned long long
#define u32 unsigned int
#define reg register
#define Raed Read
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)
#define erep(i,x) for(reg int i=Head[x]; i; i=Nxt[i])

inline int Read() {
	int res = 0, f = 1;
	char c;
	while (c = getchar(), c < 48 || c > 57)if (c == '-')f = 0;
	do res = (res << 3) + (res << 1) + (c ^ 48);
	while (c = getchar(), c >= 48 && c <= 57);
	return f ? res : -res;
}

template<class T>inline bool Min(T &a, T const&b) {
	return a > b ? a = b, 1 : 0;
}
template<class T>inline bool Max(T &a, T const&b) {
	return a < b ? a = b, 1 : 0;
}

const int N=1e5+5,M=1e5+5,mod=1e9+7;

bool MOP1;

int Sz[N],Fa1[N],Fa2[N];

char S[N];

int find1(int x) {
	return Fa1[x]==x?Fa1[x]:Fa1[x]=find1(Fa1[x]);
}

int find2(int x) {
	return Fa2[x]==x?Fa2[x]:Fa2[x]=find2(Fa2[x]);
}

bool MOP2;

inline void _main(void) {
	scanf("%s",S+1);
	int len=strlen(S+1);
	rep(i,1,len)Fa1[i]=Fa2[i]=i;
	drep(i,len,1)if(S[i+1]==S[i])Fa1[i]=find1(Fa1[i+1]);
	rep(i,1,len)if(S[i-1]==S[i])Fa2[i]=find2(Fa2[i-1]);
	rep(i,1,len) {
		if(S[i]=='R') {
			int P=find1(i);
			int t=P-i;
			if(t&1)Sz[P+1]++;
			else Sz[P]++;
		} else {
			int P=find2(i);
			int t=i-P;
			if(t&1)Sz[P-1]++;
			else Sz[P]++;
		}
	}
	rep(i,1,len)printf("%d ",Sz[i]);
}

signed main() {
#define offline1
#ifdef offline
	freopen("chessboard.in", "r", stdin);
	freopen("chessboard.out", "w", stdout);
	_main();
	fclose(stdin);
	fclose(stdout);
#else
	_main();
#endif
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N, K;
    cin >> N >> K;
    ll ans = K;
    rep(i, N - 1)
    {
        ans *= K - 1;
    }
    cout << ans;
    return 0;
}

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

typedef long long ll;

int main() {
    int H, N, A;
    cin >> H >> N;
    rep(i, N) {
        cin >> A;
        H -= A;
    }
    if (H > 0) cout << "No\n";
    else cout << "Yes\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;

set<string> s;
bool used[10];
string card[10];
int n,k,u[4];

int dfs(int c){
    if(c==k){
        string cb;
        for(int i=0;i<k;++i) cb +=card[u[i]];
        s.insert(cb);
        return 0;
    }
    for(int i=0;i<n;++i){
        if(!used[i]){
            used[i]=1;u[c]=i;
            dfs(c+1);
            used[i]=0;
        }
    }
}
int main(){
    while(cin>>n>>k,n){
        s.clear();
        for(int i=0;i<n;++i) cin>>card[i];
        memset(used,0,sizeof(used));
        dfs(0);
        cout<<s.size()<<endl;
    }
    return 0;
}

Measured memory_bytes: 3256
using System;
using System.Linq;
class Program{
  static void Main(){
    var nm = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    var num = Enumerable.Repeat(-1, nm[0]).ToArray();
    string input;
    while((input = Console.ReadLine())!=null){
      var inarray = input.Split(' ');
      var s = int.Parse(inarray[0]) - 1;
      var c = int.Parse(inarray[1]);
      if (num[s] != -1 && num[s] != c){
        Console.WriteLine(-1);
        return;
      }
      num[s] = c;
    }
    if(num[0]==0 && nm[0] >1){
      Console.WriteLine(-1);
      return;
    }
    if(num[0]==-1){
      num[0] = nm[0] > 1 ? 1 : 0;
    }
    var result = 0;
    foreach(var c in num){
      result *= 10;
      result += c >= 0 ? c : 0;
    }
    Console.WriteLine(result);
  }
}

Measured memory_bytes: 13396
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int a, b, c;
  cin >> a >> b >> c;
  int k;
  cin >> k;
  string ans = "No";
  int num = 0;
  while (a >= b) {
    num++;
    b *= 2;
  }
  while (b >= c) {
    num++;
    c *= 2;
  }
  if(num <= k){
    ans = "Yes";
  }
  cout << ans << endl;
}


Measured memory_bytes: 3648
def main():
    N, M = (int(i) for i in input().split())
    PY = [([int(i) for i in input().split()], j) for j in range(M)]
    dic = {i: [] for i in range(N)}  # 県iの市を生まれた順に持つ
    A = sorted(PY, key=lambda p: p[0][1])
    for py, i in A:
        dic[py[0]-1].append(i)

    ans = []
    for p in range(N):  # 県ごとに番号を振る
        for x, i in enumerate(dic[p], start=1):
            # 県pの中でx番目に生まれた市i
            upper = "{:>06}".format(str(PY[i][0][0]))
            lower = "{:>06}".format(str(x))
            ans.append((upper+lower, i))
    ans.sort(key=lambda p: p[1])
    for a, _ in ans:
        print(a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 129752
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 20){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll H, W, N;
ll dp[3010][2];

void solve(){
  COMinit();
  cin >> H >> W >> N;
  vector<pair<ll, ll>> obs(N);
  rep(i, N){
    cin >> obs[i].f >> obs[i].s;
    obs[i].f--, obs[i].s--;
  }
  obs.pb({0, 0});
  obs.pb({H-1, W-1});
  sort(obs.begin(), obs.end());
  dp[0][0] = 1;//i番目のマスにいて、今まで壁を何回使ってるか
  for(ll i = 1; i <= N+1; i++){
    for(ll j = 0; j < i; j++)rep(k, 2){
      ll disy = obs[i].f - obs[j].f, disx = obs[i].s - obs[j].s;
      if(disy < 0 || disx < 0) continue;
      dp[i][1-k] += dp[j][k] * comb(disy + disx, disy) % MOD;
      dp[i][1-k] %= MOD;
    }
  }
  ll ans = dp[N+1][1] + MOD - dp[N+1][0];
  ans %= MOD;
  cout << ans << endl;
}

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


Measured memory_bytes: 5120
H, W, K = map(int, input().split())
h_lines = (1, 1, 2, 3, 5, 8, 13, 21, 34)
MOD = 10 ** 9 + 7

dp = [[0] * 8 for _ in range(H + 1)]
dp[0][0] = 1
for h in range(H):
    for w in range(W):
        dp[h + 1][w] = dp[h][w] * h_lines[w] * h_lines[W - w - 1]
        if w > 0:
            dp[h + 1][w] += dp[h][w - 1] * h_lines[w - 1] * h_lines[W - w - 1]
        if w < W - 1:
            dp[h + 1][w] += dp[h][w + 1] * h_lines[w] * h_lines[W - w - 2]
        dp[h + 1][w] %= MOD
print(dp[H][K - 1])


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <cmath>
#include <cstring>
using namespace std;

#define pi acos(-1)

int to_int(string s){
    int number = 0;
    for(int i=0;i<s.size();i++){
        number *= 10;
        number += s[i] - '0';
    }
    return number;
}

string to_str(int n){
    string s;
    while(n!=0){
        s += n % 10 + 48;
        n /= 10;
    }
    reverse(s.begin(),s.end());
    return s;
}

bool isLeapYear(int year)
{
    if(((year % 4 == 0 ) && (year % 100 != 0)) || (year % 400 == 0))
        return true;
    else
        return false;
}

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

    return true;
}

bool isPalindrome(string s)
{
    for(int i=0,j=s.size()-1 ; i< s.size()/2 && j >= s.size()/2;i++,j--){
            if(s[i] == s[j])
                continue;
            else{
                return false;
            }
        }
    return true;
}

/*#define row 5001
#define col 10000

int arr[row][col];

void fib()
{
    arr[0][0] = 0;
    arr[1][0] = 1;
    for(int i=2;i<row;i++){
        for(int j=0;j<col;j++){
            if(arr[i-1][j] + arr[i-2][j] == 0)
                continue;
            arr[i][j] += arr[i-1][j] + arr[i-2][j];
            if(arr[i][j] > 9){
                arr[i][j+1] = arr[i][j]/10;
                arr[i][j] %= 10;
            }
        }
    }
}*/

int main()
{
    int n, sum=0;
    cin >> n;
    while(n--)
    {
        int a;
        cin >> a;
        sum+= a-1;

    }

    cout << sum << endl;

	return 0;
}


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<pii> edge(n-1);
    for(auto& [x,y]:edge){
        cin>>x>>y;
        if(x>y) swap(x,y);
    }
    ll ans=0;
    for(int i=n;i>0;i--){
        ans+=(1LL+i)*i/2;
    }
    for(auto [x,y]:edge){
        ans-=ll(x-1+1)*(n-y+1);
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 4772
import Control.Monad
import Data.List
check all@(s:str) = if all /= (nub all) then "No" else inCheck (last s) str
 where
  inCheck _ []     = "Yes"
  inCheck c (x:xs) = if (head x == c) then inCheck (last x) xs else "No"
main = do
 r <- readLn
 str <- replicateM r getLine
 putStrLn $ check str

Measured memory_bytes: 636
use proconio::input;

fn main() {
    input! {
        n:i64,
    }
    let cnt_vec = scan_prime(n);
    let ret = sum_cnt(cnt_vec);
    println!("{}", ret)
}

fn scan_prime(mut target: i64) -> Vec<i64> {
    let mut cnt_vec = vec![];
    if target != 1 {
        for i in 2.. {
            let mut cnt = 0;
            if i * i > target {
                if target != 1 {
                    cnt_vec.push(1);
                }
                break;
            }
            while target % i == 0 {
                target /= i;
                cnt += 1;
            }
            if cnt != 0 {
                cnt_vec.push(cnt);
            }
        }
    }
    cnt_vec
}

fn sum_cnt(cnt_vec: Vec<i64>) -> i64 {
    let ret: i64 = cnt_vec.into_iter().fold(0i64, |acc, x| {
        let mut cnt = 0;
        let mut sum = x;
        while sum > 0 {
            cnt += 1;
            sum -= cnt + 1;
        }
        acc + cnt
    });
    ret
}

#[test]
fn test_scan_prime() {
    assert_eq!(scan_prime(64), vec![6]);
    assert_eq!(scan_prime(997764507000), vec![3, 3, 3, 2]);
}

#[test]
fn test_sum_cnt() {
    assert_eq!(sum_cnt(vec![0]), 0);
    assert_eq!(sum_cnt(vec![1]), 1);
    assert_eq!(sum_cnt(vec![2]), 1);
    assert_eq!(sum_cnt(vec![3]), 2);
    assert_eq!(sum_cnt(vec![4]), 2);
    assert_eq!(sum_cnt(vec![5]), 2);
    assert_eq!(sum_cnt(vec![6]), 3);
    assert_eq!(sum_cnt(vec![6]), 3);
    assert_eq!(sum_cnt(vec![3, 3, 3, 2]), 7);
}


Measured memory_bytes: 2144
[N,M,K] = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))

#Aでどこまで行けるか。
Acount=N
Ajikan=0
for i in range(N):
    Ajikan += A[i]
    if Ajikan > K:
        Acount=i
        Ajikan=Ajikan-A[i]
        break
#print('Acount,Ajikan:', Acount,Ajikan)

jikan=0
Bcount=0
count=0
j=0
life = K - Ajikan
while Acount>=0 and Bcount<=M :
    if j>=M:
        break

    elif B[j] <= life:
        count = max(Acount+Bcount, count)
        Bcount+=1
        life -= B[j]
        j+=1

    else:
        count = max(Acount+Bcount, count)
        if Acount<=0:
            break
        life += A[Acount-1]
        Acount-=1
    count = max(Acount+Bcount, count)

print(count)


Measured memory_bytes: 117880
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    vector<vector<int>> row(h),col(w);
    rep(i,h) rep(j,w) if(s[i][j] == '#') {
        row[i].pb(j);
        col[j].pb(i);
    }
    int ans = 0;
    rep(i,h) rep(j,w) {
        if(s[i][j] == '#') continue;
        int na = 0;
            {
                int le,ri;
                if(row[i].empty()) {
                    le = -1;
                    ri = w;
                } else {
                    if(row[i][0] > j) {
                        le = -1;
                        ri = row[i][0];
                    } else {
                        auto it = upper_bound(all(row[i]),j);
                        if(it == row[i].end()) {
                            le = row[i].back();
                            ri = w;
                        } else {
                            ri = *it;
                            it--;
                            le = *it;
                        }
                    }
                }
                na += ri-le-1;
            }
            {
                int up,down;
                if(col[j].empty()) {
                    up = -1;
                    down = h;
                } else {
                    if(col[j][0] > i) {
                        up = -1;
                        down = col[j][0];
                    } else {
                        auto it = upper_bound(all(col[j]),i);
                        if(it == col[j].end()) {
                            up = col[j].back();
                            down = h;
                        } else {
                            down = *it;
                            it--;
                            up = *it;
                        }
                    }
                }
                na += down-up-1;
            }
        na--;
        chmax(ans,na);
    }
    cout << ans << endl;
}

Measured memory_bytes: 38528
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;



int main(){
  int A, B;
  cin >> A >> B;
  if(abs(A - B) % 2){
    cout << "IMPOSSIBLE" << endl;
  }
  else{
    cout << (A+B)/2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define debug(x) cout << #x << ":" << x << endl
const intl INF = 1e9;
const intl MOD = 1e9+7;
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
int main(){
    intl a;
    cin >> a;
    intl b;
    cin >> b;
    intl c;
    cin >> c;
    ld e =  1.0e-14;
    fp((sqrtl(a) + sqrtl(b) + e < sqrtl(c)));
    return 0;
}

Measured memory_bytes: 256