akhauriyash/Code-Regression huggingface dataset:
//by yjz
#include<bits/stdc++.h>
#include<ctime>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,V,v[20],vn,a[200111];
int go[20][200111];
int dp[1<<20],dpl[1<<20],dpr[1<<20];
int gol[20][200111],gor[20][200111];

void solve()
{
	memset(dp,0,sizeof(dp));
	for(int i=0;i<=vn;i++)
	{
		go[i][n]=go[i][n+1]=n;
		for(int j=n-1;j>=1;j--)
		{
			if(a[j+1]-a[j]<=v[i])go[i][j]=go[i][j+1];
			else go[i][j]=j;
		}
	}
	for(int i=1;i<(1<<vn);i++)
	{
		for(int j=0;j<vn;j++)
		{
			if((i>>j)&1)
			{
				int t=i&~(1<<j);
				dp[i]=max(dp[i],go[j][dp[t]+1]);
			}
		}
	}
}

int mx[200111];
int main()
{
	getii(n,V);
	int tV=V;
	while(tV)tV>>=1,v[vn++]=tV;
//	for(int i=0;i<vn;i++)cerr<<v[i]<<" ";cerr<<endl;
	v[vn]=V;
	for(int i=1;i<=n;i++)geti(a[i]);
	solve();
	reverse(a+1,a+n+1);
	for(int i=1;i<=n;i++)a[i]=-a[i];
	for(int i=0;i<1<<vn;i++)dpl[i]=dp[i];
	for(int i=0;i<=vn;i++)for(int j=1;j<=n;j++)gor[i][j]=go[i][j];
	solve();
//	reverse(a+1,a+n+1);

	for(int i=0;i<1<<vn;i++)dpr[i]=dp[i];
	for(int i=0;i<=vn;i++)for(int j=1;j<=n;j++)gol[i][n-j+1]=n-go[i][j]+1;
	memset(dp,0,sizeof(dp));
	
	memset(mx,-1,sizeof(mx));
	int msk=(1<<vn)-1;
	for(int i=0;i<1<<vn;i++)
	{
//		cerr<<dpl[i]<<" "<<dpr[msk-i]<<endl;
		mx[dpl[i]]=max(mx[dpl[i]],dpr[msk-i]);
	}
	for(int i=n;i>=0;i--)mx[i]=max(mx[i],mx[i+1]);
/*	for(int i=0;i<vn;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cerr<<gor[i][j]<<" ";
		}cerr<<endl;
	}*/
	for(int i=1;i<=n;i++)
	{
//		cerr<<gol[vn][i]<<" "<<gor[vn][i]<<" "<<mx[gol[vn][i]-1]<<endl;
		if(mx[gol[vn][i]-1]>=n-gor[vn][i])
		{
			puts("Possible");
		}
		else puts("Impossible");
	}
	return 0;
}

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

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

    long long X[N];
    long long Y[N];
    long long arm = 31;

    bool is_odd = false;
    bool is_even = false;
    for (int i = 0; i < N; i++)
    {
        cin >> X[i] >> Y[i];
        if ((abs(X[i]) + abs(Y[i])) % 2 == 0)
        {
            is_even = true;
        }
        else
        {
            is_odd = true;
        }
    }

    if (is_odd && is_even)
    {
        cout << -1 << endl;
        return 0;
    }

    if (is_even)
    {
        cout << arm + 1 << endl;
        cout << 1 << " ";
    }
    else
    {
        cout << arm << endl;
    }

    long long l = 1;
    for (int i = 0; i < arm; i++)
    {
        l *= 2;
    }
    for (int i = 0; i < arm; i++)
    {
        l /= 2;
        cout << l;
        if (i != arm - 1)
        {
            cout << " ";
        }
    }
    cout << endl;

    for (int i = 0; i < N; i++)
    {
        if (is_even)
        {
            cout << "R";
            X[i]--;
        }

        l = 1;
        for (int j = 0; j < arm; j++)
        {
            l *= 2;
        }
        for (int j = 0; j < arm; j++)
        {
            l /= 2;
            long long dx[4] = {1, 0, -1, 0};
            long long dy[4] = {0, 1, 0, -1};
            string word[4] = {"L", "D", "R", "U"};
            for (int k = 0; k < 4; k++)
            {
                if (abs(X[i] + dx[k] * l) + abs(Y[i] + dy[k] * l) < l)
                {
                    X[i] += dx[k] * l;
                    Y[i] += dy[k] * l;
                    cout << word[k];
                    break;
                }
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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 (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int p,q,r; cin >> p >> q >> r;
  cout << p+q+r-max(p,max(q,r)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int nxt(){int aaa;scanf("%d",&aaa);return aaa;}
typedef unsigned long long ull;
int ar[2][100005];
vector<int> v[100005];
void bfs(int node,int k){
    queue<int> q;
    q.push(node);
    ar[k][node]=0;
    while(q.size()){
        int x=q.front(); q.pop();
        for(int i=0;i<v[x].size();i++){
            int y=v[x][i];
            if(ar[k][y]==-1){
                ar[k][y]=ar[k][x]+1; q.push(y);
            }
        }
    }
}
void solve()
{
    memset(ar,-1,sizeof ar);
    int n=nxt(),tak=nxt(),ao=nxt();
    for(int i=0;i<n-1;i++){
        int a=nxt(),b=nxt();
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int ans=-1;
    bfs(tak,0);bfs(ao,1);
    //for(int i=0;i<=n;i++) cout<<ar[0][i]<<" "<<ar[1][i]<<endl;
    for(int i=1;i<=n;i++){
        if(ar[0][i]<ar[1][i]) ans=max(ans,ar[1][i]);
    }
    cout<<ans-1<<endl;

}
int main()
{
    int tc=1;
    while(tc--)
    {
        solve();
    }
    return 0;
}


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

const int MAX_N = (int)100 + 5;

map<string, int> plusmp;
map<string, int> minusmp;
int n, m;

int ans = 0;

int main(void){
  // Here your code !
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    string tmp;
    cin >> tmp;
    auto itr = plusmp.find(tmp);
    if (itr != plusmp.end()) plusmp[tmp] += 1;
    else plusmp[tmp] = 1;
  }

  scanf("%d", &m);
  for (int i = 0; i < m; ++i) {
    string tmp;
    cin >> tmp;
    auto itr = minusmp.find(tmp);
    if (itr != minusmp.end()) minusmp[tmp] += 1;
    else minusmp[tmp] = 1;
  }

  for (auto itr = plusmp.begin(); itr != plusmp.end(); ++itr) {
    int cur = itr->second - minusmp[itr->first];
    ans = max(ans, cur);
  }

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

  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: usize,
        p: [usize; n]
    }
    let mut count = 0;
    let mut i = 0;
    loop {
        if i >= n {
            break;
        }
        if p[i] == i + 1 {
            count += 1;
            i += 2;
        } else {
            i += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){
    
    int N,D;cin>>N>>D;
    cout<<(N+2*D)/(D*2+1)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
#include<complex>
#define ll long long
#define ld long double
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define FOR(i, n, x) for(int i = x; i < n; i++)

using namespace std;



int main()
{
    fast;
    int n, m, y; cin >> n >> m >> y;
    int a[n], b[m], c[y];
    FOR(i, n, 0)cin >> a[i];
    FOR(i, m, 0)cin >> b[i];
    int minans = 1e9;
    FOR(i, y, 0)
    {
        int f, s, cnt; cin >> f >> s >> cnt;
        minans = min(minans, a[f - 1] + b[s - 1] - cnt);
    }
    sort(a, a + n);
    sort(b, b + m);
    minans = min(minans, a[0] + b[0]);
    cout << minans;
    return 0;
}



Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
ll modPow(ll a, ll n, ll p) {
  if (!n) return 1;
  if (n == 1) return a % p;
  if (n & 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}
int main(){
  int n;
  cin >> n;
  ll ans = modPow(10, n, mod);
  ans -= 2 * modPow(9, n, mod);
  (ans += modPow(8, n, mod)) %= mod;
  (ans += mod) %= mod;
  cout << ans << endl;
}

Measured memory_bytes: 3600
N = int(input())
H = list(map(int, input().split()))
count = 0
count_max = 0

for i in range(N-1):
    if H[i] >= H[i + 1]:
        count += 1
        if count_max <= count:
            count_max = count
    else:
        count = 0
    i += 1

print(count_max)

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

int main() {
	long long N;
	int ans;
	cin >> N;
	for (size_t i = 1; i < int(sqrt(N)+1); i++)
	{
		if (N%i==0)
		{
			ans = N / i;
		}
	}
	cout << int(log10(ans)+1);
}

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

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

string s,t;
int dp[3010][3010];

int main(){
    cin >> s >> t;
    int sizes = s.size();
    int sizet = t.size();
    for(int i=0;i<sizes;++i){
        for(int j=0;j<sizet;++j){
            chmax(dp[i+1][j+1],dp[i][j+1]);
            chmax(dp[i+1][j+1],dp[i+1][j]);
            if(s[i]==t[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
        }
    }


    //経路を復元する。
    string ans = "";
    while(sizes > 0 && sizet > 0){
        if(dp[sizes-1][sizet]==dp[sizes][sizet]){
            sizes--;
        } else if(dp[sizes][sizet-1]==dp[sizes][sizet]){
            sizet--;
        } else { // dpテーブルを斜め移動してたら、移動する前の文字が一致
            ans = s[sizes-1] + ans;
            sizes--;sizet--;
        }
    }
    
    cout << ans << endl;
    return 0;

}



Measured memory_bytes: 35584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef unsigned long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)
const ll mod =1e9+7;

class mint {
public:
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	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;
	}
};
ostream &operator<< (ostream &os, const mint &obj){
	    os << obj.x;
		return os;
	}

class combination {
public:
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) const {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
	mint p(ll n,ll k) const{
		if (k < 0 || k > n ) return 0;
		return fact[n]*ifact[n-k];
	}
	mint h(ll n,ll k) const {
		if (k < 0 || k > n) return 0;
		return fact[n+k-1]*ifact[n-1]*ifact[k];
	}
	mint choose(ll n ,ll a) const{// k <= 1e5 n <= 1e9
	    if (a < 0 || a > n) return 0;
		mint x=1,y=1;
		for(ll i=0;i < a; i++){
			x*=n-i;
			y*=i+1;
		}
		return x / y; 
	}
	mint perm(ll n, ll a) const { // k <= 1e5
	if (a < 0 || a > n) return 0;
	   mint x=1,y=1;
	   for (ll i=0;i < a;i++){
		   x*=n-i;
	   }
	   return x;
	}
}comb(10000001);

int main(){
     ll x,y;
     string s;
     ll ax,by;
     cin >> x >> y;
     if ((2*y-x)%3 !=0 || (2*x-y)%3 != 0){
          cout << 0  << endl;
          return 0;
     }
     else {
          ax=(2*y-x)/3;
          by=(2*x-y)/3;
          mint ans=0;
          ans=comb.fact[ax+by]*comb.ifact[ax]*comb.ifact[by];
          cout << ans << endl;
     } 
     return 0;
    
}


Measured memory_bytes: 156544
#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 ll;
#define orderd_set tree<pair<int, int>, null_type,greater<pair<int, int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)
//order_of_key(k)
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
const int N = 2e3+69;
#define ALL(x) begin(x),end(x)
#define sz(x) (ll)x.size()
const int OO = 0x3f3f3f3f;
const int mod = 1000000007;

int n;
ll arr[200069];


int main()
{
    FIO
    cin >> n;
    ll num = 0;
    for(int i= 0; i< n; i++)
    {
        cin >> arr[i];
        num ^= arr[i];
    }
    //cout << num << "\n";
    for(int i = 0; i< n; i++)
    {
        cout << (ll)(arr[i]^num) << " ";
    }
    return 0;
}


Measured memory_bytes: 5188
N = int(input())
dictionnaire = {"AC":0, "WA":0,"TLE":0, "RE":0}
for i in range(N):
    e = input()
    if e in dictionnaire.keys():
        dictionnaire[e] += 1
    else:
        dictionnaire[e] = 1
    
for i in dictionnaire.keys():
    print(f"{i} x {dictionnaire[i]}")

Measured memory_bytes: 9212
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> a(n);
    for (int i = 0;i<n;i++)
        cin >> a[i];
    sort(All(a));
    int res = 0;
    for (int i = 0; i < n-1;i++){
        for (int j = i+1; j < n;j++){
            int s = a[i] + a[j];
            int x = distance(a.begin(), lower_bound(All(a), s));
            //cout << a[i] << ' ' << a[j] << ' ' << x << endl;
            res += max(x - j -1, 0LL);
        }
    }
    cout << res << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) {
    cin >> p.at(i);
  }
  int count =0;
  for (int k = 0; k <= n-3; k++) {
    if (p.at(k) <= p.at(k+1) && p.at(k+1) < p.at(k+2)) {
      count++;
    } else if (p.at(k) > p.at(k+1) && p.at(k+1) >= p.at(k+2)) {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(s)-1,i##_len=(int)(n);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int p[100000];
int y[100000];
int z[100000];
int ans[100000];

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int  Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}

void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

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


int main() {
	int n;
	scanf("%d", &n);

	int ans = 0;
	int max = 0;
	REP(i, n) {
		int p;
		scanf("%d", &p);
		ans += p;
		max = Max(max, p);
	}
	ans -= max / 2;
	PRINTD(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>

#include<cmath>
#include<iostream>
#include<fstream>

#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>

using namespace std;

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

long long int findlcm(long long int arr[],long long int n)
{
    long long int  ans = arr[0];

    for (long long int i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}

 int main()
{
    long long int n,i,j,ck=0;
    cin>>n;
    long long int arr[n];
    for(i=0; i<n; i++)
        cin>>arr[i];

     printf("%lld\n", findlcm(arr, n));
    return 0;
}





Measured memory_bytes: 3200
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> num;

    for(int i = 0; i < n; i++){        
        int aux;
        cin >> aux;
        num.push_back(aux);
    }

    long long ans = 1000000000000000;
    int res;    

    for(int i = 1; i <= 100; i++){
       long long c = 0;
       for(int j = 0; j < num.size(); j++){        
            
           c += (num[j] - i) * (num[j] - i);                        

       }
       if(c < ans){
           res = i;
           ans = c;  
       }        
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    ll N;
    cin >> N;
    rep(h,1,3501) {
        rep(w,1,3501) {
            ll denom = 4 * h * w - N * w - N * h;
            ll numer = N * h * w;
            if (denom > 0 && numer % denom == 0) {
                ll n = numer / denom;
                if (n >= 1) {
                    cout << h << " " << n << " " << w << endl;
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int x, n;
  cin >> x >> n;
  vector<int>a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  vector<int> b;
  for(int i = -100; i < 130; i++) {
    bool ok = true;
    for(int j = 0; j < n; j++) {
      if(a[j] == i + 1){
        ok = false;
        break;
      }
    }
    if(!ok){
      continue;
    }
    b.push_back(i + 1);
  }
  bool c = true;
  for(int i = 0; i < n; i++) {
    if(x == a[i]){
      c = false;
      break;
    }
  }
  if(c){
    b.push_back(x);
  }
    int mini = 1001001001;
  int idx;
  for(auto p : b) {
    if(abs(p-x) < mini){
      mini = abs(p - x);
      idx = p;
    }
  }
  cout << idx << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 10000000000000

int main(){
    int n;string s;
    cin>>n>>s;
    
    int ans=1;
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[i+1]){ans++;}
    }
    cout<<ans<<endl;
    return 0;
}

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

ll f(ll x){
  if(x==1) return 1;
  return 2*f(x/2)+1;
}

int main() {
  ll h;
  cin >> h;
  
  cout << f(h) << endl;
  return 0;
}


Measured memory_bytes: 256
// By Shreehari Bodas

#include <bits/stdc++.h>

using namespace std;

int n;
vector<int> h;
vector<int> dp;

int solve(int i){
	if(dp[i]!=-1) return dp[i];
	else{
		dp[i]=min(solve(i+2)+abs(h[i+2]-h[i]),solve(i+1)+abs(h[i+1]-h[i]));
		return dp[i];
	}
}

int main(){

	cin>>n;
	for(int i=0;i<n;i++){
		int a; cin>>a;
		h.push_back(a);
		dp.push_back(-1);
	}

	dp[n-1]=0;
	dp[n-2]=abs(h[n-1]-h[n-2]);

	cout<<solve(0)<<endl;

	return 0;
} 

Measured memory_bytes: 5876
#include<bits/stdc++.h>
#define ll long long
#define forin(x,y) for(ll i=x;i<y;i++)
#define vii vector<ll>
#define pii  pair<ll,ll>
using namespace std;

vii v;
vii lookup;
ll K;
ll minCost( ll n)
{
    if(n<=0) return 0;
    if(n == 1)  return abs(v[1]-v[0]);
    else
    {
        if(lookup[n] != -1)     return lookup[n];
        else
        {
            ll index = n;
            lookup[n] = INT64_MAX;
            for(ll i=1; i<=K && i<=n ; ++i)
            {
                lookup[n]= min(lookup[n], (minCost(n-i) + abs(v[n] - v[n-i])));
            } 
            return lookup[n];
        }
        
    }
    
}


int main()
{
    ios::sync_with_stdio(false);    cin.tie(0);     cout.tie(0);
    //int t;    cin>>t;     forin(0,t)  evaluate();
    ll n;   cin>>n; cin>>K;     v.assign(n,0);      lookup.assign(n,-1);
    forin(0,n){     cin>>v[i];}
    ll ans = minCost(n-1);
    cout<<ans<<endl;
}




Measured memory_bytes: 6528
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

from numba import njit


def getInputs():
    D = int(readline())
    CS = np.array(read().split(), np.int32)
    C = CS[:26]
    S = CS[26:].reshape((-1, 26))
    return D, C, S


def _compute_score(output, i, d, last):
    mask = np.ones((26, ))
    mask[i] = 0
    score = S[d][i] - np.sum(C * (d + 1 - last) * mask)

    return score


def solve():
    output = []
    last = np.zeros((26, ))
    #SCORE = 0
    for d in range(D):
        max_score = float('-inf')
        best_i = 0
        for i in range(26):
            output.append(i)
            score = _compute_score(output, i, d, last)
            if max_score < score:
                max_score = score
                best_i = i + 1
            output.pop()
        output.append(best_i)
        last[best_i - 1] = d + 1
        #SCORE += max_score
        #print(SCORE)

    return output


if __name__ == "__main__":
    D, C, S = getInputs()
    ans = solve()
    print('\n'.join(map(str, ans)))

Measured memory_bytes: 92404
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll X,Y;
int main(){
    cin>>X>>Y;
    if(Y%2==1){
        cout<<"No";
        return 0;
    }
    if(X<= (Y/2) && (Y/2) <=X*2){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3640
N = int(input())
T, A = [int(x) for x in input().split(" ")]
H_list = [int(x) for x in input().split(" ")]

ave_list = [T - (H * 0.006) for H in H_list]

res_point = 0
res_ave = 99999

for enu, ave in enumerate(ave_list):
    if abs(res_ave - A) > abs(ave - A):
        res_ave = ave
        res_point = enu + 1
print(res_point)


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

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

        string N;
        int i,k;
        int ans=0;
        int ctr=0;
        ll sum=0;

        cin >> N;

        for(i=0;i<N.length();i++){
                sum+=N[i]-'0';
        }


        if(sum%9)
                cout << "No" << endl;
        else
                cout << "Yes" << endl;

        return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  const int MAXP = 999983;
  vector<bool> is_prime(MAXP + 1, true);
  is_prime[0] = is_prime[1] = false;
  for(int i = 2; i <= MAXP; i++)if(is_prime[i]){
    if((ll)i * i <= MAXP){
      for(int j = i * i; j <= MAXP; j += i){
        is_prime[j] = false;
      }
    }
  }
  vector<int> acc(MAXP + 1, 0);
  for(int i = 1; i <= MAXP; i++){
    acc[i] = acc[i - 1] + (is_prime[i] ? 1 : 0);
  }
  int N;
  while(cin >> N && N != 0){
    int ans = 0;
    REP(i, N){
      int p, m; cin >> p >> m;
      int left = max(p - m, 1);
      int right = min(p + m, MAXP);
      int cnt = acc[right] - acc[left - 1];
      ans += cnt - 1;
    }
    if(ans < 0) ans = 0;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 5164
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cmath>
#include <cassert>
using namespace std;
#define MOD 1000000007

int N, K;
long long ans;
vector<vector<int>> G;
vector<long long> fac, facinv;

long long perm(long long n, long long k){
    if(n < k) return 0;
    return (fac[n] * facinv[n-k]) % MOD;
}

void dfs(int s, int par){
    if(s == 0)
        ans = (ans * perm(K-1, G[s].size())) % MOD;
    else
        ans = (ans * perm(K-2, G[s].size()-1)) % MOD;
    for(int t : G[s]){
        if(par == t) continue;
        dfs(t, s);
    }
}

long long bipow(long long n, long long k){
    if(k == 0) return 1;
    if(k%2 == 0){
        long long tmp = bipow(n, k/2);
        return (tmp*tmp)%MOD;
    }else{
        return (n * bipow(n, k-1)) % MOD;
    }
}

int main(){
    cin >> N >> K;
    G.resize(N);
    fac.resize(K+1);
    facinv.resize(K+1);
    fac[0] = 1;
    for(int i=1; i<=K; i++)
        fac[i] = (fac[i-1]*i)%MOD;
    for(int i=0; i<=K; i++)
        facinv[i] = bipow(fac[i], MOD-2);

    for(int i=0; i<N-1; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    ans = K;
    dfs(0, -1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9216
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int h = in.nextInt();
        int w = in.nextInt();
        int n = in.nextInt();
        int sr = in.nextInt();
        int sc = in.nextInt();
        char[] s = in.next().toCharArray();
        char[] t = in.next().toCharArray();
        int l = 0, r = 0, u = 0, d = 0;
        int L = sc, R = w - sc +1, U = sr, D = h - sr +1;
        boolean ans = false;
        for (int i = 0; i < n; i++) {
            if(s[i] == 'L') l++;
            if(s[i] == 'R') r++;
            if(s[i] == 'U') u++;
            if(s[i] == 'D') d++;
            if(L <= l || R <= r || U <= u || D <= d){
                ans = true;
                break;
            }
            if(t[i] == 'L' && (0 < r || Math.abs(r) < L-1)) r--;
            if(t[i] == 'R' && (0 < l || Math.abs(l) < R-1)) l--;
            if(t[i] == 'U' && (0 < d || Math.abs(d) < U-1)) d--;
            if(t[i] == 'D' && (0 < u || Math.abs(u) < D-1)) u--;
        }
        System.out.println(ans ? "NO" : "YES");
        in.close();
    }

}


Measured memory_bytes: 29792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main(void){
	long long int h, w;

	cin >> h >> w;

	long long int m = 1e9;


	for (int i = 1; i < h; i++){
		m = min(m, max(w/2*i, max((w-w/2)*i, w*(h-i))) - min(w/2*i, min((w-w/2)*i, w*(h-i))));
	}

	for (int i = 1; i < w; i++){
		m = min(m, max(h/2*i, max((h-h/2)*i, h*(w-i))) - min(h/2*i, min((h-h/2)*i, h*(w-i))));
	}

	if (h % 3 == 0 || w % 3 == 0)
		m = 0;
	
	m = min(m, min(h, w));

	cout << m << endl;


}

Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val ans = getAns((0 until 3).map { readLine()!!.split(" ").map { it.toInt() } })
    println(if(ans) "Yes" else "No")
}

fun getAns(num:List<List<Int>>):Boolean {
    for(i in (0..100)) {
        val a1 = i
        val b1 = num[0][0] - a1
        val b2 = num[0][1] - a1
        val b3 = num[0][2] - a1
        val a2 = num[1][0] - b1
        val a3 = num[2][0] - b1

        val tmp = mutableListOf<List<Int>>()
        tmp.add(listOf(a1+b1,a1+b2,a1+b3))
        tmp.add(listOf(a2+b1,a2+b2,a2+b3))
        tmp.add(listOf(a3+b1,a3+b2,a3+b3))
        var isMatch = true
        for(j in (0 until 3)) {
            for(k in (0 until 3)) {
                if(num[j][k] != tmp[j][k]) {
                    isMatch = false
                    break
                }
            }
            if(!isMatch) {
                break
            }
        }
        if(isMatch) {
            return true
        }
    }
    return false
}


Measured memory_bytes: 38308
for(r=".IVXLCDM",k=n=s=p=0,j=require("fs").readFileSync("/dev/stdin","utf8");i=j[k];k++)i=='\n'?(console.log(s),n=s=p=0):s+=(n=Math.pow(10,~~((n=r.indexOf(i))/2))/(2-(n%2))),n>p?s-=p*2:0,p=n

Measured memory_bytes: 8704
import sys
from collections import namedtuple

INF = sys.maxsize

Item = namedtuple('Item', 'w v')

N, W = map(int, input().split())

items = []

for _ in range(N):
  w, v = map(int, input().split())
  items.append(Item(w, v))
  
memo = [0] + [INF] * 100000
  
for item in items:
  for v in range(100000, item.v - 1, -1):
    memo[v] = min(memo[v], memo[v - item.v] + item.w)

print(max([v for v, w in enumerate(memo) if w <= W]))

Measured memory_bytes: 45260
#include <iostream>
using namespace std;
#define rep(i, n) for (i = 0; i < n; i++)
int h, w, n, mx, d[405][405];
char b[25][25];
void f(int p, int q) { d[p][q] = d[q][p] = 1; }
int main() {
	int i, j, k;
	cin >> h >> w;
	rep(i, h) cin >> b[i];
	n = h * w;
	rep(i, n) rep(j, n) if (i != j) d[i][j] = 1e9;
	rep(i, h) rep(j, w) {
		if (b[i][j] == '.' && b[i][j + 1] == '.')
			f(i * w + j, i * w + j + 1);
		if (b[i][j] == '.' && b[i + 1][j] == '.')
			f(i * w + j, (i + 1) * w + j);
	}
	rep(k, n) rep(i, n) rep(j, n) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); }
	rep(i, n) rep(j, n) if (d[i][j] < 1e9) mx = max(mx, d[i][j]);
	cout << mx;
}


Measured memory_bytes: 4180
#include<iostream>
#include<vector>
//#include<string>

using namespace std;

int searchRoot(vector<int>& parent) {
	for (int i = 0; i < parent.size(); i++) {
		if (parent.at(i) == -1) return i;
	}
	return -1;
}

void sub_preorder(vector<int> & parent, vector<vector<int>> & children, int node) {
	if (node == -1) return;
	cout << " " << node;
	sub_preorder(parent, children, children.at(node).at(0));
	sub_preorder(parent, children, children.at(node).at(1));
}
void preorder(vector<int> & parent, vector<vector<int>> & children) {
	int root = searchRoot(parent);
	sub_preorder(parent, children, root);
	cout << endl;
}

void sub_inorder(vector<int> & parent, vector<vector<int>> & children, int node) {
	if (node == -1) return;
	sub_inorder(parent, children, children.at(node).at(0));
	cout << " " << node;
	sub_inorder(parent, children, children.at(node).at(1));
}
void inorder(vector<int> & parent, vector<vector<int>> & children) {
	int root = searchRoot(parent);
	sub_inorder(parent, children, root);
	cout << endl;
}


void sub_postorder(vector<int> & parent, vector<vector<int>> & children, int node) {
	if (node == -1) return;
	sub_postorder(parent, children, children.at(node).at(0));
	sub_postorder(parent, children, children.at(node).at(1));
	cout << " " << node;
}
void postorder(vector<int> & parent, vector<vector<int>> & children) {
	int root = searchRoot(parent);
	sub_postorder(parent, children, root);
	cout << endl;
}

int main(void) {
	int nodenum, node, left, right;
	cin >> nodenum;

	vector<int> parent(nodenum, -1);
	vector<vector<int>> children(nodenum);

	for (int i = 0; i < nodenum; i++) {
		cin >> node >> left >> right;
		children.at(node).push_back(left);
		if(left>-1)parent.at(left) = node;
		children.at(node).push_back(right);
		if (right > -1)parent.at(right) = node;
	}

	cout << "Preorder" << endl;
	preorder(parent, children);
	cout << "Inorder" << endl;
	inorder(parent, children);
	cout << "Postorder" << endl;
	postorder(parent, children);
	return 0;


}



Measured memory_bytes: 3112
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	int k,a,b;
	cin>>k>>a>>b;
	bool ok=false;
	for(int i=0;i<=b;i+=k) {
		ok|=(a<=i);
	}
	
	cout<<(ok?"OK":"NG")<<"\n";

	return 0;
}


Measured memory_bytes: 3648
import bisect
h,w,m=map(int,input().split())
hl=[0]*h
wl=[0]*w
s=[]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    hl[a]+=1
    wl[b]+=1
    s.append([a,b])
mh=max(hl)
mw=max(wl)
hh=[]
ww=[]
for i in range(h):
    if hl[i]==mh:
        hh.append(i)
for i in range(w):
    if wl[i]==mw:
        ww.append(i)
f=0
for a,b in s:
    hi=bisect.bisect_left(hh,a)
    wi=bisect.bisect_left(ww,b)
    if hi!=len(hh) and hh[hi]==a and wi!=len(ww) and ww[wi]==b:
        f+=1
if len(hh)*len(ww)>f:
    print(mh+mw)
else:
    print(mh+mw-1)

Measured memory_bytes: 82460
#include <stdio.h>

int main(void){
    int a, b, answer;
    char op;
    while(1){
    scanf("%d %c %d", &a, &op, &b);
        if(op == '?'){
            break;
        }else if(op == '+'){
            answer = a + b;
        }else if(op == '-'){
            answer = a - b;
        }else if(op == '/'){
            answer = a / b;
        }else if(op == '*'){
            answer = a * b;
        }
        printf("%d\n", answer);
    }
    return 0;
}

Measured memory_bytes: 600
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i<n; i++) a[i] = sc.nextInt();
        int k = 0;
        int count = 1;
        for(int i = 1; i <=n; i++) {
            if(a[i-1] == count) {
                k++;
                count++;
            }
        }
        int ans = n-k;
        if(ans == n) ans = -1; 
        System.out.println(ans);
    }
}

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

int main() {
  int a;
  cin >> a;
  int b = a % 2;
  int c = (a-b)/10 % 2;
  int d = (a-10*c-b)/100 % 2;
  cout << b+c+d << endl;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  a.begin(),a.end()

class CommonIO {
public:
    CommonIO() {
        std::cin.tie(0);
        std::ios::sync_with_stdio(false);
    }
    ~CommonIO() {}

    template <class T>
    void scan(T &v) {
        std::cin >> v;
    }
    template <class T, class... Rest>
    void scan(T &v, Rest&... rest) {
        scan(v);
        scan(rest...);
    }

    template <class T>
    void print(T v) {
        std::cout << v;
    }
    template <class T>
    void print(std::vector<T> &v) {
        if (v.size() == 0) return;
        print(*v.begin());
        for (auto it = ++v.begin(); it != v.end(); ++it) {
            print(' ');
            print(*it);
        }
    }
    template <class T>
    void print(std::vector< std::vector<T> > &grid) {
        if (grid.size() == 0) return;
        print(*grid.begin());
        for (auto it = ++grid.begin(); it != grid.end(); ++it) {
            print('\n');
            print(*it);
        }
    }
    template <class T, class... Rest>
    void print(T v, Rest... rest) {
        print(v);
        print(' ');
        print(rest...);
    }

    template <class T>
    void printl(T v) {
        print(v);
        std::cout << '\n';
    }
    template <class T, class... Rest>
    void printl(T v, Rest... rest) {
        print(v);
        print(' ');
        printl(rest...);
    }
} io;


struct Infant {
  int index;
  ll active;

  ll point(int i) {
    return active * abs(index - i);
  }
};

int main() {
  ll N; io.scan(N);
  vector<Infant> A(N+2);
  REP(i, N) {
    A[i].index = i+1;
    io.scan(A[i].active);
  }
  sort(ALL(A), [](Infant& a, Infant& b) {return a.active >= b.active;});
  
  ll dp[2002] = {0,}, dp2[2002] = {0,};
  ll x, y;
  for (int sum=1; sum<=N; ++sum) {
    swap(dp, dp2);
    Infant &a = A[sum-1];
    // x = 0, y = sum
    dp[0] = dp2[0] + a.point(N-sum+1);
    //io.printl(0, sum, 0, dp2[0] + a.point(N-sum+1));
    // x = 1 ~ sum-1
    for (x=1, y=sum-1; x<sum; ++x, --y) {
      //io.printl(x, y, dp2[x-1] + a.point(x), dp2[x] + a.point(N-y+1));
      dp[x] = max(dp2[x-1] + a.point(x), dp2[x] + a.point(N-y+1));
    }
    // x = sum, y = 0
    dp[sum] = dp2[sum-1] + a.point(sum);
    //io.printl(sum, 0, dp2[sum-1] + a.point(sum), 0);

    //REP(i, N+1) io.print(dp[i], "");
    //cout << endl;
  }
  
  io.printl(*max_element(dp, dp+2002));
  
  return 0;
}


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

using ll=long long; 

int func(int x){
	int ret=0;
	while(x>0){
		ret+=x%10;
		x/=10;
	}
	return ret;
}

void solve(){
	int n;
	cin>>n;
	int x=func(n);
	if(n%x==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n, q = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = list(map(lambda x: int(x)-1, input().split()))
    edges[a].append(b)
    edges[b].append(a)

values = [0]*n
for _ in range(q):
    p, x = map(int, input().split())
    values[p-1] += x

stack = [0]
visited = [0]*n
while stack:
    v = stack.pop()
    if visited[v]:
        continue
    visited[v] = 1
    for v2 in edges[v]:
        if visited[v2]:
            continue
        values[v2] += values[v]
        stack.append(v2)
print(*values)

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

int main()
{
  int a[3];
  int five=0,seven=0;
  cin >> a[0] >> a[1] >> a[2];
  for(int i=0;i<3;i++){
	if(a[i] == 5) five ++;
	else if(a[i] == 7) seven ++;
  }
  if(five == 2 && seven == 1) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    S = input()

    T = S
    if len(S) == 3:
        T = ''
        for i in range(3):
            T += S[2 - i]
    print(T)

if __name__ == '__main__':
    main()


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

int main(){
	int n;
	cin >> n;
	int *x = new int[n];

	for(int i = 0; i < n; i++) cin >> x[i];

	int ans = 0;

	for(int i = 0; i < n - 1; i++){
		for(int j = i + 1; j < n; j++){
			ans += x[i] * x[j];
		}
	}

	cout << ans;
	
	delete x;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC176
{
    class Program
    {
        static void Main()
        {
            var str = Console.ReadLine();

            var ans = str.Select(c => c - '0').Aggregate(0, (current, num) => (current + num) % 9);

            Console.WriteLine(ans == 0 ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 27180