akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
using namespace std;


int main(){
    int64_t ans = 0;
    int a, n;

    cin >> n;

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            for(int k = 1; k <= n; k++){
                a = min(i, j);
                a = min(a, k);
                for(int l = a; 0 < l; l--){
                    if(i % l == 0 && j % l == 0){
                        if(k % l == 0){
                            ans += l;
                            break;
                        }
                    }
                }
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>
#include<random>



#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;


int N, M;
int A[100010], B[100010], C[100010];
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> M;
	FOR(i,1, N+1) {
		cin >> A[i];
	}
	FOR(i, 1, N) {
		int s = A[i], t = A[i + 1];
		if (s < t) {
			B[0] += t - s, B[s + 1] -= t - s;
			B[s + 1] += 1 + t, B[t + 1] -= 1 + t;
			C[s + 1] -= 1, C[t + 1] += 1;
			B[t + 1] += t - s, B[M + 1] -= t - s;
		}
		else {
			B[t + 1] += t + M - s; B[s + 1] -= t + M - s;
			B[s + 1] += 1 + t + M; B[M + 1] -= 1 + t + M;
			C[s + 1]--, C[M + 1]++;
			B[0] += 1 + t; B[t + 1] -= 1 + t;
			C[0]--; C[t + 1]++;
		}
		/*REP(i, M + 1) {
			pe(B[i]);
		}cout << endl;*/
	}
	FOR(i,1, M + 1) {
		B[i] += B[i - 1];
		C[i] += C[i - 1];
	}
	FOR(i, 1, M + 1) {
		C[i] *= i;
	}
	/*FOR(i, 1, M + 1) {
		pe(C[i]);
	}cout << endl;*/
	int ans = INF;
	FOR(i, 1, M + 1) {
		//pe(B[i]);
		ans = min(ans, B[i] + C[i]);
	}
	//cout << endl;
	print(ans);
}


Measured memory_bytes: 2560
N = list(map(int, list(input())))

dp=[[-1,-1] for i in range(len(N)+1)]
dp[0]=[0,1]
b=0
N.insert(0,0)

for i in range(1,len(N)):
    up = 10-N[i]
    dp[i][0]=min(dp[i-1][0]+N[i],dp[i-1][1]+up)
    dp[i][1] = min(dp[i-1][0]+N[i]+1, dp[i-1][1]+up-1)
   

print(dp[-1][0])


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

bool is_kisu(int n)
{
        return n & 1;
}

int main()
{
        int n, ans = 0;
        std::vector<int> vec, vec2;

        std::cin >> n;
        
        for(int i = 0;i < n;i++){
                int tmp;
                std::cin >> tmp;
                if(!is_kisu(tmp))
                        vec.push_back(tmp);
        }

       std::for_each(std::begin(vec), std::end(vec), [&](int i)
       {
               int tmp_ans = 0;
               while(!is_kisu(i)){
                       i /= 2;
                       tmp_ans++;
               }
               ans += tmp_ans;
       });

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

}



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll A, B, C, X;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;

    ll ans = 0;
    for(ll i=0; i<=A; i++){
        for(ll j=0; j<=B; j++){
            ll diff = (X-500*i-100*j)/50;
            if(diff >=0 && diff <= C){
                ans++;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;
int n,m;
int check(int i,int j,vector <string> &s){
	int out = 0;
	for(int i0 = -1;i0 <= 1;++i0){
		for(int j0 = -1;j0 <= 1;++j0){
			if(i0 == 0 and j0 == 0) continue;
			if(i - i0 >= 0 and i - i0 < n and j - j0 >= 0 and j - j0 < m and s[i - i0][j - j0] == '#') ++out;
		}
	}
	return out;
}

void solve(){
	cin >> n >> m;
	vector <string> s(n);
	for(int i = 0;i < n;++i) cin >> s[i];
	for(int i = 0;i < n;++i){
		for(int j = 0;j < m;++j){
			if(s[i][j] == '#') cout << "#";
			else cout << check(i,j,s);
		}
		cout << newl;
	}

	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    ll ans = 1;
    ll before = -1;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        if (i >= k)
        {
            if (a[i - k] < a[i])
            {
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
        }
    }
}

Measured memory_bytes: 4764
import java.util.*;
import java.util.function.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int u = sc.nextInt();
    int v = sc.nextInt();
    int[] A = new int[N - 1];
    int[] B = new int[N - 1];
    for (int i = 0; i < N - 1; i++) {
      A[i] = sc.nextInt();
      B[i] = sc.nextInt();
    }
    sc.close();

    @SuppressWarnings("unchecked")
    List<Integer>[] tree = new List[N + 1];
    for (int i = 0; i < N - 1; i++) {
      if (tree[A[i]] == null) tree[A[i]] = new ArrayList<>();
      tree[A[i]].add(B[i]);
      if (tree[B[i]] == null) tree[B[i]] = new ArrayList<>();
      tree[B[i]].add(A[i]);
    }

    Function<Integer, int[]> dist = s -> {
      int[] d = new int[N + 1];
      Deque<Integer> q = new ArrayDeque<>();
      q.addLast(s);
      while (!q.isEmpty()) {
        int n = q.pollFirst();
        List<Integer> edge = tree[n];
        for (int e : edge) {
          if (d[e] == 0 && e != s) {
            d[e] = d[n] + 1;
            q.addLast(e);
          }
        }
      }
      return d;
    };

    int[] du = dist.apply(u);
    int[] dv = dist.apply(v);
    int ans = 0;
    for (int i = 1; i < N + 1; i++)
      if (du[i] < dv[i]) ans = Integer.max(ans, dv[i]);
    System.out.println(ans - 1);
  }
}

Measured memory_bytes: 83380
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;

bool cmpf(const pair<string, lli> left, const pair<string, lli> right) {
	return left.first < right.first;
}
bool cmps(const pair<string, lli> left, const pair<string, lli> right) {
	return left.second < right.second;
}
using namespace std;
lli n, m, p;



int main() {
	cin >> n;
	string s;
	vector<string> vec(n);
	rep0(i, n) {
		cin >> vec[i];
		sort(all(vec[i]));
	}
	sort(all(vec));
	lli  ans = 0,temp=0;
	vector<lli> ansvec;
	rep0(i, n) {
		ansvec.push_back(1);
		int j;
		for (j = i+1; j < n; j++) {
			if (vec[i] != vec[j])break;
			ansvec[temp]++;
		}
		temp++;
		i = j-1;
	}
	for (auto e : ansvec)ans += e * (e - 1) / 2;
	cout << ans;
}


Measured memory_bytes: 8444
#include<iostream>
#include<vector>
#include<algorithm>
#define f first
#define s second
#define inf 1000000001
using namespace std;

int main()
{
  int N,m,c,d;
  vector<pair<int,int> > V;
  cin>>N>>m;
  for(int i=0;i<m;i++){
    cin>>c>>d;
    V.push_back(make_pair(c,d));
  }

  sort(V.begin(),V.end());
  
  V.push_back(make_pair(inf,inf));
  for(int i=0;i<V.size()-1;i++){
    if(V[i+1].f<=V[i].s && V[i].s<=V[i+1].s){
      V[i].s=V[i+1].s;
      V.erase(V.begin()+i+1);
      i--;
    }
    if(V[i].f<=V[i+1].f && V[i+1].s <=V[i].s){
      V.erase(V.begin()+i+1);
      i--;
    }
  }
  /*
  cout<<endl;
  for(int i=0;i<V.size();i++)cout<<V[i].f<<" "<<V[i].s<<" "<<i<<endl;
  */
  int ans=N+1;
  for(int i=0;i<V.size();i++){
    ans+=2*(V[i].s-V[i].f);
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

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

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

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

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;
const int mod = 1000000007;
struct mint {
    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;
    }

    friend std::istream &operator>>(std::istream &in, mint &o) {
        ll a;
        in >> a;
        o = a;
        return in;
    }

    friend std::ostream &operator<<(std::ostream &out, const mint &o) {
        out << o.x;
        return out;
    }

};

int main() {
    int w, h;
    cin >> w >> h;

    set<ll> horizontal, vertical;
    rep(i, w) cin >> horizontal;
    rep(i, h) cin >> vertical;
    vector<int> dp;
    int d_w = 0, d_h = 0;
    for (int t = w * h; t >= 1; t--) {
        if (contain(horizontal, t) && contain(vertical, t)) {
            dp.push_back(1);
            d_w++;
            d_h++;
        } else if (contain(horizontal, t)) {
            dp.push_back(d_h);
            d_w++;
        } else if (contain(vertical, t)) {
            dp.push_back(d_w);
            d_h++;
        } else {
            int f = w * h - t;
            int area = d_w * d_h;
            int ok = max(area - f, 0);
            dp.push_back(ok);
        }
    }
    mint ans = 1;
    for (int p : dp) ans *= p;
    cout << ans << endl;

}


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

int main (){
	int r,g,b;
	cin>>r>>g>>b;
	int a=100*r+10*g+b;
	if(a%4==0){
		cout<<"YES";
	}else{
		cout<<"NO";
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int H, W;
string A[101];
#define NO "No"
#define YES "Yes"
//--------------------------------------------------------------------------------------------------
string solve() {
    map<char, int> cnt;
    rep(y,H) rep(x,W) cnt[A[y][x]]++;
 
    if (H % 2 == 0 && W % 2 == 0) {
        for(auto p: cnt) if (p.second % 4) return NO;
        return YES;
    }
 
    if (H % 2 && W % 2) {
        map<int, int> c;
        for(auto p: cnt) c[p.second % 4]++;
        if (c[3]) return NO;
        if (c[1] != 1) return NO;
        if (c[2] > (H - 1) / 2 + (W - 1) / 2) return NO;
        return YES;
    }
 
    if (W % 2) swap(H, W);
 
    map<int, int> c;
    for(auto p: cnt) c[p.second % 4]++;
    if (c[1] || c[3]) return NO;
    if (c[2] > W / 2) return NO;
    return YES;
}
//--------------------------------------------------------------------------------------------------
int main() {
    cin >> H >> W;
    rep(y,H) cin >> A[y];
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimze("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll inf=1e18, N=100005;
ll dp[N][2];
vector<ll> adj[N];
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (1LL*x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll powMod(ll base,ll expo){
	if(base==0)return 0;
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base); 
		expo>>=1;
	}
	return ans;
}
void dfs(ll node,ll p){
	dp[node][0]=dp[node][1]=1;
	for(auto i : adj[node]){
		if(i==p)continue;
		dfs(i,node);
		rep(j,0,2){
			ll tmp=0;
			rep(k,0,2){
				if(j==k and j==1)continue;
				tmp=add(tmp,dp[i][k]);
			}
			dp[node][j]=mult(dp[node][j],tmp);
		}
	}
}
void solve(){
	ll n, x, y;
	cin>>n;
	rep(i,1,n){
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	dfs(1,0);
	cout<<add(dp[1][0],dp[1][1]);
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int m, n; cin >> m >> n;
    if(m == 0) break;
    vector<bool> v(1000000000, false);
    FOR(i, m, 100000000) {
      if(!v[i]) {
        // cout << i << ":" << v[i] <<  endl;
        n--;
        for(int j = i;j <= i+10000000; j += i) {

          v[j] = true;
        }
      }
      if(n == 0) break;
    }
    FOR(i, m, 100000000) {
      if(!v[i]) {
        cout << i << endl;
        break;
      }
    }
  }
}



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

lli n, m;

int main(void){
	cin >> n >> m;
	vector<lli> x(m);
	rep(i, m) cin >> x[i];
	sort(x.begin(), x.end());
	if(m == 1){
		cout << 0 << endl;
		return 0;
	}
	vector<lli> e(m-1);
	rep(i, m-1) e[i] = abs(x[i+1]-x[i]);
	sort(e.begin(), e.end());
	lli ans = 0;
	rep(i, m-n) ans+=e[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4760
steps = list(input())
def test(ss):
    odd = set("RUD")
    even = set("LUD")
    for i, s in enumerate(ss):
        num = i+1
        if num%2:
            if s not in odd:
                return "No"
        elif s not in even:
            return "No"
    return "Yes"
print(test(steps))
            



Measured memory_bytes: 2940
# C - Traveling Salesman around Lake
K, N = map(int, input().split())
A = list(map(int, input().split()))

dist = []
for i in range(N-1):
    dist.append(abs(A[i] - A[i+1]))
dist.append(abs(K - A[-1] + A[0]))
dist = sorted(dist, reverse=True)
print(sum(dist[1:]))

Measured memory_bytes: 105692
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = read().rstrip().decode('utf-8')

def F(S):
    yield int(S)
    for i in range(len(S)-1):
        left = S[:i+1]
        right = S[i+1:]
        x = int(left)
        for y in F(right):
            yield x + y

answer = sum(F(S))
print(answer)

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int x=1, y=1, s=1;
    while(x != 0){
        cin >> x >> y >> s;
        if(x == 0) break;
        int ma = 0;
        for(int i = 1; i <= s; ++i){
            for(int j = s; j >= 1; --j){
                if(i*(100+x)/100 + j*(100+x)/100 < s) break;
                if(i*(100+x)/100 + j*(100+x)/100 > s) continue;
                ma = max(ma, i*(100+y)/100 + j*(100+y)/100);
            }
        }
        cout << ma << "\n";
    }
    return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;

int main() {
	int n, lp1, lp2;
	vector<string> w;
	cin >> n;
	w.resize(n);
	for (lp1 = 0; lp1 < n; lp1++) {
		cin >> w[lp1];
	}
/*	for (lp1 = 0; lp1 < n; lp1++) {
		cout << w[lp1] << endl;
	}
	*/
	for (lp1 = 1; lp1 < n; lp1++) {
		if (w[lp1 - 1][w[lp1-1].size() - 1] == w[lp1][0]) {
			for (lp2 = 0; lp2 < lp1; lp2++) {
				if (w[lp2] == w[lp1]) {
					cout << "No" << endl;
					return(0);
				}
			}
		}
		else {
			cout << "No" << endl;
			return(0);
		}
	}
	cout << "Yes" << endl;
	return(0);
}


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 1010000
struct UnionFind{
    vector<int> par,sizes;
    UnionFind(int n):par(n+1),sizes(n+1,1){
        rep2(i,1,n)par[i]=i;
    }
    int find(int x){
        return (x==par[x]?x:par[x]=find(par[x]));
    }
    void unite(int x,int y){
        x=find(x);y=find(y);
        if(x==y)return ;
        if(sizes[x]<sizes[y]){
            swap(x,y);
        }
        par[y]=x;
        sizes[x]+=sizes[y];
    }
    bool same(int x,int y) {return (find(x)==find(y));}
    int size(int x) {return sizes[find(x)];}
};

main(){
  ll n=in(),m=lin();
  int q=in();
  UnionFind uf(n);
  vector<pii> v;
  rep(i,q){
    int a,b,c;
    cin>>a>>b>>c;
    if(!c){
      uf.unite(a,b);
    }
    else v.pb({a,b});
  }
  bool flag=true;
  for(auto e:v){
    if(uf.same(e.first,e.second))flag=false;
  }
  ll cnt=0;
  rep(i,n){
    if(uf.par[i]==i)cnt++;
  }
  if(v.size()>0&&(m==n-1)){
    flag=false;
  }
  if(m>n+cnt*(cnt-3ll)/2ll)flag=false;
  cout<<(flag?"Yes":"No");
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

int main() {
    int  m, f, r;
    char grade;
    int  ary[50][3] = {};
    rep(i, 50) {
        cin >> m >> f >> r;
        ary[i][0] = m;
        ary[i][1] = f;
        ary[i][2] = r;
        if (m == -1 && f == -1 && r == -1) break;
    }

    rep(i, 50) {
        if (ary[i][0] == -1 || ary[i][1] == -1) {
            grade = 'F';
        } else if (ary[i][0] + ary[i][1] >= 80) {
            grade = 'A';
        } else if (ary[i][0] + ary[i][1] >= 65 && ary[i][0] + ary[i][1] < 80) {
            grade = 'B';
        } else if (ary[i][0] + ary[i][1] >= 50 && ary[i][0] + ary[i][1] < 65) {
            grade = 'C';
        } else if (ary[i][0] + ary[i][1] >= 30 && ary[i][0] + ary[i][1] < 50) {
            if (ary[i][2] >= 50) {
                grade = 'C';
            } else {
                grade = 'D';
            }
        } else if (ary[i][0] + ary[i][1] < 30) {
            grade = 'F';
        }
        if (ary[i][0] == -1 && ary[i][1] == -1 && ary[i][2] == -1) break;
        cout << grade << "\n";
    }

    return 0;
}



Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    ll n;
    cin >> n;
    vector<vector<ll>> a(n, vector<ll>(0));
    rep(i, n)rep(j, n-1){
        ll a_i;
        cin >> a_i;
        a[i].push_back(a_i-1);
    }
    ll mx = n*(n-1)/2;

    vector<ll> cnt(1010, 0);
    queue<ll> q;
    rep(i, n)q.push(i);
    ll days = 0;

    while(!q.empty()){
        queue<ll> q2;
        while(!q.empty()){
            ll i = q.front();
            ll j = a[i].front();
            q.pop();
            if(cnt[i]<=days && !a[i].empty() && a[j].front()==i && cnt[j]<=days){
                cnt[i] = cnt[j] = days+1;
                q2.push(i);
                q2.push(j);
                a[i].erase(a[i].begin());
                a[j].erase(a[j].begin());
                mx--;
            }
        }
        days++;
        swap(q, q2);
        if(mx == 0)break;
    }
    if(mx > 0)cout << -1 << endl;
    else cout << days << endl;

}

Measured memory_bytes: 8320
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string str1,str2;
    cin>>str1>>str2;
    bool ok = true;
    ll n=str1.length(),i;
    for(i=0;i<n;i++){
        if(str1[i]!=str2[i]){
            ok = false;
            break;
        }
    }
    if(ok)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <ctime>
#define ESP 1e-10
using namespace std;
int main() {
	for (int i = 0; i < 1000000000; i++) {
		int j = i;
	}
	while (true) {
		int H, W; cin >> H >> W;
		if (H == 0 && W == 0) {
			break;
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W;j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}


}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
using namespace std;
int main(){
  int count = 0, n, d, x, y;
  double dis;
  cin >> n >> d;
  for(int i = 0; i < n; i++){
    cin >> x >> y;
    dis = sqrt(pow(x, 2) + pow(y, 2));
    if(dis <= d)count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3676
// Created by sz
#include <bits/stdc++.h>
using namespace std;

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int N,K,X,Y;
    cin>>N>>K>>X>>Y;
    if(N<=K)cout<<N*X<<endl;
    else{
        cout<<X*K +(N - K)*Y<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
N,a,b = map(int,input().split())
mod = 10**9+7
inv_t = [0]+[1]
for i in range(2,b+1):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]

def cmb(n, r):
    res = 1
    aaa = 1
    for i in range(r):
        res = res *(n-i) * inv_t[i+1]  %mod
    return res % mod

ans = pow(2,N,mod)-1-cmb(N,a)-cmb(N,b)
print(ans%mod)

Measured memory_bytes: 52720
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#define ll long long
using namespace std;

const int mod=1000000007;
const int N=100005;

int n,k,l,r,ans;
ll x,y;
int dp1[N],dp2[N],f[2][N],p1[N],p2[N];
ll a[N];

void add(bool b,int x,int y){
	for (;x<=n+2;x+=x&-x){
		f[b][x]+=y;
		(f[b][x]>=mod)?f[b][x]-=mod:0;
	}
}

int query(bool b,int x){
	int s=0;
	for (;x;x-=x&-x){
		s+=f[b][x];
		(s>=mod)?s-=mod:0;
	}
	return s;
}

int ask(bool b,int x,int y){
	int s;
	if (x>y) return 0;
	s=(query(b,y)-query(b,x-1)+mod)%mod;
	return s;
}

int main(){
	scanf("%d%lld%lld",&n,&x,&y);
	if (x>y) swap(x,y);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	l=r=n;
	for (int i=n;i>=1;i--){
		if (a[i+1]-a[i]<x) l=i;
		if (a[i+1]-a[i]<y) r=i;
		p1[i]=l;
		p2[i]=r;
	}
	for (int i=n;i>1;i--){
		if (p2[i]==n) dp1[i]=1;
		if (p1[i]==n) dp2[i]=1;
		
		l=lower_bound(a+1,a+1+n,a[i-1]+x)-a; l=max(l,i+1);
		r=p2[i]+1;
		dp1[i]+=ask(1,l,r);
		(dp1[i]>=mod)?dp1[i]-=mod:0;
		
		l=lower_bound(a+1,a+1+n,a[i-1]+y)-a; l=max(l,i+1);
		r=p1[i]+1;
		dp2[i]+=ask(0,l,r);
		(dp2[i]>=mod)?dp2[i]-=mod:0;
		
		add(0,i,dp1[i]);
		add(1,i,dp2[i]);
		if (p1[1]>=i-1) ans+=dp1[i];
		(ans>=mod)?ans-=mod:0;
		if (p2[1]>=i-1) ans+=dp2[i];
		(ans>=mod)?ans-=mod:0;
	}
	if (p1[1]==n) ans++;
	if (p2[1]==n) ans++;
	ans%=mod;
	printf("%d\n",ans);
	return 0;
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << (a) << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

const int N = 5050;
const int MOD = 1e9 + 7;

int n, comb[N][N], fact[N];
vi adj[N];

int sz[N], pref[N];
void dfs(int u, int p) {
    sz[u] = 1;
    pref[u] = -1;
    for (int v : adj[u]) if (v != p) {
        dfs(v,u);
        sz[u] += sz[v];
        if (pref[u] == -1 || (sz[v] > sz[pref[u]])) pref[u] = v;
    }
}

int dp[N][N];

void add(int &x, int y) { 
    x += y;
    if (x >= MOD) x -= MOD;
}

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

    cin >> n;
    forn(_,n-1) {
        int u,v; cin >> u >> v;
        u--; v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    for (int x = 0; x <= n; x++) {
        comb[x][0] = 1;
        for (int y = 1; y <= x; y++) {
            comb[x][y] = comb[x-1][y-1] + comb[x-1][y];
            if (comb[x][y] >= MOD) comb[x][y] -= MOD;
        }
    }
    fact[0] = 1; for (int x = 1; x <= n; x++) fact[x] = ll(x) * fact[x-1] % MOD;

    dfs(0,-1);
    int c = 0;
    while (pref[c] != -1 && sz[pref[c]]*2 > n) c = pref[c];

    int sz = 1, ind = 1; dp[0][0] = 1;
    for (int v : adj[c]) {
        dfs(v,c);
        int n = ::sz[v];
        forn(k,n+1) {
            ll coef = (ll) fact[k] * comb[n][k] % MOD * comb[n][k] % MOD;
            forn(j,sz) add(dp[ind][j+k], (ll) dp[ind-1][j] * coef % MOD);
        }
        sz += n;
        ind++;
    }
    //forn(i,sz) cerr << dp[ind-1][i] << ' '; cerr << endl;

    ll ans = 0;
    forn(k,sz) {
        auto val = (ll) dp[ind-1][k] * fact[n-k] % MOD;
        if (k&1) ans -= val; else ans += val;
    }
    ans %= MOD; if (ans < 0) ans += MOD;
    cout << ans << endl;

    return 0;
}


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

int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; ++i)
    {
        if (i % k == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

ll solve(ll X, ll Y){
  ll ret = 0;
  while(X <= Y){
    ret++;
    X *= 2;
  }
  return ret;
}


int main(){
  ll X, Y;
  cin >> X >> Y;

  ll ret = -1;
  while(true){
    ll res = solve(X, Y);
    if(res <= ret) break;
    ret = max(ret, res);
    X++;
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)

dp = Array.new(n, 10 ** 9)
dp[0] = 0
dp[1] = (h[0] - h[1]).abs

(2..(n - 1)).each do |i|
  (([0, i - k].max)..(i - 1)).each do |j|
    c = dp[j] + (h[j] - h[i]).abs
    dp[i] = c if c < dp[i]
  end
end

puts dp[-1]


Measured memory_bytes: 13316
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;
int main(){
  int N;
  cin>>N;
  int ans = 0;
  for(int i = 1;i<=N;i++){
    string s = to_string(i);
    if(s.size()%2 == 1){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	a := io.NextInt()
	io.Println(a + a*a + a*a*a)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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

    vector<vector<int>> G(n+1, vector<int>());
    rep(i, m){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> ans(n+1), dist(n+1, INF);
    queue<int> que;
    que.push(1);
    dist[1] = 0;
    while(que.size() != 0){
        int v = que.front();
        que.pop();
        for(auto nv: G[v]){
            if(dist[nv] > dist[v]+1){
                que.push(nv);
                dist[nv] = dist[v] + 1;
                ans[nv] = v;
            }
        }
    }

    cout << "Yes" << endl;
    for(int i=2; i<=n; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 10660
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

map<string,int>mep;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    int n;
    cin>>n;
    while(n--){
    	string s;
    	cin>>s;
    	mep[s]++;
    }

    cout << "AC x " << mep["AC"] << endl;
    cout << "WA x " << mep["WA"] << endl;
    cout << "TLE x " << mep["TLE"] << endl;
    cout << "RE x " << mep["RE"] << endl;

    return 0;
}


Measured memory_bytes: 3664
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
const int MOD = 1000000007;
int rui(int a, int b) {
    if(b == 0) {
        return 1;
    }
    return rui(a, b - 1) * a;
}
int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> a(N + 1);
    rep(i, 0, M) {
        int aa;
        cin >> aa;
        a[aa] = 1;
    }
    int mae = 0;
    int ato = 0;
    rep(i, 0, X) { mae += a[i]; }
    rep(i, X, N) { ato += a[i]; }
    cout << min(mae, ato) << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

n = int(input())
m = [1,1]
if n == 0:
    print(1)
elif n == 1:
    print(1)
else:
    for i in range(2, n+1):
        m.append( m[i-1] + m[i-2] )
    print(m.pop())


Measured memory_bytes: 5604
#include<iostream>
#include<cstdlib>

using namespace std;

struct Node {
	int key;
	Node *parent;
	Node *left;
	Node *right;
};
Node* NIL;
Node* root = NIL;

void insert(Node* rot, int key)
{
	Node* z = (Node*)malloc(sizeof(Node));
	z->key = key;
	z->parent = NIL;
	z->left = NIL;
	z->right = NIL;

	Node* y = NIL;
	Node* x = rot;
	while (x != NIL)
	{
		y = x;
		if (key > x->key)
			x = x->right;
		else
			x = x->left;
	}

	z->parent = y;

	if (y == NIL)
		root = z;
	else if (key < y->key)
		y->left = z;
	else
		y->right = z;
}
Node* find(Node* rot, int key)
{

	Node* x = rot;
	while (x != NIL)
	{
		if (x->key == key)
			return x;
		if (key > x->key)
			x = x->right;
		else
			x = x->left;
	}
	return x;
}
void inOrder(Node* x)
{
	if (x->left != NIL)
		inOrder(x->left);

	cout << ' ' << x->key;

    if(x->right != NIL)
		inOrder(x->right);
}
void preOrder(Node* x)
{
	cout << ' ' << x->key;

	if (x->left != NIL)
		preOrder(x->left);

	if (x->right != NIL)
		preOrder(x->right);
}
int main()
{
	int n,key;
	char C[10];

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> C;
		if (C[0] == 'i')
		{
			cin >> key;
			insert(root, key);
		}
		else if(C[0] == 'p')
		{
			inOrder(root);
			cout << endl;
			preOrder(root);
			cout << endl;
		}
		else                  //find key;
		{
			cin >> key;
			if (find(root, key) != NIL)
				cout << "yes" << endl;
			else
				cout << "no" << endl;
		}
	}
	return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}

int main()
{
  string A;
  cin >> A;
  if (A[1] == A[2] && (A[0] == A[1] || A[2] == A[3]))
  {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0033
{
    class Program
    {
        static int _ballNum = 10;
        static List<int> _pipeLeft = new List<int>();
        static List<int> _pipeRight = new List<int>();
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; ++i)
            {
                _pipeLeft = new List<int>();
                _pipeRight = new List<int>();
                _pipeLeft.Add(0);
                _pipeRight.Add(0);
                int[] ballOrder = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                PipesAndBalls(ballOrder);
                if (_pipeLeft.Count() + _pipeRight.Count() - 2 == _ballNum)
                    Console.WriteLine("YES");
                else
                    Console.WriteLine("NO");
            }
        }
        public static void PipesAndBalls(int[] ballOrder)
        {
            _pipeLeft.Add(ballOrder[0]);

            for (int i = 1; i < ballOrder.Length; ++i)
            {
                if (ballCheck(ballOrder[i]))
                {
                    if (ballOrder[i] - _pipeLeft.Last() < ballOrder[i] - _pipeRight.Last())
                        _pipeLeft.Add(ballOrder[i]);
                    else
                        _pipeRight.Add(ballOrder[i]);
                }
                else if (ballOrder[i] - _pipeLeft.Last() > 0)
                {
                    _pipeLeft.Add(ballOrder[i]);
                }
                else if (ballOrder[i] - _pipeRight.Last() > 0)
                {
                    _pipeRight.Add(ballOrder[i]);
                }
                else
                    break;
            }
        }
        public static bool ballCheck(int ballOrder)
        {
            if (ballOrder > _pipeLeft.Last() && ballOrder > _pipeRight.Last())
                return true;

            return false;
        }
    }
}


Measured memory_bytes: 18292
n=input()
ans1, ans2="No", "No"
ans3, ans4="No", "No"
if 'N' in n:
  if 'S' in n:
    ans1="Yes"
if 'S' in n:
  if 'N' in n:
    ans2="Yes"
if 'E' in n:
  if 'W' in n:
    ans3="Yes"
if 'W' in n:
  if 'E' in n:
    ans4="Yes"
if "W" not in n and "E" not in n:
    ans3, ans4 = "Yes", "Yes"
if "N" not in n and "S" not in n:
    ans1, ans2 = "Yes", "Yes"
if ans1=="Yes" and ans2=="Yes" and ans3=="Yes" and ans4=="Yes":
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,y,z;
    cin>>x>>y>>z;
    while(x!=-1||y!=-1||z!=-1){
        if(x==-1||y==-1){
            cout<<'F'<<endl;
        }
        else if(x+y>=80){
            cout<<'A'<<endl;
        }
        else if(x+y>=65){
            cout<<'B'<<endl;
        }
        else if(x+y>=50){
            cout<<'C'<<endl;
        }
        else if(x+y>=30){
            if(z>=50){
                cout<<'C'<<endl;
            }
            else{
                cout<<'D'<<endl;
            }
        }
        else{
            cout<<'F'<<endl;
        }
        cin>>x>>y>>z;
    }
}


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

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

    int ans = -(1<<30);
    for (int i=0; i<n; i++) {
      int sum = 0;
      for (int j=i; j<n; j++) {
        sum += x[j];
        ans = max(ans, sum);
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<string>

const std::string str = "2019/04/30";

int main(){
    
    std::string s;

    std::cin >> s;

    if(s > str){
        std::cout << "TBD" << std::endl;
    }else{
        std::cout << "Heisei" << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#                         author:  kagemeka 
#                         created: 2019-11-06 16:18:30(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    c = [[int(x) for x in sys.stdin.readline().split()] for _ in range(3)]
    n = 3  # able to deal with n x n
    d = []
    for i in range(1, n):
        d0i = c[0][i] - c[0][0]
        d.append(d0i)
    for i in range(1,n):
        for j in range(1, n):
            if c[i][j] - c[i][0] == d[j-1]:
                continue
            else:
                print('No')
                exit()
    print('Yes')

if __name__ == "__main__":
    # execute only if run as a script
    main()


Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) repU(i,0,(n) - 1)
#define rep1(i,n) repU(i,1,(n))
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define qceil(n,d) ((n) > 0 ? ((n) - 1) / (d) + 1 : (n) / (d))
#define parity(a,b) (a & 1 ^ b & 1 ^ 1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<db,int> pdi;

const pii dir[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int mod = 1e9 + 7;
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;

template<class Abel> struct BItree {
	int range;
	vector<Abel> data_;
	
	BItree(int size_, Abel val = 0) : range(size_ + 1)
	{
		init(range,val);
	}
	
	void init(int n, int val) {
		data_.assign(n,val);
	}
	
	Abel sum(int r) {
		Abel s = 0;
		while (r) {
			s += data_[r];
			r -= r & -r;
		}
		return s;
	}
	
	Abel sum(int l, int r) { return sum(r) - sum(l - 1); }
	
	void add(int idx, Abel diff) {
		while (idx < range) {
			data_[idx] += diff;
			idx += idx & -idx;
		}
	}
	
	void update(int idx, Abel val) { 
		int prev = sum(idx, idx);
		add(idx, val - prev);
	}
	
	int lower_bound(Abel obj) {
		int lower = 0;
		int upper = range;
		while (upper - lower > 1) {
			int mid = (lower + upper) / 2;
			if(sum(mid) < obj) lower = mid;
			else upper = mid;
		}
		return upper;
	} 
	
	int upper_bound(Abel obj) {
		int lower = 0;
		int upper = range;
		while (upper - lower > 1) {
			int mid = (lower + upper) / 2;
			if(sum(mid) > obj) upper = mid;
			else lower = mid;
		}
		return upper;
	} 
};



ll N,M,Q,K,L;
string S;
int a[100010],tmp[100010],s[100010];

bool ch(int x){
	rep(i,N) tmp[i] = 2 * (x <= a[i]) - 1;
	BItree<int> bt(N * 2 + 2);
	ll cnt = 0;
	s[0] = 0;
	bt.add(N + 1,1);
	rep(i,N) s[i + 1] = s[i] + tmp[i],cnt += bt.sum(N + 1 + s[i + 1]),bt.add(N + 1 + s[i + 1],1);
	return cnt >= (N * (N + 1) / 2 + 1) / 2;
}

int solve(){
	int l = 0;
	int r = inf32;
	while(r - l > 1){
		int m = (l + r) / 2;
		if(ch(m)) l = m;
		else r = m;
	}
	return l;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N;
	rep(i,N) cin >> a[i];
	cout << solve() << endl;
}






Measured memory_bytes: 2188