akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n;
	while (cin>>n,n){
		unsigned int sum = 0;
		unsigned int ans = 0;
		vi arr(n);
		REP(i, n)
			cin>>arr[i];
		SORT(arr);
		REP(i, n){
			ans += sum;
			sum += arr[i];
		}
		cout << ans << endl;
		
	}
}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<setprecision(12);


    int n,k;cin>>n>>k;
    vector<double> p(n);
    rep(i,n){
        double k;cin>>k;
        p[i]=((k+1)*k/2.0)/k;
    }

    // debug(p);
    double sum=0;
    rep(i,k){
        sum+=p[i];
    }
    double ans=sum;
    for(int i=k;i<n;i++){
        sum-=p[i-k];
        sum+=p[i];
        chmax(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
# 解説の手順
# 参考:kenseiQ さん
def XXOR(N,K,A):
    # 2**10=1024>1000=10**3を利用すると、K+1<10**12+1<2*40(計算されたし)がわかる
    # つまりKを二進表記しても高々40桁（0~39で扱う）しかない
    ans = 0

    # Aの各要素を二進表記した時、b番目のビットが立っているものは何個か
    bit_stand = [len([1 for a in A if (a & 1<<b) != 0]) for b in range(40)]

    # KとXを二進表記したものを上の桁から見て行って、初めて違う数字が出てきた桁がi
    for i in range(39,-2,-1):

        # K_iは1でないといけないのでその時はcontinue（解説参照）
        if i != -1 and (K & (1<<i)) == 0: # i=-1の時はX=Kの時を扱う（この時は前半部分で条件が弾かれるので1<<(-1)が実行されてエラーになることがない）
            continue

        tmp = 0
        for e in range(39,-1,-1): # 各ビットがf(x)に貢献する値を見ていく
            bit_mask = 1<<e
            num = bit_stand[e]

            if e>i: # この桁はKと同じ
                if (bit_mask & K) == 0: # Xのi桁のビットが立っていない時
                    tmp += bit_mask * num
                else:                   # Xのi桁のビットが立ってる時
                    tmp += bit_mask * (N-num) 
            elif e==i: # Xのi桁は必ず0である（解説参照）
                tmp += bit_mask * num
            else: # ここの桁は自由に決めていい
                tmp += bit_mask * max(num,N-num)
        
        ans = max(ans, tmp)
    
    return ans


N,K = map(int,input().split())
A = list(map(int,input().split()))
print(XXOR(N,K,A))

Measured memory_bytes: 14620
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <unordered_map>
#include <limits>
//std::numeric_limits<int>::max(), min()

int main (void) {

  int N, K;
  std::cin >> N >> K;

  std::string S;
  std::cin >> S;

  std::string ans = S;
  std::transform(S.begin(), S.end(), S.begin(), tolower);
  for(int i=0; i<S.size(); i++){
    if ( i == K-1 ) ans[i] = S[i];
  }
  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int a,b;
	double s,t;
	
	scanf("%d %d",&a,&b);
	
	s=(double)(a*b)/3.305785;
	
	printf("%lf\n",s);
	
	return 0;
}
	
	
	
	
	

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std; typedef long long ll;
const int N = 1e5 + 10;
int n, m, a[N], b[N], sa, sb, ans;

void WA() {
	puts("-1");
	exit(0);
}

bool check_unsolvable() {
	vector<int> x, y;
	x.push_back(sa), y.push_back(sb);
	for(int i = 1 ; i <= n ; ++ i) x.push_back(a[i]), y.push_back(b[i]);
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
//	for(int i = 0 ; i < x.size() ; ++ i)
//		cout << x[i] << ' ' << y[i] << endl;
	for(int i = 0 ; i < x.size() ; ++ i)
		if(x[i] != y[i])
			return 1;
	return 0;
}

int c[N], d[N]; 

map<int, int> tra;
int fa[N];
int get(int x) { return x == fa[x] ? x : fa[x] = get(fa[x]); }

int main() {
	scanf("%d", &n);
	for(int i = 1 ; i <= n ; ++ i) scanf("%d", &a[i]), sa ^= a[i];
	for(int i = 1 ; i <= n ; ++ i) scanf("%d", &b[i]), sb ^= b[i];
	if(check_unsolvable()) WA();
	
	int top = 0;
	for(int i = 1 ; i <= n ; ++ i)
		if(a[i] != b[i])
			c[++ top] = a[i],
			d[top] = b[i];
	c[++ top] = sa;
	d[top] = sb;
	n = top;
	int tot = 0;
	for(int i = 1 ; i <= n ; ++ i) {
		a[i] = c[i];
		b[i] = d[i];
		if(!tra[a[i]]) tra[a[i]] = ++ tot;
	}
	ans = n - 1;
	
	if(!ans) return puts("0"), 0;
	
	for(int i = 1 ; i <= tot ; ++ i) fa[i] = i;
	for(int i = 1 ; i <= n ; ++ i) {
		if(a[i] != b[i]) {
			fa[get(tra[a[i]])] = get(tra[b[i]]);
		}
	}
	for(int i = 1 ; i <= tot ; ++ i)
		if(i == get(i))
			++ ans;
	printf("%d\n", ans - 1);
}

Measured memory_bytes: 8420
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
using namespace std;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(void){
    int n,k;cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0;i < n;i++)cin >> a[i];
    sort(a.begin(),a.end());

    ll facl = 1;
    for(ll i = 1;i <= n;i++)facl = (facl * i) % mod;

    vector<mint> dp(100010,0);
    dp[k] = (mint)1;
    for(ll x = k;x >= 1;x--){
        if(dp[x].x == 0)continue;
        mint cnt = 0;
        ll l = -1,r = n;
        while(l+1!=r){
            ll m = (l+r)/2;
            if(a[m] > x)r = m;
            else l = m;
        }
        cnt = (mint)(l + 1);
        if(cnt.x == 0){
            continue;
        }
        for(ll i = 0;i < cnt.x;i++){
            dp[x % a[i]] += dp[x]/cnt;
        }
        dp[x] = 0;
    }
    mint sum = 0;
    for(ll x = k;x >= 0;x--){
       sum += (mint)x * dp[x];
    }
    sum *= facl;
    cout << sum.x << '\n';
}


Measured memory_bytes: 1152
def main():
    while True:
        a, b = map(int, input().split())
        if a == b == 0:
            break

        n = int(input())
        construction = [list(map(int, input().split())) for _ in range(n)]

        dp = [[0]*b]*a

        dp[0][0] = 1

        for i in range(a):
            for j in range(b):
                if i == 0 and j == 0:
                    continue
                
                if any(list([i+1, j+1] == construction[k] for k in range(n))):
                    dp[i][j] = 0
                    continue

                w1 = 0
                w2 = 0
                
                if i > 0:
                    w1 = dp[i-1][j]

                if j > 0:
                    w2 = dp[i][j-1];
                dp[i][j] = w1 + w2

        print(dp[a-1][b-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 7672
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
  
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
  
using namespace std;
  
typedef long long ll;
typedef pair<int, int> P;
 
int main(){
    int N, T;
    cin >> N >> T;
    vector<string> vs;
    vector<int> vi;
    int prev = -1;
    rep(i, N){
        int h, m;
        char c;
        string s;
        cin >> h >> c >> m >> s;
        int t = h*60+m-prev;
        if(prev != -1 && t >= T){
            vs.push_back(s);
            vi.push_back(t);
        }
        cin >> h >> c >> m >> s;
        prev = h*60+m;
    }
    cout << vs.size() << endl;
    rep(i, vs.size()){
        cout << vs[i] << ' ' << vi[i] << endl;
    }
 
    return 0;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

ll lcm(ll a, ll b){
  ll tmp, r, x = a * b;
  if(a < b){
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  }
  return x / b;
}

ll gcd(ll a, ll b){
  ll tmp, r, x = a * b;
  if(a < b){
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

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

  ll n;
  cin >> n;
  ll a[n];
  REP(i, n){
    cin >> a[i];
  }
  ll rec = a[0];
  REP(i, n - 1){
    rec = gcd(rec, a[i + 1]);
  }
  cout << rec << endl;
  return 0;
}


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

int main(){
    constexpr size_t maxNA = 4000000;
    size_t N;
    cin >> N;
    size_t S{0};
    bitset<maxNA> hoge;
    hoge[0] = 1;
    for(size_t i = 0, A; i < N; ++i, S += A, hoge |= hoge << A)cin >> A;
    for(size_t k = (S + 1) / 2; k <= S; ++k)if(hoge[k]){
        cout << k << endl;
        return 0;
    }
}

Measured memory_bytes: 1664
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<cmath>
#include<stdio.h>
#include<vector>
#include<set>
#include<utility>
#include<ctype.h>
#include<ctime>
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
# define ll long long
using namespace std;
int gcd(int a,int b){
    int r;
    while(b){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
int GCD(int a,int b)
{
    if(a==0) return b;
    else return GCD(b%a,a);
}
long long int power(long long int a,long long int b){
    long long int r=1;
    while(b){
        if(b & 1){
            r=r*a;
            b--;
        }
        a=a*a;
        b>>=1;
    }
    return r;
}
int palindrome(char *s,int len)
{
    int i,j,k,count=0,c=0;
    for(i=0,j=len-1;i<len,j>=0;i++,j--){
        if(s[i]==s[j]) count++;
    }
	if(count==len) return 1;
    	else return 0;
}
long long int binary(char *s,long long int len)
{
    long long int i,j,k,r=0,p=0,num;
    for(i=len-1;i>=0;i--){
        num=s[i]-'0';
        r+=(num*power(2,p));
        p++;
    }
    return r;
}
int binary_search(int *ara,int size,int n)
{
    int high,mid,low;
    low=0;
    high=size-1;
    while(low<=high){
        mid=(low+high)/2;
        if(ara[mid]==n){
            return 1;
        }
        else if(n>ara[mid]) low=mid+1;
        else if(n<ara[mid]) high=mid-1;
    }
    return -1;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int i,j,k,n,T,q;
	string s1,s2;
	int a,b;
	cin>>a>>b;
	if(a==b) cout<<"Draw"<<endl;
	else if(a==1 && b>1) cout<<"Alice"<<endl;
	else if(b==1 && a>1) cout<<"Bob"<<endl;
	else {
        if(a<b) cout<<"Bob"<<endl;
        else if(a>b) cout<<"Alice"<<endl;
	}
}



Measured memory_bytes: 256
n = int(input())
F = []
ans = -float('inf')
for i in range(n):
    a = "".join(input().split())
    a = int(a, 2)
    F.append(a)
p = [list(map(int,input().split())) for i in range(n)]
for i in range(1,2**10):
    tmp = 0
    for j in range(n):
        cnt = bin(i&F[j]).count("1")
        tmp +=p[j][cnt]
    else:
        ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 74044
#include<stdio.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<iostream>


int main(){
	double r;
	std::cin >> r;
	double l, s;
	l = 2 * M_PI*r;
	s = M_PI * r*r;
	printf("%f %f\n", s,l);
}

Measured memory_bytes: 1228
#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;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int a[1111];
set<int> S;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int x,n; cin>>x>>n;
	for(int i=0;i<n;i++) 
	{
		cin>>a[i];S.insert(a[i]);
	}
	int mindiff=int(1e9); int ans=0;
	for(int i=-1000;i<=1000;i++)
	{
		if(S.find(i)!=S.end()) continue;
		int diff = abs(x-i);
		if(diff<mindiff)
		{
			mindiff=diff; ans=i;
		}
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 3664
#include<stdio.h>
int main(){
	int a;
	while(1){
		scanf("%d",&a);
		if(a==0)return 0;
		long long int n[10000];
		for(int i=0;i<a;i++)scanf("%lld",n+i);
		long long int dp[10000];
		dp[0]=n[0];
		long long int max=dp[0];
		for(int i=1;i<a;i++){
			if(dp[i-1]>0)dp[i]=dp[i-1]+n[i];
			else dp[i]=n[i];
			if(max<dp[i])max=dp[i];
		}
		printf("%lld\n",max);
	}
}

Measured memory_bytes: 0
function Main(input)
{
    const temp = input.trim().split("\n");
    const k = parseInt(temp[0], 10);
    const s = String(temp[1]);

    if (s.length > k) {
        let ans = s.slice(0, k);
        console.log("%s...", ans);
    } else {
        console.log(s)
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29908
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}
int compw(const void *a, const void *b){return (*(int*)a>*(int*)b)-(*(int*)a<*(int*)b);}
int compr(const void *a, const void *b){return *(int*)b-*(int*)a;}

uint32_t nextpint(void){ char c=getchar(); while(c<'0'||'9'<c) c=getchar(); uint_fast32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return x; }

inline int min2(const int a, const int b){return a>b?b:a;}
inline int dif2(const int a, const int b){return a>b?a-b:b-a;}

int main(void){
	int n=nextpint();
	double a=(double)n/3;
	printf("%.12lf\n", a*a*a);
}



Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();

		int dx = n > k ? k : n;
		int dy = n > k ? n - k : 0;

		int fee = dx * x + dy * y;
		System.out.println(fee);
		sc.close();
	}
}


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

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

int main()
{
    FASTIO

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

    int dp[n][3];
    for(int i=0; i<3; i++)
        dp[0][i] = h[0][i];
    if(n == 1)
        cout << *max_element(dp[0], dp[0]+3) << "\n";
    else
    {
        for(int i=1; i<n; i++)
        {
            for(int j=0; j<3; j++)
            {
                if(j == 0)
                    dp[i][j] = h[i][j] + max(dp[i-1][1], dp[i-1][2]);
                else if(j == 1)
                    dp[i][j] = h[i][j] + max(dp[i-1][0], dp[i-1][2]);
                else
                    dp[i][j] = h[i][j] + max(dp[i-1][0], dp[i-1][1]);
            }
        }
        cout << *max_element(dp[n-1], dp[n-1]+3) << "\n";
    }

    return 0;
}

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

int main(){
    int n,k;
    int t;
    vector<int> p;

    cin >> n >> k;

    for (int i = 0; i < n; i++) {
        cin >> t;
        p.push_back(t);
    }

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

    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += p[i];
    }

    cout << sum << endl;
} 


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int main(void) {
	int a; cin >> a;
	if (a == 3 || a == 5 || a == 7)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
int main(int argc, const char * argv[]) {



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

    char a,b;
    cin>>a>>b;
    if((a=='H'&&b=='H')||(a=='D'&&b=='D'))cout<<'H'<<endl;
    else cout<<'D'<<endl;

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>

using namespace std;
int main(){
    long long N,a,b,c,ans;
    cin >> N;
    a = N/3, b = N/5, c = N/15;
    ans = N*(N+1)/2 - a*(a+1)/2*3 - b*(b+1)/2*5 + c*(c+1)/2*15;
    cout << ans << "\n";
    //printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <iomanip>
#include <string>
#include <limits.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>

using namespace std;


int main(int argc, char* argv[]){
  string n;
  cin >> n;
  if(n[0] == n[1]){
    if(n[1] == n[2]){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }else{
    if(n[1] == n[2]){
      if(n[2] == n[3]){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll n, ans = -1*INF;
    cin >> n;
    vector<vector<ll>> f(n, vector<ll>(10)), p(n, vector<ll>(10));
    rep(i, n) {
        rep(j, 10) {
            cin >> f[i][j];
        }
    }
    rep(i, n) {
        rep(j, 11) {
            cin >> p[i][j];
        }
    }
    rep(i, (1<<10)) {
        if(i == 0) continue;
        // 空いているなら1
        vector<bool> open(10, false);
        rep(j, 10) {
            if(i&(1<<j)) open[j] = true;
        }
        // 各店舗に対する利益
        ll tmp = 0;
        rep(j, n) {
            ll num = 0;
            // 営業が被っているか
            rep(k, 10) {
                if(f[j][k] && open[k]) num++;
            }
            tmp += p[j][num];
        }
        if(ans < tmp) ans = tmp;
    }
    cout << ans << endl;
    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


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

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

    ll a_c = 0, b_c = 0, c_c = 0;
    rep(i, 3){
        if(s[i] == 'a') a_c++;
        if(s[i] == 'b') b_c++;
        if(s[i] == 'c') c_c++;
    }

    if(a_c && b_c && c_c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from collections import deque

def main():
    N = int(input())
    path = [[] for _ in range(N)]
    ab = []
    ans = {}
    visited = [False] * N
    visited[0] = True
    for _ in range(N-1):
        a, b = map(int, input().split())
        path[a-1].append(b-1)
        path[b-1].append(a-1)
        # ab.append(str(a-1)+str(b-1))
        ab.append((a-1, b-1))
    
    que = deque([(0, 0)])
    while que:
        # k = 1
        k = 0
        pre, c = que.popleft()
        for next_node in path[pre]:
            if visited[next_node]:
                continue
            k += 1
            if c == k:
                k += 1
            visited[next_node] = True
            # ans[str(pre)+str(next_node)] = k
            ans[(pre, next_node)] = k
            que.append((next_node, k))
            

    print(max(ans.values()))
    for key in ab:
        print(ans[key])

if __name__ == '__main__':
    main()

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

using namespace std;


void solve() {
    string s; cin >> s;
    int n = s.size();
    for (int _ = 0; _ < n; _++) {
        cout << 'x';
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


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

const double CONV = 380000.0;

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

  string s;
  double u;
  double ans = 0.0;

  for(int i = 0; i < N; ++i) {
    cin >> u >> s;
    if(s == "JPY") {
      ans += u;
    } else {
      ans += u * CONV;
    }
  }
  cout << setprecision(12) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, l, i, j, k;
	cin >> n >> l;
	vector<string> s(n);
	for (i = 0; i < n; i++) cin >> s[i];
	sort(s.begin(), s.end());
	for (auto ss : s) cout << ss;
	cout << "\n";

	return 0;
}


Measured memory_bytes: 256
from __future__ import print_function

import sys
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def solve02():
    n = int(input().strip())
    L = []
    Xmin, Ymin, Xmax, Ymax = (sys.maxsize, sys.maxsize, -100, -100)

    for i in range(n):
        a, b = map(int, input().strip().split())
        L.append((a, b))
        Xmin, Ymin, Xmax, Ymax = (min(Xmin, a), min(Ymin, b), max(Xmax, a), max(Ymax, b))
    A, B, C, D = ((Xmin, Ymax), (Xmin, Ymin), (Xmax, Ymin), (Xmax, Ymax))

    # 対角線ACについて
    d_MinDistFromA = sys.maxsize    # 点Aからの距離が最小であるような，その最小の距離の値を求める
    d_MinDistFromC = sys.maxsize    # 点Cからの距離が最小であるような，その最小の距離の値を求める
    # 対角線BDについて
    d_MinDistFromB = sys.maxsize    # 点Bからの距離が最小であるような，その最小の距離の値を求める
    d_MinDistFromD = sys.maxsize    # 点Dからの距離が最小であるような，その最小の距離の値を求める

    for a, b in L:
        d_MinDistFromA = min(d_MinDistFromA, abs(a - Xmin) + abs(b - Ymax))
        d_MinDistFromC = min(d_MinDistFromC, abs(a - Xmax) + abs(b - Ymin))
        d_MinDistFromB = min(d_MinDistFromB, abs(a - Xmin) + abs(b - Ymin))
        d_MinDistFromD = min(d_MinDistFromD, abs(a - Xmax) + abs(b - Ymax))

    # 出力
    ans1 = abs(A[0] - C[0]) + abs(A[1] - C[1]) - (d_MinDistFromA + d_MinDistFromC)
    ans2 = abs(B[0] - D[0]) + abs(B[1] - D[1]) - (d_MinDistFromB + d_MinDistFromD)
    print(max(ans1, ans2))


def main():
    solve02()


if __name__ == '__main__':
    main()

Measured memory_bytes: 88544
#include "bits/stdc++.h"
using namespace std;
long long const INF = 9e9;
int main() {
	string S;
	cin >> S;
	bool N = false, E = false, W = false, So = false;
	for (int i = 0; i < S.size(); i++) {
		if (S.at(i) == 'N') N = true;
		if (S.at(i) == 'E') E = true;
		if (S.at(i) == 'W') W = true;
		if (S.at(i) == 'S') So = true;
	}
	if (N && !So)cout << "No" << endl;
	else if (So && !N) cout << "No" << endl;
	else if (E && !W) cout << "No" << endl;
	else if (W && !E) cout << "No" << endl;
	else cout << "Yes" << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
vector<pair<int,int>> EE[1010101];
int did[101010];
vector<int> TE[101010];

vector<int> E[301010];
int id=100001;
int dist[303030];

void dfs(int cur,int x) {
	if(did[cur]==x) return;
	did[cur]=x;
	E[id].push_back(cur);
	E[cur].push_back(id);
	FORR(r,TE[cur]) dfs(r,x);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>x>>y>>r;
		EE[r].push_back({x,y});
	}
	MINUS(did);
	FOR(i,1010100) if(EE[i].size()) {
		vector<int> V;
		FORR(e,EE[i]) {
			TE[e.first].push_back(e.second);
			TE[e.second].push_back(e.first);
			V.push_back(e.first);
			V.push_back(e.second);
		}
		
		FORR(r,V) if(did[r]!=i) {
			dfs(r,i);
			id++;
		}
		FORR(e,EE[i]) {
			TE[e.first].clear();
			TE[e.second].clear();
		}
	}
	
	memset(dist,0x3f,sizeof(dist));
	dist[1]=0;
	queue<int> Q;
	Q.push(1);
	while(Q.size()) {
		x = Q.front();
		Q.pop();
		FORR(e,E[x]) {
			if(dist[e]>dist[x]+1) {
				dist[e]=dist[x]+1;
				Q.push(e);
			}
		}
	}
	
	if(dist[N]>0x3f0000) dist[N]=-1;
	else dist[N]/=2;
	cout<<dist[N]<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 54016
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
cnt1=0
cnt2=0
for i in range(1,x+1):
    if i in a:
        cnt1+=1
for j in range(x,n+1):
    if j in  a:
        cnt2+=1
print(min(cnt1,cnt2))

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    priority_queue<ll> prQ;

    rep(i, n) {
        ll a;
        cin >> a;
        prQ.push(a);
    }

    rep(i, m) {
        ll x = prQ.top();
        x /= 2LL;
        prQ.pop();
        prQ.push(x);
    }

    ll ans = 0;
    while(!prQ.empty()) {
        ll y = prQ.top();
        ans += y;
        prQ.pop();
    }

    cout << ans << endl;
    return 0;
}

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

int main(){
	int n, h[11][11];
	while(scanf("%d", &n)){
		if(!n)break;
		for(int i = 0;i < n;i++){
			int num = 0;
			for(int j = 0;j < n;j++){
				scanf("%d", &h[i][j]);
				num += h[i][j];
			}
			h[i][n] = num;
		}
		
		for(int i = 0;i < n;i++){
			for(int j = 0;j <= n;j++){
				printf("%5d", h[i][j]);
			}
			printf("\n");
		}
		
		for(int i = 0;i <= n;i++){
			int num = 0;
			for(int j = 0;j < n;j++)num += h[j][i];
			printf("%5d", num);
		}
		printf("\n");
	}
}

Measured memory_bytes: 3112
let split s =
  Str.split (Str.regexp_string " ") s |> List.map (fun x -> float_of_string x);;

let rec read () =
  try let l = read_line () |> split |> Array.of_list in
      let (a, b, c, d, e, f) =
        (l.(2)-.l.(0), l.(4)-.l.(0), l.(3)-.l.(1), l.(5)-.l.(1),l.(6)-.l.(0), l.(7)-.l.(1)) in
      let adbc = a*.d -. b*.c in
      let (x, y) = ((e*.d -. b*.f)/.adbc, (a*.f -. e*.c)/.adbc) in
      if x > 0. && y > 0. && x +. y < 1. then
        print_endline "YES"
      else
        print_endline "NO"
      ; read ()
  with End_of_file -> ();;

let () = read ();;

Measured memory_bytes: 2260
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 0x1fffffffffffffff;

int main(){
    ll n;
    cin >> n;
    vector<ll> h(n);
    for(ll& i : h) cin >> i;
    vector<ll> dp(n, INF);
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for(ll i = 2; i < n; i++){
        dp[i] = min(dp[i - 1] + abs(h[i - 1] - h[i]), dp[i - 2] + abs(h[i - 2] - h[i]));
    }
    cout << dp[n - 1] << endl;
}



Measured memory_bytes: 1792
// Aizu Vol-2 0223: Stray Twins
// 2017.9.5 bal4u@uu

#include <stdio.h>

#define QSIZE 300000
typedef struct { char t, tx, ty, kx, ky; } Q;
Q que[QSIZE+3]; int top, end; 

char map[53][53]; int w, h;
unsigned char chk[53][53][53][53];
int tx, ty, kx, ky;

int m[2][4][2] = { 
	{ {-1,0},{ 1,0},{0,-1},{0, 1} },
	{ { 1,0},{-1,0},{0, 1},{0,-1} } };

int main()
{
	int i, x, y, a, ans;
	int t, txx, tyy, kxx, kyy, tx2, ty2, kx2, ky2;
	unsigned char cno = 1;

	while (scanf("%d%d", &w, &h) && w) {
		scanf("%d%d%d%d", &tx, &ty, &kx, &ky);
		for (y = 1; y <= h; y++) for (x = 1; x <= w; x++) scanf("%d", &a), map[y][x] = a;
		que[0].t = 0, que[0].tx = tx, que[0].ty = ty, que[0].kx = kx, que[0].ky = ky;
		chk[ty][tx][ky][kx] = cno;
		top = 0, end = 1, ans = -1;
		while (top < end) {
			t = que[top].t, txx = que[top].tx, tyy = que[top].ty, kxx = que[top].kx, kyy = que[top].ky;
			if (++top >= QSIZE) top = 0;
			if (txx == kxx && tyy == kyy) {	ans = t; break; }
			if (t >= 100) break;
			for (i = 0; i < 4; i++) {
				tx2 = txx + m[0][i][1], ty2 = tyy + m[0][i][0];
				if (tx2 < 1 || tx2 > w || ty2 < 1 || ty2 > h || map[ty2][tx2]) 
					tx2 = txx, ty2 = tyy;
				kx2 = kxx + m[1][i][1], ky2 = kyy + m[1][i][0];
				if (kx2 < 1 || kx2 > w || ky2 < 1 || ky2 > h || map[ky2][kx2])
					kx2 = kxx, ky2 = kyy;
				if (chk[ty2][tx2][ky2][kx2] == cno) continue;
				chk[ty2][tx2][ky2][kx2] = cno;
				que[end].t = t+1, que[end].tx = tx2, que[end].ty = ty2, que[end].kx = kx2, que[end].ky = ky2;
				if (++end >= QSIZE) end = 0;
			}
		}
		printf(ans < 0 ? "NA\n" : "%d\n", ans);
		cno++;
	}
	return 0;
}

Measured memory_bytes: 9316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, q, k;
vector<pair<ll, ll> > adj[100010];
bool done[100010];
ll dis[100010];
void find(ll a, ll d = 0)
{
	if (done[a]) return;
	done[a] = true;
	dis[a] = d;
	for (int i = 0; i < adj[a].size(); i++) find(adj[a][i].first, d+adj[a][i].second);

}
int main()
{
	scanf("%lld", &n);
	for (int i = 1; i < n; i++)
	{
		ll a, b, c;
		scanf("%lld%lld%lld", &a, &b, &c);
		adj[a].push_back(make_pair(b, c));
		adj[b].push_back(make_pair(a, c));
	}
	scanf("%lld%lld", &q, &k);
	find(k);
	for (int i = 0; i < q; i++)
	{
		ll a, b;
		scanf("%lld%lld", &a, &b);
		printf("%lld\n", dis[a]+dis[b]);
	}
}

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

int main(){
    double N,K,T,U,V,L,D[201];
    double k=0, boost = 0, tm = 0;
    int index = 1;
    cin >> N >> K >> T >> U >> V >> L;
    for(int i=1; i<=N; i++){
        cin >> D[i];
    }
    for(int i=0; i<L; i++){
        if(index<=N && i==D[index]){
            if(k < K)   k++;
            else        boost = V*T;
            index++;
        }
        if(boost == 0 && k > 0){
            k--;
            boost = V*T;
        }
        if(boost == 0)  tm +=1.0/U;
        else{
            tm += 1.0/V;
            boost--;
        }
    }
    cout << fixed;
    cout << setprecision(8) << tm << endl;
    return 0;
}


Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,x,i,j;
    cin>>n;
    int dp[n][3];
    for(i=0;i<3;++i)
    {
        cin>>x;
        dp[0][i] = x;
    }
    for(i=1;i<n;++i)
    {
        for(j=0;j<3;++j)
        {
            cin>>x;
            dp[i][j] = max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]) + x;
        }
    }
    cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}

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

int main() {
  int n; cin >> n;
  string s; cin >> s;
  long long tmp = 0;
  if(n == 1){
    cout << 0;
    return 0;
  }
  if(n == 2){
    cout << 0;
    return 0;
  }
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j <= n; j++){
      if(2 * j - i >= n) continue;
      if(s.at(i) != s.at(j)){
        if(s.at(j) != s.at(2 * j - i)){
          if(s.at(i) != s.at(2 * j - i)) tmp++;
        }
      }
    }
  }
  long long r=0, g=0, b=0;
  for(int i = 0; i < n; i++){
    if(s.at(i) == 'R'){
      r++;
    }else if(s.at(i) == 'G'){
      g++;
    }else{
      b++;
    }
  }
  long long out;
  out = r * g * b;
  if(out - tmp < 0){
    cout << 0;
    return 0;
  }
  cout << out - tmp;
}


Measured memory_bytes: 3632
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

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

  ll t = (s == 1) ? s + 1 : s - 1;

  rep(i, n) {
    if (i < k)
      cout << s;
    else
      cout << t;
    cout << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1280
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
typedef long long LL;
typedef long double Lf;
#define in (void)scanf
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
//#define Rep(i,a,n)for(LL i=(LL)(a);i<(LL)(n);i++)
#define rep(i,n)Rep(i,0,n)
#define Repp(i,l,r,k)for(int i=(int)(l);i<(int)(r);i+=(int)(k))
//#define Repp(i,l,r,k)for(LL i=(LL)(l);i<(LL)(r);i+=(LL)(k))
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define MOD 1000000007//998244353,1000000007,1000000009,4999999999999997
int upi(const void* a, const void* b) { return*(int*)a<*(int*)b ? -1 : *(int*)a> * (int*)b ? 1 : 0; }
int downi(const void* a, const void* b) { return*(int*)a<*(int*)b ? 1 : *(int*)a> * (int*)b ? -1 : 0; }
void sortupi(int* a, int n) { qsort(a, n, sizeof(int), upi); } //1,2,3,4,...
void sortdowni(int* a, int n) { qsort(a, n, sizeof(int), downi); }
int upLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? -1 : *(LL*)a> * (LL*)b ? 1 : 0; }
int downLL(const void* a, const void* b) { return*(LL*)a<*(LL*)b ? 1 : *(LL*)a> * (LL*)b ? -1 : 0; }
void sortupLL(LL* a, int n) { qsort(a, n, sizeof(LL), upLL); }
void sortdownLL(LL* a, int n) { qsort(a, n, sizeof(LL), downLL); }
int cmp_char(const void* a, const void* b) { return *(char*)a - *(char*)b; } // a,b,c,d
int cmp_str(const void* a, const void* b) { return strcmp(*(const char**)a, *(const char**)b); } // aaa,aab
LL gcd(LL p, LL q) { while (q) { LL t = p % q; p = q; q = t; }return p; }
LL modpow(LL a,LL n,int m){LL x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define invmodpow(b,p)modpow(b,p-2,p)// a/b≡a*b^{-1}(mod p)...return b^{-1}(mod p)
//typedef struct fac { LL n, exp; }F;
//LL fact(LL n,F*a){LL x=n,i,j,c=0;for(i=2;i*i<=x;i++){for(j=1;x%i==0;j++)x/=i;if(j>1){a[c].n=i;a[c++].exp=j-1;}}if(x-1){a[c].n=x;a[c++].exp=1;}return c;}
LL nibtan(LL* a,LL n,LL x){LL p=0,q=n/2,r=n-1;while(r-p>1){if(x>=a[q])p=q;if(x<=a[q])r=q;q=(p+r)/2;}return a[p]==x?p:r;}
//snippet

#define N 300009

void run(void) {
	LL a, b, c, d;
	in("%lld%lld%lld%lld", &a, &b, &c, &d);
	printf("%lld\n", Ma(a*c,Ma(a*d,Ma(b*c,b*d))));
}

int main(void) {
	int test = 1;
//	in("%d", &test);
	while (test--) {
		run();
		fflush(stdout);
	}
	return 0;
}

Measured memory_bytes: 1736
import sys
import numpy as np 

h, w = map(int, sys.stdin.readline().split())
grid = np.array([list(sys.stdin.readline().rstrip()) for _ in range(h)], dtype='U')
grid = np.pad(grid, 1, mode='constant')

def main():
    cnt = np.zeros((h+2, w+2))
    cnt[grid == '.'] = np.inf
    
    l = cnt.copy()
    r = cnt.copy()
    u = cnt.copy()
    d = cnt.copy()

    for i in range(1, w+1):
        l[1:h+1, i] = np.minimum(l[1:h+1, i], l[1:h+1, i-1]+1)
        i = w + 1 - i
        r[1:h+1, i] = np.minimum(r[1:h+1, i], r[1:h+1, i+1]+1)
    
    for i in range(1, h+1):
        u[i, 1:w+1] = np.minimum(u[i, 1:w+1], u[i-1, 1:w+1]+1)
        i = h + 1 - i
        d[i, 1:w+1] = np.minimum(d[i, 1:w+1], d[i+1, 1:w+1]+1)
    
    res = np.maximum(l + r + u + d - 3, 0).astype(np.int64)
    return np.amax(res)

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 267204
# https://atcoder.jp/contests/abc159/tasks/abc159_b

S = input()
N = len(S)
S_2 = S[: int((N - 1) / 2)]
S_3 = S[int(((N + 3) / 2)) - 1: ]

if S == S[:: -1] and S_2 == S_2[:: -1] and S_3 == S_3[:: -1]:
    print('Yes')

else:
    print('No')


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

int main() {
  int A,B,C,D; cin >>A >>B >>C >>D;
  int ST=max(A,C),ET=min(B,D);
  cout <<max(0,ET-ST) <<endl;
}


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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

int N, K;

ll cpow (ll b, int e)
{
    if (e == 1) return b % MOD;
    if (e == 0) return 1;

    ll v = cpow (b, e / 2);
    v = (v * v) % MOD;
    if (e & 1) v = (v * b) % MOD;
    return v;
}

ll inv (ll b)
{
    return cpow (b, MOD - 2);
}

ll fac[200100];
ll ifac[200100];

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

    cin >> N >> K;
    K = min (K, N - 1);

    fac[0] = 1;
    for (int i = 1; i <= N; i++)
        fac[i] = (fac[i-1] * i) % MOD;
    ifac[N] = inv (fac[N]);
    for (int i = N - 1; i >= 0; i--)
    {
        ifac[i] = (ifac[i+1] * (i + 1)) % MOD;
    }

    ll ans = 0;
    for (int i = N - K; i <= N; i++)
    {
        // N choose i * (N - 1) choose i - 1
        ll res = fac[N] * ifac[i];
        res = ((res % MOD) * ifac[N-i]) % MOD;
        ll res2 = (fac[N-1] * ifac[i-1]) % MOD;
        res2 = (res2 * ifac[N-i]) % MOD;
        ans += (res * res2) % MOD;
    }
    cout << ans % MOD << "\n";
}

Measured memory_bytes: 3328
import itertools
import math

S= input()
sg = [[s, len(list(g))] for s ,g in itertools.groupby(S)]
a= [0]* (len(S)+1)
ans =0

if sg[0][0]=='>':
    ans += (sg[0][1] + 1 ) * sg[0][1] //2

if sg[-1][0]=='<':
    ans += (sg[-1][1] + 1 ) * sg[-1][1] //2

for i in range(len(sg)-1):
    if sg[i][0]=='<' and sg[i+1][0]=='>':
        maxsg =max(sg[i][1] , sg[i+1][1])
        ans += (maxsg + 1 ) * maxsg //2
        minsg = min(sg[i][1] , sg[i+1][1])-1
        ans += ( minsg + 1 ) * minsg //2

print(ans)

Measured memory_bytes: 100424
#include<iostream>

using namespace std;

class point
{
public:
	double x,y;
	bool input()
	{
		return cin>>x>>y;
	}
};

int main(void)
{
	while(1)
	{
		point a,b,c,d;
		if(!(a.input()&&b.input()&&c.input()&&d.input()))break;
		if(a.x>b.x){
			point tmp=a;
			a=b;
			b=tmp;
		}
		if(c.x>d.x){
			point tmp=c;
			c=d;
			d=tmp;
		}
		if((b.y-a.y)*(d.y-c.y)+(b.x-a.x)*(d.x-c.x)==0)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 1216
def insertionSort(At, Nt):
	for i in range(Nt):
		v = At[i]
		j = i - 1
		while j >= 0 and At[j] > v:
			A[j + 1] = A[j]
			j = j - 1
		A[j + 1] = v
		print(" ".join(map(str,At)))
	return At

if __name__ == '__main__':
	N = int(input())
	A = list(map(int, input().split()))
	A = insertionSort(A, N)
	#print(" ".join(map(str,A)))


Measured memory_bytes: 5600
[N,M] = list(map(int, input().split()))
#[N,M] = [, 2]
lp = 0
up = N
for i in range(M):
    [x,y] = list(map(int, input().split()))
    lp = max(lp,x)
    up = min(up,y)
if lp > up:
    print(0)
else:
    print(up-lp+1)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
#include <functional>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    cout << #v << endl;                \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;
#define debug_vec2(v)                         \
    cout << #v << endl;                       \
    for (int i = 0; i < v.size(); i++)        \
    {                                         \
        for (int j = 0; j < v[i].size(); j++) \
        {                                     \
            cout << v[i][j] << " ";           \
        }                                     \
        cout << endl;                         \
    }

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

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

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>; // クラスカル法とかで、{cost, {from, to}}的に使う。
const ll LINF = 1001002003004005006ll;
const ll INF = 1001001001;
const double pi = acos(-1);

int main()
{
    ll n;
    cin >> n;
    if (n % 2 == 1)
    {
        cout << 0 << endl;
        return 0;
    }
    ll ans = 0;
    ll tmp = n;
    while (true)
    {
        if (tmp == 0)
        {
            break;
        }
        ans += tmp / 10;
        tmp /= 10;
    }
    tmp = n / 10;
    while (true)
    {
        if (tmp == 0)
        {
            break;
        }
        ans += tmp / 5;
        tmp /= 5;
    }
    tmp = n / 10;
    while (true)
    {
        if (tmp == 0)
        {
            break;
        }
        ans -= tmp / 10;
        tmp /= 10;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3584
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n, d] <- getIntList
    xss <- replicateM n getIntList
    print $ length [() | i <- [0..n-2], j <- [i+1..n-1], isN (dist (xss !! i) (xss !! j))]
    
dist xs ys = sum $ zipWith (\x y -> (x - y) ^2) xs ys

isN a = or $ map (\x -> x ^ 2 == a) [1..a]

Measured memory_bytes: 892