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

int main(){

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	
	double a,b,h,m;
	cin>>a>>b>>h>>m;

	double angle = h * 30;
	angle += (m/60)*30;
	angle = abs(angle-m*6);
	angle  = min(angle, 360-angle);

	// cout<<angle<<endl;

	angle = (angle * 3.1415926535897932) / 180;

	double ans  = pow(a,2) + pow(b,2) - (double)2*a*b*cos(angle);
	
	ans = sqrt(ans);

	cout<<std::fixed<<setprecision(11)<<ans;

	
	return 0;
}

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

void insertionSort(int A[], int N);

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

	for(int k = 0; k < N; k++)
		{
			if(k != N - 1)
				cout << A[k] << " ";
			else
				cout << A[k];
		}
		cout << "\n";

	insertionSort(A,N);

	
	return 0;
}

void insertionSort(int A[], int N)
{
	int v;




	for (int i = 1; i < N; i++)
	{
		v = A[i];
		int j = i - 1;

		

		while(j >= 0 && A[j] > v)
		{
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;

		for(int k = 0; k < N; k++)
		{
			if(k != N - 1)
				cout << A[k] << " ";
			else
				cout << A[k];
		}
		cout << "\n";
	}
}

Measured memory_bytes: 1164
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, K = map(int, input().split())
# 文字列の入力
#s = input()
#開業されたN個要素を受け付ける
#input_list = [list(map(int, input().split())) for i in range(N)]
print(N * K)


Measured memory_bytes: 9144
/* ****GT_18**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		int n,k,ans=INT_MAX,i,arr[100005];
		cin>>n>>k;
		rep(i,0,n)
		cin>>arr[i];
		sort(arr,arr+n);
		for(i=0;i<=n-k;i++)
		{
			ans=min(ans,arr[i+k-1]-arr[i]);
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 640
# recieve |V| and |E|
V, E = map(int, input().split())
es = [[] for i in range(V)]

for i in range(E):

	# recieve edges
	a, b, c = map(int, input().split())
	a, b = a-1, b-1
	es[a].append((b,c))
	es[b].append((a,c))

T = int(input())

# recieve info
for i in range(T):
	Nnew = int(input())
	for j in range(Nnew):
		new_id, dst = map(int, input().split())

# insert your code here to get more meaningful output
# all stay
for i in range(T) :
	print (-1)

Measured memory_bytes: 3752
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<algorithm>
#include<queue>
#include<list>
#include<stack>
#include<cstdio>
#include<fstream>
#include<numeric>
#include<functional>
#include<utility>
#include<memory>
#include <cstring>
#include<bits/stdc++.h>
using namespace std; 
  
#define CLEAN(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;

ll chek(ll n)
{
	if (n>=0) return n;
	else return -n;
}

int a,b,c;
ll k;
const ll maxn=1e18;
int main() 
{
	ll ans;
	cin>>a>>b>>c>>k;
	if (k%2==0)
	{
		ans=a-b;
	}
	else
	{
		ans=b-a;
	}
	//if (chek(ans)>max) cout<<"Unfair"<<endl;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		
		String CMD = null ;
		BufferedReader BR = null;
		BR = new BufferedReader(new InputStreamReader(System.in));
		try {
			CMD = BR.readLine();
		} catch (IOException e) {
		
			e.printStackTrace();
		}
		
		String[] QSTR001E = CMD.split(" ");
		
		int[] QINT001E = new int[QSTR001E.length];
		
		try{
			for(int i = 0;i<QSTR001E.length;i++){
				QINT001E[i] = Integer.parseInt(QSTR001E[i]);
			}
		}catch(NumberFormatException e){
			
		}
		
		int QINT002E = QINT001E[0];
		int QINT003E = QINT001E[1];
		
		System.out.println(QINT002E*QINT003E+" " + 2*(QINT002E+QINT003E) );
	}

}

Measured memory_bytes: 24296
import java.util.Scanner;


public class Main {


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

	    StringBuffer sb = new StringBuffer();
	    for (int i = 0; i < k; i++) {
	    	sb.append("ACL");
	    }

	    System.out.println(sb.toString());
	}


}

Measured memory_bytes: 35700
N = int(input())
h = list(map(int, input().split()))

# #大きな値
# INF = 10**10

# DPtable
dp = [10**10 for _ in range(N)]

#初期条件
dp[0] = 0
dp[1] = abs(h[1]-h[0])

#ループ
for i in range(N):
    if i == 0 or i == 1:
        continue
    else:
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))

print(dp[N-1])



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

using namespace std;

const int nmax=10;
bool digit[nmax]={false};



int main(){
 int n,k;
  cin >> n >> k;
 
 
  for(int i=0;i<k;i++){
   int d;
    cin >> d;
    digit[d]=true;
  }
  
 for(int i=0;i<=9*n;i++){
  int d=n+i;
  bool dis=true; 
   while(d>0){
    if(digit[d%10]) {
      dis=false;  
      break;
    }
    d/=10;
   }
   
   if(dis) { cout << n+i << endl;
            return 0;
           }
 }

}


Measured memory_bytes: 256
N, M = gets.chomp.split(" ").map(&:to_i)
S = Array.new(N).map{
  gets.chomp.split(" ").map(&:to_i)
}
C = Array.new(M).map{
  gets.chomp.split(" ").map(&:to_i)
}

ans = S.map{|s|
  C.each_with_index.min_by{|c, i|
    (s[0]-c[0]).abs + (s[1]-c[1]).abs
  }
}

puts ans.map{|c, i| i+1} * "\n"


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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion

#define int long long

int dp[1000001];
int odp[1000001];

signed main()
{
    for(int i=0; i<1000001; ++i) {
        dp[i] = i;
        odp[i] = i;
    }
    for(int i=1;; ++i) {
        int a = i*(i+1)*(i+2)/6;
        if(a>=1000000) break;
        for(int j=a; j<1000000; ++j) {
            dp[j] = min(dp[j], dp[j-a] + 1);
            if(a&1) odp[j] = min(odp[j], odp[j-a] + 1);
        }
    }
    int n;
    while(cin>>n, n) {
        cout << dp[n] << " " << odp[n] << endl;
    }
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++) cin >> b[i];
    long long int suma = 0, sumb = 0;
    for(int i = 0; i < n; i++){
        suma += a[i];
        sumb += b[i];
    }

    long long int opcount = sumb - suma;
    vector<int> diff(n);
    long long int opcount_a = opcount, opcount_b = opcount;
    for(int i = 0; i < n; i++){
        if(a[i] - b[i] >= 0){
            opcount_b -= a[i] - b[i];
        }else{
            opcount_a -= (b[i]-a[i])/2;
            if((b[i]-a[i])%2 == 1){
                opcount_b--;
                opcount_a--;
            }
        }
    }

    if(opcount_a >= 0 && opcount_b >= 0 && opcount_a*2LL == opcount_b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) {
        cout << "a > b";
    } else if (a < b) {
        cout << "a < b";
    } else {
        cout << "a == b";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cmath>
#define eps 10e-9
using namespace std;

int main()
{
	double in;
	while(cin>>in)
	{
		double t=in/9.8;
		cout<<ceil((4.9*t*t+5)/5)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1280
import bisect
 
N = int(input())
L = list(map(int, input().split()))
L.sort()
 
ans = 0
for i in range(N):
    for j in range(i+1, N):
        ans += bisect.bisect_left(L, L[i]+L[j]) - 1 - j
 
print(ans)

Measured memory_bytes: 44252
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

using namespace std;
using i64 = std::int64_t;

int main() {
  i64 n;
  cin >> n;
  i64 cum{0};
  i64 hmax{0};
  i64 h;
  for (i64 i = 0; i < n; ++i) {
    cin >> h;
    if (hmax < h) {
      hmax = h;
    } else if (h < hmax) {
      cum += hmax - h;
    }
  }
  cout << cum << endl;

  return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef complex<double> Point;
typedef pair<Point, Point> Line;
const double EPS = 1e-10;

// 内積 |a||b|cosθ
double dot(Point a, Point b){
	// return a.real() * b.real() + a.imag() * b.imag();
	return (conj(a) * b).real();
}
// ベクトルa, bがなす角の余弦(cosθ)の値
double costheta(Point a, Point b){
    return dot(a, b) / (abs(a) * abs(b));
}
// 2直線の平行判定
bool isParallel(Line a, Line b){
    double cos = costheta(a.second - a.first, b.second - b.first);
    return fabs(cos) > 1 - EPS;
}
// 2直線が垂直に交わるかどうか判定
bool isOrthogonal(Line a, Line b){
    double cos = costheta(a.second - a.first, b.second - b.first);
    return fabs(cos) < EPS;
}

int main(){
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        double x, y;
        Point p[4];
        for(int j = 0; j < 4; j++){
            cin >> x >> y;
            p[j] = {x, y};
        }
        Line s1 = {p[0], p[1]};
        Line s2 = {p[2], p[3]};
        if(isOrthogonal(s1, s2)) cout << 1 << endl;
        else if(isParallel(s1, s2)) cout << 2 << endl;
        else cout << 0 << endl;
    }
}


Measured memory_bytes: 3288
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int K = Integer.parseInt(scan.nextLine());
    int seven = 7;
    for (int i = 0; i < 47483647; i++) {
      int remain = seven % K;
      if(remain == 0){
        System.out.println(i+1);
        return;
      }
      seven = remain*10 + 7;
    }
    System.out.println("-1");
  }
}

Measured memory_bytes: 35604
N = int(input())
A = list(map(int,input().split()))
mini = []
for i in range(N):
    j = 0
    while 1:
        if A[i] % 2 == 1:
            mini.append(j)
            break
        else:
            A[i] = A[i]/2
            j += 1
print(min(mini))


Measured memory_bytes: 9172
#include <stdio.h>

int main()
{ 
	int N;
	int K;
	int wa;
	int i;
	
	scanf("%d",&N);
	scanf("%d",&K);
	
	int x[N];
	
	for (i = 0; i < N; i++){
		scanf("%d",&x[i]);
	}
	
	for (i = 0; i < N; i++){
		if ( (K - x[i]) > x[i] )
				wa += x[i];
		else
				wa += K - x[i];
	}
	
	printf("%d", wa*2);
		
	return 0;
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
vector<int> L[510];
int dp[510][510] = {};

int main() {
    int N,M,Q; cin >> N >> M >> Q;
    for(int i=0; i<M; ++i) {
        int l,r; cin >> l >> r;
        L[r].push_back(l);
    }
    for(int i=1; i<=N; ++i) sort(begin(L[i]), end(L[i]));

    for(int l=1; l<=N; ++l) {
        for(int r=l; r<=N; ++r) {
            dp[l][r] = dp[l][r - 1] + end(L[r]) - lower_bound(begin(L[r]), end(L[r]), l);
        }
    }

    while(Q--) {
        int p,q; cin >> p >> q;
        cout << dp[p][q] << '\n';
    }
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

struct segment_tree {
  vector<int> node;
  int n;
  const function<int(int,int)> fn;
  const int initial;

  segment_tree(int n, function<int(int,int)> fn, int initial) : fn(fn), initial(initial) {
    int msb = 1LL << ((n==0) ? 0 : 64 - __builtin_clzll(n)-1);
    this->n = (n==msb) ? n : msb << 1;
    node.resize(2 * this->n - 1);
    fill(node.begin(), node.end(), initial);
  }

  inline int r_child(int v) { return v*2+2; }
  inline int l_child(int v) { return v*2+1; }
  inline int parent(int v) { return (v + (v%2)) / 2 - 1; }

  int query(int ql, int qr, int v=0, int l=0, int r=-1) {
    r = (r==-1) ? n-1 : r;
    if(ql<=l && r<=qr) return node[v];
    int ret = initial, mid=(l+r)/2;
    if(ql <= mid)   ret = fn(ret, query(ql, qr, l_child(v), l,     mid));
    if(qr >= mid+1) ret = fn(ret, query(ql, qr, r_child(v), mid+1, r  ));
    return ret;
  }

  void set_value(int index, int val) {
    int v = node.size()/2 + index;
    node[v] = val;
    while((v=parent(v)) != -1) node[v] = fn(node[r_child(v)], node[l_child(v)]);
  }

  void add_value(int index, int val) { set_value(index, node[node.size()/2 + index] + val); }
  int get_value(int index) { return node[node.size()/2 + index]; }
};

int main() {
  int n,k; cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  segment_tree st(300010, [](int u, int v) { return max(u,v); }, 0);

  int ans  = 0;
  for(auto i : a) {
    int l = max(0, i - k);
    int r = min(300000, i + k);
    int q = st.query(l,r);
    st.set_value(i, q+1);
    umax(ans, q+1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 8584
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    lh: usize,
    lw: usize,
    h: usize,
    w: usize
    }
    let ans = (lh - h) * (lw - w);
    println!("{}", ans);
}


Measured memory_bytes: 2196
# -*- coding: utf-8 -*-
from math import sin, cos, radians

def main():
    N,M,X,Y  = map(int, input().split())
    x_ = list(map(int, input().split()))
    y_ = list(map(int, input().split()))
    if max(X,*x_)<min(Y,*y_):
        print("No War")
    else:
        print("War")
    # print(max(Y,*y_))
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include<cstdio>
#include<cctype>
const int N=100007,P=1000000007;
int a[N],deg[N],vis[N],pre[N],cnt[N],f[N];
int read(){int x=0,c=getchar();while(isspace(c))c=getchar();while(isdigit(c))(x*=10)+=c&15,c=getchar();return x;}
int add(int a,int b){return a+=b-P,a+(a>>31&P);}
int mul(int a,int b){return 1ll*a*b%P;}
int main()
{
    int n=read(),ans=1;
    for(int i=1;i<=n;++i) ++deg[a[i]=read()];
    for(int i=1,p;(p=i)<=n;++i)
    {
	if(deg[i]>2) return puts("0"),0;
	if(deg[i]<2||vis[i]) continue;
	do
	{
	    if(vis[p]) return puts("0"),0;
	    vis[p]=1,pre[a[p]]=p,p=a[p];
	}while(p^i);
    }
    for(int i=1,p,l1,l2;i<=n;++i)
	if(!deg[i])
	{
	    for(p=i,l1=0,l2=0;!vis[p];p=a[p]) vis[p]=1,++l1;
	    do ++l2,p=pre[p]; while(deg[p]^2);
	    if(l1<l2) ans=add(ans,ans); else if(l1>l2) return puts("0"),0;
	}
    for(int i=1;i<=n;++i)
	if(!vis[i])
	{
	    int p=i,l=0;
	    do ++l,p=a[p],vis[p]=1; while(p^i);
	    ++cnt[l];
	}
    for(int i=1;i<=n;ans=mul(ans,f[cnt[i++]]))
    {
	f[0]=1,f[1]=1+(i^1&&i&1);
	for(int j=2;j<=cnt[i];++j) f[j]=add(mul(i,mul(j-1,f[j-2])),mul(f[1],f[j-1]));
    }
    printf("%d",ans);
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] B = new int[N];
        var input = Console.ReadLine().Split();
        int[] A = new int[N];
        for (int i = 0; i < N-1; i++)
        {
            B[i] = int.Parse(input[i]);
        }
        int sum = 0;
        for (int i = 0; i < N; i++)
        {
            if (i == 0) { A[0] = B[0]; }
            else if (i == N - 1) { A[i] = B[i - 1]; }
            else { A[i] = Math.Min(B[i],B[i-1]); }
            sum += A[i];
        }
        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 13140
#include <stdio.h>

int gcd(int m, int n)
{
    int x;
    while (n != 0){
        x = n;
        n = m % n;
        m = x;
    }
    return (m);
}

int lcm(int m, int n)
{
    return ((m / gcd(m, n)) * n);
}


int main(void)
{
    int a, b;
    int t;

    while (scanf("%d %d", &a, &b) != EOF){
        if (a < b){
            t = a;
            a = b;
            b = t;
        }
        printf("%d %d\n", gcd(a, b), lcm(a, b));
    }
    return (0);
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll res;
  for (ll i=2; i*i<=n; i++) {
    if(n%i!=0) continue;
    ll ex=0;
    while(n%i==0) {
      ex++;
      n/=i;
    }
    res.push_back(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}


int main() {  
  int n;
  cin >> n;
  vi a(n),b(n),c(n);
  REP(i,n) cin >> a[i] >> b[i] >> c[i];
  vvi dp(n+1,vi(3,INF));
  dp[1][0]=a[0];
  dp[1][1]=b[0];
  dp[1][2]=c[0];
  REPD(i,2,n) {
    dp[i][0]=max(dp[i-1][1]+a[i-1],dp[i-1][2]+a[i-1]);
    dp[i][1]=max(dp[i-1][2]+b[i-1],dp[i-1][0]+b[i-1]);
    dp[i][2]=max(dp[i-1][0]+c[i-1],dp[i-1][1]+c[i-1]);
  }
  cout << max(dp[n][0], max(dp[n][1],dp[n][2])) << endl;
  return 0;
}


Measured memory_bytes: 9832
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int n, m, x;
vector<vector<int>> vec;
ll smallest = 1000000000000;

void dfs(vector<int> v, vector<bool> flag, int length){
    if(v.size() == length){
        vector<int> xVec(m, 0);
        ll sum = 0;
        rep(i, v.size()){
            rep(j, m+1){
                if(j == 0){
                    sum += vec[v[i]][j];
                }else{
                    xVec[j-1] += vec[v[i]][j];
                }
            }
        }
        bool overX = true;
        rep(i, m){
            if(xVec[i] < x) overX = false;
        }
        if(overX){
            smallest = min(smallest, sum);
        }
    }else{
        for(int i=v.back()+1; i<n; i++){
            if(!flag[i]){
                v.push_back(i);
                flag[i] = true;
                dfs(v, flag, length);
                v.pop_back();
                flag[i] = false;
            }
        }
    }
}

int main() {
    cin >> n >> m >> x;
    rep(i, n){
        vector<int> tmp;
        int c;
        cin >> c;
        tmp.push_back(c);
        rep(j, m){
            int num;
            cin >> num;
            tmp.push_back(num);
        }
        vec.push_back(tmp);
    }
    for(int i=1; i<=n; i++){
        rep(j, n){
            vector<int> tmp;
            vector<bool> flagVec(n, false);
            tmp.push_back(j);
            flagVec[j] = true;
            dfs(tmp, flagVec, i);
            tmp.pop_back();
            flagVec[j] = false;
        }
    }
    if(smallest == 1000000000000) cout << -1 << endl;
    else cout << smallest << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <list>

using namespace std;

int Count_same_element(const std::list<int>& base, const std::list<int>& other) {

   int count = 0;
   for (const auto base_element : base) {
      for (const auto other_element : other) {
         if (other_element != base_element) { continue; }
         ++count;
         break;
      }
   }

   return count;

}

std::list<int> Create_input_list() {

   std::list<int> list;
   int size;

   cin >> size;
   while (size--) {
      int value;
      cin >> value;
      list.emplace_back(value);
   }

   return std::move(list);

}

int main() {

   std::list<int> S{ Create_input_list() };
   std::list<int> T{ Create_input_list() };

   cout << Count_same_element(T, S) << endl;

   return 0;

}

Measured memory_bytes: 3360
import sys
sys.setrecursionlimit(10**6)
n, M, k = map(int,input().split())
a_l = list(map(int,input().split()))
b_l = list(map(int,input().split()))
read_a = [0]*n
read_b = [0]*M
time = 0
ans = 0
memo = -1
for j in range(n):
    if time + a_l[j] <= k:
        time += a_l[j]
        read_a[j] = 1
        memo = j
        ans = j+1
    else:
        break

kotae = [ans]


def dfs(i,a,t,m):
    global kotae
    if i < M:
        if b_l[i] + t <= k:
            tt = t + b_l[i]
            aa = a + 1
            kotae.append(aa)
            ii = i+1
            mm = m
            #print(aa)
            dfs(ii,aa,tt,mm)
            
        else:
            if m >= 0:
                tt = t - a_l[m]
                mm = m - 1
                aa = a - 1
                ii = i
                dfs(ii,aa,tt,mm)
            


dfs(0,ans,time,memo)


print(max(kotae))
    





Measured memory_bytes: 405596
#include<cstdio>
#include<algorithm>
#define int long long  
using namespace std;
signed main()
{
	int cnt=0,tmp=0,l,r,ans,cmd=0;
	scanf("%lld %lld",&l,&r);
	if(l==r)
	{
		printf("%lld",l);
		return 0;
	}
	if(l%2)
	{
		tmp=l;
		l++;
	}
	if(r%2==0)
	{
		cmd=r;
		r--;
	}
	printf("%lld",tmp^(((r-l+1)/2)%2)^cmd);
	return 0;
}

Measured memory_bytes: 128
from math import log2
n, k = map(int, input().split())
To = []
A = list(map(int, input().split()))
A = list(map(lambda x: x - 1, A))
To.append(A)
for i in range(int(log2(k))):
    N = [0 for i in range(n)]
    for j in range(n):
        N[j] = To[i][To[i][j]]
    To.append(N)

v = 0
for i in reversed(range(int(log2(k)) + 1)):
    l = 1 << i
    if l <= k:
        v = To[i][v]
        k -= l
    else:
        pass

print(v + 1)

Measured memory_bytes: 218048
#include<stdio.h>
#define N 100
int main() {
	int n,w[N],i,j,sum1,sum2,min=0,mint=0;
	scanf("%d", &n);
	for (i = 0; i < n; i++) 
		scanf("%d", &w[i]);
	
	for (i = 1; i < n; i++) {
		sum1 = 0, sum2 = 0;
		for (j = 0; j < n; j++) {
			if (j > i)
				sum1 += w[j];
			else
				sum2 += w[j];
		}
		if (sum2 > sum1)
			min = sum2 - sum1;
		else
			min = sum1 - sum2;
		if (i==1||min<mint) {
			mint = min;
		}	
	}
	printf("%d\n", mint);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	static long money;
	static int year,type,charge;
	static double rate;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int N = cin.nextInt();
		while(N--!=0){
			money=cin.nextLong();
			year=cin.nextInt();
			int n = cin.nextInt();
			long max=0;
			while(n--!=0){
				type=cin.nextInt();
				rate=cin.nextDouble();
				charge=cin.nextInt();
				if(type==0){
					max=Math.max(tanri(money),max);
				}
				else{
					max=Math.max(hukuri(money),max);
				}
			}
			System.out.println(max);
		}
	}
	static long tanri(long money){
		long sum=0;
		for(int i = 0;i<year;i++){
			sum+=(double)money*rate;
			money-=charge;
//			System.out.println(sum);
		}
//		System.out.println(money+sum);
		return money+sum;
	}
	static long hukuri(long money){
		for(int i = 0;i<year;i++){
//			System.out.println((double)money*rate);
			money=(long) (money+((double)money*rate)-charge);

//			System.out.println(money);
		}
		return money;
	}
}

Measured memory_bytes: 13000
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
typedef long long ll;

int N, Q;
string s;
vector<char> t, d;

// posにいるゴーレムが0に到達するかどうか
bool check0(int pos) {
  for (int i = 0; i < Q; i++) {
    char c = s[pos];
    if (c == t[i]) {
      d[i] == 'L' ? pos-- : pos++;
    }

    if (pos == 0) {
      return true;
    } else if (pos == N + 1) {
      return false;
    }
  }
  return false;
}

// posにいるゴーレムがN+1に到達するかどうか
bool checkN1(int pos) {
  for (int i = 0; i < Q; i++) {
    char c = s[pos];
    if (c == t[i]) {
      d[i] == 'L' ? pos-- : pos++;
    }

    if (pos == 0) {
      return false;
    } else if (pos == N + 1) {
      return true;
    }
  }
  return false;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> Q;
  cin >> s;
  s = "x" + s + "x"; // 0, N+1に番兵をつける
  t.resize(Q);
  d.resize(Q);
  for (int i = 0; i < Q; i++) {
    cin >> t[i] >> d[i];
  }

  // 0に到着するゴーレムの内、一番右のindexを求める
  int ansL = 0;
  int l = 0, r = N + 1;
  while (true) {
    if (r - l <= 1) {
      ansL = l;
      break;
    }

    int mid = (l + r) / 2;
    if (check0(mid)) {
      l = mid;
    } else {
      r = mid;
    }
  }

  // N+1に到着するゴーレムの内、一番左のindexを求める
  int ansR = N + 1;
  l = 0, r = N + 1;
  while (true) {
    if (r - l <= 1) {
      ansR = r;
      break;
    }

    int mid = (l + r) / 2;
    if (checkN1(mid)) {
      r = mid;
    } else {
      l = mid;
    }
  }

  cout << ansR - ansL - 1 << endl;
  return 0;
}

Measured memory_bytes: 952
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<double>P(N);
  for (int i = 0; i < N; i ++) cin >> P[i];
  double dp[3000][3000];
  dp[0][0] = 1 - P[0];
  dp[0][1] = P[0];
  for (int i = 1; i < N; i ++) {
    dp[i][0] = dp[i - 1][0] * (1 - P[i]);
  }
  for (int i = 1; i < N; i ++) {
    for (int j = 1; j <= i + 1; j ++) {
      double ku, ma;
      ku = dp[i - 1][j] * (1 - P[i]);
      ma = dp[i - 1][j - 1] * P[i];
      dp[i][j] = ku + ma;
    }
  }
  double ans = 0;
  int k = N / 2;
  for (int i = k + 1; i <= N; i ++) {
    ans += dp[N - 1][i];
  }
  cout << setprecision(10) << ans << endl;
}


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

int main()
{
	string s;
	string y = "x";
	cin >> s;
	

	int counter = 0;
    int s_len = s.length();
  	while (counter < s_len) {
  		s.replace(counter, s_len, y);
  		counter++;
  	}

	std::cout << s;

	return 0;
}


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

using namespace std;
using ll = long long int;

int main()
{
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;

	vector<ll> P(a), Q(b), R(c);

	for (int i = 0; i < a; i++)
	{
		cin >> P[i];
	}

	for (int i = 0; i < b; i++)
	{
		cin >> Q[i];
	}

	for (int i = 0; i < c; i++)
	{
		cin >> R[i];
	}

	sort(P.begin(), P.end(), greater<ll>());
	sort(Q.begin(), Q.end(), greater<ll>());
	sort(R.begin(), R.end(), greater<ll>());

	vector<ll> vec;
	for (int i = 0; i < x; i++)
	{
		vec.push_back(P[i]);
	}

	for (int i = 0; i < y; i++)
	{
		vec.push_back(Q[i]);
	}

	for (int i = 0; i < c; i++)
	{
		vec.push_back(R[i]);
	}

	sort(vec.begin(), vec.end(), greater<ll>());
	ll ans = 0;
	for (int i = 0; i < (x + y); i++)
	{
		ans += vec[i];
	}

	cout << ans << endl;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

ll gcd(ll x, ll y){ return y? gcd(y, x%y): x; }
int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, k;
	cin >>n >>k;
	
	ll wn = n%k;
	ll ans = 1e18+100;
	set<ll> st;
	while(1){
		wn = abs(wn  -k);
		ans = min(wn, ans);
		if(st.count(wn) ) break;
		st.insert(wn);
	}
	cout <<ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
// D - Digits Parade
#include <bits/stdc++.h>

using namespace std;

#define	MOD	1000000007

int main(int argc, char *argv[])
{
	string s;
	cin >> s;
	int n = s.size();
	vector<vector<long long> > dp(n, vector<long long>(13));
	reverse(s.begin(), s.end());

	if (s[0] == '?')
		for (int i = 0; i < 10; i++) dp[0][i] = 1;
	else
		dp[0][s[0] - '0'] = 1;

	long long t = 10;
	for (int k = 1; k < n; k++) {
		if (s[k] == '?') {
			for (int i = 0; i < 10; i++)
				for (int j = 0; j < 13; j++)
					dp[k][(i * t + j) % 13] = (dp[k][(i * t + j) % 13] + dp[k - 1][j]) % MOD;
		} else {
			int c = (s[k] - '0') * t;
			for (int j = 0; j < 13; j++)
				dp[k][(c + j) % 13] = (dp[k][(c + j) % 13] + dp[k - 1][j]) % MOD;
		}
		t = (t * 10) % 13;
	}

	cout << dp[n - 1][5] << endl;

	return 0;
}


Measured memory_bytes: 13696
N = gets.chomp.to_i
A = gets.chomp.split(" ").map(&:to_i).sort
MOD = 10**9 + 7

if A.last.zero?
  puts 0
  exit
end

mbit = Math.log2(A.last).ceil
bit_cnt = (0..mbit).map {|b| A.count{|a| a[b] == 1} }

ans = 0
0.upto(mbit) do |b|
  ans += (2 ** b) * bit_cnt[b] * (N - bit_cnt[b])
  ans %= MOD
end
puts ans


Measured memory_bytes: 45152
#include<stdio.h>
int main(){
  int n,y,i,j;
  scanf("%d%d",&n,&y);
  for(i=0;i<=n;i++){
    for(j=0;j<=n-i;j++){
      if(y/1000==9*i+4*j+n){
        printf("%d %d %d",i,j,n-i-j);
        return 0;
      }
    }
  }
  puts("-1 -1 -1");
  return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

  public static void main(String[] args) {
    FastScanner sc = new FastScanner();

    int N = sc.nextInt();


    if (N == 2) {
      int A = sc.nextInt();
      int B = sc.nextInt();
      System.out.println(A + B);
    } else {
      System.out.println("Hello World");
    }

  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) {
      return buffer[ptr++];
    } else {
      return -1;
    }
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  private void skipUnprintable() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
      ptr++;
    }
  }

  public boolean hasNext() {
    skipUnprintable();
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public int nextInt() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    int n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public long nextLong() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }
}

Measured memory_bytes: 19668
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    while(1){
        int k=0;
        cin>>a>>b;
        if(a==0&&b==0)break;
    for(int i = 1;i<=a;i++){
        for(int j = i+1;j<=a;j++){
            for(int l = j+1;l<=a;l++){
                if(b==i+j+l){
                    k++;
                }
            }
        }
    }
    cout<<k<<endl;
  }
}


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

using namespace std;
using ll = long long int;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    cout << fixed << setprecision(16);

    ll n, k;
    cin >> n >> k;
    vector<pair<ll,ll>> v(n);
    for(auto &e: v)
        cin >> e.second >> e.first;
    sort(v.begin(), v.end(), greater<>());

    ll kiso = 0;
    map<ll,ll> cnt;
    for(ll i=0; i<k; i++)
        kiso += v[i].first, cnt[v[i].second]++;
    ll kind = cnt.size();

    ll res = kiso + kind*kind;

    ll i = k, j = k-1;
    while(1) {
        while(i<n && cnt.count(v[i].second)) i++;
        if(i>=n) break;
        while(j>=0 && cnt[v[j].second]<=1) j--;
        if(j<0) break;

        kiso += v[i].first - v[j].first;
        kind++;
        res = max(res, kiso + kind*kind);
        cnt[v[j].second]--;
        cnt[v[i].second]++;
        i++, j--;
    }
    cout << res << endl;
}


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

int main() {
  int N;
  double x = 0, y = 0;
  cin >> N;
  vector<double> v(N);
  for (int i = 0; i < N; i++){
    cin >> v.at(i);
  }
    sort(v.begin(),v.end());
    x = v.at(0) + v.at(1);
    y = x/2;
    for (int i = 0; i < N-2; i++){
        y = y + v.at(i+2);
        y = y/2;
    }
    cout << y << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cina(a, n) for (int i = 0; i < n; ++i){ cin >> a[i]; }

using namespace std;

int main () {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, k, d, a;
	cin >> n >> k;
	int mp[n + 1];
	memset(mp, 0, sizeof(mp));
	for (int i = 0; i < k; ++i) {
		cin >> d;
		for (int j = 0; j < d; ++j) {
			cin >> a;
			mp[a]++;
		}
	}
	int c = 0;
	for (int i = 1; i < n + 1; i++) {
		if (mp[i] == 0) c++;
	}
	cout << c;

	return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
using namespace std;

typedef long long STATES;

int main( void )
{
	STATES free_days[31], dp[51], goal_state, next;
	STATES* p;
	int i, j, n, free_day, k;
	short answer;

	while ( scanf( "%d", &n ) == 1 && n )
	{
		memset( free_days, 0, sizeof(free_days) );
		memset( dp, 0, sizeof(dp) );

		goal_state = 0;
		for ( i = 0; i < n; i++ ) goal_state |= 1LL << i;

		for ( i = 0; i < n; i++ )
		{
			scanf( "%d", &k );
			for ( j = 0; j < k; j++ )
			{
				scanf( "%d", &free_day );
				free_days[free_day] |= 1LL << i;
			}
		}

		answer = -1;
		for ( i = 0; i < n; i++ ) dp[i] = 1LL << i;
		p = free_days + 1;
		for ( i = 30; i; i--, p++ )
		{
			next = 0;
			for ( j = 0; j < n; j++ ) if ( *p & 1LL << j ) next |= dp[j];
			if ( next == goal_state )
			{
				answer = 30 - i + 1;
				break;
			}
			for ( j = 0; j < n; j++ ) if ( *p & 1LL << j ) dp[j] |= next;
		}

		printf( "%d\n", answer );
	}

	return 0;
}

Measured memory_bytes: 764
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        Integer n = Integer.parseInt(sc.next());
        Integer k = Integer.parseInt(sc.next());
        Integer[] h = new Integer[n];
        for (int i = 0; i < n; i++) {
            h[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        Arrays.sort(h);
        long result = 0;
        for (int i = 0; i < h.length; i++) {
            if (k < n - i) {
                result += h[i];
            }
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 65660
N=int(input())
i=0
j=1
l=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
S=""
while i<N:
    i+=26**j
    j+=1
N-=i-26**(j-1)
if N==26**(j-1):
    print("z"*(j-1))
    exit()
for i in reversed(range(j-1)):
    if i!=0:
        a=N//26**i
        S+=l[a]
        N-=a*(26**i)
    else:
        S+=l[N-1]
    if N==0:
        S=S[:len(S)-1]
        S+=l[a-1]
        S+="z"*i
        break
print(S)
    



    





    






        






    
















        


























            
    


    


    
    














    


    














Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,n,i,j,k,f,a,b,c,d;
	cin>>a>>b>>c>>d;
	/*if(a<0&&c<0)cout<<max(a*c;
	else if(a<=0&&c>0)
	{
	    if(b<=0)cout<<b*c;
	    else cout<<d*b;
	}
	else if(a>=0&&c>=0)cout<<b*d;
	else if()*/
	ll ans=max(a*c,a*d);
	ans=max(ans,max(b*c,b*d));
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3648
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int a = sc.nextInt();
        // スペース区切りの整数の入力
        int b = sc.nextInt();
        int c = sc.nextInt();

        if(((a*100+b*10+c) % 4) == 0){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    long long N;
    cin >> N;
    int kitei = 26;
    string result = "";
    while(N > 0){
        N--;
        int remain = N%kitei;
        char digi = (char)(remain + 97);
        result = digi + result;
        N = (N-remain) / kitei;
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
void dfs(ll node,vector<ll>v[],ll dp[],bool vis[])
{
    vis[node]=true;
    for(ll i=0;i<v[node].size();i++)
    {
        if(!vis[v[node][i]])
        dfs(v[node][i],v,dp,vis);
        dp[node]=max(dp[node],1+dp[v[node][i]]);
    }
}
 
int main() {
    fast();
    /*ll t;
    cin>>t;
    while(t--)
    {
       
    }*/
    ll n,m;
    cin>>n>>m;
    vector<ll>v[n+1];
    ll dp[n+1]={0};
    bool vis[n+1];
    memset(vis,false,sizeof(vis));
    for(ll i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        v[x].push_back(y);
    }
    
    for(ll i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            dfs(i,v,dp,vis);
        }
    }
    ll mx=0;
    for(ll i=1;i<=n;i++)
    mx=max(dp[i],mx);
    cout<<mx<<endl;
    
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[100009];
ll ans(ll *arr, int n){
	dp[0] = 0;
	dp[1] = 0;
	dp[2] = abs(arr[1] - arr[0]);
	for(int i=3; i<=n; i++){
		dp[i] = min(dp[i-1] + abs(arr[i-1] - arr[i-2]), dp[i-2] + abs(arr[i-1] - arr[i-3]));
	}
	return dp[n];
}
int main(){
	int n; cin >> n;
	ll arr[n];
	for(int i=0; i<n; i++) {cin>>arr[i]; dp[i] = -1;}
	ll anss = ans(arr, n);
	cout << anss << endl;
}

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

#define ll long long
#define pb push_back

using namespace std;

const int N=1e5+100;
ll n,p[N],m,x;
bool b[N];

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

    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
        if(p[i]==i)
        {
            b[i]=true;
        }
    }

    for(int i=1;i<=n;i++)
    {
        if(b[i]==true)
        {
            m++;
            if(i!=n)
            {
                i++;
            }
        }
    }

    cout<<m;
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 1000000000000000;
#define all(v) v.begin(), v.end()

vector<ll> Prime(100000,0),W(100000,0);
void sosu(ll n){
  Prime.at(0)=2;
  ll t=1;
  for(ll i=3;i<n;i++){
    rep(j,t){
      if(i%Prime.at(j)==0){
        break;
      }
      if(j==t-1){
        Prime.at(t)=i;
        t++;
      }
    }
  }
}
void factor(ll M){
  rep(i,100000){
    if(Prime.at(i)==0){
      if(M==1) return;
      else{
        Prime.at(i)=M;
        W.at(i)++;
        M=1;
      }
    }else{
      while(M%Prime.at(i)==0){
        M/=Prime.at(i);
        W.at(i)++;
      }
    }
  }
}
ll modPow(ll a, ll n) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  ll t = modPow(a, n / 2);
  return (t * t) % MOD;
}

int main(){
  ll N,M,ans=1;
  cin >> N >> M;
  sosu(100000);
  factor(M);
  vector<ll> comb(100);
  rep(i,100){
    if(i==0) comb.at(i)=1;
    else{
      comb.at(i)=comb.at(i-1);
      comb.at(i)*=N-1+i;
      comb.at(i)%=MOD;
      comb.at(i)*=modPow(i,MOD-2);
      comb.at(i)%=MOD;
    }
  }
  rep(i,100000){
    ans*=comb.at(W.at(i));
    ans%=MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4588
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author verytable
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>

class TaskD {
public:
	void solve(std::istream& in, std::ostream& out) {
		size_t n;
		in >> n;
		std::vector<int> perm;
		perm.reserve(n);
		for (int i = 0; i < n; ++i) {
			int p;
			in >> p;
			perm.push_back(p - 1);
		}

		int ret = 0;
		for (int i = 0; i < n; ++i) {
			auto p = perm[i];
			if (p == i) {
				++ret;
				++i;
			}
		}

		out << ret;
	}
};


int main() {
	TaskD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[3];
    for(int i=0;i<3;i++){
        cin >> a[i];
    }
    sort(a,a+3);
    int ans=0;
    for(int i=0;i<2;i++){
        ans+=abs(a[i]-a[i+1]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
class AOJ{
public static void Main(){
String[] st=Console.ReadLine().Split(' ');
int a=int.Parse(st[0]);
int b=int.Parse(st[1]);
int c=int.Parse(st[2]);
if(a<b&&b<c)
Console.WriteLine("Yes");
else 
Console.WriteLine("No");


}
}

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

using namespace std;

int N, L;

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

	int allSum = N * (2 * L + N - 1) / 2;
	int diff = 0;

	if (L > 0) diff = L;
	else if (L + N - 1 < 0) diff = L + N - 1;

	cout << allSum - diff;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define     FasterIO        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     bug(a,b)        cout<<a<<"\t"<<b<<"\n";
#define     Case(a,b)       cout<<"Case "<<a<<": "<<b<<"\n";
#define     watch(a)        cout<<fixed<<setprecision(a)
#define     lp(i,a,b)       for(int i=a;i<b;i++)
#define     Endl            "\n";
#define     tab             "\t"
#define     reset(a,b)      memset(a,b,sizeof(a));
#define     sf(a)           scanf(" %d", &a);
#define     srt(a)          sort(a.begin(),a.end());
#define     pi              2*acos(0.0)
#define     inf             INT_MAX
const int sz=1e5+9;
int n,x,arr[sz],dp[sz],k;

int clac(int i){
    if(i==n) return 0;
    if(dp[i]!=-1)return dp[i];
    int ret1=inf;
    for(int j=1;j<=k && i+j<=n;j++){
        ret1=min(ret1,abs(arr[i]-arr[i+j])+clac(i+j));
    }
    return dp[i]=ret1;
}

void solve(){
    cin>>n>>k;
    reset(dp,-1);
    lp(i,1,n+1)cin>>arr[i];
    cout<<clac(1)<<"\n";
}

int main(){
    //FasterIO;
    #ifndef ONLINE_JUDGE
       //freopen("1.txt","r",stdin);
    #endif
    // int t;
    //cin>>t;
    //while(t--)
        solve();
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << a*b-(c * b + a * d - c* d )<< endl;
}

Measured memory_bytes: 256