akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }


/*
<url:>
問題文============================================================

=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = __builtin_popcount(N);
    
    int x = 1;
    
    while(x <= N) x<<=1;
    ans = max(ans,__builtin_popcount(min(x-1,N)));
    x>>=1;
    ans = max(ans,__builtin_popcount(x-1));
    cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3216
#include "bits/stdc++.h"
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args>
void dbg(Args&&... args) {
  using expander = int[];
  (void)expander {0,(static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {exit(0);}

string s, t;

void input() {
  getline(cin, s);
  getline(cin, t);
}

void solve() {
  s += s;
  if (s.find(t) != string::npos) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

int main() {
#ifdef DEBUG
  freopen("input", "r", stdin);
  //  freopen("output", "w", stdout);
  //  gen();
#endif
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int a; int b;
    cin >> a >> b;
    if (a <= b)
        cout << a << endl;
    else
        cout << a - 1 << endl;

}


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

using namespace std;

int a[101];
int N, ans;

static inline bool valid(int i, int j, int k)
{
    if(a[i] == a[j] || a[j] == a[k] || a[i] == a[k])
        return false;

    return (a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i]);
}

int main()
{
    cin >> N;

    for(int i = 1; i <= N; ++i)
        cin >> a[i];

    sort(a + 1, a + N + 1);

    for(int i = 1; i <= N - 2; ++i)
        for(int j = i + 1; j <= N - 1; ++j)
            for(int k = j + 1; k <= N; ++k)
                if(valid(i,j,k))
                    ans++;

    cout << ans;
    return 0;
}


Measured memory_bytes: 3576
//#include <ext/pb_ds/assoc_container.hpp> 
    // #include <ext/pb_ds/tree_policy.hpp> 
    #include <iostream>
    #include <iomanip>
    #include <sstream>
    #include <cstring>
    #include <vector>
    #include <deque>
    #include <queue>
    #include <set>
    #include <map>
    #include <valarray>
    #include <iterator>
    #include <functional>
    #include <limits>
    #include <algorithm>
    #include <numeric>
    #include <cmath>
    #include <cassert>
    #include <unordered_map>
    #include <unordered_set>
    #include <stack>
    using namespace std;
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define trace(x) cerr << #x << ": " << x << " " << endl;
     
    typedef int64_t ll;
     
    #define endl '\n'
    #define int ll
    ll mod=1e17;
    ll mod1=1e9+5;
     
    ll power(ll a,ll b)
    {
        if(b==0) return 1;
        else if(b%2==0)
            return power((((a%mod)*(a%mod))%mod),b/2)%mod;
        else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
    }
     
    // using namespace __gnu_pbds;
    // #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
    //find_by_order(k)  returns iterator to kth element starting from 0;
    //order_of_key(k) returns count of elements strictly smaller than k;
    //erase,insert same as normal set
     int h,n;
       pair<int,int> p[1000+1];
       int dp[20001][1001];
        vector<pair<double,int>> v;
    int solve(int sum,int i)
    {
        if(sum>=h)
            return 0;
        if(i==n+1)
        {
            return 1e15;
        }
        int &res=dp[sum][i];
        if(res!=-1)
            return res;
        res=1e15;
        
        int ind=v[i-1].second;
        int init=(h-sum)/(p[ind].first);
        for(int j=max(init-10,(ll)0);j<=(h-sum)/(p[ind].first)+10;++j)
        {
            res=min(res,(p[ind].second)*j+solve((p[ind].first)*j+sum,i+1));
        }
        return res;
    }
    int32_t main()
    {
        IOS

      
       cin>>h>>n;
     
       for(int i=1;i<=n;++i)
        cin>>p[i].first>>p[i].second;
   
    for(int i=1;i<=n;++i)
    {
        double x=(double)p[i].first/(double)p[i].second;
        v.push_back({x,i});
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());

    memset(dp,-1,sizeof(dp));
    cout<<solve(0,1);



    }       

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

const int64_t MOD= 1000000007;
const int Nfac= 400007;
#define MEMORY 1 // 1/0: 階乗を配列に格納をする前処理をする/しない
/* 剰余環 Z/nZ */
struct mint{ // Z/nZ に関する演算(n:素数の場合は除算も)をサポートする構造体
  int64_t rep; // 出力すべき代表元 rep \in {0,1,..,MOD- 1}
  mint(int64_t x=0): rep(((x%MOD)+ MOD)% MOD){}
  mint operator-() const { return mint(-rep);}
  mint& operator+=(const mint& x){
    rep+= x.rep; 
    if(rep>= MOD) rep-= MOD;
    return *this;
  }
  mint& operator-=(const mint& x){
    rep-= x.rep;
    if(rep< 0) rep+= MOD;
    return *this;
  }
  mint& operator*=(const mint& x){
    rep*= x.rep; rep%= MOD;
    return *this;
  }
  mint operator+(const mint x) const {
    mint ans(*this);
    ans+= x;
    return ans;
  }
  mint operator-(const mint x) const {
    mint ans(*this);
    ans-= x;
    return ans;
  }
  mint operator*(const mint x) const {
    mint ans(*this);
    ans*= x;
    return ans;
  }

  mint pow(int64_t d) const{ // d \geq 0
    if(d==0) return 1;
    else{
      mint ans= pow(d>>1);
      ans*= ans;
      if(d&1){ ans*= *this; }

      return ans;
    }
  }

  friend ostream& operator << (ostream &os, const mint& x) noexcept{
      return os << x.rep;
  }
  // MOD が素数(<=> Z/nZ が体)のとき
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint& x){
    *this *= x.inv();
    return *this;
  }
  mint operator/(const mint x) const {
    mint ans(*this);
    ans/= x;
    return ans;
  }
};

/* 階乗,二項係数 */
#if (MEMORY==1)
// 前処理として,階乗を配列に格納をするver.
vector<mint> mfac(Nfac+1), ifac(Nfac+1);
void fact_modp_init(int N= Nfac){
  mfac.at(0)= 1;
  mint buf;
  for(int i=1; i<=N; i++){
    buf= i;
    mfac.at(i)= mfac.at(i-1)* buf;
  }

  ifac.at(N)= mfac.at(N).inv();
  for(int i=N; i>0; i--){
    buf= i;
    ifac.at(i-1)= ifac.at(i)* buf;
  }
}
#else
// 前処理を回避するver.
void fact_modp_init(int N= Nfac){}
mint mfac(int N){
  mint ans= 1;
  mint buf;
  for(int i=1; i<=N; i++){
    buf= i;
    ans*= buf;
  }

  return ans;
}
#endif

mint binom_modp(int n, int k){
  if(n < 0 || min(k,n-k) < 0) return 0;
  else{
#if (MEMORY==1)
    return mfac.at(n)* ifac.at(k)* ifac.at(n-k);
#else
    return mfac(n)* mfac(k).inv()* mfac(n-k).inv();
#endif
  }
}
// ^^^ テンプレここまで ^^^
mint multiset_modp(int n, int r){
  if(n==0 && r==0) return 1;
  else{
    return binom_modp(n+r-1, r);
  }
}

int main() {
  int N,K;
  cin >> N >> K;
  fact_modp_init(Nfac);

  if(K >= N-1){
    cout << multiset_modp(N, N) << endl;
  }
  else if(K==1){ // K>1より実行されないが念の為
    mint n= N;
    cout << n*(n-1) << endl;
  }
  else{ 
    mint ans= 0;
    for(int k=0; k<=K; k++){
      ans+= binom_modp(N,k)* multiset_modp(N-k, k);
    }

    cout << ans << endl;
  }
}

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

using namespace std;

int main(){

	int N, X;

	cin >> N;

	X = N/100000000 + N/10000000%10 + N/1000000%10 + N/100000%10 + N/10000%10 + N/1000%10 + N/100%10 + N/10%10 + N%10;

	if ( N % X == 0 ){
		cout << "Yes" << endl;
	}

	else
		cout << "No" << endl;
}

Measured memory_bytes: 3568
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define readint ({int t;cin >> t;t;})

const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;

void _mod(ll &x) { x = mod(x, MOD); }

//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

int least[2010101], _least[2010101];
int Num[301];
vector<int> _Num;



class ExactChange {
public:

    void solve(std::istream &cin, std::ostream &cout) {
        int N;
        N = 1e6;
        rep(i, 0, 301)Num[i] = (i + 1) * (i + 2) * (i + 3) / 6;
        int j = 0;
        rep(i, 0, 301)if ((i + 1) * (i + 2) * (i + 3) / 6 & 1)_Num.push_back((i + 1) * (i + 2) * (i + 3) / 6);
        Fill(least, (int) 1e7);
        Fill(_least, (int) 1e7);
        least[0] = _least[0] = 0;
        _for(i, 301)
            _for(j, (int) 1e6 + 1)
                if (j + Num[i] <= N)
                    least[j + Num[i]] = min(least[j + Num[i]], least[j] + 1);

        _for(i, SZ(_Num))
            _for(j, (int) 1e6 + 1)
                if (j + _Num[i] <= N)
                    _least[j + _Num[i]] = min(_least[j + _Num[i]], _least[j] + 1);
        while (cin >> N && N) {
            cout << least[N] << " " << _least[N] << endl;
        };
    };

};


#undef int

int main() {
    ExactChange solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(0);
    ios::sync_with_stdio(0);
    out << fixed << setprecision(20);
    solver.solve(in, out);
    return 0;
}



Measured memory_bytes: 18844
N=int(input())
A=list(map(int,input().split()))
count=0
slope=0
for i in range(N-1):
  if A[i] < A[i+1]:
    if slope < 0:
      count+= 1
      slope = 0
    else:
      slope = 1
      
  elif A[i] > A[i+1]:
    if slope > 0:
      count+= 1
      slope = 0
    else:
      slope = -1
      
print(count+1)

Measured memory_bytes: 14224
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
#define int ll
using namespace std;             
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
int n;
vector <int> g[N];
ll d[N], t[N];
int len[N];
ll fac[N];
ll binpow (int x, int y) {
	if (y == 0) return 1ll;
	if (y % 2 == 0) {
		ll o = binpow (x, y / 2);
		return (o * o) % mod;
	}	
	return (binpow (x, y - 1) * x) % mod;
}
void dfs (int v, int p) {
	len[v] = 1;
	d[v] = 1;
	int all = 0, lla = 1;
	for (auto to : g[v]) {
		if (to != p) {
			dfs (to, v); 
			len[v] += len[to];
			all += len[to]; 
			lla *= fac[len[to]];
			lla %= mod;
			d[v] *= d[to];
			d[v] %= mod;
		}
	}
	d[v] *= fac[all];
	d[v] %= mod;
	d[v] = d[v] * binpow (lla, mod - 2);
	d[v] %= mod;
}
void go (int v, int p) {
	if (v != 1) {
		t[v] = t[p];
		int o = fac[n - len[v]];
		t[v] *= (fac[len[v]] * fac[n - 1 - len[v]] % mod);
		t[v] %= mod;
		t[v] *= binpow (d[v] * fac[n - 1] % mod, mod - 2);
		t[v] %= mod;
		for (auto to : g[v]) {
			if (to != p) {
				t[v] *= d[to];
				t[v] %= mod;
				o *= fac[len[to]];
				o %= mod;
			}
		}
		t[v] *= fac[n - 1];
		t[v] %= mod;
		t[v] *= binpow (o, mod - 2);
		t[v] %= mod;
	}
	for (auto to : g[v]) {
		if (to != p) {
			go (to, v);
		} 
	}

}
void solve () {
	cin >> n;
	fac[0] = 1;
	for (int i = 1; i <= n; i ++) fac[i] = (fac[i - 1] * i) % mod;
	for (int i = 1; i < n; i ++) {
		int l, r;
		cin >> l >> r;
		g[l].pb (r);
		g[r].pb (l);
	}
	dfs (1, -1);
	t[1] = d[1];
	go (1, -1);
	for (int i = 1; i <= n; i ++) {
		cout << t[i] << endl;
	}
}   	
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 20976
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)

int dp[100010][3]={0};

int main(){
    int n;cin>>n;
    int a[n][3];
    rep(i,0,n){cin>>a[i][0]>>a[i][1]>>a[i][2];}
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    rep(i,1,n){
        dp[i][0]=max(a[i][0]+dp[i-1][1],a[i][0]+dp[i-1][2]);
        dp[i][1]=max(a[i][1]+dp[i-1][0],a[i][1]+dp[i-1][2]);
        dp[i][2]=max(a[i][2]+dp[i-1][0],a[i][2]+dp[i-1][1]);
    }
    int maximum=max(dp[n-1][0],dp[n-1][1]);
    maximum=max(maximum,dp[n-1][2]);
    cout<<maximum<<endl;
    return 0;
}

Measured memory_bytes: 2560
n = int(input())
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
ans = 0

for i, bi in enumerate(reversed(b)):
    id = n-i
    if a[id] >= bi:
        ans += bi
    else:
        ans += a[id]
        bi -= a[id]
        id -= 1
        if a[id] >= bi:
            ans += bi
            a[id] -= bi
        else:
            ans += a[id]
            a[id] = 0

print(ans)


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

int main(){
	int n, a;
	while(cin >> n, n){
		n++;
		vector<int> t(n);
		t[0] = 0;
		for(int i = 1;i < n;i++){
			cin >> a;
			t[i] = max(t[i-1]+a, a);
		}
		cout << *max_element(t.begin()+1, t.end()) << endl;
	}
	return 0; 
}

Measured memory_bytes: 3028
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

  int a, b;
  cin >> a >> b;

  int ans = a + b;
  if (23 < ans) {
    ans = ans - 24;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    char A[3][3];
    REP(i,3){
        REP(j,3)cin>>A[i][j];
    }
    cout<<A[0][0]<<A[1][1]<<A[2][2]<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
  char list[][4] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
  char s[4];
  scanf("%s", s);
  for (int i = 0; i < 7; ++i) {
    if (strcmp(s, list[i]) == 0) {
      printf("%d\n", 7 - i);
      return 0;
    }
  }
}


Measured memory_bytes: 128
package main

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

func main() {
	sc = initScanner(os.Stdin)
	H := scanInt(sc)

	fmt.Println(resolve(H))
}

func resolve(H int) int {
	var count int

	index := 1
	for {
		count += index
		if H == 1 {
			break
		} else {
			H /= 2
		}
		index *= 2
	}

	return count
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}


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

int n=0, S=8191, H=8191, C=8191, D=8191;

int main() {
    cin >> n;
    char ta[n];
    int na[n];
    for (int i=0; i<n; i++) cin >> ta[i] >> na[i];
    for (int i=0; i<n; i++) {
        if (ta[i]=='S') {
            S=S-pow(2,na[i]-1);
        }
        if (ta[i]=='H') {
            H=H-pow(2,na[i]-1);
        }
        if (ta[i]=='C') {
            C=C-pow(2,na[i]-1);
        }
        if (ta[i]=='D') {
            D=D-pow(2,na[i]-1);
        }
    }
    for (int i=0; i<13; i++) {
        if (S%2==1) cout << "S " << i+1 << endl;
        S=S/2;
    }
    for (int i=0; i<13; i++) {
        if (H%2==1) cout << "H " << i+1 << endl;
        H=H/2;
    }
    for (int i=0; i<13; i++) {
        if (C%2==1) cout << "C " << i+1 << endl;
        C=C/2;
    }
    for (int i=0; i<13; i++) {
        if (D%2==1) cout << "D " << i+1 << endl;
        D=D/2;
    }
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N;
    vector<P> r(N), b(N); REP(i,N) cin >> r[i].second >> r[i].first;
    REP(i,N) cin >> b[i].first >> b[i].second;
    SORT(b); SORT(r); REVERSE(r);
    bool used[N]; REP(j,N) used[j] = false;
    int ans = 0;
    REP(i,N){
        REP(j,N){
            if(r[j].second < b[i].first && r[j].first < b[i].second && used[j] == false){
                ans++;
                used[j] = true;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void start_road(int sign_sx,int sign_sy,int sign_tx,int sign_ty);
void return_road(int sign_sx,int sign_sy,int sign_tx,int sign_ty);

int main(void)
{
    int sx,sy,tx,ty;
    char str[32];
    fgets(str,sizeof(str),stdin);
    sscanf(str,"%d%d%d%d",&sx,&sy,&tx,&ty);
    printf("U");
    int sign_sx=sx,sign_sy=sy+1,sign_tx=tx-1,sign_ty=ty;
    start_road(sign_sx,sign_sy,sign_tx,sign_ty);
    printf("RD");
    sign_sx=sx+1,sign_sy=sy,sign_tx=tx,sign_ty=ty-1;
    return_road(sign_sx,sign_sy,sign_tx,sign_ty);
    printf("LL");
    sign_sx=sx-1,sign_sy=sy,sign_tx=tx,sign_ty=ty+1;
    start_road(sign_sx,sign_sy,sign_tx,sign_ty);
    printf("DR");
    sign_sx=sx,sign_sy=sy-1,sign_tx=tx+1,sign_ty=ty;
    return_road(sign_sx,sign_sy,sign_tx,sign_ty);
    printf("U");
    return 0;
}

void start_road(int sign_sx,int sign_sy,int sign_tx,int sign_ty)
{
  int i;
  for(i=0;i<sign_ty-sign_sy;i++)
  {
    printf("U");
  }
  for(i=0;i<sign_tx-sign_sx;i++)
  {
    printf("R");
  }
}

void return_road(int sign_sx,int sign_sy,int sign_tx,int sign_ty)
{
  int i;
  for(i=0;i<sign_ty-sign_sy;i++)
  {
    printf("D");
  }
  for(i=0;i<sign_tx-sign_sx;i++)
  {
    printf("L");
  }
}

Measured memory_bytes: 128
//============================================================================
// Name        : ABC_A.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int main() {
	int N,Min;
	string S;
	int W[300000]={0},w=0,E[300000]={0},e=0;
	cin >> N;
	cin >> S;

	for(int i=0; i<N; i++){
		W[i]=w;
		if(S[i] == 'W'){
			w++;
		}
	}
	for(int i= N-1; i>=0; i--){
		E[i] = e;
		if(S[i]=='E'){
			e++;
		}
	}
	Min = E[0]+W[0];

	for(int i = 1; i<N; i++){
		Min = min(Min, W[i]+ E[i]);
	}
	cout << Min << endl; // prints !!!Hello World!!!
	return 0;
}


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

#define MAX_N (100001)
#define MAX_R (1000000)
#define max(x,y) ((x) > (y) ? (x) : (y))

void init(int data[],int n);
void updata(int data[],int k,int a,int n);
int query(int data[]);
int such(int data[],int k,int n);

int n_;

typedef struct{
  int d,t,x;
}Rec;

int main(){
  int score[4*MAX_N -1],time[4*MAX_N -1];
  int r,l,n;

  scanf("%d %d %d",&n,&r,&l);

  n_=n;
  n=1;
  while(n<n_) n*=2;

  init(score,n);
  init(time,n);
  
  int t_a=0,t_b=0;
  int k,t,d,x;
  for(int i=0;i<r;i++){

    scanf("%d %d %d",&d ,&t_a ,&x);

    k = such(score, 0, n);

    if(t_b==0) t = t_a;
    else     t = t_a - t_b;
    t_b = t_a;

    //printf("k=%d\n",k);
    updata(time, k, time[k+n-2]+t, n);

    //printf("b\n");
    updata(score, d, score[d+n-2]+x, n);
  

    /*printf("c");
    
    printf("\n---------------\n");

    printf("k = %d\n",k);
    for(int i=0;i<n-1;i++){
      printf("%d : score %d  time %d\n",i,score[i],time[i]);
    }
    printf("-  -  -  -\n");
    for(int i=n-1;i<n*2-1;i++){
      printf("%d : score %d  time %d\n",i,score[i],time[i]);
      }*/
    
  }

  k = such(score, 0, n);
  t = l-t_b;
  updata(time, k, time[k+n-2]+t, n);

  /*
  printf("\n---------------\n");
  
  printf("k = %d\n",k);
  for(int i=0;i<n;i++){
    printf("%d : score %d  time %d\n",i,score[i],time[i]);
  }
  printf("-  -  -  -\n");
  for(int i=n;i<n*2;i++){
    printf("%d : score %d  time %d\n",i,score[i],time[i]);
    }*/

  printf("%d\n",such(time,0,n));

}

void init(int data[],int n){
  for(int i=0;i<n*2-1;i++){
    data[i]=0;
  }
  return ;
}

void updata(int data[],int k,int a,int n){

  k=k+n-2;
  data[k]=a;
  
  while(k>0){
    k = (k-1)/2;

    data[k] = max(data[k*2+1] , data[k*2+2]);
  }

  return ;
}
    
int query(int data[]){
  return data[0];
}

int such(int data[],int k,int n){
 
  if(k>=n-1) return k-n+2; 

  if(data[k]==data[k*2+1]) return such(data,k*2+1,n);
  else if(data[k]==data[k*2+2]) return such(data,k*2+2,n);

}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> 
#include <iostream> 
using namespace __gnu_pbds; 
using namespace std; 
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
# define ll  long long int
# define ld  long double
# define pb push_back
# define pp pop_back
# define ff first
# define ss second
# define mp make_pair
# define ac accumulate
# define mod 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
int  main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    // #endif
   IOS;
  string x;
  cin>>x;
  ll cnt=0;
  for(ll i=0;i<x.size()/2;i++)
  {
    if(x[i]!=x[x.size()-1-i])
            cnt++;
  }
  cout<<cnt;
}

Measured memory_bytes: 256
#!/usr/bin/env python

import sys
import os

n = int(sys.stdin.readline())
s = 0

lenlist = map(int, sys.stdin.readline().strip().split(" "))
lenlist.sort()
for i in range(0,n):
    m = min(lenlist[2*i],lenlist[2*i+1])
    s += m

print s


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

using namespace std;
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a,b,x;
	//string s;
	cin >>a >>b >>x;
	
	if(x >=a && x <=a+b) puts("YES");
	else puts("NO");
	return 0;
	
}


Measured memory_bytes: 256
#encoding=utf-8
import sys

def inp():
    for line in sys.stdin:
        word = str(line[:-1])
        while True:
            tako = []
            for i in xrange(len(word) - 1):
                a = str(eval(word[i] + "+" +  word[i+1]))
                tako.append(a[-1])
            word =  "".join(tako)
            if len(word) == 1:
                break
        print word

if __name__ == "__main__":
    inp()

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

main(int argc, char const *argv[])
{
	int n,a,b,c,x;
	while(cin>>n>>a>>b>>c>>x,n)
	{
		int y[n+1];
		for (int i = 0; i < n; ++i) cin>>y[i];
		y[n]=-1;
		int now=0;
		if(x==y[0]) ++now;
		if(n==1&&now==1)
		{
			cout<<"0\n";
			continue;
		}
		int i;
		for (i = 0; i < 10000; ++i)
		{
			x=(a*x+b)%c;
			if(x==y[now]) ++now;
			if(now==n) break;
		}
		if(now==n) cout<<i+1<<endl;
		else cout<<"-1\n";
	}
	return 0;
}


Measured memory_bytes: 3080
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)
#define N 100010
vector<int>e[N];
int a[N];
vector<pair<int, int> >b;
int n;
int x, y, z;
bool c[N];
vector<int>ans;

int main() {
	scanf("%d", &n);
	f(i, n) {
		scanf("%d", &a[i]);
		b.push_back(make_pair(a[i], i));
		c[i] = false;
	}
	f(i, n - 1) {
		scanf("%d %d", &x, &y);
		x--;
		y--;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	sort(b.begin(), b.end());
	f(i, n) {
		f(j, e[b[i].second].size()) {
			if ((a[e[b[i].second][j]] < b[i].first) && (!c[e[b[i].second][j]])) {
				c[b[i].second] = true;
				ans.push_back(b[i].second + 1);
				break;
			}
		}
	}
	sort(ans.begin(), ans.end());
	f(i, ans.size()) {
		printf("%d", ans[i]);
		if (i < (ans.size() - 1))printf(" ");
		else printf("\n");
	}


	return 0;
}

Measured memory_bytes: 2688
def judge(s1, s2):
	if s1[0] == s2[2] and s1[1] == s2[1] and s1[2] == s2[0]:
		return 'YES'
	else: return 'NO'

s1 = raw_input()
s2 = raw_input()

print judge(s1, s2)

Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

int n, m;
vector<int> c(1e5+1, 0);
vector<bool> done(1e5+1, false);

int main() {
    cin>>n>>m;
    int ac = 0;
    int pen = 0;
    for (int i = 0; i < m; ++i) {
        int p; string s; cin>>p>>s;
        if (done[p]) continue;
        if (s[0] == 'W') {
            ++c[p];
        } else {
            done[p] = true;
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (done[i]) {
            ++ac;
            pen += c[i];
        }
    }
    cout << ac << " " << pen << endl;


    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 102000,mo=1e9+7;
int fac[N],ifac[N],facfac[N];
int power(int a, int n){
	int res=1;
	while(n){
		if(n&1)res=1LL*res*a%mo;a=1LL*a*a%mo;n>>=1;
	}
	return res;
}
int C(int n, int m){return 1LL*fac[n]*ifac[m]%mo*ifac[n-m]%mo;}
void Add(int &x,int y){x=x+y<mo?x+y:x+y-mo;}
int head[N],to[N<<1],nxt[N<<1],edgenum=1;
void add(int u, int v){
	to[++edgenum]=v;nxt[edgenum]=head[u];head[u]=edgenum;
}
int n,a[N],cntcir[N],res=1;bool vis[N],incir[N];Vi e[N];
int fa[N],dep[N],s[N],len,f[N];
void getcir(int u, int Fa, int Dep){
	fa[u]=Fa;dep[u]=Dep;
	if(a[u]==u&&!len){assert(!len);s[++len]=u;incir[u]=1;}
	L(i,u)
		if(!dep[to[i]])getcir(to[i],u,Dep+1);
		else if((to[i]!=Fa||(a[u]==to[i]&&a[to[i]]==u))&&dep[to[i]]<Dep&&!len){
			assert(!len);
			for(int x=u;;x=fa[x]){
				s[++len]=x;incir[x]=1;if(x==to[i])break;
			}
			if(a[s[2]]!=s[1])reverse(s+1,s+len+1);
		}
}
int ans;bool gg;
void dfs(int u, int fa, int Dep){
	int deg=0;ans=Dep;
	rep(i,0,SZ(e[u])-1)if(e[u][i]!=fa&&!incir[e[u][i]]){
		dfs(e[u][i],u,Dep+1);deg++;
	}
	if(deg>1)gg=1;
}
int main() {
	read(n);rep(i,1,n)read(a[i]),e[a[i]].pb(i),add(i,a[i]),add(a[i],i);
	fac[0]=1;rep(i,1,n)fac[i]=1LL*fac[i-1]*i%mo;
	ifac[n]=power(fac[n],mo-2);per(i,n-1,0)ifac[i]=1LL*ifac[i+1]*(i+1)%mo;
	facfac[0]=1;for(int i=2;i<=n+1;i+=2)facfac[i]=1LL*facfac[i-2]*(i-1)%mo;
	
	rep(i,1,n)if(!vis[i]){
		len=0;getcir(i,0,1);
		rep(j,1,len){ans=0;dfs(s[j],0,0);f[j]=ans;}
		if(gg){puts("0");return 0;}
		bool flag=1;rep(j,1,len)flag&=!f[j];
		if(flag)cntcir[len]++;
		else{
		//	printf("tree ");rep(j,1,len)printf("%d ",f[j]);puts("");
		//	int tot=0;rep(j,1,len)tot+=f[j];if(tot>len){puts("0");return 0;}
			static bool cvr[N];rep(j,0,len+1)cvr[j]=0;
			rep(j,1,len){
				for(int u=j,cnt=1;cnt<=f[j];cnt++,u=u+1<=len?u+1:1){
					if(cvr[u]){puts("0");return 0;}
					cvr[u]=1;
				}
			}
			rep(j,1,len)if(f[j]&&!cvr[(j+f[j])%len?(j+f[j])%len:len])res=2LL*res%mo;
		}
	}
	rep(x,1,n)if(cntcir[x]){
		int now=0;
		rep(i,0,cntcir[x])if(i%2==0){
			Add(now,1LL*C(cntcir[x],i)*power((x>1&&x%2)+1,cntcir[x]-i)%mo*facfac[i]%mo*power(x,i/2)%mo);
		//	printf("%d %d<%d %d>\n",cntcir[x],i,C(cntcir[x],i),facfac[i]);
		}
		res=1LL*res*now%mo;
	}
//	rep(i,1,n)rep(j,1,cntcir[i])printf("cir %d\n",i);
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 19456
import itertools

abcd = input()
memo = list(itertools.product(['+', '-'], repeat=3))

for i in range(2 ** 3):
    cnt = int(abcd[0])
    for j in range(3):
        if memo[i][j] == '+':
            cnt += int(abcd[j + 1])
        else:
            cnt -= int(abcd[j + 1])
    if cnt == 7:
        print(abcd[0] + memo[i][0] + abcd[1] + memo[i][1] + abcd[2] + memo[i][2] + abcd[3] + '=7')
        break


Measured memory_bytes: 3064
#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 H,A;
  cin >> H >> A;
  int ans = (H+A-1)/A;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
x, k, d = map(int, input().split())

if abs(x)//d >= k:
  print(abs(abs(x) - k*d))

else:
#  a = 1
  y = abs(x)//d
  a = y + 1
#  while abs(x) - d*a >=0:
#    a += 1
  if (k-(a-1)) % 2 ==0:
    print(abs(abs(x) - (a-1)*d))
  else:
    print(abs(abs(x) - a*d))


Measured memory_bytes: 9144
#include"bits/stdc++.h"

using namespace std;

int main() {
	string S;
	cin >> S;

	if (S == "A") {
		cout << "T" << endl;
	}
	else if (S == "T") {
		cout << "A" << endl;
	}
	else if (S == "C") {
		cout << "G" << endl;
	}
	else if (S == "G") {
		cout << "C" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int n[4] = {};
  rep(i, 3) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    n[a]++, n[b]++;
  }
  rep(i, 4) {
    if (n[i] == 3) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

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

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            var nab = Array.ConvertAll(Console.ReadLine().Split(), Convert.ToInt32);
            int n = nab[0], a = nab[1], b = nab[2];
            Console.WriteLine(Math.Min(n * a, b));
        }
    }
}


Measured memory_bytes: 13140
def include3(x):
    while True:
        if x % 10 == 3:
            return True
        else:
            x = int(x / 10)
        if x == 0:
            return False

n = int(input())
for i in range(1, n + 1):
    if i % 3 == 0 or include3(i):
        print(' %d' %i, end = '')
print('')


Measured memory_bytes: 5872
a, b, c, x, y = map(int, input().split())
ret = 0
if 2 * c <= a + b:
  m = min(x, y)
  ret += m * 2 * c
  x -= m
  y -= m
ret += min(2 * c, a) * x
ret += min(2 * c, b) * y
print(ret)


Measured memory_bytes: 2940
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = int.Parse(Console.ReadLine());

        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++)
        {
            int[] tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
            a[i] = tmp[0];
            b[i] = tmp[1];
        }

        //y座標でソート
        Array.Sort(b, a);

        int[] c = new int[n];
        int[] d = new int[n];
        for (int i = 0; i < n; i++)
        {
            int[] tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
            c[i] = tmp[0];
            d[i] = tmp[1];
        }

        //x座標でソート
        Array.Sort(c, d);

        //青い点のうち最もx 座標が小さいものに注目します。この点と仲良しペアになれる点が存在した場合，そのような点のうち最も y 座標が大きいものと仲良しペアにしてよい
        int[][] jag = new int[n][];
        for (int i = 0; i < jag.Length; i++)
        {
            jag[i] = new int[n];
        }

        //i が青い点、kが赤い点
        var hset = new HashSet<int>();
        for (int i = 0; i < n; i++)
        {
            for (int k = n - 1; k >= 0; k--)
            {
                if (hset.Contains(k)) continue;

                if (a[k] < c[i] && b[k] < d[i])
                {
                    jag[i][k] = 1;
                    hset.Add(k);
                    break;
                }
            }
        }

        var ans = 0;
        for (int i = 0; i < n; i++)
        {
            int sum = jag[i].Sum();
            if (sum != 0)
            {
                ans++;
            }
        }

        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13652
#define _USE_MATH_DEFINES
#include <cstdio>
#include <stack>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>

using namespace std;

typedef long long int64;
typedef pair<int, int> ii;
const int MOD = 1e9 + 7;

const int N = 50 + 10;
const int M = 100 + 10;
int dp[N];
vector<int> a[N];
int dfn[N], low[N];
int bcc[N];
int pre[N];

int stamp;
void DFS(int u) {
  static stack<int> S;
  low[u] = dfn[u] = stamp++;
  S.push(u);
  int child = 0;
  for (auto& v : a[u]) {
    if (dfn[v] == 0) {
      ++child;
      pre[v] = u;
      DFS(v);
      low[u] = min(low[u], low[v]);
      if (low[v] >= dfn[u]) {
        while (S.top() != v) {
          bcc[S.top()] = v;
          S.pop();
        }
        bcc[v] = v;
        S.pop();
        // if (u != 0 || child > 1) cut[u] = true;
      }
    } else {
      low[u] = min(low[u], dfn[v]);
    }
  }
}

int64 power_mod(int64 a, int n) {
  int64 ret = 1;
  for (; n; n >>= 1) {
    if (n & 1) ret = ret * a % MOD;
    a = a * a % MOD;
  }
  return ret;
}

int64 inv_mod(int64 a) {
  return power_mod(a, MOD - 2);
}

int C[300][300];
int main() {
  for (int i = 0; i < 300; ++i) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; ++j) {
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
    }
  }
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= i; ++j) {
      dp[i] += power_mod(k, __gcd(i, j)) % MOD;
      dp[i] %= MOD;
    }
    dp[i] = dp[i] * inv_mod(i) % MOD;
    // cout << i << ": " << dp[i] << endl;
  }
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  int ret = 1;
  for (int i = 0; i < n; ++i) {
    if (dfn[i]) continue;
    stamp = 1;
    DFS(i);
  }
  // for (int i = 0; i < n; ++i) {
  //   cout << i << ": " << bcc[i] << endl;
  // }
  for (int i = 0; i < n; ++i) {
    if (bcc[i] != i) continue;
    set<int> A;
    A.insert(pre[i]);
    for (int j = 0; j < n; ++j) {
      if (bcc[j] == i) A.insert(j);
    }
    int cnt = 0;
    for (auto& u : A) {
      for (auto& v : a[u]) {
        if (A.find(v) != A.end()) {
          ++cnt;
        }
      }
    }
    cnt /= 2;
    if (cnt == A.size()) {
      ret = (int64)ret * dp[cnt] % MOD;
    } else {
      ret = (int64)ret * C[cnt + k - 1][cnt] % MOD;
    }
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 640
import math

a, b, x = map(int, input().split())
V = a **2 * b

if V / 2 <=  x:
    y = a ** 2 * b - x
    s = 2 * y / a ** 3

else:
    s = a * b ** 2 / (2 * x)

#print(s)
ans = math.atan(s)
ans = math.degrees(ans)

print(ans)

Measured memory_bytes: 9260
#include <iostream>

using namespace std;

int main ()
{
	int  n,m,A[100][100],B[100],C[100];
	cin >> n >> m;

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


	for (int j = 0; j < m; j++)
	{
		cin >> B[j];
	}


	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			C[i] += A[i][j] * B[j];
		}
	}


	for (int i = 0; i < n; i++)
	{
		cout << C[i] << endl;
	}
}

Measured memory_bytes: 3148
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

bool doesHaveDuplicate(const std::string& s){
    FOR(i, 1, s.size()){
        if(s[i-1] == s[i]){return true;}
    }
    return false;
}

bool can(const std::string &s){
    FOR(j, 1, s.size()){
        int prev_pos = s[j-1] - 'A',
            pos = s[j] - 'A';
        P prev = mp(prev_pos%3, prev_pos/3), current = mp(pos%3, pos/3);
        // printf("%d, %d\n", current.first, current.second);
            
        if(prev.first == current.first && (prev.second == current.second - 1 || prev.second == current.second + 1) || 
           prev.second == current.second && (prev.first == current.first - 1 || prev.first == current.first + 1));
        else{return false;}
    }
    return true;
}

int main(){
    REP(i, 1000){
        std::string s;
        std::cin >> s;

        if(doesHaveDuplicate(s)){continue;}
        if(can(s)){std::cout << s << std::endl;}
    }
}

Measured memory_bytes: 1176
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.function.BiConsumer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int m = in.nextInt();
			Map<Integer, String> map = new HashMap<Integer, String>();
			int[] waList = new int[n + 1];
			long countAC = 0;
			long countWA = 0;
			for (int i = 0; i < m; i++) {
				int key = in.nextInt();
				String value = in.next();
				if (map.containsKey(key)) {
					String tmp = map.get(key);
					if (tmp.equals("WA")) {
						if (value.equals("AC")) {
							countAC++;
							countWA += waList[key];
							map.put(key, value);
						} else if (value.equals("WA")) {
							waList[key] = waList[key] + 1;
						}
					}
				} else if (value.equals("AC")) {
					map.put(key, value);
					countAC++;
				} else if (value.equals("WA")) {
					map.put(key, value);
					waList[key] = waList[key] + 1;
				}
			}
			out.println(countAC + " " + countWA);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

	}
}


Measured memory_bytes: 48816
#include<stdio.h>
#define MAX 500000
#define SENTINEL 1000000000
int  A[MAX];
int count = 0 ;
void Merge(int,int,int);

void Merge_Sort(int,int);

main(){
  int n;
  int i;
  int left,mid,right;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }

  left = 0;
  right = n;
  Merge_Sort(left,right);

  for(i=0; i<n; i++){
    printf("%d",A[i]);
    if(i != n-1)printf(" ");
  }
  printf("\n%d\n",count);
return 0;
}
void Merge(int left,int mid,int right){
  int n1,n2;
  int i,j,k;
  n1 = mid-left;
  n2 = right-mid;
  int L[n1+1],R[n2+1];

  for(i=0; i<n1; i++){
    L[i] = A[left+i];

  }

  for(i=0; i<n2; i++){
    R[i] = A[mid+i];

  }

  L[n1] = SENTINEL;
  R[n2] = SENTINEL;

  i = 0;
  j = 0;

  for(k=left; k<right; k++){
    count++;
    if(L[i] <= R[j])
      {
        A[k] = L[i];
        i++;
      }

    else
      {
        A[k] = R[j];
        j++;
      }  
}
}
void Merge_Sort(int left,int right){
  int mid;
  if(left+1 < right)
    {
      mid = (left + right)/2;
      Merge_Sort(left,mid);
      Merge_Sort(mid,right);
      Merge(left, mid,right);
    }
}

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

int main(){
  string S;
  cin>>S;
  bool ans =true;
  for(int i=0;i<(int)S.size();i++){
    if(i%2==0&&S.at(i)=='L'){
      ans =false;
      break;
    }else if(i%2!=0&&S.at(i)=='R'){
      ans =false;
      break;
    }
  }
  if(ans){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3608
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, q = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = list(map(lambda x: int(x)-1, input().split()))
    edges[a].append(b)
    edges[b].append(a)

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

def dfs(v, parent, add):
    nodes[v] += add
    for v2 in edges[v]:
        if v2 == parent:
            continue
        dfs(v2, v, nodes[v])

dfs(0, -1, 0)
print(*nodes)

Measured memory_bytes: 237360