akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,M;
int main(){
    cin>>N>>M;
    ll ans=1;
    for(ll i=1;i*i<=M;i++){
        if(M%i==0){
            if(M/i>=N){
                ans=max(ans,i);
            }
            if(i>=N){
                ans=max(ans,M/i);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(void) {
	int act[32][2],num[32],w,n,a,b,i,data;
	scanf("%d",&w);
	scanf("%d",&n);
	for(i = 1;i <= n;i++){
		scanf("%d,%d",&a,&b);
		act[i][0] = a;
		act[i][1] = b;
	}
	for(i = 1;i <= w;i++){
		num[i] = i;
	}
	for(i = 1;i <= n;i++){
		data = num[act[i][0]];
		num[act[i][0]] = num[act[i][1]];
		num[act[i][1]] = data;
	}
	for(i = 1;i <= w;i++){
		printf("%d\n",num[i]);
	}
	return 0;
}

Measured memory_bytes: 596
import fractions

def div(a,b,c):
    val=b//c-(a-1)//c
    return val

A,B,C,D=map(int,input().split())
numC=div(A,B,C)
numD=div(A,B,D)
lcm=int(C*D/(fractions.gcd(C,D)))
numCD=div(A,B,lcm)
ans=B-A+1-numC-numD+numCD
print(ans)

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

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif

void solve() {
    int k;
    cin >> k;
    int t = 0, x = 0;
    set<int> occur;
    while (true) {
        t++;
        x = (x * 10 + 7) % k;
        if (x == 0)
            break;
        if (occur.count(x)) {
            cout << -1;
            return;
        } else {
            occur.insert(x);
        }
    }

    cout << t;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 50488
from math import gcd
from itertools import product


def solve(string):
    k = int(string)
    ans = 0
    for a, b, c in product(range(1, k + 1), repeat=3):
        ans += gcd(gcd(a, b), c)
    return str(ans)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


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

int length(char chr[]) {
    int num = 0;
    for(int r = 0; r < 30; r++) {
        if(chr[r] == '\0') break;
        num++;
    }
    return(num);
}

int main(void) {
    char ary[30];
    scanf("%s", ary);
    int len = length(ary);
    
    for(int r = len - 1; r >= 0; r--) {
        putchar(ary[r]);
    }
    putchar('\n');
    
    //cout << len << endl;
    return(0);
}

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

int main(void){
    int N,L; string s[100];
    cin >> N >>L;
    for(int i = 0;i < N;i++)cin >> s[i];
    sort(s,s+N);
    for(int i = 0;i < N;i++)cout << s[i];
    cout << endl;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

ll dp[105][100005];

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  ll N, W;
  scanf("%lld %lld", &N, &W);

  vector<pair<ll, ll>> list(N);
  for (ll i = 0; i < N; i++) {
    ll n, w;
    scanf("%lld %lld", &n, &w);
    list[i] = make_pair(n, w);
  }

  for (ll i = N - 1; i >= 0; i--) {
    ll w = list[i].first;
    ll v = list[i].second;

    for (ll j = 0; j <= W; j++) {
      if (j >= w) {
        dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w] + v);
      } else {
        dp[i][j] = dp[i + 1][j];
      }
    }
  }

  cout << dp[0][W] << endl;
}


Measured memory_bytes: 80128
/*  */
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
#include <cassert>
#include <functional>
#include <iterator>
#include <iomanip>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,1024000")

#define sti				set<int>
#define stpii			set<pair<int, int> >
#define mpii			map<int,int>
#define vi				vector<int>
#define pii				pair<int,int>
#define vpii			vector<pair<int,int> >
#define rep(i, a, n) 	for (int i=a;i<n;++i)
#define per(i, a, n) 	for (int i=n-1;i>=a;--i)
#define clr				clear
#define pb 				push_back
#define mp 				make_pair
#define fir				first
#define sec				second
#define all(x) 			(x).begin(),(x).end()
#define SZ(x) 			((int)(x).size())
#define lson			l, mid, rt<<1
#define rson			mid+1, r, rt<<1|1
#define getBits(x)		__builtin_popcount(x)
#define getBitIdx(x)	__builtin_ffs(x)

typedef long long LL;
const int maxn = 2e5+5;
vector<pii> g1, g2;
int ans[maxn];
int fa[maxn], c[maxn];
int fa2[maxn];
bool visit[maxn];
int n, m1, m2;

int find(int x, int *fa) {
	if (x == fa[x])
		return x;
	return fa[x] = find(fa[x], fa);
}

void merge(int x, int y, int *fa) {
	int fx = find(x, fa), fy = find(y, fa);
	
	if (fx != fy) {
		fa[fx] = fy;
	}
}

void solve() {
	int u, v;
	
	rep(i, 0, n+1) fa[i] = i;
	rep(i, 0, m1) {
		u = g1[i].fir;
		v = g1[i].sec;
		merge(u, v, fa);
	}
	
	rep(i, 0, n+1) fa2[i] = i;
	rep(i, 0, m2) {
		u = g2[i].fir;
		v = g2[i].sec;
		merge(u, v, fa2);
	}
	
	vector<pair<int,int> > vc;
	rep(i, 1, n+1) {
		int bid = find(i, fa);
		vc.push_back(make_pair(bid, i));
	}
	sort(vc.begin(), vc.end());
	
	int i = 0;
	while (i < n) {
		int j = i;
		while (i<n && vc[j].fir==vc[i].fir) {
			int fi = find(vc[i].sec, fa2);
			++c[fi];
			++i;
		}
		for (int k=j; k<i; ++k) {
			int fk = find(vc[k].sec, fa2);
			ans[vc[k].sec] += c[fk];
		}
		for (int k=j; k<i; ++k) {
			int fk = find(vc[k].sec, fa2);
			--c[fk];
		}
	}
	
	rep(i, 1, n+1) {
		if (i == n)
			printf("%d\n", ans[i]);
		else
			printf("%d ", ans[i]);
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// #ifndef ONLINE_JUDGE
		// freopen("data.in", "r", stdin);
		// freopen("data.out", "w", stdout);
	// #endif
	
	int u, v;
	
	scanf("%d %d %d", &n, &m1, &m2);
	rep(i, 0, m1) {
		scanf("%d %d", &u, &v);
		// g1[u].push_back(v);
		// g1[v].push_back(u);
		g1.push_back(make_pair(u, v));
	}
	rep(i, 0, m2) {
		scanf("%d %d", &u, &v);
		// g2[u].push_back(v);
		// g2[v].push_back(u);
		g2.push_back(make_pair(u, v));
	}
	solve();
	
	// #ifndef ONLINE_JUDGE
		// printf("time = %ldms.\n", clock());
	// #endif
	
	return 0;
}


Measured memory_bytes: 7024
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int a[1000001];
main()
{
    int i,j;
    long long n,m,sum,p;
    long long a[100001];
    memset(a,0,sizeof(a));
    scanf("%lld %lld",&n,&m);
    for(i=0;i<n;i++)
        scanf("%lld",&a[i]);
    sum=0;
    for(i=0;i<n;i++)
    {
        if (a[i]+a[i+1]>m)
        {
            sum+=a[i]+a[i+1]-m;
             //printf("%lld\n",sum);
            p=a[i]+a[i+1]-m;
            a[i+1]=a[i+1]-p;
            //printf("%lld\n",a[i+1]);
            p=0;
        }
    }
    printf("%lld\n",sum);
}


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

int main() {
    int n;
    scanf("%d", &n);
    int cnt4 = 0, cnt2 = 0;
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        if (x % 4 == 0) cnt4++;
        else if (x % 2 == 0) cnt2++;
    }
    if (cnt4 + cnt2 / 2 >= n / 2) puts("Yes");
    else puts("No");
    return 0;
}

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

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

    if(1<=N && N<=9){
        cout << N << endl;
    }
    else if(10<=N && N<=99){
        cout << 9 << endl;
    }
    else if(100<=N && N<=999){
        cout << 9+ N-99 << endl;
    }
    else if(1000<=N && N<=9999){
        cout << 909 << endl;
    }
    else if(10000<=N && N<=99999){
        cout << 909+ N-9999 << endl;
    }
    else if(N == 100000){
        cout << 90909 << endl;
    }


}

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

void dfs(int v, int now, vector<bool> &used, vector<int> &zero, vector<int> &one, vector<vector<int>> &ans) {
  used[v] = true;
  if (now == 0) zero.emplace_back(v);
  else one.emplace_back(v);
  for (int i = v + 1; i < used.size(); i++) {
    if (!used[i] && ans[v][i] == -1) dfs(i, (now ^ 1), used, zero, one, ans);
  }
  return;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<vector<int>> ans(n, vector<int>(n, -1));
  
  for (int i = 1; i < n; i++) {
    vector<bool> used(n, false);
    vector<int> zero, one;
    for (int j = 0; j < n; j++) {
      if (!used[j]) dfs(j, 0, used, zero, one, ans);
    }
    if (one.size() == 0) break;
    for (int j = 0; j < zero.size(); j++) {
      for (int k = 0; k < one.size(); k++) {
        if (ans[zero[j]][one[k]] == -1) {
          ans[zero[j]][one[k]] = ans[one[k]][zero[j]] = i;
        }
      }
    }
  }
  
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (j > i + 1) cout << " ";
      cout << ans[i][j];
    }
    cout << '\n';
  }
}

Measured memory_bytes: 4580
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define ppll pair<ll, pll>
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro%mod);
}
vector<int> prime;
void seive(){
    vector<bool > isprime(1000001,true);
    for(int i=2;i*i<=1000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll ans=((n-1)*n)/2;
    cout<<ans;
    return 0;
}


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

int main() {
  int N = 5;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  int K;
  cin >> K;
  cout << ((A.at(4) - A.at(0) > K) ? ":(" : "Yay!") << "\n";
}

Measured memory_bytes: 256
H,W,K=list(map(int,input().split()))
H,W,K

Black=[]
for h in range(H):
    L_=list(input())
    for w in range(W):
        if L_[w]=='#':
            Black.append([h,w])

from itertools import product

ans=0

for h in product(range(2),repeat=H):
    for w in product(range(2),repeat=W):
        h_=[]
        for _ in range(H):
            if h[_]==1:
                h_.append(_)
        w_=[]
        for _ in range(W):
            if w[_]==1:
                w_.append(_)
                    
        Black_=[]
        
        if len(h_) == 0 and len(w_) == 0:
            pass
        elif len(w_) > 0 and len(h_) == 0:
            for W_ in w_:
                for black in Black:
                    if black[1] == W_:
                        if black not in Black_:
                            Black_.append(black)
        
        elif len(w_) == 0 and len(h_) > 0:
            for H_ in h_:
                for black in Black:
                    if black[0] == H_:
                        if black not in Black_:
                            Black_.append(black)            
        
        elif len(h_)>0 and len(w_)>0:
            for H_ in h_:
                for W_ in w_:
                    for black in Black:
                        if black[0] == H_ or black[1] == W_:
                            if black not in Black_:
                                Black_.append(black)
                    
        if len(Black)-len(Black_) == K:
#             print(h_,w_,Black_)
            ans+=1
print(ans)

Measured memory_bytes: 69072
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fill(x,c) memset(x,c,sizeof(x))
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int SIZE = 1e6+10;
ll a[SIZE];
int main() {
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll m,n;
	cin>>n>>m;
	cout<<(m==n?"Yes":"No");
  	return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

long long int N, M, K, Q, W, H, L, R;
long long int ans;



int main() {
	ios::sync_with_stdio(false);
	int num[101][101] = {};
	bool used[101][101] = {};
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		num[a][b] = c;
		num[b][a] = c;
	}
	priority_queue<pair<int, int>>PQ;
	for (int i = 1; i <= N; i++) {
		vector<int>dis(N + 1, INT_MAX);
		dis[i] = 0;
		PQ.push({ 0,i });
		while (!PQ.empty()) {
			int c = PQ.top().first;
			int cn = PQ.top().second;
			PQ.pop();
			if (dis[cn] < c)continue;
			dis[cn] = c;
			for (int j = 1; j <= N; j++) {
				if (num[cn][j]) {
					if (dis[j] > dis[cn] + num[cn][j]) {
						dis[j] = dis[cn] + num[cn][j];
						PQ.push({ dis[j],j });
					}
				}
			}
		}
		for (int j = i + 1; j <= N; j++) {
			queue<int>QQ;
			QQ.push(j);
			while (!QQ.empty()) {
				int c = QQ.front();
				for (int k = 1; k <= N; k++) {
					if (num[c][k]) {
						if (dis[c] == dis[k] + num[k][c]) {
							QQ.push(k);
							used[c][k] = true;
							used[k][c] = true;
						}
					}
				}
				QQ.pop();
			}
		}
	}
	for (int i = 1; i <= N; i++) {
		for (int j = i + 1; j <= N; j++) {
			if (num[i][j] && !used[i][j])ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(){
    int n,m;

    cin >> n >> m;

    std::vector<int> a(m);
    std::vector<int> b(m);

    for(int i = 0; i < m; ++i)
        cin >> a[i] >> b[i];

    vector<pair<int,int>> v(m);

    for(int i = 0; i < m; ++i)
        v[i] = make_pair(a[i], b[i]);

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

    int ans = 0;
    int cut = 1000000;

    for(int i = 0; i < m; ++i){
        int pos = v[i].first;

        if(cut <= pos){
            ++ans;
            cut = 1000000;
        }

        cut = min(cut, v[i].second);
    }

    cout << ans + 1 << endl;

}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
 
int main() {
  int N, M;
  cin >> N >> M;
  int a, b;
  vector<int> noman(N);
  int count = 0;
  rep (i, M) {
    cin >> a >> b;
    if ( a == 1 || a == N) {
      noman[b-1] ++;
    }
    if ( b==1 || b == N) {
      noman[a-1] ++;
    }
    if (noman[a-1] >= 2 || noman[b-1] >= 2) {
      cout << "POSSIBLE" << endl;
      count ++;
      break;
    }
  }
  if ( count == 0 ) {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N; i >= 0; i--)
const ll INF = 1000000000000000000;
//input



//processing
vector<int> A(4);


//dpTable
//int dp[100050];

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    for(int i = 0; i < N; i++){
        cin >> S.at(i);
        if (S.at(i) == "AC") A.at(0)++;
        if (S.at(i) == "WA") A.at(1)++;
        if (S.at(i) == "TLE") A.at(2)++;
        if (S.at(i) == "RE") A.at(3)++;
    }
    cout << "AC x " << A.at(0) << endl << "WA x " << A.at(1) << endl << "TLE x " << A.at(2) << endl << "RE x " << A.at(3) << endl;
    return 0;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
using namespace std;
const int mod =  1000000007;
const int LIM = 100005;
#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(a) a.begin() , a.end()
#define vvi vector<vector<int>>
//#define double long double
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define endl '\n'
#define pb push_back
#define sp <<" "<<
#define ss second
#define ff first
int power(int x, int n){
    int res = 1;
    while(n){
          if(n&1){
                res = res * x % mod;
          }
          x = x * x % mod;
          n>>=1;
    }
    return res;
}
int a[200005],n,k;
int f(int len)
{
  int cnt=0;
  for(int i=n-1;i>=0;i--)
  {
    if(a[i]<=len)break;
    cnt+= a[i]/len;
  }
  if(cnt<=k)return 1;
  else return 0;
}
int32_t main()
{     //IOS;
      int tt=1,x,y,z,i,j;
      //cin>>tt;
      while(tt--)
      { cin>>n>>k;
        for(i=0;i<n;i++)
        cin>>a[i];
        sort(a,a+n);
        int l,r;
        l=1; r=a[n-1];
        int ans=a[n-1];
        while(l<=r)
        {
          int m=(l+r)/2;
          if(f(m))
          {
            ans=m;
            r=m-1;
          }
          else
          l=m+1;
        }
        cout<<ans;
      }
}


Measured memory_bytes: 5160
#include<iostream>
using namespace std;
int main() {
	int a, b,f(0);
	cin >> a >> b;
	int x, y;
	double  x1, y1;
	x = 12.5 * a+0.5;
	//cout << x << endl;
	x1 = 12.5 * (a + 1);
	y = 10 * b;
	y1 = 10 * (b + 1);
	int xx[2000],yy[2000];
	for (int i = 0; i <double(x1-x); ++i) {
		xx[i] = x + i;
	}
	//cout << xx[11] << xx[12] << xx[13] << endl;
	for (int i = 0; i < double(y1-y); ++i) {
		yy[i] = y + i;
	}
	//cout <<  xx[0]<<xx[1]<<xx[2]<<yy[0];
	for (int i = 0; i <double(x1 - x); ++i) {
		for (int j = 0; j < double(y1 - y); ++j) {
			if (xx[i] == yy[j] && xx[i] != 0 && f == 0) {
				cout << xx[i];
				f = 1;
		}
		
		}
	}
	if (f == 0) {
		cout << -1;
	}
	return 0;
}

Measured memory_bytes: 256
from math import sqrt


def cross(P0, P1, P2):
    x0, y0 = P0; x1, y1 = P1; x2, y2 = P2
    x1 -= x0; x2 -= x0
    y1 -= y0; y2 -= y0
    return x1*y2 - x2*y1


def dot(P0, P1, P2):
    x0, y0 = P0; x1, y1 = P1; x2, y2 = P2
    x1 -= x0; x2 -= x0
    y1 -= y0; y2 -= y0
    return x1*x2 + y1*y2


def dist2(P0, P1):
    x0, y0 = P0; x1, y1 = P1
    return (x1 - x0)**2 + (y1 - y0)**2


def collision_ll(S0, S1, T0, T1):
    return cross(S0, S1, T0)*cross(S0, S1, T1) < 0 and cross(T0, T1, S0) * cross(T0, T1, S1) < 0


def dist_lp(S, E, P):
    dd = dist2(S, E)
    if 0 <= dot(S, E, P) <= dd:
        return abs(cross(S, E, P))/sqrt(dd)
    return sqrt(min(dist2(S, P), dist2(E, P)))


def dist_ll(S0, S1, T0, T1):
    if collision_ll(S0, S1, T0, T1):
        return 0
    return min(
            dist_lp(S0, S1, T0),
            dist_lp(S0, S1, T1),
            dist_lp(T0, T1, S0),
            dist_lp(T0, T1, S1)
            )


n = int(input())
for i in range(n):
    x0, y0, x1, y1, X0, Y0, X1, Y1 = map(int, input().split())
    print("%.010f" % dist_ll((x0, y0), (x1, y1), (X0, Y0), (X1, Y1)))


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

const int maxn = 1e5 + 10;
int n;
vector <int> ad[maxn];
int sz[maxn];

bool dfs(int root, int P) {
	sz[root] = 1;
	bool ret = 0, C = 0;
	for (auto x : ad[root]) {
		if (x != P) {
			ret |= dfs(x, root);
			if (sz[x] % 2 == 1) {
				if (C)
					ret = 1;
				C = 1;
			}
			sz[root] += sz[x];
		}
	}
	return ret;
}

int main() {
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		ad[u].push_back(v);
		ad[v].push_back(u);
	}
	if (dfs(0, -1) || (n % 2 == 1))
		return cout << "First", 0;
	return cout << "Second", 0;
}

Measured memory_bytes: 9552
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
ans = 0

if sum(a) < x:
    print(n - 1)
elif sum(a) == x:
    print(n)
else:
    for i in a:
        if x < i:
            print(ans)
            break
        x -= i
        ans += 1

    

Measured memory_bytes: 2940
#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;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a,b,c,d,g,h;
	cin >> a >> b >> c >> d;
	g = (c+b-1)/b;
	h = (a+d-1)/d;
	if(g<=h)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 3640
N = int(input())
As = list(map(int, input().split()))
dai = 0
for i in range(N-1):
    delta = As[i+1] - As[i]
    dai_i = 0
    if delta < 0:
        dai_i = -delta
    dai += dai_i
    As[i+1] += dai_i
print(dai)

Measured memory_bytes: 32280
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    int d, t ,s;
    cin>>d>>t>>s;
    if(d <= t*s)
        cout<<"Yes";
    else
        cout<<"No";
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3660
S = list(input())
Q = int(input())
f = list()
b = list()
r = False
for i in range(Q):
    q = input()
    if q[0] == '1':
        r = not r
    else:
        T, F, C = q.split()
        if (F == '1') ^ r:
            f.append(C)
        else:
            b.append(C)
if r:
    S = list(reversed(S + b)) + f
else:
    S = list(reversed(f)) + S + b

print(''.join(S))

Measured memory_bytes: 80888
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

    int ans;
    if(A >= 13)
        ans = B;
    else if(A >= 6)
        ans = B / 2;
    else
        ans = 0;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
	int h, w;
	std::cin >> h >> w;

	int count = 0;
	for (int i = 0; i < h * w; ++i) {
		char c;
		std::cin >> c;

		if (c == '#')
			++count;
	}

	if (count == h + w - 1)
		std::cout << "Possible" << std::endl;
	else
		std::cout << "Impossible" << std::endl;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 5005, P = 1000000007;

int n, A, B;
int f[N][2], g[N][2];

int main() {
	read(n), read(A), read(B);
	if (A > B) {
		std::swap(A, B);
	}
	f[0][0] = f[0][1] = 1;
	for (int i = 1; i < B; ++i) {
		f[i][0] = f[i][1] = 0;
		for (int j = A; j <= i; ++j) {
			f[i][0] = (f[i][0] + f[i - j][1]) % P;
		}
		for (int j = 1; j <= i; ++j) {
			f[i][1] = (f[i][1] + f[i - j][0]) % P;
		}
	}
	int s = 0;
	for (int i = 1; i < n; ++i) {
		if (i < A) {
			g[i][0] = 1;
		}
		for (int j = 1; j < A && j < i; ++j) {
			g[i][0] = (g[i][0] + g[i - j][1]) % P;
		}
		if (i < B) {
			g[i][1] = f[i][1];
		}
		for (int j = 1; j < B && j < i; ++j) {
			g[i][1] = (g[i][1] + 1ll * g[i - j][0] * f[j - 1][1]) % P;
		}
		if (n - i < A) {
			s = (s + g[i][1]) % P;
		}
		if (n - i < B) {
			s = (s + 1ll * g[i][0] * f[n - i][1]) % P;
		}
	}
	int ans = 1;
	for (int i = 1; i <= n; ++i) {
		ans = 2ll * ans % P;
	}
	ans = (ans + P - s) % P;
	print(ans);
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}



int main() {
	int n,X; cin >> n>>X;

	vector<Int> x(n);

	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}

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

	Int gcdd = abs(x[x.size() - 1] - X);
	int mod;

	for (int i = n-1; i > 0; i-- ) {
		gcdd = gcd(gcdd, (x[i] - x[i - 1]));
	}
	cout << gcdd << endl;
	//cout << lcm(24, 48);

	
	


	//cout << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int m[5][5][5];
int t[5][5][5];
int b[27];
int c[27];
char str[6];
void CLs(){
	for(int i=0;i<5;i++)
		for(int j=0;j<5;j++)
			for(int k=0;k<5;k++)
				t[i][j][k]=0;
}
int main(){
	int a;
	int T=0;
	while(scanf("%d",&a),a){
		if(T)printf("\n");
		for(int i=0;i<5;i++)
			for(int j=0;j<5;j++){
				scanf("%s",str);
				for(int k=0;k<5;k++)m[i][j][k]=str[k]-'0';
			}
		int d,e;
		scanf("%d",&d);
		for(int i=0;i<d;i++)scanf("%d",b+i);
		scanf("%d",&e);
		for(int i=0;i<e;i++)scanf("%d",c+i);
		for(int i=0;i<a;i++){
			CLs();
			for(int j=0;j<5;j++)
				for(int k=0;k<5;k++)
					for(int l=0;l<5;l++)
						for(int x=-1;x<=1;x++)
							for(int y=-1;y<=1;y++)
								for(int z=-1;z<=1;z++){
									if(x==0&&y==0&&z==0)continue;
									if(!m[j][k][l]||j+x<0||j+x>4||k+y<0||k+y>4||l+z<0||l+z>4)continue;
									t[j+x][k+y][l+z]++;
								}
			for(int j=0;j<5;j++)
				for(int k=0;k<5;k++)
					for(int l=0;l<5;l++)
						if(m[j][k][l]){
							bool ok=false;
							for(int p=0;p<e;p++)if(t[j][k][l]==c[p])ok=true;
							if(!ok)m[j][k][l]=0;
						}else{
							bool ok=false;
							for(int p=0;p<d;p++)if(t[j][k][l]==b[p])ok=true;
							if(ok)m[j][k][l]=1;
						}
		}
		printf("Case %d:\n",++T);
		for(int i=0;i<5;i++){
			for(int j=0;j<5;j++){
				for(int k=0;k<5;k++)printf("%d",m[i][j][k]);
				printf("\n");
			}
			if(i<4)printf("\n");
		}
		
	}
}

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

int main(){
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    int b,d;
    if(k!=0) b=log2(k)+1;
    else b=0;
    ll e=0,f=0;
    for(int j=b-1;j>=0;j--){
        d=0;
        for(int i=0;i<n;i++){
            if((a[i]>>j)&1) d++;
        }
        if(d<=n/2){
            f=e+(1LL<<j);
            if(f<=k) e=f;
        }
    }
    ll h=0;
    for(int i=0;i<n;i++) h+=e^a[i];
    cout<<h<<endl;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()

const double eps=1e-5;
const int INF=1e9;

int modd(int a,int b)
{
	int ret=a-b;
	if(ret>0)
	{
		return ret%3;
	}
	else
	{
		return (ret+(-ret/3 + 1)*3)%3;
	}
}
int main()
{
	string s,t;
	cin>>s>>t;
	vector<int> ssa(s.size()+1),tsa(t.size()+1),
				ssb(s.size()+1),tsb(t.size()+1);
	vector<int> tseq;
	tseq.push_back(-1);
	int sa=0,sb=0;
	REP(i,s.size())
	{
		if(s[i]=='A')
			sa++;
		if(s[i]=='B')
			sb++;
		ssa[i+1]=sa;
		ssb[i+1]=sb;
	}
	sa=0;sb=0;
	REP(i,t.size())
	{
		if(t[i]=='A')
			sa++;
		if(t[i]=='B')
			sb++;
		tsa[i+1]=sa;
		tsb[i+1]=sb;
	}

	REP(i,t.size()-1)
	{
		if(t[i]==t[i+1])
			tseq.push_back(i);
	}



	int q;
	cin>>q;
	REP(que,q)
	{
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		a--;c--;
		bool f=1;
		if(modd(ssa[b]-ssa[a], ssb[b]-ssb[a]) != 
			modd(tsa[d]-tsa[c], tsb[d]-tsb[c]))
			f=0;
		
		//auto tm=lower_bound(ALL(tseq), d-2);
		//tm--;
		//if((*tm)<c)f=0;
		if(f)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
}



Measured memory_bytes: 3004
#include<iostream>

using namespace std;


void InsertionSort(int*Array, const int Num) {
	for (int i = 1; i < Num; i++) {
		//Sort
		int tmp = *(Array + i);
		int j;
		for (j = i - 1; j >= 0 && *(Array + j) > tmp; j--) {
			*(Array + j + 1) = *(Array + j);
		}
		*(Array + j + 1) = tmp;


		//Display
		cout << *Array;
		for (int j = 1; j < Num; j++)cout << " " << *(Array + j);
		cout << endl;
	}
}

int main() {
	int Num;
	int Array[101];

	//Input
	cin >> Num;
	for (int i = 0; i < Num; i++)cin >> Array[i];

	cout << Array[0];
	for (int i = 1; i < Num; i++)cout << " " << Array[i];
	cout << endl;

	InsertionSort(Array, Num);

	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	boolean[][] map;
	int n;
	boolean m2(int i, int j){
		if(i < 0 || i >= n || j < 0 || j >= n){
			return false;
		}	
		return !map[i][j];
	}
	boolean m3(int i, int j){
		if(i < 0 || i >= n || j < 0 || j >= n){
			return false;
		}	
		return map[i][j];
	}
	boolean check(int i, int j){
		if(!m2(i,j)){
			return false;
		}
		int[] di = {-1,0,1,0};
		int[] dj = {0,1,0,-1};
		int sum = 0;
		for(int z = 0; z< 4; z++){
			sum += m3(i+di[z],j+dj[z])?1:0;
		}
		return sum < 2;
	}
	void run(){
		int x = sc.nextInt();
		for(int z = 0; z < x ; z ++ ){
			if(z!=0){
				System.out.println();
			}
			n = sc.nextInt();
			map = new boolean[n][n];
			
			int[] di = {1,0,-1,0};
			int[] dj = {0,1,0,-1};
			int  i = 0 ; 
			int  j = 0 ;
			int dirc  = 0;
			map[i][j] = true;
			for(;;){
//				System.out.println(i+","+j);
				if(check(i+di[dirc],j+dj[dirc])){
					i+=di[dirc];
					j+=dj[dirc];
					map[i][j] = true;
				}else{
//					System.out.println("turn right");
					dirc++;
					dirc = dirc&3;
					if(check(i+di[dirc],j+dj[dirc])){
						i+=di[dirc];
						j+=dj[dirc];
						map[i][j] = true;
					}else{
						break;
					}
				}
			}
			for(i =0 ; i <n;i++){
				for(j =0 ; j < n ; j++){
					System.out.print(map[n-i-1][j]?'#':' ');
				}
				System.out.println();
			}
		}
		
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  string tmp;
  map<string,int> gacha;
  cin >> N;
  for(int i=0;i<N;i++) {
	cin >> tmp;
    gacha[tmp]++;
  }
  cout << gacha.size() << endl;
}


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

using namespace std;

#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  nl "\n";
#define FIO ios_base::sync_with_stdio(false);cout.setf(ios::fixed);cout.precision(10);cout.tie(nullptr);cin.tie(nullptr);

int dx[] = { 0,0,1,-1,-1,-1,1,1 };
int dy[] = { 1,-1,0,0,-1,1,1,-1 };

template < class T> inline T biton(T n, T pos) { return n | ((T)1 << pos); }
template < class T> inline T bitoff(T n, T pos) { return n & ~((T)1 << pos); }
template < class T> inline T ison(T n, T pos) { return (bool)(n & ((T)1 << pos)); }
template < class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); }return a; }

template <class T> inline T bigmod(T p, T e, T m) {
	T ret = 1;
	for (; e > 0; e >>= 1) {
		if (e & 1) ret = (ret * p) % m; p = (p * p) % m;
	} return (T)ret;
}

#define DEBUG

#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
	cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " is " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define debug(...)
#endif

vector<long long> primes;

void sieve(int n) {

	vector<long long> pr(n + 1);

	pr[0] = pr[1] = 1;

	for (int i = 2; i <= n; i++) {

		if (pr[i] == 0)
			for (int j = i + i; j <= n; j = j + i) {
				pr[j] = 1;
			}
	}

	for (int i = 0; i < pr.size(); i++) {
		if (pr[i] == 0) {
			primes.push_back(i);
		}
	}
}

bool pairprime(vector<long long>& items)
{
	vector<long long> pr(1000006);

	for (auto n : items)
	{
		for (int i = 0; i < primes.size() && primes[i] <= sqrt(n); i++) {

			bool ok = false;
			while (n % primes[i] == 0) {
				n = n / primes[i];
				ok = true;
			}

			if (ok) {
				if (pr[primes[i]]) {
					return false;
				}
				debug(primes[i]);
				pr[primes[i]] = 1;
			}
		}

		if (n!=1) {
			if (pr[n]) {
				return false;
			}

			pr[n] = 1;
		}
	}
		


	return true;
}

void solve()
{
	int n;
	cin >> n;

	vector<long long> items(n);

	for (int i = 0; i < n; i++) {
		cin >> items[i];
	}

	if (pairprime(items)) {
		cout << "pairwise coprime" << nl;
	}
	else {

		long long gc = 0;

		for (auto i : items) {
			gc = gcd(i,gc);
		}

		if (gc == 1) {
			cout << "setwise coprime" << nl;
		}
		else {
			cout << "not coprime" << nl;
		}
	}
}

int main()
{
	sieve(1000006);

	FIO;

	int t = 1;

	while (t--)
	{
		solve();
	}

	return 0;
}

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

#define ll long long
#define ar array

int n, k, p[200001];

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

	cin >> n >> k;
	for(int i=0; i<n; ++i) {
		cin >> p[i+1];
		p[i+1]+=p[i];
	}
	int ans=0;
	for(int i=k; i<=n; ++i) {
		ans=max(ans, p[i]-p[i-k]);
	}
	cout << fixed << setprecision(9) << (double)(ans+k)/2.0;
}


Measured memory_bytes: 4472
import math
a,b,h,m = map(int,input().split())
jx = a*math.sin((h/12+m/(60*12))*2*math.pi)
jy = a*math.cos((h/12+m/(60*12))*2*math.pi)
hx = b*math.sin(m/60*2*math.pi)
hy = b*math.cos(m/60*2*math.pi)

#print(jx,jy)
#print(hx,hy)
ans = (jx-hx)**2 + (jy-hy)**2
print(ans**(1/2))

Measured memory_bytes: 62660
/*input
4 6
3 1 2 3
2 4 2
2 4 6
1 6
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define YY cout<<"YES\n"
#define NN cout<<"NO\n"
#define yy cout<<"Yes\n"
#define nn cout<<"No\n"
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=1000005;
const ll magic=500;

const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
vector<int> v[maxn];
vector<int> edge[maxn];
bool vis[maxn];
int dfs(int u){
	vis[u]=1;
	int ret=1;
	for(int v:edge[u]) if(!vis[v]){
		ret+=dfs(v);
	}
	return ret;
}

int main()
{
	IOS;
	int n,m;
	cin>>n>>m;
	REP(i,n){
		int cnt;
		cin>>cnt;
		while(cnt--){
			int tmp;
			cin>>tmp;
			tmp--;
			v[tmp].pb(i);
		}
	}
	REP(i,m){
		REP(j,SZ(v[i])-1){
			edge[v[i][j]].pb(v[i][j+1]);
			edge[v[i][j+1]].pb(v[i][j]);
		}
	}
	if(dfs(0)==n) YY;
	else NN;
}


Measured memory_bytes: 55416
#include <iostream>
#include <string.h>
using namespace std;
int main(){
	while( 1 ){
		int n, m, a;
		int lottery[1001][101];
		memset( lottery, 0, sizeof(lottery) );
		cin >> n >> m >> a;
		if( n == 0 ) break;
		while( m-- > 0 ){
			int h, p, q;
			cin >> h >> p >> q;
			lottery[1000-h][p] = q;
			lottery[1000-h][q] = p;
		}
		for( int i = 1; i <= 1000; i++ ){
			for( int j = 1; j <= 100; j++ ){
				if( lottery[i][j] && a == j ){
					a = lottery[i][j];
					break;
				}
			}
		}
		cout << a << endl;
	}
}

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

int main() {
  int n,m;cin>>n>>m;
  ll an[n],bn[n], cn[m],dn[m];
  rep(i,n) cin>>an[i]>>bn[i];
  rep(j,m) cin>>cn[j]>>dn[j];
  ll d, dmin, dx;
  rep(i,n) {
    dmin=INF;
    rep(j,m) {
      d = abs(cn[j]-an[i]) + abs(dn[j]-bn[i]);
      if (d < dmin) {
        dmin = d;
        dx = j+1;
      }
    }
    cout << dx << endl;
  }
}


Measured memory_bytes: 256
s=list(input())
t=list(input())
N=len(s)
M=len(t)

s.sort()
t.sort(reverse=True)
for i in range(min(N,M)):
    if t[i]>s[i]:
        print("Yes")
        exit()
    elif t[i]<s[i]:
        print("No")
        exit()
    else:
        continue

if N<M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

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

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

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

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

int main() {

  ll N,M;
  cin>>N>>M;
  ll P[M],Q[M];
  map <ll,vector<ll>> mp;
  FOR(i,0,M-1){
    cin>>P[i]>>Q[i];
    mp[P[i]].emplace_back(Q[i]);
  }
  for(auto &p : mp) {
    sort(p.second.begin(), p.second.end());
  }
  for(int i = 0; i < M; i++) {
    // auto id = distance( lower_bound( begin(mp[P[i]] ), end( mp[P[i]] ), Q[i]), begin( mp[ P[i] ] ) );
    auto id = lower_bound(begin(mp[P[i]]), end(mp[P[i]]), Q[i]) - begin(mp[P[i]]);
    printf("%06d%06d\n", P[i],  (ll)id + 1);
  }
  return 0;
}
 


Measured memory_bytes: 13952
def inpl(): return list(map(int, input().split()))

N, Q = inpl()
S = input()
T = [""]*(Q)
D = [-1]*(Q)
for i in range(Q):
    t, d = input().split()
    T[i] = t
    D[i] += 2*(d == "R")

def checkL(ix):
    for i in range(Q):
        if T[i] == S[ix]:
            ix += D[i]
        if ix == N:
            return True
        if ix < 0:
            return False
    return True

def checkR(ix):
    for i in range(Q):
        if T[i] == S[ix]:
            ix += D[i]
        if ix == N:
            return False
        if ix < 0:
            return True
    return True

OK = N
NG = -1
while abs(OK-NG)>1:
    mid = (OK+NG)//2
    if checkL(mid):
        OK = mid
    else:
        NG = mid

Lans = OK*1

OK = -1
NG = N
while abs(OK-NG)>1:
    mid = (OK+NG)//2
    if checkR(mid):
        OK = mid
    else:
        NG = mid
print(max(OK-Lans+1, 0))

Measured memory_bytes: 6600
#include<stdio.h>
#include<string.h>
 
#define N 1001
 
int c[N][N];
int m,n;
 
void LCRLength(char *x,char *y){
  int i,j;
 
  m=strlen(x);
  n=strlen(y);
 
  for(i=1;i<=m;i++) c[i][0]=0;
  for(j=0;j<=n;j++) c[0][j]=0;
 
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(x[i-1]==y[j-1]) c[i][j]=c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1]) c[i][j]=c[i-1][j];
      else c[i][j]=c[i][j-1];
    }
  }
}
 
int main(){
  int q,i;
  char x[N],y[N];
 
  scanf("%d",&q);
 
  for(i=1;i<=q;i++){
    scanf("%s",x);
    scanf("%s",y);
    LCRLength(x,y);
    printf("%d\n",c[m][n]);
  }
 
  return 0;
}

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

string s;

void solve() {
  if (s.at(2) == s.at(3) && s.at(4) == s.at(5)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


int main() {
  cin >> s;
  solve();
}


Measured memory_bytes: 256
// 2324
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    const int dx = tx - sx, dy = ty - sy;

    cout << string(dy, 'U') << string(dx, 'R');
    cout << string(dy, 'D') << string(dx, 'L');
    cout << 'L' << string(dy+1, 'U') << string(dx+1, 'R') << 'D';
    cout << 'R' << string(dy+1, 'D') << string(dx+1, 'L') << 'U';
    cout << "\n";

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    ll sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    tx-=sx;
    ty-=sy;
    
    for(ll y=0;y<ty;y++) cout<<"U";
    for(ll x=0;x<tx;x++) cout<<"R";
    for(ll y=0;y<ty;y++) cout<<"D";
    for(ll x=0;x<tx+1;x++) cout<<"L";
    for(ll y=0;y<ty+1;y++) cout<<"U";
    for(ll x=0;x<tx+1;x++) cout<<"R";
    cout<<"D";
    cout<<"R";
    for(ll y=0;y<ty+1;y++) cout<<"D";
    for(ll x=0;x<tx+1;x++) cout<<"L";
    cout<<"U"<<endl;
}

Measured memory_bytes: 256