akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <climits>
#include <numeric>
using namespace std;
using ll = long long;
int main() {
  int k;
  cin >> k;
  ll sum = 0;
  for (int a = 1; a <= k; a++)
    for (int b = 1; b <= k; b++)
      for (int c = 1; c <= k; c++) {
        sum += gcd(a,gcd(b,c));
      }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3180
// Author := Abhishek Giri

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define V(type) vector<(type)>
#define in(var) cin>>(var)
#define out(var) cout<<(var)
#define on(var) cout<<var<<"\n"
#define f(i,n) for(ll i = 0 ; i < n ;i++)
#define mfor(i,init,n,b) for(ll i = (init) ; i < (n) ; i+= (b))
#define cfor(i,c) for(auto i = (c).begin() ; i!= (c).end(); i++)
#define el "\n"
#define ret return
#define F first
#define S second
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define all(v) (v).begin(),(v).end()

/*##################################################################################*/


/*bool prime[100000] ;
vector < int > pr;
void calculateprime()
{
    prime[0] = prime[1] = true;
    for(int i = 2 ; i <= 100000 ; i++)
    {
        if(prime[i] == false)
        {
            pr.pb(i);
            for(ll j = i*i ; j <= 100000 ; j += i )
            {
                prime[j] = true;
            }
        }
    }
}
*/


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

void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

ll powerwithmod(ll x, unsigned ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0) return 0;

    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;

        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}


bool comp(const pair < ll , ll >  &a, const pair < ll , ll > &b ){
    if(a.F == b.F) return a.S < b.S;
    return a.F > b.F;
}

void solve();

int main() {
    clock_t begin = clock();

    fast();
    customrun();
    ll t = 1;
    //cin>>t;
    //calculateprime();
    mfor(i,1,t+1,1)
    {
        //cout<<"Case #"<<i<<": \n";
        solve();
    }
    clock_t end = clock();
    double time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
    //cout<<"\ntime spent is "<<time_spent;
    return 0;
}


void solve(){
    int n;
    in(n);

    mfor(i,1,10,1){
        if(n % i == 0){
            if( (n/i) >= 1 and (n/i) <= 9){
                out("Yes");
                ret;
            }
        }
    }

    out("No");
}


Measured memory_bytes: 3580
n = int(input())
arr = list(map(int,input().split()))
if 0 in arr:
    print(0)
else:
    res = 1
    flag = 0
    for i in arr:
        res = res*i
        if res>10**18:
            flag = 1
            break
    if flag==1:
        print(-1)
    else:
        print(res)


Measured memory_bytes: 84632
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	lint N, A, B;
	cin >> N >> A >> B;
	lint ans1 = N / (A + B)*A;
	lint ans2;
	if (A < N % (A + B)) {
		ans2 = A;
	}
	else {
		ans2 = N % (A + B);
	}
	cout << ans1+ans2 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 998244353;


ll N,A[100005],B[100005],C[100005],ans=1;


ll gcd(ll a, ll b) {
	if (b > a)swap(a, b);
	if (b == 0)return a;
	while (1) {
		if (a%b == 0)break;
		ll u = a;a = b;b = u%b;
	}
	return b;
}

int main() {
	cin >> N;
	FOR(i, 1, N+1)cin >> A[i];
	FOR(i, 1, N+1) {
		B[i] = gcd(B[i - 1], A[i]);
		C[N + 1 - i] = gcd(C[N + 2 - i],A[N+1 - i]);

	}

	FOR(i, 1, N+1) {
		ans = max(ans, gcd(B[i - 1], C[i + 1]));

	}


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

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <queue>
#include <vector>
#include <set>


using namespace std;
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

template<class T> inline bool chmin(T& a, T b) {
  //aの方が大きければ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;
}
bool compare_a_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが小さい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second < r.second;
  }
}
bool compare_a_b_big(pair<int,int> l,pair<int,int> r){
  //firstが大きい方からソート、firstが同じならbが大きい方から
  if(l.first != r.first){
    return l.first>r.first;
  }
  else{
    return l.second > r.second;
  }
}
bool compare_b_small(pair<int,int> l,pair<int,int> r){
  //secondが小さい方からソート、firstが同じならfirstが小さい方から
  if(l.second != r.second){
    return l.second<r.second;
  }
  else{
    return l.first < r.first;
  }
}
const int INF = 1e9;
const int M = 1000000007;


typedef long long int ll;
vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算、a,b<=300000でないと使えない
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<300000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

typedef long long int ll;

int pow(int a,int b){
  if(b==0) return 1;
  else{
    return a*pow(a,b-1);

  }
}

typedef struct ListNode {
    int data;
    struct ListNode *next;
} ListNode;



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

  cout << !x << endl;



}


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

int main() {
  int N, cnt = 0;
  cin >> N;
  
  vector<int> d(N);
  for(int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  
  sort(d.begin(), d.end());
  for(int i = 0; i < N-1; i++) {
    if(d.at(i) == d.at(i+1)) {
      d.at(i) = 0;
    }
  }
  
  for(int i = 0; i < N; i++) {
    if(d.at(i) != 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <numeric>
 
using namespace std;

int main(void) {
    int ae[5];
    int min = 10;
    int sum = 0;
    for(int i = 0; i < 5; i++){
        cin >> ae[i];
        int temp = ae[i]%10;
        ae[i] = ae[i]/10;
        if(temp != 0){
            if(temp < min){
                min = temp;
            }
            ae[i]++;
        }
        sum = sum + ae[i];
    }
    sum = (sum-1)*10 + min;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
ss = []
h = {}
('a'..'z').each do |c|
  h[c] = []
end
n.times do 
  ss.push gets.chomp
end
ss.each do |s|
  z = {}
  ('a'..'z').each do |c|
    z[c] = 0
  end
  s.split('').each do |c|
    z[c] += 1
  end
  z.each do |k, v|
    h[k].push(v)
  end
end
r = ''
('a'..'z').each do |c|
  h[c].min.times do
    r += c
  end
end
puts r 

Measured memory_bytes: 1916
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main() {
    int N, M; cin >> N >> M;
    vector<long long> A(N);
    for(int i=0; i < N; i++) cin >> A[i];

    map<long long, long long> nums;
    long long sum = 0;
    nums[sum]++;

    for(int i=0; i < N; i++) {
        sum += A[i];
        nums[sum % M]++;
    }

    long long ans = 0;
    for(map<long long, long long>::iterator it=nums.begin(); it != nums.end(); it++) {
        ans += it->second * (it->second - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 4992
n=int(input())
#a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
def f(x,y,z):
    return x**2 + y**2 +z**2 +x*y+y*z+z*x
dic={}
for i in range(1,n+1):
    dic[i]=0
for x in range(1,101):
    for y in range(1,100):
        for z in range(1,100):
            if f(x,y,z)<=n:
                dic[f(x,y,z)]=dic.get(f(x,y,z),0)+1
for i in range(1,n+1):
    print(dic[i])

Measured memory_bytes: 9632
#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,k;
    cin >> n >> k;
    vector<int64> h(n);
    for (int i=0; i<n; i++) cin >> h[i];
    sort(h.rbegin(), h.rend());

    if (n <= k) {
        cout << 0 << endl;
        return 0;
    }

    int64 ans = accumulate(h.begin()+k, h.end(), 0LL);
    cout << ans << endl;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N;
int a[300010];
ll ret;

int main() {
	cin >> N;
	N *= 3;

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

	int cnt = 0;
	for (int i = N-2; i >= 0; i -= 2) {
		ret += a[i];
		++cnt;
		if (cnt == N / 3) {
			break;
		}
	}
	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h> 
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
const long long int m=pow(10,9)+7;

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,d,e,n;
    ll F[20][20] = {0};
    ll ans=0;
    cin>>n;
    for(int c1=0;c1<n;c1++)
    {
        ld x;
        cin >> x;
        a = round(x*1000000000.0);
        b = 0;
        c = 0;
        while(a%5 == 0){
            b++;
            a /= 5;
        }
        while(a%2 == 0){
            c++;
            a /= 2;
        }
        c = min(19ll, c);
        for(int c2=0;c2<20;c2++)
        {
            for(int c3=0;c3<20;c3++)
            {
                if(b+c2 >= 18 && c+c3 >= 18)
                    ans+=F[c2][c3];
            }
        }
        F[b][c]++;
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3768
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""

input:
6
1 2 2 3
2 2 3 4
3 1 5
4 1 6
5 1 6
6 0

output:
1 1 12
2 2 11
3 3 8
4 9 10
5 4 7
6 5 6

"""
import sys

UNVISITED, VISITED_IN_STACK, POPPED_OUT = 0, 1, 2


def dfs(v_init):
    global timer

    # init the first node of overall graph iterations(times >= 1)
    stack = list()
    stack.append(v_init)
    d_time[v_init] += timer
    # init end

    while stack:
        current = stack[-1]
        v_table = adj_table[current]
        visited[current] = VISITED_IN_STACK
        # if adj is None, current's adj(s) have been all visited
        adj = v_table.pop() if v_table else None

        if adj:
            if visited[adj] is UNVISITED:
                visited[adj] = VISITED_IN_STACK
                timer += 1
                d_time[adj] += timer
                stack.append(adj)
        else:
            stack.pop()
            visited[current] = POPPED_OUT
            timer += 1
            f_time[current] += timer

    return None


def dfs_init():
    global timer
    for v in range(v_num):
        if visited[v + 1] == UNVISITED:
            dfs(v + 1)
            timer += 1


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    v_num = int(_input[0])
    vertices = map(lambda x: x.split(), _input[1:])

    # config length = (v_num + 1)
    # stack = []
    visited = [UNVISITED] * (v_num + 1)
    d_time, f_time = ([0] * (v_num + 1) for _ in range(2))
    adj_table = tuple([] for _ in range(v_num + 1))
    for v_info in vertices:
        v_index, adj_num, *adj_list = map(int, v_info)
        # assert len(adj_list) == adj_num
        adj_table[v_index].extend(sorted(adj_list, reverse=True))

    # timing start from 1
    timer = 1
    dfs_init()

    for index, time_info in enumerate(zip(d_time[1:], f_time[1:]), 1):
        print(index, *time_info)

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

#ifdef ONLINE_JUDGE
#define lld I64
#endif

#define endl '\n'
#define ii pair<int,int>
#define ll long long
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define add push_back

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

    int n, ma, mb;
    scanf("%d", &n);
    vi a(n), b(n);
    for(int i=0; i<n; ++i) scanf("%d %d", &a[i], &b[i]);
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    
    if(n&1){
        ma = a[n/2];
        mb = b[n/2];
    }else{
        ma = a[n/2-1] + a[n/2];
        mb = b[n/2-1] + b[n/2];
    }

    printf("%d\n", mb-ma+1);

    return 0;
}


Measured memory_bytes: 4848
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9;

int N;
int a[200010];
int mx;
int main(){
    cin>>N;
    REP(i,0,N){
        cin>>a[i];
        mx = max(mx,a[i]);
    }
    double b = mx/2.0;
    int mn=inf;
    int ans = 0;
    REP(i,0,N){
        if(mx==a[i]) continue;
        if(mn>abs(a[i]-b)){
            ans=a[i];
            mn=abs(a[i]-b);
        }
    }
    cout<<mx<<" "<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
  char buf[32] = { 0 };
  int N,Y;

  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d %d", &N, &Y);

  int Z = Y - 1000 * N;
  int x = 0;
  int y = 0;
  int flag = 0;
  while(Z >= 0){
    if(Z % 4000 == 0){
      y = Z / 4000;
      if(N - x - y >= 0){
      	flag = 1;
      	break;
      }
    }
    x++;
    Z -= 9000;
  }
  if(flag) printf("%d %d %d\n", x, y, N - x - y);
  else printf("-1 -1 -1\n");
  return 0;
}

Measured memory_bytes: 1700
/******

AUTHOR : RUDRANSH TRIPATHI, IIIT NAGPUR, CCID(rt24) & CFID(rsgt24)

MOTTO : Use criticism as fuel and you will never run out of energy.
        AIM : TO BECOME A BETTER CODER
        INTROSPECT + COURSE CORRECTIONS = CATALYST FOR SUCCESS
        Every moment is an opportunity to better yourself

*******/

#include<bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
const int MAX = 1e5 + 5;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define pb push_back
#define d(x) cout<<x<<"\n"

//basic mathematics
int gcd(int a, int b)
{
	if (a == 0)
		return b;
	return gcd(b % a, a);
}
int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}

//modular arithmetic
int powermod(int x, int y, int p)
{
	int res = 1;

	x = x % p;

	if (x == 0) return 0;

	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % p;
		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

//Prime numbers till n precomputation - range query
int prefix[MAX + 1];

void buildPrefix()
{
	bool prime[MAX + 1];
	memset(prime, true, sizeof(prime));

	for (int p = 2; p * p <= MAX; p++) {
		if (prime[p] == true) {
			for (int i = p * 2; i <= MAX; i += p)
				prime[i] = false;
		}
	}
	prefix[0] = prefix[1] = 0;
	for (int p = 2; p <= MAX; p++) {
		prefix[p] = prefix[p - 1];
		if (prime[p])
			prefix[p]++;
	}
}

int query(int L, int R)
{
	return prefix[R] - prefix[L - 1];
}


//Find all paths from a to b in an undirected graph
vector<int> g[MAX];
int visited[MAX];
//count of all the paths from 1 to n;

void dfs(int visited[MAX], int u, int v, vector<int> path)
{
	visited[u] = 1;
	if (u == v)
	{
		for (int i = 0; i < path.size(); i++)
		{
			cout << path[i] << " ";
		}
		cout << "\n";
	}
	else
	{
		for (int i = 0; i < g[u].size(); i++)
		{
			int y = g[u][i];

			if (visited[y] == 0)
			{
				visited[y] = 1;
				path.pb(y);
				dfs(visited, y, v, path);
				path.pop_back();
			}

		}
	}

	visited[u] = 0;

}

void solve()
{
	int n;
	cin >> n ;
	int arr[n];

	for (int i = 0; i < n; i++)
		cin >> arr[i];
		
    int suffix_sum = arr[n - 1]; 
    int res = 0; 
    for (int i = n - 2; i >= 0; i--)  
    { 
  
        res += (suffix_sum%M * arr[i]%M)%M; 
        suffix_sum += arr[i]%M; 
    } 
    
    cout<<res%M<<"\n";
}

int32_t main(void)
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 7480
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

constexpr ll MOD = 1000000007LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par.resize( n ); siz.resize( n ); par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T power( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}

/*
constexpr ll MAX = 500010;
ll fact[MAX];
ll inv[MAX];
ll inv_fact[MAX];

template<typename T> void initComb( T n, T m = MOD )
{
	fact[0] = fact[1] = inv_fact[0] = inv_fact[1] = 1;
	inv[1] = 1;
	for ( int i = 2; i < n; i++ ) {
		fact[i] = ( fact[i - 1] * i ) % m;
		inv[i] = m - inv[m % i] * ( m / i ) % m;
		inv_fact[i] = inv_fact[i - 1] * inv[i] % m;
	}
}

template<typename T> T comb( T n, T r, T m = MOD )
{
	if ( n < r ) return ( 0 );
	if ( n < 0 || r < 0 ) return ( 0 );
	return ( fact[n] * ( inv_fact[r] * inv_fact[n - r] % m ) % m );
}
*/

void replace( string &s, string t, string r ) {
	string::size_type p = 0;
	while ( ( p = s.find( t, p ) ) != string::npos ) {
		s.replace( p, t.length(), r );
		p += r.length();
	}
}


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

	vector<string> v( N );
	rep( i, N ) cin >> v[i];

	map<char, ll> m;
	rep( i, N )
	{
		m[v[i][0]]++;
	}

	ll total = 0;
	const char ccc[] = { 'M', 'A', 'R', 'C', 'H' };
	for ( int i = 0; i < 3; i++ )
	{
		for ( int j = i + 1; j < 5; j++ )
		{
			for ( int k = j + 1; k < 5; k++ )
			{
				total += m[ccc[i]] * m[ccc[j]] * m[ccc[k]];
			}
		}
	}

	cout << total << endl;

	return ( 0 );
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int N,i,ans;
    int *a;

    scanf("%d",&N);
    a=malloc(sizeof(int)*N);
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
    ans=0;
    for(i=0;i<N;i++){
        if(a[i]>i+1){
            if(a[a[i]-1]==i+1){
                ans++;
            }
        }
    }

    printf("%d",ans);
    return 0;
}

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

int main()
{
    int a;
    int b;
    cin >> a >> b;
    int c = b - a;
    int f[1005];
    f[1] = 1;
    for(int i = 2; i <= 999; i++)
    {
        f[i] = f[i-1] + i;

    }

    cout << f[c] - b;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        new Main().run();
    }
	int[][] cost;
	boolean[] visit;
	int[] dist;
	int n;
	int def = Integer.MAX_VALUE;
	public void run(){
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			n = scan.nextInt();
			int k = scan.nextInt();
			if(n == 0 && k == 0){
				break;
			}
			cost = new int[n][n];
			for(int i = 0;i < n;i++){
				Arrays.fill(cost[i],def);
			}
			dist = new int[n];
			visit = new boolean[n];
			for(int i = 0;i < k;i++){
				int m = scan.nextInt();
				if(m == 0){
					int a = scan.nextInt() - 1;
					int b = scan.nextInt() - 1;
					Arrays.fill(visit, false);
					Arrays.fill(dist,def);
					dijkstra(a);
					System.out.println((dist[b] == def)?-1:dist[b]);
				}else{
					int c = scan.nextInt() - 1;
					int d = scan.nextInt() - 1;
					int e = scan.nextInt();
					cost[c][d] = Math.min(cost[c][d],e);
					cost[d][c] = Math.min(cost[d][c],e);
				}
			}
		}
	}
	public void dijkstra(int start){
		dist[start] = 0;
		while(true){
			int min = def;
			int next = -1;
			for(int u = 0;u < n;u++){
				if(visit[u]){
					continue;
				}
				dist[u] = (cost[start][u] == def)?dist[u]:Math.min(dist[u],dist[start]+cost[start][u]);
				if(dist[u] < min){
					min = dist[u];
					next = u;
				}
			}
			visit[start] = true;
			start = next;
			if(start == -1){
				break;
			}
		}
	}
}

Measured memory_bytes: 48720
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // 入力受付
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        String s = scan.next();
        char array[] = s.toCharArray();

        for (int i = 0; i < n; i++) {
            if (array[i] != '0') {
                for (int j = i + 1; j < n; j++) {
                    if (array[i] == array[j]) {
                        array[j] = '0';
                    } else {
                        break;
                    }
                }
            }

        }

        String result = String.valueOf(array);
        result = result.replaceAll("0", "");

        System.out.println(result.length());

    }

}

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

int main() {
  int N;
  cin >> N;
  vector<int> X(N),Y(N),B(N);
  for (int i = 0; i < N; i++) {
    cin >> X.at(i);
    Y.at(i) = X.at(i);
  }
  
  sort(X.begin(),X.end());
  for (int i = 0; i < N; i++) {
    if (Y.at(i) <= X.at(N/2 - 1)) B.at(i) = X.at(N/2);
    else if (Y.at(i) >= X.at(N/2)) B.at(i) = X.at(N/2 - 1);
  }
  
  for (int i = 0; i < N; i++) cout << B.at(i) << endl; 
}

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

int main(){
	int a;
	cin>>a;
	map<int,int>s;
	for(int b=0;b<a;b++){
		s.insert(pair<int,int>(b+1,0));
		}
	for(int b=0;b<a*(a-1)/2;b++){
         	int c,d,e,f;
         	cin>>c>>d>>e>>f;
         	if(e>f)s[c]+=3;
         	else if(f>e)s[d]+=3;
         	else {s[c]++;s[d]++;}
	}
	map<int,vector<int>>n;
	for(int h=1;h<a+1;h++){
		n[s[h]];
		n[s[h]].push_back(h);
		}
		int l=1;
	map<int,int>k;
	for(int b=0;b<a;b++){
		k.insert(pair<int,int>(b+1,0));
		}
		auto u=n.end();
		u--;
		for(;;u--){
		for(int o=0;o<u->second.size();o++){
			k[u->second[o]]=l;
			}
			l+=u->second.size();
			if(u==n.begin())break;
		}
		for(int y=1;y<a+1;y++)cout<<k[y]<<endl;
	}

Measured memory_bytes: 3144
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

A, B, K = map(int, input().split())

if A + B <= K:
    print(0, 0)
    exit()

if A - K >=0 :
    print(A-K, B)
    exit()

print(0, B-(K-A))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int A,B,C;
  cin>>A>>B>>C;
  if(A<=C && C <= B)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int n;cin>>n;
    int min=n;
    int a;
    int ans=0;
    rep(i,n){
        cin>>a;
        if(a<=min){
            ans++;
            min=a;
        }
    }
    cout<<ans<<endl;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

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

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll n;
    cin >> n;
    vector<ll> a(n);

    REP(i,n){
        cin >> a[i];
    }

    ll count = 0;
    for(int i = 1; i < n-1; i++ ){
       if( 
             (a[i-1] < a[i] && a[i] < a[i+1]) ||
             (a[i-1] > a[i] && a[i] > a[i+1])
         ){
          count++;
       }
    }

    cout << count << endl;
}


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

#define llong long long

void fnInput(int &rnMaxSiz, vector<int> &rvnSort)
{
  cin >> rnMaxSiz;

  rvnSort.resize(rnMaxSiz);
  for (int i = 0; i < rnMaxSiz; i++)
    cin >> rvnSort[i];
}

void fnMerge(vector<int> &rvnSort, llong &rnInvCnt, int nLeft, int nMid, int nRight)
{
  vector<int> vnLeft, vnRight;
  int nLeftSiz = nMid - nLeft;
  int nRightSiz = nRight - nMid;
  
  vnLeft.resize(nLeftSiz + 1);
  vnRight.resize(nRightSiz + 1);
  for (int i = 0; i < nLeftSiz; i++)
    vnLeft[i] = rvnSort[nLeft + i];
  for (int i = 0; i < nRightSiz; i++)
    vnRight[i] = rvnSort[nMid + i];

  vnLeft[nLeftSiz] = INT_MAX;
  vnRight[nRightSiz] = INT_MAX;

  int i = 0, j = 0;
  for (int n = nLeft; n < nRight; n++)
    if (vnLeft[i] <= vnRight[j])
      rvnSort[n] = vnLeft[i++];
    else
    {
      rvnSort[n] = vnRight[j++];
      if (vnLeft[i] != INT_MAX)
        rnInvCnt += (nLeftSiz - i);
      else;
    }  
}

void fnMergeSort(vector<int> &rvnSort, llong &rnInvCnt, int nLeft, int nRight)
{
  if (nLeft + 1 < nRight)
  {
    int nMid = (nLeft + nRight) / 2;
    fnMergeSort(rvnSort, rnInvCnt, nLeft, nMid);
    fnMergeSort(rvnSort, rnInvCnt, nMid, nRight);
    fnMerge(rvnSort, rnInvCnt, nLeft, nMid, nRight);
  }
}

void fnResult(llong nInvCnt)
{
  cout << nInvCnt << endl; 
}

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

  int nMaxSiz;
  vector<int> vnSort;

  fnInput(nMaxSiz, vnSort);

  int nLeft = 0;
  int nRight = nMaxSiz;
  llong nInvCnt = 0;
  fnMergeSort(vnSort, nInvCnt, nLeft, nRight);

  fnResult(nInvCnt);

  return 0;
}

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

#define ff first
#define ss second
#define pb push_back
#define ll long long
#define ull unsigned long long
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define mst(ss,b) memset(ss,b,sizeof(ss));
#define dbg(x) cout << #x << "= " << x << endl;
typedef pair <int, int> pii;
const int inf = 0x3f3f3f3f;
const ll INF = (1LL<<62)-1;
const ll mod = 1e9+7;
const int N = 1e5+5;

int n, m;
ll add[N], del[N];
int a[N];

int  main(){
    scanf("%d%d", &n, &m);
    for(int i=1; i<=n; i++)scanf("%d", &a[i]);
    for(int i=1; i<n; i++){
        int l = a[i], r = a[i+1];
        if(l < r){
            add[1] += r-l;
            add[l+1] -= r-l;
            add[l+1] += r+1;
            add[r+1] -= r+1;
            del[l+1] -= 1;
            del[r+1] += 1;
            add[r+1] += r-l;
        }
        else if(l > r){
            add[1] += r+1;
            add[r+1] -= r+1;
            del[1] -= 1;
            del[r+1] += 1;
            add[r+1] += r-l+m;
            add[l+1] -= r-l+m;
            add[l+1] += m+r+1;
            del[l+1] -= 1;
        }
    }
    for(int i=2; i<=m; i++)add[i] += add[i-1], del[i] += del[i-1];
    ll ans = INF;
    for(int i=1; i<=m; i++){
        ans = min(ans, add[i]+i*del[i]);
    }
    printf("%lld\n", ans);
    return 0;
}


//    lower_bound()
//    __builtin_popcount()
//    ios::sync_with_stdio(false);
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    const double eps=1e-12;
//    #pragma comment(linker,"/STACK:102400000,102400000")



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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define mm 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define siz(x) (int)x.size()
#define inf 1e18

#define show(x) cout<<#x<<" "<<x<<'\n'
#define iosbase ios_base::sync_with_stdio(false); cin.tie(NULL);
#define oset tree<int , null_type, less_equal<int> , rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

int main()
{
    iosbase;
    string a,b;
    cin>>a>>b;
    
    int l1=a.size();
    int l2=b.size();

    int dp[l1+3][l2+3];
    memset(dp,0,sizeof(dp));
    int ans=0;
    for(int i=1;i<=l1;i++)
    {
        for(int j=1;j<=l2;j++)
        {
           
            if(a[i-1]==b[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    
    string res="";
    
    int i=l1,j=l2,cnt=0;
    
    while(i>0 && j>0)
    {
        if(a[i-1]==b[j-1])
        {
            
            res=a[i-1]+res;
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]) i--;
        else j--;
    
    }
    cout<<res<<endl;
}

Measured memory_bytes: 35456
N = int(input())
b = list(map(int, input().split()))
a = [ set() for _ in range(N)]
a = [-1]*N
pre = -1
for x in range(N):
    if x==0:
        a[x] = b[x]

    elif x==N-1:
        a[x] = b[x-1]

    else:
        a[x] = min(b[x-1], b[x])

print(sum(a))

Measured memory_bytes: 38384
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var nk = Input.ar;
        var comb = new Modulo.Combination(nk[0] + nk[1]);
        WriteLine(comb.Comb(nk[0] + nk[1] - 1, nk[0]));
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}
public class Modulo
{
    private static int Multiple(int num1, int num2)
        => (int)(BigMul(num1, num2) % Input.MOD);

    public static int Pow(int m, int n)
    {
        if (n == 0) return 1;
        if (n % 2 == 0) return Pow(Multiple(m, m), n / 2);
        else return Multiple(Pow(Multiple(m, m), n / 2), m);
    }

    public static int Div(int a, int b)
        => Multiple(a, Pow(b, Input.MOD - 2));

    public class Combination
    {
        private int[] _fac;
        public Combination(int num)//階乗をメモ化
        {
            _fac = new int[num + 1];
            _fac[0] = 1;
            for (var i = 1; i <= num; i++)
                _fac[i] = Multiple(_fac[i - 1], i);
        }
        public int Comb(int n, int r)
        {
            if (n < r) return 0;
            if (n == r) return 1;
            var calc = _fac[n];
            calc = Div(calc, _fac[r]);
            calc = Div(calc, _fac[n - r]);
            return calc;
        }
        public int fac(int num)
            => _fac[num];
    }

}



Measured memory_bytes: 17968
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	char S[200010];
	fread(S, 1, 200010, stdin);

	int L = 0, R = 200000;
	while (L + 1 < R) {
		int M = (L + R) / 2;
		if (S[M] >= '?') L = M;
		else R = M;
	}
	rep(i, R) {
		if (S[i] == '?') S[i] = 'D';
	}
	fwrite(S, 1, R, stdout);

	Would you please return 0;
}

Measured memory_bytes: 1728
N, A, B = map(int, input().split())
S = input()
c = 0
cb = 0
for s in S:
    if s == 'a':
        if c < A+B:
            print('Yes')
            c += 1
        else:
            print('No')
    if s == 'b':
        if c < A+B and cb < B:
            print('Yes')
            c += 1
            cb += 1
        else:
            print('No')
    if s == 'c':
        print('No')
    

Measured memory_bytes: 53080
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		int nyukyoData[][][][];
		nyukyoData = new int [4][3][10][1];
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		for (int i=0; i < n; i++){
			int b = sc.nextInt()-1;
			int f = sc.nextInt()-1;
			int r = sc.nextInt()-1;
			nyukyoData[b][f][r][0] += sc.nextInt();
		}
		for (int b=0; b < 4; b++) {
			for (int f=0; f < 3; f++) {
				for(int r=0; r < 10; r++) {
					System.out.print(" " + nyukyoData[b][f][r][0]);
					if (r == 9) {
						System.out.println("");
					}
				}
				if (f == 2 && b != 3) {
					System.out.println("####################");
				}
			}
		}
	}

}

Measured memory_bytes: 29848
#include<bits/stdc++.h>
using namespace std;
int ans[100001];
int w[100001];
int x[100001];
int n,l,t,cur;
int main()
{
    scanf("%d%d%d",&n,&l,&t);
    for(register int i=1;i<=n;++i) scanf("%d%d",&x[i],&w[i]);
    for(register int i=1;i<=n;++i)
        if(w[i]==1)
        {
            ans[i]=(x[i]+t)%l;
            cur+=(x[i]+t)/l;
        }
        else
        {
            ans[i]=(x[i]-t)%l;
            cur+=(x[i]-t)/l;
            if(ans[i]<0) --cur,ans[i]+=l;
        }
    ((cur%=n)+=n)%=n;
    sort(ans+1,ans+n+1);
    for(register int i=cur+1;i<=n;++i) printf("%d\n",ans[i]);
    for(register int i=1;i<=cur;++i) printf("%d\n",ans[i]);
    return 0;
}

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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);
#define int long long int
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()

const int N = 500009;
const int mod = 1000000007;
#define PI 3.141592653

long double a, b, x, h;

void pre()
{
}

int32_t main()
{
	IOS;
	pre();
	cin >> a >> b >> x;
	h = (x / (a * a));
	if ((int)(a * a * b) == (int)x)
	{
		cout << "0\n";
		return 0;
	}
	if (h >= (b / 2))
	{
		long double param = a / (2 * (b - h));
		long double result = atan(param) * 180 / PI;
		cout << setprecision(10) << (90 - result) << endl;
	}
	else
	{
		long double param = (b * b * a) / (2 * x);
		// param = sqrts(param);
		long double result = atan(param) * 180 / PI;
		cout << setprecision(10) << (result) << endl;
	}
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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 (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

    ll X;
    cin >> X;

    for(ll A=-2000;A<=2000;A++){
        for(ll B=-2000;B<=2000;B++){
            if(A*A*A*A*A-B*B*B*B*B == X){
                cout << A spa B << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3672
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

int main() {
	string a, b;
	cin >> a >> b;
	int p = a.size();
	int q = b.size();
	if (p > q) cout << "GREATER" << endl;
	else if (p < q) cout << "LESS" << endl;
	else {
		string ans = "EQUAL";
		rep(i, p) {
			int nowa = a[i] - '0';
			int nowb = b[i] - '0';
			if (nowa > nowb) {
				ans = "GREATER";
				break;
			}
			else if (nowb > nowa) {
				ans = "LESS";
				break;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))

#print(A)

def gcd(a,b):
    if a!=1 and b!=1 :
        while a!=b:
            if a>b :
                m=a%b
                if m==0 :
                    a=b
                else :
                    a=m
                        
                    
                
            else :        
                m=b%a
                if m==0 :
                    b=a
                else :
                    b=m
        return a
    return 1

aa=A[0]
for i in range(n) :
    aa=gcd(aa,A[i])
    #print(i)
print(aa)


Measured memory_bytes: 14252
#include <iostream>

int main(void){
    int tmp=0, ans=0;

    for (int i=0; i<5; ++i){
        int N, rem;
        std::cin >> N;
        rem = -(N % 10);
        if (rem != 0) rem += 10;
        if (tmp < rem) tmp = rem;
        ans += N + rem;
    }

    ans -= tmp;

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 3568
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        final long Mod = 1000000000+7;
        if(M>N){ // let N be the bigger one;
            int temp = N;
            N = M;
            M = temp;
        }
        if(N-M>=2){
            System.out.println(0);
            System.exit(0);
        }
        long[] Ms = new long[M+1];
        Ms[1]=1;
        for(int i=2;i<=M;i++){
            Ms[i]=(Ms[i-1]*((long)i))%Mod;
        }
        long ans=Ms[M];
        for(int i=1;i<=N;i++){
            ans = (ans*i)%Mod;
        }
        if(M==N) ans = (2*ans)%Mod;
        System.out.println(ans);
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b;
    cin >> a >>b;
    
    cout << max({a+b, a-b, a*b}) << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#define N 1000005
using namespace std;

int n;
int a[N], b[N], c[N];

inline bool chk(int x) {
    for (int i = 1; i <= n * 2 - 1; ++i)
        c[i] = a[i] < x ? 0 : 1;
    for (int i = 1; i < n; ++i) {
        int l = n - i, r = n + i;
        if (c[l + 1] == c[l])
            return c[l];
        if (c[r - 1] == c[r])
            return c[r];
    }
    return c[1];
}

int main() {
    cin >> n;
    for (int i = 1; i <= n * 2 - 1; ++i)
        scanf("%d", a + i), b[i] = a[i];
    sort(b + 1, b + n * 2);
    int l = 1, r = n * 2 - 1;
    while (l < r) {
        int mid = (l + r) >> 1;
        if (chk(b[mid])) l = mid + 1;
        else r = mid;
    }
    cout << b[l - 1] << endl;
    return 0;
}


Measured memory_bytes: 9216