akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double eps = 1e-7;
#define Loop(i, n) for(int i = 0; i < int(n); i++)
#define Loopll(i, n) for(ll i = 0; i < ll(n); i++)
#define Loop1(i, n) for(int i = 1; i <= int(n); i++)
#define Loopll1(i, n) for(ll i = 1; i <= ll(n); i++)
#define Loopr(i, n) for(int i = int(n) - 1; i >= 0; i--)
#define Looprll(i, n) for(ll i = ll(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = int(n); i >= 1; i--)
#define Looprll1(i, n) for(ll i = ll(n); i >= 1; i--)
#define Foreach(buf, container) for(const auto &buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
#define INF INFINITY
bool feq(double x, double y) { return abs(x - y) <= eps; }
bool inrange(ll x, ll t) { return x >= 0 && x < t; }
bool inrange(vll xs, ll t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
int ceillog2(ll x) { int ret = 0;	x--; while (x > 0) { ret++; x >>= 1; } return ret; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

//========================================================================//

int main() {
	ll n; cin >> n;
	if (n % 2 == 1) {
		cout << n / 2 << endl;
	}
	else {
		cout << n / 2 - 1 << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int n;
int *C;
int countingsort(int *A,int *B,int *C,int k){
  int i,j;
  for(i=0;i<=k;i++)C[i]=0;
  for(j=1;j<=n;j++)C[A[j]]++;
  // for(j=1;j<n;j++)printf("%d ",C[j]);
  // printf("%d\n",C[j]);
  for(i=1;i<=k;i++)C[i]=C[i]+C[i-1];
  // for(j=1;j<n;j++)printf("%d ",C[j]);
  // printf("%d\n",C[j]);
   for(j=n;j>=1;j--){
     B[C[A[j]]]=A[j];
     C[A[j]]--;	 
   }
   return 0;
}
int main(){
  int i;
  int k=0;
  int *A,*B;
  
  scanf("%d",&n);
  A=(int *)malloc(sizeof(int)*n+1);
  B=(int *)malloc(sizeof(int)*n+1);

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    if(k<A[i])k=A[i];
  }
  C=(int *)malloc(sizeof(int)*k);
  //printf("%d\n",k);
  countingsort(A,B,C,k);
  for(i=1;i<n;i++)printf("%d ",B[i]);
  printf("%d\n",B[i]);
  return 0;
}

Measured memory_bytes: 16268
#include <cstdio>
#include <algorithm>
using namespace std;

struct UF {
  int *p;
  UF(int N):p(new int[N]) {fill(p,p+N,-1);}
  ~UF(){delete[] p;}
  int rt(int x){return p[x]<0?x:(p[x]=rt(p[x])); }
  bool cat(int x,int y) {
    if((x=rt(x))==(y=rt(y)))return false;
    if(p[x]<p[y])swap(x,y);
    p[y]+=p[x];
    p[x]=y;
    return true;
  }
};

int main() {
  for(int tci = 0; ; tci++) {
    int n,m; scanf("%d%d", &n, &m);
    if(n==0) break;
    pair<int,pair<int,int> > *edges = new pair<int,pair<int,int> >[m];
    for(int i = 0; i < m; i++) {
      scanf("%d%d%d", &edges[i].second.first, &edges[i].second.second, &edges[i].first);
    }
    sort(edges,edges+m);
    long long costsum = 0;
    UF uf(n);
    for(int i = 0; i < m; i++) {
      if(uf.cat(edges[i].second.first,edges[i].second.second)) {
        costsum += edges[i].first;
      }
    }
    printf("%lld\n", costsum);
    delete[] edges;
  }
  return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 ll INF = 1LL << 60;
const int MAX = 100010;

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[10];
		int size = 0;

		while (sc.hasNext()) {
			int number = sc.nextInt();
			if (number == 0) {
				System.out.println(a[size - 1]);
				size--;
			} else {
				a[size] = number;
				size++;
			}
		}
	}
}

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

int Frame[256], loves, Mzq[256];
string s;
int main()
{
	cin >> loves >> s;
	for (register int i = 0;i < s.length();i ++)
	{
		Frame[s[i]] ++;
	}
	while(-- loves)
	{
		cin >> s;
		memset(Mzq, 0, sizeof(Mzq));
		for (register int i = 0;i < s.length();i ++)
		{
			Mzq[s[i]] ++;
		}
		for (register int i = 'a';i <= 'z';i ++)
		{
			Frame[i] = min(Frame[i], Mzq[i]);
		}
	}
	for (register int i = 'a';i <= 'z';i ++)
	{
		while(Frame[i] --) putchar(i);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <functional>
#include <cstring>
using namespace std;
#define MAX_V 10240
 
// ?????¶???from????????¶???to????????????cost??????
typedef struct edge
{
    int to, distance, cost;
    edge(){}
    edge(int to, int distance, int cost) : to(to), distance(distance), cost(cost){}
};
 
// first ???????????????????????????second????????¶?????????
typedef pair<int, int> P;
 
// ???
vector<edge> G[MAX_V];
 
// ????????????
int d[MAX_V];
// V?????¶?????°
int V;
 
// ?±??§£?????¶???s????????°?????????????????????????????¶???????°???±?´????
void dijkstra(int s)
{
    priority_queue<P, vector<P>, greater<P> > que;
    memset(d, 0x3f, sizeof(d));
    d[s] = 0;
    que.push(P(0, s));
 
    while (!que.empty())
    {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); ++i)
        {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.distance)
            {
                d[e.to] = d[v] + e.distance;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
 
    int /*N = V,*/ M;
    while (cin >> V >> M && V)
    {
        for (int i = 0; i < V; ++i)
        {
            G[i].clear();
        }
        for (int i = 0; i < M; ++i)
        {
            int u, v, d, c;
            cin >> u >> v >> d >> c;
            --u, --v;
            G[u].push_back(edge(v, d, c));
            G[v].push_back(edge(u, d, c));
        }
        // ?????????0???
          dijkstra(0);
        int ans = 0;
        for (int i = 1; i < V; ++i)
        {
            int min_cost = 0x3f3f3f3f;
            // ??????????¶????????????????????????¶????´???¨???????????£??????????´???¨
            for (int j = 0; j < G[i].size(); ++j)
            {
                if (d[G[i][j].to] + G[i][j].distance == d[i] && G[i][j].cost < min_cost)
                {
                    min_cost = G[i][j].cost;
                }
            }
            ans += min_cost;
        }
        cout << ans << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int x, a; cin >> x >> a;
    if (x < a) cout << 0 << endl;
    else cout << 10 << endl;
}


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

using namespace std;
const int maxn = 1e5+10;

int n, k;
int niz[maxn];

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++)
        scanf("%d", niz+i);

    int pos = -1;
    for (int i = 0; i < n; i++)
        if (niz[i] == 1) pos = i;

    printf("%d", (n + k - 3) / (k - 1));
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,a[100005],k;
ll dp[100005];
ll m=INT_MAX;

ll fun(ll p)
{
    if(p==n-1)
    {
        return 0;
    }
    if(p>=n)
    {
        return INT_MAX;
    }
    if(dp[p]!=-1)
    {
        return dp[p];
    }
    for(ll j=1;j<=k;j++)
    {
        //  ll l=abs(a[p]-a[p+j])+fun(p+j);
        // ll r=INT_MAX;
        // if((p+j+1)<n)
        // {
        //     r=abs(a[p]-a[p+j+1])+fun(p+j+1);
        // }
        //  return dp[p]=min(r,l);
        if((p+j)<n)
        {
            
            ll r=fun(p+j);
            ll l=abs(a[p]-a[(p+j)])+r;
            // cout<<(p+j)<<" "<<p<<" "<<j<<" "<<abs(a[p]-a[(p+j)])<<" "<<r<<'\n';
            // cout<<p<<" "<<r<<'\n';
            if(j==1 && m<l)
            {
                m=m+l;
            }
            m=min(m,l);
        }
        else
        {
            break;
        }
        
    }
   return dp[p]=m;
   
}

int main() {
  
    ll i;
    cin>>n>>k;
    memset(dp,-1,sizeof dp);
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        
    }
    // fun(0);
    cout<<fun(0)<<'\n';
    // for(i=0;i<n;i++)
    // {
    //     cout<<dp[i]<<" ";
    // }
   
return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n,k;
    cin >> n >> k;
    double ans = 0;
    vector<double> p;
    vector<int> val;
    REP(i,n){
        p.push_back(1.0 / n);
        val.push_back(i+1);
    }
    REP(i,n)
    {
        while(1)
        {
            if(val[i]>=k)
            {
                ans += p[i];
                break;
            }
            val[i]*=2;
            p[i]*=0.5;
        }
    }
    //cout << ans << endl;
    printf("%.16f", ans);
}


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


int main() {
  char x, y;
  cin >> x >> y;
  if(x > y) cout << ">" << endl;
  else if (x < y) cout << "<" << endl;
  else cout << "=" << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];

  int a = 0, b = 0, ab = 0;
  bool c = true;
  rep(i, n) {
    int l = s[i].size();
    if (s[i][0] == 'B') ++b;
    if (s[i][l-1] == 'A') ++a;
    rep(j, l-1) {
      if (s[i][j] == 'A' && s[i][j+1] == 'B') ++ab;
    }
    if (s[i][0] == 'B' && s[i][l-1] != 'A' ||
        s[i][0] != 'B' && s[i][l-1] == 'A') c = false;
  }
  int ans = ab + min({a, b});
  if (c && a * b > 0) --ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3676
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class Segtree<T>
{
    int n;
    T[] tree;
    Func<T, T, T> f;
    T exnum;
    public Segtree(int m, Func<T, T, T> f, T ex)
    {
        this.f = f;
        this.exnum = ex;
        n = 1;
        while (n < m) n <<= 1;

        tree = new T[(n << 1) - 1];
        for (int i = 0; i < tree.Length; i++) tree[i] = ex;
    }
    public Segtree(int m, T ini, Func<T, T, T> f, T ex)
    {
        this.f = f;
        this.exnum = ex;
        n = 1;
        while (n < m) n <<= 1;

        tree = new T[(n << 1) - 1];
        for (int i = 0; i < tree.Length; i++) tree[i] = ini;
        for (int i = 0; i < m; ++i) update(i, ini);
    }
    public void update(int j, T x)
    {
        int i = j + n - 1;
        tree[i] = x;
        while (i > 0)
        {
            i = (i - 1) >> 1;
            tree[i] = f(tree[(i << 1) + 1], tree[(i << 1) + 2]);
        }
    }
    public T look(int i) { return tree[i + n - 1]; }

    // [s, t]
    public T run(int s, int t) { return query(s, t + 1, 0, 0, n); }
    T query(int s, int t, int k, int l, int r)
    {
        if (r <= s || t <= l) return exnum;
        if (s <= l && r <= t) return tree[k];

        return f(query(s, t, (k << 1) + 1, l, (l + r) >> 1), query(s, t, (k + 1) << 1, (l + r) >> 1, r));
    }
}

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());

            Console.WriteLine((a + c) * b / 2);
        }
    }
}

Measured memory_bytes: 2648
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	int n, d;
	string s;
	cin>>n>>s>>d;
	string t = s;
	for(int i = 0; i < n; i++) {
		if(d == 0) break;
		if(s[i] == '0') {
			t[i] = '1';
			d--;
		}
	}
	for(int i = 0; i < n; i++) {
		if(d == 0) break;
		if(s[s.size() - 1 -i] == '1') {
			t[s.size() - 1 -i] = '0';
			d--;
		}
	}
	cout<< t<<endl;
}

Measured memory_bytes: 3172
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let mut hh = (0..n).map(|_| read::<usize>()).collect::<Vec<_>>();
    let ans = solve(&mut hh, 0, n);
    println!("{}", ans);

    use std::cmp::min;
    fn solve(hh: &mut Vec<usize>, l: usize, r: usize) -> usize {
        let mut ans = 0;
        let mut start = l;
        let inf = usize::max_value();
        let mut small = inf;
        for i in l..r + 1 {
            if i == r || hh[i] == 0 {
                if small < inf {
                    for j in start..i {
                        hh[j] -= small
                    }
                    ans += small + solve(hh, start, i);
                    small = inf
                }
                start = i + 1;
            } else {
                small = min(small, hh[i])
            }
        }
        ans
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;
ll v[100010];
ll v1[100010];
ll v2[100010];
vector< pair<ll, ll> > pair1, pair2;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    rep(i,0,N){
        cin >> v[i];
    }
    rep(i,0,N){
        if(i % 2 == 0){
            v1[i/2] = v[i];
        }else{
            v2[i/2] = v[i];
        }
    }
    sort(v1, v1 + N/2);
    sort(v2, v2 + N/2);
    ll cnt = 1;
    rep(i,1,N/2){
        if(v1[i] == v1[i-1]){
            cnt++;
        }else{
            pair1.push_back(make_pair(cnt, v1[i-1]));
            cnt = 1;
        }
    }
    pair1.push_back(make_pair(cnt, v1[N/2 - 1]));

    cnt = 1;
    rep(i,1,N/2){
        if(v2[i] == v2[i-1]){
            cnt++;
        }else{
            pair2.push_back(make_pair(cnt, v2[i-1]));
            cnt = 1;
        }
    }
    pair2.push_back(make_pair(cnt, v2[N/2 - 1]));
    sort(pair1.begin(), pair1.end());
    sort(pair2.begin(), pair2.end());
    ll n1 = pair1.size();
    ll n2 = pair2.size();
    ll ans = 0;
    if(pair1[n1-1].second != pair2[n2-1].second){
        ans = N - pair1[n1-1].first - pair2[n2-1].first;
    }else{
        if(n2 == 1){
            ans = N - pair1[n1-1].first;
        }else{
            ans = N - pair1[n1-1].first - pair2[n2-2].first;
        }

        if(n1 == 1){
            ans = min(ans, N - pair2[n2-1].first);
        }else{
            ans = min(ans, N - pair2[n2-1].first - pair1[n1-2].first);
        }
    }
    //if(pair1[n1-1].first >= pair2[n2-1].first){
    //    if(pair1[n1-1].second != pair2[n2-1].second){
    //        ans = N - pair1[n1-1].first - pair2[n2-1].first; 
    //    }else{
    //        if(n2 == 1){
    //            ans = N - pair1[n1-1].first;
    //        }else{
    //            ans = N - pair1[n1-1].first - pair2[n2-2].first;
    //        }
    //    }
    //}else{
    //    if(pair1[n1-1].second != pair2[n2-1].second){
    //        ans = N - pair1[n1-1].first - pair2[n2-1].first; 
    //    }else{
    //        if(n1 == 1){
    //            ans = N - pair2[n2-1].first;
    //        }else{
    //            ans = N - pair2[n2-1].first - pair1[n1-2].first;
    //        }
    //    }
    //}

    print(ans);



}


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int A,B;
cin>>A>>B;
if((A+B)%3==0||A%3==0||B%3==0)cout<<"Possible";
else cout<<"Impossible";
  return 0;
}

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

int main() {

    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    //1 a+b<cなら min(x, y) だけ買う。|x-y|だけcで買うのかbで買うのか

    int ans = 0;

    int diff = abs(x-y);
    
    //a + b < 2*c なら別々に買った方が安い。
    if ((a+b) <= 2*c) {
       ans = a*x + b*y; 
    } else {
          
      
      if (x > y) { 
         ans += c*(y*2);
         
         if (a <= 2*c) {
            ans += (a*diff);
         } else {
            ans += c * (diff*2);
         } 
      } else {
     
         ans += c*(x*2);
         
         if (b <= 2*c) {
            ans += (b*diff);
         } else {
            ans +=  c * (diff*2);
         }     
      }
    }

    cout << ans << endl;

    return 0;	
}

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

int main(){
    int min,max,n,i;
    int *data;
    long sum;
    cin>>n;
    data= new int[n];
    for (i=0;i<n;i++)cin>>data[i];
    min=data[0];max=data[0];sum=data[0];
    for (i=1;i<n;i++){
      sum+=data[i];
      if (min>data[i])min=data[i];
      else if (max<data[i])max=data[i];
    }
    cout<<min<<" "<<max<<" "<<sum<<endl;
    return 0;


}



Measured memory_bytes: 3116
import sys
from io import StringIO
import unittest

def resolve():

    n = int(input())
    a_s = list(map(int, input().split()))

    numdict = {}
    for a in a_s:
        numdict[a] = numdict.get(a, 0) + 1

    # bannしない場合のパターン数を得る。
    all_cnt = 0
    for val in numdict.values():
        all_cnt += val*(val-1) / 2

    # k番目を除いた場合のパターン数を出力していく。
    for a in a_s:
        # k番目が存在しない場合の影響数を取得
        val = numdict[a]
        work = (val-1)*(val-1-1) / 2 - val*(val-1) / 2
        print(int(all_cnt + work))



class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5
1 1 2 1 2"""
        output = """2
2
3
2
3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4
1 2 3 4"""
        output = """0
0
0
0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5
3 3 3 3 3"""
        output = """6
6
6
6
6"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """8
1 2 1 4 2 1 4 1"""
        output = """5
7
5
7
7
5
7
5"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()






Measured memory_bytes: 98884
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<long> a(n);
    vector<ll> s(n+1);
    long i;
    s[0]=0;
    for(i=0; i<n; i++) {
        scanf("%ld", &a[i]);
        s[i+1]=s[i]+a[i];
    }

    ll cnt0=0;
    {
        ll dif=0;
        for(i=1; i<=n; i++) {
            if(i%2==0 && s[i]+dif<=0) {
                cnt0+=1-(s[i]+dif);
                dif+=1-(s[i]+dif);
            }
            else if(i%2==1 && s[i]+dif>=0) {
                cnt0+=(s[i]+dif+1);
                dif-=(s[i]+dif+1);
            }
        }
    }

    ll cnt1=0;
    {
        ll dif=0;
        for(i=1; i<=n; i++) {
            if(i%2==1 && s[i]+dif<=0) {
                cnt1+=1-(s[i]+dif);
                dif+=1-(s[i]+dif);
            }
            else if(i%2==0 && s[i]+dif>=0) {
                cnt1+=(s[i]+dif+1);
                dif-=(s[i]+dif+1);
            }
        }
    }
    printf("%lld\n", MIN(cnt0,cnt1) );

    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <tr1/random>
using namespace std;

const int INF = 200000000;
tr1::mt19937 mt;

struct RBST{
	int count;
	int value;
	int minimum;
	RBST *l, *r;
	RBST(int value = 0):count(1), value(value), minimum(value), l(NULL), r(NULL){}
	static int size(RBST *a){
		return a ? a->count : 0;
	}
	static int get_min(RBST *a){
		return a ? a->minimum : INF;
	}
	RBST *update(){
		count = 1 + size(l) + size(r);
		minimum = min({get_min(l), get_min(r), value});
		return this;
	}
	// aとbを連結する(破壊的)
	static RBST *merge(RBST *a, RBST *b){
		if(!a || !b) return a?a:b;
		if( (int)(mt() % (size(a) + size(b))) < size(a)){ // aの方が優先度が高い
			a->r = merge(a->r, b);
			return a->update();
		}else{
			b->l = merge(a, b->l);
			return b->update();
		}
	}

	// [0,k)と[k,n)の2つの木に分割する
	static pair<RBST*,RBST*> split(RBST *a, int k){
		if(!a) return make_pair<RBST*,RBST*>(NULL, NULL);
		if(k <= size(a->l)){
			pair<RBST*,RBST*> t = split(a->l, k);
			a->l = t.second;
			return make_pair(t.first, a->update());
		}else{
			pair<RBST*,RBST*> t = split(a->r, k - size(a->l) - 1);
			a->r = t.first;
			return make_pair(a->update(), t.second);
		}
	}
};


RBST nodes[200000];
int p;
int x,y,z;
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	RBST *s;
	for(int i=0;i<n;i++){
		int a;
		scanf("%d", &a);
		nodes[p] = RBST(a);
		s = RBST::merge(s, &nodes[p++]);
	}
	for(;k--;){
		scanf("%d%d%d",&x,&y,&z);
		if(x==0){
			z++;
			auto t1 = RBST::split(s, y);
			auto t2 = RBST::split(t1.second, z - y);
			auto t3 = RBST::split(t2.first, RBST::size(t2.first) - 1);
			s = RBST::merge(RBST::merge(t1.first,RBST::merge(t3.second, t3.first)), t2.second);
		}else if(x==1){
			z++;
			auto t1 = RBST::split(s, y);
			auto t2 = RBST::split(t1.second, z - y);
			printf("%d\n",RBST::get_min(t2.first));
			s = RBST::merge(t1.first,RBST::merge(t2.first,t2.second));
		}else{
			auto t1 = RBST::split(s,y);
			auto t2 = RBST::split(t1.second, 1);
			*t2.first = RBST(z);
			s = RBST::merge(t1.first,RBST::merge(t2.first,t2.second));
		}
	}
}

Measured memory_bytes: 7440
from sys import stdin
from itertools import accumulate
readline = stdin.readline

N, W = map(int, input().split())
vs = [[] for _ in range(4)]
w, v = map(int, input().split())
w1 = w
vs[0].append(v)
for _ in range(N - 1):
    w, v = map(int, input().split())
    vs[w - w1].append(v)

for i in range(4):
    vs[i].sort(reverse=True)
    vs[i] = list(accumulate(vs[i]))

result = 0
for i in range(len(vs[0]) + 1):
    a = W - w1 * i
    if a < 0:
        break
    for j in range(len(vs[1]) + 1):
        b = a - (w1 + 1) * j
        if b < 0:
            break
        for k in range(len(vs[2]) + 1):
            c = b - (w1 + 2) * k
            if c < 0:
                break
            t = 0
            if i != 0:
              t += vs[0][i - 1]
            if j != 0:
              t += vs[1][j - 1]
            if k != 0:
              t += vs[2][k - 1]
            for l in range(len(vs[3]) + 1):
                d = c - (w1 + 3) * l
                if d < 0:
                    break
                if l == 0:
                    result = max(result, t)
                else:
                    result = max(result, t + vs[3][l -1])
print(result)


Measured memory_bytes: 9300
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


void solve(long long N, std::vector<std::string> S){
    map<string,int> um;
    ll ma=0;
    for (ll i = 0; i < N; i++) {
        um[S[i]]++;
        chmax(ma,(ll)um[S[i]]);
    }
    for (auto& e: um) {
        if(e.second==ma){
            cout << e.first << endl;
        }
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


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

using namespace std;

#define MAX 5050
typedef long long ll;
const ll MOD = ((1e9) + 7);

int dp[2][MAX];

int main()
{
    int N, L;
    cin >> N >> L;
    vector<int> x(N), a(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i]; 
    }
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }

    for (int i = 0; i < L; i++) {
        dp[0][i] = 1;
    }
    
    for (int i = 0; i < N; i++) {
        int curr = i & 1, next = !curr;
        for (int j = x[i]; j < L; j += a[i]) {
            if (j > 0) {
                dp[next][j] += dp[curr][j-1];
            } else {
                dp[next][j] = dp[curr][j];
            }
            dp[next][j] %= MOD;
            if (a[i] == 0) break;
        }
        
        for (int j = x[i]; j < L; j++) {
            dp[next][j+1] += dp[next][j];
            dp[next][j+1] %= MOD;
        }
        fill(dp[curr], dp[curr] + L, 0);
    }
    
    cout << dp[N&1][L-1] << endl;
    return 0;
}

Measured memory_bytes: 3140
def is_reachable(edges,start,end):
  g = {}
  for f,t,w in edges:
    if f in g: g[f].append(t)
    else: g[f] = [t]
  visiting = [start]
  visited = {}
  while visiting:
    v = visiting.pop()
    if v in visited: continue
    if v == end: return True
    visited[v] = True
    for v2 in g.get(v, ()):
      if v2 in visited or v2 in visiting: continue
      visiting.append(v2)
  return False

N,M,P = map(int, input().split())

edges = []
for _ in range(M):
    a,b,c = map(int, input().split())
    edges.append((a,b,c))

neg_inf = float("-Inf")
no_answer = False

start = 1
end = N

distance = {}
for i in range(1,N+1):
  distance[i] = neg_inf
distance[start] = 0

for i in range(N-1):
    for f,t,w in edges:
        if distance[f] + w - P > distance[t]:
            distance[t] = distance[f] + w - P

for f,t,w in edges:
    if distance[f] + w - P > distance[t] and is_reachable(edges,t,end):
        no_answer = True
        break

if no_answer:
    print(-1)
else:
    print(max(0,distance[end]))


Measured memory_bytes: 51180
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    a,b,k = map(int,input().strip().split())
    print( max(a-k,0), max(min(b,a+b-k),0) )


if __name__ == '__main__':
    main()

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

using namespace std;
int n,a[200100];
set < int > st;

int main()
{
    cin >> n;
    for(int i = 0;i<n;i++)  cin >> a[i],st.insert(a[i]);
    cout << (st.size() == n ? "YES" : "NO");
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define REP(i, n) for(ll i = 0LL; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define FOR(i, n, m) for(ll i = (ll)n; i < (ll)(m); i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define PRINT(x) std::cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dx[8] = {0,1,0,-1, 1, -1, 1, -1}, dy[8] = {1,0,-1,0,1,1,-1,-1};

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

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}

int main()
{ 
  ll X;
  cin >> X;
  PRINT(10 - X/200);
  return 0;
} 


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

int main(){
  
  int A, B;
  
  cin >> A >> B;
  
  
  if (A + B == 3){
    cout << 3 << endl;
  }else if (A + B == 5){
    cout << 1 << endl;
  }else{
    cout << 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
using namespace std; 
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
#define ve vector 
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007
#define PRECISE cout.precision(18);
#define all(c) c.begin(), c.end()
#define sec second
#define fst first
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
int main()
{
    ll n;
    cin>>n;
    ll h[n];
    for (ll i = 0; i < n; ++i)
    {
        cin>>h[i];
    }
    ll dp[n];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for (ll i = 2; i < n; ++i)
    {
        dp[i]=std::min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 5152
#!/usr/bin/env python3
from collections import Counter

def main():
    *I, = map(str, open(0).read().split())
    N = I[0]
    N = I[1:]
    
    cnt = Counter(N)
    m = max(cnt.values())

    for val in sorted(ele for ele, val in cnt.items() if val == m):
	    print(val)



main()

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<string> s(n);
  vector<vector<int>> ch(n);
  for (int i = 0; i < n; ++i) {
    int p;
    cin >> p;
    --p;
    cin >> s[i];
    if (p >= 0) {
      ch[p].push_back(i);
    }
  }
  vector<int> d(n);
  for (int i = 0; i < n; ++i) {
    for (int j : ch[i]) {
      d[j] = d[i] + 1;
    }
  }
  auto dfs = [&](auto&& self, int v) -> void {
    cout << string(d[v], '.') << s[v] << '\n';
    for (int u : ch[v]) {
      self(self, u);
    }
  };
  dfs(dfs, 0);
}



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

int main () {
	char a[15], b[15], c[15];
	int d, e;
	scanf ("%s %s", a, b);
	scanf ("%d %d", &d, &e);
	scanf ("%s", c);
	
	int tes = strcmp (a,c); 
	if (tes == 0) {
		d--;
	} else e--;
	
	printf ("%d %d\n", d, e);
}

Measured memory_bytes: 1732
#include<stdio.h>

int main(void){
  int i, x, y, z;

  for(i=0;i<10000;i++){
    scanf("%d %d",&x,&y);
    if(x == 0 && y == 0) break;
    if(x > y){
      z = x;
      x = y;
      y = z;
    }
    printf("%d %d\n",x,y);
  }
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n;cin>>n;
    vi v(n);
    rep(i,n-1){
        ll a;cin>>a;
        v[a-1]++;
    }
    for(ll x:v)out(x);
}

Measured memory_bytes: 4844
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p = sorted(p, reverse=True)
q = sorted(q, reverse=True)
r = sorted(r, reverse=True)
p_x = p[:x]
q_y = q[:y]
new_lis = p_x + q_y + r
new_lis = sorted(new_lis, reverse=True)
tasty = 0
for i in range(x+y):
    tasty += new_lis[i]
print(tasty)

Measured memory_bytes: 23328
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N, M;
	cin >> N >> M;
	
	vector<bool> done(N, false);
	vector<int> cnt(N, 0);
	
	int ans_ac = 0, ans_p = 0;
	REP(i, M) {
		int p;
		string s;
		cin >> p >> s;
		if (s == "WA") {
			++cnt[p - 1];
		}
		else {
			if (!done[p - 1]) {
				done[p - 1] = true;
				ans_ac++;
				ans_p += cnt[p - 1];
			}
		}
	}
	
	cout << ans_ac << " " << ans_p << endl;
	
	return 0;
}


Measured memory_bytes: 640
import math
a, b, x = map(int, input().split())
t = a * a * b
tan = 0
if (x > t / 2):
    tan = math.atan(2 * ((a * a * b) - x) / (a * a * a))
else:
    tan = math.atan((a * b * b) / (2 * x))

ans = tan * 180 / math.pi

print(ans)

Measured memory_bytes: 3188
def main():
	N = int(input())
	P = list(map(int, input().split()))
	ans = 0
	for i in range(N-2):
		if P[i] < P[i+1] < P[i+2]:
			ans += 1
		elif P[i+2] < P[i+1] < P[i]:
			ans += 1
	print(ans)

if __name__ == '__main__':
	main()

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

const int N=1e5+5;
const int mod=1e9+7;
int32_t main() {
    IOS
int n,sum=0;
    cin>>n;
  int t=n;
  while(t){sum+=t%10,t/=10;}
  if(n%sum)cout<<"No";
  else cout<<"Yes";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int A,B;
  
  vector<int>ans(S.size());
  
  int sum=0;
  
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='A'){
      A=i;
      break;
      
 
    }
}

for(int i=S.size()-1;i>=0;i--){
if(S.at(i)=='Z'){
  B=i;
  break;
}
}

cout<<B-A+1<<endl;
}





Measured memory_bytes: 1412
//Attention

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int n;
    string s;
    cin>>n>>s;
    ll e=0,w=0;
    rep(i,0,n){
        if(s[i]=='E')e++;
    }
    ll ans = inf;
    rep(i,0,n){
        if(s[i]=='E')e--;
        ans=min(ans,w+e);
        if(s[i]=='W')w++;
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 900
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
#include<array>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
constexpr ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acosl(-1.0);

ll mod_pow(ll x, ll n, ll m=mod) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * x % m;
		x = x * x % m; n >>= 1;
	}
	return res;
}
struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n % mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint& a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint& a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint& a, modint b) { a.n = ((ll)a.n * b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, ll n) {
	if (n == 0)return modint(1);
	modint res = (a * a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 19;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}



void solve() {
	string s, t; cin >> s >> t;
	int ans = mod;
	rep(i, s.size() - t.size() + 1) {
		int cnt = 0;
		rep(j, t.size())if (s[i + j] != t[j])cnt++;
		ans = min(ans, cnt);
	}
	cout << ans << "\n";
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(15);
	init_f(); 
	//init();
	//expr();
	//int t; cin >> t; rep(i, t)
	solve();
	return 0;
}


Measured memory_bytes: 11812
// AOJ 2151: Brave Princess Revisited
// 2017.11.11 bal4u
// 2018.2.6

#include <stdio.h>
#include <string.h>

typedef struct { int t, n, m; } QUE;
QUE que[20001]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;
	
	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i]; que[i] = que[min]; que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
//	if (qsize == 0) return 0;
//	*n = que[0].n, *m = que[0].m;
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int t, int n, int m)
{
	int i, min;
	QUE qt;
	
	i = qsize++;
	que[i].t = t, que[i].n = n, que[i].m = m;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i]; que[i] = que[min]; que[min] = qt;
		i = min;
	}
}

int to[101][101], d[101][101], e[101][101], hi[101];
int node[101][101];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int dijkstra(int start, int goal, int l)
{
	int s, m, i, k, t, p, ans;

	memset(node, 0x33, sizeof(node));
	ans = 0x7fffff;
	qsize = 0;
	node[start][l] = 0; enq(0, start, l);

	while (qsize) {
		s = que[0].n, m = que[0].m, p = que[0].t, deq();

		if (p > node[s][m]) continue; 
		if (s == goal) { ans = p; break; }

		for (i = 0; i < hi[s]; i++) {
			t = to[s][i];

			k = p + e[s][i];
			if (k < node[t][m]) node[t][m] = k, enq(k, t, m);

			k = m - d[s][i];
			if (d[s][i] <= m && p < node[t][k]) node[t][k] = p, enq(p, t, k);
		}
	}
	return ans;
}

int main()
{
	int n, m, l, k, a, b, _d, _e, i;

	while (n = in()) {
		m = in(), l = in();
		memset(hi, 0, n << 2);
		for (i = 0; i < m; i++) {
			a = in()-1, b = in()-1, _d = in(), _e = in();
			k = hi[a]++;
			to[a][k] = b, d[a][k] = _d, e[a][k] = _e;
			k = hi[b]++;
			to[b][k] = a, d[b][k] = _d, e[b][k] = _e;
		}
		printf("%d\n", dijkstra(0, n-1, l));
	}
	return 0;
}


Measured memory_bytes: 2108