akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll maxCommon(ll a, ll b)
{
    ll tmp1,tmp2,r;
        if(a >= b)
        {
            tmp1 = a;
            tmp2 = b;
        }
        else
        {
            tmp1 = a;
            tmp2 = b;
        }

        r = tmp1 % tmp2;

        while(r != 0)
        {
            tmp1 = tmp2;
            tmp2 = r;
            r = tmp1 % tmp2;
        }
    return tmp2;
}

int main()
{
    ll N;
    cin >> N;
    ll sum = 0;

    for(ll i = 1; i <= N; i++)
    {
        for(ll j = 1; j <= N; j++)
        {
            for(ll k = 1; k <= N; k++)
            {
                ll tmp = maxCommon(i,j);
                tmp =  maxCommon(tmp,k);
                sum += tmp;
            }
        }
    }   
    cout << sum << endl;
}

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

int main(){
  int n, l[200];
  int ans = 0;
  cin >> n;
  for(int i = 0;i < 2*n;i++) cin >> l[i];
  sort(l, l+(2*n), greater<int>());

  for(int i = 0;i <= 2*n-2;i+=2) ans += min(l[i], l[i+1]);
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
def tanri(money, year, ritu, cost):
	temp = int(year*(money+cost)*ritu)
	temp -= (ritu * cost*year*(year-1))//2
	return temp

def tanri_a(m,y,r,c):
	temp = m
	ans = 0
	for _ in range(y):
		ans += int(temp*r)
		temp -= c
	return ans + temp

def hukuri(m, y, r, c):
	temp = (m-c/r)*((1+r)**(y-1))
	return int(temp)

def hukuri_a(m, y, r, c):
	temp = m
	for i in range(y):
		temp = temp + int(temp*r) - c
	return int(temp)

def main(init_money):
	year = int(input())
	n = int(input())
	ans = 0
	for _ in range(n):
		temp = input().split()
		w, ritsu, cost = int(temp[0]), float(temp[1]), int(temp[2])
		# if w == 0: temp = tanri(init_money, year, ritsu, cost)
		# else: temp = hukuri(init_money, year, ritsu, cost)
		if w == 0: temp2 = tanri_a(init_money, year, ritsu, cost)
		else: temp2 = hukuri_a(init_money, year, ritsu, cost)
		ans = max(ans, temp2)
		# print(f"temp: {temp}, temp2: {temp2}, diff: {temp-temp2}")
	print(ans)
	return
		
n = int(input())
for _ in range(n):
	main(int(input()))


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

	ll n, x;
	cin>>n>>x;
	ll a[n];
	ll c(0);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll d = 0;
	for(int i=0;i<n;i++){
		if(d<=x)c++;
		d+=a[i];
	}
	if(d<=x)c++;
	cout<<c;
	return 0;
}


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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  if (S[0] == T[0])
    ans++;
  if (S[1] == T[1])
    ans++;
  if (S[2] == T[2])
    ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

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

    ll n = N;
    ll l = 9;
    while(n/10){
        n /= 10;
        (l *= 10) += 9;
    }

    while(l > N){
        n = l;
        int d = 0;
        while(n/10){
            d++;
            n /= 10;
        }
        l -= (ll)pow((ll)10, (ll)d);
    }

    ll ans = 0;
    while(l/10){
        ans += (l%10);
        l /= 10;
    }
    ans += (l%10);
    pr(ans);
}

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

typedef long long int ll;

int main()

{
  ll i,ans=1,n;
  string na,curr,prev;
  cin>>na;
  na=na+na[na.length()-1];
  prev=na[0];
  curr=na[1];
for(i=1;i<na.length()-1;i++)
{
  if(curr==prev)
   {
    curr=curr+na[i+1];
   }
   else
   {
    prev=curr;
    curr=na[i+1];
    ans++;
   }
}
cout<<ans;

}

Measured memory_bytes: 900
#include <iostream>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <climits>
using namespace std;

int main(){
	double x;
	while(cin>>x){
		double h = 4.9*x*x/9.8/9.8;
		int y=0;
		while(5*y-5<h) y++;
		cout << y << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;
int K;
int Q;
int cur;
int pts[114514];

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  cin >> N >> K >> Q;
  rep(i, Q) {
    int a;
    cin >> a;
    --a;
    pts[a]++;
  }

  rep(i, N) {
    if (pts[i] - Q + K > 0) cout << "Yes\n";
    else cout << "No\n";
  }
}




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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

const int INF = 1 << 29;

int N;
ll L;
ll a[100000];

int main() {
    string ans[] = {"Possible", "Impossible"};

    cin >> N >> L;
    rep (i, N) cin >> a[i];

    bool flg = false;
    int idx = -1;
    rep (i, N - 1) {
        if (a[i] + a[i + 1] >= L) {
            flg = true;
            idx = i + 1;
            break;
        }
    }

    if (!flg) cout << ans[1] << endl;
    else {
        cout << ans[0] << endl;
        for (int i = 1; i < idx; i++) {
            cout << i << endl;
        }
        for (int i = N - 1; i > idx; i--) {
            cout << i << endl;
        }
        cout << idx << endl;
    }
}


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

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

int H,W;
string S[2020];
int len[2020][2020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(y,H) cin>>S[y];
	
	FOR(y,H-1) {
		int same=W,ns=W;
		for(x=W-1;x>=0;x--) {
			if(S[y][x]==S[y+1][x]) {
				len[y][x]=ns-x;
				same=x;
			}
			else {
				len[y][x]=same-x;
				ns=x;
			}
		}
	}
	
	int ma=max(H,W);
	int step=0;
	while(W) {
		vector<pair<int,int>> V;
		V.push_back({-1,-1});
		for(y=1;y<=H;y++) {
			
			x=len[y-1][step];
			int f=y;
			while(V.back().second>=x) {
				f=V.back().first;
				ma=max(ma,V.back().second*(y-f+1));
				V.pop_back();
			}
			V.push_back({f,x});
		}
		W--;
		step++;
	}
	
	cout<<ma<<endl;
	
	
	
}


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


Measured memory_bytes: 20352
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int a, b, c;
    cin >> a >> b >> c;
    if (a+b+c < 22) OUT("win")
    else OUT("bust")

    return 0;
}

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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int k, a, b;
  cin >> k >> a >> b;
  a = b / k - (a - 1) / k;
  cout << (a ? "OK" : "NG");
  return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
/********************************************************************************************************************************/
/* main *************************************************************************************************************************/
/********************************************************************************************************************************/
int DEBUG = 1;										/* デバッグプリント 提出時は0 */
int main()
{
	long long		i,a,b,c,d,x,y,r,m,ans = 0;
	
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	ans = b - a +1;
	ans -= (b/c) - (a-1)/c;
	ans -= (b/d) - (a-1)/d;

	x= max(c,d);
	y= min(c,d);

	if (x%y == 0) r = y;
	else {
		while(x%y !=0) {
			r = x%y;
			x = y;
			y = r;
		}
	}

	m = c*d/r;
	ans += (b/m) - (a-1)/m;

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


	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int> v(3);
    for(int i=0;i<3;i++){
        cin>>v.at(i);
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    cout<<10*v.at(0)+v.at(1)+v.at(2)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;

int main()
{
    int N;
    std::string A, B, C;
    std::cin >> N >> A >> B >> C;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        char a = A.at(i);
        char b = B.at(i);
        char c = C.at(i);
        if (a == b and b == c) {
            continue;
        } else if (a == b or b == c or c == a) {
            ans++;
        } else {
            ans += 2;
        }
    }
    std::cout << ans << std::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 REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    int n, m;
    cin >> n >> m;
    vector<int> s;
    vector<char> c(m);
    bool ok = true;
    rep(i, m){
        int t;
        cin >> t >> c[i];
        rep(j, s.size()){
            if(s[j] == t-1 && c[j] != c[i]){
                ok = false;
            }
        }
        if(n != 1 && t == 1 && c[i] == '0'){
            ok = false;
        }
        s.push_back(--t);
    }
    string ans(n, '0');
    if(n != 1)
        ans[0] = '1';

    rep(i, m){
        ans[s[i]] = c[i];
    }
    if(ok)
        cout << ans << endl;
    else
        cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, s, t);
    int ans = 0;
    For(i, s.size()){
        if(s[i] != t[i]) ans ++;
    }
    Cout(ans);
}







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

int main(int argc, char **argv)
{
    int N, M;
    std::cin >> N >> M;
/*
    int b = N/2;
    int e = b + 1;
    
    for(int i = 0; i < M; i++){
        std::cout << (b%N)+1 << " " << (e%N)+1 << std::endl;
        b -= 1;
        e += 1;
        if((N % 2 == 0) && ((e - b) == (N / 2))){
            e += 1;
        }
    }
*/
    std::vector<std::pair<int,int>> ans;
    if(N%2){
        for(int l = 1, r = N-1; l < r; l++, r--){
            ans.emplace_back(l, r);
        }
    }else{
        bool flag = false;
        for(int l = 1, r = N-1; l < r; l++, r--){
            if(!flag && r-l <= N/2){
                --r;
                flag = true;
            }
            ans.emplace_back(l, r);
        }
    }
    for(int i = 0; i < M; i++){
        std::cout << ans.at(i).first << " " << ans.at(i).second << std::endl;
    }
    return 0;
    
}


Measured memory_bytes: 4300
#include<bits/stdc++.h>
 
#define hell                         1000000007
#define hell2                        998244353
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define all(v)                       v.begin(),v.end()
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(ll i=a;i<b;i++)
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'
 
const ll MAX=100005;
const ll SQN=330;
const ll LG=22;
const double PI=atan(1)*4;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    ll n,k;
    cin >> n >> k;
    ll sms=0,sme=0;
    rep(i,0,k) sms+=i;
    for(ll i=n-k+1;i<=n;i++) sme+=i;
    ll ans=(sme-sms+1+hell)%hell;
	ll l=k;
	ll r=n-k;
	// ret(ans);
	for(ll i=k;i<=n;i++) {
		sms+=l;
		sme+=r;
		// cout << sms << " " << sme << endl;
		ans=(ans+(sme-sms+1+hell)%hell)%hell;
		l++;
		r--;
		// cout << ans << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
inline ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p & 1)
            res = ((res % m) * (x % m)) % m;
        x = ((x % m) * (x % m)) % m;
        p >>= 1;
    }
    return res % m;
}
long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}
int gcd (int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
int lcm(int a, int b){
    return a / gcd(a, b) * b;
}

const int N = 2e3 * 2e3 + 5;
vector<int> a[20];
int n, d;
bool calc(int f, int s){
    ll sum = 0;
    for(int i = 0; i < d; ++i){
        ll part = a[f][i] - a[s][i];
        sum += (part * part);
    }
    ll sq = sqrtl((long double)sum);
    return sq * sq == sum;
}
int main() {
    ll l = D(), r = D();
    r = min(l + 2022, r);
    ll mn = INT_MAX;
    for(ll i = l; i <= r; ++i){
        for(ll j = i + 1; j <= r; ++j){
            mn = min(mn, (i * j) % 2019);
        }
    }
    printf("%lld", mn);
}


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

using namespace std;

#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define FOD(i, s, t) for (int i = s; i >= t; i--)

#define LL long long
#define mp make_pair
#define pb push_back
#define K 300001

int n;
int nxt[K];

int q[K], head, vis[K];
LL k;

LL ret;

void DFS(int u) {
	if (!vis[u]) {
		vis[u] = 1;
		head++; q[head] = u;
		
		DFS(nxt[u]);	
	} else {
		int tail = 1;
		
		while (q[tail] != u) tail++;
		
		int le = tail - 1;
		
	//	cout << k << " " << le << endl;
		
		if (k <= le) {
			ret = q[k + 1];	
		} else {
			int cyc = head - tail + 1;
			
			k -= le;
			k %= cyc;		
			
		//	cout << k << endl;
			
			ret = q[k + tail];
		}
	}
}

int main() {
	scanf("%d%lld", &n, &k);
	
	FOE(i, 1, n) scanf("%d", &nxt[i]);
	
	DFS(1);
	
	cout << ret << endl;
}

Measured memory_bytes: 5940
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int main(){
	ios::sync_with_stdio(false);
	map<int, int> mapNums;
	vector<int> arrNums;
	register int i;
	int n, nCount=0;
	cin >> n;
	for (i = 1; i <= n; ++i){
		int x;
		cin >> x;
		if (mapNums[x] == 0)
			arrNums.push_back(x);
		++mapNums[x];
	}
	for (i = 0; i < arrNums.size(); ++i){
		if (mapNums[arrNums[i]] >= arrNums[i])
			nCount += mapNums[arrNums[i]] - arrNums[i]; 
		else 
			nCount += mapNums[arrNums[i]];
	}
	cout << nCount << endl;
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 5112
/**
 * Created by kyle on 2014/12/26.
 */
public class Main {

    private static final int HOUR = 60 * 60;
    private static final int MINUTE = 60;

    public static void main(String[] args) {
        final String line = readLine();
        System.out.println(calc(line));
    }

    protected static String calc(String input) {
        int remains = Integer.parseInt(input);

        int hours = remains / HOUR;
        remains = remains % HOUR;

        int minutes = remains / MINUTE;
        remains = remains % MINUTE;

        int secs = remains;

        return hours + ":" + minutes + ":" + secs;
    }

    private static String readLine() {
        java.util.Scanner s = null;
        try {
            s = new java.util.Scanner(System.in);
            return s.nextLine();
        } finally {
            if (s != null) {
                s.close();
            }
        }
    }
}

Measured memory_bytes: 17324
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int a,b,h;

int main()
{
    cin >> a >> b >> h;
    cout << (a + b) * h / 2;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int S = 0;
		if(A * B >= C * D){
			S = A * B;
		}else if(A * B < C * D){
			S = C * D;
		}
		System.out.print(S);
	}
}

Measured memory_bytes: 21972
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
long long q,a,b,ans;
int main()
{
	scanf("%lld",&q);
	for(int i=1;i<=q;i++)
	{
		scanf("%lld%lld",&a,&b);
		if(a>b)swap(a,b);
		if(a==b||a==b-1)
			ans=2*(a-1);
		else
		{
			long long c=sqrt(a*b);
			if(c*c==a*b)c--;
			if(c*(c+1)<a*b)
				ans=2*c-1;
			else
				ans=2*c-2;
		}
		printf("%lld\n",ans);
	}
}


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

using namespace std;

int main()
{
	int n;

	scanf("%d", &n);

	while (n--){
		string train;
		set<string> s;

		cin >> train;

		int len = train.size();

		for (int i = 1; i < len; i++){
			string right_train = train.substr(i);
			string left_train = train.substr(0, i);

			string rev_right = train.substr(i);
			string rev_left = train.substr(0, i);
			
			reverse(rev_right.begin(), rev_right.end());
			reverse(rev_left.begin(), rev_left.end());

			s.insert(left_train + right_train);
			s.insert(right_train + left_train);
			s.insert(rev_left + right_train);
			s.insert(right_train + rev_left);
			s.insert(left_train + rev_right);
			s.insert(rev_right + left_train);
			s.insert(rev_left + rev_right);
			s.insert(rev_right + rev_left);
		}

		cout << s.size() << endl;
	}

	return (0);
}

Measured memory_bytes: 1316
n = gets.to_i
vs = gets.split.map(&:to_i)
evens = {}
odds  = {}
vs.map.with_index { |e, i|
  if i.even?
    if evens[e].nil?
      evens[e] = 1
    else
      evens[e] += 1
    end
  else # i.odd?
    if odds[e].nil?
      odds[e] = 1
    else
      odds[e] += 1
    end
  end
}

# {key => value} は {値 => 出現回数}。keyが値でvalueが出現回数。

# 偶数列と奇数列で、最頻値が衝突していないかのチェック
evens_top, evens_second = evens.max_by(2) { |key, value| value }
odds_top, odds_second   =  odds.max_by(2) { |key, value| value }
if evens_top[0] == odds_top[0]
  # 衝突している場合には2番目に頻度が高いものの出現回数を比較
  if evens_second.nil? && odds_second.nil?
    # どちらも2番目が存在していない場合
    evens_value = evens_top[0]
    odds_value = evens_value + 1
  elsif odds_second.nil? || evens_second[1] >= odds_second[1]
    evens_value = evens_second[0]
    odds_value = odds_top[0]
  else #evens_second[1] < odds_second[1]
    evens_value = evens_top[0]
    odds_value = odds_second[0]
  end
else
  # 衝突していない場合にはそれぞれの最頻値の値を採用
  evens_value = evens_top[0]
  odds_value = odds_top[0]
end

rewrite_count = 0
evens.each do |key, value|
  unless evens_value == key
    rewrite_count += value
  end
end
odds.each do |key, value|
  unless odds_value == key
    rewrite_count += value
  end
end
puts rewrite_count


Measured memory_bytes: 17932
n = int(input())
xu = [list(input().split()) for _ in range(n)]
btc = 380000.0
ans = float(0)

for i in range(n):
    count = 0
    if xu[i][1] == 'JPY':
        ans += int(xu[i][0])
    else:
        ans += btc * float(xu[i][0])

print('{:.7f}'.format(ans))

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

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

  int h[n];
  rep (i, n) cin >> h[i];

  int count = 0;
  rep (i, n) {
    if (h[i] >= k) count++;
  }
  cout << count << endl;

  return 0;
}

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

const int M = 1e9+7, maxn = 1e5+5;
void madd(int& a, int b) {
    a += b;
    if (a >= M) a -= M;
}
int mult(int a, int b) {
    return (1LL*a*b) % M;
}
int modexp(int a, int b) {
    int res = 1;
    while (b) {
        if (b&1) res = mult(res,a);
        a = mult(a,a);
        b >>= 1;
    }
    return res;
}
int inverse(int x) {
    return modexp(x,M-2);
}
int fac[2*maxn], ifac[2*maxn];
int H, W, A, B;

int calc(int a, int b, int c, int d) {
    int n = c-a;
    int m = d-b;
    int res = fac[n+m];
    res = mult(res,ifac[n]);
    res = mult(res,ifac[m]);
    return res;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    fac[0] = ifac[0] = 1;
    for (int i = 1; i < 2*maxn; i++) {
        fac[i] = mult(i,fac[i-1]);
        ifac[i] = inverse(fac[i]);
    }
    cin >> H >> W >> A >> B;
    int i = H-A-1;
    int j = B;
    int ans = 0;
    while (i >= 0 && j < W) {
        madd(ans,mult(calc(0,0,i,j),calc(i,j,H-1,W-1)));
        i--; j++;
    }
    cout << ans << '\n';
}



Measured memory_bytes: 1792
import java.util.*;

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();
        sc.close();
        if (K == 1) {
            System.out.println(S.substring(K-1, K).toLowerCase() + S.substring(K));
        } else if (K == N) {
            System.out.println(S.substring(0, K-1) + S.substring(K-1, K).toLowerCase());
        } else {
            System.out.println(S.substring(0, K-1) + S.substring(K-1, K).toLowerCase() + S.substring(K, N));
        }
    }
}


Measured memory_bytes: 21716
def main():
    S = input()
    N = len(S)
    dp = [[1, 0] for _ in range(N)]
    for i in range(N-1):
        if S[i] == "R" and S[i+1] == "R":
            dp[i+1][0] += dp[i][1]
            dp[i+1][1] += dp[i][0]
            dp[i][0] = 0
            dp[i][1] = 0
    for i in range(N-1, 0, -1):
        if S[i] == "L" and S[i-1] == "L":
            dp[i-1][0] += dp[i][1]
            dp[i-1][1] += dp[i][0]
            dp[i][0] = 0
            dp[i][1] = 0
    ans = [0] * N
    for i in range(N-1):
        if S[i] == "R" and S[i+1] == "L":
            ans[i] = dp[i][0] + dp[i+1][1]
            ans[i+1] = dp[i+1][0] + dp[i][1]
    print(*ans)


if __name__ == "__main__":
    main()


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

const int MAX = 1000005;
int A[MAX];
int main() {
    int H, W, N, a;
    scanf("%d %d", &H, &W);
    scanf("%d", &N);
    int p = 0;
    for (int i = 1; i <= N; i++) {
        scanf("%d", &a);
        while (a) {
            A[p] = i;
            p++;
            a--;
        }
    }
    for (int i = 1; i <= H; i++) {
        if (i % 2 == 0) {
            reverse(A+(i-1)*W, A+i*W);
        }
    }

    for (int i = 0; i < H*W; i ++) {
        if (i % W != 0) printf(" ");
        printf("%d", A[i]);
        if ((i+1) % W == 0) printf("\n");
    }
    return 0;
}

Measured memory_bytes: 384
import Data.List

f::Int->Int->Int->[((Int,Int),Int)]
f (-1) _ _ =[]
f p h w=let y=p `div` w
            x=p `mod` w
            ts=sort $ [(y,x),(h-1-y,x),(y,w-1-x),(h-1-y,w-1-x)]
            c=length $ nub $ ts
        in (head ts,c):f (p-1) h w
g ::[Int]->[Int]
g []=[]
g (x:xs)
   |x>4 =4:(g ((x-4):xs))
   |x==3=1:2:(g xs)
   |otherwise=x:g xs

f2::[Int]->[Int]->[Int]
f2 [] ys=ys
f2 _ []=[]
f2 (x:xs) (y:ys)
   |x<y=f2 xs (y:ys)
   |x>y=y:(f2 (x:xs) ys)
   |x==y=f2 xs ys

f3::[Int]->[Int]->Bool
f3 [] _=True
f3 _ []=True
f3 xs ys
   |((nub xs)==[4]) && ((nub ys)==[2])&&((sum(xs))==(sum(ys)))=True
   |otherwise=False

main = do
       x<-getLine
       as<-getContents
       let xs=sort $ g $ map length $ group $ sort $ concat (lines as)
           (h:w:[])=map read (words x)::[Int]
           ys=sort $ map snd $ nub $ f (h*w-1) h w
           ys2=f2 xs ys
           xs2=f2 ys xs
       putStrLn $ if f3 xs2 ys2 then "Yes" else "No"

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

int main()
{
   ll x;cin>>x;
   ll ansi,ansj;
   for(int i=-1000;i<=1000;i++)
   {
       bool ok=false;
       for(int j=-1000;j<=1000;j++)
       {
           if(pow(i,5)-pow(j,5)==x)
           {
               ansi=i;ansj=j;
               ok=true;
               break;
               
           }
       }
       if(ok) break;
   }
   cout<<ansi<<" "<<ansj<<"\n";
   
}

Measured memory_bytes: 3980
from collections import deque
n = int(input())
A = deque(map(int, input().split()))
A.appendleft(0)
A.append(0)
ans = 0
for i in range(1, n+2):
    ans+=abs(A[i]-A[i-1])
for i in range(1, n+1):
    d = abs(A[i]-A[i-1])+abs(A[i+1]-A[i])
    print(ans-d+abs(A[i-1]-A[i+1]))


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

int main()
{
    string s;
    int flag = 0;
    cin >> s;
    
    for(int i = 0; i < s.size(); i++)
    {
        if(i % 2 == 0 && s.at(i) == 'L') flag++;
        if(i % 2 == 1 && s.at(i) == 'R') flag++;
    }

    cout << ((flag == 0) ? "Yes" : "No") << endl;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int frac[11];

int to_i(const vector<int> &v) {
  int n = v.size();
  vector<bool> used(n, false);
  int index = 0;
  REP(i,n) {
    for(int j=v[i]-1; j>=0; --j)
      if (!used[j])
        index += frac[n-i-1];
    used[v[i]] = true;
  }
  return index;
}

vector<int> to_p(int index, int n) {
  vector<bool> used(n, false);
  vector<int> perm(n);
  REP(i,n) {
    REP(j,n) {
      if(used[j]) continue;
      if(frac[n-i-1] <= index) index -= frac[n-i-1];
      else {
        perm[i] = j;
        used[j] = true;
        break;
      }
    }
  }
  return perm;
}

void out(const vector<int>& s) {
  for(int v:s)cout<<v<<' ';
  cout<<endl;
}

map<int, int> getm(const vector<int>& s) {
  int n = s.size();
  map<int,int> ms;
  queue<tuple<int,int>> qs;
  ms[to_i(s)] = 0;
  qs.push(make_tuple(0, to_i(s)));
  while(!qs.empty()) {
    int d, i;
    tie(d, i) = qs.front(); qs.pop();
    if (ms[i] < d) continue;
    if (d >= 4) break;
    auto v = to_p(i, n);
    REP(j,n+1) REP(k,j-1) {
      auto cp = v;
      reverse(begin(cp)+k,begin(cp)+j);
      int ni = to_i(cp);
      if (ms.find(ni) == end(ms) || ms[ni] > ms[i]) {
        ms[ni] = ms[i] + 1;
        qs.push(make_tuple(ms[ni], ni));
      }
    }
  }
  return ms;
}

int main() {
  frac[0] = 1;
  REP(i,10) frac[i+1] = frac[i] * (i+1);
  int n;
  cin>>n;
  vector<int> s(n), t(n);
  REP(i,n) {
    cin>>s[i];
    --s[i];
  }
  iota(begin(t),end(t),0);
  auto ms = getm(s);
  auto mt = getm(t);
  int mn = n-1;
  for(auto p:ms){
    int i,d;
    tie(i,d) = p;
    auto itr = mt.find(i);
    if(itr != end(mt)) {
      mn = min(mn, d + itr->second);
    }
  }
  cout << mn << endl;
  return 0;
}

Measured memory_bytes: 47436
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string.h>
#include<queue>
#include<map>
#define maxn 10005
#define mod 1000000007
#define INF 0x3f3f3f3f
#define PI 3.1415926
using namespace std;
typedef long long ll;

int main(){
    //freopen("Test.txt", "r", stdin);
	int n;
	scanf("%d", &n);
	if(n == 3 || n == 5 || n == 7){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
    return 0;
}

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

using namespace std;

int main (void){
    long long int H;
    long long int attack = 1;
    long long int enemy_num = 1;
    cin >> H;
    while(1){
        if( H == 1){
            break;
        }
        else{
            enemy_num = enemy_num * 2;
            H = H /2;
            attack += enemy_num;
        }
    }
    cout << attack;
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int m = h[0];
    bool f = true;
    for(int i = 0; i < n; i++){
        if(h[i] >= m){
            m = h[i];
        }else if(m - h[i] > 1){
            f = false;
            break;
        }
    }

    if(f){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

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

int check_digits(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int main() {
  int N;
  cin >> N;
  
  int ans = 0;
  for (int i = 0; i <= N; i++) {
    if (check_digits(i) % 2) ans++;
  }
  
  cout << ans << endl;
  
}
  
  

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

using namespace std;

int ord[5] = {0};
int result = 0;
int put_tail = 125;
int put_tail_index = -1;

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

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

    for(int i=0;i<5;i++)
    {
        if(ord[i] % 10 != 0)
        {
            if(ord[i] % 10 < put_tail)
            {
                put_tail = ord[i] % 10;
                put_tail_index = i;
            }
        }
    }

    if(put_tail == 125)
    {
        for(int i=0;i<5;i++)
        {
            result += ord[i];
        }
    }
    else
    {
        for(int i=0;i<5;i++)
        {
            if(i != put_tail_index)
            {
                result += ord[i];
                if(ord[i] % 10 != 0)
                {
                    result += 10 - (ord[i] % 10);
                }
            }
        }
        result += ord[put_tail_index];
    }

    cout << result;

    return 0;
}

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

int main() {
  int a[3][3];
  int b[3][3];
  string ans="No";
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
        int tmp;
        cin >> tmp;
        a[i][j]=tmp;
        b[i][j]=0;
    } 
  }
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
        if(a[i][j]==tmp) b[i][j]++;
    } 
    }
  }
  
  if(b[0][0]+b[1][0]+b[2][0]==3) ans="Yes";
  else if(b[1][0]+b[1][1]+b[1][2]==3)ans="Yes";
  else if(b[2][0]+b[2][1]+b[2][2]==3)ans="Yes";
  else if(b[0][0]+b[1][0]+b[2][0]==3)ans="Yes";
  else if(b[0][1]+b[1][1]+b[2][1]==3)ans="Yes";
  else if(b[0][2]+b[1][2]+b[2][2]==3)ans="Yes";
  else if(b[0][0]+b[1][1]+b[2][2]==3)ans="Yes";
  else if(b[0][2]+b[1][1]+b[2][0]==3)ans="Yes";
  

  cout << ans << endl; 
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        String a = in.next();
        String b = in.next();
        String c = in.next();
        if(a.charAt(a.length() - 1) == b.charAt(0) && b.charAt(b.length() - 1) == c.charAt(0)){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 21972
import collections
N = int(input())
S = [input() for _ in range(N)]
C = collections.Counter(S)
now = -1
ans = []
for v, i in C.most_common():
    if now == -1:
        now = i
    if now != i:
        break
    ans += [v]
print(*sorted(ans), sep='\n')


Measured memory_bytes: 45040
#!/usr/bin/env ruby

K = 64
#K = 4

def g(n)
  b = []
  (1..K).to_a.reverse.each do |i|
    (d, m) = n.divmod(1 << i)
    b.push({:i => i, :b => 1 << i, :d => d, :m => m})
  end
  return b.reverse
end

def main(argv)
  (a, b) = gets.chomp.split(' ').map(&:to_i)
  
  v = g(a)
  u = g(b)
  
  t = [0] * K
  K.times do |i|
    x = 0
    if v[i][:m] >= (v[i][:b] / 2) then
      x = v[i][:b] - v[i][:m]
    else
      if (b - a) < v[i][:b] then
        x = 0
      else
        x = v[i][:b] / 2
      end
    end
    
    y = 0
    if u[i][:m] >= (u[i][:b] / 2) then
      y = u[i][:m] - (u[i][:b] / 2) + 1
    end
    
    t[i] = (x + y) % 2
  end
  t[0] = (t[0] + [u[0][:d] - v[0][:d] - 1, 0].max) % 2
  
  puts t.reverse.join('').to_i(2).to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

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

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
    for ( int i = 0; i < N; i++ ) {
        for ( int j = N - 1; j >= i + 1; j-- ) {
            if ( A[j].value < A[j - 1].value ) {
                Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N) {
    for ( int i = 0; i < N; i++ ) {
        int minj = i; 
        for ( int j = i; j < N; j++ ) {
            if ( A[j].value < A[minj].value ) minj = j;
        }
        Card t = A[i]; A[i] = A[minj]; A[minj] = t;
    }
}

void print(struct Card A[], int N) {
    for ( int i = 0; i < N; i++ ) {
        if ( i > 0 ) cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

// 比较冒泡排序和选择排序的结果
bool isStable(struct Card C1[], struct Card C2[], int N) {
    for ( int i = 0; i < N; i++ ) {
        if ( C1[i].suit != C2[i].suit ) return false;
    }
    return true;
}

int main() {
    Card C1[100], C2[100];
    int N;
    char ch;
    
    cin >> N;
    for (int i = 0; i < N; i++ ) {
        cin >> C1[i].suit >> C1[i].value;
    }
    
    for ( int i = 0; i < N; i++ ) C2[i] = C1[i];
    
    bubble(C1, N);
    selection(C2, N);
    
    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if ( isStable(C1, C2, N) ) {
        cout << "Stable" << endl;
    } else {
        cout << "Not stable" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	ll x, y;
	cin >> x >> y;
	
	if (x <= 1 && y <= 1) {
		cout << "Brown" << endl;
		return 0;
	}

	// |x - y| <= 1となるならBrownのかち

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


Measured memory_bytes: 256
-- Try AtCoder
-- author: Leonardone @ NEETSDKASU
 
main = getLine >>= putStrLn . solve

solve str = ans where
    f (n, s, e, w) c =
        case c of
        'N' -> (n + 1, s, e, w)
        'S' -> (n, s + 1, e, w)
        'E' -> (n, s, e + 1, w)
        _   -> (n, s, e, w + 1)
    (n, s, e, w) = foldl f (0, 0, 0, 0) str
    ok x y = (x > 0 && y > 0) || (x == 0 && y == 0)
    ans = if (ok n s) && (ok e w) then "Yes" else "No"

Measured memory_bytes: 636
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	typedef long long int ll;
	ll N,M;
	cin>>N>>M;
	vector<pair<ll,vector<ll> > >v(N+1);
	for(ll i=1;i<=N;i++){
		ll h;
		cin>>h;
		v[i].first=h;
	}
	for(ll i=0;i<M;i++){
		ll a,b;
		cin>>a>>b;
		v[a].second.push_back(b);
		v[b].second.push_back(a);
	}
	ll cont=0;
	for(ll i=1;i<=N;i++){
		bool a=false;
		ll j=0;
		while(a==false && j<v[i].second.size()){
			if(v[i].first<=v[v[i].second[j]].first){
				a=true;
			}
			else{
				j++;
			}
		}
		if(a==false){
			cont++;
		}
	}
	cout<<cont;
}

Measured memory_bytes: 9676
N,M,K = map(int,input().rstrip().split(" "))
A = list(map(int,input().rstrip().split(" ")))
B = list(map(int,input().rstrip().split(" ")))
A.append(10 ** 10)
B.append(10 ** 10)
Ai = 0
ans = 0
karians = 0
Aii = 0
Bii = 0
for i in range(N + 1):
    Ai += A[i]
    if Ai > K:
        Ai -= A[i]
        karians = i
        Aii = i
        ans = i
        break
for i in range(Aii + 1):
    while Ai <= K:
        Ai += B[Bii]
        karians += 1
        Bii += 1
    karians -= 1
    Bii -= 1
    Ai -= B[Bii]
    if karians > ans:
        ans = karians
    Ai -= A[Aii - 1 - i]
    karians -= 1
print(ans)

Measured memory_bytes: 40760
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str;
            str = Console.ReadLine ().Split (' ');

            int N = int.Parse (str[0]);
            int K = int.Parse (str[1]);

            str = Console.ReadLine ().Split (' ');

            int[] A = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = int.Parse (str[i]);
            }

            Array.Sort (A);

            int ans = 0;

            for (int i = 0; i < K; i++) ans += A[i];

            Console.WriteLine (ans);
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 27888
#include <bits/stdc++.h>
#define int long long
using namespace std;

template<typename T>
class SparseTable{
public:
  int LOG;
  int N, option; // option : 0 -> min, 1 -> max, 2 -> gcd
  vector<vector<T> > Array;
  vector<int> Memo, Log;
  int ok = 0;
  
  SparseTable(){}
  SparseTable(vector<T> val, int option = 0): 
    N(val.size()), option(option), Memo(N+1), Log(N+1){
    LOG = 0;
    while(N >= (1<<LOG)) LOG++;
    Array = vector<vector<T> >(LOG,vector<T>(N));
    Array[0] = val;
    
    vector<int> num(LOG);
    for(int i=0;i<LOG;i++){
      int x = 1<<i;
      if( x <= N ) Log[x] = i;
      num[i] = x;
    }
    for(int i=1;i<=N;i++) Memo[i] = *lower_bound(num.begin(), num.end(), ( i + 1 ) >> 1);
    build();
  }
  
  void update(int k, T val){assert(0<=k && k < N); ok = 0; Array[0][k] = val; }
  
  inline T merge(const T &A,const T &B){
    if( option == 0 ) return min( A, B );
    if( option == 1 ) return max( A, B );
    if( option == 2 ) return __gcd( A, B );
    assert(0);
  }
  
  void build(){
    ok = 1;
    for(int i=1;i<LOG;i++){
      int len = 1<<i;
      for(int j=0;j<N;j++){
        if( N <= j + len - 1 ) continue;
        Array[i][j] = merge( Array[i-1][j], Array[i-1][j+len/2] );
      }
    }
  }
  
  // [ l, r )の [optionを満たす値] を返す ( 0 origin )
  T get(int l, int r){
    assert(ok);
    assert(l < r && 0 <= l && r <= N);
    int k = Memo[r-l];
    return merge( Array[Log[k]][l], Array[Log[k]][r-k] );
  }
};


signed main(){
  
  int n;
  cin>>n;
  
  vector<int> a(n);
  
  for(int i=0;i<n;i++) cin>>a[i];
  
  SparseTable<int> st( a, 2 );
  
  st.build();
  
  int ans = 0;
  
  for(int i=0;i<n;i++){
    
    if( i != 0 && i != n - 1 ){
      
      ans = max( ans, __gcd( st.get( 0, i ), st.get( i + 1, n ) ) );
      
    }
    else if( i == 0 ){
      
      ans = max( ans, st.get( i + 1, n ) );
      
    }
    else if( i == n - 1 ){
      
      ans = max( ans, st.get( 0, i ) );
      
    }
    
  }
  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 17536
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define ll long long
#define INF 2000000000
#define INF2 2000000000000000000
 
using namespace std;

int main() {
    
    IOS;
    string s;
    cin >> s;
    if(s.back() == 's')
    	s += "es";
    else
    	s += "s";
    cout << s;

}

Measured memory_bytes: 3660
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
	int a[10],i;
	for(i=0;i<10;i++){
		cin>>a[i];
	}
	sort(a,a+10,greater<int>());
	for(i=0;i<3;i++){
	cout<<a[i]<<endl;
	}
}

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

struct UF{
 int N;
 vector<int> V;
 void init(int n){
  N=n; V.resize(N);
  rep(i,N) V[i] = i;
 }
 int root(int a){
  if(V[a]==a) return a;
  return V[a] = root(V[a]);
 }
 void unite(int r,int s){
  V[root(s)] = root(r);
 }
};

int main(){
 int N,M; scanf("%d%d",&N,&M);
 UF G; G.init(N);
 rep(i,M){
  int u,v; scanf("%d%d",&u,&v); u--; v--;
  G.unite(u,v);
 }
 int C[200000] = {};
 rep(i,N) C[G.root(i)]++;
 int ans=0;
 rep(i,N) ans = max(ans,C[i]);
 printf("%d\n",ans);
 return 0;
}

Measured memory_bytes: 5680
/* ex 7_1
   person_A */

#include <stdio.h>
#include <string.h>

//頂点を表す構造体point
typedef struct point{
    int x_elem;
    int y_elem;
}point;

//頂点pre_pointをx軸にx_diff,y軸にy_diffだけ移動した頂点を返す
point shift_point(point pre_point,int x_diff,int y_diff){
    pre_point.x_elem+=x_diff;
    pre_point.y_elem+=y_diff;
    return pre_point;
}


int main(void){
    //point型4頂点の宣言と頂点1,2の入力
    point angle1,angle2,angle3,angle4;
    scanf("%d %d %d %d",&angle1.x_elem,&angle1.y_elem,&angle2.x_elem,&angle2.y_elem);
    //頂点1,2の位置から頂点3,4の位置を計算し、代入
    angle3=shift_point(angle2,angle1.y_elem-angle2.y_elem,angle2.x_elem-angle1.x_elem);
    angle4=shift_point(angle3,angle2.y_elem-angle3.y_elem,angle3.x_elem-angle2.x_elem);
    //頂点3,4の出力
    printf("%d %d %d %d\n",angle3.x_elem,angle3.y_elem,angle4.x_elem,angle4.y_elem);

    return 0;
}

Measured memory_bytes: 1720
#include<iostream>
#include<set>
#include<string>
using namespace std;
int main(){
  set<string>st;
  int n;
  cin>>n;
  string a;
  for(int i=0;i<n;i++){
    cin>>a;
    st.insert(a);
  }
  cout<<st.size()<<endl;
  return 0;
}


Measured memory_bytes: 19236
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1e9
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int n; cin >> n;
    int h[22];
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    int mx = h[0];
    int ans = 1;
    for(int i = 1; i < n; i++){
        if(mx <= h[i]){
            ans++;
            mx = h[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256