akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const int EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const double PI = acos(-1);

typedef pair<ll, ll> P;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N, C;
	cin >> N >> C;
	vector<P> VP(N);
	vll V(N);
	ll sum = 0;
	REP(i, N) {
		ll x;
		cin >> x >> V[i];
		sum += V[i];
		VP[i] = P(x, sum);
	}
	vector<P> VPR = VP;
	rev(VPR); rev(V);
	sum = 0;
	REP(i, N) {
		sum += V[i];
		VPR[i].first = C - VPR[i].first;
		VPR[i].second = sum;
	}
	ll ans = 0;

	vll VA(N);//時計回りにi+1個以下食べた時の栄養価のMAX

	//時計回りにi+1個食べる
	REP(i, N) {
		ans = max(ans,VP[i].second - VP[i].first);
		VA[i] = ans;
	}

	vll VB(N);
	ll ansb = 0;
	//反時計回りにi+1個食べる
	REP(i, N) {
		ansb = max(ansb, VPR[i].second - VPR[i].first);
		VB[i] = ansb;
	}
	ans = max(ans,ansb);
	//反時計回りにi+1個食べる
	REP(i, N - 1) {
		ll now = VPR[i].second - VPR[i].first * 2;
		//そのあと時計回りに最適な個数分食べる。
		now += VA[N - i - 2];
		ans = max(ans, now);
	}
	//時計回りにi+1個食べる
	REP(i, N - 1) {
		ll now = VP[i].second - VP[i].first * 2;
		//そのあと反時計回りに最適な個数分食べる。
		now += VB[N - i - 2];
		ans = max(ans, now);
	}

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


Measured memory_bytes: 6008
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;
int h, w, a[600][600];
vector<pair<int,int>> vec1, vec2;
pair<pair<int,int>, int> fun(int x, int y, int dir){
    pair<pair<int,int>, int> ret;
    if(dir == 1){
        if(y+1 <= w){
            ret.f.f = x; ret.f.s = y+1; ret.s = dir;
        }
        else{
            ret.f.f = x+1; ret.f.s = w; ret.s = -1*dir;
        }
    }
    else{
        if(y-1 >= 1){
            ret.f.f = x; ret.f.s = y-1; ret.s = dir;
        }
        else{
            ret.f.f = x+1; ret.f.s = 1; ret.s = -1*dir;
        }
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef debug
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    cin >> h >> w;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            cin >> a[i][j];
        }
    }
    int cx = 1, cy = 1;
    int cnt = 0;
    int dir = 1;
    int dis = 0;
    while(1){
        dis++;
        //cout << dis << " " << cx << " " << cy << endl;
        if(dis == h*w)break;
        pair<pair<int,int>, int> nxt = fun(cx, cy, dir);
        if(a[cx][cy]&1){
            cnt++;
            vec1.pb({cx,cy}); vec2.pb({nxt.f.f, nxt.f.s});
            a[nxt.f.f][nxt.f.s]++;
        }
        cx = nxt.f.f; cy = nxt.f.s; dir = nxt.s;
    }
    cout << cnt << '\n';
    for(int i = 0; i < vec1.size(); i++){
        cout << vec1[i].f << " " << vec1[i].s << " " << vec2[i].f << " " << vec2[i].s << '\n';
    }
    return 0;
}


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

int main ()
{

	int a, b;
	cin >> a >> b;
	if( a < b ){
		cout << "a < b" << endl;
}
else if ( a > b ){
    	cout << "a > b" << endl;
}
else if ( a == b ){
	    cout << "a == b" << endl;
}
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }  
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> a(m);
  for(Int i=0;i<m;i++) cin>>a[i],a[i]--;
  
  vector<Int> p(n);
  iota(p.begin(),p.end(),0);
  for(Int i=0;i<m;i++) swap(p[a[i]],p[a[i]+1]);  

  for(Int h=1;h<m;h++){
    Int flg=0;
    
    vector<Int> pos(m);
    MFP([&](auto dfs,Int x)->void{
          if(x==m){            
            vector<Int> v(n),cnt(n,0);
            iota(v.begin(),v.end(),0);
            
            for(Int i=0;i<h;i++){
              for(Int j=0;j<m;j++)
                if(pos[j]==i) cnt[a[j]]++;           
              
              for(Int j=0;j<n;j++){
                if(cnt[j]>1) return;
                if(!cnt[j]) continue;                
                swap(v[j],v[j+1]);
                if(j+1<n&&cnt[j+1]) return;
                cnt[j]=0;
              }
            }
            
            if(v==p) flg=1;
            return;
          }
          for(Int i=0;i<h;i++){
            pos[x]=i;
            dfs(x+1);
          }
        })(0);
    
    if(flg){
      cout<<h<<endl;
      return 0;
    }
  }
  cout<<m<<endl;
  return 0;
}



Measured memory_bytes: 3088
N = int(input())
A = list(map(int,input().split()))
print( *A )
for i in range(1,N):
    v = A[i]
    j = i - 1
    while j >= 0 and A [j] > v :
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
    print( *A )

Measured memory_bytes: 5976
n = int(input())
s = input()
c = 0
a = [i for i in range(10) if str(i) in s]
for i in a:
    p = s.index(str(i))
    #print(i,p)
    if p >= n-2:
        continue
    for j in a:
        try:
            q = s[p+1:].index(str(j)) + p+1
        except ValueError:
            continue


        for k in a:
            try:
                r = s[q+1:].index(str(k)) + q+1
            except ValueError:
                continue

            c += 1
            #print(i,j,k,'*',p,q,r)

print(c)


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

int main() {
  int k,x;
  cin>>x>>k;
  //////
  int a=k-x+1;
  int b=k+x-1;
  for(int i=a;i<=b;i++){
    cout<<i<<" ";
  }
} 



Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
#define ll    long long int
#define pai     pair<int,int>
#define vi      vector<int>
#define vd      vector<double>
#define mpi     map<int,int>
#define mps     map<string,int>
#define sti     stack<int>
#define stc     stack<char>
#define sei     set<int>
#define ses     set<string>
#define multii  multiset<int>

 int main()
{
sti s;
vi v;
ll x;
while(cin>>x){
if(x==0){
    v.push_back(s.top());
    s.pop();
}
else{
  s.push(x);
}
}
for(int i=0;i<v.size();i++){
   cout<<v[i]<<endl;
}

}








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

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  vector<int> a(N);
  REP(i,N) cin>>a[i];
  int ans = 0;
  REP(i,N) {
    if(i % 2 == 0 ) {
      if(a[i] %	2 != 0) {
	ans++;
      } 
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3196
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////

int main(){fastio
    ll n,m;cin>>n>>m;
    ll dp[m+1][1<<n];
    rep(i,0,m)rep(j,0,(1<<n)-1)dp[i][j]=inf;
    dp[0][0]=0;
    rep(i,1,m){
        ll a,b;cin>>a>>b;
        ll c=0;
        while(b--){
            ll va;cin>>va;
            c+=(1<<(va-1));
        }
        rep(j,0,(1<<n)-1)dp[i][j]=dp[i-1][j];
        rep(j,0,(1<<n)-1){
            if((j&c)==c){
                Min(dp[i][j],dp[i-1][j-c]+a);
            }
        }
        for(ll j=(1<<n)-1;j>=0;j--){
            rep(k,0,n-1){
                if((j&(1<<k))==0){
                    Min(dp[i][j],dp[i][j+(1<<k)]);
                }
            }
        }
    }
    if(dp[m][(1<<n)-1]>=inf/2)cout<<-1<<endl;
    else cout<<dp[m][(1<<n)-1]<<endl;
    
    return 0;
}


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

int main()
{
  string a, b, c;
  cin >> a >> b >> c;
  int m, n;
  m = a.size();
  n = b.size();
  if(a[m - 1] == b[0] && b[n - 1] == c[0]){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=100001;
int stoio(std::string str){
    int ret;
    stringstream ss;
    ss << str;
    ss >> ret;
return ret;
}
int main(){
  int a,b,c,d;
  string str;
  cin >> str;
  const int n = str.length();
  vector<int> vs(n);
  for(int i=0;i<n;i++){
     vs[i] = stoio(str.substr(i,1));

  }
  a=vs[0];
  b=vs[1];
  c=vs[2];
  d=vs[3];
  for(int i=0;i<2;i++){
    
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        int bb=b,cc=c,dd=d;
        if(i%2==0)bb*=-1;
        if(j%2==0)cc*=-1;
        if(k%2==0)dd*=-1;
        if(a+bb+cc+dd==7){
          cout<<a<<(bb>0 ?'+':'-')<<b<<(cc>0 ?'+':'-')<<c<<(dd>0 ?'+':'-')<<d<<"=7"<<endl;
          return 0;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int dp[10010][2][110];

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string K; cin >> K;
    int n = K.length();
    int D; cin >> D;
    dp[0][0][0] = 1;
    rep(i, n) {
        rep(j, D) {
            rep(dig, 10) dp[i + 1][1][(j + dig) % D] = (dp[i + 1][1][(j + dig) % D] + dp[i][1][j]) % mod;
            rep(dig, K[i] - '0')  dp[i + 1][1][(j + dig) % D] = (dp[i + 1][1][(j + dig) % D] + dp[i][0][j]) % mod;
            dp[i + 1][0][(j + K[i] - '0') % D] = (dp[i + 1][0][(j + K[i] - '0') % D] + dp[i][0][j]) % mod;
        }
    }
    cout << (dp[n][0][0] + dp[n][1][0] - 1 + mod) % mod << endl;

    return 0;
}


Measured memory_bytes: 8832
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int change = 0;
        if(b < a){
            change = a;
            a = b;
            b = change;
        }
        if((a + w - b) > 0){
            System.out.println(0);
        }else{
            System.out.println(b - a - w );
        }
    }
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  int n, m;
  cin >> n >> m;
  int x = INT_MIN;
  int y = INT_MAX;
  for (int i = 0; i < m; i++){
    int l, r;
    cin >> l >> r;
    x = max(x, l);
    y = min(y, r);
  }
  cout << max(0, (y - (x - 1))) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    int n, ans=0;
    cin >> n;
    vector<int> l(n), r(n);
    rep(i, n){
        cin >> l.at(i) >> r.at(i);
        ans += r.at(i) - l.at(i)+1;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int p_min;
    cin >> p_min;

    int res = 1;
    for (int i = 1; i < n; i++) {
        int p;
        cin >> p;

        if (p_min >= p) {
            p_min = p;
            res++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("debug.txt", "w", stderr);
	#endif
}

int dpx[8]={1,1,1,-1,-1,-1,0,0};
int dpy[8]={-1,1,0,1,-1,0,-1,1};

struct Camel
{
	int l, r, k; 
}; 

bool cmp(Camel c1, Camel c2)
{
	return abs(c1.l - c1.r) > abs(c2.l  - c2.r); 
}

int32_t main()
{
	fastIO
	inp_out();
	int t; 
	cin >> t; 
	while(t -- )
	{
		int n; 
		cin >> n; 
		vector < Camel >  a(n); 
		int ans = 0; 
		for(int i = 0; i < n;  ++ i)
		{
			cin >> a[i].k >> a[i].l >> a[i].r; 
			ans  += min(a[i].l, a[i].r); 
		}

		sort(a.begin(), a.end(), cmp); 

		set < int >  str; 
		set < int , greater < int>>  stl; 
	
		for(int i = 1; i <= n;  ++ i)
		{
			stl.insert(i); 
			str.insert(i); 
		}

		for(int i = 0; i < n;  ++ i)
		{
			if(a[i].l >= a[i].r)
			{	
				auto itr = stl.lower_bound(a[i].k); 
				if(itr != stl.end())
				{
					stl.erase( * itr); 
					str.erase(str.begin()); 
					ans += abs(a[i].l - a[i].r); 
				}	
			}
			else
			{
				auto itr = str.upper_bound(a[i].k); 
				if(itr != str.end())
				{
					str.erase( * itr); 
					stl.erase(stl.begin()); 
					ans += abs(a[i].l - a[i].r); 
				}
			}

		}

		cout << ans << "\n"; 

	}
	return 0;
}


Measured memory_bytes: 26620
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

#define L 0
#define R 1

lli n,q;
string s;

bool calc(lli pos,vector<pair<char,char>> *v,bool dir){
	lli goal;
	lli now = pos;
	if(dir==L)goal=-1;
	else goal=n;

	for(lli i=0;i<q;i++){
		if(now<0 || now>=n)break;
		if(v->at(i).first == s[now]){
			if(v->at(i).second=='L')now--;
			else now++;
		}
	}
	if(now==goal)return true;
	else return false;
}

lli func(vector<pair<char,char>> *v){
	/*まず左から落ちるものを探し出す*/
	lli high=n;
	lli low=-1;
	lli middle;
	while(high-low>1){
		middle = (low+high)/2;
		if(calc(middle,v,L)){
			low = middle;
		}
		else high = middle;
	}
	lli left = high;

	high=n;
	low =-1;
	while(high-low>1){
		middle = (low+high)/2;
		if(calc(middle,v,R)){
			high=middle;
		}
		else low = middle;
	}
	lli right = low;
	if(DEBUG)cout<<"left="<<left<<" right="<<right<<endl;
	return right-left+1;
}

signed main(){

	cin>>n>>q;
	cin>>s;

	vector<pair<char,char>> v;
	REP(i,0,q){
		char t,d;
		cin>>t>>d;
		v.push_back(make_pair(t,d));
	}

	/*2分探索で左から落ちるゴーレムと右から落ちるゴーレムの2つを見つけ出す。*/
	cout<<func(&v)<<endl;

	return 0;
}

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

#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 All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   int n,k;
   cin >> n >> k;
   int ans = 1;
   for(int i=0;i<n;i++){
      if(ans * 2 < ans + k)ans *= 2;
      else ans += k;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
/* Uncomment only if you are not using GNU compiler->
#include <map> #include <algorithm> #include <vector> #include <string.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <chrono> #include <thread> #include <iomanip>
*/ 
using namespace std;

#define endl "\n"
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define re(i,a) for(ll i=0; i<a; ++i)
#define tr(i,v) for(auto &i: v)
#define mem(a,val) memset(a,val,sizeof(a))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define in(v,n) vll v(n);re(i,n) cin>>v[i]
#define printVec(v,s) cout << s; tr(i, v) cout << i << " ";
#define sz(v)	((ll)((v).size()))
#define dbgv(c, v) cout << c << " = " << v << endl;
#define P(x)				cout<<#x<<" = { "<<x<<" }\n"

typedef int ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<ll, ll> pll;
typedef vector< pll > vpll;
typedef vector< ll > vll;
typedef complex<double> point;

const long long MOD = 1000000007;
const long long inf = 1e18;
const double EPS = (1e-7);
inline ll dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}

void solve(){
	ll n;
  cin>>n;
  string s;
  map<string, int> typess;
  re(i, n) {
    cin >> s;
    typess[s]++;
  }
  printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", typess["AC"],typess["WA"],typess["TLE"],typess["RE"] );
}

int main()
{

    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cin.exceptions(cin.failbit);
    	solve();
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

#define int long long
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

const int MAX_V = 100;
const int INF = 1e12;

struct edge {
    int to, cost;
};
typedef pair<int, int> P;

int V;
vector<edge> G[MAX_V];
int d[MAX_V];

//ダイクストラ法を用いて単一始点最短路問題を解く
void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

signed main() {
    cin >> V;
    for (int i = 0; i < V; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v, c;
            cin >> v >> c;
            G[u].push_back({v, c});
        }
    }
    dijkstra(0);
    for (int i = 0; i < V; i++) {
        cout << i << " " << d[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 3232
#include <iostream> 

using namespace std;

int main(){
    int N;
    int sum =0;
    cin >> N;
    int A[N];
    int B[N];
    int C[N-1];
    for(int i = 0;i < N; i++)
    {
        cin >> A[i];
    }
    for(int i = 0;i < N; i++)
    {
        cin >> B[i];
    }
    for(int i = 0;i < N-1; i++)
    {
        cin >> C[i];
    }
    for(int i = 0;i < N-1; i++)
    {
        sum = sum + B[i];
        if(A[i+1] == A[i]+1)
        {
            sum = sum + C[A[i]-1];
        }
    }
    sum = sum + B[N-1];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
long long const Mod = 1e9 + 7;
int main() {
	int n ;
	scanf("%d",&n);
	int arr[1000005] , num;
	memset(arr,0,sizeof arr);
	long long ans = 1;
	for(int i = 0 ; i < n ; ++i){
		scanf("%d",&num);
		arr[num]++;
		if(n % 2 == 0){
			if(num >= n || num % 2 == 0 || arr[num] > 2){
				 puts("0");	return 0;
			}
			if(arr[num] == 1){
				 ans *= 2;
				 ans %= Mod;
				 
			}
		}
		else{
			if(num >= n || num % 2 != 0 || arr[num] > 2 || arr[0] > 1){
				 puts("0");	return 0;
			}
			if(num != 0 && arr[num] == 1){
				 ans *= 2;
				 ans %= Mod;
			}
		}
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 4096
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};

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

ll a[2010];

int ar[10000];
int hr[10000];
int target;
int memo[8002][8002][2];
bool rec(int in,int num,bool var) {

	if (in == 8001) { 
		return memo[in][num][var] = (num == target);
	}

	if (memo[in][num][var] != -1) {
		return memo[in][num][var];
	}

	bool res = false;
	int count = (var ? ar[in] : hr[in]);
	for (int i = 0; i <= count; i++)
	{
		int val = in * i;
		if (num + val > target) break;
		res |= rec(in + 1, num + val, var);
		if (res) { 
			break; 
		}
	}

	return memo[in][num][var] = res;
}
void Solve() {
	
	for (size_t i = 0; i < 8001; i++)
	{
		for (size_t j = 0; j < 8001; j++)
		{
			memo[i][j][0] = -1;
			memo[i][j][1] = -1;
		}
	}
	string s;
	int x, y;
	cin >> s;
	cin >> x >> y;
	int first = 0;
	int varsum = 0;
	int holsum = 0;
	bool ft = false;
	bool var = false;
	int cache = 0;
	s += "T";
	for (size_t i = 0; i < s.size(); i++)
	{
		if (s[i] == 'T') {
			if (ft) {
				if (var) {
					hr[cache]++;
					varsum += cache;

				}
				else {
					ar[cache]++;
					holsum += cache;
				}
			}
			ft = true;
			var = !var;
			cache = 0;

			continue;
		}
		if (!ft) {
			first++;
		}
		else {
			cache++;
		}
	}
	int tx = 0;
	if (x < 0) {
		tx = -x + first;
	}
	else {
		tx = x - first;
	}
	if (tx > holsum) {
		cout << "No" << endl;
		return;
	}
	else if((holsum - tx) % 2 != 0){
		cout << "No" << endl;
		return;
	}
	else {
		target = (holsum - tx) / 2;
	}

	bool r = rec(0, 0, true);

	int ty = 0;
	if (y < 0) {
		ty = -y;
	}
	else {
		ty = y;
	}
	if (ty > varsum) {
		cout << "No" << endl;
		return;
	}
	else if ((varsum - ty) % 2 != 0) {
		cout << "No" << endl;
		return;
	}
	else {
		target = (varsum - ty) / 2;
	}

	if (r && rec(0,0,false)) {	
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}


int main() {
	Solve();
	return 0;
}



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

#define len(x) ((int)(x).size())
#define log(x) cout << (x) << endl
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define loop(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(i, n) for(int i=0;i<(int)(n);++i)

using vi = vector<int>;

#define max(a,b,c,d) max(a,max(b,max(c,d)))

int dp[51][51][101];
int solve(vi& a, int K) {
  int n = len(a);
  rrep (i,n-1,0) {
    rep (j, n) {
      rep (k, K+1) {
        if (k==0 or i>j or i==j) {
          dp[i][j][k] = 0;
          if (i==j) dp[i][j][k]=(k>0)?max(0,0,0,a[i]):0;
          continue;
        }
        dp[i][j][k] = max(
          a[i] + dp[i+1][j][k-1],
          a[j] + dp[i][j-1][k-1],
          (k>1) ? dp[i+1][j][k-2]:0,
          (k>1) ? dp[i][j-1][k-2]:0
        );
      }
    }
  }
  return dp[0][n-1][K];
}


int main() {
	int n,k;
	cin>>n>>k;
	vi a(n);
	rep (i,n)cin>>a[i];
	log(solve(a,k));
}



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

int main(){

    int n; cin >> n;
    vector<int> a(100010, 0);
    vector<int> b(100010, 0);

    for(int i = 0; i < n; i++){
        int in; cin >> in;
        if(i % 2 == 0) a[in]++;
        else b[in]++;
    }

    priority_queue<pair<int, int> > pa;
    priority_queue<pair<int, int> > pb;
    
    for(int i = 0; i < 100010; i++){
        pa.push({a[i], i});
        pb.push({b[i], i});
    }

    pair<int, int> A = pa.top();
    pair<int, int> B = pb.top();
    if(A.second != B.second){
        cout << n - A.first - B.first << endl;
    }else{
        pa.pop();
        pb.pop();
        pair<int, int> AA = pa.top();
        pair<int, int> BB = pb.top();
        int ans = min(n - A.first - BB.first, n - AA.first - B.first);
        cout << ans << endl;
    }
    
    return 0;
}

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;



int main(){
    long double a, b, c, h, m;
    cin>>a >>b >>h >>m;
    long double rad = 2 * M_PI *((h + m / 60) / 12 - m / 60);
    cout<< fixed << setprecision(10) <<sqrt(a * a + b * b - 2 * a * b * cos(rad))<<endl;
}


Measured memory_bytes: 4008
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N, K; cin >> N >> K;
	vector<vector<int>>sums(10);
	for (int i = 0; i < N; ++i) {
		int c, g; cin >> c >> g; g--;
		sums[g].push_back(c);
	}
	for (auto&vs : sums) {
		sort(vs.begin(), vs.end(), greater<int>());
	}
	for (auto &vs : sums) {
		vs.insert(vs.begin(), 0);
		for (int v = 0; v < vs.size() - 1; ++v) {
			vs[v + 1] += vs[v];
			vs[v + 1] += v*(2);
		}
	}
	vector<vector<int>>dp(11, vector<int>(K + 1,-2e9));
	dp[0][0]=0;
	for (int i = 0; i < 10; ++i) {
		for (int pre_sell = 0; pre_sell <= K; ++pre_sell) {
			for (int now_sell = 0; now_sell < sums[i].size(); ++now_sell) {
				int total = pre_sell + now_sell;
				if (total <= K) {
					dp[i + 1][total] = max(dp[i + 1][total], dp[i][pre_sell] + sums[i][now_sell]);
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= K; ++i) {
		ans = max(ans, dp[10][i]);

	}
	cout << ans << endl;
	

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    ll N,K; cin >> N >> K;

    ll V[100];

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

    ll ans = 0;

    for (int l = 0;l <= N;l++){
        for (int r = N-1;r >= l-1;r--){
            if(K<(l+(N-r-1))) continue;
            ll sum = 0;
            priority_queue<ll, vector<ll>, greater<ll>> que;
            for (int i = 0;i < l;i++){
                que.push(V[i]);
                sum += V[i];
            }
            for (int i = N-1;i > r;i--){
                que.push(V[i]);
                sum += V[i];
            }
            for (int i = 0;i < K-(l+(N-r-1));i++){
                if(que.size() && que.top()<0){
                    sum -= que.top();
                    que.pop();
                }
                else break;
            }
            //cout << l << " " << r  << " " << sum << endl;
            ans = max(ans,sum);
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
gl = [0]
gr = [0]

def gcd(a,b):
    if a < b:
        a,b = b,a
    if b==0:
        return a
    else:
        return gcd(b,a%b)

for i in range(N):
    gl.append(gcd(gl[-1],A[i]))
    gr.append(gcd(gr[-1],A[-i-1]))
ans = 1
for i in range(N):
    g = gcd(gl[i],gr[-i-2])
    if ans < g:
        ans = g
print(ans)

Measured memory_bytes: 14052
// package app;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.StringJoiner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);

        // String S = sc.next();
        // long u = sc.nextLong();

        int N = sc.nextInt();

        int[][] route = new int[2][N];
        for (int i = 0; i < 2; i++) {
            route[i] = new int[N];
            for(int j = 0; j < N; j++) {
                route[i][j] = sc.nextInt();
            }
        }

        int maxCandy = Integer.MIN_VALUE;
        for (int i = 0; i < N; i++) {
            int tmp = 0;
            int h = 0;
            for (int j = 0; j < N; j++) {
                tmp += route[h][j];
                if (i == j){
                    h++;
                    tmp += route[h][j];
                }
            }
            maxCandy = Math.max(maxCandy, tmp);
        }

        System.out.println(maxCandy);
    }
}

Measured memory_bytes: 23124
#include <iostream>
using namespace std;
const int mod=1e9+7;
int n;
long long base1=8,base2=9,base3=10;
void mut(long long &base)
{
    long long k=base;
    for(int i=1;i<n;i++)base=(base*k)%mod;
}
int main(void)
{
    cin>>n;
    mut(base1);
    mut(base2);
    mut(base3);
    long long ans=base1+base3-2*base2;
    ans%=mod;
    ans=(ans+mod)%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3176
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
 

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

int main(void){
	scanf("%d %d",&n,&m);
	if(n<10 && m<10){printf("%d\n",n*m);return 0;}
	else{printf("%d\n",-1);return 0;}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define INF 1e15
#define MAXN 50
#define MAXS 2500

int N, M, S, C[MAXN + 3], D[MAXN + 3];
vector<pair<int, pair<int, int> > > adj[MAXN + 3]; //{v, {a, b}}
LL dist[MAXN + 3][MAXS + 3];

int main() {
    scanf("%d%d%d", &N, &M, &S);
    for (int i = 1; i <= M; i++) {
        int u, v, a, b;
        scanf("%d%d%d%d", &u, &v, &a, &b);

        adj[u].push_back({v, {a, b}});
        adj[v].push_back({u, {a, b}});
    }

    for (int i = 1; i <= N; i++) {
        scanf("%d%d", &C[i], &D[i]);
    }

    S = min(S, MAXS);

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= MAXS; j++) {
            dist[i][j] = INF;
        }
    }

    priority_queue<pair<LL, pair<int, int> > > pq; //{dist, {currentNode, currentSilver}}

    dist[1][S] = 0;
    pq.push({-dist[1][S], {1, S}});

    while (!pq.empty()) {
        auto top = pq.top(); pq.pop();

        int node = top.second.first;
        int silver = top.second.second;

        //try exchanging gold
        if (true) {
            int cost = D[node];
            int nextSilver = min(MAXS, silver + C[node]);
            if (dist[node][nextSilver] > dist[node][silver] + cost) {
                dist[node][nextSilver] = dist[node][silver] + cost;
                pq.push({-dist[node][nextSilver], {node, nextSilver}});
            }
        }

        //try going to neighboring nodes
        for (int i = 0; i < adj[node].size(); i++) {
            int nextNode = adj[node][i].first;
            int neededSilver = adj[node][i].second.first;
            int cost = adj[node][i].second.second;

            if (neededSilver <= silver && dist[nextNode][silver - neededSilver] > dist[node][silver] + cost) {
                dist[nextNode][silver - neededSilver] = dist[node][silver] + cost;
                pq.push({-dist[nextNode][silver - neededSilver], {nextNode, silver - neededSilver}});
            }
        }
    }

    for (int node = 2; node <= N; node++) {
        LL minDist = INF;
        for (int silver = 0; silver <= MAXS; silver++)
            minDist = min(minDist, dist[node][silver]);

        printf("%lld\n", minDist);
    }
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e3 + 5;
ll f[N][N];
pair<int, int> p[N];
ll cal(int cnt, int l, int r) {
    if(l > r) return 0;
    if(~f[l][r]) return f[l][r];
    ll ans = 1LL * p[cnt].first * abs(p[cnt].second - l) + cal(cnt + 1, l + 1, r);
    ans = max(ans, 1LL * p[cnt].first * abs(p[cnt].second - r) + cal(cnt + 1, l, r - 1));
    return f[l][r] = ans;
}
int main() {
    int n;
    scanf("%d", &n);
    for(int i = 1, x; i <= n; i++) {
        scanf("%d", &x);
        p[i] = {x, i};
    }
    sort(p + 1, p + n + 1,[](pair<int, int> a, pair<int, int> b) {
        return a.first > b.first;
    });
    memset(f, -1, sizeof f);
    printf("%lld\n", cal(1, 1, n));
    return 0;
}


Measured memory_bytes: 35364
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

struct UnionFind{
  vector<int> par; //親
  vector<int> size; //集合の大きさ

  UnionFind(int n){
    par.resize(n); size.resize(n, 1);
    for(int i = 0; i < n; i++){
      par[i] = i;
    }
  }

  //木の根を求める
  int root(int x){
    if(par[x] == x){
      return x;
    }else{
      return par[x] = root(par[x]);
    }
  }

  //xとyの属する集合を併合
  void unite(int x,int y){
    x = root(x), y = root(y);
    if(x == y) return;
    if(size[x] < size[y]) swap(x,y);
    par[y] = x;
    size[x] += size[y];
  }

  bool same(int x, int y){
    return root(x) == root(y);
  }
};

signed main(){

  int n, m; cin >> n >> m;

  vector<int> a(m), b(m);
  for(int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }

  vector<int> ans(m+1);
  ans[m] = n * (n-1) / 2;
  UnionFind uf(n);
  for(int i = m-1; i >= 0; i--){
    if(uf.same(a[i], b[i])){
      ans[i] = ans[i+1];
    }else{
      ans[i] = ans[i+1] - uf.size[uf.root(a[i])] * uf.size[uf.root(b[i])];
      uf.unite(a[i], b[i]);
    }
  }

  for(int i = 0; i < m; i++){
    cout << ans[i+1] << endl;
  }

  return 0;
}

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

int N;
int A[100000+5];

int main()
{
    cin.sync_with_stdio(false);
    cin >> N;
    // map<int, int> counts;
    // int t = 0;
    for (int i = 0; i < N; ++i)
    {
        // cin >> t;
        // counts[t]++;
        cin >> A[i];
    }

    // int w = 0, h = 0;
    // for (auto& p : counts)
    // {
    //     int a = p.first;
    //     int c = p.second;
    //     if (c >= 2)
    //     {
    //         if (c > w)
    //         {

    //         }
    //     }
    // }

    sort(A, A+N);

    long long w = 0;
    long long h = 0;
    int i = N-1;
    while (i >= 1)
    {
        if (A[i] == A[i-1])
        {
            w = A[i];
            i -= 2;
            break;
        }
        i--;
    }

    if (w == 0)
    {
        cout << 0 << endl;
        return 0;
    }

    while (i >= 1)
    {
        if (A[i] == A[i-1])
        {
            h = A[i];
            break;
        }
        i--;
    }

    cout << w*h << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> h(n+1);
    for(int i = 1; i <= n; i++) cin >> h[i];
    vector<vector<int>> e(n+1);
    for(int i = 0; i < m; i++)
    {
        int a, b; cin >> a >> b;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++)
    {
        bool ok = true;
        for(int j = 0; j < e[i].size(); j++)
        {
            if(h[e[i][j]]>=h[i]) {ok = false;break;}
        }
        if(ok) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 8752
#include <iostream>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int H, W; in(H); in(W);
  int A, B; in(A); in(B);

  rep(i, H) {
    rep(j, W) {
      if (i < B && j < A || i >= B && j >= A)
        cout << 1;
      else
        cout << 0;
    }
    cout << "\n";
  }

  return 0;
}


Measured memory_bytes: 1280
module MakeBinaryHeap (M : sig type t val compare : t -> t -> int end) = struct

  type t = { node : M.t array; mutable size : int }

  let make n (init : M.t) = { node = Array.make n init; size = 0 }

  let empty_p t = if t.size = 0 then true else false

  let pop t =
    let rec max_heapify i =
      let l = 2*i in
      let r = 2*i + 1 in
      let m = if l <= t.size && M.compare t.node.(l) t.node.(i) > 0 then l else i in
      let m = if r <= t.size && M.compare t.node.(r) t.node.(m) > 0 then r else m in
      if m = i then ()
      else begin
        let tmp = t.node.(i) in
        t.node.(i) <- t.node.(m);
        t.node.(m) <- tmp;
        max_heapify m
      end in
    let ret = t.node.(1) in
    t.node.(1) <- t.node.(t.size);
    t.size <- t.size - 1;
    max_heapify 1;
    ret

  let push x t =
    let parent i = int_of_float (floor (float_of_int i) /. 2.) in
    let rec doit i =
      let p = parent i in
      if i <= 1 || M.compare t.node.(p) t.node.(i) >= 0 then ()
      else begin
        let tmp = t.node.(i) in
        t.node.(i) <- t.node.(p);
        t.node.(p) <- tmp;
        doit p
      end in
    t.size <- t.size + 1;
    t.node.(t.size) <- x;
    doit t.size

end

module H = MakeBinaryHeap(struct type t = (int * int) let compare (_, x) (_, y) = y - x end)

let dijkstra g n =
  let h = H.make 100000 (0, 0) in
  let min_costs = Array.make n max_int in
  let reached_p = Array.make n false in
  min_costs.(0) <- 0;
  H.push (0, 0) h;
  while not (H.empty_p h) do
    let (u, x) = H.pop h in
    reached_p.(u) <- true;
    if x > min_costs.(u) then ()
    else
      List.iter (fun (v, c) ->
        let x = min_costs.(u) + c in
        if not reached_p.(v) && min_costs.(v) > x then begin
          min_costs.(v) <- x;
          H.push (v, min_costs.(v)) h;
        end) g.(u);
  done;
  min_costs

let rec make_pair acc = function
  | [] -> acc
  | v :: c :: tl -> make_pair ((v, c) :: acc) tl
  | _ -> assert false

let make_pair lst = make_pair [] lst

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let n = read_int () in
  let g = Array.make n [] in
  for _ = 0 to n - 1 do
    match read_line () |> split_on_char ' ' |> List.map int_of_string with
    | u :: _ :: l -> g.(u) <- make_pair l
    | _ -> assert false
  done;
  dijkstra g n |> Array.iteri (fun i e -> Printf.printf "%d %d\n" i e)

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

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

template<class T>
T gcd(T a, T b){
  if(a > b) swap(a, b);
  if(a == 0) return b;
  return gcd(a, b%a);
}

int barL[100];
int barR[100];

int barRatioL[100];
int barRatioR[100];

int which(int n){
  vector<bool> f(n+1, false);
  REP(i,n+1) f[barL[i]] = f[barR[i]] = true;
  REP(i,n+1) if(!f[i]) return i;
  return -1;
}

long long weight(int i){
  int l = barL[i-1];
  int r = barR[i-1];

  long long wl = l == 0 ? 1 : weight(l);
  long long wr = r == 0 ? 1 : weight(r);

  int rl = barRatioL[i-1];
  int rr = barRatioR[i-1];

  long long R = wr * rr;
  long long L = wl * rl;
  long long g = gcd(R, L);
  long long lcm = R*L/g;

  return (lcm/rl + lcm/rr);
}

int main(){
  int n;
  while(n = getInt()){
    REP(i,n){
      int a = getInt();
      int b = getInt();
      int g = gcd(a, b);

      barL[i] = getInt();
      barR[i] = getInt();

      barRatioL[i] = a / g;
      barRatioR[i] = b / g;
    }

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

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e14;
const int ZERO = 0;
const int MOD = 1000000007;
const double PI = 3.1415926535897;

signed main() {
    string S;
    cin >> S;
    string T;
    for(int i = 0;i < S.size() - 1;i++) {
        if(S.at(i) == 'B' && S.at(i + 1) == 'C') {
            T += 'T';
            i++;
        }
        else {
            T += S.at(i);
        }
    }
    int ret = 0;
    int cnt = 0;
    int cnt2 = 0;
    reverse(T.begin(), T.end());
    for(int i = 0;i < T.size();i++) {
        if(T.at(i) == 'A') {
            ret += cnt2 - cnt;
            cnt++;
            cnt2++;
        }
        else if(T.at(i) == 'T') {
            cnt2++;
        }
        else {
            cnt = 0;
            cnt2 = 0;
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 776
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define ALL(a) a.begin(),a.end()
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MOD=998244353;
ll k,n,cnt,ans,dp[2100][2100],p2[2100],C[2100][2100],dp2[2100],st[2100],top;
 
int main()
{Tie
	C[0][0]=1;
	for(int i=1;i<=2000;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
	}
	dp[0][0]=1;
	for(int i=1;i<=2001;i++)
	{
		dp[i][0]=1;
		for(int j=1;j<=2001;j++)
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
	}
	for(int i=1;i<=2001;i++)
		dp[0][i]=1;
	p2[0]=1;
	for(int i=1;i<=2001;i++)
		p2[i]=p2[i-1]*2%MOD;
	cin>>k>>n;
	for(int i=2;i<=k+1;i++)
	{
		cnt=(i-1)>>1,ans=0;
		if(i%2&&k-cnt*2>0)
			ans=dp[k-cnt*2][n];
		else if(i%2==0&&k-cnt*2-1>0)
			ans=(dp[k-1-cnt*2][n]+dp[k-1-cnt*2][n-1])%MOD;
		for(int j=1;j<=cnt;j++)
		{
			if(i%2==0)
			{
				n--,k--;
				if(n-j>=0)
					ans=(ans+dp[k-cnt*2+j][n-j]*p2[j]%MOD*C[cnt][j]%MOD)%MOD;
				n++;
				if(n-j>=0)
					ans=(ans+dp[k-cnt*2+j][n-j]*p2[j]%MOD*C[cnt][j]%MOD)%MOD;
				k++;
			}
			else
			{
				if(n-j>=0)
					ans=(ans+dp[k-cnt*2+j][n-j]*p2[j]%MOD*C[cnt][j]%MOD)%MOD;
			}
		}
		cout <<ans<<'\n';
		st[top++]=ans;
	}
	for(int i=top-2;i>-1;i--)
		cout << st[i]<<'\n';
}

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

int main(int argc, char **argv)
{
  ll n;
  cin>>n;
  ll count=0;
  
  for (ll i=1;i<n;i++){
      if (n%i==0)  count+=(n/i)-1;
      else count+=n/i;
    }
  cout<<count<<"\n";
	return 0;
}


Measured memory_bytes: 3632
import sys
import math

a, b, angle = map(int, sys.stdin.read().strip().split())

c = math.sqrt(a * a + b * b - 2 * a * b * math.cos(math.radians(angle)))
circum = a + b + c

s = (a + b + c) / 2
area = math.sqrt(s * (s - a) * (s - b) * (s - c))

h = area * 2 / a

for val in (area, circum, h):
    print('{0:.8f}'.format(val))



Measured memory_bytes: 5716
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define mp  std::make_pair
#define ll long long int
#define abs(n) ((n>0)?(n):((n)*(-1)))
#define CEIL(a,b) (((a) + ((b)-1)) / (b))
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define VREP_ll(v) for(std::vector<ll>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VREP_int(v) for(std::vector<int>::iterator itr = (v).begin(); itr != (v).end();itr++)
#define VALL(v) ((v).begin(),(v).end())
#define errln(v) cerr << (v) << endl;
#define println(v) cout << (v) << endl;

int main(int argc, const char * argv[]) {

	int a,b;
	cin >> a >> b;
	if(a >= 13){
		println(b);
	}else if(a>=6){
		println(b/2);
	}else{
		println(0);
	}

	return 0;
}


Measured memory_bytes: 256