akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;  
using namespace std;

typedef long long ll;

typedef tree<
pair <int, int>,
null_type,
less<pair <int, int>>,
rb_tree_tag,
tree_order_statistics_node_update>
os;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int main() {
  int n; cin >> n;
  os s;
  vector <int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    s.insert({-a[i], i});
  }
  for(int i = 0; i < n; i++) {
    s.erase({-a[i], i});
    auto ans = (*s.find_by_order((n / 2) - 1));
    int cur = ans.first;
    cout << -cur << '\n';
    s.insert({-a[i], i});
  }
}

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

int main() {
    int64_t A, B, C, K, ans = 0;
    cin >> A >> B >> C >> K;
    if (A >= K) {
        ans += K;
    } else {
        ans += A;
        if (A + B < K) {
            ans -= K - (A + B);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,m;
  cin >> n >> m;
  cout << pow(2,m)*(1900*m+100*(n-m)) << endl;
}

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

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a, b):
    return (a * b)//gcd(a,b)

lcm_a = 1

for i in range(N):
    lcm_a = lcm(lcm_a,A[i])

ans = 0
for i in range(N):
    ans += lcm_a//A[i]

mod = int(1e9+7)

print(ans%mod)

Measured memory_bytes: 4084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		long n = Long.parseLong(s);
		long l = 0;
		for(char c : s.toCharArray()) {
			l+=c-'0';
		}
		System.out.println(n%l==0?"Yes":"No");
	}
}

Measured memory_bytes: 23636
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)
#define clz(n)				__builtin_clzll(n))

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n;
	cin>>n;
	int ans = 0;
	if(n<9) {
			cout<<n;
			return 0;
	}
	if(n>=9) {
			ans+=9;
	}
	if(n>=100) {
			ans+=min(n-100+1,900);
	}
	if(n>=10000) {
			ans+=min(n-10000+1,90000);
	}
	cout<<ans;
	return 0;
}





Measured memory_bytes: 256
using System;


namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public ulong NextUlong()
        {
            return ulong.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    struct MyStruct
    {
        public long N;
        public int Cnt;
    }

    class Program
    {
        private int N;
        private int[] A, B, C;
        void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            A = new int[N];
            B = new int[N];
            C = new int[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = sc.NextInt();
                B[i] = sc.NextInt();
                C[i] = sc.NextInt();
            }
        }

        public void Solve()
        {
            Scan();
            var aa = new int[N];
            var bb = new int[N];
            var cc = new int[N];
            aa[0] = A[0];
            bb[0] = B[0];
            cc[0] = C[0];
            for (int i = 1; i < N; i++)
            {
                aa[i] = A[i] + Math.Max(bb[i - 1], cc[i - 1]);
                bb[i] = B[i] + Math.Max(cc[i - 1], aa[i - 1]);
                cc[i] = C[i] + Math.Max(aa[i - 1], bb[i - 1]);
            }
            Console.WriteLine(Math.Max(aa[N - 1], Math.Max(bb[N - 1], cc[N - 1])));
        }



        static void Main() => new Program().Solve();
    }


}

Measured memory_bytes: 17344
S = input()
N = len(S)-1

def dfs(s, n):
  if n == N:
    tmp = list(map(int, s.split('+')))
    #print(tmp)
    return sum(tmp)
  c = 0
  for i in ['', '+']:
    c += dfs(s + i + S[n+1], n+1)
  return c

print(dfs(S[0], 0))


Measured memory_bytes: 3060
// Author: Amey Bhavsar
// IDE: Geany/Ubuntu
// Platform: AtCoder Beginner Contest 175

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

typedef long long ll;

#define rep(i,a,b) for(auto i=a;i<b;i++)
#define repD(i,a,b) for(auto i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

// to be used with algorithms that processes a container Eg: find(all(c),42)
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
// traversal function to avoid long template definition
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
//find version works for all containers. This is present in std namespace.
#define cpresent(c,x) (find(all(c),x) != (c).end())
// ll fe (ll x, ll y) {
	// ll ans = 1;
	// while (y>0) {
		// if (y&1) {
			// ans = (x*ans) % MOD;
		// }
		// y /= 2;
		// x = (x*x) % MOD;
	// }
	// return (ans % MOD);
// }

// ll modmul(ll a, ll b) {
    // return ((a%MOD) * (b%MOD)) % MOD;
// }

// ll modadd(ll a , ll b){
    // return((a%MOD)+(b%MOD)+MOD)%MOD;
// }

// ll modsub(ll a , ll b){
    // return((a%MOD) - (b%MOD) + MOD)%MOD;
// }
#define MOD 1000000007
// int n;
// vector<int> a;
// void solution() {
	// cin >> n;
	// a.resize(n);
	// for (auto& e:a) {
		// cin >> e;
	// }
// }

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	// int t;
	// cin >> t;	
	// while(t--) {
		// solution();
	// }
	
	int n;
	cin >> n;
	vector <int > a(n);
	for (auto& e:a) cin >> e;
	int ans = 0;
	sort(all(a));
	rep(i,0,n) {
		rep(j,i+1,n) {
			rep(k,j+1, n) {
				if (a[i] + a[j] > a[k] && a[i] != a[j] && a[i] != a[k] && a[j] != a[k]) ans++; 
			}
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef pair<ll, ll> P;
#define INF (1LL << 31)
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "

int main()
{
    ll n; cin >> n;
    if (n%10 == 2 || n%10 == 4 || n%10 == 5 || n%10 == 7 || n%10 == 9){
        cout << "hon" << endl;
    }else if (n%10 == 3){
        cout << "bon" << endl;
    }else{
        cout << "pon" << endl;
    }

    return 0;
}


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

using namespace std;

int main(){
    int N,K,add=1,ans=0,now=0;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<int> sum;
    bool zero;
    if(S[0]=='0'){
        zero = true;
    }else{
        zero = false;
    }

    for(int i=1;i<N;i++){
        if(zero){
            if(S[i]=='0'){
                add++;
            }else{
                sum.push_back(add);
                zero = false;
                add = 1;
            }
        }else{
            if(S[i]=='0'){
                sum.push_back(add);
                add = 1;
                zero = true;
            }else{
                add++;
            }
        }
    }

    sum.push_back(add);

    if(S[0]=='0'){
        for(int i=0;i<min((int)sum.size(),2*K);i++){
            ans += sum[i];
        }

        for(int i=1;i<min((int)sum.size(),2*K+2);i++){
            now += sum[i];
        }

        ans = max(ans,now);

        for(int i=2*K+2;i<sum.size();i++){
            if(i%2==0){
                now = now-sum[i-2*K-1]-sum[i-2*K]+sum[i];
            }else{
                now = now+sum[i];
            }
            ans = max(ans,now);
        }
        
    }else{
        for(int i=0;i<min((int)sum.size(),1+2*K);i++){
            ans += sum[i];
        }

        now = ans;

        for(int i=2*K+1;i<sum.size();i++){
            if(i%2==0){
                now = now+sum[i];
            }else{
                now = now-sum[i-2*K-1]-sum[i-2*K]+sum[i];
            }
            ans = max(ans,now);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1020
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int x; cin >> x;
  int ans = 0;
  ans += (x/500)*1000;
  x -= (x/500)*500;
  ans += (x/5)*5;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 998244353; 

int A, B, C, D;

int solve(){
	vector<vector<int>> dp(C+1, vector<int>(D+1));
	
	for(int i = A; i <= C; i++){
		for(int j = B; j <= D; j++){
			if(A == i && B == j) {
				dp[i][j] = 1;
			} else {
				dp[i][j] = dp[i][j-1] * i % MOD + dp[i-1][j] * j % MOD + (MOD - dp[i-1][j-1] * (i-1) % MOD * (j-1) % MOD);
				dp[i][j] %= MOD;
			}
		}
	}
	
	return dp[C][D];
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	
	cin>>A>>B>>C>>D;

	cout<<solve()<<endl;
	
	return 0;
}

Measured memory_bytes: 73668
# include <bits/stdc++.h>
using namespace std;
long long a[100010],b[100010];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=0;i<n;i++) scanf("%lld",&b[i]);
	long long ans=0;
	for(int i=0;i<n;i++)
	{
		if(b[i]>=a[i])
		{
			ans+=a[i];
			b[i]-=a[i];
			if(b[i]>=a[i+1])
			{
				ans+=a[i+1];
				a[i+1]=0;
			}
			else
			{
				ans+=b[i];
				a[i+1]-=b[i];
			}
		}
		else
		{
			ans+=b[i];
			b[i]=0;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <cstdint>
#include <math.h>
using namespace std;
#define repi(i,n) for(int i=0; i<(n); i++)

int main() {
  int64_t n, d, count=0;
  cin >> n >> d;
  vector<int64_t> x(n,0);
  vector<int64_t> y(n,0);
  repi(i,n) {
    cin >> x.at(i) >> y.at(i);
  }
  repi(i,n) {
    if(sqrtf64(x.at(i)*x.at(i)+y.at(i)*y.at(i))<=d) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 6504
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	char c[105][105];
	int n,l;
	cin >> n >> l;
	for(int i = 0;i < n;i++)
		cin >> c[i];
	char temp[105];
	for(int i = 0;i < n;i++){
		for(int j = i;j < n;j++){
			if(strcmp(c[i],c[j]) > 0){
				strcpy(temp,c[i]);
				strcpy(c[i],c[j]);
				strcpy(c[j],temp);
			}
		}
	}
	char ans[10005];
	for(int i = 0;i < n;i++)
		strcat(ans,c[i]);
	cout << ans << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

vector<Int> color;
vector<vector<pair<Int, Int>>> G;

void dfs(Int col,Int t) {

	Int temp;
	Int flag;
	if (t==0) {
		temp = 0;
	}
	else if (col==1) {
		temp = 1;
	}

	else if (col > 1) {
		temp = col;
		flag = 1;//1: 1に向けて下っているとき
	}
	for (auto e : G[t]) {
		if (color[e.second]!=-INF) {//既に辺の色が確定している場合
			continue;
		}

		else if (col==1) {//降りてきた色が1の場合
			temp++;
			color[e.second] = temp;
			dfs(temp, e.first);
		}
		else {//降りてきた色が1より大きい場合

			if (flag) {
				temp--;

				if (temp!=0) {
					color[e.second] = temp;
					dfs(temp, e.first);
				}
				else {
					flag = 0;
					temp = col + 1;
					color[e.second] = temp;
					dfs(temp, e.first);
				}
			}

			else {
				temp++;
				color[e.second] = temp;
				dfs(temp, e.first);
			}
		}

	}

}

int main() {

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

	Int N;
	cin >> N;

	color.resize(N-1, -INF);

	G.resize(N);

	Int a, b;
	for (Int i = 0; i < N-1; i++) {
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back(make_pair(b, i));
		G[b].push_back(make_pair(a, i));
	}


	dfs(1, 0);//1番目の色、0番の頂点スタート

	Int cnt = -INF;
	for (Int i = 0; i < N-1; i++) {
		cnt = max(cnt, color[i]);
	}


	cout << cnt << "\n";
	for (Int i = 0; i < N-1; i++) {
		cout << color[i] << "\n";
	}

}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
 
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
 
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, K;
	cin>>N>>K;
	cout<<(K==1 ? 0:N-K)<<'\n';
	return 0;
}

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

int n, a[5];
pair<int, int> b[5];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s[0] == 'M')
			a[0]++;
		else if (s[0] == 'A')
			a[1]++;
		else if (s[0] == 'R')
			a[2]++;
		else if (s[0] == 'C')
			a[3]++;
		else if (s[0] == 'H')
			a[4]++;
	}
	long long ans = 0;
	sort(a, a + 5);
	for (int i = 0; i < 5; i++)
		b[i] = { a[i], i };
	do {
		long long r = 1;
		for (int i = 0; i < 3; i++)
			r *= b[i].first;
		ans += r;
	} while (next_permutation(b, b + 5));
	cout << ans / 12;
}

Measured memory_bytes: 256
import sys
#input = sys.stdin.buffer.readline
 
def main():
    S = input()
    l = len(S)
    a = S[:(l-1)//2]
    b = S[(l-1)//2+1:]
    
    if S == S[::-1] and a == a[::-1] and b == b[::-1]:
        print("Yes")
    else:
        print("No")
    
if __name__ == "__main__":
    main()



Measured memory_bytes: 3060
#include<iostream>
            #include<vector>
            #include<algorithm>
            using namespace std;
            int main(){
            int N,i,sumA=0,sumB=0;
            cin>>N;
            vector<int> a(N);
            for(i=0;i<N;i++){
             cin>>a[i];
            }
            sort(a.begin(),a.end());
            for(i=N-1;i>=0;i=i-2) sumA+=a[i];
            for(i=N-2;i>=0;i=i-2) sumB+=a[i];
            cout<<sumA-sumB<<endl;
            return 0;
            }

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>

const int N = 100002;
const int MOD = (int)1e9 + 7;
const long long INF = 1000000000000000000LL;

int dp[N][2], p[2], q[2], sum[N][2];
long long c[2], x[N];

long long get_sum(int n, int t)
{
    if (n < 0) {
        return 0;
    }
    return sum[n][t];
}

int main()
{
#ifdef LOCAL_JUDGE
    freopen("C.in", "r", stdin);
#endif
    std::ios::sync_with_stdio(false);
    int n;
    while (std::cin >> n >> c[0] >> c[1]) {
        x[0] = -INF;
        for (int i = 1; i <= n; ++ i) {
            std::cin >> x[i];
        }
        x[n + 1] = 2 * INF;
        dp[0][0] = dp[0][1] = sum[0][0] = sum[0][1] = 1;
        p[0] = p[1] = q[0] = q[1] = 0;
        for (int i = 1; i <= n; ++ i) {
            for (int j = 0; j < 2; ++ j) {
                if (x[i] - x[i - 1] < c[j]) {
                    p[j] = i;
                }
                while (q[j] + 1 < i && x[i + 1] - x[q[j] + 1] >= c[j ^ 1] ) {
                    q[j] ++;
                }
                dp[i][j] = 0;
                if (p[j] - 1 <= q[j]) {
                    dp[i][j] = (sum[q[j]][j ^ 1] + MOD - get_sum(p[j] - 2, j ^ 1)) % MOD;
                }
                sum[i][j] = (sum[i - 1][j] + dp[i][j]) % MOD;
            }
        }
        printf("%d\n", (dp[n][0] + dp[n][1]) % MOD);
    }
}

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

#define BUFFER  8192
#define LIMIT   80

#define FORWARD(P,I) \
  { \
    (P) = (I); \
    while ( *(P) != '\0' ) ++(P); \
  }

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int n;

  scanf ( "%d", &n );

  while ( n-- )
  {
    char  a[ BUFFER ], b[ BUFFER ];
    char  res[ BUFFER ] = { 0 };
    char  *p, *r;
    int   i;

    scanf ( " %s %s", a, b );
    FORWARD( p, a )
    for ( r = res; --p >= a; )
    {
      if ( isdigit ( *p ) ) *( r++ ) += *p - '0';
    }
    FORWARD( p, b )
    for ( r = res; --p >= b; )
    {
      if ( isdigit ( *p ) ) *( r++ ) += *p - '0';
    }

    for ( i = 0; i < LIMIT; ++i )
    {
      res[ i + 1 ]  += res[ i ] / 10;
      res[ i ]      %= 10;
    }

    if ( res[ LIMIT ] )
    {
      puts ( "overflow" );
    }
    else
    {
      for ( i = LIMIT - 1; i > 0; --i )
      {
        if ( res[ i ] ) break;
      }
      do
      {
        printf ( "%d", res[ i ] );
      }
      while ( i-- );
      puts ( "" );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
import math

a, b, x = [int(a) for a in input().split()]

if x >= a * a * b / 2:
    ans = math.degrees(math.atan2(2 * a**2 * b - 2 * x, a**3))
else:
    ans = math.degrees(math.asin( (a * b**2) / math.sqrt( 4 * x**2 + a**2 * b**4) ))

print(ans)

Measured memory_bytes: 38256
from itertools import chain
n = int(input())

p = [[] for _ in range(4)]
for _ in range(n):
    a, b, d = input().split()
    a, b = map(int, (a, b))
    p[0 if d == 'R' else 1 if d == 'L' else 2 if d == 'U' else 3].append((a, b))
to_min = [None] * 4
to_max = [None] * 4
for i in range(4):
    if p[i]:
        to_min[i] = (max if i & 1 else min)(a if i < 2 else b for a, b in p[i])
        to_max[i] = (min if i & 1 else max)(a if i < 2 else b for a, b in p[i])
still = [None] * 2
for i in range(2):
    j = (1-i)*2
    if p[j] or p[j + 1]:
        still[i] = min(b if i else a for a, b in chain(p[j], p[j+1])), max(b if i else a for a, b in chain(p[j], p[j+1])) 

def f_width(i, t):
    if still[i]:
        leftmost, rightmost = still[i]
    else:
        leftmost, rightmost = 10 ** 18, - 10 ** 18
    i *= 2
    if to_min[i] != None:
        leftmost = min(leftmost, to_min[i] + t)
    if to_max[i+1] != None:
        leftmost = min(leftmost, to_max[i+1] - t)
    if to_min[i+1] != None:
        rightmost = max(rightmost, to_min[i+1] - t)
    if to_max[i] != None:
        rightmost = max(rightmost, to_max[i] + t)
    return rightmost - leftmost

t = []
for i in range(2):
    l, r = 0, 10 ** 10
    cnt = 0
    while cnt < 100000:
        cnt += 1
        c1, c2 = l + (r - l) / 3, l + (r - l) * 2 / 3
        if f_width(i, c1) >= f_width(i, c2):
            l = c1
        else:
            r = c2
    t.append(l)
l, r = min(t), max(t)
cnt = 0
while cnt < 100000:
    cnt += 1
    c1, c2 = l + (r - l) / 3, l + (r - l) * 2 / 3
    if f_width(0, c1) * f_width(1, c1) > f_width(0, c2) * f_width(1, c2):
        l = c1
    else:
        r = c2
print('{0:.13f}'.format(f_width(0, l) * f_width(1, l)))


Measured memory_bytes: 63832
/*
AizuOnline A1325
Title Gingko Number
*/
#include <stdio.h>
int prime_f[20001];

int prime_table[]={
        2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,
        53,59,61,67,71,73,79,83,89,97,
        101,103,107,109,113,127,131,137,139};

//

void make_furui(int limit)
{
        int i,j,p;

        prime_f[0]=prime_f[1]=0;
        for(i=0;i<=limit;i++)
                prime_f[i]=1;
        for(i=0;i<sizeof(prime_table)/sizeof(int);i++)
        {
                p = prime_table[i];
                prime_f[p]=1;
                for(j=2;prime_table[i]*j<limit;j++)
                        prime_f[p*j]=0;
        }
        //printf("*\n");
}
int isprime(int n)
{
  return(prime_f[n]);
}

int x,y;
int n;
int is_complex_prime(int p,int q)
{
        int m,n;
        int p2q2,m2n2;

        p2q2=p*p+q*q;

        if(isprime(p2q2))
                return(-1);

        for(m=0;m*m<=p2q2;m++)
                for(n=0;m2n2=n*n+m*m,m2n2<p2q2;n++)
                {
                        if(m==0 && n==0)
                                continue;
                        if(m2n2==1)
                                continue;
                        if(m == 0 && !isprime(n))
                                continue;
                        if(n == 0 && !isprime(n))
                                continue;
                        //printf("mn=%d %d %d\n",m,n,m2n2);
                       
                        if(0==((m*p+n*q) % m2n2) &&
                           0==((m*q-n*p) % m2n2))
                        {
                                //printf("CD\n");
                                return(0);
                        }
                }
        return(-1);
}
main()
{
        int i;

        scanf("%d",&n);
        make_furui(20000);
        for(i=0;i<n;i++)
        {
                scanf("%d %d\n",&x,&y);
                printf("%c\n",is_complex_prime(x,y)?'P':'C');
        }
return(0);
}

Measured memory_bytes: 680
// finish date: 2018/05/20

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

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
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>

//prim(ノード数、edge[頂点名][距離、行先の頂点])
ll prim(int N, vector<vector<pii >> edge) {
    priority_queue<pii, vector<pii >, greater<pii>> pq;
    vb used(N, false);
    pq.push(pii(0, 0));
    ll total = 0;
    while (!pq.empty()) {
        int dis, t;
        tie(dis, t) = pq.top();
        pq.pop();
        if (used[t]) continue;
        used[t] = true;
        total += dis;
        for (auto e: edge[t]) {
            if (!used[e.second]) pq.push(e);
        }
    }
    return total;
}


int main() {
    int N;
    cin >> N;
    vector<pii > x(N), y(N);
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        x[i] = make_pair(a, i);
        y[i] = make_pair(b, i);
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    vector<vector<pii >> edge(N);
    FOR(i, 1, N) {
        edge[x[i - 1].second].push_back(make_pair(abs(x[i].first - x[i - 1].first), x[i].second));
        edge[x[i].second].push_back(make_pair(abs(x[i].first - x[i - 1].first), x[i - 1].second));
        edge[y[i - 1].second].push_back(make_pair(abs(y[i].first - y[i - 1].first), y[i].second));
        edge[y[i].second].push_back(make_pair(abs(y[i].first - y[i - 1].first), y[i - 1].second));

    }
    cout << prim(N, edge) << endl;

    return 0;
}




Measured memory_bytes: 17528
#include <bits/stdc++.h>
using namespace std;
 
int count(int x){
  int counter = 0;
  while(x%2 == 0){
    counter++;
    x /= 2;
  }
  return counter;
}
 
int main(){
  int n, y;
  cin >> n;
  int ans = 0;
  for(int i = 0; i < n; ++i){
      cin >> y;
      if(y%2 == 0) ans += count(y);
  }
  cout << ans << '\n';
}

Measured memory_bytes: 3640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const int INF = 1e9;

int w, h;
int d[30][30][4];
int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};

bool isin(int i, int j){
    return i >= 0 && j >= 0 && i < h & j < w;
}

int main() {
    while (cin >> w >> h && w){
        VVI s(h, VI(w));
        VI c(4);
        REP(i,h) REP(j,w) cin >> s[i][j];
        REP(i,4) cin >> c[i];
        REP(i,h) REP(j,w) REP(k,4) d[i][j][k] = INF;
        d[0][0][0] = 0;
        priority_queue<pair<P, P>, vector<pair<P, P> >, greater<pair<P, P> > > q;
        q.push(make_pair(P(0,0), P(0,0)));
        while (!q.empty()){
            pair<P,P> a = q.top();
            q.pop();
            int i = a.second.first, j = a.second.second, dir = a.first.second;
            int dist = a.first.first;
            if(d[i][j][dir] < dist) continue;
            int cost[4] = {};
            if (s[i][j] != 0) cost[dir] = c[0];
            if (s[i][j] != 1) cost[(dir+1)%4] = c[1];
            if (s[i][j] != 2) cost[(dir+2)%4] = c[2];
            if (s[i][j] != 3) cost[(dir+3)%4] = c[3];
            REP(k,4){
                int ii = i + di[k], jj = j + dj[k];
                if (!isin(ii, jj)) continue;
                if (d[ii][jj][k] > d[i][j][dir] + cost[k]){
                    d[ii][jj][k] = d[i][j][dir] + cost[k];
                    q.push(make_pair(P(d[ii][jj][k], k), P(ii, jj)));
                }
            }
        }
        int ans = INF;
        REP(k,4) ans = min(ans, d[h-1][w-1][k]);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3216
#include <stdio.h>

int main(void){
    int a,b,max;
    
    scanf("%d %d",&a,&b);

    max=a+b;
    
    if(a*b>max)
        max=a*b;
    if(a-b>max)
        max=a-b;
        
    printf("%d\n",max);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
double pi = 3.1415926535;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    int n;
    vec(a,3);
    int ans = 1;
    cin >> n;
    REP(i,n){
        int t;
        cin >> t;
        int cnt = 0;
        REP(j,3){
            if(a[j] == t){
                cnt++;
            }
        }
        //cout << t << " ";
        ans *= cnt;
        ans %= max_int;
        REP(j,3){
            if(a[j] == t){
                a[j]++;
                break;
            }
        }
        //Debug(a);
    }
    print(ans)
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 256
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {d:u32, t:u32, s:u32}
    let a: f32 = d as f32 / s as f32;
    if a <= t as f32 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
bool is_square(int n) {
    for(int i = sqrt(n) + 1;i > 0;i--) {
        if(i * i == n) {
            return true;
        }
    }
    return false;
}

int main() {
    int a,b;
    cin >> a >> b;
    string s = to_string(b);
    if(is_square(a * (int)pow10(s.size()) + b)) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N;
  cin >> N;
  vector<vector<pair<int, int>>> G(N);

  int a, b;
  for(int i = 0; i < N-1; i++){
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(make_pair(b, i));
    G[b].push_back(make_pair(a, i));
  }

  vector<int> ans(N-1);
  for(int i = 0; i < N-1; i++){
    ans[i] = -1;
  }

  vector<int> vis(N);
  for(int i = 0; i < N; i++){
    vis[i] = 0;
  }
  queue<pair<int, int>> que;
  que.push(make_pair(0, -1));
  vis[0] = 1;
  
  while(!que.empty()){
    pair<int, int> v = que.front();
    int now = v.first;
    int used_color = v.second;
    que.pop();

    int color = 0;
    for(int i = 0; i < G[now].size(); i++){
      
      if(vis[G[now][i].first] == 1) continue;
      
      while(color == used_color){
        color++;
      }
      que.push(make_pair(G[now][i].first, color));
      vis[G[now][i].first] = 1;
      ans[G[now][i].second] = color;
      color++;
    }

  }

  int max_color = 0;
  for(int i = 0; i < N-1; i++){
    chmax(max_color, ans[i]);
  }

  cout << (max_color + 1) << endl;

  for(int i = 0; i < N-1; i++){
    cout << (ans[i]+1) << endl;
  }

  return 0;
}


Measured memory_bytes: 7424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e5+10;
const ll INF = 1e9 + 1;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}


int main() {
    int N; cin >> N;
    int h[MAX];
    for (int i = 0; i < N; ++i) cin >> h[i];

    ll dp[MAX];
    for (int i = 0; i < MAX; ++i) dp[i] = INF;
    dp[0] = 0;

    for (int i = 0; i < N; ++i) {
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }

    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1408
import sys
def main():
    input = sys.stdin.readline
    K=int(input())
    N=50
    ans=[]
    m=K%N
    for i in range(N):
        t = N-1 + K//N
        ans.append(t)
    for i in range(m):
        for j in range(N):
            if i==j: ans[j]+=N
            else: ans[j]-=1
    print(N)
    print(*ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
/// IN THE NAME OF GUITAR
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef pair<ll, ll> pll;

#define sz(x)                       (ll) x.size()
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define lc                          id << 1
#define rc                          lc | 1

ll Pow(ll a, ll b, ll md, ll ans = 1) {
    for (; b; b >>= 1, a = a * a % md)
        if (b & 1)
            ans = ans * a % md;
    return ans % md;
}
 
const ll MAXN = 5e3 + 20;
const ll INF  = 1e18;
const ll MOD  = 1e9 + 7;
ll A[MAXN], n, k;
bitset<MAXN> dp, bruh;

ll check(ll pos) {
	dp = bruh;
	dp[0] = 1;
	for (ll i = 1; i <= n; i++) {
		if (i == pos) continue;
		dp |= dp << A[i];
	}
	for (ll i = max(0LL, k - A[pos]); i < k; i++) {
		if (dp[i]) return 1;
	}
	return 0;
}

int main() {
	scanf("%lld%lld", &n, &k);
	for (ll i = 1; i <= n; i++) {
		scanf("%lld", &A[i]);
		A[i] = min(A[i], k);
	}
	sort(A + 1, A + n + 1);
	ll l = 0, r = n + 1;
	while (r - l > 1) {
		ll mid = (l + r) >> 1;
		if (check(mid)) r = mid;
		else l = mid;
	}
	printf("%lld\n", l);
    return 0;
}
 

Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int r,l;
  l=a+b;
  r=c+d;
  if(l==r){
    cout<<"Balanced"<<endl;
  }
  else if(l>r){
    cout<<"Left"<<endl;
  }
  else{
    cout<<"Right"<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

int main() {
	int N; cin >> N;
	vector<int> d(N);
	for (int i = 0; i < N; i++)cin >> d[i];
	sort(d.begin(), d.end());
	int a = d[N / 2], b = d[(N - 1) / 2];
	cout << a-b;
}



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

using namespace std;
static const int MAXV = 32;

int main() {
  int w, n, A[MAXV], a, b, tmp;
  scanf("%d %d", &w, &n);
  for(int i=1;i<w+1;i++)
    A[i]=i;
  //for(int i=0;i<w+1;i++)
  //  printf("%d\n", A[i+1]);
  for(int i=0;i<n;i++) {
    scanf("%d,%d", &a, &b);
    //printf("%d %d\n", a, b);
    tmp=A[a];
    A[a]=A[b]; A[b]=tmp;
    //printf("\n%d %d %d %d %d\n", A[1], A[2], A[3], A[4], A[5]);
  }
  for(int i=1;i<w+1;i++)
    printf("%d\n", A[i]);
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void ppp(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(int n,int k){
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int jank(int a){
  char s[4]="spr";
  FOR(3)if(a==s[i])return i;
}
ll x[100000];
int main(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int p[n];
  ll sum=0;
  FOR(n){
    scanf("%d",&p[i]);
    if(i<k)sum+=p[i];
  }
  ll ans=sum;
  for(int i=k;i<n;i++){
    sum+=p[i]-p[i-k];
    ans=max(ans,sum);
  }
  PRF((ans+k)/2.0);
  return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<tuple>
#include<stack>
#include<iomanip>
#include<map>

using namespace std;



int main() {
	float n, t, a, h[1000], av[1000], res,pre,ans;
	cin >> n >> t >> a;
	pre = 1000;
	int i, j;
	for (i = 0; i < n; i++) {
		cin >>h[i];
    }
  for(i=0;i<n;i++){
		av[i] = t - 0.006*h[i];
		res= a - av[i];
		if (res < 0) res= -res;

		if (pre > res) {ans = i+1 ;pre=res;}
     
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
const int maxn = 200500;
int cnt[maxn];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    long long a, b;
    int n;
    cin >> n;
    for(int i = 0 ; i < n ; ++i){
        int x;
        cin >> x;
        if(x == 1) cnt[x] = 1;
        else{
            if(cnt[x - 1]) cnt[x] = 1 + cnt[x - 1];
        }
    }
    int ans = 1e9;
    for(int i = 0 ; i <= n ; ++i)
        if(cnt[i])
            ans = min(ans, n - cnt[i]);
    cout << (ans == 1e9 ? -1:ans) << '\n';
    return 0;
}


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

int N;
#define MAX_N 100000
int X[MAX_N], D[MAX_N - 1];
int M; long long K;
int P[MAX_N - 1];
bool Seen[MAX_N - 1];
vector<vector<int>> L;
int OL[MAX_N - 1], IL[MAX_N - 1];

int main() {
  cin >> N;
  for(int i = 0; i < N; ++i) cin >> X[i];
  for(int i = 0; i < N - 1; ++i) D[i] = X[i + 1] - X[i];
  cin >> M >> K;
  for(int i = 0; i < N - 1; ++i) P[i] = i;
  for(int i = 0; i < M; ++i) { int a; cin >> a; swap(P[a - 2], P[a - 1]); }
  for(int i = 0; i < N - 1; ++i) {
    if(!Seen[i]) {
      int j = i;
      int ol = L.size(); L.emplace_back();
      do {
        Seen[j] = true; OL[j] = ol; IL[j] = L[ol].size(); L[ol].push_back(j);
        j = P[j];
      } while(j != i);
    }
  }
  cout << X[0] << endl;
  long long tmp = X[0];
  for(int i = 0; i < N - 1; ++i) {
    vector<int>& loop = L[OL[i]];
    tmp += D[loop[(IL[i] + K) % loop.size()]];
    cout << tmp << endl;
  }
  return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int l,r,d,p;
	int ans=0;
	cin>>l>>r>>d;
	p=d;
	while(p<=r)
	{
		if(p>=l)
		ans++;
		p=p+d;
	}
	cout<<ans<<endl;
	return 0;
}



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

int main()
{
    int N;
    cin >> N;
    int sum = 0;
    int lastN;
    if (N == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    else if (N == 2)
    {
        cout << 2 << endl;
        return 0;
    }
    for (int i = 0; i < N; ++i)
    {
        sum += i;
        if (sum >= N)
        {
            lastN = i;
            break;
        }
        else
        {
            lastN = i;
        }
    }
    int overN = sum - N;
    for (int i = 1; i <= lastN; ++i)
    {
        if (i == overN)
            continue;
        else
        {
            cout << i << endl;
        }
    }

    return 0;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	ll n, a, b;
	cin >> n >> a >> b;

	vector<int> h;
	ll ma = 0;
	for(int i=0; i<n; i++){
		ll t;
		cin >> t;
		h.pb(t);
		ma = max(ma, t);
	}

	int l = -1;
	int r = ma/b+1;
	int m;
	while(r-l > 1){
		m = (l + r)/2;
		ll cnt = 0;
		for(int j=0; j<n; j++){
			ll h2 = h[j] - m*b;
			if(h2 > 0){
				cnt += (h2 + (a-b-1)) / (a - b);
			}
		}
		if(cnt > m){
			l = m;
		}else if(cnt <= m){
			r = m;
		}
	}
	cout << r << endl;

	return 0;
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,d;
	cin>>a>>b>>c;
	d=a;
	a=b;
	b=d;
	d=a;
	a=c;
	c=d;
	cout<<a<<" "<<b<<" "<<c<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <sstream>
#include <iterator>
#include <complex>
using namespace std;

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

	vector<int> h(N);
	int count = 0;
	for(int i=0; i<N; i++)
	{
		cin>>h[i];

		if(h[i]>=K)
		{
			count++;
		}
	}
	cout<<count<<endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int solve(int,int);
int A[2000],n;
 
int solve(int x,int y) {
  if(A[x] == y)
    return 1;
  if(x+1 == n)
    return 0;
  if(solve(x+1,y-A[x]) || solve(x+1,y)) 
    return 1;
  return 0;  
  }
int main(void) {
 
  int S[2000],i,m;
 
  scanf("%d",&n);
   
  for(i=0;i<n;i++) 
    scanf("%d",&A[i]);
   
  scanf("%d",&m);
  for(i=0;i<m;i++) 
    scanf("%d",&S[i]);
   
  for(i=0;i<m;i++) {
    if(solve(0,S[i])) 
      printf("yes\n");
    else printf("no\n");
     
  }
  return 0; 
}
 

Measured memory_bytes: 1808
#include <cstdio>
#define Maxn 100000
int k,n;
int ans[Maxn+5][3];
int main(){
	scanf("%d%d",&n,&k);
	if(n<2*k-1){
		puts("-1");
		return 0;
	}
	int len=0;
	for(int i=0;i<n/2;i++){
		ans[++len][0]=k+n/2-1-i;
		ans[len][1]=k+n+i*2+1;
		ans[len][2]=k+n*2+i;
	}
	for(int i=0;i<(n+1)/2;i++){
		ans[++len][0]=k+n-1-i;
		ans[len][1]=k+n+i*2;
		ans[len][2]=k+n*2+n/2+i;
	}
	for(int i=1;i<=len;i++){
		printf("%d %d %d\n",ans[i][0],ans[i][1],ans[i][2]);
	}
	return 0;
}


Measured memory_bytes: 3328
use proconio::input;

fn main() {
  input! {
    s: String,
  }
  
  let mut max = 0;
  let mut temp = 0;
  for c in s.chars() {
    if c == 'R' {
      temp += 1;
    } else {
      max = std::cmp::max(max, temp);
      temp = 0;
    }
  }
  max = std::cmp::max(max, temp);
  
  println!("{}", max);
}

Measured memory_bytes: 2132
#include<iostream>
#define ll long long
#define MOD 1000000007
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    char **arr=new char*[n+1];
    ll int **dp=new ll int*[n];
    for(int i=0;i<n;i++)
        dp[i]=new ll int[m]();
    for(int i=0;i<n;i++)
        arr[i]=new char[m];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
            cin>>arr[i][j];
    }
    int i=0;
    while(i<n&&arr[i][0]!='#')
    {
        dp[i][0]=1;i++;
    }
    int j=0;
    while(j<m&&arr[0][j]!='#')
    {
    dp[0][j]=1;
    j++;
    }
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<m;j++)
        {
            if(arr[i][j]!='#')
            {
                ll int c=(dp[i-1][j]%MOD+dp[i][j-1]%MOD)%MOD;
                if(c!=0)
                    dp[i][j]=c;
                else
                    dp[i][j]=0;
            }
        }
    }
    cout<<(dp[n-1][m-1]%MOD)<<endl;
}
    


Measured memory_bytes: 11888
// AOJ 0267 Triangle of Blocks
// 2017.9.8 bal4u@uu
// 2017.11.18

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

int b[1003];
int g[1003];

int isTriNum(int k)
{
	return ((int)sqrt((k << 3) + 1)) & 1;
}

int main()
{
	int n, i, k, a, sum, ans;

	for (i = 1; i <= 1000; i++) g[i] = i;

	while (scanf("%d", &n) && n) {
		for (sum = 0, i = 1; i <= n; i++) scanf("%d", &a), b[i] = a, sum += a;
		if (!isTriNum(sum)) { puts("-1"); continue; }
		ans = 0; while (1) {
			if (ans > 10000) { puts("-1"); break; }
			if (!memcmp(b, g, sizeof(int)*(n+1))) { printf("%d\n", ans); break; }

			for (k = 1, i = 1; i <= n; i++) {
				if (b[i] > 1) b[k++] = b[i]-1;
			}
			b[k] = n, n = k, ans++;
		}
	}
	return 0;
}

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

typedef long long ll;
typedef vector<ll> v1;
typedef vector<vector<ll>> graph;

const ll INF = 1ll << 50;

ll n;

int main(){
    cin >> n;
    for(ll x = 0;x <= n;x++){
        if((x*108)/100 == n){
            cout << x << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}


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

int main()
{
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;

  bool isinrectangle = false;
  if(( x - r  >= 0 and x + r <= W ) and ( y - r >= 0 and y + r <= H )) {
    isinrectangle = true;
  }

  if( isinrectangle == true ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3092
<?php
define("MAX", 1300000);

// sieve
for ($i = 0; $i < MAX; $i++) {
  $isPrime[] = 1;
}
$isPrime[0] = $isPrime[1] = 0;
for ($i = 2; $i < MAX; $i++) {
  if (!$isPrime[$i]) continue;
  for ($j = 2 * $i; $j < MAX; $j += $i) {
    $isPrime[$j] = 0;
  }
}

while (fscanf(STDIN, "%d", $k) && $k) {
  $ans = 0;
  $idx = $k;
  while (!$isPrime[$idx]) {
    $ans++;
    $idx++;
  }
  $idx = $k;
  while (!$isPrime[$idx]) {
    $ans++;
    $idx--;
  }
  print $ans . "\n";
}

Measured memory_bytes: 195792
from collections import deque
import sys
def input():
    return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    G = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b, c = list(map(int, input().split()))
        a -= 1
        b -= 1
        G[a].append([b, c])
        G[b].append([a, c])
    q, k = list(map(int, input().split()))
    k -= 1
    stack = deque([k, ])
    ans = [-1] * n
    ans[k] = 0
    while stack:
        x = stack.popleft()
        for (dx, l) in G[x]:
            if ans[dx] == -1:
                ans[dx] = ans[x] + l
                stack.appendleft(dx)
    for _ in range(q):
        x, y = list(map(lambda x: int(x) - 1, input().split()))
        print(ans[x] + ans[y])

if __name__ == '__main__':
    main()


Measured memory_bytes: 87472
#include<stdio.h>
int main()
{
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  
  if(a/d>c/b) printf("Yes");
  if(a/d==c/b)
  {
  	if(a%d==0&&c%b!=0) printf("No");
  	else printf("Yes");
  }
  if(a/d==c/b-1)
  {
  	if(a%d!=0&&c%b==0) printf("Yes");
	else printf("No");  
  }
  if(a/d<c/b-1) printf("No");
  
  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }      
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  a.push_back(0);
  a.push_back(0);
  a.push_back(0);
  int A=0,B=0;
  for(int i=0;i<N/2+1;i++){
    A+=a.at(2*i);
    B+=a.at(2*i+1);
  }
  cout<<A-B<<endl;
}

Measured memory_bytes: 3604
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
satisfy = sum(B)

for i in range(n-1):
    if A[i+1] == A[i] + 1:
        satisfy += C[A[i]-1]

print(satisfy)

Measured memory_bytes: 3064