akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class LowestCommonAncestor
{
private:
    vector<vector<int> > to; // ??????????????°
    vector<int> depth;       // ??????????????±???
    int climb(int curr, int dist)
    {
        int i = 0;
        while(dist > 0){
            if(dist % 2 == 1)
                curr = to[curr][i];
            dist /= 2;
            ++ i;
        }
        return curr;
    }
public:
    LowestCommonAncestor(const vector<vector<int> >& edges, int root)
    {
        int n = edges.size();
        to.assign(n, vector<int>());
        depth.resize(n);

        queue<pair<int, int> > q;
        q.push(make_pair(root, -1));

        int cnt = 0;
        while(!q.empty()){
            int m = q.size();
            while(--m >= 0){
                int curr, prev;
                tie(curr, prev) = q.front();
                q.pop();

                depth[curr] = cnt;
                if(prev != -1){
                    to[curr].push_back(prev);
                    int j = prev;
                    for(unsigned k=0; k<to[j].size(); ++k){
                        j = to[j][k];
                        to[curr].push_back(j);
                    }
                }

                for(int next : edges[curr]){
                    if(next != prev)
                        q.push(make_pair(next, curr));
                }
            }
            ++ cnt;
        }
    }
    // 2??????????????????????°???±????\?????????????
    int getAncestor(int a, int b)
    {
        int diff = depth[a] - depth[b];
        if(diff < 0)
            b = climb(b, -diff);
        else
            a = climb(a, diff);
        if(a == b)
            return a;

        for(int i=to[a].size()-1; i>=0; --i){
            if(i < (int)to[a].size() && to[a][i] != to[b][i]){
                a = to[a][i];
                b = to[b][i];
            }
        }
        return to[a][0];
    }
    // ??????????????±????????????
    int getDepth(int a)
    {
        return depth[a];
    }
    // 2???????????????????????¢?????????
    int getDist(int a, int b)
    {
        int c = getAncestor(a, b);
        return getDepth(a) + getDepth(b) - getDepth(c) * 2;
    }
};

int main()
{
    int n;
    cin >> n;
    vector<vector<int> > edges(n);
    for(int i=0; i<n; ++i){
        int k;
        cin >> k;
        while(--k >= 0){
            int j;
            cin >> j;
            edges[i].push_back(j);
        }
    }

    LowestCommonAncestor lca(edges, 0);

    int q;
    cin >> q;
    while(--q >= 0){
        int u, v;
        cin >> u >> v;
        cout << lca.getAncestor(u, v) << endl;
    }

    return 0;
}

Measured memory_bytes: 20900
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  int D,G,ans=INF,pro=0,score=0;
  cin >> D >> G;
  int p[D],c[D];
  rep(i,D) cin >> p[i] >> c[i];
  int sum[D];
  rep(i,D) sum[i]=100*(i+1)*p[i]+c[i];
  rep(i,Flag(D)){
    score=0,pro=0;
    rep(j,D) if(i&Flag(j)) score+=sum[j],pro+=p[j];
    if(score>=G) ans=min(ans,pro);
    else{
      int x=D-1;
      while(i&Flag(x) && x>=0) x--;
      if(x<0) continue;
      else pro+=ceil((double)(G-score)/((x+1)*100));
      if((G-score)/((x+1)*100)<p[x]) ans=min(ans,pro);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


void solve(){
    string s;
    cin>>s;
    if(s=="AAA"||s=="BBB") cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
     
    solve();


    return 0;
}

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

int main(){
    int n,ans=0,k;
    cin >> n >> k;
    vector<int> l(n);
    for(int i=0;i<n;i++) cin >> l[i];
    sort(l.begin(),l.end());
    reverse(l.begin(),l.end());
    for(int i=0;i<k;i++) ans+=l[i];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

// graph template
template<typename T>
class Edge{
    public:
        int src, to; T cost;

        Edge(int to, T cost): src(-1), to(to), cost(cost){}
        Edge(int src, int to, T cost): src(src), to(to), cost(cost){}
};
template<typename T>
using Edges = vector<Edge<T>>;
template<typename T>
using AdjacencyList = vector<Edges<T>>;
template<typename T>
using Matrix = vector<vector<T>>;

template<typename T>
vector<T> dijkstra(AdjacencyList<T> &g, int s){
    const auto INF = numeric_limits<T>::max();
    vector<T> dist(g.size(), INF);

    using Pr = pair<T, int>;
    priority_queue<Pr, vector<Pr>, greater<Pr>> que;
    dist[s] = 0;
    que.emplace(dist[s], s);

    while(not que.empty()){
        T cost; int v;
        tie(cost, v) = que.top(); que.pop();
        if(dist[v] < cost) continue;

        for(auto &e: g[v]){
            if(dist[e.to] > dist[v] + e.cost){
                dist[e.to] = dist[v] + e.cost;
                que.emplace(dist[e.to], e.to);
            }
        }
    }

    return dist;
}

int N, Q, K;

int main(void){
    cin >> N;
    AdjacencyList<ll> g(N);
    for(int i = 0; i < N-1; i++){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        g[a].push_back(Edge<ll>(b, c));
        g[b].push_back(Edge<ll>(a, c));
    }

    cin >> Q >> K;
    vector<ll> vec = dijkstra(g, K-1);
    for(int i = 0; i < Q; i++){
        int x, y;
        cin >> x >> y;
        cout << vec[x-1] + vec[y-1] << '\n';
    }

    return 0;
}

Measured memory_bytes: 11220
#include <stdio.h>

char buf[1025];
char c1[]=".,!? ";
char c2[]="abc";
char c3[]="def";
char c4[]="ghi";
char c5[]="jkl";
char c6[]="mno";
char c7[]="pqrs";
char c8[]="tuv";
char c9[]="wxyz";

int main(void){
    int count,lines,i,j;
    scanf("%d",&lines);
    for(i=0;i<lines;i++){
        scanf("%s",buf);
        j=0;
        count=0;
        while(buf[j]){
            if(buf[j]=='0'){
                switch(buf[j-1]){
                    case '0':
                        break;
                    case '1':
                        printf("%c",c1[(count-1)%5]);
                        break;
                    case '2':
                        printf("%c",c2[(count-1)%3]);
                        break;
                    case '3':
                        printf("%c",c3[(count-1)%3]);
                        break;
                    case '4':
                        printf("%c",c4[(count-1)%3]);
                        break;
                    case '5':
                        printf("%c",c5[(count-1)%3]);
                        break;
                    case '6':
                        printf("%c",c6[(count-1)%3]);
                        break;
                    case '7':
                        printf("%c",c7[(count-1)%4]);
                        break;
                    case '8':
                        printf("%c",c8[(count-1)%3]);
                        break;
                    case '9':
                        printf("%c",c9[(count-1)%4]);
                        break;
                }
                count=0;
            }else{
                count++;
            }
            j++;
        }
        printf("\n");
    }
    return 0;
}

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

int main(void){
    string s;
    cin >> s;

    vector<pair<ll, ll>> p;

    ll a[s.size()];
    ll count = 1;
    ll flag = 0;
    rep(i, s.size() - 1){
        if(s[i] == 'R' && s[i+1] == 'R' && flag == 0){
            count++;
            a[i] = 0;
        }
        if(s[i] == 'R' && s[i+1] == 'L' && flag == 0){
            p.push_back({count, 0});
            count = 1;
            flag = 1;
            a[i] = -1;
        }
        if(s[i] == 'L' && s[i+1] == 'L' && flag == 1){
            count++;
            a[i] = 0;
        }
        if(s[i] == 'L' && s[i+1] == 'R' && flag == 1){
            p[p.size() - 1].second = count;
            count = 1;
            flag = 0;
            a[i] = 0;
        }
    }
    a[s.size() - 1] = 0;
    p[p.size() - 1].second = count;

    ll c = 0;
    rep(i, s.size()){
        if(a[i] == -1){
            if(p[c].first % 2 == p[c].second % 2){
                a[i] = (p[c].first + p[c].second) / 2;
                a[i+1] = a[i];
            }else if(p[c].first % 2 == 0){
                a[i] = (p[c].first + p[c].second) / 2;
                a[i+1] = a[i] + 1;
            }else if(p[c].first % 2 != 0){
                a[i+1] = (p[c].first + p[c].second) / 2;
                a[i] = a[i+1] + 1;
            }
            c++;
        }
        cout << a[i] << " ";
    }
    cout << endl;
    return 0;
}


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

struct Weighted_Union_Find {
    std::vector<int> par;
    std::vector<int> rank;
    std::vector<long long> wdiff;
    //初期化
    void init( int n ) {
        par.resize( n );
        rank.resize( n );
        wdiff.resize( n );
        for ( int i = 0; i < n; ++i ) {
            par[ i ] = i;
            rank[ i ] = 0;
            wdiff[ i ] = 0;
        }
    }
    
    //木の根を探す
    int find( int s ) {
        if ( par[ s ] == s ) {
            return s;
        }
        int r = find(par[ s ]);
        wdiff[s] += wdiff[par[s]];
        return par[s] = r;
    }
    
    long long weight(int x) {
        find(x); // 経路圧縮
        return wdiff[x];
    }

    long long diff(int x, int y) {
        return weight(y) - weight(x);
    }

    //結合
    bool unite( int x, int y, long long w ) {
        w += weight(x);
        w -= weight(y);
        x = find( x );
        y = find( y );
        if ( x == y ) {
            return false;
        }
        if ( rank[ x ] < rank[ y ] ) {
            std::swap(x, y);
            w = -w;
        }
        if ( rank[x] == rank[y] ) ++rank[x];
        par[y] = x;
        wdiff[y] = w;
        return true;
    }
    
    //二つの数の根が同じかどうか
    bool same( int x, int y ) {
        return find( x ) == find( y );
    }
    
    //サイズを返す
    unsigned int size() {
        return par.size();
    }
};

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    Weighted_Union_Find wuf;
    while(cin >> n >> q && n && q){
        wuf.init(n);
        while(q--){
            char query;
            cin >> query;
            if(query == '!'){
                int a, b, w;
                cin >> a >> b >> w;
                wuf.unite(a - 1, b - 1, w);
            }else{
                int a, b;
                cin >> a >> b;
                if(wuf.same(a - 1, b - 1)){
                    cout << wuf.diff(a - 1, b - 1) << "\n";
                }else{
                    cout << "UNKNOWN\n";
                }
            }
        }
    }
}


Measured memory_bytes: 4500
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

#define repi(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)

bool c[100001];
int n, k;

int main() {
	ios::sync_with_stdio(false);
	
	while(1) {
		cin >> n >> k;
		if(!(n|k))break;
		rep(i, n+1)c[i]=false;
		int t;
		rep(i, k) {
			cin >> t;
			c[t] = true;
		}
		int l=0;
		if(c[0]) {
			int j=0, t=0;
			repi(i, 1, n+1) {
				if(!c[i])continue;
				j=i;
				while(j<=n && c[j])j++;
				t=j;
				j++;
				while(j<=n && c[j])j++;
				l = max(l, j-i);
				i=t;
			}
		}else {
			int j=0;
			repi(i, 1, n+1) {
				if(!c[i])continue;
				j=i;
				while(j<=n && c[j])j++;
				l = max(l, j-i);
				i=j;
			}
		}
		cout <<l <<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1292
X, K, D = map(int, input().split())

p = X // D

if abs(p) > K:
    ans = min(abs(X - K * D), abs(X + K * D))

else:
    m0 = abs(X - D * p)
    m1 = abs(X - D * (p + 1))

    if abs(m0) < abs(m1):
        if (K - p) % 2 == 0:
            ans = m0
        else:
            ans = m1
    else:
        if (K - p - 1) % 2 == 0:
            ans = m1
        else:
            ans = m0
print(ans)


Measured memory_bytes: 9196
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias Mame = Tuple!(long, "point", long, "number");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long n, k;
    scan(n, k);
    auto h = aryread();
    long cnt;
    foreach (e; h)
    {
        if (e >= k)
            cnt++;
    }
    cnt.writeln();
}


Measured memory_bytes: 4348
def main():
  n,m=map(int,input().split())
  inf=10**9
  dp=[inf]*(1<<n)
  dp[0]=0
  
  #cost=[inf for i in range(m)]
  for i in range(m):
    a,b=map(int,input().split())
    c=[1<<(int(x)-1) for x in input().split()]
    t=sum(c)
    #cost[i]=[s,a]
    for s in range(1<<n):
      if dp[t|s]>dp[s]+a:
        dp[t|s]=dp[s]+a
      #dp[t|s]=min(dp[t|s], dp[s]+a)
    
  #print(cost)
  """
  dp=[inf]*(1<<n)
  dp[0]=0
  for s in range(1<<n):
    for bit,c in cost:
      dp[s|bit]=min(dp[s|bit], dp[s]+c)
  #print(dp)
  """
  #print(dp)
  print(-1 if dp[-1]==inf else dp[-1])

if __name__=='__main__':
  main()

Measured memory_bytes: 9208
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000

long long a[N];
int p[N];
int d[N];

void init(void){
	f(i, N){
		p[i] = i;
		d[i] = 1;
		a[i] = 1;
	}
	return;
}

int pa(int x){
	if (p[x] == x)return x;
	else return p[x] = pa(p[x]);
}


long long uni(int x, int y){
	int px = pa(x);
	int py = pa(y);
	long long z;
	if (px == py)return 0;
	if (d[px] < d[py]){
		p[px] = py;
		d[py] = max(d[py], d[px] + 1);
		z = a[px] * a[py];
		a[py] += a[px];
		a[px] = 0;
		return z;
	}
	else{
		p[py] = px;
		d[px] = max(d[px], d[py] + 1);
		z = a[px] * a[py];
		a[px] += a[py];
		a[py] = 0;
		return z;
	}
}

bool jud(int x, int y){
	int px = pa(x);
	int py = pa(y);
	if (px == py)return true;
	else return false;
}



int main(){
	long long n, q;
	int x, y, z;
	long long s, ans;
	int ss[N];
	int tt[N];
	long long fians[N];
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	init();
	scanf("%d", &q);
	f(qq, q)scanf("%d %d", &ss[q - qq - 1], &tt[q - qq - 1]);
	fians[0] = 0;
	f(qq, q){
		s = uni(ss[qq], tt[qq]);
		fians[qq + 1] = fians[qq] + s;
	}
	ans = n*(n - 1);
	ans = ans / 2;
	f(i, q){
		printf("%lld\n", ans - fians[q - i - 1]);
	}

	return 0;
}

Measured memory_bytes: 6912
import sys
import math
from  collections import defaultdict


# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')

mod = 1000000007

def solve(test):
	h, w = map(int, input().split())
	grid = []
	for i in range(h):
		grid.append(list(input()))


	dp = [[0 for j in range(w)] for i in range(h)]
	dp[0][0] = 1
	for j in range(1, w):
		if grid[0][j] == '.':
			dp[0][j] += dp[0][j - 1]

	for i in range(1, h):
		if grid[i][0] == '.':
			dp[i][0] += dp[i - 1][0]

	for i in range(1, h):
		for j in range(1, w):
			if grid[i][j] == '.':
				dp[i][j] += (dp[i - 1][j] + dp[i][j - 1]) % mod

	ans = dp[-1][-1]
	print(ans)




if __name__ == "__main__":
	test_cases = 1
	for t in range(1, test_cases + 1):
		solve(t)


Measured memory_bytes: 89564
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
const int INF = 1e9;

int main (){
  int n,ans=0;
  cin>>n;
  vector<int> A(n);
  for(int i=0;i<n;i++) cin>>A[i];
  bool flag=true;
  while(flag){
    flag=false;
    for(int i=1;i<n;i++){
      if(A[i-1]>A[i]){
        swap(A[i-1],A[i]);
        ans++;
        flag=true;
      }
    }
  }
  for(int i=0;i<n;i++){
    cout<<A[i];
    if(i+1<n) cout<<" ";
  }
  cout<<endl;
  cout<<ans<<endl;
}


Measured memory_bytes: 3080
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<queue>
#include<functional>
#include<numeric>
#include<limits>

int main()
{
	std::uint64_t v;
	std::cin >> v;
	auto x = v / 11;
	auto y = v % 11;
	std::cout << 2 * x + (y == 0 ? 0 : y > 6 ? 2 : 1) << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<math.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
#define N (1000000000+7)
#define INF (ll)1e16
typedef long long ll;

int main(void){
    int n;
    cin>>n;
    vector<double>v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    sort(v.begin(),v.end());
    double ans=(double)v[0];
    for(int i=1;i<n;i++){
        ans=(double)(ans+v[i])/2;
    }
    printf("%.9lf\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int a[100000];
vector<int>g[100000];
int k;
int ans;
int dfs(int s){
    int res = 0;
    for(int x:g[s]){
        res = max(res, dfs(x)+1);
    }
    if(res == k-1 and a[s] != 0){
        ans++;
        res = -1;
    }
    return res;
}
int main(){
    int n;
    scanf("%d%d",&n,&k);
    rep(i,n){
        scanf("%d",a+i);
        a[i]--;
    }
    if(a[0] != 0){
        ans++;
        a[0] = 0;
    }
    rep(i,n-1){
        g[a[i+1]].push_back(i+1);
    }
    //rep(i,n)show(g[i].size());
    dfs(0);
    cout << ans << endl;
}

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

int main() {
	auto optimize_cpp_stdio = []() {
		std::ios::sync_with_stdio(false);
		std::cout.tie(nullptr);
		std::cin.tie(nullptr);
		return 0;
	}();

	int n, m;
	std::string s;
	std::cin >> n >> s >> m;

	auto new_begin = std::find(s.begin(), s.end(), 'D');
	s.erase(s.begin(), new_begin);
	n = s.size();

	//DMC
	for (int iter = 0, k; iter < m; iter++) {
		std::cin >> k;
		int M = 0, C = 0;
		int64_t ans = 0, cur = 0;
		for (int i = 0, j = 0; i < n;) {
			if (j <= i) {
				j = i, M = C = cur = 0;
			}
			while (j < n && j - i < k) {
				if (s[j] == 'M') M++;
				if (s[j] == 'C') cur += M, C++;
				j++;
			}
			ans += cur;
			i++;
			while (i < n && s[i] != 'D') {
				if (s[i] == 'M') cur -= C, M--;
				if (s[i] == 'C') C--;
				i++;
			}
		}
		std::cout << ans << '\n';
	}
	return 0;
}

Measured memory_bytes: 1948
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(int)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, m;
	cin >> n >> m;
	vector<pll> a(n);
	REP(i, n) cin >> a[i].first >> a[i].second;
	ll ans = 0, c = m;
	sort(ALL(a));
	REP(i, n) {
		if(c == 0) continue;
		if(c <= a[i].second) {
			ans += a[i].first * c;
			c = 0;
		} else {
			ans += a[i].first * a[i].second;
			c -= a[i].second;
		}
	}
	cout << ans << endl;
	return 0;
}
/* --------------------------------------- */


Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N, M;

int main() {
    cin >> N;

    int l = 0;
    vi ans(0);
    if (N % 2 == 1) {
        for (int i = 1; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                if (i + j == N) continue;
                ans.push_back(i);
                ans.push_back(j);
                l++;
            }
            ans.push_back(i);
            ans.push_back(N);
            l++;
        }
    } else {
        for (int i = 1; i <= N; i++) {
            for (int j = i + 1; j <= N; j++) {
                if (i + j == N + 1) continue;
                ans.push_back(i);
                ans.push_back(j);
                l++;
            }
        }
    }

    cout << l << endl;
    for (int i = 0; i < l; i++) {
        cout << ans[2 * i] << ' ' << ans[2 * i + 1] << endl;
    }

    return 0;
}


Measured memory_bytes: 384
from math import factorial
 

N, M = map(int, input().split())
MOD = 10**9 + 7
diff = abs(N - M)
 
 
if diff == 0:
    ans = (factorial(N) * factorial(M)) * 2
elif diff == 1:
    ans = factorial(N) * factorial(M)
else:
    ans = 0
 
 
ans %= MOD
print(ans)

Measured memory_bytes: 5188
import numpy as np
from scipy.spatial import distance
from scipy.sparse.csgraph import floyd_warshall
n = int(input())
xy = np.zeros((n, 2))
for i in range(n):
    xy[i, 0], xy[i, 1] = (int(x) for x in input().split())
print(np.sum(distance.cdist(xy, xy, metric='euclidean'))/n)

Measured memory_bytes: 19480
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

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

const int INF = 1e9;
const int MOD = 1e9+7;

int main(void){
	int n;
	cin >> n;
	if(n == 1){
		cout << "Hello World" << endl;
	}else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
    string s;
    cin >> s;
    int k = 0;
    int p = 0;
    for (char a: s) {
        char b;
        if (k) {
            b = 'p';
            k--;
        }
        else {
            b = 'g';
            k++;
        }
        if (a != b) {
            if (a == 'g') {
                p++;
            }
            else {
                p--;
            }
        }
    }
    cout << p << endl;
}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  string Ans = "NO";
  rep(i, 1, B+1) {
    if((A*i)%B == C) {
      Ans = "YES";
      break;
    }
  }

  cout << Ans << endl;
}


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

using namespace std;

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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> L(n + 1, 0);
    vector<int> R(n + 1, 0);
    int current = 0;
    rep(i, n) {
        if (s[i] == '#') current++;
        L[i + 1] = current;
    }
    current = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == '.') current++;
        R[i] = current;
    }
    int ans = INT_MAX;
    rep(i, n + 1) {
        ans = min(ans, L[i] + R[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2180
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

const int MOD = 1e9 + 7;
const int INFi = 2e9 + 1;
const lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
const char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(i, vec) for(auto &(i) : (vec))


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

std::string ptv = "Positive", ntv = "Negative", zr = "Zero";


int main(void){
  int a, b; cin >> a >> b;
  if(a > 0 && b > 0) cout << ptv << BR;
  else if(a * (lli)b <= 0) cout << zr << BR;
  else{
    if((b - a) % 2 == 0) cout << ntv << BR;
    else cout << ptv << BR;
  }
  return 0;
}

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

int main() {
  int n, r;
  cin >> n >> r;
  if(n < 10) {
    int c = 100 * (10 - n);
    c = c + r;
    cout << c << endl;
  } else {
    cout << r << endl;
  }
}

Measured memory_bytes: 3596
a = input().split()
A = int(a[0])
B = int(a[1])
H = int(a[2])
M = int(a[3])
import math
aa = 30 * H + 0.5 * M
bb = M * 6
z = aa - bb
ans = (A**2 + B**2 - 2*A*B*math.cos(math.radians(z)))**(1/2)

print(ans)

Measured memory_bytes: 9400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 310;
int d[maxn][maxn];
int n, m, L;
void floyd(){
	for (int k = 1; k <= n; k++){
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				d[i][j] = min(d[i][k] + d[k][j], d[i][j]);
			}
		}
	}
}
int main(){
	memset(d, 0x3f, sizeof d);
	scanf("%d%d%d", &n, &m, &L);
	for (int i = 1; i <= m; i++){
		int u, v, w;
		scanf("%d%d%d", &u, &v, &w);
		d[u][v] = w, d[v][u] = w;
	}
	floyd();
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			if (d[i][j] <= L) d[i][j] = 1;//可以一次性到达
			else d[i][j] = 1e9;
		}
	}
	floyd();
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++){
			if (d[i][j] == 1e9) d[i][j] = -1;
			else d[i][j]--;
		}
	}
	int q;
	cin >> q;
	while (q--){
		int x, y;
		scanf("%d%d", &x, &y);
		printf("%d\n", d[x][y]);
	}
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
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; }

using ll = long long;
using P = pair<ll,ll>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 998244353LL;

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

template <typename T>
struct RMQ {//normal
    const T INF = numeric_limits<T>::max();
    int n;         
    vector<T> dat; 
    RMQ(int n_) : n(), dat(n_ * 4, INF) { 
        int x = 1;
        while (n_ > x) {
            x *= 2;
        }
        n = x;
    }
 
    void update(int i, T x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;  
            dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }
 
    // the minimum element of [a,b)
    T query(int a, int b) { return query_sub(a, b, 0, 0, n); }
    T query_sub(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return INF;
        } else if (a <= l && r <= b) {
            return dat[k];
        } else {
            T vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            T vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};

int main() {
  ll N,x;
  cin>>N>>x;
  vector<ll> v(N);
  rep(i,N) cin>>v[i];
  RMQ<ll> R(N);
  rep(i,N) {
    R.update(i,v[i]);
  }
  ll ans = INF;
  rep(i,N){
    ll p = 0;
    rep(j,N){
      int s = j-i;
      if(s<0) s += N;
      if(s>j){
        p += min(R.query(s,N),R.query(0,j+1));
      }
      else p += R.query(s,j+1);
    }
    p += x*i;
    chmin(ans,p);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3672
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    if (args.length > 0 && args(0) == "TEST") {
      println(test())
    } else {
      val input = io.Source.stdin.getLines().mkString("\n")
      println(solve(input).trim())
    }
  }

  def solve(input: String): String = {
    val s: Scanner = new Scanner(input)
    val n = s.nextInt
    ((n - 2) * 180).toString
  }

  val tests = List(
    """3""".stripMargin -> """180""",
    """100""".stripMargin -> """17640"""
  )

  def test(): String = tests.map { case (i, o) => (i.trim(), o.trim()) }
    .zipWithIndex.map {
    case ((input, outputExpect), i) =>
      val output = solve(input).trim()
      val tnum = i + 1
      s"test$tnum:" + (
        if (output == outputExpect) "Passed"
        else s"Failed\nexpect:\n$outputExpect\noutput:\n$output")
  }
    .mkString("\n")
}

Measured memory_bytes: 25932
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;

string str;
int main(){
    cin>>str;
    int n=str.size();
    int a=n,b=0;
    for(int i=0;i<n;i++){
        if(str[i]=='A')a=i,i=n;
    }
    for(int i=n;i>=0;i--){
        if(str[i]=='Z')b=i,i=-1;
    }
    
    cout<<b-a+1<<endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>

#define MAX 2000001
#define VMAX 10000

int main(){
    int C[VMAX+1]; // Aの中に要素番号以下の数がいくつかあるかを示す配列
    int n;
    
    scanf("%d", &n);
    
    unsigned short *A = (unsigned short *)malloc(sizeof(unsigned short) * n+1);
    unsigned short *B = (unsigned short *)malloc(sizeof(unsigned short) * n+1);

    for(int i= 0; i< VMAX+1; i++) C[i] = 0;

    for(int i = 0; i<n; i++) {
        scanf("%hu", &A[i+1]);
        C[A[i+1]]++;
    }

    for(int i= 1; i<= VMAX; i++) C[i] = C[i] + C[i-1];
    
    for(int i=1; i<=n; i++){
        B[C[A[i]]] = A[i];
        C[A[i]]--;
    }

    for(int i=1; i<=n; i++){
        if(i>1) printf(" ");
        printf("%u", B[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 10412
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif 


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

    string S;  cin >> S;
    int N = S.size();

    const ll MOD = 1e9 + 7;
    const int M = 13;
    vvl dp(N + MGN, vl(M + MGN, 0));
    dp[0][0] = 1;

    for(int i=0; i<N; i++) {
        if (S[i]=='?') {
            for (int d = 0; d<=9; d++) {
                for(int j=0; j<M; j++) {
                    dp[i+1][(j*10 + d) % M] += dp[i][j];
                    dp[i+1][(j*10 + d) % M] %= MOD;
                }
            }
        } else {
            int d = S[i] - '0';
            for(int j=0; j<M; j++) {
                dp[i+1][(j*10 + d) % M] += dp[i][j];
                dp[i+1][(j*10 + d) % M] %= MOD;
            }
        }
    }

    ll ans = dp[N][5];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 19920
#include<bits/stdc++.h>
using namespace std;
#define mx 200001
#define inf 1e9
vector<int>adjlist[mx];
int visited[mx],dist[mx];
void bfs(int s){
    dist[s]=0,visited[s]=1;
    queue<int>q;
    q.push(s);
    while(!q.empty()){
        int u=q.front();
        q.pop();
        for(auto v : adjlist[u]){
            if(!visited[v]){
                visited[v]=1;
                dist[v]=dist[u]+1;
                q.push(v);
            }
        }
    }
}
int main(){
    int n,m,x,y,i;
    cin>>n>>m;
    for(i=0;i<m;i++){
        cin>>x>>y;
        adjlist[x].push_back(y);
        adjlist[y].push_back(x);
    }
    bfs(1);
    if(dist[n]==2)printf("POSSIBLE\n");
    else printf("IMPOSSIBLE\n");
    return 0;
}


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

using namespace std;

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

typedef int _loop_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)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,m;
int x[125252];

// O(N^2)
void naive1(){
  vi dp(n+1,0);
  dp[n] = 1;
  int tail = m-1;
  FORR(i,0,n){
    if(tail>=0 && x[tail]==i){
      tail--;
      continue;
    }
    FOR(j,i+1,n+1){
      ll sa = j-i;
      dp[i] += sa*sa%MOD*dp[j]%MOD;
      if(dp[i]>=MOD)dp[i]-=MOD;
    }
  }
  printf("%d\n",dp[0]);
}

// O(N)
void naive2(){
  // (x+1)^2 - x^2 = 2x + 1
  ll xxc = 1; // x^2 * c
  ll xc = 1;  // x * c
  ll c = 1;   // c
  int tail = m-1;
  FORR(i,1,n){
    ll dp = 0;
    if(tail>=0 && x[tail]==i){
      tail--;
    }else{
      dp = xxc;
    }
    // step
    xxc += 2*xc + c;
    xxc %= MOD;
    xc += c;
    xc %= MOD;
    // add
    xxc += dp;
    xxc %= MOD;
    xc += dp;
    xc %= MOD;
    c += dp;
    c %= MOD;
  }
  printf("%lld\n",xxc);
}

// O(MlogN)
typedef vector<vi> mat;
mat mul(mat a,mat b){
  int n = a.size();
  mat r(n,vi(n,0));
  REP(i,n)REP(j,n)REP(k,n){
    (r[i][j] += (ll)a[i][k] * b[k][j] % MOD) %= MOD;
  }
  return r;
}
mat mpow(mat a,int x){
  int n = a.size();
  mat ret(n,vi(n,0));
  REP(i,3)ret[i][i] = 1;
  while(x>0){
    if(x&1)ret=mul(ret,a);
    a=mul(a,a);
    x>>=1;
  }
  return ret;
}
void solve(){
  // I
  mat I(3,vi(3,0));
  REP(i,3)I[i][i] = 1;
  // 0 successive
  mat A(3,vi(3,0));
  A[0][0] = 1; A[0][1] = 2; A[0][2] = 1;
  A[1][1] = 1; A[1][2] = 1; A[2][2] = 1;
  // 1 successive
  mat B = A;
  REP(i,3)B[i][0] += 1;
  // solve
  mat ans = I;
  int last = n-1;
  FORR(i,0,m){
    ans = mul(mpow(B,last-x[i]), ans);
    ans = mul(A, ans);
    last = x[i]-1;
  }
  ans = mul(mpow(B,last-1+1), ans);
  ll yo = ((ll)ans[0][0] + ans[0][1] + ans[0][2]) % MOD;
  printf("%lld\n",yo);
}

int main(){
  scanf("%d%d",&n,&m);
  REP(i,m)scanf("%d",x+i);
  solve();
  return 0;
}


Measured memory_bytes: 640
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>

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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;


ll N, M;


vector<pint> query;
int main() {
	cin >> N >> M;


	ll a, b;
	rep(i, M) {
		cin >> a >> b;

		query.push_back(make_pair(a, b));

	}

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

	priority_queue < ll, vector<ll>, greater<ll>> pq;
	ll ans = 0;
	rep(i, query.size()) {


		if (pq.size() != 0) {
			if (query[i].first >= pq.top()) {

				int l = pq.size();
				rep(j, l) pq.pop();
			}
		}


		if (pq.size() == 0)
			ans += 1;

		pq.push(query[i].second);


	}



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

Measured memory_bytes: 1780
def a():
    s = input()
    total = 700
    for i in s:
        total += 100 if i == 'o' else 0
    print(total)


def b():
    n, x = map(int, input().split())
    m = [int(input()) for _ in range(n)]
    print(len(m) + ((x - sum(m)) // min(m)))


b()


Measured memory_bytes: 2940
fun main(args: Array<String>) {
  val (a, b, x) = readLine()!!.split(" ").map { it.toDouble() }
  if (a * a * b / 2 > x) {
    val rad = Math.atan(a * b * b / (2.0 * x))
    println(rad * 180 / Math.PI)
  } else {
    val rad = Math.atan((2.0 / (a * a)) * (a * b - x / a))
    println(rad * 180 / Math.PI)
  }
}



Measured memory_bytes: 35948
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	cin >> n;
	vector<long long> a(n), b(n), c(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	long long d[n];
	fill(d, d+n, -1);
	long long e[n];
	fill(e, e+n, -1);

	int right = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] < b[right]) {
			d[right] = i;
			continue;
		}
		while (a[i] >= b[right] && right < n) {
			d[right] = i-1;
			right++;
		}
		if (right < n)
			d[right] = i;
	}
	right++;
	for (; right < n; right++)
		d[right] = d[right-1];

	right = 0;
	for (int i = 0; i < n; i++) {
		if (b[i] < c[right]) {
			e[right] = i;
			continue;
		}
		while (b[i] >= c[right] && right < n) {
			e[right] = i-1;
			right++;
		}
		if (right < n)
			e[right] = i;
	}
	right++;
	for (; right < n; right++)
		e[right] = e[right-1];
//	cout << "d: " << endl;
//	for (int i = 0; i < n; i++) {
//		printf("%d ", d[i]);
//	}
//	cout << endl;
//	cout << "e: " << endl;
//	for (int i = 0; i < n; i++) {
//		printf("%d ", e[i]);
//	}
//	cout << endl;
	long long bsum[n], csum[n];
	for (int i = 0; i < n; i++) {
		if (i == 0)
			bsum[i] = d[i]+1;
		else
			bsum[i] = bsum[i-1] + d[i]+1;
	}
	for (int i = 0; i < n; i++) {
		if (i == 0) {
			if (e[i] == -1)
				csum[i] = 0;
			else
				csum[i] = bsum[e[i]];
		} else {
			if (e[i] == -1)
				csum[i] = csum[i-1];
			else
				csum[i] = csum[i-1] + bsum[e[i]];
		}
	}
	cout << csum[n-1] << endl;
	return 0;
}

Measured memory_bytes: 8808
#include<iostream>
#define ll long long
using namespace std;
int main(int argc, char *argv[])
{
	ll a;
	cin>>a;
	if(a%100 <= 12 && a%100>0 && a/100 <= 12 && a/100 >0 )
	{
		cout<<"AMBIGUOUS"<<endl;
	}
	else if (a%100<=12 && a%100>0)
	{
		cout<<"YYMM"<<endl;
	}
	else if (a/100<=12 && a/100>0)
	{
		cout<<"MMYY"<<endl;
	}
	else cout<<"NA"<<endl;
	
	
	

	return 0;
}

Measured memory_bytes: 3044
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np
from collections import deque

def abc075_c():
    N, _ = map(int, readline().strip().split())
    edge_list = []  # 辺のリスト
    adj_mtx = np.zeros((N, N), dtype=int)  # 隣接行列(0-index)
    for ln in readlines():
        a, b = map(int, ln.strip().split())
        edge_list.append((a-1, b-1))
        adj_mtx[a-1, b-1] = adj_mtx[b-1, a-1] = 1

    def bfs(start: int, W: list):
        que = deque()  # 未訪問点
        dist = [-1] * len(W)  # 最短距離
        que.append(start)  # スタート地点で初期化
        dist[start] = 0  # スタート地点で初期化
        while que:
            here = que.popleft()  # 今いる点
            # 隣接点を処理
            for i, node in enumerate(W[here]):
                if node == 0: continue  # つながっていない
                if dist[i] != -1: continue  # 訪問済み
                dist[i] = dist[here] + 1  # 距離を更新
                que.append(i)  # 処理待ちに追加
        return dist

    ans = 0
    for a, b in edge_list:
        # 辺の1つを取り除く
        adj_mtx[a, b] = adj_mtx[b, a] = 0
        # bfsして未訪問点が存在するなら、取り除いた辺は橋である
        dist = bfs(0, adj_mtx.tolist())
        if -1 in dist: ans += 1
        # 取り除いた辺を元に戻す
        adj_mtx[a, b] = adj_mtx[b, a] = 1

    print(ans)

abc075_c()

Measured memory_bytes: 12512
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = (Node*)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	//どの節点の下にキーを格納するか探す//
	while (x != NIL) {
		y = x;
		if (z->key < x->key) {
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	//上で決めた節点の左か右のどちらの子になるかをきめる
	z->parent = y;
	if (y == NIL) {
		root = z;
	}
	else {
		if (z->key < y ->key) {
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if (u == NIL)return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if (u == NIL)return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}

int main() {
	int n, i, x;
	string com;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		cin >> com;
		if (com == "insert") {
			scanf("%d", &x);
			insert(x);
		}
		else if (com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}

	}

	return 0;
}



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

int main() {
	// your code goes here
	int n;
	int a[20][20];
	cin>>n;
	while(n!=0){
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				a[i][j]=0;
			}
		}
		int k=1+n/2;
		int l=n/2;
		int m=1;
a[k][l]=1;
		for(int u=0;u<n;u++){
			for(int v=1;v<n;v++){
			
			k=(k+1)%n;
			l=(l+1)%n;
			m=m+1;
			a[k][l]=m;
			}
			k=(k+2)%n;
			m=m+1;
			a[k][l]=m;
		}
		a[k][l]=a[k][l]-n*n;
		for(int q=0;q<n;q++){
			for(int w=0;w<n;w++){
				if(10>a[q][w]){
				cout<<"   "<<a[q][w];
				}
				else if(100>a[q][w]){
					cout<<"  "<<a[q][w];
				}
				else if(99<a[q][w]){
					cout<<" "<<a[q][w];
				}
			}
			cout<<endl;
		}
		
		
		cin>>n;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    ll n,a,b,c,d,e;
    cin >> n >> a >> b >> c >> d >> e;
    cout << 5 + (n+min({a,b,c,d,e})-1)/min({a,b,c,d,e})-1 << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

int main() {
  string S_A, S_B, S_C;
  cin >> S_A >> S_B >> S_C;
  
  queue<char> card_A, card_B, card_C;
  for (int i = 0; i < S_A.size(); i++) card_A.push(S_A.at(i));
  for (int i = 0; i < S_B.size(); i++) card_B.push(S_B.at(i));
  for (int i = 0; i < S_C.size(); i++) card_C.push(S_C.at(i));
  
  char answer;
  char turn = card_A.front();
  card_A.pop();
  while (true) {
    if (turn == 'a') {
      if (card_A.empty()) {
        answer = 'A';
        break;
      }
      turn = card_A.front();
      card_A.pop();
    }
    else if (turn == 'b') {
      if (card_B.empty()) {
        answer = 'B';
        break;
      }
      turn = card_B.front();
      card_B.pop();
    }
    else {  // if (turn == 'c')
      if (card_C.empty()) {
        answer = 'C';
        break;
      }
      turn = card_C.front();
      card_C.pop();
    }
  }
  
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())

A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

answer = 0

for i in range(N - 1):
    if A_list[i + 1] - A_list[i] == 1:
        answer += C_list[A_list[i] - 1]

answer += sum(B_list)

print(answer)


Measured memory_bytes: 3060
n = int(input())
t = 0
s = set()
ans = 1
for i in range(n):
    w = input()
    if w[0] != t and i >= 1:
        ans = 0
        break
    t = w[-1]
    s.add(w)
if len(s) != n:
    ans = 0
print(["No","Yes"][ans])

Measured memory_bytes: 8928