akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
const int MaxN = 2e5;
using namespace std;
typedef long long LL;
int a[MaxN + 5], b[MaxN + 5], c[MaxN + 5];
int n;
int main() 
{
	while(~scanf("%d", &n)) {
		for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
		for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
		for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
		sort (a + 1, a + n + 1);
		sort (b + 1, b + n + 1);
		sort (c + 1, c + n + 1);
		LL ans = 0;
		LL nowa = 0, nowb = 0, tmp = 0;
		for (int i = 1; i <= n; i++) {
			while(nowb + 1 <= n && b[nowb + 1] < c[i]) {
				nowb++;
				while(nowa + 1 <= n && a[nowa + 1] < b[nowb]) nowa++;
				tmp += nowa;
			}
			ans = ans + tmp;
		}
		printf("%lld\n", ans);
	}
}

Measured memory_bytes: 1280
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<vector>
using namespace std;
typedef long long ll;
const int maxn=1010,oo=9999999;
int f[maxn],w[maxn],n;
vector <int> son[maxn];
int dp[2][5050];
void dfs(int v){
	for(int i=0;i<son[v].size();i++)
		dfs(son[v][i]);
	for(int i=0;i<=w[v];i++)
		dp[0][i]=dp[1][i]=oo;
	int x=1;dp[x][0]=0;
	for(int i=0;i<son[v].size();i++){
		x^=1;int y=x^1,u=son[v][i];
		for(int j=0;j<=w[v];j++)
			dp[x][j]=oo;
		for(int j=0;j<=w[v];j++){
			if(j>=w[u])dp[x][j]=min(dp[x][j],dp[y][j-w[u]]+f[u]);
			if(j>=f[u]){
				//if(v==5)cout<<x<<" "<<u<<" "<<j<<" "<<dp[x][j]<<" "<<dp[y][j-f[u]]+w[u]<<endl;
				dp[x][j]=min(dp[x][j],dp[y][j-f[u]]+w[u]);
			}
		}
	}
	f[v]=oo;
	//cout<<"print"<<v<<":";
	for(int i=0;i<=w[v];i++){
		//cout<<dp[x][i]<<" ";
		f[v]=min(f[v],dp[x][i]);
	}
	//cout<<endl;
}
int main(){
	cin>>n;
	for(int i=2;i<=n;i++){
		int x;
		cin>>x;
		son[x].push_back(i);
	}
	for(int i=1;i<=n;i++){
		cin>>w[i];
	}
	dfs(1);
	//for(int i=1;i<=n;i++)
	//	cout<<f[i]<<" ";
	if(f[1]<oo)cout<<"POSSIBLE";
	else cout<<"IMPOSSIBLE";
	return 0;
}


Measured memory_bytes: 384
def solve():
    N = int(input())
    S = [input() for _ in range(N)]

    inner = 0
    for s in S:
        inner += s.count("AB")
    
    # B_ended = 0
    # A_begin = 0

    A_ended = 0
    B_begin = 0
    both = 0
    for s in S:
        if s[0] == "B" and s[-1] == "A":
            both += 1   

        elif s[0] == "B": B_begin += 1
        elif s[-1] == "A": A_ended += 1

    mmA = 0
    if both > 0:
        if A_ended > 0:
            mmA += 1
            A_ended-=1
        if B_begin > 0:
            mmA += 1
            B_begin -= 1

    mmA += min(A_ended, B_begin)    
    if both > 0:
        mmA += both-1

    # if A_ended != B_begin:
    #     # 片方余ってるとき
    #     mmA += both
    # elif both > 0:
    #     mmA += both - 1 
    
    print(inner + mmA )
    

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3700
(defun bit-collection (n function)
  (loop :for k :from 0 :upto (expt 2 n)
          :thereis(funcall function (loop :for j :from 0 :upto (1- n) :collect (logbitp j k)))))
(defun parse-int-char (n)
  (cond ((char= #\0 n) 0)
        ((<= 49 (char-code n) 57) (- (char-code n) 48))
        (t nil)))
(let* ((lst (mapcar #'parse-int-char (concatenate 'list (read-line)) )))
  (defun f (ll)
    (if (= 7 (reduce #'+ (cons (car lst) (mapcar (lambda (x y) (if x y (- 0 y))) ll (cdr lst)))))
        (progn (princ (car lst)) (mapcar (lambda (x y) (princ (if x "+" "-")) (princ y)) ll (cdr lst)) (princ "=7"))))
  (bit-collection 3 #'f))


Measured memory_bytes: 17252
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

const int MAX_N = 2e5 + 6;

vector<int> v[MAX_N];

int main() {
	int n,m;
	scanf("%d %d",&n,&m);
	for (int i=1;n>=i;i++) {
		int x,y;
		scanf("%d %d",&x,&y);
		v[x].push_back(y);
	}
	for (int i=0;m+1>=i;i++) {
		sort(v[i].begin(),v[i].end());
	}
	priority_queue<int,vector<int>,greater<int> > pq;
	int nxt=0;
	for (int i=0;m>=i;i++) {
		if (i==0) {
			for (int j:v[i]) {
				pq.push(j);
			}
		}
		else {
			if (v[i].size() == 0) {
				if (!pq.empty() && pq.top()<=i) pq.pop();
				else {
					if (nxt < i) nxt=i;
					while (v[nxt].size() == 0 && nxt<=m+1) nxt++;
					if (v[nxt].size() == 0) continue;
					else v[nxt].pop_back();
				}
			}
			else {
				for (int j=0;v[i].size()-1>j;j++) {
					pq.push(v[i][j]);
				}
			}
		}
	}
	printf("%d\n",pq.size());
}


Measured memory_bytes: 8960
/*
	author: zhaodeyin
	time: 2018.3.11
*/
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
char s[5][5];
int main(){
	for(int i = 1; i <= 3; i++)
		for(int j = 1; j <= 3; j++)
			scanf(" %c",&s[i][j]);
	cout<<s[1][1]<<s[2][2]<<s[3][3];
	cout<<endl;
	return 0;
}

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

const int MAXN = 200005;

int n, a, b, c, d;
char s[MAXN];

bool reach(int x, int y){
	while(true){
		if(x > y)return false;
		if(x == y)return true;
		
		if(s[x + 1] == '.'){
			x += 1;
		}else if(s[x + 2] == '.'){
			x += 2;
		}else{
			return false;
		}
	}
}

int main(){
	scanf("%d %d %d %d %d %s", &n, &a, &b, &c, &d, s);
	a--, b--, c--, d--;

	if(!reach(a, c) || !reach(b, d)){
		printf("No\n");
	}else{
		if(c < d){
			printf("Yes\n");
		}else{
			bool found = false;
			for(int i = b; i <= d; i++){
				if(s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.'){
					found = true;
					break;
				}
			}
			
			if(found)printf("Yes\n");
			else printf("No\n");
		}
	}

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

inline void InitRand()
{
    srand((unsigned int)time(NULL));
}

int main() {
    InitRand();
    int D; cin >> D;
    veci C(26);
    vecveci S(D,veci(26));
    veci T(D);
    REP(i,26) cin >> C[i];
    REP(i,D) REP(j,26) cin >> S[i][j];
    REP(i,D) {
        T[i] = rand()%26;
    }
    int M; M = 2*1e5;
    veci B(M),Q(M);
    REP(i,M) {
        B[i] = rand()%D;
        Q[i] = rand()%26;
    }

    veci last_d(26);
    ll old_ans = 0;
    REP(i,D) {
        int d = i+1;
        last_d[T[i]] = d;
        old_ans += S[i][T[i]];
        REP(j,26) {
            old_ans -= C[j]*(d-last_d[j]);
        }
    }

    REP(i,M) {
        int old_p = T[B[i]];
        T[B[i]] = Q[i];
        ll score = 0;
        veci last(26);
        REP(j,D) {
            int d = j+1;
            last[T[j]] = d;
            score += S[j][T[j]];
            REP(k,26) {
                score -= C[k]*(d-last[k]);
            }
        }
        if(old_ans < score) {
            old_ans = score;
        }
        else {
            T[B[i]] = old_p;
        }
    }
    REP(i,D) cout << T[i]+1 << endl;
}

Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
int color[100010];
int seen[100010];
vector<vector<pair<int,int > > >G(100010);
void dfs(int v,int p,int c){
  color[v]=c;
  seen[v]=1;
    for(auto e:G[v]){
      if(seen[e.first])continue;
        if(e.second%2)dfs(e.first,v,1-c);
        else dfs(e.first,v,c);
    }
}
int main(){
    int n;cin>>n;
    for(int i=0;i<n;i++){
        int u,v,w;cin>>u>>v>>w;
        G[u].push_back({v,w});
        G[v].push_back({u,w});
    }
  seen[1]=1;
    dfs(1,0,0);
    for(int i=1;i<=n;i++){
        cout<<color[i]<<endl;
    }
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

using namespace std;

ll POWER (ll x, ll y, ll mod){
    ll ans = 1, c = x;
    while (y){
        if ((y & 1) == 1)
            ans = ans * c % mod;
        c = c * c % mod;
        y /= 2;
    }
    return ans;
}

const ll N = 1e5 + 5, MOD = 1e9 + 7;
const double C = 1;

int n;
vector < int > g[N];
ll dp[N][2];

void dfs (int k, int p){
    for (int u: g[k]){
        if (u == p)
            continue;
        dfs (u, k);
    }
    dp[k][0] = 1;
    dp[k][1] = 1;
    for (int u: g[k]){
        if (u == p)
            continue;
        dp[k][1] = dp[k][1] * dp[u][0] % MOD;
        dp[k][0] = dp[k][0] * (dp[u][0] + dp[u][1]) % MOD;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for (int i = 1; i < n; i++){
        int u, v;
        cin>>u>>v;
        g[u].pb (v);
        g[v].pb (u);
    }
    dfs (1, 0);
    cout<<(dp[1][0] + dp[1][1]) % MOD<<endl;
    return 0;
}


Measured memory_bytes: 14208
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

ll mod;

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll powll(ll x, ll y){
    x %= mod;
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll calc1(ll n, ll p){
    ll ten = powll(10, p);
    ll ret = 0, x = 1, c = 1;
    while (n){
        if (n & 1){
            ret = (ret * powll(ten, c)) % mod;
            ret = (ret + x) % mod;
        }
        x = (x + x * powll(ten, c)) % mod;
        c *= 2;
        n /= 2;
    }
    return ret;
}

ll calc2(ll n, ll p){
    ll ten = powll(10, p);
    ll ret = 0, x = 0, c = 1, d = 0;
    while (n){
        if (n & 1){
            ll tmp = (x + calc1(c, p) * (d % mod)) % mod;
            ret = (ret + tmp * powll(ten, d)) % mod;
            d += c;
        }
        ll tmp = (x + calc1(c, p) * (c % mod)) % mod;
        x = (x + tmp * powll(ten, c)) % mod;
        c *= 2;
        n /= 2;
    }
    return ret;
}

ll calc2_naive(ll n, ll p){
    ll ret = 0;
    ll x = 1;
    ll ten = powll(10, p);
    REP(i,n){
        ret = (ret + i * x) % mod;
        x = (x * ten) % mod;
    }
    return ret;
}

ll naive(ll a, ll n, ll b, ll d){
    ll ret = 0;
    ll ten = powll(10, d), base = 1;
    REP(i,n){
        ll tmp = (a - i * b) % mod;
        tmp = (tmp + mod) % mod;
        tmp = (tmp * base) % mod;
        ret = (ret + tmp) % mod;
        base = (base * ten) % mod;
    }
    return ret;
}

int main() {
    ll n, a, b;
    cin >> n >> a >> b >> mod;

    ll base = 1, t = 1e17, ans = 0;
    FORR(d,18,1){
        ll m = (t - a + b - 1) / b;
        if (t < a) m = 0;
        if (m < n){
            ll s = ((a % mod) + ((n - 1 + mod) % mod) * (b % mod)) % mod;
            ll x = n - m;

            // cout << d << " " << s << " " << x << endl;

            ll tmp = (s * calc1(x, d)) % mod;
            tmp = (tmp + (mod - (b % mod)) * calc2(x, d)) % mod;
            ans = (ans + tmp * base) % mod;

            base = (base * powll(powll(10, d), x)) % mod;
            n = m;
        }
        t /= 10;
    }    

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>
#include <memory.h>
#include <assert.h>
#include <iomanip>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    double N, K;
    cin >> N >> K;

    double ans = 0;
    for(int i = 1; i <= N; i++) {
        double n = i;
        double cnt = 1;
        while(n < K) {
            cnt *= 2;
            n *= 2;
        }
        ans += 1.0 / (N * cnt);
    }

    cout << setprecision(12) << ans << endl;;

    return 0;
}

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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

int main()
{
    ll N;
    cin >> N;
    vector<string> s(N);
    rep(i,N) cin >> s[i];

    multiset<string> A;
    set<string> a;
    rep(i,N)
    {
        A.insert(s[i]);
        a.insert(s[i]);
    }

    ll most = 0;


    for(set<string>::iterator itr = a.begin(); itr != a.end(); ++itr)
    {
        if( A.count( *itr ) > most ) most = A.count( *itr );
    }

    vector<string> ans;

    for(set<string>::iterator itr = a.begin(); itr != a.end(); ++itr)
    {
        if( A.count( *itr ) == most ) ans.push_back( *itr );
    }
    sort(all(ans));
    rep(i,ans.size()) cout << ans[i] << endl;





}


Measured memory_bytes: 34676
N = int(input())
A = list(map(int, input().split()))

cnt_minus = 0
wa = 0
small = 10 ** 10
for i in range(N):
    if A[i] < 0:
        cnt_minus += 1
    wa += abs(A[i])
    small = min(abs(A[i]), small)
    

if cnt_minus % 2 == 0:
    print(wa)
else:
    print(wa - (2 * small))

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int t;
unordered_set<int> st;
int main() {
    for (int i = 0; i < 3; ++i) {
        cin >> t;
        st.insert(t);
    }
    cout << st.size() << endl;
    return 0;
}


Measured memory_bytes: 3504
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int x[n+5];
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
    }
    int l=0;
    int f=0;
    while(1)
    {
        f=0;

        for(int i=0;i<n;i++)
        {
            if(x[i]%2==0)
            {
                x[i]=x[i]/2;
            }
            else
            {
                f=3;
            }
        }
        if(f==0)
        {
            l++;
        }
        else
        {
            break;
        }
    }
    cout<<l<<endl;
return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

double a[100010], b[100010];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) {
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b+n);

  REP(i, n) {
    int tmp = 0;
    tmp += (lower_bound(b, b+n, a[i])-b)*3;
    auto tmp1 = equal_range(b, b+n, a[i]);
    tmp += (tmp1.second - tmp1.first - 1);
    cout << tmp << endl;
  }
  return 0;
}

Measured memory_bytes: 4572
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

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

	int N; cin >> N;

	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];	
	}
	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());

	long ans = 0;
	queue<long> que;
	que.push(A[0]);	
	for (int i = 1; i < N; i++) {
		ans += que.front();
		que.pop();
		que.push(A[i]);	
		que.push(A[i]);	
	}
	cout << ans << endl;


	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    int res = n/2;
    if (n%2 ==0)
        --res;
    cout << res << endl;
    return 0;
}


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

int main(){
  string S;
  cin >> S >> S;
  for(int i=0; i<S.size()-1;){
    if(S[i]==S[i+1]) S.erase(S.begin()+i);
    else i++;
  }
  cout << S.size() << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  set<ll> st;
  REP(i, n) {
    ll a;
    cin >> a;
    st.insert(a);
  }
  cout << (SZ(st) == n ? "YES" : "NO") << endl;
}

Measured memory_bytes: 9600
from sys import stdin
from itertools import repeat
def main():
    n = int(stdin.readline())
    a = map(int, stdin.read().split(), repeat(10, n - 1))
    ch = [[] for _ in xrange(n + 1)]
    for i, x in enumerate(a, 2):
        ch[x] += [i]
    q = [1]
    pu = q.append
    po = q.pop
    d = [0] * (n + 1)
    l = [0] * (n + 1)
    while q:
        x = po()
        if d[x] == 0:
            pu(x)
            d[x] = 1
            for y in ch[x]:
                pu(y)
        elif d[x] == 1:
            t = [l[y] for y in ch[x]]
            t.sort(reverse=True)
            l[x] = 0
            for i, y in enumerate(t):
                if l[x] < i + y + 1:
                    l[x] = i + y + 1
    print l[1]
main()


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

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int num[3] = { 0,0,0 };
	for (int i = 0; i < N; i++) {
		int p;
		cin >> p;
		num[(p > A) + (p > B)]++;
	}
	cout << min({ num[0], num[1], num[2] }) << endl;
}


Measured memory_bytes: 256
n,m = [int (i) for i in input().split()]

A = []
for nc in range(n):
    A.append([int(i) for i in input().split()])

b = []
for mc in range(m):
    b.append(int (input()))

product = []
for nc in range(n):
    total = 0
    for mc in range(m):
        total += A[nc][mc] * b[mc]

    product.append(total)

[print(p) for p in product]

Measured memory_bytes: 7016
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int H = sc.nextInt();
		int W = sc.nextInt();
		char[][] A = new char[H][W];
		int[] hh = new int[H];
		int[] ww = new int[W];
		for( int i=0; i<H; i++ ){
			int a = 0;
			String S = sc.next();
			for( int k=0; k<W; k++ ){
				A[i][k] = S.charAt(k);
				if( A[i][k]=='#' ){
					a = 1;
				}
			}
			if( a==0 ){
				hh[i] = 1;
			}
		}
		for( int i=0; i<W; i++ ){
			int a = 0;
			for( int k=0; k<H; k++ ){
				if( A[k][i]=='#' ){
					a = 1;
				}
			}
			if( a==0 ){
				ww[i] = 1;
			}
		}
		for( int i=0; i<H; i++ ){
			if( hh[i]==1 ){
				continue;
			}
			String ans = "A";
			for( int k=0; k<W; k++ ){
				if( ww[k]==1 ){
					continue;
				}
				String ss = String.valueOf(A[i][k]);
				ans += ss;
			}
			System.out.println(ans.substring(1));
		}
	}
}


Measured memory_bytes: 25940
#include <iostream>
#include <string>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int c[30];
int s[400][30];
int main() {
	int d;
	cin >> d;
	for (int i = 1; i <= 26; i++) {
		cin >> c[i];
	}
	for (int i = 1; i <= d; i++) {
		for (int j = 1; j <= 26; j++) {
			cin >> s[i][j];
		}
	}
	int ans = 0;
	int t;
	int co[30] = { 0 };
	for (int i = 1; i <= d; i++) {
		cin >> t;
		ans += s[i][t];
		co[t] = i;
		for (int j = 1; j <= 26; j++) {
			ans -= c[j] * (i - co[j]);
		}
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;cin >> n >> m;
	vector<int> a(m);
	vector<int> b(m);
	vector<int> c(m);
	rep(i,m){
		cin >> a.at(i) >> b.at(i) >> c.at(i);
		a.at(i)--;
		b.at(i)--;
	}
	int MAX=1000000000;
	vector<vector<int>> dist(n,vector<int>(n));
	rep(i,n){
		rep(j,n){
			dist[i][j]=MAX;
		}
		dist[i][i]=0;
	}
	rep(i,m){
		dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
		dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
	}
	rep(k,n){
		rep(i,n){
			rep(j,n){
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	
	int ans=0;
	rep(i,m){
		if(dist[a[i]][b[i]]<c[i]) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main() {

	double a, b, c, d, e, f, x, y;

	while(cin >> a >> b >> c >> d >> e >> f) {
		y=(a*f-c*d)/(a*e-b*d);
		x=(c-b*y)/a;
		printf("%.3f %.3f\n", x, y);
	}

	return 0;

}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>

struct node_t {
	int key;
	struct node_t *parent;
	struct node_t *left;
	struct node_t *right;
};
typedef struct node_t Node;

Node *tree_insert(Node *top, Node *z) {
	Node *y, *x;

	y = NULL;
	x = top;
	while (x != NULL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	z->parent = y;
	if (y == NULL) {
		top = z;
	} else if (z->key < y->key) {
		y->left = z;
	} else {
		y->right = z;
	}
	return top;
}

Node *tree_find(Node *node, int key) {
	if (node == NULL)
		return NULL;
	if (node->key == key)
		return node;
	if (key < node->key)
		return tree_find(node->left, key);
	return tree_find(node->right, key);
}

Node *tree_minimum(Node *x) {
	while (x->left != NULL) {
		x = x->left;
	}
	return x;
}

Node *tree_successor(Node *x) {
	Node *y;

	if (x->right != NULL) {
		return tree_minimum(x->right);
	}
	y = x->parent;
	while (y != NULL && x == y->right) {
		x = y;
		y = y->parent;
	}
	return y;
}

Node *tree_delete(Node *top, Node *z) {
	Node *y, *x;

	if (z->left == NULL || z->right == NULL) {
		y = z;
	} else {
		y = tree_successor(z);
	}

	if (z->left != NULL) {
		x = y->left;
	} else {
		x = y->right;
	}

	if (x != NULL) {
		x->parent = y->parent;
	}
	if (y->parent == NULL) {
		top = x;
	} else if (y == y->parent->left) {
		y->parent->left = x;
	} else {
		y->parent->right = x;
	}

	if (y != z) {
		z->key = y->key;
	}
	return top;
}

void inorder_walk(Node *node) {
	if (node->left != NULL) {
		inorder_walk(node->left);
	}
	printf(" %d", node->key);
	if (node->right != NULL) {
		inorder_walk(node->right);
	}
}

void preorder_walk(Node *node) {
	printf(" %d", node->key);
	if (node->left != NULL) {
		preorder_walk(node->left);
	}
	if (node->right != NULL) {
		preorder_walk(node->right);
	}
}

int main(void) {
	int n, i, key;
	char cmd[20];
	Node *top = NULL, *p;

	scanf("%d ", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %d ", cmd, &key);
		if (cmd[0] == 'i') {
			p = malloc(sizeof(Node));
			p->key = key;
			p->parent = p->left = p->right = NULL;
			top = tree_insert(top, p);
		} else if (cmd[0] == 'f') {
			puts(tree_find(top, key) != NULL ? "yes" : "no");
		} else if (cmd[0] == 'd') {
			p = tree_find(top, key);
			if (p != NULL) {
				top = tree_delete(top, p);
			}
			//free(p);
		} else {
			inorder_walk(top);
			putchar('\n');
			preorder_walk(top);
			putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 19368
#include <iostream>
#include <string>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;

int main(){
  string S;
  cin >> S;
  if(S[0]!=S[1]&&S[1]!=S[2]&&S[2]!=S[0]) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define INF (int)1e9+1
#define INFLL (int)1e18+1
#define sz(bb) (int)bb.size()
#define all(qq) qq.begin(), qq.end() 
#define Max(a, b, c) max(a, max(b, c))
#define Min(a, b, c) min(a, min(b, c))
const double PI=acos(-1);
// #define int unsigned long long int//used when x<2^64-1 && x>0
#define int long long//used when x<2^63-1
//bool cmp if returns true it keeps 1st as first else swaps
typedef long long  ll;

const int N=10;
void solve()
{
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<"\n";
}
int32_t main()
{
    IOS;
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

 
void solve()
{
    string s;cin>>s;
    int n=s.size();
    vector<int>r(n,0);
    REP(qwer,2)
    {
        int sum=0;
        REP(i,n)
        {
            if(s[i]=='R')sum++;
            else {r[i]+=sum/2;r[i-1]+=(sum+1)/2;sum=0;}
        }
        reverse(ALL(s));
        reverse(ALL(r));
        REP(i,n) s[i]=s[i]=='R'?'L':'R';
    }
    for(auto itr:r)cout<<itr<<" ";cout<<endl;
}

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

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

using namespace std;

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

	int n;
	cin >> n;
	vector<int>color(9, 0);

	vector<int>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] < 400)
			color[0]++;
		else {
			if (a[i] < 800)
				color[1]++;
			else {
				if (a[i] < 1200)
					color[2]++;
				else {
					if (a[i] < 1600)
						color[3]++;
					else {
						if (a[i] < 2000)
							color[4]++;
						else {
							if (a[i] < 2400)
								color[5]++;
							else {
								if (a[i] < 2800)
									color[6]++;
								else {
									if (a[i] < 3200)
										color[7]++;
									else {
										color[8]++;
									}
								}
							}
						}
					}
				}
			}
		}
	}
	int min = 0, max;
	for (int i = 0; i < 8; i++) {
		if (color[i])
			min++;
	}
	if (min == 0) {
		min = 1;
		max = color[8];
	}
	else
		max = min + color[8];
	cout << min << " " << max << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
int a,b;
  cin>>a>>b;
  for(int i=1;i<=3;i++){
if(i!=a && i!=b){
  cout<<i<<endl;
  break;}
  }
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string s;
int main()
{
	cin>>s;
	int len=s.length();
	for(int i=0;i<len;i++)
	{
        if(s[i]=='A'&&s[i+1]=='C')
		{
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
	return 0;
}

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

ll powmod(ll a,ll b)
{
   ll res = 1;
   while(b > 0) {
      if(b & 1) res = (res * a) % MOD;
      a = (a*a)%MOD;
      b = b >> 1; 
  }
  return res % MOD;
}
vpll a(1001);
ll N;
vll dp(10001, -1);

ll cal(ll h) 
{
	if(h <= 0) {
		return 0;
	}
	if(dp[h] != -1) {
		return dp[h];
	}
	ll ans = (ll)1e10;
	for(ll i=0;i<N;i++) {
		ans = min(ans, cal(h - a[i].first) + a[i].second);
	}
	dp[h] = ans;
	return ans;
}

void solve()
{
    ll h;
    cin >> h >> N;
    for(ll i=0;i<N;i++) {
    	cin >> a[i].first >> a[i].second;
    }
    cout << cal(h) << "\n";
    // for(ll i=1;i<=100;i++) {
    // 	cout << dp[i] << "\n";
    // }
}

int main()
{
    FAST_IO;
    // #ifndef ONLINE_JUDGE 
    //   OC;
    // #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 768
#include <iostream>

int main()
{
    int n, m;
    int sum = 0;
    std::cin >> n >> m;
    for (int i = 0; i < m; ++i)
    {
        int tmp;
        std::cin >> tmp;
        sum += tmp;
    }

    std::cout << (sum <= n ? n - sum : -1) << std::endl;

    return 0;
}


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

int main() {
  
  int N; cin >> N; int duplication = 0;
  
  string s, t; cin >> s >> t;
  
  for (int i = 1; i <= N; i++) {
    
    string tmpS = s.substr(N - i, i);
    
    string tmpT = t.substr(0, i);
    
    if (tmpS == tmpT) duplication = i;
    
  }
  
  int ans = N * 2 - duplication;
  
  cout << ans << endl;
  
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  while(a != b || b != c){
    if(a > b) swap(a, b);
    if(a > c) swap(a, c);
    if(b > c) swap(b, c);
    ans++;
    if(a == b){
      a++;
      b++;
    }else{
      a+=2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
k=int(input())
import math
s=0
result=0
for a in range(1,k+1,1):
    for b in range(a,k+1,1):
        for c in range(b,k+1,1):
            gcd=math.gcd(math.gcd(a,b),math.gcd(b,c))
            if a==b==c:
                pass
            elif (a==b and b!=c) or (b==c and b!=a) or (a==c and a!=c):
                gcd=3*gcd
            else:
                gcd=6*gcd
            
            result+=gcd
print(result)

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,a,b;
    cin>>x>>a>>b;
    if(x-a>0 && x-b>0 && x-a>x-b) cout<<"B\n";
    else if(x-a>0 && x-b>0 && x-a<x-b) cout<<"A\n";
    else if(x-a<0 && x-b>0 && a-x<x-b) cout<<"A\n";
    else if(x-a<0 && x-b>0 && a-x>x-b) cout<<"B\n";
    else if(x-a<0 && x-b<0 && a-x>b-x) cout<<"B\n";
    else if(x-a<0 && x-b<0 && a-x<b-x) cout<<"A\n";
    else if(x-a>0 && x-b<0 && x-a<b-x) cout<<"A\n";
    else if(x-a>0 && x-b<0 && x-a>b-x) cout<<"B\n";
    else cout<<"A\n";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		Scanner kb = new Scanner( System.in);	
		int a,b,c,count;

		a=kb.nextInt();
		b=kb.nextInt();
		c=kb.nextInt();
		count=0;
		for( int i=a; i<=b; i++) {
			if( 0 == c%i ) {
				count++;
			}
		}
		System.out.println( count );	
	}
}

Measured memory_bytes: 17356
N=int(input())
T=list(map(int, input().split()))
A=list(map(int, input().split()))
H1,H2=[0]*N,[0]*N
h=0
for i in range(N):
  if h<T[i]:
    H1[i]=T[i]
    h=T[i]
h=0
for i in range(N):
  if h<A[-1-i]:
    H2[-1-i]=A[-1-i]
    h=A[-1-i]
#print(H1,H2)
H=[0]*N
for i in range(N):
  if H1[i]!=0 and H2[i]!=0 and H1[i]!=H2[i]:
    print(0)
    exit()
  else:
    H[i]=max(H1[i],H2[i])
    
if H1.index(max(H1))>H2.index(max(H2)):
  print(0)
  exit()
  
ans=1
left=H[0]
right=0
cnt=0
for i in range(1,N):
  if H[i]!=0 and cnt==0:
    left=H[i]
  elif H[i]!=0:
    right=H[i]
    d=min(left,right)
    ans*=pow(d,cnt,10**9+7)
    ans%=10**9+7
    cnt=0
    left=H[i]
  elif H[i]==0:
    cnt+=1
print(ans)
  

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

int main() {
  int N;
  cin >> N;
  vector<int> a(3 * N);
  for (int i = 0; i < 3 * N; i++) cin >> a[i];
  sort(a.rbegin(), a.rend());
  long long ans = 0;
  for (int i = 0; i < N; i++) ans += a[2 * i + 1];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int arr[n+1];
	for(int i=0;i<n;++i)
	cin>>arr[i+1];
	int dp[n+1];
	memset(dp,0,sizeof(dp));
	dp[n]=0;
	dp[n-1]=abs(arr[n]-arr[n-1]);
	for(int i=n-2;i>0;--i)
	{
		dp[i]=min(abs(arr[i]-arr[i+1])+dp[i+1],abs(arr[i]-arr[i+2])+dp[i+2]);
	}
	cout<<dp[1];
}
	

Measured memory_bytes: 1024
n,a,b=map(int,input().split())
s=input()
x=0
y=0
for i in range(n):
  if s[i]=="a":
    if y<a+b:
      print("Yes")
      y+=1
    else:
      print("No")
  elif s[i]=="b":
    if y<a+b and x<b:
      x+=1
      y+=1
      print("Yes")
    else:
      print("No")
  else:
    print("No")
      

Measured memory_bytes: 4016
import math
N = int(input())
T = [None] * N
A = [None] * N
for i in range(N):
  T[i], A[i] = map(int, input().split())

t, a = T[0], A[0]

for i in range(1, N):
  if (t < T[i] and a < A[i]):
    t, a = T[i], A[i]
  else:
    n = max((t - 1) // T[i] + 1, (a - 1) // A[i] + 1)
    t, a = n * T[i], n * A[i]

print(t + a)

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> ac(n);
    vector<int> pena(n);
    int penalty = 0;
    rep(i, m) {
        int tmp;
        string judge;
        cin >> tmp >> judge;
        if(judge == "AC" and ac[tmp - 1] == 0) {
            ac[tmp - 1] = 1;
            penalty += pena[tmp - 1];
        }
        if(judge == "WA" and ac[tmp - 1] == 0)
            pena[tmp - 1] += 1;
    }
    cout << accumulate(ac.begin(), ac.end(), 0) << " " << penalty << endl;
}


Measured memory_bytes: 4024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/

int main()
{
	//freopen("D:\\code\\text\\input.txt","r",stdin);
	//freopen("D:\\code\\text\\output.txt","w",stdout);
	ll a = readll();
	ll b = readll();
	ll c = readll();
	c -= a;
	c -= b;
	if (c <= 0)
	{
		printf("No\n");
	} else
	{
		c *= c;
		if (c > 4ll * a * b)
		{
			printf("Yes\n");
		} else
		{
			printf("No\n");
		}
	}
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
//#include <sstream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <cmath>
//#include <functional>
//#define LL long long

using namespace std;


const int maxn = 100005;
long long a[maxn];
long long b[maxn];

int main()
{
//    printf("ok");
#ifdef LOCAL
//    freopen("/Users/ecooodt/Desktop/c++ and acm/DI2_lesson/2/2.txt","r",stdin);
#endif
//    printf("%d",-5%5)
    memset(a,0,sizeof(a));
    long long n,m;
    scanf("%lld",&n);
    long long sum = 0;
    for(int i = 0; i < n; i++)
    {
        scanf("%lld",&a[i]);
        sum += a[i];
    }
    long long t = n*(1+n)/2;
    if(sum % t != 0)
    {
        printf("NO\n");
        return 0;
    }
    sum /= t;

    for(int i = 1; i < n; i++)
    {
        b[i-1] = a[i-1] - a[i];
    }
    b[n-1] = a[n-1] - a[0];


    for(int i = 0 ; i < n ; i++)
    {
        b[i] += sum;
        if(b[i] == 0)
        {
            continue;
        }
//        printf("%d\n",b[i]);
        if(b[i] % n != 0 || b[i] < 0)
        {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i = (a); i >= (b); i--)
#define FORR(i,a,b) for (int i = (a); i > (b); i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

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

    if(a==b){
    	cout << "Draw\n";
    }else{
    	if(a==1 && b>1)
    		cout << "Alice\n";
    	else if(a>1 && b==1)
    		cout << "Bob\n";
    	else if(a>b)
    		cout << "Alice\n";
    	else if(a<b)
    		cout << "Bob\n";
    }

    return 0;
}


Measured memory_bytes: 256
// :(((
// g & h for subtitle
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ld long double
const int maxn = 2e5 + 10 , mod = 1e9 + 7;

ll n;
map<string, ll> m;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	m["AC"] = m["WA"] = m["TLE"] = m["RE"] = 0;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		m[s] ++;
	}
	cout << "AC x " << m["AC"] << endl << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl << "RE x " << m["RE"] << endl;
	return 0;	
}


Measured memory_bytes: 3652
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
 
class Main
{
	static class Pair
	{
		int first, second;
		public Pair(int f, int s)
		{
			first = f;
			second = s;
		}
		
		public String toString()
		{
			return first + " " + second;
		}
	}
	
	static class PairComparator implements Comparator <Pair>
	{
		public int compare(Pair p1, Pair p2)
		{
			if(p1.first < p2.first)
				return -1;
			if(p1.first > p2.first)
				return 1;
			if(p1.second < p2.second)
				return -1;
			if(p1.second > p2.second)
				return 1;
			return 0;
		}
	}
	
	static int log2(double a)
	{
		return (int)(Math.log(a) / Math.log(2));
	}
	
	static long gcd(long a, long b)
	{
		long r;
		while((r = a % b) > 0)
		{
			a = b;
			b = r;
		}
		return b;
	}
	
	static class TrieNode
	{
		TrieNode z, o;
		boolean end;
		long count;
		
		public TrieNode()
		{
			 z = null;
			 o = null;
			 count = 0;
			 end = false;
		}
	}
	
	public static void main(String[] args) throws IOException
	{
		long n = in.nextLong();
		long k = in.nextLong();
		long ans = 0;
		for(int i = 0; i < n; i ++)
		{
			long x = in.nextLong();
			ans += Math.min(Math.abs(k - x), x) * 2;
		}
		sop(ans);
	}
    
	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
	
    static FastReader in = new FastReader();
  
    public static void sop(Object o)
    {
    	System.out.print(o);
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <vector>
#include <utility>

int H, W;
int a[505][505];
int main()
{
    std::cin >> H >> W;
    for (int i = 0; i < H; ++i)
        for (int j = 0; j < W; ++j)
            std::cin >> a[i][j];

    std::vector<std::pair<std::pair<int, int>, std::pair<int, int>>> ans;
    for (int i = 0; i < H; ++i)
        for (int j = i % 2 == 0 ? 0 : W - 1; j >= 0 && j < W; i % 2 == 0 ? ++j : --j)
        {
            if (i % 2 == 0 && i == H - 1 && j == W - 1 || i % 2 != 0 && i == H - 1 && j == 0)
                break;

            if (a[i][j] % 2 != 0)
            {
                --a[i][j];
                ++a[(i % 2 == 0 && j == W - 1 || i % 2 != 0 && j == 0) ? i + 1 : i][(i % 2 == 0) ? ((j < W - 1) ? j + 1 : j) : ((j > 0) ? j - 1 : j)];
                ans.emplace_back(std::make_pair(i + 1, j + 1),
                                 std::make_pair((i % 2 == 0 && j == W - 1 || i % 2 != 0 && j == 0) ? i + 2 : i + 1,
                                                (i % 2 == 0) ? ((j < W - 1) ? j + 2 : j + 1) : ((j > 0) ? j : j + 1)));
            }
        }

    std::cout << ans.size() << '\n';
    for (int i = 0; i < ans.size(); ++i)
        std::cout << ans[i].first.first << ' ' << ans[i].first.second << ' '
                  << ans[i].second.first << ' ' << ans[i].second.second << '\n';
    std::cout << std::flush;

    return 0;
}

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

int main() {
  int64_t A, B;
  cin >> A >> B;
  if ((max(A, B) + min(A, B)) % 2LL == 0) {
    cout << (max(A, B) + min(A, B)) / 2LL << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 3564
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <stack>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

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

  bool res = true;

  int N = S.size();

  for (int i = 0; i < (N - 1) / 2; ++i)
    if (S[i] != S[N - i - 1])
      res = false;

  for (int i = 0; i < (N - 1) / 2; ++i)
    if (S[i] != S[(N - 1) / 2 - i - 1])
      res = false;

  // for (int i = (N - 1) / 2 + 1; i < N)
  //   if (S[i] != S[N - i + 1])
  //     res = false;

  int c = (N - 1) / 2;
  for (int i = 0; i < (N - 1) / 2; ++i)
    if (S[c + i + 1] != S[N - i - 1])
      res = false;

  if (res == false) {
    std::cout << "No" << std::endl;
  } else {
    std::cout << "Yes" << std::endl;
  }

  return 0;
}


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

int main() {
    string str;
    string order;
    string n;
    string t;
    int q;
    int a, b;
    cin >> str;
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> order >> a >> b;
        n = str.substr(a, b - a + 1);
        if (order == "print") {
            cout << n << endl;
        } else if (order == "reverse") {
            reverse(n.begin(), n.end());
            str.replace(a, b - a + 1, n);
        } else if (order == "replace") {
            cin >> t;
            str.replace(a, b - a + 1, t);
        }
    }
    
    return 0;
}



Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <cstdio> 
using namespace std;
 
int main(void) {
    int a,b,c;
    cin>>a>>b>>c;
    if (a==b && b!=c || a==c && b!=c || b==c && a!=c){
        cout<<"Yes"<<endl;
    } else{
        cout<<"No"<<endl;
    }    
    return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_K = (int)(1e1 + 5);

int n, k;
set<int> dset;

int ans = 0;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);

  for (int i = 0; i < k; ++i) {
    int tmp;
    scanf("%d", &tmp);
    dset.insert(tmp);
  }

  for (int i = n; i < 100 * n; ++i) {
    bool flg = false;
    string str_i = to_string(i);

    for (auto c: str_i) {
      int num = c - '0';
      if (dset.find(num) != dset.end()) {
        flg = true;
        break;
      }
    }

    if (flg) continue;

    ans = i;
    break;
  }

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

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif


    string s;
    cin >> s;
    int cur = 0;
    int ans = 0;
    for (char c : s) {
        if (c == 'W') ans += cur;
        else ++cur;
    }   

    cout << ans << '\n';
}   

Measured memory_bytes: 720