akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9 + 7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int N;
string S;

inline vector<int> Z_algorithm(string S) {
	vector<int> A(S.size());
	A[0] = S.size();
	int i = 1, j = 0;
	while(i < S.size()){
		while(i + j < S.size() && S[j] == S[i + j]) j++;
		A[i] = j;

		if(j == 0){
			i++;
			continue;
		}
		int k = 1;
		while(k + A[k] < j){
			A[i + k] = A[k];
			k++;
		}
		i += k;
		j -= k;
	}
	return A;
}

signed main() {
	cin >> N >> S;
	ll ans = 0;
	rep(i, N) {
		string T = S.substr(i, N - i);
		vector<int> v = Z_algorithm(T);
		for (int j = 1; j < v.size(); j++) {
			if(v[j] <= j) ans = max(ans, (ll)v[j]);
		}
	}
	cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    for (int ans = 1; ans < 50000; ++ans) {
        if (floor(ans * 1.08) == n) {
            cout << ans << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}


Measured memory_bytes: 256
// finish date: 2018/01/11
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

#define bigmod 1000000007
using namespace std;

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

int mul(int a, int b) {
    return (int) (((ll) (a % bigmod) * (b % bigmod)) % bigmod);
}

int factorial(int n) {
    int ans = 1;
    FOR(i, 1, n + 1) {
        ans = ans * i;
    }
    return ans;
}

int main() {
    string A, B, C;
    cin >> A >> B >> C;
    if(A[A.length()-1]==B[0]&&B[B.length()-1]==C[0]) {
        cout<<"YES"<<endl;
    }else cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 256
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int a,b,c,x;
    cin>>a;
    cin>>b;
    cin>>c;
    cin>>x;
    
    int cnt=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                int y = 500*i + 100*j + 50*k;
                if(x==y){
                    //cout<<i<<" "<<j<<" "<<k<<endl;
                    cnt++;        
                }
            }
        }
    }
    cout<<cnt<<endl;
    return 0;
}



Measured memory_bytes: 256
d = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for i in range(d)]

ans = [0]*d
last = [0]*26

def score(day, last, today, C, S):
    res = 0
    res += S[day][today]
    last[today] = day+1
    for i in range(26):
        res -= C[i]*(day+1 - last[i])
    return res        

for i in range(d):
    t = int(input())
    if i > 0:ans[i] += ans[i-1]
    ans[i] += score(i,last,t-1,C,S)
print("\n".join(str(i) for i in ans))


Measured memory_bytes: 68176
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<limits>
#include<algorithm>
#include<numeric>
#include<utility>

int main(){
    int N, L;
    long long int res;

    std::cin >> N >> L;

    res = N*(2*L+N-1)/2;
    if(L>=0) res-=L;
    else if(L+N-1<=0) res-=(L+N-1);

    std::cout << res << std::endl;

    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    string a, b;
    cin >> a >> b;
    int res = stoi(a + b);
    int ans = sqrt(res);

    cout << (ans * ans == res ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
n = int(input())
tb1 = [[-1 for _ in range(n)] for _ in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        tb1[i][x-1] = y
gmax = 0
for i in range(1,2**n):
    nomatch = False
    for j in range(n):
        if ((i >> j) & 1):
            nomatch = False
            for ind in range(n):
                if ind==j:pass
                else:
                    shou = False
                    resl = False
                    if tb1[j][ind] == -1:continue
                    elif tb1[j][ind] == 1:shou = True
                    elif tb1[j][ind] == 0:pass
                    if ((i>>ind)&1):resl = True
                    if shou != resl:
                        nomatch = True
                        break
        if nomatch:break
    else:
        tempstr = bin(i)
        c = tempstr.count('1')
        gmax = max(gmax,c)
print(gmax)  

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
 
int main(void){
  int x,y,b,p;
  int n;
  cin>>n;
  while(n--){
    cin>>x>>y>>b>>p;
    int sum = x * b + y * p;
    int sum1 = sum;
    if(b >= 5 && p >= 2) sum1 *= 0.8;
    else if(b >= 5) sum1 = (x * b + y * 2) * 0.8;
    else if(p >= 2) sum1 = (x * 5 + y * p) * 0.8;
    cout << (sum > sum1 ? sum1 : sum) << endl; 
  }
 
 
}

Measured memory_bytes: 1160
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
const ll INF = 1e18;

int main() {
    ll n;
    cin >> n;
    cout.precision(99);
    if (n % 2 == 0) 
        cout << 1.0 / 2 << "\n";
    else 
        cout << ((n / 2 + 1) * 1.0) / n << "\n";

    return 0;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int>h(N);
  
  for(int i=0;i<N;i++){
    cin>>h[i];
  }
  
  sort(h.begin(),h.end());
  int ans=1e9+10;
  for(int i=K-1;i<N;i++){
    ans=min(ans,h[i]-h[i-K+1]);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 640
import sys
input = sys.stdin.readline
from collections import Counter

n = int(input())
a = list(map(int, input().replace("\n","").split()))

"""
for i in range(1,n+1):
    print(a.count(i))
"""

S = Counter(a)

for i in range(1,n+1):
    print(S[i])

Measured memory_bytes: 33856
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001

vi root(100005);
int find(int x){
	if(root[x]==x) return x;
	else return root[x]=find(root[x]);
}
bool same(int x, int y){
	return find(x)==find(y);
}	
void union_tree(int x,int y, int &n_trees){
	if(same(x,y)) return;
	int rt_x = root[x];
	int rt_y = root[y];	
	root[rt_y] = rt_x;
	n_trees--;
}

int main(void) {
	int n,m; cin >> n >> m;
	int n_trees = n;
	rep(i,n) root[i] = i;
	rep(i,m){
		int x,y,z; cin >> x >> y >> z;
		x--; y--;
		union_tree(x,y,n_trees);
	}
	cout << n_trees << endl;
}




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

using namespace std;

template<class T> inline T sqr(const T& a) {
  return a * a;
}

template<class T> inline int len(const T &c) {
  return static_cast<int>(c.size());
}

template<class T> inline bool maximize(T &r, const T c) {
  if (r < c) {
    r = c;
    return true;
  }
  return false;
}

template<class T> inline bool minimize(T &r, const T c) {
  if (r > c) {
    r = c;
    return true;
  }
  return false;
}

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const ld EPS = 1e-9;
const ld PI = 2 * acos(0.0);
const int N = 5100;

int n, k;
int a[N];
int can[N];
int ver;

bool Check(int m, int l) {
  ++ver;
  can[0] = ver;
  for (int i = 0; i < m; ++i) {
    for (int j = k - a[i] - 1; j >= 0; --j) {
      if (can[j] == ver) {
        int tg = j + a[i];
        can[tg] = ver;
        if (tg >= l) {
          return true;
        }
      }
    }
  }
  return false;
}

int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  int ans = 0;
  map<int, bool> done;
  for (int i = 0; i < n; ++i) {
    if (a[i] >= k) {
      continue;
    } else {
      bool flag;
      if (done.count(a[i])) {
        flag = done[a[i]];
      } else {
        int val = a[i];
        swap(a[i], a[n - 1]);
        flag = !Check(n - 1, k - val);
        done[val] = flag;
        swap(a[i], a[n - 1]);
      }
      if (flag) {
        ++ans;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 512
package main

import "fmt"

func main() {
	// Code for C - *3 or /2
	var N int
	fmt.Scanf("%d", &N)

	var count, a int
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &a)
		for {
			if a%2 == 0 {
				a = a / 2
				count++
			} else {
				break
			}
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    char a[60][60];
    int h,w,i,j,f;f=1;
    scanf("%d%d",&h,&w);
    for(i=1;i<=h;i++)
        scanf("%s",(a[i]+1));
    for(i=1;i<h;i++)
        for(j=1;j<w;j++)
    {
        if(a[i][j]=='#')
        {


                if(a[i+1][j]!=a[i][j]&&a[i][j]!=a[i][j+1]&&a[i-1][j]!=a[i][j]&&a[i][j-1]!=a[i][j])
                {
                    printf("No");
                    return 0;

                }




        }
    }
     printf("Yes");
        return 0;
}

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

const int DIM = 1e5 + 5;

int anc[DIM];

struct str {
    int x, y, z;
} pts[DIM], edg[DIM << 1];

int getroot(int x) {
    return (anc[x] < 0) ? x : getroot(anc[x]);
}

int main(void) {
    ios::sync_with_stdio(false);
    
    int a, b, c;
    cin >> a >> b >> c;
    
    cout << min(a + b, min(a + c, b + c));
    return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)

answer = 0

for bit in range(1 << (N-1)):
    f = S[0]

    for i in range(N-1):
        if bit & (1 << i):
            f += '+'
        f += S[i+1]

    answer += sum(map(int, f.split('+')))

print(answer)


Measured memory_bytes: 3060
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar_unlocked(); while(c==' '||c=='\n') c=getchar_unlocked(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar_unlocked(); } *s='\0'; return len; }

void rsorta_d32(void *base, const int count, const int size){
	typedef int32_t rsort_t;
	rsort_t (*a)[size]=(rsort_t(*)[size])base;
	rsort_t (*b)[size]=(rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][0]>>(0<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][0]>>(0<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t (*t)[size]=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][0]>>(1<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][0]>>(1<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t (*t)[size]=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][0]>>(2<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][0]>>(2<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t (*t)[size]=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][0]>>(3<<3))+0x80]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][0]>>(3<<3))+0x80]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t (*t)[size]=a; a=b; b=t;}
	free(b);
}

int s[400000][3];
std::set<int> t;
int main(void){
	int n=nextint();
	int m=nextint();
	for(int i=0; i<n; i++){
		int a=nextint();
		int b=nextint();
		int c=nextint();
		s[i][0]=b-c;
		s[i][1]=-1;
		s[i][2]=c;
		s[i+n][0]=a-c;
		s[i+n][1]=1;
		s[i+n][2]=c;
		//printf(" %d %d %d\n", a-c, b-c, c);
	}
	rsorta_d32(s, n*2, 3);
	int j=0;
	for(int i=0; i<m; i++){
		int d=nextint();
		while(j<2*n && s[j][0]<=d){
			if(s[j][1]>0){
				t.insert(s[j][2]);
				//printf(" push %d %d\n", s[j][0], s[j][2]);
			}else{
				t.erase(s[j][2]);
				//printf(" pop  %d %d\n", s[j][0], s[j][2]);
			}
			j++;
		}
		if(t.empty()){
			puts("-1");
		}else{
			printf("%d\n", *t.begin());
		}
	}
}


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

int main() {
  int N;
  cin >> N;
  bitset<200002>b;
  cin >> b;
  int a=b.count();
  if(a==0){
    for(int i=0;i<N;i++){
      cout << 1 << endl;
    }
    return 0;
  }
  if(a==1){
    if(b.test(0)){
      for(int i=0;i<N-1;i++){
        cout << 2 << endl;
      }
      cout << 0 << endl;
    }
    else{
      for(int i=0;i<N-1;i++){
        if(b.test(N-i-1)) cout << 0 << endl;
        else cout << 1 << endl;
      }
      cout << 2 << endl;
    }
    return 0;
  }
  vector<int>up(N);
  vector<int>down(N);
  up.at(0)=1;
  down.at(0)=1;
  for(int i=1;i<N;i++){
    up.at(i)=(up.at(i-1)*2)%(a+1);
  }
  for(int i=1;i<N;i++){
    down.at(i)=(down.at(i-1)*2)%(a-1);
  }
  
  int uup=0;
  int ddown=0;
  
  for(int i=0;i<N;i++){
    if(b.test(i)) uup+=up.at(i);
    uup%=(a+1);
  }
  for(int i=0;i<N;i++){
    if(b.test(i)) ddown+=down.at(i);
    ddown%=(a-1);
  }
  
    
  for(int i=N-1;i>=0;i--){
    bitset<200002>c;
    c=b;
    c.flip(i);
    if(c==0) {
      cout << 0 << endl;
      continue;
    }
    int64_t x;
    if(c.test(i)){
      x=(uup+up.at(i))%(a+1);
    }else{
      x=(ddown-down.at(i)+a-1)%(a-1);
    }
    if(x==0){
      cout << 1 << endl;
      continue;
    }
    int j=1;
    while(x!=0){
      bitset<1000>y(x);
      x%=y.count();
      j++;
    }
    cout << j << endl;
  }
}

Measured memory_bytes: 5016
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

n, m = map(int, input().split())

ans = 1

div = make_divisors(m)

for i in div:
    if i * n <= m:
        ans = i
    else:
        break

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
typedef pair<int, int> P;
vector<int> G[200001];
deque<vector<ll>> dp[200001];
int solve(int v) {
    vector<P> ch;
    vector<ll> tmp = {1, 1, 0};
    if(G[v].size() == 0) {
        dp[v].push_front(tmp);
        return v;
    }
    for(int to : G[v]) {
        int id = solve(to);
        ch.emplace_back(dp[id].size(), id);
    }
    sort(ch.begin(), ch.end());
    int last = ch.back().second;
    int len = -1;
    for(int k = 0; k + 1 < ch.size(); k++) {
        P p = ch[k];
        for(int d = 0; d < p.first; d++) {
            vector<ll> src = dp[p.second][d];
            vector<ll> dst = dp[last][d];
            for (int i = 0; i <= 2; i++) dp[last][d][i] = 0;
            for (int i = 0; i <= 1; i++) {
                for (int j = 0; j <= 2; j++) {
                    ll t = (src[i] * dst[j]) % MOD;
                    (dp[last][d][min(i + j, 2)] += t) %= MOD;
                }
            }
        }
        len = max(len, p.first);
        dp[p.second].clear();
    }
    for(int d = 0; d < len; d++) {
        (dp[last][d][0] += dp[last][d][2]) %= MOD;
        dp[last][d][2] = 0;
    }
    dp[last].push_front(tmp);
    return last;
}
int cnt[200001];
void dfs(int v, int d) {
    cnt[d]++;
    for(int to : G[v]) {
        dfs(to, d+1);
    }
}
ll mod_pow(ll a, ll n) {
    if(n == 0) return 1;
    if(n % 2 == 0) {
        ll t = mod_pow(a, n/2);
        return (t*t) % MOD;
    }
    return (a*mod_pow(a, n-1)) % MOD;
}
int main() {
    int N;
    cin >> N;
    for(int i = 1; i <= N; i++) {
        int p;
        cin >> p;
        G[p].push_back(i);
    }
    dfs(0, 0);
    int id = solve(0);
    ll ans = 0;
    for(int d = 0; d < dp[id].size(); d++) {
        ll t = dp[id][d][1];
        (t *= mod_pow(2, N+1-cnt[d])) %= MOD;
        (ans += t) %= MOD;
    }
    cout << ans << endl;
}

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

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

using namespace std;

int N, M;
priority_queue<pair<int, int>> pq;

int main() {
    ll ans = 0;
    cin >> N >> M;
    REP(i, N) {
        int tmp;
        cin >> tmp;
        pq.emplace(tmp, 1);
    }

    REP(i, M) {
        int b, c;
        cin >> b >> c;
        pq.emplace(c, b);
    }

    int cnt = 0;
    for(;;) {
        if (cnt == N) break;
        auto t = pq.top();
        while (t.second > 0 && cnt < N) {
            ans += t.first;
            cnt++;
            t.second--;
        }
        pq.pop();
    }

    cout << ans << endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<int,int> p;

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

    vector<p> LR1, LR2;
    rep(i,N){
        string S; cin >> S;
        
        string T;
        rep(i,S.length()){
            if(!T.empty() && T.back() == '(' && S[i] == ')') T.pop_back();
            else T.push_back(S[i]);
        }

        int L = count(T.begin(), T.end(), '(');
        int R = count(T.begin(), T.end(), ')');

        if(L-R >= 0) LR1.push_back(p(R,L));
        if(L-R < 0) LR2.push_back(p(L,R));
    }

    sort(LR1.begin(), LR1.end());
    sort(LR2.begin(), LR2.end(), greater<p>());

    int l_brackets = 0;
    rep(i,LR1.size()){
        int R = LR1[i].first, L = LR1[i].second;

        l_brackets -= R;
        if(l_brackets < 0){ cout << "No" << endl; return 0; }
        l_brackets += L;
    }

    rep(i,LR2.size()){
        int R = LR2[i].second, L = LR2[i].first;

        l_brackets -= R;
        if(l_brackets < 0){ cout << "No" << endl; return 0; }
        l_brackets += L;
    }

    if(l_brackets != 0) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 11276
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll A[100010];
    rep(i,0,N) cin >> A[i];
    sort(A,A+N);
    ll v = A[0];
    rep(i,1,N) v = gcd(v, A[i]);
    if(K > A[N-1]){
        print("IMPOSSIBLE");
    }else{
        rep(i,0,N){
            if(K == A[i]){
                print("POSSIBLE");
                return 0;
            }
        }
        rep(i,0,N){
            ll diff = A[i] - K;
            if(diff % v == 0){
                print("POSSIBLE");
                return 0;
            }
        }
        print("IMPOSSIBLE");
    }


 }

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <numeric>




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define decp(n) cout<<fixed<<setprecision((int)n)
#define _GLIBCXX_DEBAC
#include <functional>
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

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

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m, int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
	return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t, sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;

map<string, int> memo;

using P=pair<ll,ll>;

/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/
ll findIndex(int value, vector<ll> a)
{

	for (ll i = 0; i < (ll)a.size(); i++) {
		if (a[i] == value) {
			return i;
		}
	}
	return -1;
}

ll nCr(ll n, ll r) {
	ll a = 1;
	for (ll i = n; i > n - r; --i) {
		a = a * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		a = a / i;
	}
	return a;
}



const int INF = 1001001001;



int main() {
	double n,k;
	cin >> n>>k;
	vector<ll> a(n);
	rep(i, n)cin >> a[i];
	cout << ceil((n - 1) / (k - 1)) << endl;
	return 0;
}













Measured memory_bytes: 4116
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
int n, a[maxn + maxn];

int read() {
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || '9' < ch) { if (ch == '-') f = -f; ch = getchar(); }
    while ('0' <= ch && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    return x * f;
}

bool check(int k) {
    bool tran[maxn]; // 相邻 
    for (int i = 1; i <= n; ++i) tran[i] = a[i] >= k;
    int mid = (n + 1) / 2, pos = 0, flg = -1;
    for (int i = mid; i < n; ++i) { if (tran[i] == tran[i + 1]) { pos = i - mid, flg = tran[i]; break; } }
    for (int i = mid; i > 1; --i) { if (tran[i] == tran[i - 1] && mid - i < pos) { flg = tran[i]; break; } } 
    if (flg != -1) return flg;
    return tran[1];
}

int main() {
    n = read(); n = n + n - 1;
    for (int i = 1; i <= n; ++i) a[i] = read();
    int l = 1, r = n, ans = 1;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (check(mid)) ans = mid, l = mid + 1;
        else r = mid - 1;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
long long longpow(long long n, long long a, long long mod) {
  if (a == 0) return 1;
  if (a == 1) return n % mod;
  if (a % 2 == 1) return (n * longpow(n, a - 1, mod)) % mod;
  ll t = longpow(n, a / 2, mod) % mod;
  return (t * t) % mod;
}
int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];
  map<int, int> mp{};
  REP(i, N) mp[A[i]]++;
  if (N % 2 == 1) {
    if (mp[0] != 1) {
      cout << 0 << endl;
      return 0;
    }
  }
  for (int i = 1; i < N; i++) {
    if (N % 2 == 0) {
      if (i % 2 == 1) {
        if (mp[i] != 2) {
          cout << 0 << endl;
          return 0;
        }
      }
    } else {
      if (i % 2 == 0) {
        if (mp[i] != 2) {
          cout << 0 << endl;
          return 0;
        }
      }
    }
  }
  cout << longpow(2, N / 2, MOD) << endl;
}

Measured memory_bytes: 6788
h, w, d = map(int, input().split())

a = [list(map(int, input().split())) for i in range(h)]

dic = [0] * (h * w)

for i in range(h):
    for j in range(w):
        dic[a[i][j] - 1] = i, j

s = [[0] * (h * w // d + 1) for i in range(d)]

for i in range(d):
    for j in range(1, h * w // d + 1):
        b = i + d * (j - 1)
        c = i + d * j

        if c >= len(dic):
            break
        
        y, x = dic[b]
        ny, nx = dic[c]
        s[i][j] = s[i][j - 1] + abs(ny - y) + abs(nx - x)

q = int(input())

for i in range(q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    print(s[l % d][r // d] - s[l % d][l // d])


Measured memory_bytes: 22876
#include<iostream>
#include<map>
using namespace std;
int main(){
  int n;
  map<char,char>mp;
  while(cin >> n,n){
    for(int i=0;i<n;i++){
      char a, b;
      cin >> a >> b;
      mp[a] = b;
    }
    int m;
    cin >> m;
    for(int i=0;i<m;i++){
      char a;
      cin >> a;
      if(mp.find(a)!=mp.end()) cout << mp[a];
      else cout << a;
    }
    cout << endl;
    mp.clear();
  }
}

Measured memory_bytes: 1192
fn input_one<T: std::str::FromStr> () -> Result<T, T::Err> {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    n.trim().parse()
}

fn input_arr<T: std::str::FromStr> () -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().flat_map(str::parse).collect()
}

fn main() {
    let n: isize = input_one().unwrap();
    let x: Vec<isize> = input_arr();
    let &x_min = x.iter().min().unwrap();
    let &x_max = x.iter().max().unwrap();
    println!("{}", x.iter().map(|&v| v * v).sum::<isize>() + (x_min..=x_max).map(|v| - 2 * v * x.iter().sum::<isize>() + n * v * v).min().unwrap());
}


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


class Program
{
    static void Main(string[] args)
    {
    long num_a = long.Parse(Console.ReadLine());
    Console.WriteLine(num_a + Math.Pow(num_a, 2) + Math.Pow(num_a, 3));
    //System.Diagnostics.Debug.WriteLine(num_a + Math.Pow(num_a, 2) + Math.Pow(num_a, 3));
    }
}

Measured memory_bytes: 27896
/**
 *    author        : Saurav Paul 
 *    created       : August 21, 2020 12:18 PM
 *    Problem Name  : C - Tsundoku
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc172/tasks/abc172_c
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

using ll = long long int ;

void solve(){

    int N , M , K ;
    cin >> N >> M >> K ;

    vector<int> deskA(N) , deskB(M) ;

    for(auto& x: deskA) cin >> x ;
    for(auto& x: deskB) cin >> x ;

    vector<ll> ca , cb ;

    ca.push_back(0) ;
    cb.push_back(0) ;

    for(auto x : deskA) ca.push_back(x + ca.back()) ;
    for(auto x : deskB) cb.push_back(x + cb.back()) ;

    int can_read = 0 ;

    for(int i = 0 , j = 0 ; i <= N ; i++){
        if(ca[i] > K) break ;
        
        while(j+1 <= M && cb[j+1] + ca[i] <= K){
            j ++ ;
        }
        while(j > 0 && cb[j] + ca[i] > K){
            j -- ;
        }
        can_read = max(can_read, i + j) ;
    }

    cout << can_read << endl ;

}

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

    int testcases = 1;
    for(int i = 1 ; i <= testcases ; i ++){
        solve();
    }

    return 0 ;
}


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

int main() {
  ll n, m; cin >>n >>m;
  vector<ll> a(n);
  priority_queue<ll> queue;
  rep(i,n) {
    cin >> a[i];
    queue.push(a[i]);
  }
  rep(i,m) {
    ll torima = queue.top();
    queue.pop();
    queue.push(torima /2);
  }
  ll ans = 0;
  while(!queue.empty()) {
    ans += queue.top();
    queue.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 2168
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#define MAX 13300000000
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<int > vi;

int main() {
	ll n,x;
	cin >> n>>x;
	vl A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	vl C(n,MAX);
	ll ans = 1ll << 62;
	for (ll i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			C[j] = min(C[j], A[(j + i)%n]);
		}
		ll cost = 0;
		for (int j = 0; j < n; j++) {
			cost += C[j];
		}
		cost += i*x;
		ans = min(ans, cost);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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;
}

int calc_bit_count_for_string(const string &S, const int N) {
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == '1') {
            ans++;
        }
    }
    return ans;
}

int calc_bit_count_for_num(ll x) {
    assert(x >= 0);
    int ans = 0;
    while (x != 0) {
        if (x % 2 == 1) {
            ans++;
        }
        x >>= 1;
    }
    return ans;
}

ll mod_pow(const ll base, const ll n, const int mod) {
    assert(n >= 0);
    assert(mod > 0);
    if (n == 0) {
        return 1LL % mod;
    }

    ll ans = mod_pow(base, n / 2, mod);
    ans = (ans * ans) % mod;
    if (n % 2 == 1) {
        ans = (ans * base) % mod;
    }
    return ans;
}

ll calc_first(const int mod, const string &S, const int N) {
    assert(mod > 0);

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans = (((ans * 2) % mod) + (S[i] - '0')) % mod;
    }
    return ans;
}

// 11:53
int main(void) {
    int N;
    cin >> N;
    string S;
    cin >> S;

    vector<int> ans(N, 0);

    // for zero
    {
        const int mod = calc_bit_count_for_string(S, N) + 1;

        ll original = calc_first(mod, S, N);
        for (int i = 0; i < N; i++) {
            if (S[i] == '0') {
                ll acc = original;
                int cnt = 0;
                acc = (acc + mod_pow(2, N - 1 - i, mod)) % mod;
                // printf("i: %d, mod: %d, acc: %lld\n", i, mod, acc);
                cnt++;
                while (acc > 0) {
                    acc = acc % calc_bit_count_for_num(acc);
                    // printf("i: %d, mod: %d, acc: %lld\n", i, mod, acc);
                    cnt++;
                }
                ans[i] = cnt;
            }
        }
    }

    // for one
    {
        const int mod = calc_bit_count_for_string(S, N) - 1;
        if (mod > 0) {
            ll original = calc_first(mod, S, N);
            for (int i = 0; i < N; i++) {
                if (S[i] == '1') {
                    ll acc = original;
                    int cnt = 0;
                    acc = (acc + mod - mod_pow(2, N - 1 - i, mod)) % mod;
                    // printf("i: %d, mod: %d, acc: %lld\n", i, mod, acc);
                    cnt++;
                    while (acc > 0) {
                        acc = acc % calc_bit_count_for_num(acc);
                        // printf("i: %d, mod: %d, acc: %lld\n", i, mod, acc);
                        cnt++;
                    }
                    ans[i] = cnt;
                }
            }
        }
    }

    for (int i = 0; i < N; i++) {
        printf("%d\n", ans[i]);
    }

    return 0;
}


Measured memory_bytes: 4436
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final long MOD = 998_244_353;

    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int s = scanner.nextInt();

        final int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }

        final long[][] dpTable = new long[n][s];
        long count = 0;
        if (a[0] < s) {
            dpTable[0][a[0]] = 1;
        } else if (a[0] == s) {
            count = n;
        }

        for (int i = 1; i < n; i++) {
            // a[i]を選ばない場合
            System.arraycopy(dpTable[i - 1], 0, dpTable[i], 0, s);

            // a[i] が s を超過した場合何もしない
            if (a[i] > s) {
                continue;
            }
            // a[i] が s だと，a[i] を含む全ての区間の組み合わせを足す
            else if (a[i] == s) {
                count = (count + (i + 1) * (n - i)) % MOD;
                continue;
            }

            // a[i] を足して s になる場合，始点の距離の総数 * 終点の距離の総数を足せる
            if (dpTable[i - 1][s - a[i]] != 0) {
                count = (count + dpTable[i - 1][s - a[i]] * (n - i)) % MOD;
            }

            // a[i] を選ぶ場合
            for (int j = 1; j < s - a[i]; j++) {
                if (dpTable[i - 1][j] == 0) {
                    continue;
                }
                //
                dpTable[i][j + a[i]] += dpTable[i - 1][j];
                dpTable[i][j + a[i]] %= MOD;
            }

            // 新たに始点を始める場合
            dpTable[i][a[i]] += i + 1;
            dpTable[i][a[i]] %= MOD;
        }

        System.out.println(count);
    }
}


Measured memory_bytes: 127768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <math.h>
using namespace std;

int main()
{
	double a, b;
	cin >> a >> b;

	double avg = (a + b) / 2;
	cout << (int)ceil(avg) << endl;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str=Console.ReadLine().Split(' ');
            
            int A=int.Parse(str[0]);
            int B=int.Parse(str[1]);
            int C=int.Parse(str[2]);
            int K=int.Parse(str[3]);

            if(K<=A)
            {
                Console.WriteLine(K);
            }
            else if(K>A+1 && K<=A+B)
            {
                Console.WriteLine(A);
            }
            else
            {
                Console.WriteLine(A-(K-(A+B)));
            }
        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

Measured memory_bytes: 27408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  int N,A,B; cin >> N >> A >> B;
  if ((B - A) % 2 == 0) cout << "Alice" << endl;
  else cout << "Borys" << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
writelines = sys.stdout.writelines
N = int(readline())
L = [None]*N; R = [None]*N
S = [-1]*N
P = [-1]*N
D = [-1]*N
DG = [0]*N
H = [-1]*N
for i in range(N):
    i, l, r = map(int, readline().split())
    L[i] = l; R[i] = r
    if l != -1:
        P[l] = i
        DG[i] += 1
    if r != -1:
        P[r] = i
        DG[i] += 1
    if l != -1 != r:
        S[l] = r; S[r] = l
def dfs(v, d):
    D[v] = d
    H[v] = h = max((dfs(L[v], d+1) if L[v] != -1 else 0), (dfs(R[v], d+1) if R[v] != -1 else 0))
    return h+1
dfs(P.index(-1), 0)
writelines(["node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n" % (i, P[i], S[i], DG[i], D[i], H[i], 'root' if P[i] == -1 else 'leaf' if DG[i] == 0 else 'internal node') for i in range(N)])




Measured memory_bytes: 5628
#include <iostream>
#include <stack>
using namespace std;
int a[10];
stack<int> b[2];
bool dfs(int i, int to)
{
	if (i == 9)
	{
		if (a[i] > b[to].top() || a[i] > b[!to].top())
			return true;
		else
			return false;
	}
	else if (a[i] > b[to].top() && a[i] > b[!to].top())
	{
		b[to].push(a[i]);
		if (dfs(i+1, to))
			return true;
		b[to].pop();
		b[!to].push(a[i]);
		if (dfs(i+1, !to))
			return true;
		return false;
	}
	else if (a[i] > b[to].top())
	{
		b[to].push(a[i]);
		if (dfs(i+1, to))
			return true;
		b[to].pop();
		return false;
	}
	else if (a[i] > b[!to].top())
	{
		b[!to].push(a[i]);
		if (dfs(i+1, !to))
			return true;
		b[!to].pop();
		return false;
	}
	else
		return false;
}
int main()
{
	int n, i, j;
	cin >> n;
	for (i = 0; i < n; i++)
	{
		for (j = 0; j < 10; j++)
			cin >> a[j];
		b[0].push(0);
		b[1].push(0);
		if (dfs(0, 0)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
}

Measured memory_bytes: 0
H,W,A,B=map(int,input().split())
for j in range(B):
    for i in range(A):
        print("1",end="")
    for i in range(W-A):
        print("0",end="")
    print()
for j in range(H-B):
    for i in range(A):
        print("0",end="")
    for i in range(W-A):
        print("1",end="")
    print()




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

int main() {
  int a, b;
  cin >> a >> b;
  if ( a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  }
  else {
     cout << "Even" << endl;
   }
}
  

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
  
long cmp(const void *a,const void *b){
  return *(long*)a - *(long*)b;
}

int main(){
  long n = 0;
  long a[100010] = {};
  long i = 0;
  long rightflag = 1;
  long cnt = 1;
  
  scanf("%ld",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
  }
  
  qsort(a,n,sizeof(long),cmp);
  
  if(n%2==1){
    for(i=0;i<n;i++){
      if(2*((i+1)/2) != a[i]){
        rightflag = 0;
      }
    }
  }else{
    for(i=0;i<n;i++){
      if(2*(i/2) + 1 != a[i]){
        rightflag = 0;
      }
    }
  }
  
  if(rightflag){
    for(i=0;i<n/2;i++){
      cnt = (cnt * 2)%1000000007;
    }
  }else{
    cnt = 0;
  }
  printf("%ld",cnt);
  return 0;
}
  
  

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

const float pi = 3.14159265359;
int main() {

  float a, b, x;
  cin >> a >> b >> x;
  
  if (x > a * a * b /2) {
    cout << fixed << setprecision(12) << atan(2 * (a * a * b - x) / (a * a * a)) * 180 / pi << endl;
    
  } else {
    cout << fixed << setprecision(12) << atan(a * b * b / (2 * x)) * 180 / pi << endl;
  }
}

Measured memory_bytes: 3864
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <vector>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;


int main(){
    ll r,L,n,edgenum;
    cin>>L;
    vector<ll> st,en,cost;
    for(ll i=0;pow(2,i)<=L;i++){
        r=i;
    }
    n=r+1;

    for(ll i=1;i<n;i++){
        //cout<<i<<" "<<i+1<<" "<<pow(2,i-1)<<endl;
        st.push_back(i);
        en.push_back(i+1);
        cost.push_back(pow(2,i-1));
        //cout<<i<<" "<<i+1<<" "<<0<<endl;
        st.push_back(i);
        en.push_back(i+1);
        cost.push_back(0);

        edgenum+=2;
    }
    //cout<<"a"<<L-pow(2,r)<<endl;

    for(ll t=n-1;1<=t;t--){
        //cout<<t<<" "<<(L-pow(2,r))<<" "<<pow(2,t-1)<<endl;
        if((L-pow(2,r))>=pow(2,t-1)){
            //cout<<t<<" "<<n<<" "<<L-pow(2,t-1)<<endl;
            st.push_back(t);
            en.push_back(n);
            cost.push_back(L-pow(2,t-1));

            L-=pow(2,t-1);
            edgenum++;
        }
    }

    cout<<n<<" "<<edgenum<<endl;
    for(ll i=0; i<edgenum;i++){
        cout<<st[i]<<" "<<en[i]<<" "<<cost[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <bits/stdc++.h>
int main() {
 int n,a[100002],b[100002];
  long int ans=0;
	cin>>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++)
	  {if(a[i]>=b[i])
	     ans=ans+b[i];
	   else { if((a[i]+a[i+1])>=b[i])
	       {ans=ans+b[i];
	         a[i+1]=a[i]+a[i+1]-b[i]; }
	         else
	         {
	             ans=ans+a[i]+a[i+1];
	             a[i+1]=0;
	         }
	       
	   }
	  
	  }
	  cout<<ans;
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int[] a = new int[n + 1];
		sa = br.readLine().split(" ");
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		a[n] = 101;
		br.close();

		int c = 0;
		int cnt = 0;
		int ans = 0;
		for (int i = 0; i <= n; i++) {
			if (a[i] != c) {
				ans += cnt / 2;
				cnt = 0;
				c = a[i];
			}
			cnt++;
		}
		System.out.println(ans);
	}
}


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

#define ALL(a) (a).begin(), (a).end()
#define llong long long

using namespace std;

signed main(){
	while(true){
		int n; cin >> n;
		if(n == 0)break;
		set<pair<int,int>> st;
		string z; getline(cin, z);
		for(int i = 0; i < n; i++){
			string raw;
			getline(cin, raw);
			stringstream ss; ss << raw;
			int id; ss >> id;
			pair<int, int> score;
			vector<pair<int, int>> t(10);
			for(int j = 0; j < 10; j++){
				ss >> t[j].first;
				if(t[j].first == 10 && j != 9)continue;
				if(ss.eof())break;
				ss >> t[j].second;
			}
			for(auto e : t)score.first += e.first + e.second;
//			for(auto e : t)cerr << e.first << "," << e.second << " ";
			int ls = 0;
			if(!ss.eof())ss >> ls;
			score.first += ls;
//			cerr << ls << endl;
//			cerr << score.first << endl;
			for(int j = 0; j < 10; j++){
				if(t[j].first == 10){
					if(j == 9){
						//score.first += t[j].second + ls;
					}
					else{
						score.first += t[j+1].first;
						if(t[j+1].first == 10 && j+1 < 9){
							score.first += t[j+2].first;
						}
						else{
							score.first += t[j+1].second;
						}
					}
				}
				else if(t[j].first + t[j].second == 10){
					if(j == 9){
						//score.first += ls;
					}
					else{
						score.first += t[j+1].first;
					}
				}
//				cerr << score.first << " ";
			}
//			cerr << endl;
			score.first *= -1;
			score.second = id;
			st.insert(score);
		}
//		cerr << st.size() << endl;
		for(auto e : st){
			cout << e.second << " "<< (-e.first) << endl;
		}
	}
	return 0;
}




Measured memory_bytes: 3104
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >>d;
    cout << min(a,b)+min(c,d) << endl;
    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))
import math
if N==K:
  print(1)
else:
  ans=10**18
  for i in range(K-1):
    n=N-(K-i)
    ans=min(ans,math.ceil(n/(K-1))+1)
  print(ans)

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

int main() {
  long long X;
  cin >> X;
  int ans1, ans2;
  bool is_ans = false;
  for (long long i = -200; i < 200 and (not is_ans); i++) {
    for (long long j = -200; j < 200 and (not is_ans); j++) {
      long long tmp1 = i * i * i * i * i - j * j * j * j * j;
      if (tmp1 == X) {
	ans1 = i;
	ans2 = j;
	is_ans = true;
      }
    }
  }
	
  cout << ans1 << " " << ans2 << endl;
  
  return 0;
}


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

using namespace std;

int main(void){
  double x[4], y[4];
  double p[4];
  
  while (scanf("%lf,%lf,", &x[0], &y[0])>0){
    scanf("%lf,%lf,%lf,%lf,%lf,%lf", &x[1], &y[1], &x[2], &y[2], &x[3], &y[3]);
    for (int i=0; i<4; i++){
      int j=(i+1)%4;
      int k=(i+2)%4;
      p[i] = (x[j]-x[i])*(y[k]-y[j])-(x[k]-x[j])*(y[j]-y[i]);
      //printf("%lf\n", p[i]);
    }
    puts(p[0]*p[1]<0||p[1]*p[2]<0||p[2]*p[3]<0||p[3]*p[0]<0 ? "NO": "YES");
  }
  return 0;
}


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

int main(int argc, char** argv){
  int A, B, K;
  cin >> A >> B >> K;
  int k=0;
  int i=1;
  int cd[A];
  while(1){
    if(i > A || i > B) break;
    if(A%i == 0 && B%i == 0) {cd[k] = i; k++;}
    i++;
  }
  printf("%d", cd[k-K]);
  return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
vector<ll> adj[100005];
ll visited[100005];
ll father[100005];





int main(){

    ll n;
    ll m;
    cin>>n>>m;
    ll aa,bb;
    fo(i,m) {
        cin>>aa>>bb;
        adj[aa].pb(bb);
        adj[bb].pb(aa);


    }
    FOR(i,1,n) {visited[i]=0; father[i]=i;}
    queue<ll> qq;
    qq.push(1);
    visited[1]=1;
    while(!qq.empty()){
        ll tmp=qq.front();
        qq.pop();
        //dbg(tmp);
        for(auto kk:adj[tmp]){
            if(!visited[kk]) {
                //if(tmp==6) dbg(kk);
                visited[kk]=1;
                qq.push(kk);
                father[kk]=tmp;
            }
        }


    }
    bool can=true;
    FOR(i,2,n){
        if(father[i]==i) can=false;
    }

    if(!can) cout<<"No"<<endl;
    else{
        cout<<"Yes"<<endl;
        FOR(i,2,n) cout<<father[i]<<endl;
    }






    

  

}

Measured memory_bytes: 13708