akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int H, W;
char S[400][400];
bool used[400][400];
long cnt;
long cnt_w;
long cnt_b;

void dfs(int h, int w, int n){
    if(used[h][w] == true) return;
    used[h][w] = true;
    if(S[h][w] == '.') cnt_w++;
    else cnt_b++;
    
    if(h-1 >= 0 && S[h][w] != S[h-1][w]) dfs(h-1, w, n);
    if(h+1 <= H-1 && S[h][w] != S[h+1][w]) dfs(h+1, w,n);
    if(w-1 >= 0 && S[h][w] != S[h][w-1]) dfs(h, w-1, n);
    if(w+1 <= W-1 && S[h][w] != S[h][w+1]) dfs(h, w+1, n);
    return;
}

int main(){
    cin >> H >> W;
    long ans_w = 0, ans_b = 0;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> S[i][j];
            used[i][j] = false;
        }
        //cout << i << H << endl;
    }
    //cout << H << W << endl;
    for(int i = 0; i < H; i++){
        for(int j= 0; j < W; j++){
            cnt_w = 0;
            cnt_b = 0;
            if(S[i][j] == '#') {
                dfs(i, j, i*W+j);
                ans_w += cnt_w*cnt_b;
                //cout << cnt_w << endl;
            }
        }
    }
    cout << ans_w << endl;
}

Measured memory_bytes: 13056
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws InterruptedException {
		FastScanner fs=new FastScanner();
		int x=fs.nextInt();
		x-=400;
		System.out.println(8-x/200);
	}
	
	void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
	}

}


Measured memory_bytes: 32616
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define inf1 INT_MAX
#define inf2 LLONG_MAX
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define sbit __builtin_popcount
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define rit(it,x) for(auto it=x.begin();it!=x.end();it++)
#define cases(t) int t; cin>>t; rep(casn,1,t+1)
#define fill(a,b) memset(a,b,sizeof(a))
#define dbg(x) cerr<<#x<<" "<<x<<endl;
#define dbga(arr,n) cerr<<#arr<<": "; rep(tt,0,n)cerr<<arr[tt]<<" "; cerr<<endl;
#define infile ifstream fin; fin.open("input.txt")
#define outfile ofstream fout; fout.open("output.txt")
#define vec vector<int>
#define pii pair<int,int>
#define plii pair<ll,int>
#define pll pair<ll,ll>
#define p_queue priority_queue< plii,vector< plii >,greater< plii > > 
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define si(x) scanf("%d",&x)
#define sc(x) scanf("%c",&x)
#define sl(x) scanf("%lld",&x)
#define sst(x) scanf("%s",x)
#define pl(x) printf("%lld\n",x)
#define pi(x) printf("%d\n",x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mex 100005

inline ll binex(ll a,ll b)
{
    ll ans=1,temp=a%mod;
    while(b!=0){
        if(b&1) ans=(ans*temp)%mod;
        temp=(temp*temp)%mod;
        b=b>>1;
    }
    return ans;
}

inline int solve(int n,int w,int wt[],int val[])
{
    ll dp[mex][n]; //mex = n*val
    for(int i=0;i<n;i++) dp[0][i]=0;
    for(int i=1;i<mex;i++) dp[i][0]=inf1; 
    dp[val[0]][0]=wt[0];
    for(int i=1;i<mex;i++){
        for(int j=1;j<n;j++){
            if(val[j]<=i) dp[i][j]=min(dp[i][j-1],wt[j]+dp[i-val[j]][j-1]);
            else dp[i][j]=dp[i][j-1];
        }
    }
    for(int i=mex-1;i>=0;i--){
        if(w>=dp[i][n-1]) return i;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,w; cin>>n>>w;
    int val[n],wt[n];
    rep(i,0,n) cin>>wt[i]>>val[i];
    cout<<solve(n,w,wt,val)<<endl;
}

Measured memory_bytes: 78336
//written by NewbieChd
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 10003;
char s[N];

int main() {
    int n, len, i, a = 0, b = 0, c = 0, ans = 0;
    scanf("%d", &n);
    while (n--) {
        scanf("%s", s + 1), len = strlen(s + 1);
        for (i = 1; i <= len; ++i)
            if (s[i] == 'B' && s[i - 1] == 'A')
                ++ans;
        if (s[len] == 'A')
            s[1] == 'B' ? ++c : ++a;
        else
            if (s[1] == 'B')
                ++b;
    }
    if (c) {
        ans += c - 1;
        if (a)
            ++ans, --a;
        if (b)
            ++ans, --b;
    }
    ans += min(a, b);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
string t;
int s[4][4005],a[4005];
ll ans,n;
int main()
{
	cin>>n>>t;
    for(int i=1;i<=n;i++)
{
	if(t[i-1]=='R')a[i]=0;
    if(t[i-1]=='G')a[i]=1;
    if(t[i-1]=='B')a[i]=2;
}
     for(int i=1;i<=n;i++)
   {
     for(int j=0;j<=2;j++) s[j][i]=s[j][i-1];
     s[a[i]][i]=s[a[i]][i-1]+1;
    } 
       for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
        {
	if(a[i]==a[j])continue;
    ans+=s[3-a[i]-a[j]][n]-s[3-a[i]-a[j]][j];
    if(2*j-i<=n&&a[2*j-i]==3-a[i]-a[j])ans--;
}
cout<<ans;
return 0;
}

Measured memory_bytes: 3660
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static int N,K;
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		N=sc.nextInt();
		K=sc.nextInt();
		int[][] a = new int[K][N];
		for(int i=0;i<K;i++){
			Arrays.fill(a[i], -1);
		}
		for(int i=0;i<K;i++){
			int m=sc.nextInt();
			for(int j=0;j<m;j++){
				a[i][j]=sc.nextInt();
			}
		}
		int R=sc.nextInt();int ans=0;
		int[] b = new int[N+1];
		for(int i=0;i<R;i++){
			int x = sc.nextInt();
			int y = sc.nextInt();
			for(int k=0;k<K;k++){
				for(int j=0;j<N;j++){
					for(int h=0;h<N;h++){
						if(a[k][j]==x&& a[k][h]==y || a[k][j]==y&& a[k][h]==x){
							b[a[k][j]]=b[a[k][h]]=1;
						}
					}
					
				}
			}
		}
		for(int i=0;i<N+1;i++){
			ans+=b[i];
		}
		System.out.println(ans);
		
	}

}

Measured memory_bytes: 23136
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#define fi first
#define se second
#define pb(i) push_back(i)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define mes(a, b) memset(a, b, sizeof(a))
#define sbs(i, j) substr(i, j)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6 + 10;
const int INF = 0x3f3f3f3f;
const int inf = -INF;
const int mod = 1e9 + 7;
const double pi = acos(-1.0);
int n, m, k;
char a[10][10];
int cnt[N];
int c[10], r[10];
int f[N];
int visr[10], visc[10];
int main()
{
    while (cin >> n >> m >> k)
    {
        int sum = 0;
        rep(i, 0, n - 1)
        {
            cin>>a[i];
            rep(j, 0, m - 1)
            {
                if (a[i][j] == '#')
                {
                    r[i]++;
                    c[j]++;
                    sum++;
                }
            }
        }
        int ans = 0;
        for (int i = 0; i < (1 << n); i++)
        {
            for (int j = 0; j < (1 << m); j++)
            {
                int tmp = 0;
                mes(visr,0);
                mes(visc,0);
                rep(k,0,n-1)
                {
                    if ((i >> k) & 1)
                    {
                        tmp += r[k];
                        visr[k] = 1;
                    }
                }
                rep(k,0,m-1)
                {
                    if ((j >> k) & 1)
                    {
                        tmp += c[k];
                        rep(o, 0, n - 1)
                        {
                            if (a[o][k] == '#' && visr[o])
                            {
                                tmp--;
                            }
                        }
                        visc[k] = 1;
                    }
                }
                if (sum - tmp == k)
                    ans++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

int main() {
    ll N;
    cin >> N;
    vector<ll> W(N);
    rep(i, N) cin >> W[i];
    vector<ll> cumsum(N + 1, 0);
    rep(i, N) cumsum[i + 1] = W[i] + cumsum[i];
    ll mn = 1e9;
    for (int T = 1; T < N; T++) {
        if (abs(cumsum[T] - (cumsum[N] - cumsum[T])) < mn) {
            mn = abs(cumsum[T] - (cumsum[N] - cumsum[T]));
        }
    }
    cout << mn << endl;
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  int k=n%10;
  if(k==2 || k==4||k==5||k==7||k==9){
      cout<<"hon"<<endl;
  }
  else if(k==3){
  cout<<"bon"<<endl;
  }
  else{
    cout<<"pon"<<endl;
   }
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
using namespace std;
int n,m,l,r,arr[100100],ans;
int main ()
{
cin>>n>>m;
for(int i=0;i<m;i++)
  {
  cin>>l>>r;
    arr[l]++;
    arr[r+1]--;
  }
  for(int i=1;i<=n;i++)
  {
 arr[i]+=arr[i-1];
    if(arr[i]==m)
    ans++;
  }

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    vector<ll> A(3);
    cin >> A[0] >> A[1] >> A[2];
    sort(A.begin(), A.end());
    if(A[0] + A[1] == A[2]) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=1e9;
const long long IINF=1e18;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,W,T; cin >> N >> M >> W >> T;
    vector<string> S(M),comp;
    vector<int> V0(M),L(N),X(N),Y(N),cS(M),V(M);
    vector<ll> P0(M),P(M);
    vector<vector<string>> R(N);
    vector<vector<int>> cR(N);
    vector<vector<ll>> Q(N);
    for (int i=0;i<M;++i){
        cin >> S[i] >> V0[i] >> P0[i];
        comp.emplace_back(S[i]);
    }
    for (int i=0;i<N;++i){
        cin >> L[i] >> X[i] >> Y[i];
        for (int j=0;j<L[i];++j){
            string r; int q; cin >> r >> q;
            R[i].emplace_back(r);
            Q[i].emplace_back(q);
            comp.emplace_back(r);
        }
    }
    X.emplace_back(0); Y.emplace_back(0);
    sort(comp.begin(),comp.end());
    comp.erase(unique(comp.begin(),comp.end()),comp.end());
    for (int i=0;i<M;++i){
        cS[i]=lower_bound(comp.begin(),comp.end(),S[i])-comp.begin();
        V[cS[i]]=V0[i]; P[cS[i]]=P0[i];
    }
    for (int i=0;i<N;++i){
        for (int j=0;j<L[i];++j){
            int cr=lower_bound(comp.begin(),comp.end(),R[i][j])-comp.begin();
            cR[i].emplace_back(cr);
        }
    }
    vector<vector<ll>> dp0(1<<N,vector<ll>(W+1,-IINF));
    vector<vector<int>> dp1(1<<(N+1),vector<int>(N+1,INF));
    auto d=[&](int i,int j){return abs(X[i]-X[j])+abs(Y[i]-Y[j]);};
    dp0[0][0]=dp1[0][N]=0;
    for (int mask=1;mask<(1<<N);++mask){
        int pre=mask,now;
        for (int i=N-1;i>=0;--i) if (mask&1<<i){
            now=i; pre^=1<<i; break;
        }
        for (int j=0;j<=W;++j) dp0[mask][j]=dp0[pre][j];
        for (int j=0;j<=W;++j){
            for (int k=0;k<L[now];++k){
                if (j+V[cR[now][k]]<=W){
                    dp0[mask][j+V[cR[now][k]]]=max(dp0[mask][j+V[cR[now][k]]],dp0[mask][j]+P[cR[now][k]]-Q[now][k]);
                }
            }
        }
    }
    for (int mask=0;mask<(1<<(N+1));++mask){
        for (int i=0;i<=N;++i){
            for (int j=0;j<=N;++j){
                if (!(mask&1<<j)){
                    dp1[mask|1<<j][j]=min(dp1[mask|1<<j][j],dp1[mask][i]+d(i,j));
                }
            }
        }
    }
    vector<pair<ll,int>> v;
    for (int mask=0;mask<(1<<N);++mask){
        ll Max=0;
        for (int j=0;j<=W;++j) Max=max(Max,dp0[mask][j]);
        v.emplace_back(Max,dp1[mask|1<<N][N]);
    }
    vector<ll> dp(T+1,-IINF);
    dp[0]=0;
    for (int i=0;i<=T;++i){
        for (auto p:v){
            ll val=p.first; int t=p.second;
            if (i+t<=T) dp[i+t]=max(dp[i+t],dp[i]+val);
        }
    }
    ll ans=0;
    for (int i=0;i<=T;++i) ans=max(ans,dp[i]);
    cout << ans << '\n';
}



Measured memory_bytes: 13268
#include <iostream>

using namespace std;

int main(){
  int n;
  long long tot_pair = 0;
  bool odd_flag = false;
  cin >> n;
  for (int i=0;i<n;i++) {
    long long a;
    cin >> a;
    if (a > 0 && odd_flag) {
      tot_pair++;
      a--;
    }
    tot_pair += a / 2;
    if (a % 2 == 1) {
      odd_flag = true;
    } else {
      odd_flag = false;
    }

  }
  cout << tot_pair << endl;
  
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long 
#define M 1000000007
#define P pair<int,int>

int n,k;
ll ans;

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

  for(int b=1;b<=n;b++){
    ans+= (n/b)*max(0,b-k);
    ans+= max(0,n%b-k+1);
  }
  if(k==0)
    ans-=n;

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

//snuke
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
  mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
  mint operator+(const mint a) const { mint res(*this); return res+=a; }
  mint operator-(const mint a) const { mint res(*this); return res-=a; }
  mint operator*(const mint a) const { mint res(*this); return res*=a; }
  mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; }
  // for prime mod
  mint inv() const { return pow(mod-2); }
  mint& operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const { mint res(*this); return res/=a; }
}; 
 
vector<ll> inv,fact,invfact;
void mod_build(int n){  
  fact.resize(n+1); inv.resize(n+1); invfact.resize(n+1);
  fact[0]=inv[0]=invfact[0]=1; inv[1]=1;
  rep(i,n){
    fact[i+1]=fact[i]*(i+1)%mod;
    if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
    invfact[i+1]=invfact[i]*inv[i+1]%mod;
  }
}
ll perm(int n,int k){ if(n<0||k<0||k>n){ return 0; } else { return fact[n]*invfact[n-k]%mod; } }
ll comb(int n,int k){ if(n<0||k<0||k>n){ return 0; } else { return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod; }}
ll modpow(ll n,ll k){
  k%=mod-1; if(k<0)k+=mod-1;
  ll ret=1; while(k){ if(k&1)ret=ret*n%mod; n=n*n%mod; k>>=1; }
  return ret;
}
ll modinv(ll a){ return modpow(a, mod-2); }

int main(){
  mod_build(mx);
  int n,k;
  cin >> n >> k;

  rep(i,k){
    int cnt = i+1;
    mint ans = comb(n-k+1,cnt);
    ans *= comb(k-1,i);
    cout << ans.x << endl;
  }
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>

int main() {

	int K, A, B;

	std::cin >> K;
	std::cin >> A >> B;

	if (A % K == 0) {
		std::cout << "OK";
	}else{
		if (A + (K - (A % K)) <= B) {
			std::cout << "OK";
		}
		else {
			std::cout << "NG";
		}
	}
	// A + (K - (A % K)) // Aより大きい最初のKの倍数
}

Measured memory_bytes: 3636
N, M = map(int, input().split())
X = [int(x) for x in input().split()]

s = sorted(X)
dist = [s[n]-s[n-1] for n in range(1,len(s))]
dist = sorted(dist)[:M-N]
if N >= M:
  print(0)
else:
  res = 0
  for n in range(len(dist)):
    res += dist[n]
  print(res)

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

int main(){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  string ans="";
  ans+=s1.at(0);ans+=s2.at(1);ans+=s3.at(2);
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

class Node:
    def __init__(self):
        self.is_root = True
        self.parent = None
        self.child_num = 0
    
    def root_node(self):
        node = self
        while not node.is_root:
            node = node.parent
        return node

def main():
    N, M = map(int, input().split())

    nodes = [Node() for i in range(N)]

    ab = [list(map(int, input().split())) for i in range(M)]
    
    inc = (N * (N-1)) // 2
    ans = [inc]
    for i in range(M-1, -1, -1):
        a, b = ab[i]
        a -= 1
        b -= 1
        root_a = nodes[a].root_node()
        if root_a != nodes[a]:
            nodes[a].parent = root_a
        root_b = nodes[b].root_node()
        if root_b != nodes[b]:
            nodes[b].parent = root_b
        if root_a == root_b:# もともと連結成分だった場合
            ans.append(inc)
        else:# 新たに連結成分になった場合
            # if root_b.child_num > root_a.child_num:
            #     tmp = root_a
            #     root_a = root_b
            #     root_b = tmp
            inc -= (root_a.child_num + 1) * (root_b.child_num + 1)
            ans.append(inc)
            root_b.is_root = False
            root_b.parent = root_a
            root_a.child_num += root_b.child_num + 1

    for i in range(M-1, -1, -1):
        print(ans[i])

if __name__ == "__main__":
    main()



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


int main() {
	ios::sync_with_stdio(false);
	int R, G, B, n;
	cin >> R >> G >> B >> n;
	int ans = 0;
	for (int r = 0; r * R <= n; r++)
		for (int g = 0; g * G + r * R <= n; g++) {
			int rem = n - r * R - g * G;
			if (rem % B != 0 || rem < 0) continue;
//			cout << r << " " << g << " " << rem / B << endl;
			ans++;
		}
	cout << ans << endl;


	return 0;
}


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

double memo[2000][2001];
double prob(int k, int t, const string& s){
  if(memo[k][t] >= 0) return memo[k][t];
  double& res = memo[k][t];
  if(t == 0 && s[k] == 'R') return res = 1;
  if(t == 0 && s[k] == 'B') return res = 0;
  const int N = s.size();
  res = 0;
  for(int d = 1; d <= 6; d++){
    res += prob((k + d) % N, t - 1, s) / 6.0;
  }
  return res;
}

int main(){
  int N, T;
  while(cin >> N >> T && N){
    REP(i, N)REP(j, T + 1) memo[i][j] = -1;
    string s;
    cin >> s;
    double ans = 0;
    REP(i, N){
      ans = max(ans, prob(i, T, s));
    }
    printf("%.16lf\n", ans);
  }
  return 0;
}

Measured memory_bytes: 32700
#include <stdio.h>
int main(){
    int n,ans=0;
    scanf("%d",&n);
    int arr[n];
    for(int i=0;i<n;i++){
        scanf("%d",&arr[i]);
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(arr[i]!=arr[j]&&arr[j]!=arr[k]&&arr[k]!=arr[i]&&arr[i]+arr[j]>arr[k]&&arr[j]+arr[k]>arr[i]&&arr[k]+arr[i]>arr[j]){
                    ans++;
                }
            }
        }
    }
    printf("%d\n",ans);
}

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

typedef ostringstream OSS;
typedef istringstream ISS;

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<PII> VPII;

#define COST first
#define POS second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(void) {
    int N;
    cin >> N;
    VI ps(N);
    for (auto &p : ps) cin >> p;

    vector<VPII> es(N);
    for (int i = 0; i < N; i++) {
        if (ps[i] == 0) {
            for (int j = 1; j <= 6; j++) {
                if (i + j >= N) { break; }
    
                es[i].PB(MP(1, i + j));
            }
        } else {
            es[i].PB(MP(0, i + ps[i])); // auto move
        }
    }

    priority_queue<PII, vector<PII>, greater<PII>> q;
    q.push(MP(0, 0));
    
    VI dist(N, INF);
    dist[0] = 0;

    while (q.size()) {
        PII cur = q.top();
        q.pop();

//        cout << cur.POS << " " << cur.COST << endl;
        
        if (cur.COST > dist[cur.POS]) {
            continue;
        }

        for (auto e : es[cur.POS]) {
            int next_cost = cur.COST + e.COST;
            int next_pos = e.POS;

//            cout << "--- " << next_cost << " " << next_pos << endl;

            if (next_cost < dist[next_pos]) {
                q.push(MP(next_cost, next_pos));
                dist[next_pos] = next_cost;
            }
        }
    }

    cout << dist[N - 1] << endl;

	return 0;
}

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

int main(){
	int a[10010];
	int b[10010];
	char op[10010];
	int i = 0, i2, i3 = 0;
	while (i < 10010){
		cin >> a[i];
		cin >> op[i];
		cin >> b[i];
		if (op[i] == '?'){
			i2 = i;
			break;
		}
		i++;
	}
	while (i3 <= i2 + 1){
		if (op[i3] == '+'){
			cout << a[i3] + b[i3] << endl;
		}
		if (op[i3] == '-'){
			cout << a[i3] - b[i3] << endl;
		}
		if (op[i3] == '*'){
			cout << a[i3] * b[i3] << endl;
		}
		if (op[i3] == '/'){
			cout << a[i3] / b[i3] << endl;
		}
		i3++;
	}
	return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    int x,y,z;
    cin >> x >> y >> z;
    if(x + y + z >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 1005

int r;

int main()
{
    _FastIO;
    cout.precision(20);
    cin >> r;
    cout << fixed << (3.141592653589793238462643383279502884197) * (2 * r) << endl;
    return 0;
}


Measured memory_bytes: 3780
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char in[120];
char out[120];
int main(){
	scanf("%s",in);
	int at=0;
	for(int i=0;in[i];i++){
		if(in[i]=='B'){
			if(at>0)at--;
		}else out[at++]=in[i];
	}
	out[at]=0;printf("%s\n",out);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9;

int main(){
  int N,M;
  cin>>N>>M;
  if ((N+M)%2==0){
    cout << (N+M)/2<<endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var vals = Console.ReadLine().Split(' ');
            var sum = vals.Select(v => int.Parse(v)).Sum();
            Console.WriteLine(sum >= 22 ? "bust" : "win");
        }
    }
}


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

#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i,a) for (auto i = rbegin(a); i != rend(a); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-10;
ll mod = static_cast<ll>(1e9 + 7);
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }


ll n, k;
void solve() {
    cin >> n >> k;
    n %= k;
    cout << min(n, k - n) << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 256
S = input()
if S[0] == "A" and "C" in S[2:-1]:
  a = list(S)
  a.remove("A")
  a.remove("C")
  count = 0
  for i in range(len(a)):
    if a[i].islower():
      count += 1
  if count == len(a):
    ans = "AC"
  else:
    ans = "WA"
else:
  ans = "WA"

print(ans)

Measured memory_bytes: 3064
a, b, c, x, y = map(int, input().split())

single = a*x+b*y
pair_max = 2*c*max(x, y)
pair_min = 2*c*min(x, y) + a*abs(x-y)*(x>y) + b*abs(x-y)*(x<y)

print(min(single, pair_max, pair_min))

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

int i, j;

vector <string> word(string str);

int main(void)
{
	string str;
	char type;
	while (cin >> str >> type, type != 'X'){
		int flag = 0;
		vector <string> vs = word(str);
		if (type == 'L'){
			cout << vs[0];
			for (i = 1; i < vs.size(); i++){
				vs[i][0] ^= 32;
				cout << vs[i];
			}
			puts("");
		}
		if (type == 'U'){
			for (i = 0; i < vs.size(); i++){
				vs[i][0] ^= 32;
				cout << vs[i];
			}
			puts("");
		}
		if (type == 'D'){
			for (i = 0; i < vs.size(); i++){
				cout << vs[i];
				if (i + 1 != vs.size()) cout << "_";
			}
			puts("");
		}
	}
	
	return 0;
}

vector <string> word(string str)
{
	vector <string> vs;
	bool flag = false;
	for (i = 0; i < str.size(); i++){
		if (str[i] == '_') {
			flag = true;
			break;
		}
	}
	
	string tmp;
	if (flag){
		for (i = 0; i < str.size(); i++){
			if (str[i] != '_'){
				tmp += (str[i] |= 32);
			}
			else {
				vs.push_back(tmp);
				tmp.clear();
			}
		}
		vs.push_back(tmp);
		return vs;
	}
	
	if ('a' <= str[0] && str[0] <= 'z'){
		for (i = 0; i < str.size(); i++){
			if (!('A' <= str[i] && str[i] <= 'Z')){
				tmp += (str[i] |= 32);
			}
			else {
				vs.push_back(tmp);
				tmp.clear();
				break;
			}
		}
		for (; i < str.size(); i++){
			tmp += (str[i] |= 32);
			if (('A' <= str[i + 1] && str[i + 1] <= 'Z') && i + 1 < str.size()){
				vs.push_back(tmp);
				tmp.clear();
			}
		}
		vs.push_back(tmp);
		return vs;
	}
	
	if ('A' <= str[0] && str[0] <= 'Z'){
		for (i = 0; i < str.size(); i++){
			tmp += (str[i] |= 32);
			if (('A' <= str[i + 1] && str[i + 1] <= 'Z') && i + 1 < str.size()){
				vs.push_back(tmp);
				tmp.clear();
			}
		}
		vs.push_back(tmp);
		return vs;
	}
	
	return vs;
}
	

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

int main()
{
    int N;
    cin >> N;
    long long A[N];
    for (int i = 0; i < N; ++i)
        cin >> A[i];
    long long maxVal = 0;
    for (int i = 0; i < N - 1; ++i)
    {
        for (int j = i + 1; j < N; ++j)
        {
            long long val = A[i] - A[j];
            if (val < 0)
            {
                val = -val;
            }
            maxVal = max(val, maxVal);
        }
    }
    cout << maxVal << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

signed main() {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    FOR(i, 0, N) {
        int h;
        cin >> h;
        ans += (h >= K);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

typedef long long LL;

using namespace std;

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

int main(void) {
	vector<int>n(4);
	for (int i = 0; i < 4; i++)cin >> n[i];
	sort(n.begin(), n.end());
	if (n[0] == 1 && n[1] == 4 && n[2] == 7 && n[3] == 9) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
        bool cup[3];
        char c, c2;

        cup[0] = true;
        cup[1] = cup[2] = false;
        while (scanf("%c%*[,]%c%*[\n]", &c, &c2) != EOF) {
                int i = c - 'A';
                int i2 = c2 - 'A';
                bool tmp = cup[i];
                cup[i] = cup[i2];
                cup[i2] = tmp;
        }

        int i;
        for (i = 0; i < 3; i++) {
                if (cup[i]) {
                        printf("%c\n", 'A' + i);
                        break;
                }
        }

        return 0;
}

Measured memory_bytes: 2600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int A, B, K;
    cin >> A >> B >> K;

    int big = max(A, B);
    int cnt = 0;
    int ans;
    for(int i=big;i>0;--i){
        if( A%i == 0 && B%i == 0 )  cnt++;
        if( cnt == K ){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
#define ll long long
map<int, int>mo;
const int maxn = 2e5 + 5;
int a[maxn], b[maxn];
int main()
{
	int n; cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	int xsum = a[0];
	for (int i = 1; i < n; i++)
	{
		xsum ^= a[i];
	}
	for (int i = 0; i < n; i++)
	{
		cout << (a[i]^xsum) << " ";
	}

	 
}

Measured memory_bytes: 4336
#include <stdio.h>

int main ()
{
	int w,h,n;
	scanf("%d %d %d \n",&w,&h,&n);
	int block[h][w];
	for(int i=0;i<h;++i)
	{
		for(int j=0;j<w;++j)
		{
			block[i][j]=0;
		}
	}
	for(int k;k<n;++k)
	{
		int x,y,a;
		scanf("%d %d %d \n",&x,&y,&a);
		switch (a)
		{
			case 1:
			for(int i=0;i<h;++i)
			{
				for(int j=0;j<w;++j)
				{
					if(j<x) block[i][j]=1;
				}
			}
			break;
			case 2:
			for(int i=0;i<h;++i)
			{
				for(int j=0;j<w;++j)
				{
					if(j>=x) block[i][j]=1;
				}
			}
			break;
			case 3:
			for(int i=0;i<h;++i)
			{
				for(int j=0;j<w;++j)
				{
					if(i<y) block[i][j]=1;
				}
			}
			break;
			case 4:
			for(int i=0;i<h;++i)
			{
				for(int j=0;j<w;++j)
				{
					if(i>=y) block[i][j]=1;
				}
			}
			break;
		}
	}
	int count=0;
	for(int i=0;i<h;++i)
	{
		for(int j=0;j<w;++j)
		{
			if(block[i][j]==0) count++;
		}
	}
	printf("%d\n",count);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll cm[M],m[M];

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

	ll i,j,k,l,n,ans = 0;

	cin >> k >> n;

	for(i=1;i<=n;++i)
		m[i] = 1;
	for(i=2;i<=n;++i)
	{
		if(cm[i])
		{
			if(m[i] == 0)
				continue;
			if(cm[i]%2)
				m[i] = -1;
			else
				m[i] = 1;
			continue;
		}
		m[i] = -1;
		for(j=i+i;j<=n;j+=i)
		{
			cm[j]++;
			if(j%(i*i) == 0)
				m[j] = 0;
		}
	}

	for(j=1;j<=n;++j)
	{
		l = n/j;
		ll c = 0;
		for(i=1;i<=l;++i)
		{
			c = (c + 1ll*m[i]*pwr(n/(i*j),k,md))%md;
		}
		ans = (ans + 1ll*j*c%md)%md;
	}

	cout << ans << "\n";
}


	

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

//http://abc047.contest.atcoder.jp/tasks/abc047_b
//ABC047-B-すぬけ君の塗り絵 2 イージー
class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("5 4 2");
            WillReturn.Add("2 1 1");
            WillReturn.Add("3 3 4");
            //9
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("5 4 3");
            WillReturn.Add("2 1 1");
            WillReturn.Add("3 3 4");
            WillReturn.Add("1 4 2");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("10 10 5");
            WillReturn.Add("1 6 1");
            WillReturn.Add("4 1 3");
            WillReturn.Add("6 9 4");
            WillReturn.Add("9 4 2");
            WillReturn.Add("3 1 3");
            //64
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();

        SplitAct(InputList[0]);
        int W = wkArr[0]; int H = wkArr[1];
        int UB_X = W - 1;
        int UB_Y = H - 1;

        bool[,] IsBlackArr = new bool[UB_X + 1, UB_Y + 1];

        //2次元配列を黒く塗る処理
        Action<int, int, int> FillBlackAct = (pX, pY, pA) =>
        {
            if (pA == 1)
                for (int X = 0; X <= pX - 1; X++)
                    for (int Y = 0; Y <= UB_Y; Y++)
                        IsBlackArr[X, Y] = true;
            if (pA == 2)
                for (int X = pX; X <= UB_X; X++)
                    for (int Y = 0; Y <= UB_Y; Y++)
                        IsBlackArr[X, Y] = true;
            if (pA == 3)
                for (int X = 0; X <= UB_X; X++)
                    for (int Y = 0; Y <= pY - 1; Y++)
                        IsBlackArr[X, Y] = true;
            if (pA == 4)
                for (int X = 0; X <= UB_X; X++)
                    for (int Y = pY; Y <= UB_Y; Y++)
                        IsBlackArr[X, Y] = true;
        };

        foreach (string EachStr in InputList.Skip(1)) {
            SplitAct(EachStr);
            FillBlackAct(wkArr[0], wkArr[1], wkArr[2]);
        }
        Console.WriteLine(IsBlackArr.Cast<bool>().Count(A => A == false));
    }
}


Measured memory_bytes: 3160
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P	  = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	int n;
	string s;
	cin >> n >> s;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		while (i + 1 < n && s[i] == s[i + 1]) {
			i++;
		}
		ans++;
	}
	dump(ans);
	return 0;
}

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

int main(int argc, char const *argv[]) {
    int N,M;
    std::cin >> N >> M;

    std::vector<int> road_map(N);
    for(int road_index = 0 ; road_index < M ; road_index++ )
    {
        int start_pos;
        int dist_pos;
        std::cin >> start_pos >> dist_pos;
        road_map[start_pos - 1]++;
        road_map[dist_pos - 1]++;
    }

    for(const auto& show_road_times : road_map )
    {
        std::cout << show_road_times << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[] blood = new int[4];
		while(scan.hasNext()){
			String[] str = scan.nextLine().split(",");
			if(str[1].equals("A")){
				blood[0] += 1;
			}else if(str[1].equals("B")){
				blood[1] += 1;
			}else if(str[1].equals("AB")){
				blood[2] += 1;
			}else if(str[1].equals("O")){
				blood[3] += 1;
			}
		}
		for(int i = 0;i < 4;i++){
			System.out.println(blood[i]);
		}
	}
}

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

using namespace std;

int main()
{

int n;
cin>>n;
if(n>=400 && n<=599){cout<<8;}
if(n>=600 && n<=799){cout<<7;}
if(n>=800 && n<=999){cout<<6;}
if(n>=1000 && n<=1199){cout<<5;}
if(n>=1200 && n<=1399){cout<<4;}
if(n>=1400 && n<=1599){cout<<3;}
if(n>=1600 && n<=1799){cout<<2;}

if(n>=1800 && n<=1999){cout<<1;}
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
using namespace std;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
        ans += int(s[i]) - 48;
    }
    // cout << ans << endl;
    if (ans % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string A, B;
  cin >> A >> B;
  if(A.length() < B.length()){
    cout << "LESS" << endl;
  }else if(A.length() > B.length()){
    cout << "GREATER" << endl;
  }else{
    bool is_equal = true;
    for(int i = 0; i < A.length(); i++){
      if(int(A[i]-'0') > int(B[i]-'0')){
        cout << "GREATER" << endl;
        is_equal = false;
        break;
      }else if(int(A[i]-'0') < int(B[i]-'0')){
        cout << "LESS" << endl;
        is_equal = false;
        break;
      }
    }
    if(is_equal){
      cout << "EQUAL" << endl;
    }
  }

  return 0;
}


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


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

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}

ll f(int n){
	if(n<2) return 1LL;
	return n * f(n-2);
}

int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll n;
	cin >>n;

	if(n%2) { puts("0"); return 0;}
	ll w = n /10;
	ll p = 10;

	rep(i, 120){
		p *= 5;
		if(p>n) break;
		w += n/p;
	}
	
	cout << w <<"\n";
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  int ans = 0;
  while(getline(cin,s)){
    int k = 0;
    for(int i=0; i<s.size(); i++){
      if(s[i]>='0' && s[i]<='9') k = k*10+s[i]-'0';
      else if(k!=0){ans+=k;k = 0;}
    }
    if(k!=0) ans+=k;
  }
  cout <<ans<<endl;
  return 0;
}

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

int N;
int AC = 0;
int RE = 0;
int WA = 0;
int TLE = 0;

int main() {
  cin >> N;
  string S[N];
  for (int i = 0; i < N; i++) {
    cin >> S[i];
    if (S[i] == "AC") AC++;
    else if (S[i] == "RE") RE++;
    else if (S[i] == "WA") WA++;
    else if (S[i] == "AC") AC++;
    else if (S[i] == "TLE") TLE++;
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
  return 0;
}


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

using namespace std;

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

#define PB push_back
#define MP make_pair

#define FOR(prom, a, b) for(int prom = (a); prom < (b); prom++)
#define FORDE(prom, a, b) for(int prom = (a); prom >= (b); prom--)
#define R1(a) do{scanf("%d", &(a));}while(0)
#define R2(a, b) do{scanf("%d%d", &(a), &(b));}while(0)
#define R3(a, b, c) do{scanf("%d%d%d", &(a), &(b), &(c));}while(0)
#define SV(vec) do{int __sv;scanf("%d", &(__sv));vec.PB(__sv);}while(0)
#define ALL(vec) (vec).begin(), (vec).end()
#define MM(co, cim) memset((co), (cim), sizeof((co)))
#define DEB(x) cerr << ">>> " << #x << " : " << x << endl;
#define INF   1000000007
#define INFLL 1000000000000000007LL

int n, m, q, a[54], b[54], c[54], d[54], arr[14], res;

void go (int ci, int ln)
{
  if (ci > n)
  {
    int cres = 0;
    FOR(i, 0, q)
    {
      if (arr[b[i]] - arr[a[i]] == c[i]) cres += d[i];
    }
    res = max(res, cres);
    return;
  }
  FOR(i, ln, m + 1) 
  {
    arr[ci] = i;
    go(ci + 1, i);
  }
}

int main ()
{
  R3(n, m, q);
  FOR(i, 0, q)
  {
    R2(a[i], b[i]);
    R2(c[i], d[i]);
  }
  res = 0;
  go(1, 1);
  printf("%d\n", res);
  
  return 0;
}


Measured memory_bytes: 3816