akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int, Int> pii;
typedef pair<Int, double> pid;
typedef pair<double, double> pdd;
typedef pair<Int, pii> pip;
typedef pair<pii, Int> ppi;
typedef pair<double, Int> pdp;
typedef vector<Int> veci;
typedef vector<double> vecd;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<pii> vecpii;
typedef vector<ppi> vecppi;
typedef vector<veci> mati;
typedef vector<vecll> matll;
typedef vector<vecd> matd;
#define PB(x) push_back(x)
#define EB(x) emplace_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define REP(i, a, b) for(int i = (a);i <= (b);i++)
#define FORO(i, n) REP(i,0,(int)n-1)
#define FORI(i, n) REP(i,1,(int)n)
#define FORIT(i, t) for(auto i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a, _b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
#define DEBUG 1
#if DEBUG
#define DUMP(a) do { std::cout << #a " = " << (a) << ", "; } while(false)
#define DUMPLN(a) do { std::cout << #a " = " << (a) << std::endl; } while(false)
#else
#define DUMP(a)
#define DUMPLN(a)
#endif
template<typename T, typename U>
inline void getMin(T &a, U b) { if (a > b) a = b; }
template<typename T, typename U>
inline void getMax(T &a, U b) { if (a < b) a = b; }
template<typename T>
vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T>
vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T>
vector<T> getEmptyVector() { return vector<T>(); }
template<typename T>
void appendAll(vector<T> &a, vector<T> b) { a.insert(a.end(), b.begin(), b.end()); }
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
// #define X first
// #define Y second
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const ll MOD = 1000000007;
const int MAXN = 1 << 17;
const int inf = 1 << 27;
const ll llinf = 1LL << 50;
const int NIL = -inf;
int popcount(int x) { return __builtin_popcount(x); }


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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//
//    #pragma GCC optimize("unroll-loops")
//    #pragma GCC optimize("Ofast")
//    #pragma GCC optimize("-O3")
//    #pragma GCC optimize("no-stack-protector")
//    #pragma GCC optimize("fast-math")

#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
////////////////////////////////???????????????CHECK THIS OUT???????????????//////////////////////////////
#define ll long long
////////////////////////////////???????????????CHECK THIS OUT???????????????//////////////////////////////
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define getfiles    ifstream cin("input.txt");ofstream cout("output.txt");
#define pw(x) (1ll << x)
#define sz(x) (ll)x.size()
#define endl "\n"
#define rall(x) x.rbegin(),x.rend()
#define len(a) (ll)a.size()
#define rep(x,l,r) for(ll x=l;x<r;x++)
//#define for(int i=0;i<n;i++) for(ll i=0;i<n;i++)
using namespace std;
//using namespace __gnu_pbds;
ld eps = (ld)1 / 1e6;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//const ll to[5]={0,4,6,7,9};
//const ll N=2*1e5+1;
const ll R=1e4;
//const ll to[7]={1,2,3,1,3,2,1};
//const ll tx[4]={0,0,-1,1};
//const ll ty[4]={-1,1,0,0};
const char rev_to[4]={'E','W','N','S'};
const ll N=2*1e5+4;
//set<int> lol2[26][26];
//set<int>ab;
//set<int>ba;
signed main(){
    fast_io;
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=2;i*i<=n;i++){
        if(n%i) continue;
        ll cnt=0;
        while(n%i==0){
            n/=i;
            cnt++;
        }
        ll D=1+8*cnt;
        ll x=((ld)-1+sqrt(D))/2;
        ans+=x;
    }
    if(n>1){
        ans++;
    }
    cout<<ans;
    return 0;
}
/*
    (x+1)*x/2=cnt
    cnt*2=(x+1)*x
    x^2+x-2*cnt=0;
    D=1+8*cnt
    x1=(-1+D)/2
    если WA , то чекер говно, поэтому почекай l8 строчку
    !x || !y x-проигрышная или выигрышная , y-колво таких позиций
    x==0 проигрышная
    y==0 четное проигрышных или четное выигрышных
    x==0 && y==0 четное проигрышных
*/


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int i,n,k,j;
	string s;
	cin>>s;
	n = s.size();
	map<char, int> id;
	id['N'] = 0;
	id['S'] = 1;
	id['W'] = 2;
	id['E'] = 3;
	vi cnt(5, 0);
	for(char x: s) cnt[id[x]] = 1;
	if(cnt[0] & !cnt[1]){
		cout<<"No\n";
	}
	else if(!cnt[0] & cnt[1]){
		cout<<"No\n";
	}
	else if(cnt[2] & !cnt[3]){
		cout<<"No\n";
	}
	else if(!cnt[2] & cnt[3]){
		cout<<"No\n";
	}
	else cout<<"Yes\n";

	return 0;
} 

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
	if (exp & 1) result = ((ll)result * base) % mod;
	base = ((ll)base * base) % mod;
	exp >>= 1;
	}
	return result;
}

void ipgraph(int m){
	int i, u, v;
	fo(i, m){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();
        string t = sc.Next();

        long answer = 0;

        for (int i = 0; i < s.Length; i++)
        {
            if (s[i] != t[i])
            {
                answer++;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 27324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

ll gcd(ll x,ll y){
  if (y==0){
    return x;
  }
  return gcd(y,x%y);
}

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

int main(){
    ll A,B;
    cin >> A >> B;
    ll C=gcd(A,B);
    map<ll,ll> m=prime_factor(C);
    ll s=m.size();
    cout << s+1 << endl;
}

Measured memory_bytes: 256
A, B, C = map(int, input().split())
if A * B * C % 2 == 0:
  print(0)
else:
  M = max(A, B, C)
  if M == A:
    print(B * C)
  elif M == B:
    print(A * C)
  else:
    print(A * B)

Measured memory_bytes: 9148
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000000000000ll
#define N 300009
#define sqr(x) (ll)(x)*(x)
using namespace std;

int n,q[N],a[N]; ll mx1[N],mx2[N],s[N],f[N],h[N],dp[2][N];
void work(ll *f,int l,int r){
	int i,j; bool flag=(l>r);
	if (l>r){
		swap(l,r);
		for (i=l,j=r; i<j; i++,j--) swap(a[i],a[j]);
	}
	s[l-1]=f[l-1]=f[r+1]=0;
	for (i=l; i<=r; i++) s[i]=s[i-1]+a[i];
	int tail=1; q[1]=l-1; h[l-1]=sqr(l-1);
	for (i=l; i<=r; i++){
		f[i]=f[i-1];
		while (tail>1 && h[q[tail]]-h[q[tail-1]]<2ll*i*(q[tail]-q[tail-1])) tail--;
		if (tail)
			f[i]=max(f[i],f[q[tail]]+sqr(i-q[tail])-s[i]+s[q[tail]]);
		h[i]=f[i]+s[i]+sqr(i);
		while (tail>1 && (h[i]-h[q[tail]])*(q[tail]-q[tail-1])>=(h[q[tail]]-h[q[tail-1]])*(i-q[tail])) tail--;
		q[++tail]=i;
	}
	if (flag)
		for (i=l,j=r; i<j; i++,j--){
			swap(a[i],a[j]); swap(f[i],f[j]);
		}
}
void solve(int l,int r){
	if (l==r){
		mx1[l]=max(mx1[l],1ll-a[l]); return;
	}
	int mid=l+r>>1,i,tail;
	solve(l,mid); solve(mid+1,r);
	s[l-1]=0;
	for (i=l; i<=r; i++) s[i]=s[i-1]+a[i];
	for (i=l-1,tail=0; i<=mid; i++){
		h[i]=dp[0][i]+s[i]+sqr(i);
		while (tail>1 && (h[i]-h[q[tail]])*(q[tail]-q[tail-1])>=(h[q[tail]]-h[q[tail-1]])*(i-q[tail])) tail--;
		q[++tail]=i;
	}
	for (i=mid+1; i<=r; i++){
		while (tail>1 && h[q[tail]]-h[q[tail-1]]<2ll*i*(q[tail]-q[tail-1])) tail--;
		f[i]=dp[1][i+1]+dp[0][q[tail]]+sqr(i-q[tail])-s[i]+s[q[tail]];
	}
	for (i=r-1; i>mid; i--) f[i]=max(f[i],f[i+1]);
	for (i=mid+1,tail=0; i<=r+1; i++){
		h[i]=dp[1][i]-s[i-1]+sqr(i);
		while (tail>1 && (h[i]-h[q[tail]])*(q[tail]-q[tail-1])>=(h[q[tail]]-h[q[tail-1]])*(i-q[tail])) tail--;
		q[++tail]=i;
	}
	for (i=l; i<=mid; i++){
		while (tail>1 && h[q[tail]]-h[q[tail-1]]<2ll*i*(q[tail]-q[tail-1])) tail--;
		f[i]=dp[0][i-1]+dp[1][q[tail]]+sqr(q[tail]-i)+s[i-1]-s[q[tail]-1];
	}
	for (i=l+1; i<=mid; i++) f[i]=max(f[i],f[i-1]);
	for (i=l; i<=r; i++) mx1[i]=max(mx1[i],f[i]);
}
int main(){
	scanf("%d",&n);
	int i,j;
	for (i=1; i<=n; i++){
		scanf("%d",&a[i]); a[i]=(a[i]<<1)-1;
	}
	memset(mx1,195,sizeof(mx1));
	work(dp[0],1,n); work(dp[1],n,1);
	solve(1,n);
	for (i=1; i<=n; i++) mx2[i]=dp[0][i-1]+dp[1][i+1];
	int cas; scanf("%d",&cas);
	while (cas--){
		scanf("%d%d",&i,&j); j=(j<<1)-1;
		printf("%lld\n",max(mx2[i],mx1[i]+a[i]-j)>>1);
	}
	return 0;
}


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

int main()
{
    ll a, b; cin >> a >> b;
    ll dif = b - a;
    ll sum = 0;
    rep(i,dif-1) {
        sum += (i+1);
    }
    cout << sum - a << endl;

 

}


Measured memory_bytes: 3624
#include <stdio.h>
int main(void){
  int N,i,A,max=0;
  long int s=0;
  setbuf(stdout,NULL);
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A);
    if(A<max)s+=max-A;
    else if(A>=max)max=A;
  }
  printf("%ld",s);
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

LL x, y;

int main() {
    cin >> x >> y;
    if (abs(x - y) <= 1) {
        cout << "Brown" << endl;
    } else {
        cout << "Alice" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    string s;
    cin >> s;
    int cnt[26] = {};
    REP(i,s.size()) cnt[ int(s[i] - 'a')] ++;
    REP(i,26) if(cnt[i] %2 != 0){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i,N) {
        cin >> A[i];
        B[i] = A[i];
    }

    sort(B.begin(), B.end(), greater<int>());

    rep(i,N) {
        if (A[i] == B[0]) cout << B[1] << endl;
        else cout << B[0] << endl;
    }

    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }



signed main(){

    int A, B, C; cin >> A >> B >> C;
    int X[3][3];
    X[0][0] = A;
    X[0][1] = B;
    X[1][1] = C;
    X[2][0] = A + B - C;
    X[2][2] = B + C - X[2][0];
    int s = A + C + X[2][2];
    X[0][2] = s - A - B;
    X[1][0] = s - A - X[2][0];
    X[1][2] = s - X[1][0] - C;
    X[2][1] = s - B - C;
    REP(i, 3){
        REP(j, 3) cout << X[i][j] << " ";
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int dp[2510][2510];
int s;
vi t;

int main(){
	int n;
	cin>>n;
	t.resize(n);
	rep(i, n) cin>>t[i], s+= t[i];
	rep(i, 2510) rep(j, 2510) dp[i][j] = 1e9;
	dp[0][0] = s;
	for(int i = 0; i < n; i++) {
		for(int j = s; j >= 0; j--) {
			for(int k = s - t[i]; k >= 0; k--) {
				if(dp[j][k] != 1e9) dp[j][k+t[i]] = min(dp[j][k+t[i]], dp[j][k] - t[i]);
				if(dp[k][j] != 1e9) dp[k+t[i]][j] = min(dp[k+t[i]][j], dp[k][j] - t[i]);
			}
		}
	}
	int ans = 1e9;
	rep(i, 2510) rep(j, 2510) ans =min(ans, max({i, j, dp[i][j]}));
	cout<<ans<<endl;
}

Measured memory_bytes: 27680
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int R = 0;
    for (char c : S) if (c == 'R') R++;
    int ans = 0;
    for (int i = 0; i < R; i++) if (S[i] == 'W') ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3740
#include<stdio.h>

int main(){
  int W,H,x,y,r,f=0;
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
  if(x+r>W) f=1;
  if(y+r>H) f=1;
  if(r>x) f=1;
  if(r>y) f=1;
  if(f==0) printf("Yes\n");
  else printf("No\n");
  return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#define llong long long
#define pb(a) push_back(a)
#define strVecSORT(strVec) sort(strVec.begin(), strVec.end());
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;

int main(){
  int N;
  cin>>N;
  int i;
  vector<int> gray,brown,green,lightBlue,Blue,yellow,orange,red,rainbow;
  rep(i,N){
    int a;
    cin>>a;
    if(a<=399) {gray.pb(a);
    }else if(a<=799) {brown.pb(a);
    }else if(a<=1199) {green.pb(a);
    }else if(a<=1599) {lightBlue.pb(a);
    }else if(a<=1999) {Blue.pb(a);
    }else if(a<=2399) {yellow.pb(a);
    }else if(a<=2799) {orange.pb(a);
    }else if(a<=3199) {red.pb(a);
    }else if(a<=4800) {rainbow.pb(a);
    }
}
  int grayA,brownA,greenA,lightBlueA,BlueA,yellowA,orangeA,redA,rainbowA;
  if(gray.size()==0){
    grayA=0;
  }else{
    grayA=1;
  }
  if(brown.size()==0){
    brownA=0;
  }else{
    brownA=1;
  }
  if(green.size()==0){
    greenA=0;
  }else{
    greenA=1;
  }
  if(lightBlue.size()==0){
    lightBlueA=0;
  }else{
    lightBlueA=1;
  }
  if(Blue.size()==0){
    BlueA=0;
  }else{
    BlueA=1;
  }
  if(yellow.size()==0){
    yellowA=0;
  }else{
    yellowA=1;
  }
  if(orange.size()==0){
    orangeA=0;
  }else{
    orangeA=1;
  }
  if(red.size()==0){
    redA=0;
  }else{
    redA=1;
  }
  if(rainbow.size()==0){
      rainbowA=0;
  }else{
      rainbowA=rainbow.size();
  }
  int ansMin=grayA+brownA+greenA+lightBlueA+BlueA+yellowA+orangeA+redA;
  int ansMax=grayA+brownA+greenA+lightBlueA+BlueA+yellowA+orangeA+redA+rainbowA;
  if(ansMin==0){
    ansMin=1;
  }
  cout<<ansMin;
  cout<<" ";
  cout<<ansMax<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#define int long long
int test[100000], uiop[100000];
using namespace std;
signed main() {
	int n, a, b, c = 0, d = 0, e = 0; cin >> n >> a >> b;
	c = a, d = b;
	for (int h = 1; h <= 1000000; h++) {
		if (h % 2 == 1) {
			a = a - b;
		}
		else {
			b = a + b;
		}
		if (a == c && b == d) { e = h; break; }
		test[h] = a; uiop[h] = b;
	}
	if (n % e == 0) {
		cout << a << ' ' << b << endl;
	}
	else {
		cout << test[n % e] << ' ' << uiop[n % e] << endl;
	}
}


Measured memory_bytes: 3116
//#include "stdafx.h"
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>
#include "random"
#include "chrono"
#include "cstring"

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target_ans("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++)
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
//#define endl '\n'

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;

#define int long long
//#define int unsigned int
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;
typedef vector<vi> vvi;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

vi xx = { 1, 0, -1, 0 };
vi yy = { 0, 1, 0, -1 };
string dir = "LRUD";

const int N = 2e5 + 50, oo = 3e18 + 500;
//const int mod = 998244353;
const int mod = 1e9 + 7;
//const int mod = 1e9 + 9;
const double eps = 1e-12, PI = 2 * acos(0.0);
int n, m, k;
long long cnt = 0;
int lg = 18;
set<int> g[N];
vi rg[N];
vi visit(N, 0);

signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("abbreviation.in", "r", stdin);
	freopen("abbreviation.out", "w", stdout);*/

	cin >> n;

	vi a(n);
	int x = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		x ^= a[i];
	}

	for (int i = 0; i < n; i++)
	{
		cout << (a[i] ^ x) << " ";
	}
}



Measured memory_bytes: 15296
#include<cstdio>
#include<map>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef unsigned long long uLL;
const uLL con=371902093;
uLL pw[45],rdm[30],ans;
char s[45];
int n;
map<uLL,int> M;
int main(){
  srand(1234);
  scanf("%d%s",&n,s+1);
  pw[0]=1; for(int i=1;i<=40;i++) pw[i]=pw[i-1]*con;
  for(int i=0;i<=25;i++) rdm[i]=rand()*rand()*rand()*rand();
  for(int i=0;i<=(1<<n)-1;i++){
    uLL h1=0,h2=0; int cnt=0;
    for(int j=1;j<=n;j++)
      if((i>>j-1)&1) h1=h1*con+rdm[s[j]-'a'], cnt++;  
    h1=h1*pw[n-cnt];
    for(int j=n;j>=1;j--)
      if(!((i>>j-1)&1)) h2=h2*con+rdm[s[j]-'a'];
    M[h1-h2]++;
  }
  for(int i=0;i<=(1<<n)-1;i++){
    uLL h1=0,h2=0; int cnt=0;
    for(int j=1;j<=n;j++)
      if((i>>j-1)&1) h1=h1*con+rdm[s[n+j]-'a']; 
    for(int j=n;j>=1;j--)
      if(!((i>>j-1)&1)) h2=h2*con+rdm[s[n+j]-'a'], cnt++;
    h2=h2*pw[n-cnt];
    ans+=M[h2-h1];
  }
  printf("%llu\n",ans);
  return 0;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    string ans{};
    rep(i,n) ans.push_back('a');
    bool err=false;
    rep(i,m){
        int s;
        char c;
        cin>>s>>c;
        s--;
        if(ans[s]=='a'||ans[s]==c){
            ans[s]=c;
        }else{
            err=true;
        }
    }
    if(ans[0]=='0'&&n>1) err=true;
    rep(i,n){
        if(ans[i]=='a'){
            if(i==0&&n>1) ans[i]='1';
            else ans[i]='0';
        }
    }
    if(!err) cout<<ans<<endl;
    else cout<<-1<<endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define	INF	0x3f3f3f3f
#define	LL	long long
#define	MAXN	100010
using namespace std;
char s[MAXN];
vector <int> a[MAXN];
int n;

template <typename T> void chkmin(T &x, T y){x = min(x, y);}
template <typename T> void chkmax(T &x, T y){x = max(x, y);}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

int main(){
	scanf("%s", s + 1);
	n = strlen(s + 1);
	int fla = 1;
	if (s[1] == '0') fla = 0;
	if (s[n] == '1') fla = 0;
	for (int i = 1; i < n; ++i)
		if (s[i] != s[n - i]) {fla = 0; break;}
	if (!fla) {printf("-1\n"); return 0;}
	int cnt = 1;
	for (int i = 2; i <= n; ++i){
		if (s[i] == '0') continue;
		int delta = i - cnt - 1, cur = cnt;
		cnt = i;
		for (int j = 0; j <= delta; ++j)
			printf("%d %d\n", cur + j, cnt);
	} 
	for (int i = n; i <= n; ++i){
		int delta = i - cnt - 1, cur = cnt;
		cnt = i;
		for (int j = 0; j <= delta; ++j)
			printf("%d %d\n", cur + j, cnt);
	}
	return 0;
}

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

using namespace std;



int main() {
	int X;
	cin >> X;
	for (int a = -118;a<=119;++a) {
		for (int b = -119; b <= 118;++b) {
			if (X == (pow(a,5)-pow(b,5))) {
				cout << a << " "<<b << endl;
				return 0;
			}
		}
	}
	return 0;
}

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

string s;
int n,k,cnt;

int main()
{
	scanf("%d %d",&n,&k);
	cin>>s;
	for(int i=0;i<n;++i)
		if(s[i]==s[i+1]) cnt++;
	printf("%d",min(n-1,cnt+2*k));
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    if (a <= 9 && b <= 9)
        cout << a * b << endl;
    else
        cout << -1 << endl;
    return 0;
}

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

int main()
{
    int n,k;
    cin >> n>>k;
    vector<int> mV;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        mV.push_back(x);
    }
    vector<int> fA(n);
    for (int i = 0; i < n; i++) {
        fA[i] = INT_MAX;
    }
    fA[n - 1] = 0;
    for (int i = n - 2; i >= 0; i--) {
        for (int j = 1; (i + j <= n - 1 && j<=k); j++) {
            fA[i] = min(fA[i], abs(mV[i + j] - mV[i])+ fA[i+j]);
        }
    }
   
    cout << fA[0] << endl;
    
}



Measured memory_bytes: 1144
N, K = map(int, input().split())
x = list(map(int, input().split()))

ans = float("inf")
for i in range(N-K+1):
    ans = min(ans, min(abs(x[i]) + abs(x[i+K-1]-x[i]), abs(x[i+K-1]) + abs(x[i]-x[i+K-1])))

print(ans)


Measured memory_bytes: 14252
def read_input():
    h, w = map(int, input().split())
    slist = []
    for i in range(h):
        slist.append(input().strip())

    return h, w, slist

# i, jの周辺に1を足す
def sumup(board, i, j):
    def notbomb(x):
        return x != '#'

    up = i - 1 >= 0
    down = i + 1 < len(board)
    left = j - 1 >= 0
    right = j + 1 < len(board[0])

    if up:
        if notbomb(board[i - 1][j]):
            board[i - 1][j] += 1
        if left:
            if notbomb(board[i - 1][j - 1]):
                board[i - 1][j - 1] += 1
        if right:
            if notbomb(board[i - 1][j + 1]):
                board[i - 1][j + 1] += 1
    if left:
        if notbomb(board[i][j - 1]):
            board[i][j - 1] += 1
    if right:
        if notbomb(board[i][j + 1]):
           board[i][j + 1] += 1
    if down:
        if notbomb(board[i + 1][j]):
            board[i + 1][j] += 1
        if left:
            if notbomb(board[i + 1][j - 1]):
                board[i + 1][j - 1] += 1
        if right:
            if notbomb(board[i + 1][j + 1]):
                board[i + 1][j + 1] += 1
    return board

def submit():
    h, w, slist = read_input()

    board = []
    for s in slist:
        board.append([0 if c == '.' else c for c in s])

    for i in range(h):
        for j in range(w):
            if board[i][j] == '#':
                board = sumup(board, i, j)

    for row in board:
        print(''.join([str(c) for c in row]))


if __name__ == '__main__':
    submit()

Measured memory_bytes: 41712
import math

n, d = map(int, input().split())
xy = [list(map(int, input().split())) for a in range(n)]
count = 0
for i in range(n):
    number = (xy[i][0]**2)+(xy[i][1]**2)
    result = math.sqrt(number)
    if result <= d:
        count += 1
    else:
        count += 0
print(count)

Measured memory_bytes: 45388
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		char s[][] = new char[H + 2][W + 2];
		String temp = "";
		for (int i = 0; i < H + 2; i++) {
			if (i != 0 && i != H + 1) {
				temp = sc.next();
			}
			for (int j = 0; j < W + 2; j++) {
				if (i != 0 && i != H + 1 && j != 0 && j != W + 1) {
					s[i][j] = temp.charAt(j-1);
				}
			}
		}
		boolean flag = true;
		for (int i = 1; i < H + 1; i++) {
			for (int j = 1; j < W + 1; j++) {
				if (s[i][j] == '#' && s[i][j - 1] == '.' && s[i][j + 1] == '.' && s[i - 1][j] == '.'
						&& s[i + 1][j] == '.') {
					flag = false;
				}
			}
		}
		if (flag) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23764
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>

using namespace std;

struct S{
  int v,t;
  bool operator<(S s)const{
    return t>s.t;
  }
};

int main(){
  int N,E,T;
  cin>>N>>E>>T;
  priority_queue<S> que;
  for(int i=1;i<=N;i++){
    int W;
    cin>>W;
    if(W){
      que.push({i,1});
    }
  }
  int G[1234],C[1234],S[1234][12];
  for(int i=0;i<E;i++){
    cin>>G[i]>>C[i];
    for(int j=0;j<C[i];j++){
      cin>>S[i][j];
    }
  }
  int nn[312]={};
  while(!que.empty()){
    auto c=que.top();
    que.pop();
    if(nn[c.v])continue;
    nn[c.v]=c.t;
    for(int i=0;i<E;i++){
      bool u=false;
      bool f=false;
      vector<int> v(C[i]);
      for(int j=0;j<C[i];j++){
	u|=S[i][j]==c.v;
	f|=!nn[S[i][j]];
	v[j]=nn[S[i][j]];
      }
      if(u&&!f){
	sort(begin(v),end(v));
	int m=0;
	for(int k=0;k<v.size();k++){
	  m=max<int>(m,v.size()-1-k+v[k]);
	}
	que.push({G[i],m});
      }
    }
  }
  cout<<(nn[T]?nn[T]:-1)<<endl;
}

Measured memory_bytes: 1292
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class Data
{
public:
    double t;
    long long v;
    Data(){
        t = 0.0;
        v = 0;
    }
    Data(double t, long long v){
        this->t = t;
        this->v = v;
    }
    Data operator+(const Data& d){
        double t2 = (t * v + d.t * d.v) / (v + d.v);
        long long v2 = v + d.v;
        return Data(t2, v2);
    }
};

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

    deque<Data> dq;
    double sum = 0.0;
    while(--n >= 0){
        Data in;
        cin >> in.t >> in.v;

        if(!dq.empty()){
            long long out = in.v;
            while(out > 0){
                auto& d = dq.front();
                if(out < d.v){
                    sum -= out * d.t;
                    d.v -= out;
                    out = 0;
                }
                else{
                    sum -= d.v * d.t;
                    out -= d.v;
                    dq.pop_front();
                }
            }
        }

        sum += in.v * in.t;
        while(!dq.empty() && in.t < dq.back().t){
            in = in + dq.back();
            dq.pop_back();
        }
        dq.push_back(in);

        double ans = sum / l;
        printf("%.10f\n", ans);
    }

    return 0;
}


Measured memory_bytes: 18704
#include <iostream>
#include <utility>
#include <functional>
#include <set>
#define Fi first
#define Se second
using namespace std;
using ll = long long;
using pll = pair<long long, long long>;

//auto f = [](const pll &a, const pll &b){return a.Fi<b.Fi && a.Se<b.Se;};
//multiset<pll, function<bool(const pll &, const pll &)>> ms(f);
multiset<ll, greater<ll>> ms;

ll n;
ll a[100005];
ll ans = 0;

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

    for (int i = 1; i <= n; i++) {
        ll x = a[i];

        if(ms.upper_bound(x) != ms.end()) {
            ms.erase(ms.upper_bound(x));
            ms.insert(x);
        }
        else {
            ms.insert(x);
            ans++;
        }
    }

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


Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		int ans = 0;
		int cnt = 0;
		for(int i = 1; i < n; i++) {
			if(s.charAt(i) == s.charAt(i - 1)) {
				ans++;
			} else {
				cnt++;
			}
		}
		boolean flag = cnt % 2 == 1;
		int div = cnt / 2;
		if(k <= div) {
			ans += k * 2;
		} else if(flag) {
			ans += div * 2;
			ans++;
		} else {
			ans += div * 2;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 25884
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n, ma, mb;
    cin >> n >> ma >> mb;
    vi a(n), b(n), c(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i] >> c[i];
    }
    vvl dp(401, vl(401, INF));
    dp[0][0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 400; j >= 0; --j) {
            for (int k = 400; k >= 0; --k) {
                if (j - a[i] >= 0 && k - b[i] >= 0)
                    chmin(dp[j][k], dp[j - a[i]][k - b[i]] + c[i]);
            }
        }
    }
    ll ret = INF;
    for (int i = 1; i <= 400; ++i) {
        int aa = ma * i;
        int bb = mb * i;
        if (aa <= 400 && bb <= 400) {
            chmin(ret, dp[aa][bb]);
        } else
            break;
    }
    if (ret == INF)
        cout << -1 << "\n";
    else
        cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 1536
K,N=map(int,input().split())
mod=998244353
L=max(K,N)
table=[1]*(3*L+5)
t=1
for i in range(1,3*L+5):
    t*=i
    t%=mod
    table[i]=t
rtable=[1]*(3*L+5)
t=1
for i in range(1,3*L+5):
    t*=pow(i,mod-2,mod)
    t%=mod
    rtable[i]=t
ans=[]
for k in range(2,K+2):
    num=0
    if k%2==1:
        l=k//2
        p=l
        r=K-2*l
        for q in range(l+1):
            if N-q>=0 and r+q-1>=0:
                s=(table[l]*rtable[q]*rtable[l-q])%mod
                s=(s*pow(2,q,mod))%mod
                t=(table[N+r-1]*rtable[N-q]*rtable[r+q-1])%mod
                s=(s*t)%mod
                num+=s
                num=num%mod
                #print(10,q,k,l,p,num,s)
        ans.append(num)
    else:
        l=k//2
        p=l-1
        r=K-k+1
        for q in range(p+1):
            if N-q-1>=0 and r+q-1>=0:
                s=(table[p]*rtable[q]*rtable[p-q])%mod
                s=(s*pow(2,q,mod))%mod
                t=(table[N+r-2]*rtable[N-q-1]*rtable[r+q-1])%mod
                s=(s*t)%mod
                num+=s
                num%=mod
                #print(9,q,k,l,p,num,s)
            if N-q>=0 and r+q-1>=0:
                s=(table[p]*rtable[q]*rtable[p-q])%mod
                s=(s*pow(2,q,mod))%mod
                t=(table[N+r-1]*rtable[N-q]*rtable[r+q-1])%mod
                s=(s*t)%mod
                num+=s
                num%=mod 
                #print(10,q,k,l,p,num,s)
        ans.append(num)
print('\n'.join(map(str,ans)))
ans=ans[::-1]
print('\n'.join(map(str,ans[1:])))

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

const double PI = 3.14159265358979323846;
//using namespace boost::multiprecision;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 1e15;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

void warshall_floyd(int n, vector<vector<ll>> &distances) {
    for (int k = 0; k < n; k++) {       // 経由する頂点
        for (int i = 0; i < n; i++) {    // 始点
            for (int j = 0; j < n; j++) {  // 終点
                if (distances[i][j] == INF && (distances[i][k] == INF || distances[k][j] == INF)) {
                    distances[i][j] = INF;
                } else {
                    distances[i][j] = min(distances[i][j], distances[i][k] + distances[k][j]);
                }
            }
        }
    }
}

struct Edge {
    ll to, cost;
};


class Dijkstra {
    ll vector_count;

    vector<ll> distances;
    vector<vector<Edge>> edges;

public:
    Dijkstra(ll n) {
        vector_count = n;
        distances.resize(n, INF);
        edges.resize(n);
    }

    void insertTowWay(ll from, ll to, ll cost) {
        edges[from].push_back({to, cost});
        edges[to].push_back({from, cost});
    }

    void insert(ll from, ll to, ll cost) {
        edges[from].push_back({to, cost});
    }

    void dijkstra(ll k) {
        distances[k] = 0;  // 始点sへの最短距離は0

        priority_queue<P, vector<P>, greater<P>> que;  // 距離が小さい順に取り出せるようgreater<P>を指定
        que.push(P(0, k));
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            int v = p.second;  // 更新した頂点の中で距離が最小の頂点v
            if (distances[v] < p.first) {
                continue;
            }
            for (auto e : edges[v]) {  // 頂点vから出る辺eを走査
                if (distances[e.to] > distances[v] + e.cost) {
                    distances[e.to] = distances[v] + e.cost;
                    que.push(P(distances[e.to], e.to));
                }
            }
        }
    }

    ll distance(ll to) {
        return distances[to];
    }

};

int main() {

    int n;
    cin >> n;

    Dijkstra dijkstra(n);

    rep(i, n - 1) {
        int a, b;
        ll d;
        cin >> a >> b >> d;
        a--;
        b--;
        dijkstra.insertTowWay(a, b, d);
    }
    dijkstra.dijkstra(0);

    rep(i, n) {
        cout << dijkstra.distance(i) % 2 << endl;
    }

}

Measured memory_bytes: 8704
SA = input()
SB = input()
SC = input()
c = "a"
iA = iB = iC = 0
while True:
  if c == "a":
    if iA == len(SA):
      break
    c = SA[iA]
    iA += 1
  elif c == "b":
    if iB == len(SB):
      break
    c = SB[iB]
    iB += 1
  elif c == "c":
    if iC == len(SC):
      break
    c = SC[iC]
    iC += 1
if c == "a":
  print("A")
if c == "b":
  print("B")
if c == "c":
  print("C")


Measured memory_bytes: 3064
#include <stdio.h>
#include <limits.h>

int main(void) {
   
   int N;
   
   scanf("%d",&N);
   
   int A[N];
   int i;
   long right_sum = 0;
   for (i = 0;i < N; i++) {
      scanf("%d",&A[i]);
      right_sum = right_sum + A[i];
   }
   
   long left_sum = 0;
   long diff = 9223372036854775807;
   
   for (i = 0; i < N; i++) {
      left_sum = left_sum + A[i];
      right_sum = right_sum - A[i];
      if (labs(left_sum - right_sum) < labs(diff)) {
         diff = left_sum - right_sum;
      }
   }
  
   printf("%ld\n",labs(diff));
   
   return 0;
}


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

int main()
{
    int n,a,b,c;cin>>n>>a>>b>>c;
    vector<int> l(n);
    int i,j;
    for(i=0;i<n;i++)cin>>l.at(i);
    int max=1;
    int la,lb,lc;
    int ans=1e8;
    int kans;
    int ii;
    vector<int> place(n);
    for(i=0;i<n;i++)max*=4;
    for(i=0;i<max;i++)
    {
        kans=0;
        ii=i;
        la=0;
        lb=0;
        lc=0;
        for(j=0;j<n;j++)
        {
            place.at(j)=ii%4;
            ii/=4;
        }
        for(j=0;j<n;j++)
        {
            if(place.at(j)==1)
            {
                if(la>0)kans+=10;
                la+=l.at(j);
            }
            if(place.at(j)==2)
            {
                if(lb>0)kans+=10;
                lb+=l.at(j);
            }
            if(place.at(j)==3)
            {
                if(lc>0)kans+=10;
                lc+=l.at(j);
            }
        }
        if(la!=0&&lb!=0&&lc!=0)
        {
            kans+=abs(la-a)+abs(lb-b)+abs(lc-c);
            if(kans<ans)ans=kans;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	ll N,A,B;
	cin>>N>>A>>B;
	DBG("","","","");
	ll ans=0;
	if(N>(A+B)){
		ans=N/(A+B);
		ans*=A;
		ll amari=N%(A+B);
		if(amari>A) ans+=A;
		else        ans+=amari;
		cout<<ans<<endl;
	}
	else if(N>A){
		ans=A;
		cout<<ans<<endl;
	}
	else{
		ans=N;
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
typedef unsigned long long Ull;
#define MM(a,b) memset(a,b,sizeof(a));
const double eps = 1e-10;
const int  inf =0x7f7f7f7f;
const double pi=acos(-1);
const int maxn=100000+10;
int c[maxn][22],deep[maxn],vis[maxn];
vector<vector<int> > G(maxn);

void dfs(int u,int par)
{
    c[u][0]=par;
    for(int i=1;i<=20;i++) c[u][i]=c[c[u][i-1]][i-1];
    for(int i=0;i<G[u].size();i++)
    {
        int v=G[u][i];
        if(v==par) continue;
        deep[v]=deep[u]+1;
        dfs(v,u);
    }
}

int lca(int u,int v)
{
    if(deep[u]<deep[v]) swap(u,v);
    for(int i=20;i>=0;i--)
      if(deep[c[u][i]]>=deep[v])
          u=c[u][i];
    if(u==v) return u;
    for(int i=20;i>=0;i--)
    if(c[u][i]^c[v][i])
    {
        u=c[u][i];
        v=c[v][i];
    }
    return c[u][0];
}

int dis(int u,int v)
{
    /* printf("u:%d deep[u]:%d\n",u,deep[u]);
     printf("v:%d deep[v]:%d\n",v,deep[v]);
     printf("lca:%d deeplca:%d\n",lca(u,v),deep[lca(u,v)]);
     printf("dis:%d\n",deep[u]+deep[v]-2*deep[lca(u,v)]);
     printf("\n");
     */
     return deep[u]+deep[v]-2*deep[lca(u,v)];
}

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=n;i++) G[i].clear();
        deep[1]=0;
        for(int i=2;i<=n;i++)
        {
            int x;scanf("%d",&x);
            G[x].push_back(i);
        }
        dfs(1,1);
       // for(int i=1;i<=n;i++)
        //   printf("deep:%d %d\n",i,deep[i]);
       //for(int i=1;i<=n;i++)
        //  for(int j=1;j<=n;j++)
         //    printf("ww%d %d %d\n",i,j,dis(i,j));

        int pre=1;ll ans=0;
        queue<int> q;
        q.push(1);
        while(q.size())
        {
            int u=q.front();q.pop();
            for(int i=0;i<G[u].size();i++)
            {
                 int v=G[u][i];
                 ans+=dis(pre,v);
                 pre=v;
                 q.push(v);
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 22032
#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
 
#define PI acos(-1.0)
#define CIR(i, l, u) for(int i = l; i < u; ++i)
#define cir(i, u, l) for(int i = u; i > l; --i)
#define p(x) cout << x << endl
#define pd(x) cout << "*" << x << endl
#define py cout << "YES" << endl
#define pn cout << "NO" << endl 
#define INI(n, i) memset(n, i, sizeof(n))
#define MAX(a, b) a = a > b ? a : b
#define MIN(a, b) a = a < b ? a : b
#define ll long long
const int inf = 0x3f3f3f3f;
const int maxn = 1.5e5 + 5;
const ll mod = 1e9 + 7;

//struct N{
//	int val;
//	int pos;
//} bra[105];
//
//bool cmp(N a, N b)
//{
//	return a.val < b.val;
//}

//bool cmp(int a, int b)
//{
//	return a > b;
//}

struct cmp2
{
    bool operator () (const int a,const int b)
    {
        return a>b;//????
    }
};

ll gcd(ll m,ll n)
{
    ll y;  
    y=m%n;
    while(y!=0)
    {
        m=n;
        n=y;
        y=m%n;
    }
    return n;
}

int main()
{
	int a, b;
	cin >> a >> b;
	int v = ceil(a / 0.08);
	if(v * 0.1 < b + 1 && v * 0.1 >= b)
	{
		cout << v << endl;
//		cout << v * 0.08 << " " << v * 0.1 << endl;
	}
	else
	{
		
		v = floor(b / 0.1);
		if(v * 0.08 >= a && v * 0.08 < a + 1) p(v);
		else p("-1");
//		p("-1");
//		cout << v << " " << v * 0.08 << " " << v * 0.1 << endl;
	}

	return 0;
}




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

#define int long long
#define pii pair<int, int>
#define pb push_back

int n, s;
int const N = 3e3 + 10, M = 998244353;
int a[N];
int dp[N][2 * N][3];

signed main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);    
    cin >> n >> s;
    for(int i = 1 ; i <= n ; i++){
        cin >> a[i];
    }
    
    int ans = 0;
    dp[n + 1][s][2] = 1;
    for(int i = n ; i >= 1 ; i--){
        for(int sum = s ; sum >= 0 ; sum --){
            for(int t = 0 ; t <= 2 ; t++){
                if(t == 0) {
                    dp[i][sum][0] = (dp[i + 1][sum][0] + dp[i + 1][sum + a[i]][1] + dp[i + 1][sum][1]) % M;
                }
                else if( t == 1){
                    dp[i][sum][1] = (dp[i + 1][sum][1] + dp[i + 1][sum + a[i]][1] + dp[i + 1][sum + a[i]][2] + dp[i + 1][sum][2]) % M;
                }
                else{
                    dp[i][sum][2] = dp[i + 1][sum][2] % M;
                }
            }
        }
        (ans += dp[i][0][1]) %= M;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 423168