akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> v(N);
  for (int& x : v) cin >> x;
  const int n = min(N, K);
  int ans = -2e9;
  for (int a = 0; a <= n; a++) {
    for (int b = 0; a + b <= n; b++) {
      const int c = K - a - b;
      vector<int> t;
      for (int i = 0; i < a; i++) t.push_back(v[i]);
      for (int i = 0; i < b; i++) t.push_back(v[N - i - 1]);
      sort(t.begin(), t.end());
      int s = 0;
      for (int& x : t) s += x;
      for (int i = 0; i < c && i < t.size() && t[i] < 0; i++) s -= t[i];
      ans = max(ans, s);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
 #include <math.h>
 #include <string>
using namespace std;

int main() {
	
	int n;
	char c;
	int a[4];
	a[1]=0;
	a[0]=0;
	a[2]=0;
	a[3]=0;
	string s;
while(cin>>n>>c>>s){
	if(s=="A"){
		a[0]=a[0]+1;
	}
	if(s=="B"){
		a[1]=a[1]+1;
	}
	if(s=="AB"){
		a[2]=a[2]+1;
	}
	if(s=="O"){
		a[3]=a[3]+1;
	}
}
cout<<a[0]<<endl<<a[1]<<endl<<a[2]<<endl<<a[3]<<endl;

	return 0;
}

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

static ll m = 1e9+7;

int main() {

    ll N;
    cin >> N;

    vl A(N);
    rep(i, N) cin >> A[i];

    ll k = 1;
    ll ans = 0;
    rep(i, N) {
        if (A[i] == k) {
            k++;
            ans++;
        }
    }

    if (ans == 0) {
        cout << -1 << endl;
    }
    else {
        cout << N- ans << endl;
    }

    return 0;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) {
        int tmp;
        cin >> tmp;
        tmp--;
        a[tmp] = i;
    }
    int ans = 1;
    int tmp2 = 1;

    REP(i, n-1) {
        if(a[i+1] > a[i]) tmp2++;
        else {
            ans = max(tmp2, ans);
            tmp2 = 1;
        }
    }
    ans = max(tmp2, ans);
    cout << n - ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
const long double eps = 1e-12;
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2
#define REP(a,b) for(long long a = 0;a < b;++a)
long long solve(long long based, long long kazu,long long bader,long long border) {
	long long now_cookie = 1;
	REP(i, bader) {
		if(based != 1)
		if (now_cookie > border / (based-1LL)) {
			return true;
		}
		now_cookie *= based - 1LL;
	}
	REP(i, kazu - bader) {
		if (now_cookie > border / (based)) {
			return true;
		}
		now_cookie *= based;
	}
	if (now_cookie >= border) return true;
	return false;
}
int main() {
	long long n, a;
	cin >> n >> a;
	long long ans = n;
	for (long long use_cookie = 1; use_cookie < 40; ++use_cookie) {
		long long bot = 1e18;
		long long top = 0;
		while (abs(top - bot) > 1) {
			long long mid = (top + bot) / 2;
			if (solve(mid, use_cookie + 1, 0, n) == true) {
				bot = mid;
			}
			else top = mid;
		}
		for (long long q = 0; q <= use_cookie; ++q) {
			if (solve(bot, use_cookie + 1, q, n) == 0) break;
			ans = min(ans, bot * (use_cookie+1LL) + use_cookie * a - q);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

map<char,int> c = {
  {'M',0},
  {'A',1},
  {'R',2},
  {'C',3},
  {'H',4},
};
int main() {
  int n;
  cin >> n;
  vector<ll> m(5);
  rep(i,n){
    string s;
    cin >> s;
    if(c.count(s[0])==0) continue;
    m[c[s[0]]]++;
  }
  ll ans = 0;
  rep(i,5)rep(j,5)rep(k,5){
    if(i<j&&j<k) ans += m[i]*m[j]*m[k];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def sumDigit(x):
	total = 0
	while x > 0:
		total += x % 10
		x = x // 10

	return total

N = int(input())
ans = []

for a in range(1, N):
	sum_A = sumDigit(a)
	sum_B = sumDigit(N - a)
	ans.append(sum_A + sum_B)

print(min(ans))

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

#define zero(a) memset(a,0,sizeof(a))
#define inff(a,n) fill(a,a+n+1,inf)
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define write(x) printf("%d\n",x)
int main(void)
{
	//freopen("C:\\Users\\YuXiaoKang\\Desktop\\test.txt","r",stdin);
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[0]+a[1]==a[2])
    {
        cout <<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main (void){

    int n;
    int t[101];
    int m;
    int p[101];
    int x[101];
    int sum = 0;
    int i;

    scanf("%d" ,&n);

    for( i = 0; i < n; i++) {

        scanf("%d" ,&t[i]);
        sum = sum + t[i];
    }

    scanf("%d" ,&m);

    for( i = 0; i < m; i++) {
        
        scanf("%d %d" ,&p[i] ,&x[i]);
    }

    for( i = 0; i < m; i++) {
        
        printf("%d\n" ,sum - t[p[i] - 1] + x[i]);
    }
    
    return 0;
    
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,h,w;
char e;
int main(){
    cin>>e;
    if(e=='A')cout<<"T"<<endl;
    if(e=='T')cout<<"A"<<endl;
    if(e=='C')cout<<"G"<<endl;
    if(e=='G')cout<<"C"<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <regex>

using namespace std;
using ll = long long int;
const ll MOD = 1e9 + 7;

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

	vector<int> N(s.size(), 0);
	for (int i = 0; i < s.size(); i++) {
		N[i] = s[i] - '0';
	}

	vector<int> pre(2019, 0);
	vector<int> next(2019, 0);

	ll sum = 0;
	for (int i = 0; i < N.size(); i++) {
		for (int j = 0; j < 2019; j++) {
			next[(j * 10 + N[i]) % 2019] += pre[j];
		}
		next[N[i]] += 1;

		sum += next[0];
		swap(next, pre);
		for (int j = 0; j < 2019; j++) {
			next[j] = 0;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 4284
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;
#define rep(i,s,n)for(int i=s;i<n;i++)
typedef long long ll;

int main() {
	string s; cin >> s;
	ll l = stoi(s.substr(0, 2));
	ll r = stoi(s.substr(2, 2));
	bool a = false;
	bool b = false;

	if (l == 0 || l >= 13 && l <= 99) {
		a = true;
	}

	if (r == 0 || r >= 13 && r <= 99) {
		b = true;
	}

	if (a & b) {
		cout << "NA" << endl;
	}
	else if (!a & b) {
		cout << "MMYY" << endl;
	}
	else if (a & !b) {
		cout << "YYMM" << endl;
	}
	else if (!a & !b) {
		cout << "AMBIGUOUS" << endl;
	}
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i,n) cin >> h[i];
	int res=0;
	int max=0;
	rep(i,n){
		if(max<=h[i]){
			max = h[i];
			res++;
		}
	}

	cout << res << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>
#include <string>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#include <stack>

#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long
const int INF = 1 << 29;
const ll llINF = 10000000000000000;

const int MOD = 1000000007;

#define MAX_N 100100
typedef pair<int, int> P;
typedef pair<ll, ll> llP;

class UnionFindTree{
private:
    int par[MAX_N];
    int urank[MAX_N];
    int size[MAX_N];
public:
    int init(int n);
    int find(int x);
    int unite(int x, int y);
    int same(int x, int y);
    int parnum(int x){return par[x];}
    int ranknum(int x){return urank[x];}
    int sizenum(int x){return size[find(x)];}
};

int UnionFindTree::init(int n){
    REP(i, n){
        par[i] = i;
        urank[i] = 0;
        size[i] = 1;
    }
    return 0;
}

int UnionFindTree::find(int x){
    if(par[x] == x)return x;
    else return par[x] = find(par[x]);
}

int UnionFindTree::unite(int x, int y){
    x = find(x);
    y = find(y);
    
    if(x == y)return 0;
    if(urank[x] < urank[y]){
        par[x] = y;
        size[y] += size[x];
    }else{
        par[y] = x;
        size[x] += size[y];
        if(urank[x] == urank[y])urank[x] ++;
    }
    return 0;
}

int UnionFindTree::same(int x, int y){
    return find(x) == find(y);
}

int main(){
    int A, B;
    cin >> A >> B;
    if((A * B) % 2 == 0)printf("No\n");
    else printf("Yes\n");
}


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

using namespace std;
using namespace __gnu_pbds;

#define int long long

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void solve();

signed main()
{
    #ifdef _______
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
    #else
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    int _ = _ = _ = 1;
    for (_; _; --_)
        solve();
}

const int N = 2e6 + 13, mod = 1e9 + 7;

void solve()
{
    int n, d, ans=0;
    cin>>n>>d;
    for (int i=0;i<n;i++)
    {
        int x, y;
        cin>>x>>y;
        ans+=x*x+y*y<=d*d;
    }
    cout<<ans;
}

Measured memory_bytes: 3632
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   int countA=0,countB=0,i;
   cin>>s;
   for(i=0;i<s.length();i++)
   {
     if(s[i]=='A')countA++;
     else countB++;
   }
   if(countA==2||countB==2)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;

}



Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

int main() {

    int N, i;
    cin >> N >> i;

    cout << N - i + 1 << endl;

}

































Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int K; cin >> K;
  int A, B; cin >> A >> B;
  bool ok = false;
  for(int i = 1; i*K <= B; i++){
    if(A<=i*K&&i*K<=B){
      ok = true;
    }
  }
  if(ok){
    cout << "OK" << endl;
  } else {
    cout << "NG" << endl;
  }
  return 0;
}


Measured memory_bytes: 3592
#include<stdio.h>

int main(void){
	int len[10],vel[2];
	int ans,i; int sum=0;
	double time,x;

	while(scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
		&len[0],&len[1],&len[2],&len[3],&len[4],&len[5],&len[6],
		&len[7],&len[8],&len[9],&vel[0],&vel[1])!=EOF){
			sum=0;
			for(i=0;i<10;i++) sum+=len[i];
	time=(double)sum/(vel[0]+vel[1]);
	x=(double)time*vel[0];

	for(i=0;i<10;i++){
		if(x>0 && x<(double)len[i]) ans=i+1;
		else if(x<0) break;
		else ans=i;
		x-=(double)len[i];
	};
	printf("%d\n", ans);
	};
	return (0);
	}

Measured memory_bytes: 596
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 9223372036854775807
#define MOD 998244353
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll> a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi>b.fi;
}
//----------------------------------------------------------------------
ll sum[200020];
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //-------------------------------
    ll n,k;cin>>n>>k;
    V<ll>a(n);
    for(ll i=0;i<n;i++)cin>>a[i];

    for(ll z=0;z<mmin(k,41);z++){
        me(sum,0,sizeof(sum));
        for(ll i=0;i<n;i++){
            sum[mmax(0,i-a[i])]++;
            if(mmin(n-1,i+a[i])+1<n)
            sum[mmin(n-1,i+a[i])+1]--;
        }
        for(ll i=1;i<n;i++){
            sum[i]+=sum[i-1];
        }
        for(ll i=0;i<n;i++)a[i]=sum[i];
    }
    for(ll i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
    //-------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------








































Measured memory_bytes: 6360
#include <stdio.h>
#include <string.h>

int main(){
    char letter[30];

    scanf("%c ",letter);

        if((letter[0]=='a') || (letter[0]=='b') || (letter[0]=='c') || (letter[0]=='d') || (letter[0]=='e') || (letter[0]=='f') ||(letter[0]=='g') || (letter[0]=='h') || (letter[0]=='i') || (letter[0]=='j') || (letter[0]=='k') || (letter[0]=='l') || (letter[0]=='m') || (letter[0]=='n') || (letter[0]=='o') || (letter[0]=='p') || (letter[0]=='q') || (letter[0]=='r') || (letter[0]=='s') ||(letter[0]=='t') ||(letter[0]=='u') || (letter[0]=='v') ||(letter[0]=='x') || (letter[0]=='z') ){
            printf("a\n");
        }else{
            printf("A\n");
        }





    return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int n,ans,sum;
  scanf("%d",&n);
  while(n != 0){
    ans = 0;
    sum = 1000-n;
    
    while(sum >= 500){
      sum -= 500;
      ans++;
    }
    while(sum >= 100){
      sum -= 100;
      ans++;
    }
    while(sum >= 50){
      sum -= 50;
      ans++;
    }
    while(sum >= 10){
      sum -= 10;
      ans++;
    }
    while(sum >= 5){
      sum-=5;
      ans++;
    }
    while(sum != 0){
      sum--;
      ans++;
    }
    cout << ans << endl;
    scanf("%d",&n);
  }
  return 0;
}

Measured memory_bytes: 3116
import math

def dnt(n):
    if n >= 0:
        return (-1) * (n // 2)
    else:
        return math.ceil((-1) * (n / 2))

N = int(input())
S = ""

if N == 0:
    print(0)

else:
    while N != 1:
        if N % 2 == 1:
            S = "1" + S
        else:
            S = "0" + S
        N = dnt(N)
    print("1"+S)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

ll n;
vector<vector<ll>> g, wf;
vector<ll> color;
 
bool dfs(int v, int c) {
    color[v] = c;
    rep(i, sz(g[v])) {
        if (color[g[v][i]] == c) return false;
        if ((color[g[v][i]] == 0) && (!dfs(g[v][i], -c))) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MAX / 2 - 1;
    cin >> n;
    wf.resize(n, vector<ll>(n, inf));
    rep(i, n) wf[i][i] = 0;
    g.resize(n);
    rep(i, n) {
        string s;
        cin >> s;
        rep(j, n) {
            if (s[j] == '1') {
                wf[i][j] = 1;
                g[i].push_back(j);
            }
        }
    }
    color.resize(n, 0);
    if (!dfs(0, 1)) {
        cout << -1 << endl;
        return 0;
    }
    rep(i, n) rep(j, n) rep(k, n) wf[j][k] = min(wf[j][k], wf[j][i] + wf[i][k]);
    ll ans = 0;
    rep(i, n) {
        rep(j, n) {
            if (wf[i][j] == inf) continue;
            ans = max(ans, wf[i][j]);
        }
    }
    cout << (ans + 1) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

int main()
{  fast
ll n,m;
cin>>n>>m;
if(abs(n-m)>1)
cout<<"Alice";
else
cout<<"Brown";
}


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

#define fi first
#define se second
#define sc scanf
#define pr printf
#define pb push_back
#define ll long long
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 100100;
const long long MX = sqrt(N);
const long long H = 17;
const long long MAGIC = 1000;
const long long mod = 1e9 + 7;

using namespace std;

int n;
int a[N];

bool f(int a, int b, int c)
{
        return (a <= b && b <= c || a >= b && b >= c);
}

void solve()
{
        int cnt = 0;
        cin >> n;
        for(int i = 1; i <= n; i++){
                cin >> a[i];
        }
        for(int i = 1; i <= n; i++){
                int co = 0;
                vector < int > v;
                for(int j = i; j <= n; j++){
                        if(!v.empty()){
                                if(v.back() < a[j]){
                                        co |= 1;
                                }
                                if(v.back() > a[j]){
                                        co |= 2;
                                }
                        }
                        v.pb(a[j]);
                        if(co == 3){
                                cnt++;
                                i = j - 1;
                                break;
                        }
                        if(j == n){
                                i = j;
                        }
                }
        }
        cout << cnt + 1 << endl;
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("landscape.in");
        //fout("landscape.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1000000000;

signed main() {
  ll N, K;
  cin >> N >> K;
  ll p[N];
  rep(i, N) {
    ll a;
    cin >> a;
    p[i] = a;
  }

  ll index = 0;
  ll max = 0;
  ll sum = 0;
  rep(i, N) {
    if (i == 0) {
      rep(k, K) {
        ll j = i + k;
        if (j >= N) {
          sum = 0;
          break;
        }
        sum += p[j];
      }
    } else {
      ll j = i + K - 1;
      if (j >= N) {
        sum = 0;
        break;
      }
      sum += p[j] - p[i - 1];
    }
    if (max < sum) {
      index = i;
      max = sum;
    }
  }

  double ans = 0.0;
  map<ll, double> m;

  ll summ[1001];
  ll before = 0;
  rep(i, 1001) {
    summ[i] = before + i;
    before = before + i;
  }

  debug(index);
  rep(k, K) {
    ll j = index + k;
    ll num = p[j];
    debug(num);
    if (m[num] == 0) {
      double s = summ[num];
      m[num] = s / double(num);
      ans += s / double(num);
    } else {
      ans += m[num];
    }
  }

  printf("%.9lf\n", ans);
  return 0;
}

Measured memory_bytes: 1920
#include "bits/stdc++.h"
using namespace std;

long long N, M;
int di[3] = { 1, 2, 3 }, dj[3] = { 1, -1, 0 };
vector<long long> INV;

void init() {
	INV.resize(N + 1);
	INV[1] = 1;
	for (int i = 2; i <= N; i++) {
		INV[i] = M - (INV[M % i] * (M / i)) % M;
	}
}

int main() {
	cin >> N >> M;
	N *= 3;
	init();
	static long long DP[6001][12001] = {};
	DP[0][N] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= N * 2; j++) {
			if (DP[i][j] == 0) continue;
			for (int k = 0; k < 3; k++) {
				int ni = i + di[k], nj = j + dj[k];
				if (0 <= ni && ni <= N && 0 <= nj && nj <= N * 2) {
					DP[ni][nj] += (DP[i][j] * INV[ni]) % M;
					DP[ni][nj] %= M;
				}
			}
		}
	}
	long long ANS = 0;
	for (int i = N; i <= N * 2; i++) {
		ANS += DP[N][i];
		ANS %= M;
	}
	for (int i = 1; i <= N; i++) {
		ANS *= i;
		ANS %= M;
	}
	cout << ANS << endl;
}

Measured memory_bytes: 560512
import copy
n = int(input())
A = input().split()
B = copy.deepcopy(A)
C = A[:]
for i in range(n):
    for j in range(n-1, i, -1):
        if int(B[j-1][1]) > int(B[j][1]):
            B[j-1], B[j] = B[j], B[j-1]
print(" ".join(B))
print("Stable")

_min = 0
for i in range(n):
    _min = i
    for j in range(i, n):
        if int(C[j][1]) < int(C[_min][1]):
            _min = j
    C[_min], C[i] = C[i], C[_min]
print(" ".join(C))
if B == C:
    print("Stable")
else:
    print("Not stable")


Measured memory_bytes: 6344
from collections import deque


def main():
    input()  # n
    friendliness = deque(sorted(int(x) for x in input().split()))
    edges = deque()
    popped = friendliness.pop()
    edges.append(popped)
    ans = 0
    while friendliness:
        ans += edges.popleft()
        popped = friendliness.pop()
        edges.append(popped)
        edges.append(popped)
    print(ans)


if __name__ == '__main__':
    main()


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

int N;
ll nt;
vector <pair <ll, ll> > res;

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

int main()
{
    ios_base::sync_with_stdio(0);

    cin >> N;
    nt = 0;
    for (int i = 0; i < N; i++)
    {
        int a, b;
        cin >> a >> b;
        if (a < b)
        {
            nt += b - a;
            res.push_back (make_pair (b, b));
        }
        else
        {
            res.push_back (make_pair (a, b));
        }
    }

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

    ll shi = 0;
    ll nwhole = 0;
    ll nbest = 1, dbest = 1;
    for (int i = 0; i < N; i++)
    {

        //cout << i << " " << nt << " " << res[i].first << " " << res[i].second << endl;
        if (res[i].first <= nt)
        {
            nt -= res[i].first;
            shi = max (shi, res[i].second);
            nwhole++;
            continue;
        }
        else
        {
            // (i * res[i] + nt) / N * res[i]
            ll nnum = res[i].first - nt;
            ll dnum = max (shi, res[i].second);
            ll g = gcd (nnum, dnum);
            nnum /= g;
            dnum /= g;

            if (nnum * dbest < dnum * nbest)
            {
                nbest = nnum;
                dbest = dnum;
            }
            //cout << nnum / g << " " << dnum / g << "\n";
            //return 0;
        }
    }

    // (nwhole + 1 - nbest/dbest) / N
    ll tnum = (nwhole + 1) * dbest - nbest;
    ll tden = N * dbest;
    ll g = gcd (tnum, tden);
    tnum /= g;
    tden /= g;

    cout << tnum << " " << tden << "\n";
    return 0;
}

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) (int)((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n, m;
	cin >> n >> m;
	int ans = n * (n-1) / 2 + m * (m-1) / 2;
	cout << ans << endl;
}


Measured memory_bytes: 256
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

n = k()
ss = [v() for i in range(n)]

c = Counter(ss)
a = list(c.most_common())
maxc = a[0][1]

Ans = []
for i in a:
    if i[1] == maxc:
        Ans.append(i)
    
Ans.sort()
for i in Ans:
    print(i[0])

Measured memory_bytes: 51096
import math
li1 = []
li2 = []
mod = [99, -1]
for i in range(5):
  n = int(input())
  li1.append(n)
  li2.append(math.ceil(n / 10) * 10)
  if n % 10 < mod[0] and n % 10 != 0:
    mod[0] = n % 10
    mod[1] = i
if mod[0] == 99:
  ans = 0
  for j in range(5):
    ans += li1[j]
else:
  li2[mod[1]] = li1[mod[1]]
  ans = 0
  for j in range(5):
    ans += li2[j]
print(ans)

Measured memory_bytes: 3064
main = do
  [n,x] <- map read . words <$> getLine
  l <- map read . words <$> getLine
  print (f 1 0 x l)

f :: Int -> Int -> Int -> [Int] -> Int
f ans sum x l
  | l == [] = ans
  | sum + head l <= x = f (ans + 1) (sum + head l) x (tail l)
  | otherwise = ans


Measured memory_bytes: 892
def mod_pow(x, n, MOD):
    if n == 0:
        return 1
    if n % 2 == 0:
        result = mod_pow(x * x, n // 2, MOD)
        return result % MOD
    else:
        result = x * mod_pow(x, n - 1, MOD)
        return result % MOD

from collections import Counter        

MOD = 998244353
N = int(input())
D = list(map(int, input().split()))
max_num = max(D)

count = Counter(D)
ans = 1

if D[0] != 0:
    print(0)
    exit()

if count[0] != 1:
    print(0)
    exit()

for i in range(max_num):

    ans *= mod_pow(count[i], count[i+1], MOD)
    ans %= MOD

print(ans)

Measured memory_bytes: 19936
def solve():
    N, K = map(int, input().split())
    A = [0]+list(map(int, input().split()))
    visited = [-1]*(N+1)
    visited[1] = 0
    now = 1
    for i in range(1,K+1):
        now = A[now]
        if visited[now]>=0:
            break
        visited[now] = i
    if i==K:
        ans = now
    else:
        num = (K-visited[now])%(i-visited[now])+visited[now]
        ans = visited.index(num)
    return ans
print(solve())


Measured memory_bytes: 32372
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<utility>
using namespace std;
int n,a[1000000+100],cnt1,cnt2;
int main()
{

    cin>>n;
    for (int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
sort(a+1,a+n+1);
reverse(a+1,a+n+1);
for (int i=1;i<=n;i++)
{
    if (i%2==1)cnt1+=a[i];
    else       cnt2+=a[i];
}
cout<<cnt1-cnt2<<endl;

return 0;
}


Measured memory_bytes: 256
"""取込"""
n, x = [int(i) for i in input().split(" ")]

"""問題"""
def f(a, b):
    # print("({0}, {1})".format(a, b))
    l = max(a, b)
    s = min(a, b)
    if s == 0:
        return -l
    else:
        return (l // s) * s * 2 + f(l % s, s)

d = n + f(n - x, x)

"""出力"""
print(d)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
  	int a,b,c;
  	int ans = 0;
  	cin >> a >> b >> c;
  	while(true){
      b = b - a;
      if(b >= 0) ans++;
      if(b == 0 || ans == c || b < 0) break;
    }
    cout << ans << endl;
}

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

#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod                     1000000007
#define eps                     1e-9
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define in(a,b)                 ( (b).find(a) != (b).end())
#define pb                      push_back
//#define fill(a,v)               memset(a, v, sizeof a)
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define mp                      make_pair
#define minin(a)                *min_element (all(a))
#define maxin(a)                *max_element(all(a))
#define asort(c)                sort(all(c))
#define dsort(c)                sort(all(c), greater<int>()) 
#define PI                      3.14159265358979323846
#define int                     long long
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  set<int>                    si;
typedef  map<int, int>              mii;
typedef  long double                 ld;

clock_t time_p=clock();
void timer()
{
    time_p=clock()-time_p;
    cerr<<"Execution Time: "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int32_t main()
{
  FIO

 
  int n,t;
  cin>>n>>t;
  int ans=10000000;
  int mx=ans;
  int c[n],tm[n];
  forn(i,n)
  {
    cin>>c[i]>>tm[i];
    if(tm[i]<=t)
    {
      ans=min(ans,c[i]);
    }
  }
  if(ans==mx)
  {
    cout<<"TLE";
  }
  else
    cout<<ans;
  timer();
  return 0;
}  

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

  private static final long INF = Long.MAX_VALUE / 4;

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    long N = scanner.nextLong();
    long[] time = new long[5];
    for (int i = 0; i < 5; i++) {
      time[i] = scanner.nextLong();
    }
    long minTime = INF;
    for (int i = 0; i < 5; i++) {
      if (time[i] < minTime) {
        minTime = time[i];
      }
    }
    long ex = (N - 1) / minTime;
    System.out.println(5L + ex);
  }

}


Measured memory_bytes: 25172
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main
{
    private static InputStream debugInput() {
        String s = "4\n" +
                "20 18 2 18";
        return new ByteArrayInputStream(s.getBytes());
    }

    private static InputStream stdin() {
        return System.in;
    }

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(stdin());
        int n = sc.nextInt();
        int[] xs = new int[n];
        for (int i = 0; i < n; i++) {
            xs[i] = sc.nextInt();
        }
        Arrays.sort(xs);

        boolean isA = true;
        int sumOfA = 0;
        int sumOfB = 0;
        for (int i = 0; i < n; i++) {
            int value = xs[n - i - 1];
            if (isA) {
                sumOfA += value;
            }
            else {
                sumOfB += value;
            }
            isA = !isA;
        }

        System.out.println(sumOfA - sumOfB);
   }
}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T Gcd(T a, T b){
    if( b==0 ) return a;
    return Gcd(b, a%b);
}

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

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    graph g(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--; b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    vector<int> c(n);
    int sum = 0;
    rep(i,n){
        cin >> c[i];
        sum += c[i];
    }
    sort(rall(c));
    int flag = 0;
    queue<int> que;
    vector<int> ans(n);
    que.push(0);
    while(!que.empty()){
        auto x = que.front();
        ans[x] = c[flag];
        flag++;
        que.pop();
        for(auto nx: g[x]){
            if(ans[nx]==0){
                que.push(nx);
            }
        }
    }
    cout << sum-c[0] << '\n';
    rep(i,n){
        cout << ans[i] << " ";
    }
    cout << '\n';
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
  //Nの入力
  int N;
  cin >> N;
  //A_nの入力
  int A[N];
  for(int i = 1; i<(N+1); i++){
    cin >> A[i];
  }
  //B_nの入力
  int B[N];
  for(int i = 1; i < (N + 1); i++){
    cin >> B[i];
  }
  //C_nの入力
  int C[N-1];
  for(int i = 1; i < N; i++){
    cin >> C[i];
  }
  
  //満足度
  int M = 0;
  for(int j = 1; j < (N+1); j++){
    //cout << M << endl;
    M = M + B[A[j]];
    //ボーナス
    if(A[j] == (A[j-1] + 1)){
      M = M + C[A[j-1]];
    }
  }
  
  //出力
  cout << M;
  return 0;
  
  /*
  // 整数の入力
    int a;
    cin >> a;
    // スペース区切りの整数の入力
    int b,c;
    cin >> b >> c;
    // 文字列の入力
    string s;
    cin >> s;
    // 出力
    cout << (a+b+c) << " " << s << endl;
    return 0;
    */
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <functional>
#include <queue>
#include <cmath>

using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rep1(i,n) for(int i=1;i<=(int)n;++i)

int N, K;

int Sum[200010];
map<int, int> counter;

int f(int a)
{
	return a % K;
}

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

	int ans = 0;

	rep1(i, N) {
		cin >> Sum[i];
		Sum[i] += Sum[i-1];
		Sum[i] %= K;
	}
	rep(i,N+1)Sum[i]=(Sum[i]-i+K*1001001001)%K;
 

	rep(i, N+1) {
		if (i - K >= 0) counter[Sum[i - K]]--;
		ans += counter[Sum[i]];
		counter[Sum[i]]++;
	}

	cout << ans << endl;
}


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

// limit
#define mod1 22439423LL
#define mod2 42342432LL
#define mod3 56454765LL
#define mod4 66867574LL
#define oo 1000000007LL
#define OO 1000000000000000007LL
#define maxN 17

// loop
#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define fdtoa(i, x, y, a) for(int i = (x); i >= (y); i -= a)
#define ftosqrt(i, x, y) for(int i = (x); i*i <= (y); ++i)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)
#define fdtoit(rit, var) for (__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); ++rit)

// debug
#define debug cout << "*" << endl;
#define bug1d(a, x, y) { cout << #a << ": "; fto(_, x, y) cout << a[_] << ' '; cout << endl; }
#define bug2d(a, x, y, u, v) { cout << #a << ": " << endl; fto(i, x, y) {fto(j, u, v) cout << a[i][j] << ' '; cout << endl;}; cout << endl;}
#define bug(a) cout << #a << " = " << a << endl;
#define bug2(a, b) cout << #a << " = " << a << "; "; cout << #b << " = " << b << endl;
#define bug3(a, b, c) cout << #a << " = " << a << "; "; cout << #b << " = " << b << "; "; cout << #c << " = " << c << endl;

// operation
#define mp make_pair
#define pb push_back
#define pf push_front
#define mt make_tuple

// structure
#define ii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define matrix vector<vi>
#define iii pair <ii, int>

// get value
#define FF first
#define SS second
#define get(x, a) get<(x)>(a)

// data type
#define ll long long
#define ull unsigned long long

// function
#define lb lower_bound
#define ub upper_bound

// const value
#define pi 3.14159265358979323846264338327950288419716939937510

using namespace std;

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T min(T a, T b, T c, T d) {
    return min(a, min(b, min(c, d)));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

template <class T>
T max(T a, T b, T c, T d) {
    return max(a, max(b, max(c, d)));
}

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

int main() {
//    #ifndef ONLINE_JUDGE
//        freopen("tmp.inp", "r", stdin);
//        freopen("tmp.out", "w", stdout);
//    #endif // ONLINE_JUDGE

    int n, m;
    scanf("%d%d", &n, &m);

    if  (n == 1) n += 13;
    if  (m == 1) m += 13;

    if (n == m) puts("Draw");
    else if (n < m) puts("Bob");
    else puts("Alice");

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    char c = getchar();
    cout << char(c+1) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 505
int h,w;
char g[1000][1000],A[1000][1000],B[1000][1000];
int main(){
    scanf("%d%d",&h,&w);
    for(int i=1;i<=h;++i)
        scanf("%s",g[i]+1);
    memset(A,'.',sizeof(A));
    memset(B,'.',sizeof(B));
    for(int i=1;i<=h;++i)
        for(int j=1;j<=w;++j)
            if(g[i][j]=='#')A[i][j]=B[i][j]='#';
    for(int i=1;i<=h;++i)
        for(int j=2;j<w;++j)
            (i&1)?A[i][j]='#':B[i][j]='#';
    for(int i=1;i<=h;++i)A[i][1]=B[i][w]='#';
    for(int i=1;i<=h;++i,puts(""))
        for(int j=1;j<=w;++j)
            putchar(A[i][j]);
    puts("");
    for(int i=1;i<=h;++i,puts(""))
        for(int j=1;j<=w;++j)
            putchar(B[i][j]);
    return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, n) cin >> a[i];

    rep(j,min(100,k)){
        vector<int> b(n, 0);
        for (int i = 0; i < n;i++){
            int l = max(0, i - a[i]);
            int r = min(n - 1, i + a[i]);
            b[l]++;
            if(r+1<n)
                b[r + 1]--;
        }
        for (int i = 1; i < n; i++)
            b[i] += b[i - 1];
        rep(i, n) a[i] = b[i];
    }
    rep(i, n) cout << a[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 5152
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi p(n), q(n);
    rep(i,n) cin >> p.at(i);
    rep(i,n) cin >> q.at(i);
    vi v(n);
    rep(i,n) v.at(i) = i+1;
    int64_t index = 0, pindex, qindex;
    do{
        bool pres = true;
        bool qres = true;
        rep(i,n){
            if(v.at(i) != p.at(i)) pres = false;
            if(v.at(i) != q.at(i)) qres = false;
        }
        if(pres) pindex = index;
        if(qres) qindex = index;
        index++;
        // rep(i,n) cout << v.at(i) << " ";
        // cout << endl;
    }while(next_permutation(v.begin(), v.end()));
    cout << abs(pindex - qindex) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;


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

  int N,T,A; cin >> N >> T >> A;
  int dif, res = 1;
  rep(i, N) {
    int H; cin >> H;
    int dif2 = abs(T*1000-H*6 - A*1000);
    if(i==0) dif = dif2;
    if(dif2 < dif) {
      dif = dif2;
      res = i+1;   // 1-origin
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
from sys import stdin
import math
import fractions

n, m = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]

cnt = 0
suma = sum(a)

for aa in a:
    if aa  >= suma / 4 / m:
        cnt += 1

if cnt >= m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 5332
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const long double INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

const int MAX=50;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<vector<ll>> cnt(MAX,vector<ll>(MAX,0));
    for (int i=0;i<N;++i){
        long double a; cin >> a;
        a+=1e-10;
        ll A=(ll)(1e9*a);
        int p=0,q=0;
        while(A%2==0) ++p,A/=2;
        while(A%5==0) ++q,A/=5;
        ++cnt[p][q];
    }
    ll ans=0;
    for (int i=0;i<MAX;++i){
        for (int j=0;j<MAX;++j){
            for (int k=0;k<MAX;++k){
                for (int l=0;l<MAX;++l){
                    if (i+k>=18&&j+l>=18){
                        if (i==k&&j==l) ans+=cnt[i][j]*(cnt[i][j]-1);
                        else ans+=cnt[i][j]*cnt[k][l];
                    }
                }
            }
        }
    }
    cout << ans/2 << '\n';
}

Measured memory_bytes: 3784