akhauriyash/Code-Regression huggingface dataset:
object Main extends App{
  import scala.io.StdIn.readLine;
    val compare : Array[Int] => String = (input: Array[Int]) => {
      //W, H, x, y, r
      val inside = List(
        input(2) - input(4) >= 0,
        input(2) + input(4) <= input(0),
        input(3) - input(4) >= 0,
        input(3) + input(4) <= input(1)
      )
      inside.foldLeft(true)((x,y) => x && y) match {
        case true => "Yes"
        case false => "No"
      }
    }
    val a = readLine().split(" ").map(_.toInt)
    println(compare(a))
}



Measured memory_bytes: 43884
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            int N = Integer.parseInt(br.readLine());
            int result = 0;
            for(int i=1; i<=N; i=i+2){
                int count = 0;
                
                for(int j=1; j<=i; j++){
                    if(i%j == 0){
                        count++;
                    }
                }
                
                if(count == 8){
                    result++;
                    //System.out.println(i);
                }
            }
            
            System.out.println(result);
            
        }catch(Exception e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 32776
h, w = map(int, input().split())
s = [[] for _ in range(h)]
resh, resw = 0, 0
for i in range(h):
    s[i] = input().split()
    if 'snuke' in s[i]:
        resh, resw = i + 1, s[i].index('snuke')

print(chr(65 + resw), resh, sep='')



Measured memory_bytes: 62152
#include<bits/stdc++.h>
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define GCD(a, b)       __gcd(a, b)
#define pi              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
using namespace std;

int main()
{

    LD l;
    cin>>l;

    l/=3;
    l=l*l*l;

    cout<<fixed<<setprecision(6)<<l;




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  pair<int, int> Ai[N];
  for (int i = 0; i < N; i++) cin >> Ai[i].first, Ai[i].second = i;
  sort(Ai, Ai + N);
  //   debugArray(Ai, N);
  int ans[N];
  for (int i = 0; i < N; i++) {
    ans[i] = Ai[i].second + 1;
  }
  for (int i = 0; i < N; i++) cout << ans[i] << (i == N - 1 ? '\n' : ' ');
  return 0;
}


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

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

ll kaizyou(ll N){
  ll num=1;
  for(ll i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

int main(){
  int N,M;
  cin >> N >> M;
  vector<int>p(M);
  vector<string>S(M);
  rep(i,M){
    cin >> p.at(i) >> S.at(i);
  }
  int ans=0;
  int pe=0;
  vector<int>cnt(N);
  vector<bool>b(N,false);
  rep(i,M){
    if(b.at(p.at(i)-1)){
      continue;
    }
    else{
      if(S.at(i)=="WA"){
        cnt.at(p.at(i)-1)+=1;
      }
      else{
        ans++;
        pe+=cnt.at(p.at(i)-1);
        b.at(p.at(i)-1)=true;
      }
    }
  }
  cout << ans << " " << pe << endl;
  
  
}
      
  
  
  

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll INF = 1LL<<60;
 
int main() {
	ll N;
  	cin >> N;
  	ll ans = 0;
  	vector<ll> L(2 * N);
  	rep(i,2 * N){
      cin >> L[i];
    }
  	sort(all(L));
  	rep(i,(2 * N)-1){
      ans += min(L[i],L[i+1]);
      ++i;
    }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

import static java.lang.System.in;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0;i<n;i++) a[i]=sc.nextInt();
        boolean flag = true;
        for(int i=0;i<n;i++) flag &= (a[i]%2==0);
        String ans = flag?"second":"first";
        System.out.println(ans);
        /*Arrays.sort(a,Collections.reverseOrder());
        int[] dp = new int[n];
        if(n==1){
          String ans = a[0]%2==0?"second":"first";
          System.out.println(ans);
          System.exit(0);
        }
        Arrays.fill(dp,-1);
        // dp[i]=0 means first wins. =1 means second wins
        if(a[0]%2==0&&a[1]%2==0) dp[1]=1;
        else dp[1]=0;
        PrintWriter out = new PrintWriter(System.out);
        out.println(ans);
        out.flush();*/
    }
}


Measured memory_bytes: 52576
#include <algorithm>
#include <array>
#include <assert.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

struct DSU {
    DSU(ll n) : parent(n), rank(n, 0) {
        std::iota(parent.begin(), parent.end(), 0);
    }
    void make_set(ll v) {
        parent[v] = v;
        rank[v] = 0;
    }

    ll find_set(ll v) {
        if (v == parent[v]) return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(ll a, ll b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (rank[a] < rank[b]) swap(a, b);
            parent[b] = a;
            if (rank[a] == rank[b]) ++rank[a];
        }
    }
    vl parent;
    vl rank;
};

ll n, h, w, ans;

struct Kek {
    void read(ll ii) {
        i = ii;
        cin >> x >> y >> a;
        --x, --y;
    }
    bool operator<(const Kek& other) const {
        if (a != other.a) return a > other.a;
        return i < other.i;
    }
    pll get_edge() { return { x, y + h }; }
    ll x, y, a, i;
};

const ll MAXN = 2e5 + 228;
Kek keks[MAXN];
bool fucked[MAXN];

int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    cin >> n >> h >> w;

    for (int i = 0; i < n; ++i) {
        keks[i].read(i);
    }

    sort(keks, keks + n);
    DSU d(h + w + 10);
    for (int i = 0; i < n; ++i) {
        pll e = keks[i].get_edge();
        ll v = e.fi;
        ll u = e.se;
        if (d.find_set(v) == d.find_set(u)) {
            if (fucked[d.find_set(v)]) {
                continue;
            }
            ans += keks[i].a;
            // cerr << "take " << keks[i].x << " " << keks[i].y << " " << keks[i].a << " " << keks[i].i << endl;
            fucked[d.find_set(v)] = true;
        } else {
            if (fucked[d.find_set(v)] && fucked[d.find_set(u)]) {
                continue;
            } else {
                bool xx = fucked[d.find_set(v)] || fucked[d.find_set(u)];
                fucked[d.find_set(v)] = xx;
                fucked[d.find_set(u)] = xx;
            }
            ans += keks[i].a;
            // cerr << "take " << keks[i].x << " " << keks[i].y << " " << keks[i].a << " " << keks[i].i << endl;
            d.union_sets(v, u);
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    if(k == 1) {
        long long ans = 1LL * n * n * n;
        cout << ans << endl;
        return 0;
    }
    int p = n/k;
    int q = 0;
    if(k%2 == 0) {
        q = 1 + floor((double)(n - (k/2))/(double)k);
    }
    long long ans = 1LL*p*p*p + 1LL*q*q*q;
    cout << ans << endl;
    return 0;
}


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

// int N = 2;
// int t[] = {0, 3, 6};
// int x[] = {0, 1, 2};
// int y[] = {0, 1, 1};

int N;
int t[100001];
int x[100001];
int y[100001];

int main() {
    cin >> N;
    rep(i, N) {
        cin >> t[i+1] >> x[i+1] >> y[i+1];
    }
    for (int i = 0; i < N; i++) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        // printf("%d %d", dt, dist);
        if (dt < dist) {
            cout << "No" << endl;
            return 0;
        }
        if (dt % 2 != dist % 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n, m; cin >> n >> m;
  vector<vector<int>> es(n);
  vector<int> de(n);
  for (int i = 0; i < m; i++) {
    int v, u; cin >> v >> u;
    v--, u--;
    es[v].emplace_back(u);
    de[u]++;
  }
  
  deque<int> ord;
  vector<bool> se(n);
  function<void(int)> dfs = [&](int v) {
    if (se[v]) return;
    se[v] = true;
    for (auto u : es[v]) {
      if (se[u]) continue;
      dfs(u);
    }
    ord.push_front(v);
  };
  for (int i = 0; i < n; i++) {
    if (de[i] == 0) dfs(i);
  }

  vector<int> di(n);
  for (auto v : ord) {
    for (auto u : es[v]) {
      di[u] = max(di[u], di[v] + 1);
    }
  }

  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, di[i]);
  }
  cout << ans << '\n';
}


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

using namespace std;

signed main() {
	int cnt[4];
	fill(cnt, cnt + 4, 0);
	for (int i = 0; i < 3; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		cnt[u]++;
		cnt[v]++;
	}
	for (int i = 0; i < 4; i++) {
		if (cnt[i] > 2) {
			cout << "NO\n";
			return 0;
		}
	}
	cout << "YES\n";
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    int arr[3] = {1, 2, 3};

    for (int i = 0; i < 3; i++) {
        if (arr[i] != a && arr[i] != b) cout << arr[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s; cin >> s;
	int x, y; cin >> x >> y;
	vector<int>vec_x, vec_y;
	bool ok = true;
	int cnt = 0;
	s.push_back('T');
	rep(i, 0, s.size()) {
		if (s[i] == 'T') {
			if (ok) {
				if (cnt)vec_x.push_back(cnt);
				ok = false;
			}
			else {
				if (cnt)vec_y.push_back(cnt);
				ok = true;
			}
			cnt = 0;
		}
		else cnt++;
	}

	map<int, int>mp;
	mp[0] = -1;
	rep(i, 0, vec_x.size()) {
		map<int, int>memo = mp;
		for (auto p : memo) {
			if (p.second == i - 1) {
				mp[p.first + vec_x[i]] = i;
				if (s[0] == 'F' && i == 0)continue;
				mp[p.first - vec_x[i]] = i;
			}
		}
	}
	if (!mp.count(x) || mp[x] != vec_x.size() - 1) {
		puts("No");
		return 0;
	}
	mp.clear();
	mp[0] = -1;
	rep(i, 0, vec_y.size()) {
		map<int, int>memo = mp;
		for (auto p : memo) {
			if (p.second == i - 1) {
				mp[p.first + vec_y[i]] = i;
				mp[p.first - vec_y[i]] = i;
			}
		}
	}
	if (mp[y] != vec_y.size() - 1) {
		puts("No");
		return 0;
	}
	cout << "Yes" << "\n";

	return 0;
}

Measured memory_bytes: 4420
#include<bits/stdc++.h>
using namespace std;
string s;
int ans;
int main()
{
	cin>>s;
	for(int i=1;i<s.size();i++)
	  if(s[i-1]==s[i])
	   {
	     if(s[i]=='1') s[i]='0';
	     else s[i]='1';
	     ans++;
	   } 
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int main() {
    int n;
    cin >> n;
    int32_t max_v = 0;
    int32_t min_v = 1e9 + 1;
    for (size_t i = 0; i <= n; ++i) {
        int a;
        cin >> a;
        if (a > max_v) max_v = a;
        if (a < min_v) min_v = a;
    }

    cout << max_v - min_v << endl;
    return EXIT_SUCCESS;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	map<string,int>mp;
	int n,ma=0;
	string s;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		mp[s]++;
		ma=max(mp[s],ma);
	}
	for(auto p:mp){
		auto a=p.first;
		auto b=p.second;
		if(b==ma){
			cout<<a<<endl;
		}
	}
}


Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, k, s;
	cin >> n >> k >> s;
	rep(i, 1, k){
		cout << s << " ";
	}
	rep(i, 1, n-k){
		ll p = (s == 1e9)? s-1 : s+1;
		cout << p << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

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

    ll n;
    cin>>n;
    ll ar[n];
    map<ll,ll> m;
    ll ans=0;
    for(ll i=0;i<n;++i){
        cin>>ar[i];
        ll val=i-ar[i];
        ans+=m[val];
        m[i+ar[i]]+=1;
    }
    cout<<ans;

    return (0);
}


Measured memory_bytes: 27964
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	int n=0;
	cin>>s;
	for(int i=0;4>i;i++){
		if(s.at(i)=='+'){
			n++;
		}
		if(s.at(i)=='-'){
			n--;
		}
	}
	cout<<n<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		// ?????°??¨?????°?????????
		int line = in.nextInt();
		int column = in.nextInt();

		// ????????????????´??????????????????¨???
		int[][] matrix = new int[line + 1][column + 1];

		// ?????????????????????????´?
		for(int l = 0; l < line; l++){

			for(int c = 0; c < column; c++){

				matrix[l][c] = in.nextInt();

				matrix[l][column] += matrix[l][c];

			}
		}

		for(int c = 0; c < column; c++){

			for(int l = 0; l < line; l++){

				matrix[line][c] += matrix[l][c];

				

			}

matrix[line][column] += matrix[line][c];

		}

		// ???????????????????????????
		for(int l = 0; l <= line; l++){

			for(int c = 0; c < column; c++){

				System.out.print(matrix[l][c] + " ");

			}

			System.out.println(matrix[l][column]);

		}

	}

}

Measured memory_bytes: 45568
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    ll x, y; cin >> x >> y;
    cout << (abs(x-y)<=1? "Brown\n":"Alice\n");

    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

B = sorted(B)
C = sorted(C)
b_list = {N:0}
for i in range(N-1,-1,-1):
    j = bisect_right(C,B[i])
    b_list[i] = N - j + b_list[i+1]
m = 0
for i in range(N):
    j = bisect_right(B,A[i])
    m += b_list[j]
print(m)


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

int main() {
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.end());

  if(a[0]==5&&a[1]==5&&a[2]==7) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
/*
ll vis[100005]={0};
ll par[100005]={0};
//map<ll,ll> mp;
ll ma=0;
void dfs(vector<ll> v1[],int x)
{
    
    vis[x]=1;
        for(auto i : v1[x])
        {
            if(vis[i]==0)
                dfs(v1,i);
        }
        
    return ;
}*/
int main()
{
    ll a,b,c,d,e,x,t,n,m,count;
    //ll ma=-1;
    t=1;
    string s1;
    cin>>s1;
    cin>>t;
    //vector<ll> ev,od;
    //map<char,ll> mp;
    //set <char> se;
    list <char> arr;
    for(int i=0;i<s1.size();i++)
    {
        arr.push_back(s1[i]);
    }
    char ch='a';
    auto start=arr.begin();
    auto end=arr.end();
    x=1;
    while(t--)
    {
        cin>>a;
        if(a==1)
        {
            x++;
        }
        else if(a==2)
        {
            cin>>b;
            cin.ignore();
            cin>>ch;
            if(b==1)
            {
                if(x%2==1) arr.push_front(ch);
                else arr.push_back(ch);
            }
            else if(b==2)
            {
                if(x%2==0) arr.push_front(ch);
                else arr.push_back(ch);
                
            }
        }
        
    }
    //cout<<s1;
    if(x%2==1)
    {
        for(auto it=arr.begin();it!=arr.end();it++)
        {
            cout<<*it;
        }
    }
    else
    {
        for(auto it=arr.rbegin();it!=arr.rend();it++)
        {
            cout<<*it;
        }
    }
    return 0;
}
 

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int N;
  cin >> N;
  vector<int> H(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  vector<int> dp(N, INF);
  dp[0] = 0;
  dp[1] = abs(H[1] - H[0]);
  for (int i = 2; i < N; i++) {
    int cost1 = abs(H[i] - H[i - 1]);
    int cost2 = abs(H[i] - H[i - 2]);
    dp[i] = min(dp[i - 1] + cost1, dp[i - 2] + cost2);
  }
  cout << dp[N - 1] << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  long long n, x; cin >> n >> x;
  vector<long long> a(n), b(n); for (long long i = 0; i < n; i++) cin >> a[i];
  long long res = numeric_limits<long long>::max();
  for (int i = 0; i < n; i++) {
    long long tmp = 0;
    for (int j = 0; j < n; j++) tmp += a[j];
    tmp += i * x;
    b = a;
    for (int j = 0; j < n; j++) a[j] = min(b[j], b[(j - 1 + n) % n]);
    res = min(res, tmp);
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
 
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }

//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
#define EACH(a,A) for(auto a: A)
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 
//cin,cout高速化のおまじない＋桁数指定
inline VLL cinvll(LL N){
  VLL A(N);
  REP(i,N){
    cin >> A[i];
  }
  return move(A);
}
struct Fast{
	Fast(){
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast;



void func(){
  LL mod = 1e9+7;
  LL N;
  cin >> N;
  auto A = cinvll(N);
  //PRINTSP(A);
  // すべての組み合わせのXORの和

  LL xor_sum =0;
  LL K = 60;
  for (LL i = 0; i < K; ++i) {
    LL cnt=0;
    REP(n,N){
      LL bit = A[n];
      if (bit & ((LL)1 << i)) {
        cnt++;
      }
      else{
      }
    }
    LL a = cnt*(N-cnt);
    a %= mod;
    LL b = ((LL)1 << i);
    b %= mod;
    
    xor_sum += a*b;
    xor_sum %= mod;
  } 

  cout << xor_sum;
} 
int main()
{
  func();
  return 0;
}
 

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

int main() {
  int N, K, l = 0;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (K - x < x) {
      l += (K - x) * 2;
    } else {
      l += x * 2;
    }
  }
  cout << l << endl;
}

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    vector<int> v[n+1];
    for(int i=1;i<=m;i++)
    {
        int a,b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    vector<int> res(n+1,0);
    vector<int> d(n+1,-1);
    d[1]=0;
    queue<int> q;
    q.push(1);
    while(!q.empty())
    {
        int a=q.front();
        q.pop();
        for(int to:v[a])
        {
            if(d[to]==-1)
            {
                d[to]=d[a]+1;
                q.push(to);
                res[to]=a;
            }
        }
    }
    cout << "Yes\n";
    for(int i=2;i<=n;i++) cout << res[i] << "\n";
    return 0;
}


Measured memory_bytes: 10520
#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

#define ll long long

void exgcd(int a, int b, int& x, int& y) {
	if (!b) {
		x = 1, y = 0;
	} else {
		exgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
}

int inv(int a, int n) {
	int x, y;
	exgcd(a, n, x, y);
	return (x < 0) ? (x + n) : (x);
}

const int Mod = 1e9 + 7;

template <const int Mod = :: Mod>
class Z {
	public:
		int v;

		Z() : v(0) {	}
		Z(int x) : v(x){	}
		Z(ll x) : v(x % Mod) {	}

		Z operator + (Z b) {
			int x;
			return Z(((x = v + b.v) >= Mod) ? (x - Mod) : (x));
		}
		Z operator - (Z b) {
			int x;
			return Z(((x = v - b.v) < 0) ? (x + Mod) : (x));
		}
		Z operator * (Z b) {
			return Z(v * 1ll * b.v);
		}
		Z operator ~() {
			return inv(v, Mod);
		}
		Z operator - () {
			return Z(0) - *this;
		}
		Z& operator += (Z b) {
			return *this = *this + b;
		}
		Z& operator -= (Z b) {
			return *this = *this - b;
		}
		Z& operator *= (Z b) {
			return *this = *this * b;
		}
};

Z<> qpow(Z<> a, int p) {
	Z<> rt = Z<>(1), pa = a;
	for ( ; p; p >>= 1, pa = pa * pa) {
		if (p & 1) {
			rt = rt * pa;
		}
	}
	return rt;
}

typedef Z<> Zi;

const int N = 303;

int n;
Zi f[2][N][N];
int A[N << 1], flag[N << 1];

int main() {
	scanf("%d", &n);
	int cur = 0, cnt1 = 0, cnt2 = 0;
	for (int i = 1, x; i <= (n << 1); i++) {
		scanf("%d", &x);
		A[i] = x;
		if (x != -1) {
			flag[x] = 1;
		}
	}
	for (int i = 1; i <= (n << 1); i += 2) {
		if (flag[A[i]] && flag[A[i + 1]]) {
			flag[A[i]] = flag[A[i + 1]] = 2;
			cnt2++;
		}
	}
	f[cur][0][0] = 1;
	for (int i = (n << 1); i; i--) {
		if (flag[i] == 2) {
			continue;
		}
		cur ^= 1;
		memset(f[cur], 0, sizeof(f[cur]));
		for (int j = 0; j <= n; j++) {
			for (int k = 0; k <= cnt1; k++) {
				Zi v = f[cur ^ 1][j][k];
				if (!flag[i]) {
					if (j < n) f[cur][j + 1][k] += v;
					if (j > 0) f[cur][j - 1][k] += v;
					if (k > 0) f[cur][j][k - 1] += v * k;
				} else {
					f[cur][j][k + 1] += v;
					if (j > 0) f[cur][j - 1][k] += v;
				}
			}
		}
		cnt1 += flag[i] == 1;
	}
	Zi ans = f[cur][0][0];
	for (int i = n - cnt2 - cnt1; i; i--)
		ans *= i;
	printf("%d\n", ans.v);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
using Graph = vector<vector<int>>;
using Graph_Wei = vector<vector<pair<int,int>>>;
using ll = long long;



int main() {

    long double a,b,x;

    cin >> a >> b >> x;

    long double h;
    long double ans;

    if(x >= a*a*b/2.0){

        h = 2/a * (a * b - x/a);

        ans = atan2(h,a) / acos(-1) * 180.0;
    }else{

        h = (2 * x )/(a * b);
        ans = atan2(b,h) / acos(-1) * 180.0;

    }

    cout << fixed << setprecision(10) << ans << endl;


    return 0;

}

Measured memory_bytes: 256
def split(word): 
    return [char for char in word] 
MOD=10**9+7
h,w,k1=map(int,input().split())
dp=[]
for i in range(h+1):
  dp.append([])
  for j in range(w):
    dp[-1].append(0)
dp[0][0]=1
connections=[0]*(w-1)
totallegal=0
for i in range(pow(2,w-1)):
  s='{0:b}'.format(i)
  k=split(s)
  k.reverse()
  for j in range(w-1-len(k)):
    k.append('0')
  k.reverse()
  failflag=0
  for j in range(1,w-1):
    if k[j]=='1' and k[j-1]=='1':
      failflag=1
  if failflag==1:
    continue
  for j in range(w-1):
    if k[j]=='1':
      connections[j]+=1
  totallegal+=1
for i in range(h):
  for j in range(w):
    used=0
    if j>0:
      dp[i+1][j-1]=(dp[i+1][j-1]+connections[j-1]*dp[i][j])%MOD
      used+=connections[j-1]
    if j<w-1:
      dp[i+1][j+1]=(dp[i+1][j+1]+connections[j]*dp[i][j])%MOD
      used+=connections[j]
    dp[i+1][j]=(dp[i+1][j]+(totallegal-used)*dp[i][j])%MOD
print(dp[h][k1-1])

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

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

  string s;
  cin >> s;
  int n = s.size();
  int res = 0;
  for (int i = 1; i <= (n - 1) / 2; i++) {
    if (s.substr(0, i) == s.substr(i, i)) res = i * 2;
  }
  cout << res << '\n';
  return 0;
}

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

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);

    for (int i=0; i<n; i++) cin >> a[i];
    int ans= INT_MAX;
    for(int i=0; i<n; i++) {
        int current=0;
        while(a[i]%2 != 1){
            current++;
            a[i] /= 2;
        }
        ans = min(ans, current);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3164
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String[] strs = sc.nextLine().split(" ");

		ArrayList<Integer> list = new ArrayList<Integer>();

		for (int i = 0; i < 4; i++) {
			list.add(Integer.parseInt(strs[i]));
		}

		Collections.sort(list);

		if (list.get(0) == 1 && list.get(1) == 4 && list.get(2) == 7 && list.get(3) == 9) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

}

Measured memory_bytes: 22996
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, P = MAP()

#素因数分解
def factorization(n):
	arr = []
	tmp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if tmp%i == 0:
			cnt = 0
			while tmp%i == 0:
				cnt += 1
				tmp //= i
			arr.append([i, cnt])
	if tmp != 1:
		arr.append([tmp, 1])
	if arr == []:
		arr.append([n, 1])
	return arr
	
arr = factorization(P)
ans = 1
for x, y in arr:
	if N <= y:
		ans *= x**(y//N)

print(ans)

Measured memory_bytes: 5208
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int shihab;
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
  //  FI(); /// skip this line for compile
    ll a,b,c;
    cin >> a >> b >> c;
    if(c-a-b>0 && (c-a-b)*(c-a-b)>4*a*b) cout << "Yes\n";
    else cout << "No\n";
    return 0;
    //code end
}
//okbye


Measured memory_bytes: 3596
#include <stdio.h>

int main()
{
	int A, B, C, D;
	scanf("%d %d %d %d", &A, &B, &C, &D);
	A = (A < C)? C: A;
	B = (B < D)? B: D;
	printf("%d\n", (A < B)? B - A: 0);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1704
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a%3==0 || b%3==0 || (a+b)%3==0) printf("Possible\n");
	else printf("Impossible\n");
	return 0 ;
}


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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	long long a, b, c, k;

	cin >> a >> b >> c >> k;
	long long cnt = 0, maxsum = 0;
	while (cnt < k) {
		if (a > 0) {
			maxsum++;
			a--;
		}
		else if (b > 0) b--;
		else {
			maxsum--;
			c--;
		}
		cnt++;
	}
	cout << maxsum << '\n';
	return 0;
}

Measured memory_bytes: 3592
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(H: int, W: int, A: "List[List[int]]", B: "List[List[int]]"):
    base = [[abs(A[h][w]-B[h][w]) for w in range(W)] for h in range(H)]
    mx = (1 << 12800) - 1
    table = [[0]*W for _ in range(H)]
    table[0][0] = (1 << (6400 + base[0][0])) | (1 << (6400-base[0][0]))
    for h in range(H):
        for w in range(W):
            if h > 0:
                table[h][w] |= (table[h-1][w] << base[h][w])
                table[h][w] |= (table[h-1][w] >> base[h][w])
            if w > 0:
                table[h][w] |= (table[h][w-1] << base[h][w])
                table[h][w] |= (table[h][w-1] >> base[h][w])
            table[h][w] &= mx

    m = INF
    for j in range(12800):
        i = (table[H-1][W-1] >> j) & 1
        if i == 1:
            m = min(m, abs(j-6400))
    print(m)
    # print(table[H-1])

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = [[int(next(tokens)) for _ in range(W)]
         for _ in range(H)]  # type: "List[List[int]]"
    B = [[int(next(tokens)) for _ in range(W)]
         for _ in range(H)]  # type: "List[List[int]]"
    solve(H, W, A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13428
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int N; // Graph(Tree)の頂点数
vector< vector<int> > G; // Graph(Tree)の隣接リスト表現
vector<int> D; // 各頂点のrootからの距離
int LOG_N; // log2(N)の天井
vector< vector<int> > P; // P[k][v] : 頂点vの2^k番目の先祖
void dfs(int prev, int index, int d) {
    P[0][index] = prev;
    D[index] = d;
    for (int i = 0; i < G[index].size(); i++) {
        int next = G[index][i];
        if (next == prev) continue;
        dfs(index, next, d + 1);
    }
}
void init() {
    LOG_N = int(ceil(log2(N) + 1));
    P.clear(); P.resize(LOG_N, vector<int>(N));
    D.clear(); D.resize(N);
    dfs(-1, 0, 0);
    for (int k = 0; k < LOG_N - 1; k++) {
        for (int v = 0; v < N; v++) {
            if (P[k][v] < 0) P[k + 1][v] = -1;
            else P[k + 1][v] = P[k][ P[k][v] ];
        }
    }
}
// 頂点vのn番目の親を返す
int nth_parent(int v, int n) {
    for (int k = 0; k < LOG_N; k++)
        if (n & (1 << k)) v = P[k][v];
    return v;
}
// 2頂点uとvのLCAを返す
int lca(int u, int v) {
    if (D[u] > D[v]) swap(u, v);
    v = nth_parent(v, D[v] - D[u]);
    if (u == v) return u;
    for (int k = LOG_N - 1; k >= 0; k--) {
        if (P[k][u] != P[k][v]) {
            u = P[k][u];
            v = P[k][v];
        }
    }
    return P[0][u];
}
// 2頂点uとvの距離を返す
int dist(int u, int v) {
    int root = lca(u, v);
    return (D[u] - D[root]) + (D[v] - D[root]);
}

int main() {
    cin >> N;
    G.clear(); G.resize(N);
    for (int i = 0; i < N; i++) {
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int c; cin >> c;
            G[i].push_back(c);
        }
    }
    init();
    int Q; cin >> Q;
    for (int q = 0; q < Q; q++) {
        int u, v; cin >> u >> v;
        cout << lca(u, v) << endl;
    }
    return 0;
}

Measured memory_bytes: 18716
#include <cstdio>
#include <cmath>

int W, H, N;
int x[500], y[500], p[502];

int findset(int x)
{
	return x == p[x] ? x : p[x] = findset(p[x]);
}

int main()
{
	scanf("%d %d %d", &W, &H, &N);
	for (int i = 0; i < N; ++i)
		scanf("%d %d", &x[i], &y[i]);
	double L = 0;
	double R = 2e9;
	while (R - L > 1e-4)
	{
		double M = (L + R) / 2;
		for (int i = 0; i < N + 2; ++i)
			p[i] = i;
		for (int i = 0; i < N; ++i)
		{
			if (x[i] <= M)
				p[findset(i)] = N;
			if (x[i] >= W - M)
				p[findset(i)] = N + 1;
		}
		for (int i = 0; i < N; ++i)
			for (int j = i + 1; j < N; ++j)
				if (hypot(x[i] - x[j], y[i] - y[j]) <= 2 * M)
					p[findset(i)] = findset(j);
		if (findset(N) == findset(N + 1))
			R = M;
		else
			L = M;
	}
	printf("%.3f\n", (L + R) / 2);
	return 0;
}

Measured memory_bytes: 2812
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
typedef long long int ll;
using namespace std;

#define MAXN (10000+5)
#define MAXA (1000000+5)

int main(){
	char c;

	cin >> c;
	c++;
	cout << c << endl;
}

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

#define ll long long int

int N;
int dias[3];
ll memo[2][3];

ll solve(){
	cin>>memo[0][0]>>memo[0][1]>>memo[0][2];
	for(int i = 1; i<N; i++){
		cin>>dias[0]>>dias[1]>>dias[2];
		for(int j = 0; j<3;j++)
			memo[i&1][j]=dias[j]+max(memo[(i+1)&1][(j+1)%3],memo[(i+1)&1][(j+2)%3]);
	}
	ll maxi = 0;
	for(int j = 0; j<3;j++)
		maxi = max(memo[(N-1)&1][j], maxi);
	return maxi;
}

int main() {
	cin>>N;
	cout<<solve()<<"\n";
	return 0;
}

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

using namespace std;
const long long int big = 998244353;
const int MAX = 510000;
long long int fac[MAX], finv[MAX], inv[MAX];

long long int COM(long long int n, long long int k);
void COMinit();

long long int mpow(int m, int k);

int main()
{
    int n, tempn, maxn, minn;
    cin >> n;
    pair<int, int> a[n];
    pair<int, int> b[n];
    pair<int, int> c[n];
    string temp;
    int aind = 0, bind = 0, minc = 0, aadd = 0, badd = 0;
    for (int i = 0; i < n; i++)
    {
        tempn = 0;
        maxn = 0;
        minn = 0;
        cin >> temp;
        for (int j = 0; j < temp.length(); j++)
        {
            if (temp[j] == '(')
            {
                tempn++;
            }
            else
            {
                tempn--;
            }

            if (minn > tempn)
                minn = tempn;
        }
        if (tempn > 0)
        {
            a[aind].second = tempn;
            a[aind].first = minn;
            aind++;
            aadd += tempn;
        }
        else if (tempn < 0)
        {
            b[bind].second = -tempn;
            b[bind].first = minn - tempn;
            bind++;
            badd -= tempn;
        }
        else
        {
            if (minc > minn)
                minc = minn;
        }
    }
    if (aadd != badd)
    {
        cout << "No" << endl;
        return 0;
    }
    if (aadd + minc < 0)
    {
        cout << "No" << endl;
        return 0;
    }

    sort(a, a + aind);
    reverse(a, a + aind);
    sort(b, b + bind);
    reverse(b, b + bind);
    tempn = 0;
    for (int i = 0; i < aind; i++)
    {
        if (tempn + a[i].first < 0)
        {
            cout << "No" << endl;
            return 0;
        }
        tempn += a[i].second;
    }
    tempn = 0;
    for (int i = 0; i < bind; i++)
    {
        if (tempn + b[i].first < 0)
        {
            cout << "No" << endl;
            return 0;
        }
        tempn += b[i].second;
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 26924
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int A,B;
int N,M,K,X,Y;
//=============================
void input()
{
    cin>>N>>A>>B;
}
//=============================
void func(){}
/*
 - 樹形図をかく
*/
//=============================
void solve()
{
    cout<<min(A*N , B)<<endl;

}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
def scc(N , M):
    ans = 0
    if N * 2 >= M:
        ans += M // 2
        return ans
    else:
        ans += N
        M -= N*2
        ans += M//4
        return ans

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

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int MOD = 2019;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	long long L, R;
	cin >> L >> R;
	if (R - L + 1 >= 2019){
		cout << 0 << endl;
	}
	else{
		int ans = 2018;
		for (long long i = L; i <= R; i++){
			for (long long j = i + 1; j <= R; j++){
				long long p = i * j;
				ans = min(ans, (int)(p % MOD));
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;

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

    if(a >= k){
        a = a - k;
    }else if(k - a < b){
        b = b - k + a;
        a = 0;
    }else{
        a = 0;
        b = 0;
    }

    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
string S;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>S;
    ll n=S.length();
    map<char,ll> m;
    rep(i,0,n){
        m[S[i]]++;
    }
    ll ans=n*(n-1)/2+1;
    for (char i='a';i<='z';i++){
        ans-=m[i]*(m[i]-1)/2;
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 720
N,M=map(int,input().split())
xyz=[]
for i in range(N):
    x,y,z=map(int,input().split())
    xyz.append([x,y,z])
ans=0
for k in range(8):
    A=[k>>2 &1,k>>1 &1,k>>0 &1]
    l=[]
    for i in range(N):
        t=0
        for j in range(3):
            if A[j]==0:
                t+=xyz[i][j]
            else:
                t-=xyz[i][j]
        l.append(t)
    l.sort(reverse=True)
    ans=max(ans,sum(l[:M]))
print(ans)


Measured memory_bytes: 3296
import java.util.Scanner;
import java.util.LinkedList;
import java.util.Collections;
import java.util.Comparator;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        LinkedList<Integer> nums = new LinkedList<>();
        int[] counts = new int[200001];

        // input
        int num = scan.nextInt();
        int k = scan.nextInt();
        for(int i = 0; i < num; i++){
            counts[scan.nextInt()] += 1;
        }
        for(int i = 0; i < 200001; i++){
            if(counts[i] != 0){
                nums.add(counts[i]);
            }
        }

        // search
        Collections.sort(nums, Comparator.reverseOrder());
        for(int i = 0; i < k; i++){
            nums.poll();
        }
        int sum = 0;
        while(nums.size() > 0){
            sum += nums.poll();
        }

        // answer
        System.out.println(sum);


    }
}

Measured memory_bytes: 96008