akhauriyash/Code-Regression huggingface dataset:
#include <stdlib.h>
#include <stdio.h>

int main()
{
	char string[101];
	scanf("%s",string);
	int i;
	int c = 0;
	int f = 0;
	for (i=0;string[i] != '\0';i++) {
		if (string[i] == 'C') c = 1;
		if (c == 1 && string [i] == 'F')  f = 1;
	}
	if (f == 1) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<vector>
#include<map>
#include<algorithm>
#include<functional>


using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using ll=long long;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n, k;

	while(scanf("%d%d", &n, &k)==2)
	{
		ll ans, t;

		t=n/k;
		ans=t*t*t;
		if(k%2==0 && n*2>=k)
		{
			t=(n-k/2)/k+1;
			ans+=t*t*t;
		}

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


Measured memory_bytes: 128
H = [str(i) for i in list(input())]

N = len(H)
CHILDS = []

def RLadd(Rcount,Lcount):
    M = []
    X = Rcount+Lcount
    for i in range(X):
        if i == Rcount - 1:
            if X % 2 == 0:
                M.append(X//2)
            else:
                if Rcount %2 == 1:
                    M.append((X-1)//2 + 1)
                else:
                    M.append((X-1)//2)
        elif i == Rcount: 
            if X % 2 == 0:
                M.append(X//2)
            else:
                if Rcount %2 == 1:
                    M.append((X-1)//2)
                else:
                    M.append((X-1)//2 + 1)
        else:
            M.append(0)
    return(M)

Rcount =0
Lcount =0
for i in range(N):
    if H[i] == "L":
        Lcount += 1
    elif H[i] == "R":
        if Lcount == 0:
            Rcount += 1
        
        elif Lcount != 0:
            M = RLadd(Rcount,Lcount)
            for i in range(Rcount+Lcount):
                CHILDS.append(M[i])
            Rcount =1
            Lcount =0
            
M = RLadd(Rcount,Lcount)
for i in range(Rcount+Lcount):
    CHILDS.append(M[i])

print(' '.join(map(str, CHILDS)))

Measured memory_bytes: 12052
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b + c >= 22) cout << "bust" << '\n';
  else cout << "win" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main()
{
    string S;
    int w;

    cin >> S >> w;

    int idx=0;
    string Ans="";
    
    for(size_t i = 0; i < ceil(S.size()*1.0 / w); i++)
    {
        Ans.push_back(S[idx]);
        idx += w;
        // cout << Ans << " " << idx << endl;
    }
    
    cout << Ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	while(m--){
		int k;
		cin>>k;
		for(int i=0;i<k;i++){
			int t;
			cin>>t;
			a[t]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(a[i]==0)ans++;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 3648
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input);
    println!("{}", output);
}

fn run(input: String) -> String {
    input.chars().filter(|&x| x == '1').count().to_string()
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (1000000000000000000ll)
#define mod (1000000007)

int n;
char s[111111];
int to[111111];
int ans[111111];
int I_Love_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	scanf("%s",s);
	n=strlen(s);
	FOR(i,1,n){
		if(s[i-1]=='R'&&s[i]=='L'){
			int k=i-1;
			while(k>=0&&s[k]=='R'){
				to[k]=i-1;
				k--;
			}
			k=i;
			while(k<n&&s[k]=='L'){
				to[k]=i-1;
				k++;
			}
		}
	}
	FOR(i,0,n){
		int pos=to[i];
		if((i-pos)%2==0){
			ans[pos]++;
		}
		else{
			ans[pos+1]++;
		}
	}
	FOR(i,0,n){
		printf("%d",ans[i]);
		printf((i==n-1?"\n":" "));
	}
	
	
	
	return 0;
}


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

#define S second
#define F first
#define all(a) a.begin() , a.end()
#define pb push_back 
#define DBG cout<<"debug\n";

typedef long long ll;

const int N = 2 * 1e5 + 10;
const ll inf = 9e18 + 9; 

ll res;
ll a[N];


void solve(){
    map<int , pair<int , bool>> mp;
    string a = "AC" , w = "WA";
    int key, n;
    cin>>key>>n;

    int corr = 0, pen = 0;
    for(int i = 0; i < n; i++) {
        int x ; string s;
        cin>>x>>s;
        if(mp[x].second == false && s == w) {
            mp[x].first++;
        } 
        if(mp[x].second == false && s == a) {
            mp[x].second = true;
        }
    }

    for(auto i : mp) {
        if(i.second.second) {
            corr++;
            pen += i.second.first;
        }
    }

    cout<<corr<<" "<<pen;
}

int main(int argc, char const *argv[]){
    ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
    ll t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

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

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>

#define INF 100000000000
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int par[1000000]; //par[i] : iの親の番号
int rnk[1000000]; //root[i] : iの木のランク

//全てが根であるとして初期化
void init(int n){
    for(int i = 0; i < n; i++){
        par[i] = i;
        rnk[i] = 0;
    }
}

//データxが属する木の根を再帰で取得
int root(int x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = root(par[x]);
    }
}

//xとyが同じ木に属しているかを判定
bool same(int x, int y){
    return root(x) == root(y);
}

//xとyの木を併合
void unite(int x, int y){
    int rx = root(x); //xの根
    int ry = root(y); //yの根
    if(rx == ry) return; //根が同じならそのまま

    if(rnk[rx] < rnk[ry]){
        par[rx] = ry;
    }else{
        par[ry] =rx;
        if(rnk[rx] == rnk[ry]) rnk[rx]++;
    }
}

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> p(n);

    int i;
    for(i = 0; i < n; i++){
        cin >> p[i];
    }

    init(n);

    int x, y;
    for(i = 0; i < m; i++){
        cin >> x >> y;
        unite(x-1, y-1);
    }

    int count = 0;
    for(i = 0; i < n; i++){
        if(same(i, p[i]-1)){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 5120
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	ll n, d;
	cin >> n >> d;
	int cnt = 0;
	for (int i = 0;  i < n; i++) {
		ll x, y;
		cin >> x >> y;
		if (x * x + y * y <= d * d) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define ll __int128

using namespace std;

template<typename S,typename T>auto&operator<<(auto&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(auto&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(auto&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(auto&o,map<K,T>&m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(auto&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}
template<typename S,typename T,typename U>
struct TRI{S fi;T se;U th;TRI(){}TRI(S f,T s,U t):fi(f),se(s),th(t){}};
template<typename S,typename T,typename U>
auto& operator<<(auto& o,TRI<S,T,U>& t){return o<<"{"<<t.fi<<","<<t.se<<","<<t.th<<"}";}

typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef TRI<int, int, int> tri;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 200005;

ll x[MAX_N], sm[MAX_N];

using LL = __int128;

istream& operator>>(istream& is, LL& v)
{
    string s;
    is >> s;
    v = 0;
    for (int i = 0; i < (int)s.size(); i++) {
        if (isdigit(s[i])) { v = v * 10 + s[i] - '0'; }
    }
    if (s[0] == '-') { v *= -1; }
    return is;
}

ostream& operator<<(ostream& os, const LL& v)
{
    if (v == 0) { return (os << "0"); }
    LL num = v;
    if (v < 0) {
        os << '-';
        num = -num;
    }
    string s;
    for (; num > 0; num /= 10) { s.push_back((char)(num % 10) + '0'); }
    reverse(s.begin(), s.end());
    return (os << s);
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, X;
    cin >> n >> X;
    rep(i,n){
        cin >> x[i];
        sm[i+1] = sm[i] + x[i];
    }
    ll ans = (1LL << 62);
    srep(k,1,n+1){
        ll res = 0;
        for(int j = 0;; j++){
            if(j == 0) res += 5*(sm[n-k*j] - sm[max((ll)0, n-k*j-k)]);
            else res += (2*j+3)*(sm[n-k*j] - sm[max((ll)0, n-k*j-k)]);
            if(n-k*j-k <= 0) break;
        }
        cmn(ans, res+(n+k)*X);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
int main(){
//	freopen("text.out","w",stdout);
	long long n;
	scanf("%lld",&n);
	long long a[n+1],b[n];
	for(int i=0;i<n+1;i++){
		scanf("%lld",&a[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%lld",&b[i]);
	}
	long long sum=0;
	for(int i=0;i<n;i++){
		if(a[i]>b[i]){
			sum+=b[i];
		}
		else{
			sum+=a[i];
			if(b[i]-a[i]>a[i+1]){
				sum+=a[i+1];
				a[i+1]=0;
			}
			else{
				sum+=b[i]-a[i];
				a[i+1]=a[i+1]-b[i]+a[i];
			}
		}
	}
	printf("%lld\n",sum);
	return 0;
}

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

int main(){

	int S,a,b,c;
	cin >> S;

	a = S/3600;
	b = (S - 3600*a)/60;
	c = (S - 3600*a) - 60*b;

	cout << a << ':' << b << ':' << c << endl;
	return 0;
}

Measured memory_bytes: 1164
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const int INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 998244353;
const ll N = 1LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000;


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

void solve() {
    int n;
    cin >> n;
    vector<vector<int> > d(n, vector<int>(n, n));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            d[i][j] = min(d[i][j], i);
            d[i][j] = min(d[i][j], j);
            d[i][j] = min(d[i][j], n - 1 - i);
            d[i][j] = min(d[i][j], n - 1 - j);
        }
    }
    vector<vector<int> > used(n, vector<int> (n, 1));
    int p;
    ll res = 0;
    for (int i = 0; i < n * n; ++i) {
        int x, y;
        cin >> p;
        --p;
        x = p / n;
        y = p % n;
        res += d[x][y];
        queue<pii> q;
        q.push(pii(x, y));
        used[x][y] = 0;
        while (!q.empty()) {
            pii pp = q.front();
            x = pp.first, y = pp.second;
            q.pop();
            for (int j = 0; j < 4; ++j) {
                int x1 = x + dx[j];
                int y1 = y + dy[j];
                if ((x1 < 0) || (y1 < 0) || (x1 >= n) || (y1 >= n))
                    continue;
                if (d[x1][y1] > d[x][y] + used[x][y]) {
                    q.push(pii(x1, y1));
                    d[x1][y1] = d[x][y] + used[x][y];
                }
            }
        }
    }
    cout << res << endl;
}

//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    
    solve();

#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}

Measured memory_bytes: 5148
INF = 10 ** 7
def main():
    N,M = map(int,input().split())
    coin = list(map(int,input().split()))
    dp = [INF] * (N + 1)
    dp[0] = 0
    for c in coin:
        for i in range(c,N + 1):
            dp[i] = min(dp[i],dp[i - c] + 1)
    print(dp[-1])
if __name__ == '__main__':
    main()



Measured memory_bytes: 7512
using System;

namespace ARC074_C___Chocolate_Bar
{
    class Program
    {
        static void Main(string[] args)
        {
            var HW = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            var H = HW[0];
            var W = HW[1];

            var S = long.MaxValue;
            for (int h = 1; h < H; h++)
            {
                var s1 = h * W;
                var s2 = Math.Max((int)((H - h) / 2) * W, (H - h) * (int)(W / 2));
                var s3 = H * W - s1 - s2;
                var smax = Math.Max(s1, Math.Max(s2, s3));
                var smin = Math.Min(s1, Math.Min(s2, s3));
                S = Math.Min(S, smax - smin);
            }
            for (int w = 1; w < W; w++)
            {
                var s1 = H * w;
                var s2 = Math.Max((int)(H / 2) * (W - w), H * (int)((W - w) / 2));
                var s3 = H * W - s1 - s2;
                var smax = Math.Max(s1, Math.Max(s2, s3));
                var smin = Math.Min(s1, Math.Min(s2, s3));
                S = Math.Min(S, smax - smin);
            }
            Console.WriteLine(S);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,k;
    cin>>n>>k;
    vector<pair<int,int>>p;
    const int x=200001;
    rep(i,x){
        p.push_back(make_pair(0,i));
    }
    rep(i,n){
        int a; cin>>a;
        p[a].first++;
    }
    int sum=0,ans=0;
    rep(i,x){
        if(p[i].first!=0)sum++;
    }
    sort(p.begin(),p.end());
    rep(i,x){
        if(sum<=k){
            cout<<ans<<endl;
            return 0;
        }
        if(p[i].first!=0){ans+=p[i].first; sum--;}
    }
}


Measured memory_bytes: 2420
from itertools import accumulate

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    CUSUM = tuple(accumulate(A))

    sub = 0
    for i in range(N-1):
        if CUSUM[i]*2 < A[i+1]:
            sub = i+1
    print(N-sub)
    
if __name__ == "__main__":
    main()

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

int main(){
    int N;
    string S;
    cin>>N>>S;
    if(N%2==0){
        if(S.substr(0,N/2)==S.substr(N/2,N/2))cout<<"Yes";
        else cout<<"No";
    }else{
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3608
sub f{
	$v[$_]=my$t=pop;
	grep$v[$_]?$v[$_]&$t:f(3-$t),@$_;
}
@n=1..<>;
map{push@$_,$_[--$|]for@_=split$"}<>;
$v[$_]||${@$_?f(1)?b:a:c}++for@n;
print@n*2*$c-$c*$c+2*$a*$a+$b*$b+2*$a*$b

Measured memory_bytes: 152448
/**
 *   author: malviyanshiv
 *   created: 13 April 2019  17:20:04
**/

#include <bits/stdc++.h>

using namespace std;

#define REP(i, a, b) for(int i = a; i < b; i++)
#define RREP(i, a, b) for(int i = a-1; i >= b; i--)
#define FORE(a) for(auto ele : a )
#define ALL(a) begin(a), end(a)
#define RPB(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define PB push_back
#define MP make_pair
#define MOD 1000000007
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define F first
#define S second
#define TC int t; cin >> t; while(t--)
#define SET(a,b) memset(a,b,sizeof(a))

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

typedef long long ll;
typedef pair< int, int > PII;


void optimizeIO(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
}

int main(){
	optimizeIO();

	int a, b;
	cin >> a >> b;
	int val = max( a, b);
	if( a > b )
		a--;
	else
		b--;
	val += max( a, b);
	cout << val << endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    // input M D
        // M = d1 * d10 なる積の日の日数を出力せよ
        Scanner sc = new Scanner(System.in);
        int monthNum = sc.nextInt();
        int dayNum = sc.nextInt();
        int resNum = 0;
        for(int j = 4; j <= monthNum; j++) {
            for (int i = 22; i <= dayNum; i++) {
                if (1 < i % 10 && ((i / 10) * (i % 10) == j)) {
                    resNum++;
                }
            }
        }
        System.out.println(resNum);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
ll lcm(ll c,ll b){
    return c*b/gcd(c,b);
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/
typedef pair<ll,pair<ll,ll>> P;
bool pc(const P& f,const P& s){
    return f.second.second>s.second.second;
}

int main(){
    string s;
    cin>>s;
    ll ans=0;
    rep(i,s.size()){
        if(i%2==0){
            if(s[i]=='p')ans--;
        }else if(s[i]=='g') ans++;
    }
    op(ans);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;


signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n;
    int h[100010];
    long long dp[100010];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> h[i];
        dp[i] = 0;
    }
    for(int i=1;i<n;i++){
        if(dp[i]){
            dp[i] = min(dp[i],dp[i-1] + abs(h[i] - h[i-1]));
        }else{
            dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
        }
        if(i >= 2){
            dp[i] = min(dp[i],dp[i-2] + abs(h[i] - h[i-2]));
        }
    }
    cout << dp[n-1] << "\n";
    return 0;
}


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

int num, l;

int main(void) {
  while(cin >> num >> l, num || l) {
    map<int, int> mp;

    int cnt = 0;
    while(true) {
      vector<int> v;
      int i = 0;
      // cout << num << endl;
      if(mp.count(num) != 0) {
        cout << mp[num] << " " << num << " " << cnt - mp[num] << endl;
        break;
      }
      mp[num] = cnt;
      while(num > 0) {
        v.push_back(num % 10);
        num /= 10;
        i++;
      }
      REP(j, i, l) v.push_back(0);
      // cout << "size : " << v.size() << endl;
      sort(v.begin(), v.end());
      int mini = 0, maxi = 0;
      REP(j, 0, l) {
        mini = mini * 10 + v[j];
        maxi = maxi * 10 + v[l - j - 1];
      }
      // cout << maxi << " " << mini << endl;
      num = maxi - mini;
      cnt++;
    }
  }

  return 0;
}

Measured memory_bytes: 3060
N = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(N):
    ans += min(a[i]+a[i+1],b[i])
    if a[i]<b[i]:
        a[i+1] = max(a[i]+a[i+1]-b[i],0)
print(ans)

Measured memory_bytes: 19116
#include <bits/stdc++.h>
using namespace std;
using LL=long long;

int main(){
    int n;
    cin >> n;
    while(n != 0){
    vector<vector<int>> s(30);
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        for(int j=0; j<x; j++){
            int f;
            cin >> f;
            f--;
            s[f].push_back(i);
        }
    }
    vector<LL> b(n, 0);
    int ans = -1;
    for(int i=0; i<n; i++){
        b[i] |= (1LL << i);
    }

    for(int i=0; i<30; i++){
        LL tmp = 0;
        for(auto &&x : s[i]){
            tmp |= b[x];
        }
        for(auto &&x : s[i]){
            b[x] |= tmp;
        }
        if(tmp == (1LL<<n)-1){
            ans = i+1;
            break;
        }
    }
    cout << ans << endl;
    cin >> n;
    }
}









Measured memory_bytes: 3072
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
   int a;
   int flag = 0;
   cin >> a;
   for(int i = 1; i <= 9; i++) {
       if(a % i == 0 && (a / i) <= 9) {
           flag = 1;
           break; 
       } 
   }
   if(flag == 0) {cout << "No" << endl;}
   else {cout << "Yes" << endl;}
    return 0;
}


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

ll s1, s2, c1, c2;

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

    rep(i, n) {
        ll a;
        cin >> a;
        s1 += a, s2 += a;
        if (i % 2 == 0) {
            if (s1 <= 0) c1 += 1 - s1, s1 = 1;
            if (s2 >= 0) c2 += 1 + s2, s2 = -1;
        } else {
            if (s1 >= 0) c1 += 1 + s1, s1 = -1;
            if (s2 <= 0) c2 += 1 - s2, s2 = 1;
        }
    }

    cout << min(c1, c2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 201000;
int b[N],a[N],c[N],n,mod,ans;
bool check(int lim){
	for(int i=1;i<=n;i++)
		b[i]=i+lim>n?a[i]-mod:a[i];
	merge(b+1,b+n-lim+1,b+n-lim+1,b+n+1,c+1);
	int mx=0;
	for(int i=1;i<=n/2;i++){
		if(c[i]+c[n-i+1]<0) return 0;
		mx=max(mx,c[i]+c[n-i+1]);
	}
	ans=min(ans,mx);
	return 1;
}
int main(){
	read(n);read(mod);n*=2;
	for(int i=1;i<=n;i++) read(a[i]);
	sort(a+1,a+n+1);
	ans=mod;
	int l=0,r=n/2+1;
	while(l+1<r){
		int mid=l+r>>1;
		if(check(mid)) l=mid;
		else r=mid;
	}
	check(l);
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 2560
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

ll N;
ll a[MAX];

int main() {
    cin >> N;

    REP(i, N) {
        cin >> a[i];
    }    

    multiset<int> ms;

    for(int i=0; i<N; ++i){
        auto it = ms.lower_bound(a[i]);
        if(it != ms.begin()){
            it--;
            ms.erase(it);
        }
        ms.insert(a[i]);
    }

    cout << ms.size() << endl;

    return 0;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int a,b,all[9999],sa[9999],ke[9999],ba,bn;
int main(){
    cin>>a>>b;
    for(int i=0;i<a;i++){ cin>>all[i]; }
    for(int i=0;i<b;i++){ cin>>sa[i];  }
    for(int i=0;i<b;i++){
        for(int o=0;o<a;o++){
            if(all[o]<=sa[i]){ke[o]++;break;}
        }
    }
    for(int i=0;i<a;i++){
        if(ke[i]>ba){ba=ke[i];bn=i+1;}
    }
    cout<<bn<<endl;
}

Measured memory_bytes: 3116
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

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

	cout << (N * (N + 1) / 2) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<iostream>
using namespace std;

int main() {
	const int n = 6;
	int dice[n];
	int top, front;
	int p;
	int dice_result[6];
	const int dice_tem[4][6] = { { 3,2,6,1,5,4 },{ 2,6,3,4,1,5 },
	{ 5,1,3,4,6,2 },{ 4,2,1,6,5,3 } };
	for (int i = 0; i < n; i++) {
		cin >> dice[i];
	}
	int num;
	cin >> num;
	for (int v = 0; v < num; v++) {
		cin >> top >> front;
		for (int d = 0; dice[0] != top ; d++) {
			if (d == 0)continue;

			for (int i = 0; i < n; i++) {
				dice_result[i] = dice[dice_tem[d % 2][i] - 1];
			}
			for (int i = 0; i < n; i++)dice[i] = dice_result[i];
		}
		
		for (p = 0; p < 4; p++) {
			for (int i = 0; i < n; i++) {
			dice_result[i] = dice[dice_tem[p][i]-1];
		}
			if (front == dice_result[0]) break;
		}
		int a = p == 0 ? 2 : p == 1 ? 0 : p == 2 ? 3 : p == 3 ? 1 : -1;
		int y[6];
		for (int i = 0; i < n; i++)y[i] = dice[dice_tem[a][i] - 1];
		cout << y[0]  << endl;
		

	}
	return 0;
}
		


Measured memory_bytes: 3096
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;
// const int imax = 100000;

int main(){
	double t,x;
	cin >> t >> x;
	printf("%lf\n",t/x);
	return 0;
}

Measured memory_bytes: 3780
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args){
		String[] arg = readLine().split(" ");
		if(arg.length<2){return;}
		try{
			int T = Integer.parseInt(arg[0]);
			int X = Integer.parseInt(arg[1]);
			double t = (double)T/X;
			System.out.print(String.format("%.7f", t));
		}catch(Exception e){
			e.printStackTrace();
		}
		return;
	}

	private static String readLine(){
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		try{
			return reader.readLine();
		}catch(Exception e){
			return e.getMessage();
		}
	}
}


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<long long> A(N), B(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i] >> B[i];
	}
	long long ans = 0;
	for (int i = N - 1; i >= 0; --i) {
		auto x = A[i] + ans;
		ans += (x + B[i] - 1) / B[i] * B[i] - x;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
def main():
    s = input()
    rev_s = s[::-1]

    half_s = ['']*((len(s) - 1) // 2)
    for i in range((len(s) - 1) // 2):
        half_s[i] = s[i]
    rev_half_s = half_s[::-1]

    plus_three_s = [''] * (len(s) - ((len(s) + 3) // 2) + 1)
    count = 0
    for j in range(((len(s) + 3) // 2) - 1, len(s)):
        plus_three_s[count] = s[j]
        count += 1
    rev_plus_three_s = plus_three_s[::-1]

    if s == rev_s and half_s == rev_half_s and plus_three_s == rev_plus_three_s:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()


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

int main() {
 long long int n;
  cin >> n;
  vector<long long int> d;
  d.resize(n);
  for(long long int i=0; i<n; i++){
    cin >> d.at(i);
  }
  sort(d.begin(),d.end());
  cout << d.at(n/2)-d.at(n/2-1) << endl;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	string s;
	cin >> n >> s;
	vector<vector<int> > index(26);
	for(int i = 0; i < s.length(); i++){
		index[s[i] - 'a'].push_back(i);
	}
	queue<pair<int, vector<int> > > qu;
	for(int i = 0; i < 26; i++){
		if(!index[i].empty()) qu.push(make_pair(1, index[i]));
	}
	int ans = 0;
	while(!qu.empty()){
		pair<int, vector<int> > p = qu.front();
		int l = p.first;
		vector<int> startIndex = p.second;
		qu.pop();
		// cout << l << endl;
		if(startIndex.size() < 2) continue;
		auto itr = startIndex.begin();
		int minIndex = *(itr);
		itr = startIndex.end();
		itr--;
		int maxIndex = *(itr);
		// 以下の条件が成り立つ時は既に重なっているのでアウト
		// cout << minIndex << " " << maxIndex << endl;
		if(minIndex + l > maxIndex) continue;
		ans = l;
		vector<vector<int> > index(26);
		for(auto itr = startIndex.begin(); itr != startIndex.end(); itr++){
			int nowi = (*itr) + l;
			if(nowi >= s.length()) continue;
			index[s[nowi] - 'a'].push_back(*itr);
		}
		for(int j = 0; j < 26; j++){
			if(!index[j].empty()) qu.push(make_pair(l + 1, index[j]));
		}
	}
	cout << ans << endl;
}

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

#define ll long long
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1000000007;

using namespace std;

int n,a[100100];
int d[100100];
int main(){
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>a[i];
	}
	d[1]=0;
	d[2]=abs(a[2]-a[1]);

	for (int i=3;i<=n;i++){
		d[i]=min(d[i-1]+abs(a[i-1]-a[i]),d[i-2]+abs(a[i-2]-a[i]));
	}
	cout<<d[n];
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define For(i,j,k) for(int i=j;i<=k;++i)
using namespace std;
int read(){
	int x=0,l=1; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') l=-1; ch=getchar();}
	while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
	return x*l;
}
bitset<4000005> f;
int main(){
	int n=read(),sum=0,s,x; f[0]=1;
	For(i,1,n) x=read(),f|=(f<<x),sum+=x; s=(sum+1)>>1;
	For(j,s,sum) if (f[j]) printf("%d\n",j),exit(0);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


int main(){
    string S;
    cin >> S;
    for(int i=0; i<S.length(); i++){
        if(S[i]=='7'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main() {
    long long N, M; cin >> N >> M;
    if(N == 1 && M == 1){
        cout << "1" << endl;
        return 0;
    }
    else if(N == 1){
        cout << M - 2 << endl;
        return 0;
    }
    else if(M == 1){
        cout << N - 2 << endl;
        return 0;
    }
    else {
        cout << (M - 2) * (N - 2) << endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int a, b;
	cin >> a >> b;
	if (a*b%2==0)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,i,k,cnt=0,ans=0;
	cin>>n;
	vector<ll>arr(n);
	for(i=0;i<n;i++)cin>>arr[i];
	for(k=0;k<60;k++){
		cnt=0;
		for(i=0;i<n;i++){
			if((arr[i]>>k)&1ll)cnt++;
		}
		ans += (((1ll<<k)%mod) * (cnt % mod))%mod * ((n - cnt)%mod);
        ans %= mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;

    vector<int> a;
    int k = 0;
    int max = 0;
    int max_poji = 0;
    for(int i = 0; i < N; i++){
        cin >> k;
        a.push_back(k);
        if(k > max){
            max = k;
            max_poji = i;
        }
    }

    int ans = 0;
    for(int i = 0; i< N; i++){
        if(i == max_poji){
            ans += int(max / 2);
        }else{
            ans += a[i];
        }
    }

    cout << ans << endl;
}

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

using namespace std;

const int mod = 1e9 + 7;
vector<int> gr[123456];
long long dp[123456][3];

long long solve(int u, int c, int p) {
	if(dp[u][c] != -1) return dp[u][c];
	dp[u][c] = 1;
	if (c == 1) {
		for(int v : gr[u]) {
			if(v==p) continue;
			dp[u][c] *= solve(v, !c, u);
			dp[u][c] %= mod;
		}
	} else {
		long long a = 0;
		for(int v : gr[u]) {
			if(v==p) continue;
			a = 1;
			solve(v, c, u);
			solve(v, !c, u);
		}
		if(!a) {
			return dp[u][c] = 1;
		}
		//dp2[i][c] = (dp2[i+1][0]+dp2[i+1][1]) * a[i][c] for c in 1, 0
		int i = 0;
		if(gr[u][i] == p) i++;
		a = dp[gr[u][i]][0];
		long long b = dp[gr[u][i]][1];
		long long aold = a;
		long long bold = b;
		i++;
		for(; i < gr[u].size(); i++) {
			if(gr[u][i] == p)  continue;
			a = (((aold + bold) % mod) * dp[gr[u][i]][0]) % mod;
			b = (((aold + bold) % mod) * dp[gr[u][i]][1]) % mod;
			aold = a;
			bold = b;
		}
		dp[u][c] = (a + b) % mod;
	}
	return dp[u][c];
}


int main () {
	int n;
	cin >> n;
	memset(dp, -1, sizeof dp);
	int x,y;
	for (int i = 0; i < n-1; i++) {
		cin >> x >> y;
		x--; y--;
		gr[x].push_back(y);
		gr[y].push_back(x);
	}
	int root=0;
	solve(root, 0, -1);
	solve(root, 1, -1);
	cout << (dp[root][0] + dp[root][1]) % mod << endl;
}


Measured memory_bytes: 17536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll h,w;
	cin>>h>>w;
	if(h==1||w==1){
		cout << 1;
		return 0;
	}
	cout << (h*w+2-1)/2;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())

angle = (30 * H + 0.5 * M) - (6 * M)
if angle < 0:
    angle *= -1

cos = math.cos(math.radians(angle))

x = A ** 2 + B ** 2 - (2 * A * B * cos)

print(math.sqrt(x))

Measured memory_bytes: 9508
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1e5+10;
#define pb push_back
#define pii pair<int,int>
#define f first
#define s second
vector<int> G[N],Gt[N];
vector<pii> tf;
int dp[N],vis[N],t;
void dfs(int u)
{
  vis[u]=1;
  t++;
  for(auto v:G[u]) if(!vis[v]) dfs(v);
  tf.pb({++t,u});
}
int main()
{
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=m;i++)
  {
    int x,y;
    cin>>x>>y;
    G[x].pb(y);
    Gt[y].pb(x);
  }
  for(int i=1;i<=n;i++) if(!vis[i]) dfs(i);
  sort(tf.rbegin(),tf.rend());
  // for(int i=0;i<tf.size();i++) cout<<tf[i]<<" ";
  // cout<<endl;
  // dp[tf[0].s]=0;
  for(int i=0;i<tf.size();i++)
  {
    int x=tf[i].s,res=-1;
    for(int j=0;j<Gt[x].size();j++) res=max(res,dp[Gt[x][j]]);
    dp[x]=1+res;
  }
  int ans=-1;
  for(int i=1;i<=n;i++) ans=max(ans,dp[i]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 14968
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 200000 + 10;
char s[N]; int n;
int lef[N];
int main() {
	scanf("%d%s", &n,s+1);	
	if(s[1] == 'W') return !printf("0\n");
	lef[1]=1;
	for(int i=2;i<=2*n;i++){
		if(s[i]==s[i-1]) lef[i]=1^lef[i-1];
		else lef[i]=lef[i-1];
	}

	int cnt=0,ans=1;
	for(int i=1;i<=2*n;i++){
		//printf("# %d\n", lef[i]);
		if(lef[i]){cnt++;}
		else {	
			ans=1LL*ans*cnt%MOD;
			if(cnt==0)return !printf("0\n");
			cnt--;
		}
	}
	if(cnt)return !printf("0\n");
	for(int i=1;i<=n;i++)ans=1LL*ans*i%MOD;
	cout<<ans<<endl;
}

Measured memory_bytes: 1280
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int cap = sc.nextInt();
		
		int[] v = new int[n];
		int[] w = new int[n];
		
		for(int i=0;i<n;i++){
			v[i] = sc.nextInt();
			w[i] = sc.nextInt();
		}
		
		System.out.println(unboundedKnapsack(w,v,cap));
	}
	
	//個数制限なしナップサック問題
	static int unboundedKnapsack(int[] weight, int[] value, int capacity){
		int n = weight.length;
		int[][] dp = new int[n+1][capacity+1]; //dp[i+1][w]が品物0から品物iまでを用いた重さ制限wの問題の解
		
		for(int i=0;i<n;i++){
			for(int w=1;w<=capacity;w++){
				if(w>=weight[i]){
					dp[i+1][w] = Math.max(dp[i+1][w-weight[i]]+value[i],dp[i][w]);
					//dp[i][w-weight[i]]+value[i]はdp[i+1][w-weight[i]]+value[i]の劣化なので調べる必要なし
				}
				else{
					dp[i+1][w] = dp[i][w];
				}
			}
		}
		
		return dp[n][capacity];	
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 28980
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for i in range(N+1):
    for j in range(i, N+1):
        stone = V[:i] + V[j:]
        if len(stone) > K:
            continue
        else:
            count = K-len(stone)
            stone.sort()
            for k in range(min(count, len(stone))):
                if stone[k] < 0:
                    stone[k] = 0
                else:
                    break
            ans = max(ans, sum(stone))
print(ans)


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

int main() {
    int n, i;
    string s;
    cin >> n >> s;
    int black[n] = {0}, white[n] = {0};
    for (i = 0; i < n; i++) {
        if (s[i] == '#')
            black[i]++;
        else
            white[i]++;
        if (i != 0)
            black[i] += black[i - 1];
    }
    for (i = n - 2; i >= 0; i--)
        white[i] += white[i + 1];
    int ans = n;
    for (i = 0; i < n - 1; i++)
        ans = min(ans, black[i] + white[i + 1]);
    ans = min(ans, black[n - 1]);
    ans = min(ans, white[0]);
    cout << ans << endl;
}


Measured memory_bytes: 2180
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

vi a(10000);
int n,l,r;

int main(){
	cin>>l>>r>>n;
	for(int i=0;i<n;i++){
		int L,R;
		cin>>L>>R;
		for(int j=L;j<R;j++) a[j]=1;
	}
	for(int i=l;i<r;i++){
		if(a[i]){
			cout<<1<<endl;
			return 0;
		}
	}
	cout<<0<<endl;
}


Measured memory_bytes: 3124
n = int(input())
a = list(map(int, input().split()))
maxIndex = [i for i, x in enumerate(a) if x == max(a)]
c = a[:maxIndex[-1]+1]
max = c[0]
r = len(c)
cnt = 0
for t in c:
  if max <  t:
    max = t
  if max > t:
    cnt += 1
print(r - cnt)

Measured memory_bytes: 3064