akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n, i;
        double d_1, d_2, d_3, d_n;
        n = sc.nextInt();
        d_1 = 0.0;
        d_2 = 0.0;
        d_3 = 0.0;
        d_n = 0.0;
        double[] x = new double[n];
        double[] y = new double[n];
        for(i=0;i<n;i++){
            x[i] = sc.nextDouble();
            //System.out.println(x[i]);
        }
        for(i=0;i<n;i++){
            y[i] = sc.nextDouble();
            //System.out.println(y[i]);
        }
        for(i=0;i<n;i++){
            d_1 += Math.abs(x[i]-y[i]);
            d_2 += Math.pow(Math.abs(x[i]-y[i]),2);
            d_3 += Math.pow(Math.abs(x[i]-y[i]),3);
            if(Math.abs(x[i]-y[i])>d_n)d_n = Math.abs(x[i]-y[i]);
            
        }
        System.out.println(d_1);
        System.out.println(Math.sqrt(d_2));
        System.out.println(Math.cbrt(d_3));
        System.out.println(d_n);
        
    }
}


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

const int MAX_N = 2000;
const int MAX_AI = 2000;

int main() {
    int N, A[MAX_N];
    cin >> N;
    for (int i = 0; i < N; i++) cin >> A[i];

    int sum = 0;
    for (int i = 0; i < N; i++) sum += A[i];

    bitset<MAX_N * MAX_AI> dp = 1;
    for (int i = 0; i < N; i++) dp |= (dp << A[i]);

    int median = (sum + 1) / 2;
    while (true) {
        if (dp[median] == 1) break;
        median++;
    }

    cout << median << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

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

	for(int i=0; i<s.length(); i+=2) cout << s.at(i);
	cout << endl;

	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll K;
  cin >> K;
  llvec d(K, 0);
  ll cur = 0;
  ll cnt=0;
  while(d[cur]==0){
    cnt++;
    d[cur]=1;
    cur = mod(cur*10 + 7, K);
    if(cur==0){
      cout << cnt;
      return 0;
    }
  }
  cout << -1;
  return 0;
}


Measured memory_bytes: 11016
n = int(input())
a = [int(item) for item in input().split()]

if n == 2:
    if a[0] == 1 and a[1] == 1:
        print("Possible")
        exit()
    else:
        print("Impossible")
        exit()

cnt = [0] * 100
for item in a:
    cnt[item] += 1

maxa = max(a)
mina = (maxa + 1) // 2

ans = True
for i in range(100):
    if i < mina:
        if(cnt[i] > 0):
            ans = False
    elif i == mina:
        if i == 1 and cnt[i] != 1:
            ans = False
        if i > 1:
            if maxa % 2 == 1 and not cnt[i] == 2:
                ans = False
            if maxa % 2 == 0 and not cnt[i] == 1:
                ans = False
    elif i > mina and i <= maxa: 
        if cnt[i] < 2:
            ans = False

if ans:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f3f3f3f3fll
using namespace std;
typedef long long ll;
const int N=2005;
int n;
ll a[N],b[N],dp[N][N];
bool cmp(int x,int y){return a[x]>a[y];}
int main()
{
    memset(dp,-inf,sizeof(dp));
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]),b[i]=i;
    sort(b+1,b+1+n,cmp);
    dp[1][n]=0;
    ll ans=0;
    for(int i=n-1;i>=0;i--)
    {
        int pos=b[n-i];
        for(int l=1;l+i<=n;l++)
        {
            if(i==0)
            {
                ans=max(ans,a[pos]*abs(pos-l)+dp[l][l]);
                continue;
            }
            int r=l+i;
            dp[l+1][r]=max(dp[l+1][r],dp[l][r]+a[pos]*abs(pos-l));
            dp[l][r-1]=max(dp[l][r-1],dp[l][r]+a[pos]*abs(pos-r));
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 35256
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
map<char,bool>mp;
map<char,bool>mp2;
int ans=0;
int main(){
    cin>>n;
    cin>>s;
   // mp[s[0]]++;


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

        for(int j=i+1;j<n;j++){
            mp.clear();
            mp2.clear();
            int l=0,r=0;
            while(l<j){
                mp[s[l]]++;
                l++;
            }
            r=j;
            while(r<n)
                {
                    mp2[s[r]]++;
                    r++;
                }
            int cnt=0;
            for(char x='a';x<='z';x++)
            cnt+=min(mp[x],mp2[x]);
            ans=max(ans,cnt);
        }
    }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 256
package main

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

func main() {
	S := getStdin()
	T := getStdin()

	ans := 0
	for i := 0; i < len(T); i++ {
		if S[i] != T[i] {
			ans++
		}
	}
	fmt.Printf("%d\n", ans)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 3388
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,k;
	cin>>n>>k;
	long long int arr[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
	}
	long long int dp[n+1];
	dp[1]=0;
	dp[2]=abs(arr[2]-arr[1]);
	long long int mini=INT_MAX,l;
	for(int i=3;i<=n;i++)
	{
		dp[i]=INT_MAX;
		for(int j=1;j<=k;j++)
		{
			if(i-j>=1)
			{
		dp[i]=min(dp[i-j]+abs(arr[i]-arr[i-j]),dp[i]);
			}
		}	
	}
/*	for(int i=1;i<=n;i++)
	{
		cout<<dp[i]<<" ";
	}
	cout<<endl;*/
	cout<<dp[n]<<endl;
}

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


char str[200050];

bool decd(int x,int y){
	for(int i=x;i<=y;i++){
		if(str[i]=='#'&&str[i+1]=='#') return false;
	}
	return true;
}
bool decd2(int x,int y){
	for(int i=x;i<=y;i++){
		if(str[i-1]=='.'&&str[i]=='.'&&str[i+1]=='.') return true;
	}
	return false;
}
int main(){
	int N=0,A=0,B=0,C=0,D=0;
	bool ans;
	scanf("%d",&N);
	scanf("%d%d%d%d",&A,&B,&C,&D);
	scanf("%s",str+1);
	if(C<D){
		ans=decd(B,D)*decd(A,C);
		if(ans==true) printf("Yes\n");
		else printf("No\n");
	}
	else if(C>D){
		ans=decd(B,D)*decd(A,C);
		if(ans==false) printf("No\n");
		else{
			ans=decd2(B,D);
			if(ans==true) printf("Yes\n");
			else printf("No\n");
		}
	}
	return 0;
}


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

int main(void)
{
    double r;
    scanf("%lf", &r);
    double area, circumference;
    area = r * r * M_PI;
    circumference = 2 * r * M_PI;
    printf("%lf %lf\n", area, circumference);

    return(0);
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a[345678], r;
ll t;

int main() {
	cin >> n;
	rep(i,n*3) cin >> a[i];
	sort(a, a+n*3);
	r = n*3 - 1;
	rep(i,n) t += a[r-1], r -= 2;
	cout << t << ln;
}

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

template <typename T,typename U>
struct compressor{
	vector<pair<pair<T,int>,U>> v;
	void add(T x,U y){
		v.emplace_back(make_pair(x,v.size()),y);
	}
	
	void compress(){
		
		sort(v.begin(),v.end());
		
		vector<pair<pair<T,int>,U>> t;
		rep(i,v.size()){
			if(t.size()!=0 && t.back().first.first == v[i].first.first){
				t.back().second = func(t.back().second,v[i].second);
			}
			else{
				t.push_back(v[i]);
			}
		}
		swap(v,t);
		
	}

	U func(U a,U b){
		return a+b;
	}
	
	U e(){
		return 0;
	}

	int size(){
		return v.size();
	}
	
	U get(int p){
		return v[p].second;
	}
	
	U operator[] (T &x){
		auto it = lower_bound(v.begin(),v.end(),make_pair(make_pair(x,-1),0));
		if(it==v.end() || it->first.first!=x){
			return e();
		}
		else return it->second;
	}
};

bool f = false;
compressor<pair<string,string>,int> get(string S){
	int N = S.size();
	compressor<pair<string,string>,int> C;
	for(int i=0;i<(1<<N);i++){
		string s="",t="";
		for(int j=0;j<N;j++){
			if((i>>j)&1)s+=S[j];
			else t+=S[j];
		}
		reverse(t.begin(),t.end());
		if(f)swap(s,t);
		C.add(make_pair(s,t),1);
	}
	f=true;
	C.compress();
	return C;
}
 
int main(){
	
	int N;
	cin>>N;
	
	string S;
	cin>>S;
	
	compressor<pair<string,string>,int> C0 = get(S.substr(0,N)),C1 = get(S.substr(N));
	
	long long ans = 0;
 
	for(auto a:C0.v){
		ans += (long long)a.second * C1[a.first.first];
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

int main(){
  int N; cin >> N;
  int A[100010];
  for(int i=0; i<=N; i++){
    cin >> A[i];
  }
  long long sum=0;
  for(int i=0; i<N; i++){
    int tmp;
    cin >> tmp;
    if(A[i]>=tmp){
      sum+=tmp;
    }else{
      sum+=A[i];
      if(A[i+1]>=tmp-A[i]){
        sum+=(tmp-A[i]);
        A[i+1]-=(tmp-A[i]);
      }else{
        sum+=A[i+1];
        A[i+1]=0;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 640
var lines =[];


var readline = require("readline");
var rl = readline.createInterface({
  input:  process.stdin,
  output: process.stdout
});

rl.on('line',function(x){
  lines.push(x);
});

rl.on('close',function(){

  var s = lines[0].split("");
  var blue=0;
  var red=0;
  
  for(var i=0;i<s.length;i++){
    if(s[i]==="0"){red++;}
    else{blue++;}
  }

  console.log(Math.min(red,blue)*2);
    
});

Measured memory_bytes: 8652
from collections import defaultdict
def main():
    n = int(input())
    s =defaultdict(lambda:0)
    for i in range(n):
        s[input()] += 1
    max_s = max(s.values())
    for key, value in sorted(s.items()):
        if value == max_s:
            print(key)

if __name__ == "__main__":
    main()

Measured memory_bytes: 46996
/*ABC 131 F */
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
// typedef pair<int,int> P;
//pair<first,secont>;
const int V = 100002;
vector<int> grp[V*2];
bool visited[V*2];
vector<int> cnt(2);

void dfs(int v){
    if (visited[v] == true)return ;
    visited[v] = true;
    cnt[v/V]++;
    for (int u : grp[v])dfs(u);
}

int main(){
    int n;
    cin >> n;
    rep(i,n) {
        int x , y ;
        cin  >> x >> y;
        y += V;
        //無向グラフを作成（有向グラフを相互に作る）
        grp[x].push_back(y);
        grp[y].push_back(x);
        // rep(i,V*2) rep(j,grp[i].size()) cout << grp[i][j] << endl;
    }
    ll ans = 0;
    rep(i,V*2){
        if (visited[i] == true) continue;
        cnt = vector<int>(2);//カウンタの初期化
        dfs(i);
        ans += (ll)cnt[0]*cnt[1];
    }
    ans -= n;//元から存在した辺を除く
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=9223372036854775806;
const int inf=2147483646;
int a,b,n;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n>>a>>b;
	cout<<min(a*n,b);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		S = S.replace("/", "");
		int date = Integer.parseInt(S);
		
		if(date <= 20190430) {
			System.out.println("Heisei");
		} else {
			System.out.println("TBD");
		}
		
	}
}


Measured memory_bytes: 22608
import java.util.Scanner;

class Main {
	public static void pr(Object o) {
		System.out.println(o);
	}

	int[][] t;

	int n;




	int[] hash;//ハッシュ。



	int min;

	public void run() {
		Scanner sc = new Scanner(System.in);
		while (true) {
			n = sc.nextInt();
			min=Integer.MAX_VALUE;
			if (n == 0) {
				break;
			}
			hash=new int[1<<n];
			for(int i=0;i<(1<<n);i++){
				hash[i]=Integer.MAX_VALUE;
			}

			t = new int[n + 1][n + 1];
			for (int i = 0; i < n; i++)
				for (int j = 0; j <= n; j++) {
					t[i][j] = sc.nextInt();
				}

			hash[0]=0;//ステージを順に追加していく動的計画法
			for(int i=0;i<(1<<n);i++){
				for(int stage=0;stage<n;stage++){
					if((i & (1<< stage))!=0){
						continue;
					}
					hash[i+(1<<stage)]=Math.min(hash[i]+t[stage][0],hash[i+(1<<stage)]);

					for(int buki=0;buki<n;buki++){
						if((i & (1<< buki))==0){
							continue;
						}
						hash[i+(1<<stage)]=Math.min(hash[i]+t[stage][buki+1],hash[i+(1<<stage)]);
					}

 				}
			}
			pr(hash[(1<<n)-1]);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 15000
using System;

namespace abc124A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = A + (A - 1);
            int D = B + (B - 1);
            int E = A + B;
            if (C < D)
                C = D;
            if (C < E)
                C = E;
            Console.WriteLine(C);
        }
    }
}


Measured memory_bytes: 13140
/**
 * @author      : Luis Miguel Baez <es.luismiguelbaez@gmail.com>
 * @created     : Thursday August 13, 2020
 */

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ms(arr, value) memset(arr, value, sizeof arr)
#define ll    int64_t

#define pii   pair<int, int>
#define piii  tuple<int, int, int>
#define pll   pair<ll, ll>
#define plll  tuple<ll, ll, ll>

#define F  first
#define S  second

const int oo  = (int)(1e9);
const ll lloo  = (ll)(1e18);

const int N = int(1e5) + 10;

class Task {
public:
    int n, w;
    vector<pair<int, int>> A;
    // (peso, valor)
    
    ll dp[110][N];

    ll go(int index, int W) {
        if(index > n) return 0;
        ll &ans = dp[index][W];
        if(ans != -1) return ans;
        
        if(W-A[index].F < 0) {
            return go(index+1, W);
        }

        ll x = A[index].S + go(index+1, W-A[index].F);
        ll y = go(index+1, W);
        ans = max(x, y);
        return ans;
    }

    ll solveOne(istream &in, ostream &out) {
        in >> n >> w;
        A.resize(n+1);
        int w_i, v_i;
        for(int i = 1; i <= n; ++i){
            in >> w_i >> v_i;
            A[i] = {w_i, v_i};
        }
        memset(dp, -1, sizeof dp);
        ll ans = go(1, w);
        return ans;  
    }
    
    void solve(istream &in, ostream &out) {
        int t=1;
        while(t--) {
            out << solveOne(in, out) << endl;
        }
    }
};

auto main() -> int {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    Task solver;
    istream &in(cin);
    ostream &out(cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 89612
#include<bits/stdc++.h>
using namespace std; int i, j, k, l, n, s, t;
int main() {
	while (true) {
		cin >> n; s = 0; t = sqrt(n) + 1;
		if (!n) { break; }
		for (i = 0; i < t; i++) {
			for (j = i; j < t; j++) {
				for (k = j; k < t; k++) {
					for (l = k; l < t; l++) {
						if (i*i + j*j + k*k + l*l == n) {
							s++;
						}
					}
				}
			}
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    vector<char> vec(N);
    for (int i = 0;i<N;i++){
        char s = S[i];
        if (i != K-1) vec[i] = s;
        else vec[i] = tolower(s);
    }
    for(int i = 0;i<N;i++){
        cout << vec[i];
    }
    cout << endl;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int a[4 * mx2][4 * mx2], vis[4 * mx2][4 * mx2];
LL ans = 0;

void bfs(int u, int v)
{
    vis[u][v] = 1;

    queue<pair<int, int>> Q;
    Q.push({u, v});

    LL col[] = {0, 0, 0};

    while(!Q.empty()){

        pair<int, int> P = Q.front();
        Q.pop();

        int c = a[P.X][P.Y];
        col[c]++;

        for(int i = 0; i < 4; i++){
            int x = P.X + dx[i], y = P.Y + dy[i];
            if(vis[x][y])
                continue;
            if(a[x][y] == 3 - c)
                vis[x][y] = 1, Q.push({x, y});
        }
    }

    ans += col[1] * col[2];
}

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

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            char c;
            cin >> c;

            if(c == '#')
                a[i][j] = 2;
            else
                a[i][j] = 1;
        }
    }

    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w; j++){
            if(!vis[i][j])
                bfs(i, j);
        }
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 5020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;

    for(int i=1;i<=3500;i++){
        for(int j=i;j<=3500;j++){
            if(4*i*j-N*i-N*j<=0) continue;
            if((N*i*j)%(4*i*j-N*i-N*j)==0){
                cout << i << " " << j << " " << (N*i*j)/(4*i*j-N*i-N*j) << endl;
                return 0;
            }
        }
    }



}


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

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

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

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

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

int main() {
  string s[3];
  rep(i, 3) {
    cin >> s[i];
  }

  vector<queue<char>> q(3);
  rep(i, 3) {
    rep (j, s[i].size()) {
      q[i].push(s[i][j]);
    }
  }

  int index = 0;
  while (1) {
    if (q[index].empty()) {
      char ans = 'A' + index;
      P(ans);
      break;
    }
    int tmp = q[index].front();
    q[index].pop();
    index = tmp - 'a';
  }



  return 0;
}


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

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

    vector<int> a(N);
    int res2 = 0;
    int res4 = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (a[i] % 2 == 0 && a[i] % 4 != 0) {
            res2++;
        }
        else if (a[i] % 4 == 0) {
            res4++;
        }
    }

    if (res4 >= N / 2) {
        cout << "Yes" << endl;
    }
    else {
        if (res2 == N - res4 * 2) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 640
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#define N 200005
#define lowbit(o) o&(-o)
using namespace std;
int i,j,k,l,s,n,m,R[N],L[N],q[N],ans,G[N],r;
int a[N],b[N];
char c[N];
inline bool cmp(int x,int y) {
	return R[x]<R[y];
}
int main() {
	scanf("%s",c+1);
	n=strlen(c+1);
	for (i=1;i<=n;i++) a[i]=c[i]-48,L[i]=R[i]=100000000;
	scanf("%s",c+1);
	for (i=1;i<=n;i++) b[i]=c[i]-48;
	for (i=1;i<=n;i++) for (j=1;j<=n;j++) if (b[j]) L[i]=min(L[i],(i-j+n)%n),R[i]=min(R[i],(j-i+n)%n);
	ans=100000000;
	for (i=1;i<=n;i++) {
		r=0; k=i;
		for (j=1;j<=n;j++) {
			if (a[k]!=b[j]) q[++r]=k;
			k%=n; k++;
		}
		sort(q+1,q+1+r,cmp);
		G[r+1]=0;
		for (k=r;k;k--) G[k]=max(G[k+1],L[q[k]]);
		
		for (k=0;k<=r;k++) {
			//workL:
			ans=min(ans,(R[q[k]]+max((i-j+n)%n,G[k+1]))*2-(i-j+n)%n+r);
			//workR:
			ans=min(ans,(G[k+1]+max((j-i+n)%n,R[q[k]]))*2-(j-i+n)%n+r);
		}
	}
	if (ans>=100000000) ans=-1;
	printf("%d\n",ans);
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int h[100005];
int dp[100005];
int main(){
    int n, k;
    scanf("%d%d", &n, &k);
    for(int i=1;i<=n;i++){
        scanf("%d", &h[i]);
        dp[i] = 2e9;
        if(i == 1) dp[i] = 0;
        for(int j=i-1;j>=max(1, i-k);j--){
            dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]));
        }
    }   
    printf("%d\n", dp[n]);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
//-std=c++11
#define print(x) printf("%.12f",x);
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#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 pii pair < int, int >
#define iter ::iterator
#define forit(a) for(it=a.begin();it!=a.end();it++)
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod = 998244353;
const int N = (int)2e5 + 5;

void solve(){
	int n;
	cin>>n;
	double sum=0;
	int a[n];
	rep(i,n){
		cin>>a[i];
		sum+=1.0/a[i]*1.0;
	}
	double ans=1.0/sum;
	printf("%.12f",ans);
}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map
#define mtv(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)

vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out( 
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cout << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    stringstream ss; ss << H;
    cout << args[idx] << "- " << ss.str() << ", ";
    debug_out(args, idx + 1, LINE_NUM, T...);
}


void doit(){
	ll n,i,j;
	cin >> n;
	if(n <= 9){
		cout << n << nl;
		return ;
	}
	queue<ll>q;
	rep(i,1,10)q.push(i);
	ll cur = 0;
	while(true){
		ll k = q.front();
		q.pop();
		cur++;
		if(cur == n){
			cout << k << nl;
			return;
		}
		if(k%10 != 0)q.push(10*k+(k%10)-1);
		q.push(10*k+(k%10));
		if(k%10 != 9)q.push(10*k+(k%10)+1);
	}
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> t(n);
  for (int i = 0; i < n; i++) {
    cin >> x.at(i);
    t.at(i) = x.at(i);
  }
  sort(t.begin(), t.end());
  int a = t.at(t.size() / 2 - 1);
  int b = t.at(t.size() / 2);
  for (int i = 0; i < n; i++) {
    if (a == b) {
      cout << a << endl;
    } else {
      if (x.at(i) <= a) {
        cout << b << endl;
      }
      if (x.at(i) >= b) {
        cout << a << endl;
      }
    }
  }
  return 0;
}


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 
	int n;
	cin >> n;
	int t , cnt = 0;
	rep(i , n){
		cin >> t;
		cnt += t % 2;
	}
	if(cnt % 2)dier("NO");
	dier("YES");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll h,n;
  cin>>h>>n;
  vll a(n),b(n);
  ll cu=0;
  rep(i,n) {
    cin>>a[i]>>b[i];
    cu=max(cu,a[i]);
  }
  vvll dp(n+10,vll(cu+h+1,INF));
  dp[0][0]=0;
  rep(i,n){
    rep(j,h+cu){
      if(a[i]>j){
        dp[i+1][j]=dp[i][j];
      }
      else{
        dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i]]+b[i]);
      }
    }
  }
  ll ans=INF;
  for(int i=h;i<=h+cu;i++){
    if(ans>dp[n][i]){
      ans=dp[n][i];
    }
  }

  COUT(ans);
}


Measured memory_bytes: 88832
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    S = input()
    n = len(S)
    if S != S[::-1]:
        print("No")
        return
    h = n // 2
    pre = S[:h]
    suf = S[h+1:]
    print("Yes" if pre==pre[::-1] and suf==suf[::-1] else "No")
resolve()

Measured memory_bytes: 38384
package main

import (
	"fmt"
)

func main() {
	// Code for A - Wanna go back home
	var S string
	fmt.Scanf("%s", &S)

	count := make(map[string]int, len(S))
	for i := 0; i < len(S); i++ {
		count[S[i:i+1]]++
	}

	var flag1 int = 0
	if (count["W"] == 0 && count["E"] != 0) || (count["W"] != 0 && count["E"] == 0) {
		flag1 = 0
	} else {
		flag1 = 1
	}

	var flag2 int = 0
	if (count["N"] == 0 && count["S"] != 0) || (count["N"] != 0 && count["S"] == 0) {
		flag2 = 0
	} else {
		flag2 = 1
	}

	if flag1 == 1 && flag2 == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1868
#include <iostream>
#include <vector>
 
using namespace std;
 
#define MAX 500000
#define INF (1<<29)
 
vector<int> vec;
 
void make(){
    bool prime[MAX];
    fill(prime,prime+MAX,true);
    prime[0] = prime[1] = false;
    for(int i = 2 ; i < MAX ; i++){
	if(prime[i]){
	    vec.push_back(i);
	    for(int j = 2*i ; j < MAX ; j+=i){
		prime[j] = false;
	    }
	}
    }
}
 
 
int main(){
    int M,A,B;
  
    make();
    while(cin >> M >> A >> B, (M | A | B)){
	int a,b,max = 0;
	for(int i = 0 ; i < (int)vec.size() ; i++){
	    for(int j = 0 ; j <= i ; j++){
		if(vec[i]*vec[j] > M) break;
		if(A*vec[i] <= vec[j]*B){
		    if(vec[i]*vec[j] > max){
			max = vec[i]*vec[j];
			a = vec[j]; b = vec[i];
		    }
		}
	    }
	}
	cout << a << " " << b << endl;
    }
    return 0;
}

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


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<int> a(n,0);
    vector<int> b(n,0);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    int ans = -1e9;
    for(int mask = 0; mask < (1<<n); mask++){
        int cur = 0;
        for(int i=0;i<n;i++){
            if((mask>>i)&1){
                cur += a[i] - b[i];
            }
        }
        ans = max(ans, cur);
    }
    cout<<ans;
    return 0;
}


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


int main(){
    int n;
    cin>>n;
    long long str[n+1];
    str[0] = 2;
    str[1] = 1;
    int i=2;
    while(i<=n){
        str[i] = str[i-1] + str[i-2];
        i++;
    }

    printf("%lld\n", str[n]);
    return 0;
}

Measured memory_bytes: 256
//ABC-141-E
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;
const long long B = 1007;

template<typename T>
vector<int> Zalgorithm(const vector<T> & v){
    int n = v.size();
    vector<int> res(n);
    res[0] = n;
    int i = 1, j = 0;
    while(i < n){
        while(i + j < n && v[j] == v[i + j]) j++;
        res[i] = j;
        if(j == 0){
            i++;
            continue;
        }
        int k = 1;
        while(i + k < n && k + res[k] < j){
            res[i + k] = res[k];
            k++;
        }
        i += k;
        j -= k;
    }
    return res;
}

vector<int> Zalgorithm(const string & s){
    return Zalgorithm(vector<char>(s.begin(), s.end()));
}

signed main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans = 0;
    rep(i,n){
        vector<int> z = Zalgorithm(s.substr(i));
        rep(j,z.size()){
            if(z[j] <= j){
                ans = max(ans, z[j]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define I int
#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define P(a) printf("%d\n",a)
#define PL(a) printf("%lld\n",a)
#define PT(t) printf("Case %d: ",t)
#define PB(a) push_back(a)
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define ll long long 
using namespace std;
#define mx 500004
#define md 1000000007ll
typedef pair<int, int >P;
typedef vector<ll>V;

////////define value/////
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}

int main(){
    int n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    if(m<=n)s[m-1] = tolower(s[m-1]);
    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

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

  if(a < b)
    puts("a < b");
  if(a > b)
    puts("a > b");
  if(a == b)
    puts("a == b");

  return 0;
  
}



Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int main()
{	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
        
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll poss1= a*c;
	ll poss2= a*d;
	ll poss3= b*c;
	ll poss4= b*d;
	cout<<max({poss1,poss2,poss3,poss4});
	nl;
}

Measured memory_bytes: 3664
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int n =s.nextInt();
        long arr[] = new long[n];
        for(int i=0;i<n;i++)arr[i]=s.nextInt();
        long sum = 0;
        for(int i=1;i<n;i++){
            if(arr[i]<arr[i-1]){
                sum+=arr[i-1]-arr[i];
                arr[i]=arr[i-1];
            }
        }
        System.out.println(sum);
    }

}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

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

int main() {
  int n,a[100010];
  scanf("%d", &n);
  for (int i=0;i<n;++i) {
    scanf("%d", a+i);
  }
  sort(a, a+n);
  int l = 0, r = n-1;
  while (l<r) {
    int k = (l+r+1)>>1;
    if (a[k]<=a[n-1]/2) l = k;
    else r = k-1;
  }
  r = l+1;
  if (r<n) {
    r = a[n-1]-a[r];
    if (r>a[l]) ++l;
  }
  printf("%d %d\n", a[n-1], a[l]);
  return 0;
}

Measured memory_bytes: 640
/*
First, solve the problem.Then write the code. - John Johnson
@author: returnAC
*/
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define need_for_speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); // Thanks Joshua :)
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);

signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	need_for_speed;
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	int cnt = 0;
	for(int i=1;i<n-1;i++)
	{
		vector<int> z; z.push_back(a[i]); z.push_back(a[i-1]); z.push_back(a[i+1]);
		sort(z.begin(),z.end());
		if(z[1]==a[i])++cnt;
	}
	cout<<cnt<<endl;
}

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

long long int v;
vector < vector< long long int > > g;
vector< long long int > match;
bool used[1001];

long long int gcd( long long int x, long long int y ) {

  if ( y > x ) swap( x, y );

  while( y > 0 ) {

    long long int k = x % y;
    x = y;
    y = k;

  }

  return x;

}

bool dfs( long long int x ) {

  used[x] = true;

  for ( long long int i = 0; i < g[x].size(); i++ ) {

    long long int k = g[x][i];
    long long int w = match[k];

    if ( w < 0 || !used[w] && dfs(w) ) {

      match[x] = k;
      match[k] = x;
      return true;

    }

  }

  return false;
}

int main() {

  while( true ) {

    long long int m, n;
    cin >> m >> n;
    if ( m == 0 ) break;
    v = m + n;

    vector< long long int > b, r;

    for ( long long int i = 0; i < m; i++ ) {
      long long int in;
      cin >> in;
      b.push_back( in );
    }

    for ( long long int i = 0; i < n; i++ ) {
      long long int in;
      cin >> in;
      r.push_back( in );
    }

    g.clear();
    for ( long long int i = 0; i < v; i++ ) {
      vector< long long int > vec;
      g.push_back( vec );
    }

    for ( long long int i = 0; i < m; i++ ) {
      for ( long long int j = 0; j < n; j++ ) {
	if ( gcd( b[i], r[j] ) > 1 ) {
	  g[i].push_back( j+m );
	  g[j+m].push_back( i );
	}
      }
    }

    long long int ans = 0;

    match.clear();
    for ( long long int i = 0; i < v; i++ ) {
      match.push_back( -1 );
    }

    for ( long long int x = 0; x < v; x++ ) {

      if ( match[x] < 0 ) {

	for ( long long int j = 0; j < v; j++ ) {
	  used[j] = false;
	}

	if ( dfs( x ) == true ) {
	  ans++;
	}

      }

    }

    cout << ans << endl;

  /*
  for ( long long int i = 0; i < m; i++ ) {
    g[i].push_back( m+n );
  }
  for ( long long int i = 0; i < n; i++ ) {
    g[m+i].push_back( m+n+1 );
  }
  */

  }

  return 0;

}

Measured memory_bytes: 4160
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int ll;
typedef pair<ll, ll> pll;
 
#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)
 
const ll MOD = 1000000007;
const ll INF = (ll) 1e15;
 
ll H, W;
string S[30];
bool U[25][25];
 
ll x[4] = {1, 0, -1, 0};
ll y[4] = {0, 1, 0, -1};
 
struct Data {
    pll g;
    ll c;
};
 
ll solve(pll s, pll g) {
    memset(U, 0, sizeof(U));
    queue<Data> q;
    q.push(Data{s, 0});
    U[s.first][s.second] = true;
    while (!q.empty()) {
        auto t = q.front();
        q.pop();
 
        if (t.g.first == g.first && t.g.second == g.second) {
            return t.c;
        }
        REP(i, 4) {
            ll nx = t.g.first + x[i];
            ll ny = t.g.second + y[i];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W)
                continue;
            if (S[nx][ny] == '#' || U[nx][ny])
                continue;
            U[nx][ny] = true;
            q.push(Data{pll(nx, ny), t.c + 1});
        }
    }
 
    return 0;
}
 
int main() {
    cin >> H >> W;
    REP(i, H) {
        cin >> S[i];
    }
 
    ll ans = 0;
    REP(i, H) {
        REP(j, W) {
            if (S[i][j] == '#')
                continue;
            REP(k, H) {
                REP(l, W) {
                    if (S[i][j] == '#')
                        continue;
                    ans = std::max(ans, solve(pll(i, j), pll(k, l)));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
s = ns()

# RGBRGBGBBBB

r = [0] * (n + 1)
g = [0] * (n + 1)
b = [0] * (n + 1)

for i in range(n):
    r[i + 1] = r[i]
    g[i + 1] = g[i]
    b[i + 1] = b[i]
    if s[i] == 'R':
        r[i + 1] += 1
    elif s[i] == 'G':
        g[i + 1] += 1
    else:
        b[i + 1] += 1

ans = 0
for i in range(n):
    t = 0
    for j in range(i + 1, n):
        if s[i] != s[j]:
            if (s[i] == 'R' and s[j] == 'G') or (s[i] == 'G' and s[j] == 'R'):
                t += b[n] - b[j + 1]
            elif (s[i] == 'R' and s[j] == 'B') or (s[i] == 'B' and s[j] == 'R'):
                t += g[n] - g[j + 1]
            elif (s[i] == 'G' and s[j] == 'B') or (s[i] == 'B' and s[j] == 'G'):
                t += r[n] - r[j + 1]
    j = 1
    while i + j * 2 < n:
        if s[i] != s[i + j] and s[i] != s[i + j * 2] and s[i + j] != s[i + j * 2]:
            t -= 1
        j += 1
    ans += t

print(ans)

Measured memory_bytes: 68944
#include <bits/stdc++.h>
 
using namespace std;
 
long long dp[100000][3];
long long a[100000];
long long b[100000];
long long c[100000];
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    cin >> a[0] >> b[0] >> c[0];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i = 1; i < n; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i];
    }
    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
    
    return 0;
}

Measured memory_bytes: 4992