akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
using Graph = vector<vector<int> >;
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; }
//#define int long long

//bitを見てもok
//構築は2の塁乗多い？（二部グラフだからか）
//奇閉路無し　は　2部グラフ

//二部グラフで、分割統治（再帰利用で実装）

int n;
vector<vector<int>> res;

void rec(int left, int right, int v) {
    //半開区間　[l, r) の利用
    if(right - left <= 1) return;

    int mid = (left + right) / 2;
    rec(left, mid, v + 1);
    rec(mid, right, v + 1);

    for(int i = left; i < mid; i++) {
        for(int j = mid; j < right; j++) {
            res[i][j] = v;
        }
    }
}

void solve() {
    cin >> n;
	res.assign(n, vector<int>(n, 1));
    rec(0, n, 1);

    rep(i, n) {
        for(int j = i + 1; j < n; j++) {
            cout << res[i][j] << " ";
        }
        cout << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 1536
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    string s;
    cin >> s;
    int zero_c = 0;
    int one_c = 0;
    REP(i, s.size()) {
        if (s[i] == '0') {
            zero_c++;
        } else {
            one_c++;
        }
    }
    cout << min(zero_c, one_c) * 2 << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n, k;
	cin >> n >> k;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int h;
		cin >> h;
		if (h >= k) ++ans;
	}
	cout << ans;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
int N;
int main() {
	scanf("%d", &N);
	vector<int> h(N);
	vector<int> dp(N, 2147483647);
	rep(i, 0, N)scanf("%d", &h[i]);
	dp[0] = 0;
	rep(i, 0, N - 1) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		if(i != N - 2)dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
	}
	printf("%d", dp[N - 1]);
	return 0;
}

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

int main(){
    int a, b, c;
    int tmp;

    cin >> a >> b >> c;

    tmp = a;
    a = b;
    b = tmp;

    tmp = a;
    a = c;
    c = tmp;

    cout << a << " "<< b << " " << c << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  ll A, B; cin >> A >> B;
  ll ans = ((B-A)/2)%2;
  if (A%2) ans ^= A;
  if (B%2==0) ans ^= B; 
  if (A%2==0 && B%2==1) ans^=1;

  cout << ans << endl;

  




  // cout << fixed << setprecision(10);
  
  return 0;
}


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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;

int n, m;
map<int, int> mp;

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

  cin >> n >> m;
  int sum = 0;
  int ans = 0;
  rep(i, 0, n) {
    int A;
    cin >> A;
    sum += A;
    int b = sum % m;
    if (mp[b] == 0) {
      mp[b] = 1;
    } else {
      mp[b]++;
    }
    if (b == 0) ans++;
  }

  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    int c = itr->second;
    ans += c * (c - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
int n, a, b, inv[200005];
const int M = 1000000007;
int poww(int a, int b){
    int res = 1;
    while (b > 0){
        if (b & 1) res = 1ll * res * a % M;
        a = 1ll * a * a % M, b >>= 1;
    }
    return res;
}
void init(){
    n = read(), a = read(), b = read();
}
void solve(){
    inv[1] = 1;
    int ans = poww(2, n);
    ans = (ans + M - 1) % M;
    for (int i = 2; i <= b; ++i){
        inv[i] = 1ll * (M - M / i) * inv[M % i] % M;
    }
    int cc1 = 1, cc2 = 1;
    for (int i = 1; i <= a; ++i)
        cc1 = 1ll * cc1 * (n - i + 1) % M, 
        cc1 = 1ll * cc1 * inv[i] % M;
    for (int i = 1; i <= b; ++i)
        cc2 = 1ll * cc2 * (n - i + 1) % M, 
        cc2 = 1ll * cc2 * inv[i] % M;
    ans = (ans + M - cc1) % M;
    ans = (ans + M - cc2) % M;
    printf("%d\n", ans);
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

void printVector(const vector<ll>& vec) {
    for (ll value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

int main()
{
    string S, T;
    cin >> S >> T;

    int ss = S.size(), ts=T.size();

    int on, onj=0;

    rep(i, ss - ts + 1) {
        on = 0;
        rep(j, ts) {
            if (S[i + j] == T[j]) ++on;
        }
        onj = max(on, onj);
    }

    cout << ts - onj << endl;

}

Measured memory_bytes: 3620
#include <stdio.h>

#define N (4)

int main(void)
{
  char s[N];
  int i,j;
  int k[2]={0,0};

  scanf("%4s",s);

  for(i=1;i<N;i++)
  {
    if(s[0]==s[i])
    {
      k[0]=k[0]+1;
    }
  }
  if(s[0]==s[1])
  {
    if(s[2]==s[3])
    {
      k[1]=k[1]+1;
    }
  }
  else
  {
    for(i=2;i<N;i++)
    {
      if(s[1]==s[i])
      {
        k[1]=k[1]+1;
      }
    }
  }

  if(k[0]==1 && k[1]==1)
  {
    printf("Yes");
  }
  else
  {
    printf("No");
  }

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N, a[101];
    cin >> N;
    for(int i = 0; i < N; i++)cin >> a[i];

    int num[110] = {0};
    for(int i = 0; i < N; i++){
        num[a[i]]++;
    }

    int ans = 0;
    for(int i = 0; i <= 100; i++){
        if(num[i]){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define loop(i,n) rep(i,0,n)
using namespace std;
using ll = long long;
using weighted_graph = vector<vector<pair<int,double>>>;
using unweighted_graph = vector<vector<int>>;
vector<double> dijkstra(const weighted_graph &g,const int e){
    using node=pair<int,double>; auto cmp=[](node &a,node &b)->bool {return (a.second>b.second);};
    priority_queue<node,vector<node>,decltype(cmp)> pq(cmp);
    vector<double> w(g.size(),numeric_limits<double>::max());
    pq.push({e,0}); w[e]=0;
    while(!pq.empty()){ auto u=pq.top(); pq.pop();
        for(auto &v:g[u.first])if(w[u.first]+v.second<w[v.first]){ w[v.first]=w[u.first]+v.second; pq.push({v.first,w[v.first]}); }}
    return w;
}
int main(){
    double xs,ys,xt,yt;
    int n;
    cin >> xs >> ys >> xt >> yt >> n;
    vector<double> x(n+2),y(n+2),r(n+2);
    x[0]=xs;
    y[0]=ys;
    x[1]=xt;
    y[1]=yt;
    rep(i,2,n+2){
        cin >> x[i] >> y[i] >> r[i];
    }
    weighted_graph g(n+2);
    auto dist = [&](double xi,double yi,double xj,double yj)->double{
        return sqrt((xi-xj)*(xi-xj)+(yi-yj)*(yi-yj));};
    loop(i,n+1)rep(j,i+1,n+2){
        double d=max(0.0,dist(x[i],y[i],x[j],y[j])-r[i]-r[j]);
        g[i].push_back({j,d});
        g[j].push_back({i,d});
    }
    auto ans=dijkstra(g,0);
    cout << setprecision(10) << ans[1] << endl;
    return 0;
}

Measured memory_bytes: 22640
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner (System.in)){
			while (true) {
				int a = sc.nextInt();
				int b = sc.nextInt();

				if ((a == 0) && (b == 0)) break;

				System.out.println(Math.min(a, b) + " " + Math.max(a, b));
			}
		}
	}
}


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

#define fs first
#define sc second

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v ) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

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

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int k = 0, m = i;
        while (m > 0) {
            m /= 10;
            ++k;
        }
        if (k & 1) {
            ++ans;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib> 
#include <cmath>
using namespace std;
int main(void)
{
    int A, B,C,D;
    cin >> A >> B >> C >> D;
    string ans;
    if (abs(A -C)<= D){
        ans = "Yes";
    }
    else if ( abs(A-B)<=D && abs(B-C)<=D){
        ans = "Yes";
    }

    else{
        ans = "No";
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    string S;
    io.read(S);
    vector<int> v(26, 0);
    for(int i = 0; i < S.size(); i++){
        v[S[i] - 'a']++;
    }
    int k;
    for(k = 0; k < 26 && v[k] > 0; k++);
    if(k >= 26) cout << "None";
    else cout << (char)(k + 'a');
    return 0;
}

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

#define MOD 1000000007
#define ll long long int
#define vi vector<ll>
#define vii vector< vector<ll> >
#define PI 3.1415926535897932384626433832795

ll a,b,c,d,e,f;

ll currinside = 0;
ll currsug = 0;
long double bestdens = 0;
ll bestsug = 0;
ll bestwat = 100;

long double min(long double d, long double e) {
	if(d < e) {
		return d;
	}
	return e;
}

long double max(long double d, long double e) {
	if(d > e) {
		return d;
	}
	return e;
}

bool was[5001][5001];
bool was2[5001];

void checkwithwater() {
	//cout << currsug << " " << currinside << "\n" << flush;
	if(currsug+currinside > f) {
		return;
	}
	if(was[currinside][currsug]) {
		return;
	}
	was[currinside][currsug] = true;
	if(currinside/100*e < currsug) {
		return;
	}
	//cout << currsug << " " << currinside << " " << best << "\n";
	if(currsug/((long double) (currinside+currsug)) > bestdens-0.0000000001) {
		bestsug = currsug;
		bestwat = currinside;
		bestdens = currsug/((long double) (currinside+currsug));
	}
	currsug+= c;
	checkwithwater();
	currsug-= c;
	currsug+= d;
	checkwithwater();
	currsug-= d;
}


void check() {
	if(currinside > f) {
		return;
	}
	if(was2[currinside]) {
		return;
	}
	was2[currinside] = true;
	checkwithwater();
	currinside+= 100*a;
	check();
	currinside-= 100*a;
	currinside+= 100*b;
	check();
	currinside-= 100*b;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b >> c >> d >> e >> f;
	memset(was,false,sizeof(was));
	memset(was2,false,sizeof(was2));
	check();
	cout << bestwat+bestsug << " " << bestsug;// << " " << check();
	return 0;
}



Measured memory_bytes: 24704
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(20)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	int n;
	cin >> n;
	vi v(n);
	rep(i, 0, n - 1) cin >> v[i];
	int ans = v[0];
	rep(i, 1, n - 1) ans ^= v[i];
	rep(i, 0, n - 1) {
		int a = ans ^ (v[i]);
		cout << a << " ";
	}
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// test
	solve();

	return 0;
}

Measured memory_bytes: 4712
import java.util.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
//    static final long mod=1000000007;
    static int dx[]={-1,0,1,0};
    static int dy[]={0,-1,0,1};
    static long pl,mi;

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        int a[]=sc.nextIntArray(n);
        int b[]=sc.nextIntArray(n);
        ArrayList<Integer> p=new ArrayList<Integer>();
        long m=0;
        int ans=0;
        for (int i = 0; i < a.length; i++) {
			int d = a[i]-b[i];
			if(d<0) {ans++;m+=d;}
			if(d>0)p.add(d);
		}
        sort(p);
        while(!p.isEmpty() && m<0) {
        	ans++;
        	m+=p.get(p.size()-1);
        	p.remove(p.size()-1);
        }
	  
	     
        out.println(m>=0?ans:"-1");
        out.flush();
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//    public int compareTo(P p){
//        return d-p.d; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 47520
n,m,x,y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

for z in range(x + 1, y + 1):
    if all(i < z for i in a) and all(i >= z for i in b):
        print('No War')
        exit()
print('War')


Measured memory_bytes: 39024
import collections as cl
N = int(input())
S = input()
a,b = '',''
d = cl.Counter(S)
rgb = d['R']*d['B']*d['G']
expt = 0
for i in range(N):
  a = S[i]
  for j in range(i,(N+i-1)//2+1):
    if S[j] != a:
      b = S[j]
      k = 2*j-i
      if S[k]!=b and S[k]!=a:
        expt += 1
print(rgb-expt)

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  for(int i=0; i<m; i++)
    cin >> p.at(i) >> s.at(i);
  
  vector<int> ac(n);
  for(int i=0; i<m; i++) {
    if(s.at(i) == "AC") {
      ac.at(p.at(i)-1) = 1;
    }
  }
  
  vector<int> flags(n);
  int cor = 0;
  int wro = 0;
  for(int i=0; i<m; i++) {
    if(ac.at(p.at(i)-1) == 0) {
    }
    else {
      if(flags.at(p.at(i)-1) == 0) {
        if(s.at(i) == "WA") {
          wro++;
        }
        else {
          cor++;
          flags.at(p.at(i)-1)++;
        }
      }
    }
  }
  
  cout << cor << " " << wro << endl;
}

Measured memory_bytes: 6912
n, x, m = map(int, input().split())

lst = set()
num = []
for i in range(1, n + 1):
    lst.add(x), num.append(x)
    x = x ** 2 % m
    if x in lst:
        cnt, idx = i, num.index(x)
        div, mod = divmod(n - cnt, len(num) - idx)
        ans = sum(num[:idx + mod])
        ans += sum(num[idx:]) * (div + 1)
        break
else:
    ans = sum(num)
print(ans)


Measured memory_bytes: 77308
#include <bits/stdc++.h>
using namespace std;
int N;
long long T;
long long dp[200100][31] = {};
long long a[200100], b[200100];
long long const INF = 1001001001001;

int main() {
    cin >> N >> T;
    for(int i=0; i<N; ++i) cin >> a[i] >> b[i];
    
    vector<int> order(N);
    iota(begin(order), end(order), 0);
    sort(begin(order), end(order), [](int i, int j){return a[i] * (b[j] + 1) > a[j] * (b[i] + 1);});

    int nmax = 0;
    for(int i=0; i<N; ++i) if(a[order[i]] > 0) nmax = i + 1;
    
    for(int j=1; j<=30; ++j) dp[0][j] = INF;
    for(int i=0; i<nmax; ++i) {
        dp[i + 1][0] = 0;
        for(int j=1; j<=30; ++j) {
            dp[i + 1][j] = dp[i][j];
            if(dp[i][j - 1] != INF) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - 1] + 1 + a[order[i]] * (dp[i][j - 1] + 1) + b[order[i]]);
        }
    }

    vector<long long> B(N - nmax);
    for(int i=0; i<N-nmax; ++i) B[i] = b[order[nmax + i]];
    sort(begin(B), end(B));

    int res = 0;
    for(int j=0; j<=30; ++j) {
        if(dp[nmax][j] > T) break;
        int cnt = j;
        long long t = dp[nmax][j];
        for(long long tmp : B) {
            if(t + 1 + tmp <= T) {
                t += 1 + tmp;
                ++cnt;
            }
        }
        res = max(res, cnt);
    }
    
    cout << res << '\n';
}

Measured memory_bytes: 52608
#include<bits/stdc++.h>
using namespace std;
#define INS(x) x.begin(),x.end()
    

    
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    long long h,w;
    cin>>h>>w;

    if (h==1||w==1) {cout<<1<<'\n'; return 0;}
    long long a=ceil(1.0*w/2),b;
    if (w%2) b=a-1;
    else b=a;

    long long base=h/2;
    if (h%2) cout<<base*(a+b)+a;
    else cout<<base*(a+b);
    return 0;
}

Measured memory_bytes: 256
//C - Exception Handling
//20190912

using System;
using System.Linq;
using System.Collections.Generic;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var A = new int[N];

            for(int i=0;i<N;i++)
            {
                A[i] = int.Parse(Console.ReadLine());
            }

            var ACopy = A.OrderBy(a => -a).ToList();
            
            for(int i=0;i<N;i++)
            {
                if(A[i] == ACopy[0]) Console.WriteLine(ACopy[1]);
                else Console.WriteLine(ACopy[0]);   
            }
        }
    }
}


Measured memory_bytes: 21588
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        StringBuffer sb = new StringBuffer(s);
        if(s.length() == 2){
            System.out.println(s);
        }else{
            System.out.println(sb.reverse());
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
//#include <math.h>
#include <cmath>
#include <numeric>
using namespace std;

int main(){
  int N;
  cin>>N;
  vector<int> la(N);//大きさも指定しないといけない
  int a;
  for (int i=0;i<N;i++){
    cin>>a;
    la.at(i)=a;
  }
  int minm=accumulate(la.begin(),la.end(),0)/N;//numericが必要
  int maxm=(accumulate(la.begin(),la.end(),0)+N-1)/N;
  long int ans1=0,ans2=0;//この書き方おk
  for (int i =0;i<N;i++){
    ans1+=pow(la.at(i)-minm,2);//cmathが必要
  }
  for (int i =0;i<N;i++){
    ans2+=pow(la.at(i)-maxm,2);
  }
  cout<<min(ans1,ans2)<<endl;
}


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

int Cmp(const void *a, const void *b){
  return *(int *)a - *(int *)b;
}

int Max(int N, int x){
  int i, S;
  int a[N];
  S = 0;
  for(i = 0;i < N;i++) scanf("%d", &a[i]);
  qsort(a, N, sizeof(int), Cmp);
  i = 0;
  while(i < N){
    if(S + a[i] <= x){
      S += a[i];
      i++;
    }else break;
  }
  if(S > x || (i == N && S < x)) i--;
  return i;
}

int main(void){
  int N, x;
  scanf("%d %d", &N, &x);
  printf("%d\n", Max(N, x));
  return 0;
}

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

vector<int> z_algorithm(string s) {
	vector<int> res(s.size());
	
	res[0] = s.size();
	
	int i = 1, j = 0;
	
	while (i < s.size()) {
		while (i + j < s.size() && s[j] == s[i + j]) j++;
		res[i] = j;
		if (j == 0) { i++; continue; }
		int k = 1;
		while (i + k < s.size() && k + res[k] < j) res[i + k] = res[k], k++;
		i += k;
		j -= k;
	}
	
	return res;
}

string w;
bool cut[512345], rcut[512345];
vector<int> z, rz;

int main() {
	string w; cin >> w;
	int N = w.size();
	
	z = z_algorithm(w);
	fill(cut, cut + N + 1, true);
	FOR(i, 1, N) {
		if (!cut[i]) continue;
		for (int j = i; j <= z[i]; j += i) cut[j + i] = false;
	}
	
	reverse(ALL(w));
	
	rz = z_algorithm(w);
	fill(rcut, rcut + N + 1, true);
	FOR(i, 1, N) {
		if (!rcut[i]) continue;
		for (int j = i; j <= rz[i]; j += i) rcut[j + i] = false;
	}
	
	int cnt = 0;
	FOR(i, 1, N) if (cut[i] && rcut[N - i]) cnt++;
	
	bool same = count(ALL(w), w[0]) == N;
	bool good = cut[N];
		
	int a, b;
	if (same) a = N, b = 1;
	else if (good) a = 1, b = 1;
	else a = 2, b = cnt;
	
	printf("%d\n%d\n", a, b);
	
	return 0;
}


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

using namespace std;
const int N=3e5+5;
int a[N],b[N],c[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int X,Y,A,B,C;
    cin>>X>>Y>>A>>B>>C;
    for(int i=0;i<A;i++)
        cin>>a[i];
    for(int i=0;i<B;i++)
        cin>>b[i];
    for(int i=0;i<C;i++)
        cin>>c[i];
    sort(a,a+A);reverse(a,a+A);
    sort(b,b+B);reverse(b,b+B);
    sort(c,c+C);reverse(c,c+C);
    priority_queue< int , vector<int> , greater<int> >pq;
    long long ans=0;
    for(int i=0;i<X;i++)
    {
        ans+=a[i];
        pq.push(a[i]);
    }
    for(int i=0;i<Y;i++)
    {
        ans+=b[i];
        pq.push(b[i]);
    }
    for(int i=0;i<C;i++)
    {
        if(pq.empty()) break;
        int t=pq.top();
        pq.pop();
        if(t>=c[i]) break;
        ans+=c[i]-t;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2552
#include "bits/stdc++.h"
using namespace std;

int64_t z(int64_t p)
{
  if(p>=0)
    return p;
  else
    return p*-1;
}

int main()
{
  int64_t x,k,d,di,ans,a;
  cin>>x>>k>>d;
  di=z(x)/d;
  if(di>=k)
    ans=z(x)-k*d;
  else
  {
    if(x>0)
    {
      a=x-di*d;
      if((k-di)%2==0)
        ans=a;
      else
        ans=d-a;
    }
    else if(x<0)
    {
      a=x+di*d;
      if((k-di)%2==0)
        ans=a*-1;
      else
        ans=a+d;
    }
    else
    {
      if(k%2==0)
        ans=0;
      else
        ans=d;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int W[N];
  int sumr = 0;
  int suml = 0;
  int div = 100000;
  for(int i=0;i<N;i++){
    cin >> W[i];
    sumr += W[i];
  }
  for(int j=0;j<N;j++){
    if(abs(sumr-suml)<div){
      div = abs(sumr-suml);
    }
    suml += W[j];
    sumr -= W[j];
  }
  cout << div << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int z(int a){
  if(a<1)a*=-1;
  return a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
ll c[100000];
int main(void){
  int n;
  scanf("%d",&n);
  int a,sum=0;
  FOR(n){
    scanf("%d",&a);
    sum+=a-1;
  }
  PRN(sum);
  return 0;
}


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

using namespace std;

int main(){
	int k,a,b;
	cin>>k>>a>>b;
	string ans="NG";

	for(int i=a;i<=b;i++) if(i%k==0) ans="OK";

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include<vector>
#include <queue>
#include <string>
using namespace std;
int h[100005] = {0};
int main()
{
	string n;
     cin >> n ; 
	 if (n == "abc" || n == "acb" || n == "bac" || n == "bca" || n == "cab" || n == "cba")cout << "Yes" << endl;
	 else cout << "No" << endl;
}

Measured memory_bytes: 256
// tap dance
#include <iostream>
#include <string>
using namespace std;

int main() {
    string tap;
    string odd = "RUD";
    string even = "LUD";
    cin >> tap;

    for (int i = 0; i < (int)tap.size(); i++) {
        char ch = tap[i];
        if (i % 2) {
            if (even.find(ch) == string::npos) {
                cout << "No\n";
                //cout << ch << " even" << endl;
                return 0;
           }
        } else {
            if (odd.find(ch) == string::npos) {
                cout << "No\n";
                //cout << ch << " odd" << endl;
                return 0;
            }
        }
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;
using VLL = vector<ll>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;

const int MOD = 1000000007;
const int INF = 1000000000;

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




int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << ((a+b+c > 21) ? "bust\n" : "win\n");
    return 0;
}


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

int main(){
    long long int x, y;
    scanf("%lld %lld", &x, &y);

    long long int ans = 0;
    while(x <= y){
        ans++;
        x *= 2;
    }
    printf("%lld\n", ans);

    return 0;
}

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

int main() {
    int N;
    int dif = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        int l, r;
        cin >> l >> r;
        dif += r - l + 1;
    }
    cout << dif << endl;
}

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

int main(){
    int N;
    while(cin>>N,N){
        vector<string> S(N);
        for(auto &s:S) cin>>s;
        int G[26][26];
        fill(G[0],G[26],0);
        bool flag=true;
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                string s1=S[i], s2=S[j];
                if(s1==s2) continue;
                int ite=0;
                while(ite<min(s1.size(),s2.size())&&s1[ite]==s2[ite]) ite++;
                if(ite==s1.size()) continue;
                if(ite==s2.size()){
                    flag=false;
                    continue;
                }
                G[s1[ite]-'a'][s2[ite]-'a']=1;
            }
        }
        for(int k=0;k<26;k++){
            for(int i=0;i<26;i++){
                for(int j=0;j<26;j++){
                    G[i][j]|=G[i][k]&G[k][j];
                }
            }
        }
        for(int i=0;i<26;i++){
            if(G[i][i]) flag=false;
        }
        cout<<(flag?"yes":"no")<<endl;
    }

    return 0;
}


Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    string s;
    cin >> s;
    int k;
    cin >> k;

    vector<string> sub;
    for(int i=0;i<s.length();i++){
        for(int j=1;j<=k;j++){
            sub.push_back(s.substr(i,j));
        }
    }
    sort(sub.begin(),sub.end());
    std::unique(sub.begin(),sub.end());

    cout << sub[k-1] << endl;
    return 0;
}



Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	int curri=0,currv=0,i;
	
	while(curri<n)
	{
		for( i=curri;i<n;i++)
		{
			if(a[i]==currv+1)
			{
				curri=i;
				currv++;
				break;
			}
		}
		if(i==n) break;
	}
	if(currv==0) cout<<"-1";
	else cout<<n-currv;
	return 0;
	
}

Measured memory_bytes: 1024
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        //static int N;
        //static long mod = 1000000007;
        //static char[] az = Enumerable.Range('a', 'z' - 'a' + 1).Select(i => (Char)i).ToArray();
        static void Main(string[] args)
        {
            //var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var N = long.Parse(Console.ReadLine());
            Console.WriteLine(cul(N));

        }

        static long cul(long N)
        {
            long ans = 0;
            for (long i = 1; i <= (long)Sqrt(N); i++)
            {
                if(N%i == 0)
                {
                    var tmp = (N - i) / i;
                    if (tmp > i)
                    {
                        ans += tmp;
                    }
                }
                
            }

            return ans;
        }
    }
}


Measured memory_bytes: 27496
#include <iostream>

using namespace std;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
   long int k;
   cin>>k;
   long int sum=0;
   for(long int i=1;i<=k;i++){
       for(long int j=1;j<=k;j++){
           for(long int t=1;t<=k;t++){
               sum+=gcd(gcd(i,j),t);
           }
       }
   }
    cout<<sum<<endl;
}

Measured memory_bytes: 3580
#include <stdio.h>
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
const int mod = 998244353;
const int maxn = 4020;
long long fat[maxn], ifat[maxn], pw[maxn];
long long xp(long long a, long long b){
	long long r = 1;
	for(; b; b >>= 1, a = (a * a) % mod) if(b&1) r = (r * a) % mod;
	return r;
}
long long comb(int x, int y){
	if(x < 0 || y < 0) return 0;
	if(x < y) return 0;
	return (fat[x] * ifat[y] % mod) * ifat[x - y] % mod;
}
int u[maxn], s[maxn];
void init(){
	for(int e = 0;e  < maxn; e++) u[e] = e, s[e] = 1;
}
int find(int x){
	if(x == u[x]) return x;
	return u[x] = find(u[x]);
}
void join(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y){

	} else {
		u[x] = y;
		s[y] += s[x];
		s[x] = 0;
	}
}
int n, k;
int main(){
	fat[0] = 1;
	for(int e = 1; e < maxn; e++) fat[e] = e * fat[e-1] % mod;
	for(int e = 0; e < maxn; e++) ifat[e] = xp(fat[e], mod - 2);
	pw[0] = 1;
	for(int e = 1; e < maxn; e++) pw[e] = 2 * pw[e-1] % mod;
	cin >> k >> n;
	for(int e = 2; e <= 2*k; e++){
		init();
		for(int f = 1; f <= k; f++){
			int r = e - f;
			if(r >= 1 && r <= k){
				join(f, r);
			}
		}
		int c0 = 0, c1 = 0, c2 = 0;
		for(int f = 1; f <= k; f++){
			if(find(f) == f){
				if(s[f] == 1) c1++;
				else c2++;
			}
		}
		if(e%2 == 0) c1--, c0++;
		long long ans = 0;
		for(int f = 0; f <= c2; f++){
			ans += comb(n + c1 - 1, f + c1 - 1) * comb(c2, f) % mod * pw[f] % mod;
			if(ans >= mod) ans -= mod;
			if(c0){
				ans += comb(n + c1 - 2, f + c1 - 1) * comb(c2, f) % mod * pw[f] % mod;
				if(ans >= mod) ans -= mod;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import math
from decimal import Decimal
# 入力
a,b,h,m = map(int,input().split())

tri_m = Decimal(360 / 60 * m )

tri_h = Decimal((360 / 12 * h) + (360 / 12 / 60 * m))

# print("tri_m:{},tri_h:{}".format(tri_m,tri_h))
angle = tri_m - tri_h
# if angle > 180:
#   angle -= 180

# print("angle:{}".format(angle))

ans = round(Decimal(math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(math.radians(angle)))),9)

print(str(ans))


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

using namespace std;

int main()
{
   int n,k;
   map<int,int> a;
   int i,j;
   cin>>n>>k;
   for(i=0;i<n;i++){
    cin>>j;
    a[j]++;
   }
   multiset<int> vv;
   for(map<int,int>::iterator t=a.begin();t!=a.end();t++){
    vv.insert(t->second);
   }
   int ans=0;
   while(vv.size()>k){
    ans+=*(vv.begin());
    vv.erase(vv.begin());
   }
   cout<<ans;
}


Measured memory_bytes: 18944
fun main(args: Array<String>) {
    val (x, y, z) = readLine()!!.split(" ").map { it.toInt() }
    var a = 0
    var s = mutableListOf<Int>()
    var t = ""
    for (i in 0..x) {
        t = i.toString()
        s = mutableListOf<Int>()
        while(t.count() > 0){
            s.add(t[0].toInt() - 48)
            t = t.substring(1 until t.count())
        }
        if(s.sum() in (y..z)){
            a += i
        }
    }
    println(a)
}

Measured memory_bytes: 40368
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll a,b,c,d,e,i,j,k,l,n,m,x,y,t,p;
    cin>>x;
    if(x==0)
    {
        cout<<1<<endl;
    }
    else
    {
        cout<<0<<endl;
    }
}


Measured memory_bytes: 3628
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] h = new int[n];
    for(int i = 0;i<n;i++){
      h[i] = sc.nextInt();
    }
    Arrays.sort(h);
    int min = 1000000008;
    for(int i = 0;i<n-k+1;i++){
      min = Math.min(min,h[i+k-1]-h[i]);
    }
    System.out.println(min);
  }
}


Measured memory_bytes: 59616
#include<bits/stdc++.h>
using namespace std;
int l,f[2222222],nt[2222222],to[2222222],path[2222222];
char c[2222222];
int main()
{
	scanf("%s",c+1);
	l=strlen(c+1);
	for(int i=0;i<26;i++)
	{
		nt[i]=l+1;
	}
	for(int i=1;i<=l;i++)
	{
		f[i]=1e9;
	}
	f[l+1]=1e9;
	f[l+2]=0;
	for(int i=l;i>0;i--)
	{
		nt[c[i]-'a']=i;
		for(int j=0;j<26;j++)
		{
			if(f[i]>f[nt[j]+1]+1)
			{
				f[i]=f[nt[j]+1]+1;
				path[i]=j;
				to[i]=nt[j]+1;
			}
		}
	}
	for(int i=1;i<=l;i=to[i])
	{
		printf("%c",path[i]+'a');
		
	}
}

Measured memory_bytes: 10624
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> height(n);
    for (int i = 0; i < n; i++)
        cin >> height[i];

    vector<int> costMin(n);
    costMin[0] = 0;
    costMin[1] = abs(height[1] - height[0]);
    for (int i = 2; i < n; i++) {
        int firstStone = abs(height[i] - height[i - 1]) + costMin[i - 1];
        int secondStone = abs(height[i] - height[i - 2]) + costMin[i - 2];
        costMin[i] = min(firstStone, secondStone);
    }

    cout << costMin.back();
    return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define taskname "VirtualACM"
using namespace std;

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif // CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    int ans = 0;
    char c;
    for (c = getchar(); c == '+' || c == '-'; c = getchar())
        ans += (c == '+')? 1 : -1;
    cout << ans;
}


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

using namespace std;

enum STATUS { TOP,
              UP,
              DOWN,
              BOTTOM };
             
int main()
{
  int n;
  string f;
  int count;
  STATUS status;
  
  while (1) {
    count = 0;
    status = BOTTOM;
    cin >> n;
    if (!n) break;
    while (n--) {
      cin >> f;
      if (f[1] == 'u') {
        if (status == UP) {
          status = TOP;
          count++;
        } else if (status == DOWN) {
          status = TOP;
        } else if (status == BOTTOM) {
          status = UP;
        }
      } else {
        if (status == DOWN) {
          status = BOTTOM;
          count++;
        } else if (status == UP) {
          status = BOTTOM;
        } else if (status == TOP) {
          status = DOWN;
        }
      }
    }
    cout << count << endl;
  }
}
  



Measured memory_bytes: 3012
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
const ll E=1e17+7;
#define F first
#define S second
#define MK make_pair


ll aiu(ll a,ll b){
    return (a|b)-(a&b);
}


int main(){
    ll n;
    cin>>n;
    vector<ll> a;
    for(int i=0;i<n;i++){
        ll b;
        cin>>b;
        a.push_back(b);
    }
    ll c=a[0],s=0,g=0,sum=a[0],count=1;
    while(g<n-1){
        while(g<n-1 && aiu(c,a[g+1])==sum+a[g+1]){
            g++;
            sum+=a[g];
            c=aiu(c,a[g]);
            count+=g-s+1;
        }
        
        while(g<n-1 && aiu(c,a[g+1])!=sum+a[g+1]){
            c-=a[s];
            sum-=a[s];
            s++;
        }
    }
    cout<<count<<endl;
    
    
    
    return 0;
}

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

int main() {
  
  int n,k,c;
  string s;
  
  cin >> n >> k >> c;
  cin >> s;
  
  int num=0;
  
  vector<int>l(k), u(k);
  
  for(int i=0; i<s.size(); i++){
    
    if(num==k)
      break;
    
    else if(s.at(i)=='o'){
      l.at(num)=i;
      num++;
      i +=c;
      continue;
    }
  }
  
  num=0;
  
  for(int i=s.size()-1; i>-1; i--){
    
    if(num==k)
      break;
    
    else if(s.at(i)=='o'){
      u.at(num)=i;
      num++;
      i -=c;
      continue;
    }
  }
  
  reverse(u.begin(), u.end()); // {5, 2, 2, 1}
  
  for(int i=0; i<k; i++){
    if(l.at(i)==u.at(i))
      cout << l.at(i)+1 << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 3332
n,k=map(int,input().split())
l=[0]*n
for i in range(n):
  a,b=map(int,input().split())
  l[i]=[a,b]
l.sort()
s=0
x=0
for i in range(n):
  s+=l[i][1]
  if s>=k:
    x=l[i][0]
    break
print(x)

Measured memory_bytes: 20064
<?php
list($n, $m, $l) = explode(" ", trim(fgets(STDIN)));
$a = array();
$b = array();
$c = array();

for ($i = 0; $i < $n; $i++) $a[$i] = explode(" ", trim(fgets(STDIN)));
for ($i = 0; $i < $m; $i++) $b[$i] = explode(" ", trim(fgets(STDIN)));
for ($i = 0; $i < $n; $i++)
  for ($j = 0; $j < $l; $j++)
    $c[$i][$j] = 0;

for ($i = 0; $i < $n; $i++)
  for ($j = 0; $j < $l; $j++)
    for ($k = 0; $k < $m; $k++)
      $c[$i][$j] += $a[$i][$k] * $b[$k][$j];

$out = array();
for ($i = 0; $i < $n; $i++)
  array_push($out, implode(" ", $c[$i]));

echo implode("\n", $out) . "\n";



Measured memory_bytes: 14668