akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    u32 N;
    string S;
    cin >> N >> S;
    u32 sum = 0;
    for (u32 i = 2; i < N; i++) {
        string sub = S.substr(i - 2, 3);
        if (sub == "ABC") sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	Scanner sc = new Scanner(System.in);
	int a; 

	public void syori(){
		for(int u=0;u<10;u++){
			int suji = sc.nextInt();
			a += suji;
		}
	}

	public void out(){
		System.out.println(a);
	}


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Main m = new Main();

		m.syori();
		m.out();
	}
}

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

using namespace std;


int main() {
    string x;
    while (cin >> x){
        if (x == (string)"0") break;
        long s = 0;
        for (long i = 0; i < x.size(); i++) s += (char)x[i] - (long)'0';
        cout << s << endl;
        }
    return 0;
}

Measured memory_bytes: 1192
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                String input = sc.next();
                char[] xx = new char[10];
                xx[2]='k';
                xx[3]='s';
                xx[4]='t';
                xx[5]='n';
                xx[6]='h';
                xx[7]='m';
                xx[8]='y';
                xx[9]='r';
                xx[0]='w';

                for (int i = 0; i < input.length(); i+=2) {
                        int num = Character.getNumericValue(input.charAt(i));
                        if (num != 1 && num != 0) {
                                System.out.print(xx[num]);
                        } else if(num == 0) {
                                if (input.charAt(i + 1) == 'U') {
                                        System.out.print("nn");
                                } else {
                                        System.out.print('w');
                                        if (input.charAt(i + 1) == 'D') {
                                                System.out.print('o');
                                        } else {
                                                System.out.print('a');
                                        }
                                }
                                continue;
                        }
                        if (input.charAt(i + 1) == 'T' ) {
                                System.out.print('a');
                        }
                        if (input.charAt(i + 1) == 'L' ) {
                                System.out.print('i');
                        }
                        if (input.charAt(i + 1) == 'U' ) {
                                System.out.print('u');
                        }
                        if (input.charAt(i + 1) == 'R' ) {
                                System.out.print('e');
                        }
                        if (input.charAt(i + 1) == 'D' ) {
                                System.out.print('o');
                        }
                }
                System.out.println("");
        }
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  string s;
  cin >> s;
  int k;
  cin >> k;
  for(char &x : s){
    if(x == 'a') continue;
    if('z' - x + 1 <= k){
      k -= 'z' - x + 1;
      x = 'a';
    }
  }
  k %= 26;
  for(int i = s.size() - 1; i >= 0 ; i -- ){
    s[i] += k;
    k = 0;
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 592
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 200000+5;

using namespace std;
struct Edge{
    int x,y;
    int dis;
    Edge(){}
    Edge(int x,int y,int dis):x(x),y(y),dis(dis){}
    bool operator <(const Edge &rhs)const{
        return dis<rhs.dis;
    }
}edge[N];
int tot;
struct Node{
    int x,y;
}node[N];
int father[N];
 
bool cmpX(int a,int b){
    return node[a].x<node[b].x;
}
bool cmpY(int a,int b){
    return node[a].y<node[b].y;
}
int Find(int x){
    if(father[x]!=x)
        return father[x]=Find(father[x]);
    return x;
}
int n;
int Kruskal(){
    for(int i=1;i<=n;i++)
        father[i]=i;
 
    int mst=0;
    sort(edge+1,edge+1+tot);
    for(int i=1;i<=tot;i++){
        int x=Find(edge[i].x);
        int y=Find(edge[i].y);
        if(x!=y){
            mst+=edge[i].dis;
            father[x]=y;
        }
    }
    return mst;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&node[i].x,&node[i].y);
 
    for(int i=1;i<=n;i++)
        father[i]=i;
    sort(father+1,father+1+n,cmpX);
    for(int i=1;i<n;i++){
        int x=father[i];
        int y=father[i+1];
        int dis=node[y].x-node[x].x;
        edge[++tot]=Edge(x,y,dis);
    }
 
    for(int i=1;i<=n;i++)
        father[i]=i;
    sort(father+1,father+1+n,cmpY);
    for(int i=1;i<n;i++){
        int x=father[i];
        int y=father[i+1];
        int dis=node[y].y-node[x].y;
        edge[++tot]=Edge(x,y,dis);
    }
 
    int mst=Kruskal();
    printf("%d\n",mst);
 
    return 0;
}


Measured memory_bytes: 4096
#include<stdio.h>
int main()
{
	int D;
	scanf("%d\n",&D);
	if(D==22){
		printf("Christmas Eve Eve Eve");
	}
	else if(D==23){
		printf("Christmas Eve Eve");
	}
	else if(D==24){
		printf("Christmas Eve");
	}
	else if(D==25){
		printf("Christmas");
	}
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int n;cin>>n;
  if(n%2!=0) {
    cout<<"No"<<endl;
    return 0;
  }
  string s;
  cin>>s;
  n/=2;
  rep(i,n){
    if(s[i]!=s[i+n]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<cstring>
using namespace std;
typedef long long ll;
int main(){
	string s;
	cin>>s;
	ll n=s.size();
	bool flag=true;
	for(ll i=0;i<(n-1)/2;i++)
	{
		if(s[i]!=s[(n-1)/2-1-i])
		{
			flag=false;
		}
	}

	for(ll i=(n+3)/2;i<n;i++)
	{
		if(s[i]!=s[n-2-i+(n+3)/2])
		{
			flag=false;
		}
	}
	for(ll i=0;i<n;i++)
	{
		if(s[i]!=s[n-1-i])
		{
			flag=false;
		}
	}
	if(flag) cout<<"Yes"<<endl;
	else	cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    long long ans = 0;
    int N;
    long long W;
    vector<long long> w,v;
    long long dp[101][301];
    
    
    cin >> N >> W;
    w.resize(N);
    v.resize(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> w[i] >> v[i];
    }
    
    for ( int i = 0; i <= 100; i++ ) {
    for ( int j = 0; j <= 300; j++ ) {
        dp[i][j] = LLONG_MIN;
    }
    }
    dp[0][0] = 0;
    
    for ( int i = 0; i < N; i++ ) {
        for ( int j = N-1; j >= 0; j-- ) {
            for ( int k = 300; k >= 0; k-- ) {
                if ( dp[j][k] != LLONG_MIN && ( j*w[0]+k+w[i] ) <= W ) {
                    dp[j+1][ k+w[i]-w[0] ] = max( dp[j][k] + v[i],  dp[j+1][ k+w[i]-w[0] ] );
                }
            }
        }
    }
    
    for ( int i = 0; i <= N; i++ ) {
        for ( int k = 300; k >= 0; k-- ) {
            if ( dp[i][k] != LLONG_MIN ) { ans = max( ans, dp[i][k] ); }
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  int N;
  cin >> N;
  vector<int> B(N);
  for(int i=0;i<N;i++){
    int A;
    cin >> A;
    B.at(A-1)=i+1;
  }
  for(int i=0;i<N;i++){
    cout << B.at(i);
    if(i==N-1){
      cout << endl;
    }
    else{
      cout << " ";
    }
  }
}   

Measured memory_bytes: 3740
#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  2e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
ll a[MAXN], minx[MAXN];
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
	minx[0]=MAXN; 
	
	ll n, res=0;
	
	cin>>n;
	foo(i,1,n){
		cin>>a[i];
		minx[i]=min(minx[i-1],a[i]);
		if(minx[i]>=a[i]){
			res++;
		}
	}
	
	cout<<res;
}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(t--){
		MAIN();
	}

}

Measured memory_bytes: 9600
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())

x = ii()

ct = 0
for i in range(1,10):
    for j in range(1,10):
        if(x==i*j):
            ct = 1
if(ct==1):
    print("Yes")
else:
    print("No")

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

using namespace std;

int main(){
    long long n, uk = 0;
    cin >> n;
    long long arr[n + 1];
    for(long long i = 0; i <= n; ++i){
        cin >> arr[i];
    }
    for(long long i = 0; i < n; ++i){
        long long tmp; cin >> tmp;
        if(arr[i] > tmp){
            arr[i] -= tmp;
            uk += tmp;
        }else{
            tmp -= arr[i];
            uk += arr[i];
            arr[i] = 0;
            if(tmp >= arr[i + 1]){
                uk += arr[i + 1];
                arr[i + 1] = 0;
            }else{
                arr[i + 1] -= tmp;
                uk += tmp;
            }
        }
    }
    cout <<  uk;
    return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n;
   cin >> n;
   cout << n/2 + n%2 << endl;
   return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> s;
typedef long long int ll;

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}

char A,B;

int main(){
  scanf("%c %c",&A,&B);
  if(A-B > 0){
    printf(">\n");
    return 0;
  }
  if(A-B == 0){
    printf("=\n");
    return 0;
  }
  printf("<\n");
}


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

int main(){
    int vec[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int a;
    cin >> a;

    cout  << vec[a-1] << endl;

}

Measured memory_bytes: 256
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d, e, H, W, L;
long long A[200005] = {};
long long B[500][500] = {};
long long C[205][205] = {};
long long D[200005] = {};
long long E[200005] = {};
bool f, ff;
string S[2];
set <long long>sll;
pl bufpl;
vector <long long>vl;
vector <pl>vpl;
vector <string> vs;
set<ll> llset;

/*struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


bool fs[2005][2005] = {};

int main() {


	cin >> a >> b;

	cout << (b - a) * 2 + a << endl;

	return 0;

}


Measured memory_bytes: 2304
import sys
from _collections import deque
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    SA = readline().decode('utf-8').strip()
    SB = readline().decode('utf-8').strip()
    SC = readline().decode('utf-8').strip()
    A = deque(SA)
    B = deque(SB)
    C = deque(SC)
    now = A.popleft()
    while True:
        if now=='a':
            if not A:
                print('A')
                break
            else:
                now = A.popleft()
        elif now=='b':
            if not B:
                print('B')
                break
            else:
                now = B.popleft()
        else:
            if not C:
                print('C')
                break
            else:
                now = C.popleft()

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

stack<int> S;
vector<pair<int,int>> P;
vector<int> V;

int main() {
  string s; cin >> s;
  for (int i = 0; i < s.length(); i++) {
    char c = s[i];
    if (c == '\\')
      S.push(i);
    if (c == '/') {
      if (!S.empty()) {
        int t = S.top(); S.pop();
        P.push_back(make_pair(t,i));
      }
    }
  }
  if (P.empty()) {
    cout << 0 << endl << 0 << endl;
    return 0;
  }
  int area = 0;
  int lake_end = -1;
  sort(P.begin(), P.end());
  for (auto it = P.begin(); it != P.end(); ++it) {
    int l = (*it).first; int r = (*it).second;
    if (lake_end < l && area != 0) {
      V.push_back(area);
      area = 0;
    }
    if (area == 0)
      lake_end = r;
    area += ((r-l+1)+(r-l-1))*1/2;
  }
  V.push_back(area);
  cout << accumulate(V.begin(), V.end(), 0) << endl;
  cout << V.size() << ' ';
  for (int i = 0; i < V.size(); i++) {
    cout << V[i] << (i == V.size()-1 ? '\n' : ' ');
  }
}



Measured memory_bytes: 3344
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    using ll = long long;
    
    int n;
    cin >> n;
    
    vector<ll> a(n);
    int m_c = 0;
    
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        
        if (a[i] < 0) {
            m_c++;
            a[i] = -a[i];
        }
    }
    
    sort(a.begin(), a.end());
    
    ll ans = 0;
    
    for (int i = 0; i < n; i++) {
        ans += a[i];
    }
    
    if (m_c % 2 == 1) {
        ans -= a[0] * 2;
    }
    
    cout << ans << endl;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll power(ll x, ll y, ll p = MOD){  
    ll res = 1LL; 
    x = x % p;
    if (x == 0) return 0;
    while (y > 0){
        if (y & 1LL)  
            res = (res*x) % p;
        y = y>>1LL; 
        x = (x*x) % p;  
    }  
    return res;  
}  

int main(){
	IO
	int n, k;
	cin >> n >> k;
	int arr[n];
	rep(i, 0, n){
		cin >> arr[i];
	}

	int dp[n+1];
	rep(i, 0, n+1) dp[i] = INF;
	dp[0] = 0;
	rep(i, 0, n){
		rep(j, 1, k + 1){
			if(i+j<n)
				dp[i+j] = min(dp[i+j], dp[i] + abs(arr[i+j] - arr[i]));
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 4380
from itertools import permutations
from math import sqrt


def calc_dist(a, b):
    return sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)


def main():
    N = int(input())
    town_list = [tuple(map(int, input().split())) for _ in range(N)]
    ans_list = []

    a = permutations(town_list, len(town_list))

    for v in a:
        tmp = 0
        for i in range(len(v) - 1):
            tmp += calc_dist(v[i], v[i + 1])
        ans_list.append(tmp)

    print(sum(ans_list) / len(ans_list))


if __name__ == "__main__":
    main()


Measured memory_bytes: 4400
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut cnts = vec![0 as i64; 5];
    for _ in 0..n {
        let c = read::<String>().chars().collect::<Vec<char>>()[0];
        let index = match c {
            'M' => Some(0),
            'A' => Some(1),
            'R' => Some(2),
            'C' => Some(3),
            'H' => Some(4),
            _ => None,
        };
        if index != None { cnts[index.unwrap()] += 1; }
    }
    let mut ans = 0 as i64;
    for i in 0..5 {
        for j in i+1..5 {
            for k in j+1..5 {
                ans += cnts[i] * cnts[j] * cnts[k];
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int n;
    string s;
    int ans=0;
    cin>>n>>s;
    char tmp=s[0];
    for(int i=0;i<n;i++){
        if(tmp==s[i])continue;
        else{
            tmp = s[i];
            ans++;
        }
    }
    cout<<ans+1<<endl;
}

Measured memory_bytes: 512
a = int(input())
b= int(input())
c = int(input())
d = int(input())
e = int(input())
x = int(input())

f  = True 

la = [a,b,c,d,e]
lb = [a,b,c,d,e]

for e, v in enumerate(la):
    for e2,v2 in enumerate(lb):
        if e < e2:
            if v2 - v > x:
                f = False

if f:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef int64_t ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



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

    vector<string> vec(N);
    rep(i, N) {
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    rep(i, N) {
        cout << vec.at(i);
    }
    return 0;
}

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

typedef long long ll;
const ll MOD = 998244353;
const int N = 3e5;

ll dmod(ll x){
	return x%MOD;
}

ll fe(ll x, ll p){
	if(p==0) return 1ll;
	if(p==1) return x;
	ll ret = fe(x,p/2);
	ret = dmod(ret*ret);
	if(p&1) ret = dmod(ret*x);
	return ret;
}

ll fakto[N+5];

void pre(){
	fakto[0] = 1ll;
	for(int i=1;i<=N;i++){
		fakto[i] = dmod(fakto[i-1] * (ll)i);
	}
	return;
}

ll nCr(ll n, ll r){
	ll inv = dmod(fakto[r] * fakto[n-r]);
	inv = fe(inv,MOD-2);
	return dmod(inv*fakto[n]);
}

int n;
ll a,b,k;


int main(){
	pre();
	scanf("%d",&n);
	scanf("%lld%lld%lld",&a,&b,&k);
	ll ans = 0ll;
	for(int i=0;i<=n;i++){
		ll dk = k - a*(ll)i;
		if(dk < 0) break;
		if(dk%b != 0) continue;
		ll bagi = dk/b;
		if(bagi > n) continue;
		ll ret = nCr(n,i);
		ret = dmod(ret*nCr(n,bagi));
		ans = dmod(ans+ret);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2560
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#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 int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define sz(x) int(x.size())
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> oset;

// find_by_order(k) returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

const int mod = 1e9 + 7;
const int inf = 9e18;
const int N = 2e5 + 5;

void solve(){
    int i,n,sum=0;
    cin>>n;
    for(i=1;i<=n;++i){
        if(i%3 && i%5)
            sum+=i;
    }
    cout<<sum;
}

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

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
using namespace std;
typedef long long longlong;
typedef long long LL;
typedef pair<int, pair<int, int>> Trio;
typedef pair<int, int> Pair;
 
int main(void) {
	int n,k,ma=0;
	cin >>n>>k;
	vector<int> l(n);
	for(int i=0;i<n;i++){
	cin >>l[i];
	}
	sort(l.begin(),l.end(),greater<int>());
	for(int i=0;i<k;i++){
	ma+=l[i];
	}
	cout <<ma<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())

def dfs(s, n):
    if  int(s) > n:
        return 0
    ret = 0
    if all([c in s for c in '753']):
        ret = 1
    for c in '753':
        ret += dfs(s + c, n)
    return ret 

print(dfs('0', n))


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

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll count,ans,res;
    count = n / (a+b);
  res = n % (a+b);
    if(res <= a) ans = a * count + res;
    else ans = a * count + a;
    cout << ans << endl;


}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <complex>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<LL> VL;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef complex<double> CD;

PDD solve(double p1x, double p1y, double p2x, double p2y, double px, double py) {
	PDD q;

	if (p1x == p2x) {
		q = mp(p1x, py);
	}
	else if (p1y == p2y) {
		q = mp(px, p1y);
	}
	else {
		double l1s, l1y, l2s, l2y;
		l1s = (p1y - p2y) / (p1x - p2x);
		l1y = p1y + l1s * (p1x * -1);
		l2s = (1 / l1s)*-1;
		l2y = py + l2s * (px*-1);

		//cout << "line1 : y=" << l1s << "*x+" << l1y << endl;
		//cout << "line2 : y=" << l2s << "*x+" << l2y << endl;

		double ax, ay;
		ax = (l2y - l1y) / (l1s - l2s);
		ay = l1s * ax + l1y;
		q = mp(ax, ay);
	}

	PDD re = mp(q.first * 2 - px, q.second * 2 - py);

	return re;
}


int main() {
	double w, x, y, z; cin >> w >> x >> y >> z;
	int q; cin >> q;
	rep(i, q) {
		double a, b; cin >> a >> b;
		PDD ans = solve(w, x, y, z, a, b);
		printf("%.20f %.20f\n", ans.first, ans.second);
	}
}


Measured memory_bytes: 3300
n=int(input())
ans=0
X=[[0]*10 for i in range(10)]
for i in range(1,n+1):
    t=(int)(str(i)[0])
    b=(int)(str(i)[-1])
    X[t][b]+=1

for i in range(1,10):
    for j in range(1,10):
        ans+=X[i][j]*X[j][i]

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#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 pb push_back
#define pii pair<int,int>
#define mp make_pair
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 str = "";
	string s = "";
	string t = "";
	int n = 0;
	int m = 0;
	int l = 0;
	cin >> str >> l;
	for(int j = 0; j < l; ++j){
		cin >> s >> n >> m;
		if(s == "replace"){
			cin >> t;
			str.replace(n, t.size(), t);
		}
		if(s == "print"){
			for (int i = n; i <= m; ++i)
			{
				cout << str[i];
			}
			cout << endl;
		}
		if(s == "reverse"){
			for (int i = 0; i <= m - n; ++i)
			{
				str.insert(n+i, 1, str[m]);
				str.erase(m+1, 1);
			}
		}
	}
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int MX = 1e3;
const ll INF = 1e9;

int h, w, sx, sy, ex, ey;

bool grid[MX][MX], vis[MX][MX];
int cost[MX][MX];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> h >> w >> sx >> sy >> ex >> ey;
	--sx, --sy, --ex, --ey;
	rep(i, 0, h) {
		string line;
		cin >> line;
		rep(j, 0, w) {
			grid[i][j] = (line[j] == '.');
			cost[i][j] = INF;
		}
	}
	
	set<pair<int, pii>> q;
	q.insert({0, {sx, sy}});
	cost[sx][sy] = 0;
	while (!q.empty()) {
		pii v = q.begin()->second;
		int x = v.first, y = v.second;
		q.erase(q.begin());
		vis[x][y] = true;
		// cout << "Visiting " << x << ' ' << y << '\n';
		rep(i, -2, 3) {
			rep(j, -2, 3) {
				int a = x + i, b = y + j;
				if (a < 0 || a >= h || b < 0 || b >= w) continue;
				if (vis[a][b]) continue;
				if (!grid[a][b]) continue;
				
				int diff;
				if (abs(i) + abs(j) <= 1) diff = 0;
				else diff = 1;
				
				if (cost[x][y] + diff < cost[a][b]) {
					q.erase({cost[a][b], {a, b}});
					cost[a][b] = cost[x][y] + diff;
					q.insert({cost[a][b], {a, b}});
				}
			}
		}
	}
	
	// rep(i, 0, h) {
		// rep(j, 0, w) {
			// cout << cost[i][j] << ' ';
		// }
		// cout << endl;
	// }
	
	if (cost[ex][ey] == INF) cout << -1;
	else cout << cost[ex][ey];
}


Measured memory_bytes: 9736
n,t = gets.split.map(&:to_i)
list = [[0,0]]+(1..n).map{gets.split.map(&:to_i)}.sort
dp = (0..n).map{[0]*(t)}

(1..n).each{|ni|
  a,b = list[ni]
  dpnim,dpni = dp[ni-1,2]
  (0..t-1).each{|ti|
    dpni[ti] = if ti-a >= 0 && dpnim[ti] < dpnim[ti-a]+b
      dpnim[ti-a]+b
    else
      dpnim[ti]
    end
  }
}
p (1..n).map{|ni|dp[ni-1][t-1]+list[ni][1]}.max

Measured memory_bytes: 72568
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9 + 5;
constexpr long long INFLL = 1LL << 62;
constexpr double eps = (1e-9);

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

  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(ALL(a));
  vector<ll> cs(n, 0);   // i番目以下の生き物すべてが合体したときの大きさ
  cs[0] = a[0];
  for (int i = 1; i < n; i++) {
    cs[i] = cs[i-1] + a[i];
  }
  int ans = 1;  // 最大の生き物はOK

  for (int i = n-2; i >= 0; i--) {
    if (cs[i] * 2 >= a[i+1]) ans++;  // 自分以下の生き物を全部吸収したら次の生き物を吸収できる？
    else break;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4748
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) throws Exception {
		List<Integer> list = new ArrayList<Integer>();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		// BufferedReader br = new BufferedReader(new FileReader("in1.txt"));
		// BufferedReader br = new BufferedReader(new FileReader("in2.txt"));
		int N = Integer.parseInt(br.readLine());
		String[] s_in = br.readLine().split(" ");
		for (int i = 0; i < N; i++)
			list.add(Integer.parseInt(s_in[i]));
		
		int cnt_swap = 0;
		for (int i = 0; i < N; i++) {
			// list[0..i-1]??????????????????
			for (int j = N - 1; j > 0; j--) {
				if (list.get(j) < list.get(j - 1)) {
					int tmp = list.get(j - 1);
					list.set(j - 1, list.get(j));
					list.set(j, tmp);
					cnt_swap++;
				}
			}
		}
		
		StringBuilder sb = new StringBuilder();
		for (int n : list) {
			sb.append(n);
			sb.append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		sb.append('\n');
		sb.append(cnt_swap);
		System.out.println(sb.toString());
	}
	
}

Measured memory_bytes: 18388
#include<iostream>

using namespace std;

int main()
{
	int a,b,c,d,l,r;
	cin>>a>>b>>c>>d;
	l=a+b;
	r=c+d;
	if(l==r) cout<< "Balanced" <<endl;
	else if(l>r) cout<<"Left"<<endl;
	else cout<<"Right"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;



vector<int64_t> prime_factorize_unique(int64_t n){
  vector<int64_t> res;
  for(int64_t i=2LL; i*i<=n; ++i){
    if(n%i == 0){
      res.push_back(i);
      while(n%i == 0){
        n/=i;
      }
    }
  }
  if(n!=1) res.push_back(n);
  return res;
}


int main(){
  LLI a,b;
  while(cin >> a >> b){
    LLI g = gcd(a,b);

    auto pf = prime_factorize_unique(g);
    
    
    cout << pf.size() + 1<< endl;
  }


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        int a,b,c,x;
        int output=0;
        int i,j,k;
        int ac,bc,cc;

        Scanner scan = new Scanner(System.in);
        a=scan.nextInt();
        b=scan.nextInt();
        c=scan.nextInt();
        x=scan.nextInt();

        for(i=0;i<=a;i++)
        {   
            for(j=0;j<=b;j++)
            {
                for(k=0;k<=c;k++)
                {
                    ac=500*i;
                    bc=100*j;
                    cc=50*k;
                    if(ac+bc+cc==x)
                    {
                        output++;
                    }

                }
            }
        }
        System.out.println(output);
    } 
}

Measured memory_bytes: 21844
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int main(){
  int N,a[210000],ans[210000];
  cin>>N;
  for(int i=1;i<=N;i++) cin>>a[i];
  int count=0,countA=0;
  for(int i=N;i>=1;i--,count=0){
    if(i*2>N) ans[i]=a[i];
    else{
      int temp=i*2;
      while(temp<=N){
        count+=ans[temp];
        temp+=i;
      }
      if(count%2!=a[i]) ans[i]=1;
    }
    if(ans[i]==1) countA++;
  }
  
  cout<<countA<<endl;
  int hantei=0;
  if(countA!=0){
    for(int i=1;i<=N;i++){
      if(ans[i]==1){
        if(hantei==0){
          cout<<i;
          hantei++;
        }else cout<<" "<<i;
      }
    }
    cout<<endl;
  }
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <atcoder/all>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
//#define inf 2000000000
#define inf 8000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;
using namespace atcoder;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
const int maxn=200005;
//i_am_noob
int n,a[maxn],b[maxn],ans[maxn]={0},pos[maxn],minn=inf,k;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    rep(n){
        cin >> a[i] >> b[i];
        a[i]--,b[i]--;
        pos[a[i]]=i;
    }
    k=n-1;
    rep(n){
        minn=min(minn,b[pos[i]]);
        if(n-1-i==minn){
            rep2(j,minn,k+1) ans[pos[n-1-j]]=k+1-minn;
            k=minn-1;
        }
    }
    rep(n) print1(ans[i]);
    return 0;
}


Measured memory_bytes: 9940
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BProductMax solver = new BProductMax();
        solver.solve(1, in, out);
        out.close();
    }

    static class BProductMax {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            long a = in.nextInt(), b = in.nextInt(), c = in.nextInt(), d = in.nextInt();
            out.println(func.max(a * c, a * d, b * c, b * d));
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class func {
        public static long max(long... v) {
            //Taken from @KharYusuf
            long max = Long.MIN_VALUE;
            for (long i : v) max = Math.max(max, i);
            return max;
        }

    }
}



Measured memory_bytes: 32444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll, ll, ll>>>;

// MOD確認

int main(){
   ll A,B,C,K;
   cin >> A >> B >> C >> K;
   rep(i,K){
      if(B <= A) B *=2;
      else if(C <= B) C*= 2;
      else break;
   }
   if(A < B && B < C) cout << "Yes" << endl;
   else cout << "No" << endl;
}

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

int n, m;
int a[305][305];
bool check[305];

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

	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) cin >> a[i][j];
	}
	
	// a[i][m + 1] = 0
	int rank = 0;
	for (int col = 1; col <= m; ++col) {
		int row = 0;
		for (int i = 1; i <= n; ++i) if (!check[i] && a[i][col]) row = i;
		if (!row) {
			++rank; continue;
		}
		check[row] = true;
		for (int i = 1; i <= n; ++i) if (i != row && a[i][col]) {
			for (int j = 1; j <= m; ++j) a[i][j] ^= a[row][j];
		}
	}
	
	// 2^(m + n - 1) - 2^(rank + n - 1)
	int tmp = 1, res = 1;
	static const int mod = 998244353;
	for (int i = 1; i <= m + n - 1; ++i) res = 2LL * res % mod;
	for (int i = 1; i <= rank + n - 1; ++i) tmp = 2LL * tmp % mod;
	
	res = (res - tmp) % mod;
	if (res < 0) res += mod;
	
	cout << res << endl;
}


Measured memory_bytes: 640
L,R = map(int,input().split())

if R-L >= 2019:
    ans = 0
else:
    ans = 4000
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            p = ((i%2019) * (j%2019))%2019
            if p < ans:
                ans = p

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  if(a%3==0 || b%3==0 || (a+b)%3==0) cout<<"Possible";
  else cout<<"Impossible";
  
  return 0;
}
  


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  const int m=100000;
  int *cnt=(int *)calloc(m+1,sizeof(int));
  int i;
  for(i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    cnt[a]++;
  }
  int x=0;
  int y=0;
  for(i=1;i<=m;i++){
    while(cnt[i]>=3){
      cnt[i]-=2;
    }
    if(cnt[i]>=2) y++;
    if(cnt[i]>=1) x++;
  }
  while(y>=2) y-=2;
  printf("%d\n",x-y);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 512
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007
#define MODB  998244353 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

ll chev(ll x, ll y, ll xx, ll yy){
	return max(abs(x-xx), abs(y-yy));
}
ll f(ll x, ll y, int d){
	if(d==0) return x-y;
	else return x+y;
}

int main() {
	ll ans = 0;
	ll tmp;
	int n; cin >> n;
	vector<ll> x(n), y(n);
	REP(i, n)cin >> x[i] >> y[i];
	REP(j, 2){
		ll maf = -LLINF, mif = LLINF;
		REP(i, n){
			maf = max(maf, f(x[i], y[i], j));
			mif = min(mif, f(x[i], y[i], j));
		}
		ans = max(ans, maf - mif);
	}
	cout << ans << endl;
}

Measured memory_bytes: 6420
#include <cstdlib>
#include <iostream>
#include <string>


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

  std::string a, b;
  std::cin >> a >> b;

  if (a.length() > b.length()) {
    std::cout << "GREATER" << std::endl;
  } else if (a.length() < b.length()) {
    std::cout << "LESS" << std::endl;
  } else if (a > b) {
    std::cout << "GREATER" << std::endl;
  } else if (a < b) {
    std::cout << "LESS" << std::endl;
  } else {
    std::cout << "EQUAL" << std::endl;
  }

  return EXIT_SUCCESS;
}


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

using namespace std;

int gcd(int a, int b) {
	for (; b; swap(a, b))
		a %= b;
	return a;
}

int main() {
	int n, x;
	cin >> n >> x;
	int g = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		g = gcd(g, abs(a - x));
	}
	cout << g << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

long long N;
long long ans;
long long ans_1;
long long ans_2;
long long tmp;
long long MIN = INF;

int main(){
	cin >> N;
	ans = N - 1;
	for (int i = 1; i <= sqrt(N); i++){
		if (N%i == 0){
			ans = min(ans, i + N / i - 2);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256