akhauriyash/Code-Regression huggingface dataset:
import math

a, b, x = map(int, input().split())
s = x / a
# (aa * b / 2) * a = x
aa = (2 * x) / (a * b)
if aa <= a:
	theta = math.atan2(b,aa)
else:
	# a * (b - bb) + a * bb / 2 = s
	# a * b - a * bb + a * bb / 2 = s
	# a * b - a * bb / 2 = s
	# bb * a / 2 = a * b - s
	bb = (a * b - s) * 2 / a
	theta = math.atan2(bb,a)
print(math.degrees(theta))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int w, h, n;
  cin >> w >> h >> n;
  int l = 0, r = w, d = 0, u = h;
  rep(i, n){
    int x, y, mode;
    cin >> x >> y >> mode;
    if(mode == 1){
      l = max(l, x);
    }
    if(mode == 2){
      r = min(r, x);
    }
    if(mode == 3){
      d = max(d, y);
    }
    if(mode == 4){
      u = min(u, y);
    }
  }
  if(r < l || u < d) cout << 0 << endl;
  else cout << (r-l)*(u-d) << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int sum_digit(int n)
{
    int res = 0;
    while (n)
    {
        res += n % 10;
        n /= 10;
    }
    return res;
}

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

    cout << ((n%sum_digit(n)==0) ? "Yes" : "No") << '\n';
    return (0);
}


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

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; i += 2){
        int count = 0;
        for(int j = 1; j <= i; ++j){
            if(i % j == 0) count++;
        }
        if(count == 8) ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
#define REP(i,m,n) for(int i = (int)(m) ; i < (int) (n);i++)
#define rep(i,n) REP(i,0,n)

int n;
int b[110];
int ans;


int main(){

	cin >> n;
	rep(i, n - 1) cin >> b[i];
	//入力
	
	rep(i, n){
		if (i == 0){
			ans += b[i];
		}
		else if (i == n - 1){
			ans += b[n - 2];
		}
		else {
			ans += min(b[i], b[i - 1]);
		}
	}
	cout << ans << endl;


}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort
#include <math.h>

#define DEBUG 0

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll mod = 1000000007;
static const ll INF = 1000000000000000000LL;
                    //999999997000000003
                    //1000000000000000000

using namespace std;

int main(){
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N;
    cin >> N;
    ll res = 0;
    REP(i,N)
    {
        int a;
        cin >> a;
        res += a - i - 1;
    }

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



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

using namespace std;
typedef long long ll;
int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);

    ll t=1;
    //cin>>t;
    while(t--)
    {
       string s;
       cin>>s;
       s=="ABC"? cout<<"ARC":cout<<"ABC";
    }
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std; 

int main(void) {
	int nov,noe,u,v;
	cin >> nov;
	vector< vector<int> > adj(nov,vector<int>(nov,0));
	for (int i = 0; i < nov; ++i) {
		cin >> u;
		cin >> noe;
		for (int j = 0; j < noe; ++j) {
			cin >> v;
			adj[u-1][v-1] = 1;
		}
	}
	for (int i = 0; i < nov; ++i) {
		for (int j = 0; j < nov; ++j) {
			cout << adj[i][j];
			if (j < nov-1) {
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> sum(n + 1);
    REP(i, n) {
        sum[i + 1] = sum[i];
        if (s[i] == '#') sum[i + 1]++;
    }

    int ans = n;
    REP(i, n + 1) chmin(ans, (sum[i] - sum[0]) + ((n - i) - (sum[n] - sum[i])));
    cout << ans << endl;
        
}



Measured memory_bytes: 1300
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007;
using namespace std;
using lint = long long;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < (int)vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T = lint>
struct Edge {
	int from, to;
	T cost;
	Edge() {}
	Edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
};

template<class T>
vector<T> Bellman_Ford(vector<Edge<T>> &edges, int V, int st) {

	const T inf = numeric_limits<T>::max(); // different from INF!!!
	vector<T> dist(V, inf);
	dist[st] = 0;
	for (int i = 0; i < V - 1; i++) {
		for (const auto &e : edges) {
			if (dist[e.from] == inf) continue;
			dist[e.to] = min(dist[e.to], dist[e.from] + e.cost);
		}
	}

	for (int i = 0; i < V - 1; i++) {
		for (const auto &e : edges) { // finding negative loop
			if (dist[e.from] == inf) continue;
			if (dist[e.from] == -inf) dist[e.to] = -inf; // src is nloop -> dst is nloop
			else if (dist[e.to] > dist[e.from] + e.cost) dist[e.to] = -inf; // chmin is possible -> nloop
		}
	}

	return dist;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M, P;
	cin >> N >> M >> P;

	int a, b, c;
	vector<Edge<int>> edges(M);
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> c;
		a--, b--;
		edges[i] = { a, b, P - c };
	}

	auto dist = Bellman_Ford(edges, N, 0);
	DMP(dist);
	
	lint ans = -dist.back();
	DMP(ans);
	if (ans == numeric_limits<int>::max()) cout << "-1\n";
	else if (ans < 0) cout << "0\n";
	else cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 384
class Node
  attr_accessor :id, :key, :parent, :left, :right

  def set_info(id, key)
    @id = id
    @key = key
  end
end

class Tree
  attr_accessor :nodes, :root, :result

  def initialize(n)
    @nodes = Array.new(n).map{ Node.new() }
    @result = []
  end

  def insert(id, key)
    z = @nodes[id]
    z.set_info(id, key)
    y = nil
    x = @root

    while !x.nil?
      y = x
      if z.key < x.key
        x = x.left
      else
        x = x.right
      end
    end

    if y.nil?
      @root = z
    elsif z.key < y.key
      y.left = z
      z.parent = y
    else
      y.right = z
      z.parent = y
    end
  end

  def find(x, k)
    while !x.nil? && x.key != k
      if k < x.key
        x = x.left
      else
        x = x.right
      end
    end
    return x
  end

  def Preorder(u)
    @result.push(@nodes[u].key)
    Preorder(@nodes[u].left.id) unless @nodes[u].left.nil?
    Preorder(@nodes[u].right.id) unless @nodes[u].right.nil?
  end

  def Inorder(u)
    Inorder(@nodes[u].left.id) unless @nodes[u].left.nil?
    @result.push(@nodes[u].key)
    Inorder(@nodes[u].right.id) unless @nodes[u].right.nil?
  end

  def clean_result
    @result = []
  end

end

def main
  n = gets.to_i
  tree = Tree.new(n)

  n.times do |num|
    ins, key = gets.chomp.split
    if ins == 'insert'
      tree.insert(num, key.to_i)
    elsif ins == 'find'
      tree.find(tree.root, key.to_i) ? puts('yes') : puts('no')
    else
      tree.Inorder(tree.root.id)
      puts ' ' + tree.result.join(' ')
      tree.clean_result
      tree.Preorder(tree.root.id)
      puts ' ' + tree.result.join(' ')
      tree.clean_result
    end
  end
end

main



Measured memory_bytes: 75396
# import sys
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools
# import collections # queue
# from fractions import Fraction

mod = int(1e9+7)
INF = 1<<29
lINF = 1<<35

def main():
    h,w = map(int,input().split())
    a = []
    a.append(['#'] * (w + 2))
    for i in range(h):
        x = list(input())
        x.insert(0,'#')
        x.append('#')
        a.append(x)
    a.append(['#'] * (w + 2))
    for i in range(len(a)):
        print(''.join(a[i]))
    return

if __name__=='__main__':
    main()


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

using namespace std;

int main(){
    
    long long int i,j,k,n,m;
    cin>>n>>k;
    long long int a[n];
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    long long int cost[n];
    for(i=0;i<n;i++){
        cost[i]=1000000000;
    }
    cost[0]=0;
    cost[1]=abs(a[1]-a[0]);
   // cout<<cost[1];
    for(i=0;i<n;i++){
        for(j=i+1;j<=i+k&&j<n;j++){
                cost[j]=min(cost[j],cost[i]+abs(a[j]-a[i]));
    }
}
    cout<<cost[n-1];
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll h;
  cin >> h;
  ll cnt = 0;
  while(h >= 1) {
    h /= 2;
    cnt++;
  }
  ll ans = pow(2, cnt) - 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int r,g,b,k;
signed main(){
	cin>>r>>g>>b>>k;
	while(k>0&&g<=r){
		g*=2;k--;
	}
	if(g<=r){cout<<"No"<<endl; return 0;
	}
	while(k&&b<=g){
		b*=2;k--;
	}
	if(b<=g){
		cout<<"No"<<endl; return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
   long long n, a[100100], b[100100], i, ans=0, sumprepare=0, dif[100100], shortage=0;
   cin >> n;
   for(i=0;i<n;i++){
       cin >> a[i];
   }
   for(i=0;i<n;i++){
       cin >> b[i];
       sumprepare+=a[i]-b[i];
       dif[i]=a[i]-b[i];
       if(a[i]<b[i]){
           ans++;
           shortage+=a[i]-b[i];
       }
   }
   if(sumprepare<0) {
       cout << -1 <<endl;
       return 0;
   }
   sort(dif, dif+n, greater<long long>());
   i=0;
   while(1){
       if(shortage>=0) break;
       shortage+=dif[i];
       i++;
       ans++;
   }
   cout <<ans <<endl;
   return 0;
}

Measured memory_bytes: 5932
//                   ********** YATIN KWATRA **********

// AC BAKSHI RABBA

#include <bits/stdc++.h>
#define ll                      long long 
#define ld                      long double
#define ull                     unsigned long long 
#define FIO                     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl                    "\n"
#define fo(i,a,b)               for(int i = a; i<=b ; i++)
#define rfo(i,a,b)              for(int i = a; i>=b ; i--)
#define vii                     vector<int>
#define vll                     vector<ll>
#define pq                      priority_queue
#define uom                     unordered_map                
#define all(v)                  v.begin(),v.end()
#define mp                      make_pair
#define pb                      push_back
#define pob                     pop_back
#define ff                      first
#define ss                      second
#define pii                     pair<int,int> 
#define pll                     pair<long,long>
#define mll                     map<ll,ll>
#define mii                     map<int,int>
#define vvii                    vector<vii>
#define vvll                    vector<vll>
#define mod                     1000000007
#define pi                      3.1415926535897932384626433832795

using namespace std;

void INPUT() 
{  
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}


/*
    
   -> Check For Overflows
   -> Out of Bounds
   -> Initialisations of global arrays and variables
   -> Its not Always Complex, Try to simplify
   -> write it down and try to solve
   -> Have Faith in urself and in ur approach
   -> If it seems totally out of reach, switch to next :)
   -> And Come Back later, if possible ..
*/

const int W = 100005;
const int N = 105;

#define inf 1e18

ll dp[N][W];
ll n,w;
pll v[N];

ll f(int i, ll sum)
{
  if(sum == 0) return 0LL;
  if(i == n) return inf;

  if(dp[i][sum] != -1) return dp[i][sum];

  ll op1 = inf, op2 = inf;

  if(v[i].ss <= sum) op1 = f(i+1,sum - v[i].ss);
  op2 = f(i+1,sum);

  if(op1 != inf) op1 += v[i].ff;


  dp[i][sum] = min(op1,op2);

  return dp[i][sum];
}


void solve()
{ 
  
        cin >> n >> w;

        ll sum = 0LL;
        
        fo(i,0,n-1)
        {
          cin >> v[i].ff >> v[i].ss;
          sum += v[i].ss;
        } 


        fo(i,0,N-1)
        {
          fo(j,0,W-1) dp[i][j] = -1;
        }


        fo(i,0,sum)
        {
           f(0,i);
        }

        ll ans = 0LL;

        fo(i,0,N-1)
        {
          fo(j,0,W-1)
          {
            if(dp[i][j] != -1 and dp[i][j] <= w) ans = max(ans,(ll)j);
          }
        }


        cout << ans << endl;



       
}
int main() {
    
    FIO
    INPUT();
    
    int t;
    t = 1;
    //cin >> t;
    
    while(t--)
    {
       solve();
    }
    return 0;
}


Measured memory_bytes: 85672
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  ll n, m;
  cin >> n >> m;
  ll ans = 0;
  if (n * 2 >= m) {
    ans = m / 2;
  } else {
    ans = n + (m - 2 * n) / 4;
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C){
    if(A == B && B == C) cout << YES << endl;
    else cout << NO << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
ll llmax = LLONG_MAX;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
vi d1 = {1, 0, -1, 0}, d2 = {0, 1, 0, -1};
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}
void sorti(vi &a) {sort(a.begin(), a.end());}
void sortll(vll &a) {sort(a.begin(), a.end());}
void sorts(vs &a) {sort(a.begin(), a.end());}

int main() {
  string s, t;
  cin >> s >> t;
  if (s[0] == t[2] && t[0] == s[2] && s[1] == t[1]) YES();
  else NO();
}

Measured memory_bytes: 764
n = int(input())
N=n
p=2
d={}
ans=0
while(1):
    while(n%p==0):
        n//=p
        if d.get(p)==None:
            d[p]=1
        else:
            d[p]+=1
    if p**2>=N:
        if n!=1:
            d[n]=1
        break
    p+=1
for k,v in d.items():
    i=1
    while(1):
        v-=i
        if v>=0:
            ans+=1
            i+=1
        else:
            break
if (ans==0) and (N>1):
    print(1)
else:
    print(ans)

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

int main(){
  int n, x;
  cin >> n >> x;
  int m[n+1] = {};
  int sum = n, min_ = 1000000;
  for(int i = 0; i < n; i++){
    cin >> m[i];
    x -= m[i];
    min_ = min(min_, m[i]);
  }
  if(m > 0) sum += x / min_;
  cout << sum << endl;
  return 0;
}


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

int main(){
		int N;
		cin >> N;
		if((N%7==0 && N >6)||( N%4 == 0 && N>3)){
				cout << "Yes" << endl;
				return 0;
		}

		int s = N/7;
		int M = N;
		for(int i=0;i<14;i++){
				if(M%4 == 0 ){
					cout << "Yes" << endl;
						return 0;
				}
				if(M <= 3){break;}
				M -= 7;
		}
		cout << "No" << 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 a[100000], n, m;
ll sum[300000], sum2[300000];

int dist(int a, int b) {
	return (b + m - a) % m;
}
int dist(int a, int b, int c) {
	return min(dist(a, b), dist(c, b) + 1);
}
signed main() {
	scanf("%d%d", &n, &m);
	rep(i, n)scanf("%d", &a[i]), a[i]--;
	rep(i, n - 1) {
		if (a[i] < a[i + 1]) {
			sum[a[i] + 1]++;
			sum[a[i + 1] + 1]--;
			sum2[a[i + 1] + 1] -= a[i + 1] - a[i];
		}
		else {
			sum[a[i] + 1]++;
			sum[a[i + 1] + m + 1]--;
			sum2[a[i + 1] + m + 1] -= a[i + 1] + m - a[i];
		}
	}
	for (int i = 1; i < m * 2; i++) {
		sum[i] += sum[i - 1];
		sum2[i] += sum2[i - 1] + sum[i];
	}
	ll id = 0, Max = 0;
	rep(i, m) {
		if (sum2[i] + sum2[i + m] > Max) {
			id = i; Max = sum2[i] + sum2[i + m];
		}
	}
	ll ans = 0;
	rep(i, n - 1) {
		ans += dist(a[i], a[i + 1], id);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 4224
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)

char s[110];
int main(){
	while(1){
		int n=0;
		char c;
		while((c=getchar())!=10&&c!=-1)s[n++]=c;
		s[n]=0;
		if(s[0]=='.'&&s[1]==0)break;
		ll st[110]={},stcnt=0;
		ll flag=1;
		rep(i,0,n){
			if(s[i]=='(')st[stcnt++]=1;
			if(s[i]=='[')st[stcnt++]=2;
			if(s[i]==')'){
				if(stcnt==0||st[stcnt-1]==2){
					flag=0;
					break;
				}else stcnt--;
			}
			if(s[i]==']'){
				if(stcnt==0||st[stcnt-1]==1){
					flag=0;
					break;
				}else stcnt--;
			}
		}
		puts(flag&&stcnt==0?"yes":"no");
	}
}


Measured memory_bytes: 2032
#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 REP(i, n) for(int i = 0; i < (int)(n); i++)
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to k'th element (0-based), order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define NEWL EVAL({cout << '\n';})
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
//------------------------------------------------------------------------------------------------------

const int N = 300 + 10;

int n;
int a[N][N];

void die() {
    cout << -1 << endl;
    exit(0);
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cin >> a[i][j];
        }
    }
    LL ans = 0;
    for (int u = 1; u <= n; u++) {
        for (int v = u+1; v <= n; v++) {
            int poten = INF;
            for (int i = 1; i <= n; i++) {
                if (i == u or i == v)
                    continue;
                poten = min(poten, a[u][i] + a[i][v]);
            }
            if (a[u][v] > poten)
                die();
            if (a[u][v] < poten) {
                ans += a[u][v];
            } else {
                assert(a[u][v] == poten);
            }
        }
    }
    cout << ans << endl;
}





























Measured memory_bytes: 640
def cmb(a, b, fact, mod):
    return fact[a] * pow(fact[b], mod - 2, mod) * pow(fact[a - b], mod - 2, mod) % mod


def main():
    h, w, a, b = map(int, input().split())
    mod = 10 ** 9 + 7

    fact = [1] * (h + w + 1)
    for i in range(1, h + w + 1):
        fact[i] = (fact[i - 1] * i) % mod

    ans = 0
    for i in range(b, w):
        ans += cmb(h - a + i - 1, i, fact, mod) * cmb(w - 1 - i + a - 1, w - i - 1, fact, mod) % mod
    print(ans % mod)

if __name__ == '__main__':
    main()



Measured memory_bytes: 42604
#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,m;
    cin>>n>>m;
    vector<ll> a(n);
    priority_queue<int> pq;
    rep(i,n){
      cin>>a[i];
        pq.push(a[i]);
    }
    int cnt = 1;
    
    while(cnt<=m){
        ll max = pq.top();
        max/=2;
        pq.pop();
        pq.push(max);
        cnt++;
    }
    ll ans = 0;
    rep(i,n){
        ans += pq.top();
        pq.pop();
    }
    
    
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  string s;
  cin >> s;
  int len = sz(s);
  int ans = INF;
  rep(i,len-2) {
    int n = (s[i] - '0') * 100 + (s[i+1] - '0') * 10 + (s[i+2] - '0');
    ans = min(ans,abs(753 - n));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    int n,m,sum=0;
    cin>>n>>m;
    vll a(m);
    rep(i,m){
        cin>>a.at(i);
        sum+=a.at(i);
    }
    if(sum>n)cout<<-1<<endl;
    else cout<<n-sum<<endl;
    
    
}
   



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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int64_t rs64() {
	int64_t n;
	scanf("%" SCNd64, &n);
	return n;
}
#define EPS 1e-8
bool enclosed(int x, int y, double cx, double cy, double r) {
	return std::hypot(cx - x, cy - y) <= r + EPS;
}

int main() {
	int n = ri();
	int x[n], y[n];
	for (int i = 0; i < n; i++) x[i] = ri(), y[i] = ri();
	
	double res = 1e5;
	// two
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) continue;
			double cx = (double) (x[i] + x[j]) / 2;
			double cy = (double) (y[i] + y[j]) / 2;
			double r = std::hypot(x[i] - x[j], y[i] - y[j]) / 2;
			bool ok = true;
			for (int k = 0; k < n; k++) if (!enclosed(x[k], y[k], cx, cy, r)) ok = false;
			if (ok) res = std::min(res, r);
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) continue;
			double ccx = (double) (x[i] + x[j]) / 2;
			double ccy = (double) (y[i] + y[j]) / 2;
			double vecx = y[i] - y[j];
			double vecy = x[j] - x[i];
			for (int k = 0; k < n; k++) {
				if (i == k || j == k) continue;
				double l = -100000, r = 1000000;
				auto ok = [&] (double m, int k) {
					double cx = ccx + vecx * m;
					double cy = ccy + vecy * m;
					double r = std::hypot(x[i] - cx, y[i] - cy);
					return enclosed(x[k], y[k], cx, cy, r);
				};
				bool reverse = ok(l, k);
				for (int _ = 0; _ < 100; _++) {
					double m = (l + r) / 2;
					bool cur = ok(m, k);
					if (reverse) {
						if (cur) l = m;
						else r = m;
					} else {
						if (cur) r = m;
						else l = m;
					}
				}
				double opt = l;
				std::cerr << "i:" << i << " j:" << j << " k:" << k << " : " << opt << std::endl;
				bool cont = true;
				for (int l = 0; l < n; l++) {
					if (!ok(opt, l)) cont = false;
				}
				if (cont) {
					double cx = ccx + vecx * opt;
					double cy = ccy + vecy * opt;
					double r = std::hypot(x[i] - cx, y[i] - cy);
					res = std::min(res, r);
				}
			}
		}
	}
	printf("%.11f\n", res);
	return 0;
}


Measured memory_bytes: 256
# encoding: utf-8
N = int(input())
h = list(map(int, input().split()))

# TODO: check question C of ABC 04? (03?)

def mysub(a, b): return a - b if a > b else b - a

tab = [0] * N
for i in range(1, N):
    if i == 1:
        tab[i] = mysub(h[1], h[0])
    else:
        tab[i] = min([tab[i - 1] + mysub(h[i], h[i - 1]) # +1
                      ,tab[i - 2] + mysub(h[i], h[i - 2])]) # +2

print(tab[-1])


Measured memory_bytes: 13980
import collections
N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

cnt = collections.Counter(prime_factorize(N))
ans = 0
# print(cnt)
for val in cnt.values():
    # print(val)1
    m = 1
    while m*(m+1)//2 <= val:
        m += 1
    ans += m-1

print(ans)

Measured memory_bytes: 9368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N; cin >> N;
  vector<ll> A(N); rep(i,N) cin >> A[i];
  vector<ll> ss(N+1,0);
  rep(i,N) ss[i+1] = ss[i] + A[i];
  vector<ll> xs(N+1,0);
  rep(i,N) xs[i+1] = xs[i] ^ A[i];

  ll ans = 0;
  int r=1;
  for(int l=0;l<N;l++){
    ll p = ss[r]-ss[l];
    ll x = xs[r]^xs[l];
    //cout << l << " " << r << " " << p << " " << x << endl;
    for(;r<=N;r++){
      if(r==N){
        ll w = r-l;
        ans += w*(w+1)/2;
        l=1e9;
        break;
      }
      p += A[r];
      x ^= A[r];
      if(p!=x){
        ll w = r-l;
        ans += w;
        break;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


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

#define ll long long

using namespace std;

int main()
{
	int n;
	cin >> n;
	ll last=0,sum=0;
	for(int i = 0; i < n; i++)
	{
		ll ai;
		cin >> ai;
		sum += max(0ll, last-ai);
		last=max(last,ai);
	}
	cout << sum << endl;
}


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

int main() {
    char c;
    cin >> c;

    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
         cout << "vowel" << endl;
    else cout << "consonant" << endl;
}


Measured memory_bytes: 3640
#include<stdio.h>
#include<string.h>
int main(){
    int n,i;
    char s[10000];
    
    scanf("%d",&n);
    scanf("%s",s);
    
    for(i = 0; i < strlen(s); i++){
        if(s[i] + n > 90){
            s[i] = s[i]+n-26;
            printf("%c",s[i]);
        }else{
            s[i] = s[i] + n;
            printf("%c",s[i]);
        }
    }
    printf("\n");
    return 0;
}


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

int main(){
  long long int n;
  cin>>n;
  long long int a=2;
  long long int b=1;
  long long int c=0;
  for(int i=0;i<n-1;i++){
      c=a+b;
      a=b;
      b=c;
    }
    if(n==1) cout<<"1"<<endl;
    else cout<<c<<endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

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

    if(S == "Sunny"){
        cout << "Cloudy" << endl;
    } else if(S == "Cloudy"){
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N=gets.chomp.to_i
A=gets.chomp.split.map(&:to_i)
B=gets.chomp.split.map(&:to_i)
C=gets.chomp.split.map(&:to_i)

diff_a = []
(A.size-1).times do |i|
  diff_a << [A[i+1] - A[i],A[i]]
end

b_sum = B.inject(&:+)
diff_one_index = diff_a.select{|a| a.first == 1}.map(&:last)

additional = 0
diff_one_index.each do |n|
  additional += C[n-1]
end

puts b_sum+additional

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct UnionFind {
    UnionFind(int n) {
        rank.assign(n, 0);
        parent.resize(n);
        num.resize(n);
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
            num[i] = 1;
        }
    }

    int find(int x) {
        if (x == parent[x])
            return x;
        return parent[x] = find(parent[x]);
    }

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

    void unit(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;

        if (rank[x] < rank[y]) {
            parent[x] = y;
        }
        else {
            parent[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
        ll n = num[x] + num[y];
        num[x] = num[y] = n;
    }

    vector<int> rank;
    vector<int> parent;
    vector<int> num;
};

pll A[100005];

int main() {
    ll N, M;
    cin >> N >> M;
    REP(i, M) {
        cin >> A[i].first >> A[i].second;
        A[i].first--;
        A[i].second--;
    }

    UnionFind uf(N);
    vector<ll> ans;
    ll t = N * (N - 1) / 2;
    for (int i = M - 1; i >= 0; --i) {
        ans.push_back(t);
        if (uf.same(A[i].first, A[i].second)) {
            continue;
        }
        ll n = uf.num[uf.find(A[i].first)];
        ll m = uf.num[uf.find(A[i].second)];
        t -= n * m;
        uf.unit(A[i].first, A[i].second);
    }

    for (int i = ans.size() - 1; i >= 0; --i) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4980
import math

while True:
    m, n = map(int, input().split())
    
    if m==0 and n==0:
        break
    
    num = pow(m, n)
    
    A = []
    a = num//pow(10, 68)
    A.append(a)
    b = num%pow(10, 68)
    
    a = b//pow(10, 64)
    A.append(a)
    b = b%pow(10, 64)
    
    a = b//pow(10, 60)
    A.append(a)
    b = b%pow(10, 60)
    
    a = b//pow(10, 56)
    A.append(a)
    b = b%pow(10, 56)
    
    a = b//pow(10, 52)
    A.append(a)
    b = b%pow(10, 52)
    
    a = b//pow(10, 48)
    A.append(a)
    b = b%pow(10, 48)
    
    a = b//pow(10, 44)
    A.append(a)
    b = b%pow(10, 44)
    
    a = b//pow(10, 40)
    A.append(a)
    b = b%pow(10, 40)
    
    a = b//pow(10, 36)
    A.append(a)
    b = b%pow(10, 36)
    
    a = b//pow(10, 32)
    A.append(a)
    b = b%pow(10, 32)
    
    a = b//pow(10, 28)
    A.append(a)
    b = b%pow(10, 28)
    
    a = b//pow(10, 24)
    A.append(a)
    b = b%pow(10, 24)
    
    a = b//pow(10, 20)
    A.append(a)
    b = b%pow(10, 20)
    
    a = b//pow(10, 16)
    A.append(a)
    b = b%pow(10, 16)
    
    a = b//pow(10, 12)
    A.append(a)
    b = b%pow(10, 12)
    
    a = b//pow(10, 8)
    A.append(a)
    b = b%pow(10, 8)
    
    a = b//pow(10, 4)
    A.append(a)
    b = b%pow(10, 4)
    A.append(b)
    
    LIST = ['Mts','Fks','Nyt','Asg','Ggs','Gok','Sai','Sei',
            'Kan','Ko','Jou','Jo','Gai','Kei','Cho','Oku','Man','']
    
    for i in range(len(A)):
        if A[i]==0:
            print(end='')
        else:
            print(A[i],end='')
            print(LIST[i],end='')
    
    print('')


Measured memory_bytes: 5692
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
if x==12 or x==11 or x==2 or y==2:print('No')
elif x in a and y in a or x in b and y in b: print('Yes')
else: print('No')

Measured memory_bytes: 3060
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

#define NMAX 500010

struct QUARR{
    int l;
    int r;
    int index;
    int type;
    int ans;
    bool operator<(QUARR q) const{
        if(type==1){
            if(q.r==r) return q.l>l;
            return q.r>r;
        }
        else{
            return q.index>index;
        }
    }
};

int ft_bit[NMAX];
void ft_add(int a,int w,int N){
    for(int x=a;x<=N;x+=x&-x){
        ft_bit[x]+=w;
    }
}

int ft_sum(int a){
    int ret=0;
    for(int x=a;x>0;x-=x&-x){
        ret+=ft_bit[x];
    }
    return ret;
}

signed main(){
    QUARR qu[NMAX];
    int last[NMAX];
    int c[NMAX];
    int N,Q;

    cin>>N>>Q;
    for(int i=1;i<=N;i++){
        cin>>c[i];
        last[i]=-1;
    }

    for(int i=1;i<=Q;i++){
        int l,r;
        cin>>l>>r;
        qu[i].l=l;
        qu[i].r=r;
        qu[i].index=i;
        qu[i].type=1;
        qu[i].ans=0;
    }

    sort(qu+1,qu+Q+1);

    for(int i=1;i<=qu[1].r;i++){
        if(last[c[i]]==-1){
            ft_add(i,1,N);
            last[c[i]]=i;
        }
        else{
            ft_add(last[c[i]],-1,N);
            ft_add(i,1,N);
            last[c[i]]=i;
        }
    }

    qu[1].ans=ft_sum(qu[1].r)-ft_sum(qu[1].l-1);
    qu[1].type=2;
    for(int i=2;i<=Q;i++){
        for(int j=qu[i-1].r+1;j<=qu[i].r;j++){
            if(last[c[j]]==-1){
                ft_add(j,1,N);
                last[c[j]]=j;
            }
            else{
                ft_add(last[c[j]],-1,N);
                ft_add(j,1,N);
                last[c[j]]=j;
            }
        }
        qu[i].ans=ft_sum(qu[i].r)-ft_sum(qu[i].l-1);
        qu[i].type=2;
    }

    sort(qu+1,qu+Q+1);

    for(int i=1;i<=Q;i++){
        cout<<qu[i].ans<<"\n";
    }
}


Measured memory_bytes: 35084
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        String T = scan.next();
        int A = scan.nextInt();
        int B = scan.nextInt();
        String U = scan.next();
        if (S.equals(U)) {
            A -= 1;
        } else {
            B -= 1;
        }
        System.out.printf("%d %d\n", A, B);
    }
}


Measured memory_bytes: 23124
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n=int(input())
a=list(map(int,stdin.readline().split()))
total=0
for i in a:
    total=total^i 
for i in range(n):
    a[i]=total^a[i]
print(*a)

Measured memory_bytes: 31836
#include<stdio.h>
 
int m[101][101];
 
void matrixChain(int n, int *p){
  int i,j,k,l;
   
  for(i=1; i<n+1; i++){
    m[i][i]=0;
  }
  for(l=2; l<n+1; l++){
    for(i=1; i<n-l+2; i++){
      j=i+l-1;
      m[i][j]=100000000;
      for(k=i; k<j; k++){
    if(m[i][j]>m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]){
      m[i][j]=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
    }
      }
    }
  }
}
 
int main(){
  int i,p[101],n;
  scanf("%d", &n);
  for(i=1; i<n+1; i++){
    scanf("%d%d", &p[i-1], &p[i]);
  }
  matrixChain(n,p);
  printf("%d\n", m[1][n]);
   
  return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

const int MOD = 1000000007;

const int MAX_N = 2000010;
long long fac[MAX_N + 1], finv[MAX_N + 1];

struct init_fac {
    long long mod_inv(long long a, long long m) {   // gcd(a, m) = 1
        long long b = m, x = 1, y = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(x -= t * y, y);
        }
        x = (x % m + m) % m;
        return x;
    }

    init_fac() {
        fac[0] = 1;
        for (int i = 1; i <= MAX_N; ++i) fac[i] = i * fac[i - 1] % MOD;
        finv[MAX_N] = mod_inv(fac[MAX_N], MOD);
        for (int i = MAX_N - 1; i >= 0; --i) finv[i] = (i + 1) * finv[i + 1] % MOD;
    }
} init_fac;

long long nPk(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return fac[n] * finv[n - k] % MOD;
}

long long nCk(int n, int k) {
    if (n < k || n < 0 || k < 0) return 0;
    return nPk(n, k) * finv[k] % MOD;
}

long long nHk(int n, int k) {
    if (n < 0 || k < 0) return 0;
    return nCk(n + k - 1, k);
}

void _main() {
    int X, Y;
    cin >> X >> Y;
    if ((-X + 2 * Y) % 3 != 0 || (2 * X - Y) % 3 != 0) {
        cout << 0 << endl;
        return;
    }
    int a = (-X + 2 * Y) / 3, b = (2 * X - Y) / 3;
    cout << nCk(a + b, a) << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 31488
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
int mod(ll a){
    int c=a%1000000007;
    if(c>=0)return c;
    else return c+1000000007;
}
typedef pair<int,int> i_i;

#define NIL -1
int n;
int f(int a){
    int c=a%n;
    if(c>0)return c;
    else return n+c;
}

int main(){
    cin>>n;
    ll a[n+2];for(int i=1;i<=n;i++)cin>>a[i];
    ll dp[n+1][n+1];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i==j)dp[i][j]=a[i];
            else if(f(j-i+1)==n)dp[i][j]=0;
            else dp[i][j]=NIL;
        }
    }
    for(int len=2;len<=n-1;len++){
        for(int i=1;i<=n;i++){
            int j=f(i+len-1);
            ll max1,max2;
            if(a[f(i+1)]>a[j])max1=dp[f(i+2)][j]+a[i];
            else max1=dp[f(i+1)][f(j-1)]+a[i];
            if(a[i]>a[f(j-1)])max2=dp[f(i+1)][f(j-1)]+a[j];
            else max2=dp[i][f(j-2)]+a[j];
            dp[i][j]=max(max1,max2);
        }
    }
    
    ll max=0,ans=0;
    for(int i=1;i<=n;i++){
        ans=a[i];
        if(a[f(i+1)]>a[f(i-1)])ans+=dp[f(i+2)][f(i-1)];
        else ans+=dp[f(i+1)][f(i-2)];
        if(max<ans)max=ans;
        
    }
    cout<<max<<endl;
    return 0;
}



Measured memory_bytes: 34344
#include <bits/stdc++.h> 
#define ll long long
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define F first
#define S second
#define mp make_pair
#define PII pair<int,int>
#define PLL pair<long long,long long>
#define pq priority_queue
#define M map
#define UM unordered_map
#define graph unordered_map<int,vector<int>>
#define graphw unordered_map<int,vector<pair<int,int>>>
#define V vector
#define mod 1000000007
#define inf 3000000000000000007ll
#define P pair
#define Fast ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(), a.rend()
#define sz(a) signed(a.size())
#define FIXED cout << fixed << setprecision(12)
#define L list
#define D deque
#define ld long double
using namespace std;
// pair operation
template<class T, class U>istream& operator>>(istream& in, pair<T,U> &rhs){in >> rhs.first;in >> rhs.second;return in;}
template<class T, class U>ostream& operator<<(ostream& out,const pair<T,U> &rhs){out << rhs.first;out << " ";out << rhs.second;return out;}
template<class T, class U>pair<T,U> operator+(pair<T,U> &a, pair<T,U> &b){return pair<T,U>(a.first+b.first,a.second+b.second);}
template<class T, class U>pair<T,U> operator-(pair<T,U> &a, pair<T,U> &b){return pair<T,U>(a.first-b.first,a.second-b.second);}
// Linear STL
// VECTOR
template<class T>istream& operator>>(istream& in, vector<T> &a){for(auto &i: a)cin >> i;return in;}
template<class T>ostream& operator<<(ostream& out, const vector<T> &a){for(auto &i: a)cout << i << " ";return out;}
// SET
template<class T>ostream& operator<<(ostream& out, const set<T> &a){for(auto &i: a)cout << i << " ";return out;}
template<class T>ostream& operator<<(ostream& out, const unordered_set<T> &a){for(auto &i: a)cout << i << " ";return out;}
template<class T>ostream& operator<<(ostream& out, const multiset<T> &a){for(auto &i: a)cout << i << " ";return out;}
// MAP
template<class T,class U>ostream& operator<<(ostream& out, const map<T,U> &a){for(auto &i: a)cout << "(" << i.first << ", " << i.second << "(\n";return out;}
template<class T,class U>ostream& operator<<(ostream& out, const unordered_map<T,U> &a){for(auto &i: a)cout << "(" << i.first << ", " << i.second << "(\n";return out;}

int main() {
    Fast;
    int t=1;
    // cin>>t;
    while(t--){
        int n,x,y;
        cin>>n>>x>>y;
        V<int> g[n+10];
        if(x>y)swap(x,y);
        for(int i=1;i<n;i++){
            g[i].pb(i+1);
            g[i+1].pb(i);
        }
        g[x].pb(y);
        g[y].pb(x);
        V<int> ans(n+10);
        for(int i=1;i<=n;i++){
            queue<int> q;
            q.push(i);
            UM<int,int> dis;
            dis[i]=0;
            while(!q.empty()){
                auto x=q.front();
                q.pop();
                for(auto i:g[x]){
                    if(!dis.count(i)){
                        q.push(i);
                        dis[i]=dis[x]+1;
                        ans[dis[i]]++;
                    }
                }
            }
        }
        for(int i=1;i<n;i++){
            cout<<ans[i]/2<<endl;
        }
    }
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
  int n, map[1001][5], mp, mq, mr, mc, i, f;
  while(scanf("%d", &n) && n){
    for(i = 0; i < n; ++i){
      scanf("%d%d%d%d", &map[i][0], &map[i][1], &map[i][2], &map[i][3]);
      map[i][4] = map[i][1] * 4 + map[i][2] * 9 + map[i][3] * 4;
    }

    scanf("%d%d%d%d", &mp, &mq, &mr, &mc);
    f = 0;
    for(i = 0; i < n; ++i){
      if(map[i][1] <= mp && map[i][2] <= mq && map[i][3] <= mr && map[i][4] <= mc){
	printf("%d\n", map[i][0]);
	f = 1;
      }
    }
    if(!f) puts("NA");
  }
  return 0;
}

Measured memory_bytes: 632
#include <iostream>

using namespace std;

int main(){
    int h;
    int r;
    cin >> h >> r;
    if((h + r) > 0){
        cout << "1" << endl;
    }
    else if((h + r) < 0){
        cout << "-1" << endl;
    }
    else{
        cout << "0" << endl;
    }
}


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

const ll mod = 1e9+7;

ll n, ans, ten[15] = {1}, sum[15];

ll calc (ll X) {
	if(X <= 10) return ten[X] % mod;
	ll R = calc(X/2);
	R = R * R % mod;
	if(X&1) R = R * 10 % mod;
	return R;
}

int main()
{
	scanf("%lld",&n);
	for(ll i=1;i<=16;i++) {
		ten[i] = ten[i-1] * 10;
	}
	for(ll i=1;i<=n;i++) {
		ll X = n/i, Y = n%i;
		if(X < 10 && i >= ten[X+1]) break;
		if(X < 10 && (i-Y > ten[X]-ten[X-1] || Y > ten[X+1]-ten[X])) continue;
		if(Y) ans = (ans + 1) % mod;
		else ans = (ans + calc(X) + mod - calc(X-1) + 1 + mod - i) % mod;
	}
	for(ll i=2;i<10;i++) {
		sum[i] = (ten[i] - ten[i-1]) * i;
	}
	for(ll i=2;;i++) {
		if(sum[i] > n) break;
		ll X;
		for(ll j=1;j<=ten[i-1]-ten[i-2];j++) {
			X = j * (i-1);
			for(ll k=i;;k++) {
				X += sum[k];
				if(X >= n) break;
				if((n-X)%(k+1)==0 && (n-X)/(k+1) <= ten[k+1]-ten[k]) ans++;
			}
		}
		ans %= mod;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 384