akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 1000 + 7
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;

const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;

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

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0,cnt=0;;
    for(int i=0;i<n;++i){
        if(s[i]=='I'){
            cnt+=1;
            ans=max(cnt,ans);
        }
        else
        {
            cnt-=1;
        }
        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int , int> P;
typedef vector<P> vP;
typedef vector<vector<int>> vvi;
typedef vector<vector<P>> vvP;
#define INF 1000000
int main() {
	string s;
	cin >> s;
	int x = s.size();
	int ans = 0;
	for (int i = 1; i < x; i++) {
		if (s[i - 1] != s[i])ans++;
	}
	cout << ans<<endl;
	return 0;

}


Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<math.h>
using namespace std;

int main(){

    double v,s,floorH;
    int i;
    while(cin>>v){
        s=(v/9.8)*(v/2);
        for(i=1;i;i++){
            floorH=5*i-5;
            if(floorH>=s){
                cout<<i<<endl;
                break;
            }
        }
    }

return 0;
}

Measured memory_bytes: 1224
/*#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#include<bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define mp make_pair
#define len(s) s.size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define rocknroll cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0)
#define pq priority_queue
#define pii pair < int, int >
#define pll pair < ll, ll >
#define debug cout << " ---------------------------------------- "
#define kektor vector
#define int long long
typedef long long ll;
typedef long double ld;
typedef double dbl;
typedef unsigned long long ull;

using namespace std;


signed main()
{
    rocknroll;
    int n;
    cin >> n;
    vector<int>v(n);
    for(auto &i : v)
        cin >> i;
    sort(all(v));
    int sum = 0;
    for(int i = 0; i + 1 < n; ++i)
        sum += v[i];
    if (sum > v[n - 1])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define ll long long

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll a;
    cin>>a;
    cout << a+(a*a)+(a*a*a) << "\n";

    return 0;
}

Measured memory_bytes: 3604
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String W = scan.next().toLowerCase();
        int count = 0;
        int sys_count = 0;

        while(true){

            sys_count++;
            String T = scan.next();
          
            if(T.equals("END_OF_TEXT")){
                break;
            }

            if(W.equals(T.toLowerCase())){
                ++count;
            }

        }
        System.out.println(count);
    }
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
int n;
void add(vi &v, int i) {
	for (; i <= 2 * n; i += (i&-i))v[i]++;
}

int sum(vi &v, int i) {
	int ret = 0;
	for (; i > 0; i -= (i&-i))ret += v[i];
	return ret;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	vi c(2 * n), v(2 * n);
	REP(i, 2 * n) {
		char a;
		cin >> a >> v[i];
		c[i] = (a == 'B');
	}
	vi b(n), w(n);
	REP(i, 2 * n) {
		if (c[i])b[v[i] - 1] = i + 1;
		else w[v[i] - 1] = i + 1;
	}
	vvi bt(n + 1, vi(2 * n + 10, 0)), wt(n + 1, vi(2 * n + 10, 0));
	REP(i, n) {
		REP(j, 2 * n + 10) {
			bt[i + 1][j] = bt[i][j];
		}
		add(bt[i + 1], b[i]);
	}

	REP(i, n) {
		REP(j, 2 * n + 10) {
			wt[i + 1][j] = wt[i][j];
		}
		add(wt[i + 1], w[i]);
	}

	vvi dpb(n + 1, vi(n + 1, 0)), dpw(n + 1, vi(n + 1, 0));
	REP(i, n) {
		REP(j, n + 1) {
			dpb[i][j] = i - sum(bt[i], b[i]) + j - sum(wt[j], b[i]);
		}
	}

	REP(i, n + 1) {
		REP(j, n) {
			dpw[i][j] = i - sum(bt[i], w[j]) + j - sum(wt[j], w[j]);
		}
	}

	vvi dp(n + 1, vi(n + 1, INF));
	dp[0][0] = 0;
	REP(i, n + 1) {
		REP(j, n + 1) {
			if (i > 0)dp[i][j] = min(dp[i - 1][j] + dpb[i - 1][j], dp[i][j]);
			if (j > 0)dp[i][j] = min(dp[i][j - 1] + dpw[i][j - 1], dp[i][j]);
		}
	}
	cout << dp[n][n] << endl;
}


Measured memory_bytes: 110208
#pragma GCC optimize "-O3"
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define LSOne(S) (S & (-S))
#define ll long long
#define two pair<ll,ll>
#define twol pair<ll,ll>
#define four pair<two,two>
#define pb push_back
#define mk make_pair
#define y1 y1922
#define INF 1000000000000000000
#define P 1000000007
#define lmax 1000000000
#define nn 1000003
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define vi vector<ll>
#define vll vector<ll>
#define vtwo vector<two>
#define ALL(container) (container).begin(), (container).end()
#define sz(container) (ll)(container.size())
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define mid(a,b) (a+b>>1)
#define minN 0
#define maxN 10000000
#define na(x) ((x)<P?(x):(x)-P)
#define ab(a) (-(a)<(a)?(a):-(a))
#define FAST std::ios::sync_with_stdio(false)
#define xRand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define rnd rng
#define IT iterator
typedef
tree<
  ll,// aq pair<ll,ll> shegidzlia
  null_type,
  less/*_equal*/<ll>,// aqac
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
// '_equal' mashin ginda roca multiset gchirdeba
template<class key, class value,class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
ordered_map<ll, ll> my_map;
inline ll rin(){
	ll x=0,w=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if (ch=='-') w=0,ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return w?x:-x;
}
inline ll bin(){
	ll x=0;char ch=getchar();
	while (ch<'0'||ch>'9') ch=getchar();
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x;
}
map<vll,ll>mp;
ll n,ans;
string str;
ll get(vi v){
	ll p1=29,p2=1000003,p3;
	p3=p1;
	ll o=0;
	for(auto i:v){
		o+=p1*i;
		p1*=p3;
		p1%=p2;
		o%=p2;
	}
	return o;
}
void process(string str){
	map<char,ll>mp_ch;
	vi v;
	for(auto i:str){
		mp_ch[i]++;
	}
	for(char i='a';i<='z';i++){
		v.pb(mp_ch[i]);
	}
//	ll u=get(v);
	ans+=mp[v];
//	cout<<mp[u]<<endl;
	mp[v]++;
}
int main(){FAST;xRand;
cin>>n;
for(int i=0;i<n;i++){
	cin>>str;
	process(str);
}
cout<<ans<<endl;

}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
                 *   *   * *   *
                  *   *   *   *
                   *   * *   *
                     *  *   *
					   *  *


*/



Measured memory_bytes: 31488
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;


int main(){
  int n;cin>>n;
  vector<int> v(n+1);
  for(int i=1;i<=n;i++)cin>>v[i];
  int ans=0, temp=v[0];
  for(int i=1;i<=n;i++){
      if(v[i]>temp){
          ans+=v[i]-temp;
      }
      temp=v[i];
  }
  cout<<ans;
}

Measured memory_bytes: 256
import itertools
H, W = [int(_) for _ in input().split()]
Aij = [[0] * (W + 1)] + [[0] + [int(_) for _ in input().split()] for _ in range(H)]

count = 0
result = []

for i, j in itertools.product(range(1, H + 1), range(1, W)):
    if Aij[i][j] % 2:
        count += 1
        result += ['{} {} {} {}'.format(i, j, i, j + 1)]
        Aij[i][j + 1] += 1
for i in range(1, H):
    if Aij[i][W] % 2:
        count += 1
        result += ['{} {} {} {}'.format(i, W, i + 1, W)]
        Aij[i + 1][W] += 1

print(count)
print('\n'.join(result))


Measured memory_bytes: 19752
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define mp make_pair
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 1000005  //check the limits, man
const ll INF = 1e18;
int main()
{
    int n,i,x;
    ll t,a,b;
    in(n);
    cin >> a >> b;
    vi v(n);
    read(v,i,n);
    ll ans=0;
    if(a>b)
    {
        ans=b,ans*=(n-1);
    }
    else
    {
        x=(b/a);
        rep(i,n-1)
        {
            t=a,t*=(v[i+1]-v[i]);
            ans+=min(t,b);
        }
    }
    llout(ans);
}




Measured memory_bytes: 640
ENV[A='RUBY_THREAD_VM_STACK_SIZE']||exec({A=>?5*8},'ruby',$0)
F=->c{H[c].all?{|e|Z[e]?(Z[c]-Z[e])%2>0:(Z[e]=Z[c]^1;F[e])}}
N,M=gets.split.map &:to_i;H=Hash.new{|h,k|h[k]=[]};Z={1=>0}
M.times{a,b=gets.split.map &:to_i;H[a]<<b;H[b]<<a}
p (F[1]?Z.partition{|k,v|v<1}.map(&:size).reduce(:*):N*~-N/2)-M

Measured memory_bytes: 109760
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<pair<int, int>> A(N);
  REP(i, N) cin >> A[i].first >> A[i].second;

  vector<pair<int, int>> B(N);
  REP(i, N) cin >> B[i].first >> B[i].second;

  sort(ALL(A), [&](pair<int, int> const & l, pair<int, int> const & r){
      return l.second > r.second;
      });
  sort(ALL(B));

  vector<bool> used(N, false);

  int ans = 0;

  REP(i, N) REP(j, N){
    if(used[j]) continue;
    if(A[j].first < B[i].first && A[j].second < B[i].second){
      used[j] = true;
      ans++;
      break;
    }
  }

  cout << ans << "\n";

  return 0;
}

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

int main() {
  int nMember, nNeedMember;
  while(cin >> nMember >> nNeedMember, nMember | nNeedMember) {
    vector<int> dates(100, 0); //one base
    for(int i = 0; i < nMember; ++i) {
      int ndate;
      cin >> ndate;
      for(int j = 0; j < ndate; ++j) {
        int date;
        cin >> date;
        ++dates[date];
      }
    }
    auto max_itr = max_element(dates.begin(), dates.end());
    cout << ((*max_itr >= nNeedMember) ? distance(dates.begin(), max_itr) : 0) << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>

int main(void)
{

        int a,i,j,b;

        scanf("%d",&a);

        for(i=0; i<=9; i++){
                for(j=0; j<=9; j++){
                                b=i*j;
                        if(a==b) {printf("Yes\n"); a=1000;}
        }
                }
        if(a!=1000)printf("No\n");

        return 0;
}

Measured memory_bytes: 128
program sample
	implicit none
    real(8) :: a,b,x,y,x1,y1
    
    read(*,*) a,b
    
    x = a*100/8
    y = b*10
    x1 = (a+1)*100/8
    y1 = (b+1)*10
    
	if (x<=y .and. y<x1) then
    	write(*,*) int(y)
    else if (y<=x .and. x<y1) then
    	if (int(x) == x) then
    		write(*,*) int(x)
        else
        	write(*,*) int(x) + 1
        end if
    else
    	write(*,*) -1
    end if
    
    stop
end program sample

Measured memory_bytes: 256
/*Saurav Paul*/
#include<bits/stdc++.h>
using namespace std;

using vec = vector<int> ;
const int nax = 1e5 + 10;

vec indegree(nax);
vec graph[nax] ;
vec dp(nax, -1 ) ;

int dfs(int node){
	if(dp[node] != -1 ) return dp[node];
	int cnt = 0;
	for(auto x : graph[node] ){
		cnt = max(dfs(x) , cnt );
	}
	return dp[node] = cnt + 1; 
}


int main()
{
	int vertex, edge ;
	scanf("%d%d",&vertex,&edge);
	
	for(int i = 0 ; i < edge ; i++){
		int a , b; 
		scanf("%d%d",&a,&b);
		graph[a].emplace_back(b);
		indegree[b] ++;
	}
	
	int ans = 0;
	for( int i = 1; i <= vertex ; i++){
		if(indegree[i] == 0 ){
			ans = max(ans,dfs(i) );
		}
		
	}
	
	printf("%d\n",ans-1);
    return 0;
}


Measured memory_bytes: 11136
#include<cstdio>
#include<cmath>
typedef long long LL;
int D;
LL ans=0;
LL solve(int len){
	LL now=0,ans=1;
	for(int l=0,r=len-1;l<r;++l,--r){
		LL dw=(LL)pow(10,l),qaq=((LL)pow(10,r)-dw)/9;
		if(now<D){
			int wg=(D-now)/dw%10;
			now+=qaq*wg;
			ans=ans*(10-wg-(l==0));
		}else{
			int wg=(now-D)/dw%10;
			now-=qaq*wg;
			ans=ans*(10-wg-(l==0));
		}
	}
	if(len&1)ans*=10;
	if(now==D)return ans;
	return 0;
}
int main(){
	scanf("%d",&D);
	if(D%9)return puts("0"),0;
	D/=9;
	for(int i=1;i<=18;++i)
	if(pow(10,i)>D)ans+=solve(i);
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
    int N,K;
    cin >> N >> K;
    double p=0.0;
    for(int i=1;i<=N;i++){
        int j=i;
        double q=1.0000000000/N;
        while(j<K){
            q/=2.0;
            j*=2;
        }
        p+=q;
    }
    cout << setprecision(10)<< p << endl;
    return 0;
}

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

using namespace std;

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

    return gcd(b, a % b);
}

int calc(vector<int> v, int nu){
	v.erase(v.begin() + nu);

	for(int i=1;i<v.size();i++){
	//cout <<"EE "<< i << v.size() <<endl;
		v[i]=gcd(v[i], v[i-1]);
		if(v[i]==1) return 1;
	}

	return v[v.size()-1];
}

int main(){

	int n, ma=0;
	vector<int> v;

	cin>> n;
	v.resize(n);
	for(int i=0;i<n;i++) cin>> v[i];

	sort(v.begin(), v.end());

	for(int i=n-1;1<i;i--){
		if(v[i]==v[i-2]) v.erase(v.begin() + i-1);
	}

	if(v.size()==1){
		cout<< v[0] << endl;
		return 0;
	}

	if(v.size()==2){
		cout<< max(v[0], v[1]) << endl;
		return 0;
	}

	for(int i=0;i<v.size();i++){
		ma=max(ma, calc(v, i));
		//cout<<"cal"<<endl;
	}

	//for(int i=0;i<v.size();i++) cout<< v[i] << endl;

	cout<< ma << endl;
	//cout<< v[0] << " " << v[1] << endl;


}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]==a[1]&&a[1]==5&&a[2]==7)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
W, H, N = map(int, raw_input().split())
L, R, T, B = 0, W, H, 0
pos = []
for i in range(N):
    x, y, a = map(int, raw_input().split())
    if a == 1:
        L = max(x,L)
    elif a == 2:
        R = min(x,R)
    elif a == 3:
        B = max(y,B)
    elif a == 4:
        T = min(y,T)
if (R-L)<0 or (T-B)<0:
    print 0
else:
    print (R-L)*(T-B)

Measured memory_bytes: 2568
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){
    char s[100];
    int l;

    scanf("%s",s);
    l = strlen(s);
    for(int i=0;i<l;i++)
        s[i] = 'x';
    printf("%s",s);
    return 0;

}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A;
const ll mo=1000000007;

const int NUM_=10400001;
static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>A;
	inv[1]=fact[0]=factr[0]=1;
	for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
	for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	
	ll ret=0;
	for(i=1;i<=A;i++) {
		int a,b,c;
		a=i;
		if(i==A) {
			b=N-i;
			c=0;
		}
		else {
			b=N-A;
			c=A-i-1;
		}
		
		ll sum=0;
		for(j=i-1;j>=0;j--) {
			ll pat=fact[a-j]*fact[(a-j)+b-1]%mo*factr[(a-j)-1]%mo;
			(pat*=fact[a]*factr[j]%mo*factr[a-j]%mo*fact[(a-j)+b+c]%mo*factr[(a-j)+b]%mo)%=mo;
			if(j&1) ret-=pat;
			else ret+=pat;
		}
	}
	cout<<(ret%mo+mo)%mo<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 247408
def check(*a_list):
    ele_odd = len(a_list[0::2])
    ele_even = len(a_list[1::2])
    count = 0
    for i in a_list[0::2]:
        if i == "R":
            count += 1
        if i == "D":
            count += 1
        if i == "U":
            count += 1
    if count != ele_odd:
        return "No"

    count = 0
    for i in a_list[1::2]:
        if i == "L":
            count += 1
        if i == "D":
            count += 1
        if i == "U":
            count += 1
    if count != ele_even:
        return "No"
    return "Yes"


S = input()
print(check(*S))


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


int main(){

int x;
cin >> x;

int n = 120;
int ansa=0;
int ansb=0;

 for (int i = 0; i < n; i++)
    {
        
        for (int j = 0; j < n; j++)
        {
            if(i*i*i*i*i-j*j*j*j*j == x){
                ansa = i;
                ansb = j;
                goto goal;
                }
            if(i*i*i*i*i+j*j*j*j*j == x){
                ansa = i;
                ansb = -j;
                goto goal;
                }
        }
    }
   


goal:

cout << ansa <<" "<< ansb << endl;


}


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

namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ls = new int[3, 3];
            for (int i = 0; i < 3; i++)
            {
                var str = Console.ReadLine()
                    .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                    .Select(x => int.Parse(x))
                    .ToArray();
                for (int j = 0; j < 3; j++)
                {
                    ls[j, i] = str[j];
                }
            }

            int c11 = ls[0, 0];
            int c12 = ls[0, 1];
            int c13 = ls[0, 2];
            int c21 = ls[1, 0];
            int c22 = ls[1, 1];
            int c23 = ls[1, 2];
            int c31 = ls[2, 0];
            int c32 = ls[2, 1];
            int c33 = ls[2, 2];
            bool isTrue = false;
            if (c11 - c12 == c21 - c22 && c21 - c22 == c31 - c32)
            {
                if (c11 - c13 == c21 - c23 && c21 - c23 == c31 - c33)
                {
                    if (c12 - c13 == c22 - c23 && c22 - c23 == c32 - c33)
                    {
                        if (c11 - c21 == c12 - c22 && c12 - c22 ==c13 - c23)
                        {
                            if (c21 - c31 == c22 - c32 && c22 - c32 == c23 - c33)
                            {
                                if (c11- c31 == c12 - c32 && c12 - c32 ==c13 - c33)
                                {
                                    isTrue = true;
                                }
                            }
                        }
                    }
                }
            }
            if (isTrue)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.ReadLine();
        }
        
    }

}

Measured memory_bytes: 13396
import sys

N, X, Y = map(int, input().split())
X -= 1
Y -= 1

answer = [0 for _ in range(N-1)]

for i in range(N):
  for j in range(i+1, N):
    answer[min(j-i, abs(X-i) + 1 + abs(j-Y))-1] += 1

for k in range(N-1):
  print(answer[k])

Measured memory_bytes: 46172
#include <iostream>

using namespace std;

int gcd(int a, int b){
   if(a < b){
      int tmp = a;
      a = b;
      b = tmp;
   }

   if(a % b){
      return gcd(b, a % b);
   }
   else{
      return b;
   }

}

int main(){

   int a, b;

   cin >> a >> b;

   cout << gcd(a, b) << endl;

   return 0;
}


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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x);

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;

int main(){
    double W, H, x, y;
  	cin >> W >> H >> x >> y;
    double ans = W*H/2;
    DCOUT(ans,10);
    cout << " ";
    
    if(x==W/2&&y==H/2) cout << 1 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 256
import numpy as np

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

n_set = 0
if K % 2 == 0:
  if N >= K/2:
  	n_modhalf = (N - K/2) // K + 1
  	n_set += n_modhalf ** 3
  
n_modK = N // K
n_set += n_modK ** 3

print(int(n_set))

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

int main() {
  int N;
  cin >> N;
  long long ans = 0;
  long long wer = 1;
  int count = 0;
  while(count < N - 1){
    long long tmp = wer;
    wer += ans;
    ans = tmp;
    count++;
  }
  cout << ans * 2 + wer << endl;
}


Measured memory_bytes: 384
import operator
n = int(input())
arr=[]
for i in range(n):
    arr.append(input())
d={}
for i in arr:
    d[i]=0
for i in arr:
    d[i]+=1

val = sorted(d.values(),reverse=True)[0]

ans=[]
for i in d:
    if(d[i]==val):
        ans.append(i)

ans=sorted(ans)
#print(ans)
for x in ans:
    print(x)

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

using namespace std;

typedef long long int ll;

int n, w, values[109], weights[109];

int main() {
  ios::sync_with_stdio(0); cin.tie(); cout.tie();
  cin >> n >> w;
  ll vSum = 0;

  // take weights and values
  for (int i = 0; i < n; i++) {
    cin >> weights[i] >> values[i];
    vSum += values[i];
  }

  vector <ll> dp(vSum+1, 1000000005); // dp[i] = the min total weight of items with total value exactly i
  dp[0] = 0;

  for (int i = 0; i < n; i++)
    for (int value_already = vSum - values[i]; value_already >= 0; value_already--)
      dp[value_already+values[i]] = min(dp[value_already+values[i]], dp[value_already]+weights[i]);

  for (int i = vSum; i >= 0; i--)
    if (dp[i] <= w) {
      cout << i << endl;
      break;
    }

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;

#define loopi(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define loop(i, n) for (int i = 0; i < (int)n; i++)
#define loopeq(i, n) for (int i = 0; i <= (int)n; i++)
#define loopll(i, n) for (ll i = 0; i < (ll)n; i++)
#define looplleq(i, n) for (ll i = 0; i <= (ll)n; i++)

int main() {
    int n; cin >> n;
    vll as(n, 0);
    ll prod = 1;
    ll sh = 1000000000000000000;
    loop(i, n) {
        cin >> as[i];
        if (as[i] == 0) {cout << 0 << endl; return 0;}
    }
    loop(i, n) {
        if ((ld)sh / (ld)prod < (ld)as[i]) {
            cout << -1<< endl; return 0;
        }
        prod *= as[i];
    }
    cout << prod << endl;
}

Measured memory_bytes: 4052
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoderCs
{
    class Program
    {


        static List<int> Result = new List<int>();


        static void Main()
        {

            var Arg = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var Num = Arg[0];
            var X = Arg[1];
            var Y = Arg[2];

            for (int i = 1; i < Num; i++)
            {

                for (int j = i + 1; j <= Num; j++)
                {

                    if (i <= X)
                    {

                        if (j < X)
                        {

                            ResultEdit(j - i);

                        }
                        else if (j < Y)
                        {

                            int Compare1 = j - i;
                            int Compare2 = (X - i) + (Y - j) + 1;
                            ResultEdit(Compare1 > Compare2 ? Compare2 : Compare1);

                        }
                        else
                        {

                            ResultEdit((X - i) + (j - Y) + 1);

                        }

                    }
                    else if (i <= Y)
                    {

                        int Compare1, Compare2;
                        Compare1 = j - i;

                        if (j < Y)
                        {

                            Compare2 = (i - X) + (Y - j) + 1;

                        }
                        else
                            Compare2 = (i - X) + (j - Y) + 1;

                        ResultEdit(Compare1 > Compare2 ? Compare2 : Compare1);

                    }
                    else
                    {

                        ResultEdit(j - i);

                    }

                }

            }

            for (int i = 0; i < Num - 1; i++)
            {

                if (i < Result.Count) Console.WriteLine(Result[i]);
                else Console.WriteLine(0);

            }


        }

        static void ResultEdit(int Distance)
        {

            if (Result.Count < Distance) Result.Add(1);
            else Result[Distance - 1]++;

        }


}
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int  oh;
   int ohh;
   bool oj=true;
   bool ojj=false;
    string s;
    cin>>s;
    int len=s.size();
     for(int i=0;i<len;++i) {
        if(i%2==0) {
            if(s[i]=='L') oj=false;
        }
        else {
            if(s[i]=='R') oj=false;
        }
    }


     if(oj) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {

int a,b,s[110],d[110],e;
   cin >> a;
  
  for(int i=0;i<a;i++)
    cin >>s[i];
  
  b=0;
  
  for(int i=1 ;i<a-1;i++){
    if(((s[i-1]>s[i])&&(s[i]>s[i+1]))||((s[i-1]<s[i])&&(s[i]<s[i+1]))){
      b++;
    }
  }
  
  cout << b << endl;
  
  return 0;
}
   
  


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

int k, n;
const int MAX_N = 200000;
int a[MAX_N];

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

  int d[n];
  int max_d = 0;
  int sum = 0;

  for (int j = 0; j < n - 1; j++) {
    d[j] = a[j + 1] - a[j];
    sum += d[j];
    if (max_d < d[j])
    {
      max_d = d[j];
    }

    d[n - 1] = a[0] + k - a[n - 1];
    if (d[n - 1] > max_d) {
      max_d = d[n - 1];
    }
  }

  printf("%d", k - max_d);

  return 0;
}

Measured memory_bytes: 1792
//include
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

// conversion
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();
}

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

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

template <class T>
inline T nCr(T n, T r)
{
    T num = 1;
    for (int i = 1; i <= r; ++i)
    {
        num *= (n - i + 1) / i;
    }
    return num;
}
template <class T>
inline T nPr(T n, T r)
{
    r = n - r;
    T sum = 1;
    int i;
    for (i = n; i >= r + 1; --i)
        sum *= i;
    return sum;
}

template <class T>
inline T facctorial(T k)
{
    T sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

//numeric
template <class T>
inline T gcd(T a, T b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

template <class T>
inline T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#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())

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

//constant
constexpr double EPS = 1e-10;
const double PI = acos(-1.0);
constexpr LL INF = 1e10;

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

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

int main()
{
    int n;
    cin >> n;
    vector<double> v(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    sort(ALL(v));
    double ans = (v[0] + v[1]) / 2;
    for (int i = 2; i < n; ++i)
    {
        ans = (ans + v[i]) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/******************************************
* AUTHOR : GURUTEJA *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second

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

}

  int main() {
    debug();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int a,b,m,p,q,c,sum=0,minno=1e18,maxno=1e18;
    cin>>a>>b>>m;

    long long int x[a],y[b];

    for (int i = 0; i <a; ++i)
    {
    	cin>>x[i];
    	minno=min(minno,x[i]);
    }

    for (int i = 0; i <b; ++i)	
    {
    	cin>>y[i];
    	maxno=min(maxno,y[i]);
    }
    sum=(minno+maxno);
    for (int i = 0; i <m; ++i)
    {
    	cin>>p>>q>>c;
    	sum=min(sum,((x[p-1]+y[q-1])-c));
    }
     

    cout<<sum<<endl;

    return 0;
  }

Measured memory_bytes: 5180
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  int a, b; cin >> a >> b;
  cout << a*a-b << endl;
  system("pause");
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
typedef long long lld;
#define INF (1<<20)

int main(){
  int N; cin >> N;
  int ban[311][311];
  lld P[311][311];
  memset(P,0,sizeof(P));
  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++){
      cin >> ban[i][j];
      P[i][j] = P[i][j-1]+P[i-1][j]-P[i-1][j-1]+ban[i][j];
    }
  }
  lld ret = -INF;
  for(int i=1;i<=N;i++){
    for(int j=i;j<=N;j++){
      lld prev=0;
      for(int k=1;k<=N;k++){
	lld line = P[j][k]-P[i-1][k]-P[j][k-1]+P[i-1][k-1];
	ret = max(ret,line+prev);
	prev = max(line,prev+ban[i][k]+(i!=j?ban[j][k]:0));
      }
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 4200
import java.math.BigInteger

fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val n1 = sc.asSequence().take(9).map(String::toInt).toMutableList()

    val n = sc.nextInt()
    sc.asSequence().take(n).map(String::toInt).forEach {
        val idx = n1.indexOf(it)
        if (idx >= 0) {
            n1[idx] = 0
        }
    }
    if (n1[0] == 0 && n1[3] == 0 && n1[6] == 0
        || n1[1] == 0 && n1[4] == 0 && n1[7] == 0
        || n1[2] == 0 && n1[5] == 0 && n1[8] == 0
        || n1[0] == 0 && n1[1] == 0 && n1[2] == 0
        || n1[3] == 0 && n1[4] == 0 && n1[5] == 0
        || n1[6] == 0 && n1[7] == 0 && n1[8] == 0
        || n1[0] == 0 && n1[4] == 0 && n1[8] == 0
        || n1[2] == 0 && n1[4] == 0 && n1[6] == 0) {
        print("Yes")
    } else {
        print("No")
    }
}


Measured memory_bytes: 29720
#include <iostream>

using namespace std;

int main() 
{
	int x, h, m, s;
	cin >> x;
	h=x/3600;
	m=(x-h*3600)/60;
	s=x%60;
	cout << h << ":" << m << ":" << s << endl;
	
	return 0;
}


Measured memory_bytes: 3096
def is_umbalance(s):
    if len(s) == 2:
        return s[0] == s[1]
    if s[0] == s[1] or s[1] == s[2] or s[2] == s[0]:
        return True
    else:
        return False


def main(s):
    for i in range(len(s) - 1):
        if is_umbalance(s[i:i+2]):
            print(i + 1, i + 2)
            return
        if i + 2 < len(s) and is_umbalance(s[i:i+3]):
            print(i + 1, i + 3)
            return
    print(-1, -1)


if __name__ == '__main__':
    main(input())

Measured memory_bytes: 39536
def make_2dgrid(g)
  h = g.size
  s = Array.new(h + 1) { Array.new(h + 1, 0) }
  h.times do |i|
    h.times do |j|
      s[i + 1][j + 1] = s[i][j + 1] + s[i + 1][j] - s[i][j] + g[i][j]
    end
  end
  s
end

def query(s, x1, x2, y1, y2)
  s[x2][y2] - s[x1][y2] - s[x2][y1] + s[x1][y1]
end

n, k = gets.split.map(&:to_i)

k2 = 2 * k
gB = Array.new(k2) { Array.new(k2, 0) }
n.times do
  x, y, ci = gets.split
  x = x.to_i % k2
  y = (y.to_i + (ci == "W" ? k : 0)) % k2
  gB[x][y] += 1
end
ans = 0

sB = make_2dgrid(gB)

# 涙ぐましいランダムアクセス削減
sBk2 = sB[k2]
sBk20 = sBk2[0]
sB0 = sB[0]
sB00 = sB0[0]
k.times do |i|
  sBi = sB[i]
  sBik = sB[i + k]
  sBik0 = sBik[0]
  sBk2k2 = sBk2[k2]
  sB0k2 = sB0[k2]
  sBikk2 = sBik[k2]
  sBi0 = sBi[0]
  k.times do |j|
    ikjk = sBik[j + k]
    # score = query(sB, 0, i, 0, j)
    score = sBi[j] - sB0[j] - sBi0 + sB00
    # score += query(sB, i + k, k2, 0, j)
    score += sBk2[j] - sBik[j] - sBk20 + sBik0
    # score += query(sB, i, i + k, j, j + k)
    score += ikjk - sBi[j + k] - sBik[j] + sBi[j]
    # score += query(sB, 0, i, j + k, k2)
    score += sBi[k2] - sB0k2 - sBi[j + k] + sB0[j + k]
    # score += query(sB, i + k, k2, j + k, k2)
    score += sBk2k2 - sBikk2 - sBk2[j + k] + ikjk
    ans = score if score > ans
    score = n - score
    ans = score if score > ans
  end
end
p ans


Measured memory_bytes: 66428
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){

    int n,s;

    vector<int> num(10);

    for(int i = 0;i < 10;i++){
        num[i] = i;
    }

    while(cin >> n >> s){

        if(n == 0 && s == 0){
            break;
        }

        int ans = 0;
        
        for(int i = 0 ; i < (1 << num.size()) ; i++){
            int sum = 0;
            int bit_count = 0;
            for(int j = 0 ; j < num.size() ; j++){
                if( (i >> j) & 1){
                    sum += num[j];
                    bit_count++;
                    /*if(bit_count == n){
                        break;
                    }*/
                }
            }
            if(sum == s && bit_count == n){
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


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

typedef long long ll;
ll p =(ll)1e9+7;

map<int, int> prime_factor(int n){
    map<int, int> res;
    for(int i=2; i*i<=n; i++){
        while(n%i==0){
            ++res[i];
            n /= i;
        }
    }
    if(n!=1) res[n] = 1;
    return res;
}

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

    map<int,int> factor[N+1], mainFactor;
    for(int i=1; i<=N; i++){
        factor[i] = prime_factor(i);
        for(auto itr=factor[i].begin(); itr!=factor[i].end(); itr++){
            //cout << itr->first <<" "<< itr->second << endl;
            mainFactor[itr->first] += itr->second;
        }
    }
    ll ans=1;
    for(auto itr=mainFactor.begin(); itr!=mainFactor.end(); itr++){
        //cout <<" "<< itr->first <<" "<< itr->second << endl;
        ans *= (itr->second)+1; ans%=p;
    }
    
    cout << ans << endl;

}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    map<int, int> mp;

    int n;
    cin >> n;
    rep(i, n)
    {
        int a;
        cin >> a;
        mp[a]++;
    }

    int sum = 0;

    for (auto x : mp)
    {
        if (x.first <= x.second)
            sum += x.second - x.first;
        else
            sum += x.second;
    }

    OP(sum);

    return 0;
}

Measured memory_bytes: 4736
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

class AtCoder
{
    const int MOD = 1000000007;
    int Check(int start, int[] waters)
    {
        int ret = start;
        foreach (int i in Enumerable.Range(0, waters.Length).Skip(1))
        {
            //Console.WriteLine(ret);
            ret = waters[i] - ret;
        }
        //Console.WriteLine($"{start} {ret}");
        return ret;
    }
    public void Slove()
    {
        //var inputs = Console.ReadLine().Split();
        int n = int.Parse(Console.ReadLine());
        int[] waters = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int aStart = 0;
        for(int start = 0, end = waters[0]; start <= end;)
        {
            int center = (start + end) / 2;
            int v = Check(center, waters) + center;

            if (v == waters[0])
            {
                aStart = center;
                break;
            }
            else if(v > waters[0])
                end = center - 1;
            else
                start = center + 1;
        }
        int[] ans = new int[n];
        ans[0] = waters[0] - aStart;
        foreach(int i in Enumerable.Range(0, n).Skip(1))
        {
            ans[i] = waters[i - 1] - ans[i - 1];
        }
        Console.WriteLine(string.Join(" ", ans.Select(x => x * 2)));
        //ans = Enumerable.Range(0, n).Select(x => ans[x] + ans[(x + 1) % n]).ToArray();
        //Console.WriteLine(string.Join(" ", ans.Select(x => x)));

    }
    static void Main()
    {
        var ac = new AtCoder();
        ac.Slove();
    }
}

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

int main()
{
  int n, m, p, x, t_sum = 0;
  vector<int> t(100);
  vector<int> ans(100);

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> t[i];
    t_sum += t[i];
  }
  cin >> m;
  for (int i = 0; i < m; i++)
  {
    cin >> p >> x;
    ans[i] = t_sum - t[p - 1] + x;
  }
  for (int i = 0; i < m; i++)
    cout << ans[i] << endl;

}

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

 int main() {
   string S, e = "erase", er = "eraser", d = "dream", dr = "dreamer";

   cin >> S;

   while(1) {
     if (S.length() >= 5 && S.substr(S.length() - 5, 5) == e) S = S.substr(0, S.length() - 5);
     else if (S.length() >= 6 && S.substr(S.length() - 6, 6) == er) S = S.substr(0, S.length() - 6);
     else if (S.length() >= 5 && S.substr(S.length() - 5, 5) == d) S = S.substr(0, S.length() - 5);
     else if (S.length() >= 7 && S.substr(S.length() - 7, 7) == dr) S = S.substr(0, S.length() - 7);
     else break;
   }

   if (S.length() == 0) cout << "YES" << endl;
   else cout << "NO" << endl;
 }


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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> Dif(M - 1);
	vector<int> X(M);
	for (int i = 0; i < M; i++) cin >> X[i];
	sort(X.begin(), X.end());
	for (int i = 0; i < M - 1; i++) Dif[i] = X[i + 1] - X[i];
	sort(Dif.begin(), Dif.end());
	int ans = 0;
	for (int i = 0; i < M - N; i++) ans += Dif[i];
	cout << ans << endl;
}

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

int main() {
    long double a,b,h,m,p = 3.141592653589;
    cin>>a>>b>>h>>m;
    long double C = ((60*h+m)/2 - 6*m) / 180;
    long double x = a*a + b*b - 2*a*b*cos(C*p);
    cout<<setprecision(15)<<sqrt(x)<<endl;
}

Measured memory_bytes: 4140
N = int(input())
P = [int(input()) for _ in range(N)]
P.sort()
S = sum(P)
if S % 10 == 0:
    for i in range(N):
        if P[i] % 10 != 0:
            print(S-P[i])
            exit()
    print(0)
else:
    print(S)


Measured memory_bytes: 38256