akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int H, W;
	cin >> H >> W;
	int cnt = 0;
	vector< vector<char> > A(H, vector<char>(W));
	for (int i = 0; i < H; ++i)
	{
		for (int j = 0; j < W; ++j)
		{
			cin >> A[i][j];
			if (A[i][j] == '#')
			{
				++cnt;
			}
		}
	}
	if (cnt != (H - 1) + (W - 1) + 1)
	{
		cout << "Impossible" << endl;
		return;
	}
	P pos;
	pos.first = 0;
	pos.second = 0;
	for (int i = 0; i < cnt - 1; ++i)
	{
		if (pos.first + 1 < H && A[pos.first + 1][pos.second] == '#')
		{
			pos.first = pos.first + 1;
		}
		else if (pos.second + 1 < W && A[pos.first][pos.second + 1] == '#')
		{
			pos.second = pos.second + 1;
		}
		else
		{
			cout << "Impossible" << endl;
			return;
		}
	}
	cout << "Possible" << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int i = 0;
  while (i<s.size()){
    if (s.at(i)=='C') break;
    i++;
  }
  if (i==s.size()){
    cout << "No";
  } else { 
    while (i<s.size()){
      if (s.at(i)=='F') break;
      i++;
    }
    if (i==s.size()){
      cout << "No";
    } else {
      cout << "Yes";
    }
  }
}

Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto ac = new bool[](N);
    auto wa = new long[](N);
    foreach (_; 0 .. M)
    {
        auto ps = readln.split();
        long p = ps[0].to!long;
        p--;
        if (ps[1] == "AC")
        {
            ac[p] = true;
            continue;
        }
        if (ps[1] == "WA" && !ac[p])
        {
            wa[p]++;
            continue;
        }
    }
    long[2] ans;
    ans[0] = ac.sum();
    ans[1] = zip(ac,wa).map!"a[0]?a[1]:0".sum();
    arywrite(ans[]);
}


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

int main() {
	int A[3]; cin >> A[0] >> A[1] >> A[2];
	sort(A, A+3);
	int sa1 = A[2]-A[0], sa2 = A[2]-A[1];
	if((sa1%2)==(sa2%2)) cout << (sa1+sa2)/2 << endl;
	else cout << (sa1+sa2+3)/2 << endl;
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;



struct state {
  int turn;
  int y,x;
  int ba;
  state() {}
  state(int a,int y, int x, int ba) : turn(a) ,y(y) , x(x) ,ba(ba)  {}
};

typedef pair<int,int> pii;
typedef pair<int, pair<int,int> > piii;

int dx[] = {-1,-1,-1,0,0,1,1,1};
int dy[] = {-1,0,1,-1,1,-1,0,1};
int main() {
  int n;
  while(cin >> n , n){
    state stat;
    int ba = 0;
    for(int i = 0; i < n; i++){
      string str;
      cin >> str;
      REP(j, str.size()) {
        if (str[j] == '#') ba |= 1<<(i*n+j);
        if (str[j] == '@') {
          stat.y = i;
          stat.x = j;
        }
      }
    }
    stat.ba = ba;
    stat.turn = 0;
    queue<state> Q;
    Q.push(stat);

    int res = -1;
    map<piii, bool> visited;
    
    while(!Q.empty()) {
      state now = Q.front();
      Q.pop();
      
      if (visited[piii(now.ba,pii(now.y,now.x))]) continue;
      visited[piii(now.ba,pii(now.y,now.x))] = 1;

      // cout << now.turn << endl;
      // REP(i, n) {
      //   REP(j, n) {
      //     if (now.ba >> (i*n+j) & 1) 
      //       cout << '#';
      //     else {
      //       if(i==now.y && j==now.x)
      //         cout << '@';
      //       else
      //         cout << '.';
      //     }
      //   }
      //   cout << endl;
      // }

      bool f = 0;
      REP(i, n) {
        REP(j, n) {
          if (now.ba >> (i*n+j) & 1) {
            f = 1;
            break;
          }
        }
        if(f) break;
      }
      if (!f) {
        res = now.turn;
        break;
      }
      REP(k, 8) {
        int yy = now.y+dy[k];
        int xx = now.x+dx[k];

        if(yy<0||yy>=n||xx<0||xx>=n) continue;
        if(now.ba >> (yy*n+xx) & 1) continue;

        //  cout << yy << " " << xx << endl;
        state next = now;
        next.turn++;
        next.y = yy;
        next.x = xx;
        
        REP(i, n) {
          REP(j, n) {
            int cnt = 0;
            REP(k, 8) {
              int ii = i+dy[k];
              int jj = j+dx[k];
              if (ii<0||ii>=n||jj<0||jj>=n) continue;
              if ((now.ba >> (ii*n+jj) & 1) || ii==next.y&&jj==next.x) cnt++;
            }
            if (next.ba >> (i*n+j) & 1) {
              if (cnt == 2 || cnt == 3);
              else {
                next.ba ^= 1<<(i*n+j);
              }
            } else if (!(i==next.y&&j==next.x)) {
              if (cnt == 3) {
                next.ba |= 1 << (i*n+j);
              }
            }
          }
        }
        
        if(visited[piii(next.ba, pii(next.y, next.x))]) continue;
        Q.push(next);
      }
    }
    cout << res << endl;
  }
  

}

Measured memory_bytes: 1900
#include<iostream>
#include<string>
#include<map>
using namespace std;

int func(string s, string t){
    int ans=0;
    for(char c='a';c<='z';c++){
        bool founds=false,foundt=false;
        for(int i=0;i<s.length();i++){
            if(s[i]==c){
                founds=true;
            }
        }
        for(int i=0;i<t.length();i++){
            if(t[i]==c){
                foundt=true;
            }
        }
        if(founds&&foundt)ans++;
    }
    return ans;
}
 
int main(){
    int N,i,j,k;
    string S;
    cin>>N>>S;
    int ans=0;
    for(i=1;i<N;i++){
        map<char, int> mp;
        string s1,s2;
        for(j=0;j<i;j++){
            s1+=S[j];
        }
        for(k=i;k<N;k++){
            s2+=S[k];
        }
        int tmp=func(s1,s2);
        ans=max(ans,tmp);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int n, m, t, p;
    cin >> n >> m >> t >> p;
    if (n == 0 && m == 0 && t == 0 && p == 0){
      break;
    }
    vector<vector<int>> cnt(m, vector<int>(n, 1));
    for (int i = 0; i < t; i++){
      int d, c;
      cin >> d >> c;
      vector<vector<int>> cnt2(m, vector<int>(n, 0));
      if (d == 1){
        for (int j = 0; j < m; j++){
          for (int k = 0; k < n; k++){
            if (k < c){
              cnt2[j][c - k - 1] += cnt[j][k];
            } else {
              cnt2[j][k - c] += cnt[j][k];
            }
          }
        }
      }
      if (d == 2){
        for (int j = 0; j < m; j++){
          for (int k = 0; k < n; k++){
            if (j < c){
              cnt2[c - j - 1][k] += cnt[j][k];
            } else {
              cnt2[j - c][k] += cnt[j][k];
            }
          }
        }
      }
      swap(cnt, cnt2);
    }
    for (int i = 0; i < p; i++){
      int x, y;
      cin >> x >> y;
      cout << cnt[y][x] << endl;
    }
  }
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define int long long
 
int x[200000], y[200000];
int32_t main() {
	int n;
	cin >> n;
	int a;
 
	for (int i = 1; i <= n; ++i) {
		cin >> a;
		if (a + i < n)
			x[a + i]++;
		if (i - a > 0)
			y[i - a]++;
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		ans += x[i] * y[i];
	}
	cout << ans << "\n";
}

Measured memory_bytes: 6736
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// input scanner
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextInt64s(n int) []int64 {
	ret := make([]int64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt64()
	}
	return ret
}

func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) int {
	ans := l[0]
	for _, n := range l {
		if n > ans {
			ans = n
		}
	}
	return ans
}

func min(l []int) int {
	ans := l[0]
	for _, n := range l {
		if n < ans {
			ans = n
		}
	}
	return ans
}

func abs(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}

// main
func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt64()
	a := nextInt64()
	b := nextInt64()
	if a > b {
		a, b = b, a
	}
	if (b-a)%2 == 0 {
		fmt.Println((b - a) / 2)
	} else {
		if a > n-b {
			fmt.Println((n - b) + (b-a+1)/2)
		} else {
			fmt.Println((a - 1) + (b-a+1)/2)
		}
	}
}


Measured memory_bytes: 640
import collections

n = int(input())
a = list(map(int, input().split()))
a_sum = sum(a)
ac = collections.Counter(a)
q = int(input())
ans = []
for i in range(q):
    b, c = map(int, input().split())
    b_num = ac[b]
    before = b * b_num
    after = c * (b_num)
    a_sum = a_sum - before + after
    ans.append(a_sum)

    tmp = ac[b]
    del ac[b]
    ac[c]+= tmp

[print(total) for total in ans]


Measured memory_bytes: 26692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(a >= k){
    cout << k << endl;
  }else if(a+b >= k) {
    cout << a << endl;
  }else{
    cout << a - (k-a-b) << endl;
  }

  return 0;
}


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

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    int a, b;
    char c;
    cin >> a >> c >> b;
    if (c == '+') cout << a + b << endl;
    else cout << a - b << endl;
}

Measured memory_bytes: 256
from itertools import accumulate

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A = sorted(A)
B = sorted(B)
C = sorted(C)

acc_a = [0]*N
acc_c = [0]*N

i_a = 0
i_c = N-1
for i in range(N):
    b = B[i]
    while i_a < N and A[i_a] < b:
        acc_a[i] += 1
        i_a += 1

for i in reversed(range(N)):
    b = B[i]
    while i_c >= 0 and C[i_c] > b:
        acc_c[i] += 1
        i_c -= 1

acc_a = list(accumulate(acc_a))
acc_c = list(accumulate(acc_c[::-1]))
acc_c = acc_c[::-1]

ans = 0
for a, c in zip(acc_a, acc_c):
    ans += a*c
print(ans)


Measured memory_bytes: 124212
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 char colour[7][10] = { "SUN", "MON", "TUE", 
                           "WED" ,"THU" ,"FRI" ,"SAT" }; 
	//char s[7][3]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
	char str[3];
	cin>>str;
	int i,ans;
	for(i=0;i<7;i++)
	{
		if(strcmp(str,colour[i])==0) 
		{
			ans=7-i;
			break;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
const int dx[]={1,0,-1,0,1,-1,1,-1}, dy[]={0,-1,0,1,1,-1,-1,1};

bool valid(int x,int y,int W,int H)
{
    return (x>=0&&x<W)&&(y>=0&&y<H);
}
int main()
{
    int W,H,i,j,k,x,y;
    queue<int> Q;
    cin >> H >> W;
    while(W && H)
    {
        int num=0;
        int A[W][H];
        for(i=0;i<W;i++)
            for(j=0;j<H;j++)
                cin >> A[i][j];
        for(i=0;i<W;i++)
            for(j=0;j<H;j++)
            {
                if(A[i][j]==1)
                {
                    Q.push(i);
                    Q.push(j);
                    A[i][j]=0;
                    num++;
                    while(!Q.empty())
                    {
                        x=Q.front();
                        Q.pop();
                        y=Q.front();
                        Q.pop();
                        for(k=0;k<8;k++)
                        {
                            if(valid(x+dx[k],y+dy[k],W,H))
                            {
                                if(A[x+dx[k]][y+dy[k]]==1)
                                {
                                    Q.push(x+dx[k]);
                                    Q.push(y+dy[k]);
                                    A[x+dx[k]][y+dy[k]]=0;
                                }
                            }
                        }
                    }
                }
            }
        cout << num << endl;
        cin >> H >> W;
    }
    return 0;
}


Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  string s, t;
  cin >> s >> t;
  P(t + s);


  return 0;
}





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

#define range 524289
#define mod 998244353
#define eps 1e18
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <ll> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;


int e[8] = {1,-1,1, -1, 2,2,-2,-2};
int z[8] = {2, 2,-2, -2, 1,-1,1,-1};



int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--){
        int n, k;
        cin>>n>>k;

        vi a(n);
        for (int i = 0; i < n; ++i)
        {
            /* code */
            cin>>a[i];
        }

        vi dp(n, INT_MAX);
        dp[0] =0;
        // cout<<a[0]<<a[1]<<endl;
        for (int i = 1; i <n; ++i)
        {
            /* code */
            for(int j = 1; j<=k&&i-j>=0; j++){
                dp[i] = min(dp[i], dp[i-j]+abs(a[i]-a[i-j]));
            }
        }
        cout<<dp[n-1]<<endl;
        return 0;

    }

}



Measured memory_bytes: 1920
#include <iostream>

#define rep(i, first, to) for(ll i = first; i < to; ++i)

using namespace std;
typedef long long ll;
const ll MAX = 1LL << 60;

ll h, w;
ll solve1() {
	ll min, max;

	min = h / 3;
	if (h % 3 != 0) {
		max = h / 3 +  1;
	} else {
		max = h / 3;
	}
	return (max - min) * w;
}
ll solve2() {
	ll min, max;

	min = w / 3;
	if (w % 3 != 0) {
		max = w / 3 +  1;
	} else {
		max = w / 3;
	}
	return (max - min) * h;
}
ll solve3() {
	ll s1,s2, s3;
	ll w2, w3;
	ll max1, min1;
	ll ans = MAX;
	w2 = w / 2;
	w3 = w % 2 == 0 ? w / 2 : w / 2 + 1;
	rep(i, 1, h / 2 + 1) {
		s1 = w * i;
		s2 = w2 * (h - i);
		s3 = w3 * (h - i);
		max1 = max(s1, max(s2, s3));
		min1 = min(s1, min(s2, s3));
		if (max1 - min1 < ans) {
			ans = max1 - min1;
		}
	}
	return ans;
}
ll solve4() {
	ll w2, w3;
	ll s1,s2, s3;
	ll max1, min1;
	ll ans = MAX;
	w2 = h / 2;
	w3 = h % 2 == 0 ? h / 2 : h / 2 + 1;
	rep(i, 1, w / 2 + 1) {
		s1 = h * i;
		s2 = w2 * (w - i);
		s3 = w3 * (w - i);
		max1 = max(s1, max(s2, s3));
		min1 = min(s1, min(s2, s3));
		if (max1 - min1 < ans) {
			ans = max1 - min1;
		}
	}
	return ans;
}

int main() {
	cin >> h >> w;
	ll ans = min(solve1(), min(solve2(), min(solve3(), solve4())));
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double pi = 3.141592653589793;

int main(){
  int a,b,h,m;
  cin >> a >> b >> h >> m;
  double h_r,m_r,d_r;
  h_r = 30 * (h % 12) + 30 * ((double)m / 60);
  m_r = 6 * (m % 60);
  d_r = abs(h_r - m_r);
  d_r = 2 * pi * d_r / 360;
  double tmp,ans = 0;
  tmp = a*a + b*b - 2*a*b*cos(d_r);
  cout << setprecision(15);
  ans = sqrt(tmp);
  cout << ans << endl;
}

Measured memory_bytes: 4288
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  ll n;
  cin >> n;
  ll res = n/11;
  if (n%11 > 6) res = (res+1)*2;
  else if (0 < n%11 && n%11 <= 6) res = res*2+1;
  else res *= 2;
  dump(res);					\
  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
p=[list() for i in range(n+1)]
for a,b in l:
	p[a].append(b)
	p[b].append(a)
q=[(1,[1])]
ans=0
while len(q)!=0:
	x,v=q.pop(0)
	if len(v)==n:
		ans+=1
		continue
	for i in p[x]:
		if i in v:continue
		q.append((i,v+[i]))
print(ans)


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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int abs(int a,int b){
	return (a>b)?a:b;
}
int main(){
	fast_io
	int a,b,c,d,m;
	cin>>a>>b>>c>>d;
	//m=min(abs(a-c), abs(b-a)+abs(c-b));
	if(abs(a-c)<=d or (abs(b-a)<=d and abs(c-b)<=d)) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 384
import math

N = int(input())
P = list(input().split())
Q = list(input().split())

count = 0

def keisan(t):
    num = []
    q = 0
    c = 0
    tmp = 1
    while q < N:
        if int(t[q]) > tmp and (tmp in num) is False:
            c += math.factorial(N - q - 1)
            tmp += 1
        elif int(t[q]) == tmp:
            q += 1
            num.append(tmp)
            tmp = 1
        else:
            tmp += 1
    return c


count += abs(keisan(P) - keisan(Q))

print(count)


Measured memory_bytes: 3064
package main
/*
N A B
*/
import (
        "bufio"
         "fmt"
        // "log"
        "os"
        "strconv"
        "strings"
)

func main() {
        stdin := bufio.NewScanner(os.Stdin)
        stdin.Scan()
        line := strings.Split(stdin.Text(), " ")
        a, _ := strconv.Atoi(line[0])
        b, _ := strconv.Atoi(line[1])
        c, _ := strconv.Atoi(line[2])
	n:=0
	for i:=1;i*a <= b;i++ {
	if i <= c {
	n++
	}
	
	}
	fmt.Println(n)

}


Measured memory_bytes: 640
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);

    int num[] = new int[5];

    for(int i=0; i<=4; i++){
      num[i] = scanner.nextInt();
    }
    int k = scanner.nextInt();

    for(int i=0; i<num.length; i++){
      if(num[num.length-i-1] - num[i] > k){
        System.out.println(":(");
        return;
      }
    }
    System.out.println("Yay!");
    return;

  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,k,ans;
int a[N],du[N],dis[N],vis[N];
void tp(int u){
	vis[u]=1;dis[u]++;if(a[u]==u) return;
	if(dis[u]==k&&a[u]!=1) ans++,dis[u]=0;
	du[a[u]]--;dis[a[u]]=max(dis[a[u]],dis[u]);
	if(du[a[u]]==0&&vis[a[u]]==0) tp(a[u]); 
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	if(a[1]!=1) ans=1,a[1]=1;
	for(int i=1;i<=n;i++) du[a[i]]++;
	for(int i=1;i<=n;i++) if(du[i]==0&&vis[i]==0) tp(i);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
N = gets.to_i
if N == 1 
    puts "Hello World"
else 
    data = Array.new 
    2.times do |i|
        data.push(gets.to_i)
    end 
    int = 0 
    data.each do |n|
        int += n 
    end 
    puts int 
end 

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

int main()
{
  int r, g, b;
  cin >> r >> g >> b;
  if((100 * r + 10 * g + b) % 4 == 0)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int n,l,i,j;
  //文字列の個数と長さを決める
  scanf("%d %d",&n,&l);
  char str[n][l+1];
  char swap[l+1];
  //文字を入れて大きさを比べ並び替え
  for(i=0;i<n;i++){
   scanf("%s",str[i]);
  }
  for(i=0;i<n;i++){
   for(j=0;j<i;j++){
    if(strcmp(str[i],str[j])<0){
      strcpy(swap,str[i]);
      strcpy(str[i],str[j]);
      strcpy(str[j],swap);
    }
   }
  }
  //出力
  for(i=0;i<n;i++){
   printf("%s",str[i]);
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define i64 long long
using namespace std;
int main() {
	// your code goes here
	int R,C;
	scanf("%d %d",&R,&C); getchar();
	string grid[2*R+2];
	char newGrid[2*R+2][C+2];
	
	for(int i=0;i<R;i++){
		cin>>grid[i];
		//printf("%s\n", grid[i].c_str());
		for(int j=0;j<C;j++) {
			newGrid[2*i][j]   = grid[i][j];
			newGrid[2*i+1][j] = grid[i][j];
		}
	}
	
	/* for(int i=0;i<R;i++){
		for(int j=0;j<C;j++) printf("%c",newGrid[i][j]);
		printf("\n");
	}
	printf("\n"); 
	
	for(int i=1;i<=2*R;i++){
		for(int j=1;j<=C;j++){
			newGrid[i][j] = newGrid[(i+1)/2][j];
		}
	}
	*/
	
	for(int i=0;i<2*R;i++){
		//printf("%d: ", i);
		for(int j=0;j<C;j++) printf("%c",newGrid[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
ll nmax = 100001;
vll bit(nmax);
ll bmax(ll id){
    if(!(id)) return 0;
    return max(bit[id], bmax(id-((id)&(-id))));
}
void badd(ll id, ll x){
    if(id>nmax) return;
    bit[id] = max(x, bit[id]);
    badd(id+((id)&(-id)), x);
}
vll rbit(nmax);
ll rbmax(ll id){
    if(!(id)) return 0;
    return max(rbit[id], rbmax(id-((id)&(-id))));
}
void rbadd(ll id, ll x){
    if(id>nmax) return;
    rbit[id] = max(x, rbit[id]);
    rbadd(id+((id)&(-id)), x);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,c;
    cin >> n >> c;
    vll x(n),v(n);
    ll ans = 0;
    REP(i,n){
        cin >> x[i] >> v[i];
    }
    ll sum = 0;
    REP(i,n){
        sum+=v[i];
        ans = max(ans, sum-x[i]);
        badd(i+1,sum-x[i]);
    }
    sum = 0;
    for(int i=n-1;i>=0;i--){
        sum+=v[i];
        ans = max(ans, sum-(c-x[i]));
        rbadd(n-i, sum-(c-x[i]));
    }
    sum=0;
    REP(i,n){
        sum+=v[i];
        ans = max(ans, sum-x[i]*2+rbmax(n-i-1));
    }
    sum = 0;
    for(int i=n-1;i>=0;i--){
        sum+=v[i];
        ans = max(ans, sum-(c-x[i])*2+bmax(i));
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3456
n, m, s, t = map(int, input().split())
s -= 1; t -= 1
G = [[] for i in range(n)]
for i in range(m):
    u, v, a, b = map(int, input().split())
    G[u-1].append((v-1, a, b))
    G[v-1].append((u-1, a, b))
V = 10**15
ans = [0]*n

from heapq import heappush, heappop
def dijkstra(s, m):
    D = [10**30]*n
    que = [(0, s)]
    D[s] = 0
    while que:
        co, v = heappop(que)
        if D[v] < co:
            continue
        for w, a, b in G[v]:
            c = b if m else a
            if co + c < D[w]:
                D[w] = co + c
                heappush(que, (co+c, w))
    return D
D1 = dijkstra(s, 0)
D2 = dijkstra(t, 1)
v = 10**30
for i in range(n-1, -1, -1):
    v = min(v, D1[i] + D2[i])
    ans[i] = 10**15 - v
print(*ans, sep='\n')

Measured memory_bytes: 115356
import bisect


def main():
    N = int(input())
    A = [int(input()) for _ in range(N)][::-1]
    ans = [A[0], ]
    bright = bisect.bisect_right
    L = 1
    for i, a in enumerate(A):
        if i == 0:
            continue
        index = bright(ans, a)
        if index == L:
            ans.append(a)
            L += 1
        else:
            ans[index] = a
    print(L)


if __name__ == "__main__":
    main()


Measured memory_bytes: 56408
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << 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) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void test_case();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	int n, x;
	cin >> n >> x;
	vector < int > l(n);
	for (auto &el: l) {
		cin >> el;
	}
	int res = 1;
	int pos = 0;
	for (int i = 0; i < n; ++i) {
		pos += l[i];
		res += (pos <= x);
	}
	cout << res << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
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 gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n, k;
  cin >> n >> k;
  vi h(n);
  rep(i,n){
    cin >> h[i];
  }
  sort(all(h));
  ll ans = INF;
  for (ll i = 0; i + k-1 < n;i++){
    ll tmp = h[i + k - 1] - h[i];
    chmin(ans, tmp);
  }
  print(ans);
}

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

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

    int vals[n];
    for (int i=0; i<n; i++)
        cin >> vals[i];

    int dp[n] = {0};
    for (int i=1; i<n; i++){
        int mn = INT_MAX;
        
        for (int j=1; j<=k and i-j >= 0; j++){
            mn = min(mn, dp[i-j] + abs(vals[i] - vals[i-j]));
        }
        dp[i] = mn;
    }

    cout << dp[n-1] << "\n";
}


Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var NM = ReadLine().Split().Select(int.Parse).ToArray();
        var N = NM[0];
        var M = NM[1];
        var r = int.MaxValue;
        var l = 0;
        for (int i = 0; i < M; i++)
        {
            var LR = ReadLine().Split().Select(int.Parse).ToArray();
            l = Max(l, LR[0]);
            r = Min(r, LR[1]);
        }
        WriteLine(r - l + 1 > 0 ? r - l + 1 : 0);
    }
}


Measured memory_bytes: 17464
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main(void){
    cout<<fixed<<setprecision(12);
    
    double a,b,C,rC,S,L;
    
    cin>>a>>b>>C;
    rC=C*M_PI/180;
    
    S=(a*b*sin(rC))/2;
    L=a+b+sqrt(a*a+b*b-2*a*b*cos(rC));
    
    cout<<S<<endl;
    cout<<L<<endl;
    cout<<2*S/a<<endl;
    
}



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

int gcd(long long int a, long long int b) {
  long long int temp;
  if(a < b){
    temp = a;
    a=b;
    b=temp;
  }
  while (b) {
      temp = a%b;
      a = b;
      b = temp;
  }
  return a;
}

int main(){
  int N;
  long long int A[100000];
  long long int fromleft[100000];
  long long int fromright[100000];
  long long int now_gcd, max;
  cin >> N;
  now_gcd = 0;
  for(int i=0; i<N; i++){
      cin >> A[i];
      if(i==0){
          now_gcd = A[i];
      }
      else{
          now_gcd = gcd(now_gcd,A[i]);
      }
      fromleft[i] = now_gcd;
  }
  for(int i=0; i<N; i++){
      if(i==0){
          now_gcd = A[N-1-i];
      }else{
          now_gcd = gcd(A[N-1-i],now_gcd);
      }
      fromright[i] = now_gcd;
  }
  max = 1;
  for(int i=0; i<N ;i++){
      if(i == 0){
          now_gcd = fromright[N-1-1];
      }if(i == N-1){
          now_gcd = fromleft[N-1-1];
      }else{
          now_gcd = gcd(fromleft[i-1], fromright[N-1-1-i]);
      }
      if(max < now_gcd){
          max = now_gcd;
      }
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
typedef long long ll;
#define vstroku() to_string()
#define vchislo() to_ulong()
#define gcd(x,y) __builtin_gcd(x,y)
#define numberof1(x) __builtin_popcount(x)
#define povsemelementam(i,mnozh) for(auto i: mnozh)
#define podotrezok(i,j) substr(i-1,j) // like prefix sum, (i,j)=s[j]-s[i-1]
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back 
#define pii pair <int, int>
#define F first
#define S second
#define mipletsplay ios_base::sync_with_stdio(0); cin.tie(0); 


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 3e5;
const ll INF = 1e9;
const ll kek=998244353;

int main() {
mipletsplay;
string s;
cin>>s;
map <int,int> m;
vector <ll> a(200);
for (int i=0;i<4;i++)
{
a[s[i]]++;
}
bool ok=true;
int h;
for (int i=0;i<200;i++)
{
if (a[i]==0||a[i]==2)
h=1;
else
ok=false;


}
if (ok)
cout<<"Yes";
else
cout<<"No";

}

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

int main(){
    string s;
    cin >> s;
    string c="0",c2="1";
    int a=0,b=0;
    rep(i,s.size()){
        if(s[i]==c[0])b++;
        else a++;
        string tmp=c2;
        c2=c;
        c=tmp;
    }
    cout << min(a,b) << endl;
}

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

long long int N, K;

int main()
{
	cin >> N >> K;
	vector<int> A(N), C(N), Visited(N);

	int x;
	for (int i = 0; i < N; ++i)
	{
		cin >> x;
		A[i] = x - 1;
	}

	for (int i = 0; i < N; ++i)
	{
		C[i] = 0;
		Visited[i] = 0;
	}

	long long int K2 = K;
	long long int now, cnt, loop, r;
	now = cnt = 0;
	while (K2 > 0)
	{
		if (Visited[now] == 1)
		{
			r = C[now];
			loop = cnt - C[now];
			break;
		}
		else
		{
			Visited[now] += 1;
			C[now] = cnt;
		}
		now = A[now];
		++cnt;
		--K2;
	}

	if (K2 != 0)
	{
		K = (K - r) % loop;
		while (K > 0)
		{
			now = A[now];
			--K;
		}
	}
	cout << now + 1 << endl;
}


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
typedef long long lld;
#define PB push_back
#define FF first
#define SS second
 
const int INF = 2000000000;
const int N = 100000 + 10;
int arr[N];
 
class BIT{
	#define lowbit(x) ((x)&(-(x)))
	private:
		lld arr[N];
		int size;
	public:
		//1-base (l, r]
		void init(int n){
			size=n;
			//arr=new lld[n];
			fill(arr,arr+n,0);
		}
		void add(int l, int r, lld v){
			add(r, v);
			add(l, -v);
		}
		void add(int r, lld v){
			while(r){
				arr[r]+=v;
				r-=lowbit(r);
			}
		}
		lld query(int x){
			lld sm=0;
			while(x<size){
				sm+=arr[x];
				x+=lowbit(x);
			}
			return sm;
		}
	#undef lowbit
};
 
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n, m;cin>>n>>m;
	for(int i=0;i<n;i++) cin>>arr[i];
	lld sumL=0, sumR=0;
	for(int i=0;i<n-1;i++) sumL+=arr[i];
	for(int i=1;i<n;i++) sumR+=arr[i]+m*(arr[i-1]>arr[i]);
	BIT cnt, sm;
	cnt.init(m+5);sm.init(m+5);
	for(int i=1;i<n;i++){
		if(arr[i-1]>arr[i]){
			cnt.add(arr[i-1], m, 1);
			cnt.add(0, arr[i], 1);
			sm.add(arr[i-1], m, arr[i-1]);
			sm.add(0, arr[i], arr[i-1]-m);
		}else{
			cnt.add(arr[i-1], arr[i], 1);
			sm.add(arr[i-1], arr[i], arr[i-1]);
		}
	}
	lld val=sumR-sumL;
	for(int i=1;i<=m;i++){
		lld curV=sumR-sumL-cnt.query(i)*(i-1)+sm.query(i);
		if(curV < val) val=curV;
	}
	cout<<val<<'\n';
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mxn=2e5+3,du=1e9+7;
int n;
int a[mxn];
int sum[mxn];
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i];
    for (int i=n;i>=1;i--)
    {
        sum[i]=sum[i+1]+a[i];
        sum[i]%=du;
    }
    int ans=0;
    for (int i=1;i<=n;i++)
    {
        ans+=(a[i]*sum[i+1])%du;
        ans%=du;
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 6612
N=int(input())
l1=[[] for i in range(N)]
for i in range(N):
    l=list(map(int,input().split()))
    for j in range(len(l)):
        l1[i].append(l[j])
l2=[[] for i in range(N)]
for j in l1[0]:
    l2[0].append(j)
for j in range(1,N):
    l2[j].append(l1[j][0]+max(l2[j-1][1],l2[j-1][2]))
    l2[j].append(l1[j][1]+max(l2[j-1][0],l2[j-1][2]))
    l2[j].append(l1[j][2]+max(l2[j-1][0],l2[j-1][1]))
#print(l2)
print(max(l2[N-1][0],l2[N-1][1],l2[N-1][2]))


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

struct Card {
  char suit;
  char value;
};
void bubble(struct Card A[],int N) {
  for (int i=0; i<N; i++) {
    for (int j=N-1; j>=i+1; j--) {
      if (A[j].value<A[j-1].value) {
        Card t=A[j];
        A[j]=A[j-1];
        A[j-1]=t;
      }
    }
  }
}
void selection(struct Card A[],int N) {
  for (int i=0; i<N; i++) {
    int minj=i;
    for (int j=i; j<N; j++) {
      if (A[j].value<A[minj].value) {
        minj=j;
      }
    }
    Card t=A[i];
    A[i]=A[minj];
    A[minj]=t;
  }
}
void print(struct Card A[],int N) {
  for (int i=0; i<N; i++) {
    cout << (i==0?"":" ") << A[i].suit << A[i].value << flush;
  }
  cout << endl;
}
bool isStable(struct Card C1[],struct Card C2[],int N) {
  for (int i=0; i<N; i++) {
    if (C1[i].suit!=C2[i].suit) {
      return false;
    }
  }
  return true;
}
int main() {
  int N;
  cin >> N;
  Card C1[N], C2[N];
  for (int i=0; i<N; i++) {
    cin >> C1[i].suit >> C1[i].value;
    C2[i]=C1[i];
  }
  bubble(C1,N);
  selection(C2,N);
  print(C1,N);
  cout << "Stable" << endl;
  print(C2,N);
  if (isStable(C1,C2,N)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
  return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll ans,x,a[15],n;
void dfs(int p,ll s)
{
	if(p==n+1) {ans+=s;return;}
	ll t=0;
	for(int i=p;i<=n;i++)
	    t=t*10+a[i],dfs(i+1,s+t);
}
int main(){
	cin>>x;
	while(x>0) a[++n]=x%10,x/=10;
	reverse(a+1,a+n+1);
	dfs(1,0);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	long long int r, d, x;
	cin >> r >> d >> x;
	for (int i = 1; i <= 10; i++)
	{
		x = r * x - d;
		cout << x << endl;
	}


}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double t0 = 2*PI*h/12 + PI/6*m/60, t1 = 2*PI*m/60;
    double x0 = a * cos(t0), y0 = a * sin(t0), x1 = b * cos(t1), y1 = b * sin(t1);
    cout << sqrt((x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1)) << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 4116
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;
ll GCD(ll x, ll y) {if (x % y == 0) return y;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x * y / GCD(x, y);}

int main(){
 ll n,M=0,ans=0; cin>>n;
  rep(i,n){
  ll t; cin>>t;
    M=max(M,t);
    ans+=t;
  }
  cout<<ans-M/2<<endl;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int n; cin >> n; bool four = false;
    rep(i, n){
        char c; cin >> c;
        if(c == 'Y') four = true;
    }
    if(four) out("Four"); else out("Three");
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL ex_gcd(LL a, LL b, LL & x, LL & y) {
	LL d = a;
	if(b != 0) {
		d = ex_gcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else { x = 1; y = 0; }
	return d;
}
LL divmod(LL x, LL y, LL MOD) {
	LL inv, m;
	ex_gcd(y, MOD, inv, m);
	if(inv < 0) { inv += MOD; }
	return x * inv % MOD;
}

// ----

LL n, a[100001], b[100001], v, MOD = 1e9 + 7;

LL   memo[2][100002];
bool flag[2][100002];
LL comb(LL x, LL y) {
	if(! inII(y, 0, x)) { return 0; }
	
	LL z = (x == n - 1);
	if(flag[z][y]) { return memo[z][y]; }
	flag[z][y] = true;
	
	if(y == 0) { return memo[z][y] = 1; }
	LL r = divmod(comb(x, y - 1) * (x - (y - 1)) % MOD, y, MOD);
	return memo[z][y] = r;
}

int main() {
	cin >> n;
	inc(i, n + 1) { cin >> a[i]; }
	
	inc(i, n + 1) { b[i] = -1; }
	inc(i, n + 1) {
		if(b[ a[i] ] != -1) {
			v = n + 1 - (abs(b[ a[i] ] - i) + 1);
			break;
		}
		b[ a[i] ] = i;
	}
	
	inc1(k, n + 1) {
		LL ans = (comb(n - 1, k) + comb(n - 1, k - 2) + 2 * comb(n - 1, k - 1) + (MOD - comb(v, k - 1))) % MOD;
		cout << ans << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 3712
N = int(input())
A = sorted(list(map(int, input().split())))
 
# 最大公約数を求める関数
def gcd(a,b):
    rem = a % b
    while rem != 0:
        a = b
        b = rem
        rem = a % b
    return b
 
cand = A[0]
 
for i in range(1,N):
    cand = gcd(cand, A[i])
 
    if cand == 1:
        break
 
print(cand)

Measured memory_bytes: 14224
#include "stdio.h"
#include <vector>
using namespace std;

vector<int> gra[100010];
int v[100020];

int DFS(int s) {
       v[s] = 1;
       for (int i = 0; i < gra[s].size(); i++) {
              if (v[gra[s][i]] == 0)
                 DFS(gra[s][i]);
       }
       return 0;
}

int main() {
       int N, M;
       scanf("%d%d", &N, &M);
       for (int i = 1; i <= N; i++) {
           v[i] = 0;
       }
       int v1, v2;
       for (int i = 0; i < M; i++) {
                scanf("%d%d", &v1, &v2);
                gra[v1].push_back(v2);
                gra[v2].push_back(v1);
       }
       int res = 0;
       for (int i = 1; i <= N; i++)
               if (v[i] == 0) {
                     DFS(i);
                     res++;
                }  
       printf("%d", res - 1); 
}

Measured memory_bytes: 9584
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////

int n;
li tab[1000005];

///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

void dfs(int cur, int v, int p, int d[]){
	d[v] = cur;
	list<int>::iterator it;
	for(it = tab[v].begin(); it != tab[v].end(); it++){
		if(*it == p) continue;
		dfs(cur+1, *it, v, d);
	}
}

/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	int u, v;
	list<int>::iterator it;
	
	cin >> n >> u >> v;
	for(int i = 0; i < (n-1); i++){
		int v1, v2;
		cin >> v1 >> v2;
		tab[v1].pb(v2);
		tab[v2].pb(v1);
	}
	
	int du[1000005];
	int dv[1000005];
	dfs(0, u, -1, du);
	dfs(0, v, -1, dv);
	
	int ans = 0;
	for(int i = 1; i <= n+1; i++){
		if(du[i] < dv[i]) ans = max(ans, dv[i]-1);
	}
	cout << ans;
	
	
	return 0;
}


Measured memory_bytes: 30208