akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <numeric>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline bool Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e17;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n);
    cins(all(a));
    ll max = 0,index = 0;
    rep(i,n){
        if (abs(a[i]) > abs(max)){
            max = a[i];
            index = i;
        }
    }
    PRINT(2*(n-1));
    rep(i,n){
        if (i != index) cout << index+1 << " " << i+1 << endl;
    }
    rep(i,1,n){
        if (max >= 0) cout << i << " " << i+1 << endl;
        else cout << n-i+1 << " " << n-i << endl;
    }
}


Measured memory_bytes: 256
num = int(input())
pole_list = sorted([int(item) for item in input().split()])

from bisect import bisect_left as bil

cnt = 0

for i in range(num):
    for j in range(i + 1, num):
        cnt += bil(pole_list, pole_list[i] + pole_list[j]) - j - 1
print(cnt)

Measured memory_bytes: 3188
use proconio::input;

#[allow(non_snake_case)]
fn main() {
    input! {
        K: i32,
        A: i32,
        B: i32,
    }

    for a in A..=B {
        if a % K == 0 {
            println!("OK");
            return;
        }
    }
    println!("NG");
}


Measured memory_bytes: 2152
#include<stdio.h>

int main(){
	int N;
	scanf("%d\n", &N);
	char s[N];
	scanf("%s", s);
  	int i = 0, j = 0, k = 0;
	long long int r = 0, g = 0, b = 0, check = 0;
	for(i = 0; i < N; i++){
		if(s[i] == 'R'){
			r++;
		}else if(s[i] == 'G'){
			g++;
		}else{
			b++;
		}
	}
	//printf("%s\n", s);
	/*
	for(i = 0; i < N - 2; i++){
		for(j = i + 1; j < N - 1; j++){
			if(s[i] == s[j]) continue;
			for(k = j + 1; k< N ; k++){
				if(j - i == k - j ){
					if(s[i] != s[k] && s[ j ] != s[k]){
						check+=1;				
					}
				}
			}
		}
	}
	*/
	for(i = 0; i < N - 2; i++){
		for(k = i + 2; k < N; k++){
			if((i+k)%2 == 0){
				if(s[i] != s[(i+k)/2] && s[i] != s[k] && s[(i + k)/2] != s[k]){
					check += 1;
				}
			}
		}
	}
	
	printf("%lld\n", r*g*b-check);
	return 0;
}


Measured memory_bytes: 2120
# coding=utf-8

###
### for atcorder program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

def get_input():
    N = []
    while True:
        try:
            #N.append(input())
            #N.append(int(input()))
            N.append(float(input()))
        except EOFError:
            break
    return N

N = get_input()

print(max(N)-min(N))




Measured memory_bytes: 5652
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,arr[1000000],m,count=0,flag=0,brr[1000000];
 cin >> n;
 for(long long i=0;i<n;i++){
   cin >> arr[i];
   brr[i]=arr[i];
 }
 sort(arr,arr+n);
 for(long long i=0;i<n;i++){
     if(arr[i]!=brr[i])
     count++;
 }
 if(count==2||count==0)
 cout <<"YES";
 else
 cout << "NO";
 
 
 
}
 


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
const long long mod=1e9+7;
const long long INF=1LL<<60;

int par[100010];
int urank[100010];
 
void init(int n){
   for(int i=0;i<n;i++){
      par[i]=i;
      urank[i]=0;
   }
}
int find(int x){
   if(par[x]==x)return x;
   else return par[x]=find(par[x]);
}
void unite(int x,int y){
   x=find(x);
   y=find(y);
   if(x==y)return ;
   if(urank[x]<urank[y])par[x]=y;
   else {
      par[y]=x;
      if(urank[x]==urank[y])urank[x]++;
   }
}
bool same(int x,int y){
   return find(x)==find(y);
}
 
 
 
int main(){
   int n,m;
   cin>>n>>m;
   vector<int> x(m),y(m),z(m);
   init(n);
   for(int i=0;i<m;i++){
      cin>>x[i]>>y[i]>>z[i];
      x[i]--;y[i]--;
      unite(x[i],y[i]);
   }
 
   set<int> st;
   for(int i=0;i<n;i++){
      st.insert(find(i));
   }
   cout<<st.size()<<endl;
}
 
   

Measured memory_bytes: 6912
#include<bits/stdc++.h>
#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
using namespace std;

int main() {
    int n; cin >> n;
    cout << n * 800 - (n / 15) * 200 << endl;
}

Measured memory_bytes: 256
object Main extends App {
  val Array(n, m, c) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  val b = scala.io.StdIn.readLine.split(" ").map(_.toInt)

  val ans = (0 until n).map { _ =>
    val a = scala.io.StdIn.readLine.split(" ").map(_.toInt)
    val sum = (0 until m).map { i =>
      a(i) * b(i)
    }.sum + c
    if (sum > 0) {
      1
    } else {
      0
    }
  }.sum

  println(ans)
}


Measured memory_bytes: 55072
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
//#define ls x<<1
//#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-8;
const ull hashp=131;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;
map<pll,int>mp,vis;
ll x[maxn],y[maxn];
int qpow(int a,int b){
	int ret=1;
	while(b){
		if(b&1)ret=1ll*ret*a%mod;
		b>>=1;
		a=1ll*a*a%mod;
	}
	return ret;
}
ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}
void solve(){
	int n;scd(n);
	int num=0;
	rep1(i,n){
		scanf("%lld%lld",&x[i],&y[i]);
		if(!x[i]&&!y[i]){
			num++;
			continue;
		}
		//if(!x[i])y[i]/=abs(y[i]);
		//if(!y[i])x[i]/=abs(x[i]);
		ll g=gcd(x[i],y[i]);
		mp[pll(x[i]/g,y[i]/g)]++;
		mp[pll(-x[i]/g,-y[i]/g)]++;
	}
	int ans=1;
	rep1(i,n){
		if(!x[i]&&!y[i])continue;
		ll g=gcd(x[i],y[i]);
		if(vis.count(pll(x[i]/g,y[i]/g)))continue;
		vis[pll(x[i]/g,y[i]/g)]=vis[pll(-y[i]/g,x[i]/g)]=vis[pll(-x[i]/g,-y[i]/g)]=vis[pll(y[i]/g,-x[i]/g)]=1;
		ans=1ll*ans*(((qpow(2,mp[pll(x[i]/g,y[i]/g)])+qpow(2,mp[pll(-y[i]/g,x[i]/g)]))%mod-1+mod)%mod)%mod;
	} 
	ans=(ans+num)%mod;
	ans=(ans-1+mod)%mod;
	ac;
}
int main(){
    //IOS;
    //freopen("D:\\data.txt","r",stdin);
    //freopen("D:\\out.txt","w",stdout);
    solve();

	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;                                             ;;
	;;         ;;            ;;;;;;;;;       ;;    ;;
	;;        ;; ;;        ;;                ;;    ;;
	;;       ;;   ;;       ;;                ;;    ;;
	;;      ;;;;;;;;;      ;;                ;;    ;;
	;;     ;;       ;;     ;;                      ;;
    ;;    ;;         ;;      ;;;;;;;;;       ;;    ;;
    ;;                                             ;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    return 0;
}

Measured memory_bytes: 93752
while True:
    n = input()
    if n == 0:
        break
    dic = {}    
    for _ in xrange(n):
        a, b = raw_input().split()
        dic[a] = b
    f = lambda x:x if x not in dic else dic[x]
    print "".join(f(raw_input().strip()) for _ in xrange(input()))

Measured memory_bytes: 5860
w, h = map(int, input().split())
plst = [int(input()) for _ in range(w)]
qlst = [int(input()) for _ in range(h)]
plst.sort()
qlst.sort()
p_cnt = w + 1
q_cnt = h + 1
ppos = 0
qpos = 0
ans = 0
while 1:
    if plst[ppos] < qlst[qpos]:
        ans += plst[ppos] * q_cnt
        p_cnt -= 1
        ppos += 1
        if ppos == w:
            ans += sum(qlst[qpos:])
            break
    else:
        ans += qlst[qpos] * p_cnt
        q_cnt -= 1
        qpos += 1
        if qpos == h:
            ans += sum(plst[ppos:])
            break
print(ans)
        


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

int main()
{
  string S;
  cin >> S;
  int ans  = 0;
  int tmp_count = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T')
    {
      tmp_count++;
    } else {
      tmp_count = 0;
    }
    ans = max(ans, tmp_count);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
int n,m,x,y,z;
int a[20][20],sum,dp[1<<15][15],f[1<<15];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++){
		scanf("%d%d%d",&x,&y,&z);
		x--,y--;
		a[x][y]=a[y][x]=z;
		sum+=z;
	}
	for (int i=1;i<1<<n;i++)
		for (int j=0;j<n;j++)
			for (int k=j+1;k<n;k++)
				if ((i&(1<<j))&&(i&(1<<k)))
					f[i]+=a[j][k];
	memset(dp,-1,sizeof(dp));
	dp[1][0]=0;
	int all=(1<<n)-1;
	for (int i=1;i<1<<n;i+=2){
		for (int j=0;j<n;j++)
			if (i&(1<<j)){
				int t=dp[i][j];
				if (t==-1) continue;
				for (int k=0;k<n;k++){
					if (i&(1<<k)) continue;
					if (a[j][k]) dp[i|(1<<k)][k]=std::max(dp[i|(1<<k)][k],t+a[j][k]);
				}
				int rest=all^i;
				for (int k=rest;k;k=(k-1)&rest){
					dp[i|k][j]=std::max(dp[i|k][j],t+f[k|(1<<j)]);
				}
			}
	} 
	printf("%d\n",sum-dp[all][n-1]);
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
   int n;
   cin >> n;
   map<ll,int>L;
   rep(i,n){
      int a;
      cin >> a;
      L[a]++;
   }
   vector<ll>s;
   s.push_back(0);
   s.push_back(0);
   for(auto len:L){
      if(len.second>=2){
         s.push_back(len.first);
      }
      if(len.second>=4){
         s.push_back(len.first);
      }
   }
   sort(s.begin(),s.end());
   cout << s[s.size()-1]*s[s.size()-2] << endl;
   return 0;
}

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

using ll = long long; 

/*
30
4

brute-force -> look one by one -> from 1 to 30 -> if the digit sum is multiple of 4, then add
O(K * log K)


dp[d] - how many ways to get to remainder is d

dp[0] is the ans

dp[d] - how many ways to get to digit_sum as d

*/


int add(int a, int b) {
    const int mod = 1e9+7;
    int c = a + b;
    if (c >= mod) {
        c -= mod;
    }
    return c;
}

int subtract(int a, int b) {
    const int mod = 1e9+7;
    int c = a - b;
    if (c < 0) {
        c += mod;
    }
    return c;
}

int main() {
    const int nax = 10123;
    char K[nax];
    int D;
    scanf("%s", K);
    scanf("%d", &D);
    int len = strlen(K);
    vector<vector<int>> dp(D, vector<int>(2));
    // dp[sum][smaller_already] - no. of ways to choose digits so far
    // such that digits sum % D = sum and smaller_already means if the number
    // is already less than K
    dp[0][0] = 1;
    
    for (int where = 0; where < len; where++) {
        vector<vector<int>> new_dp(D, vector<int>(2));
        for (int sum = 0; sum < D; sum++) {
            for (bool sm_already : {false, true}) {
                for (int digit = 0; digit < 10; digit++) {
                    if (digit > K[where] - '0' && !sm_already) {
                        break;
                    }
                    int new_sum = (sum + digit) % D;
                    bool smaller = sm_already || digit < (K[where] - '0');
                    new_dp[new_sum][smaller] = add(new_dp[new_sum][smaller], dp[sum][sm_already]);
                }
            }
        }
        dp = new_dp;
    }
    
    int answer = add(dp[0][false], dp[0][true]);
    
    answer = subtract(answer, 1);
    
    printf("%d", answer);
    /*
    int ans = 0;
    for (int i = 1; i <= K; i++) {
        if (digit_sum(i) % D == 0) {
            ans += 1;
        }
    }
    printf("%d", ans);
    */
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		if(k<s.length()) {
			System.out.println(s.substring(0, k)+"...");
		}else {
			System.out.println(s);
		}




	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


Measured memory_bytes: 38776
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
      	int k = sc.nextInt();
      	int x = sc.nextInt();
      	int y = sc.nextInt();
		
      int sam = n*x;
      if(n>k){
        sam=sam-((x-y)*(n-k));
      }
     
      System.out.print(sam);
    }
}

Measured memory_bytes: 21844
n=int(input())
a=list(map(int, input().split()))
abs_a = []
#負の数を数えながら、絶対値でどれが一番小さいかを計算
min_a = 10**9
num_minus = 0
for i in range(n):
    abs_ai = abs(a[i])
    if a[i]<0:
        num_minus+=1
    if abs_ai<min_a:
        min_a=abs(abs_ai)
    abs_a.append(abs_ai)
ans=sum(abs_a)
if num_minus%2!=0:
    ans = ans-2*min_a
print(ans)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define int long long int
#define MOD 1000000007
#define pb push_back
using namespace std;
void solve() {
        int n, l;
        cin >> n >> l;
        string str[n];
        for(int i=0;i<n;i++)
                cin >> str[i];
        sort(str, str+n);
        string ans = "";
        for(int i=0;i<n;i++) {
                for(int j=0;j<l;j++) {
                        cout << str[i][j];
                }
        }
        cout << endl;
        return ;
}

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, c, d, e;
  cin >> A >> B;
  c = A+B;
  d = c/2;
  e = c%2;
  if (e == 0){
    cout << d << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
N, K = map(int, input().split())

S = input()

if N==1:
    print(0)
    exit()

b = 0
p1 = 0
p2 = 0
for i in range(N):
    if i == 0:
        if S[i] == S[i+1]:
            b += 1
        if S[i] == "L":
            p1 += 1
        else:
            if S[i] == "R" and S[i+1] == "L":
                p2 += 1
    elif 0 < i < N-1:
        if S[i] == S[i+1]:
            b += 1
        if S[i] == "R" and S[i+1] == "L":
            p2 += 1
    elif i == N-1:
        if S[i] == "R":
            p1 += 1

#print(b)
if K <= p2:
    b += 2*K
else:
    b += 2*K
    K -= p2
    b += max(p1, K)

print(min(N-1,b))

Measured memory_bytes: 3316
#include <iostream>
#include <cstdlib>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <queue>
#include <math.h>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;

const ll INF_MAX = 1e9, MOD = 1000000007;

const ll INF = 1e18;

bitset <10000> u;



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

	if (c - 1 - b > a)
		cout << a + b + 1 + b;
	else cout << c + b;
}

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

#include "bits/stdc++.h"

using namespace std;
#define int long long


class CMultipleGift {
public:
    void solve(std::istream &in, std::ostream &out) {
      int x, y;
      in >> x >> y;
      int t = x;
      int ans = 0;
      while (t <= y) {
        ans++;
        t *= 2;
      }
      out << ans << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  CMultipleGift solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(int i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

class runtime_modint {
  using u64 = std::uint_fast64_t;

  static u64 &mod() {
    static u64 mod_ = 0;
    return mod_;
  }

public:
  u64 a;

  runtime_modint(const u64 x = 0) : a(x % get_mod()) {}
  u64 &value() noexcept { return a; }
  const u64 &value() const noexcept { return a; }
  runtime_modint operator+(const runtime_modint rhs) const {
    return runtime_modint(*this) += rhs;
  }
  runtime_modint operator-(const runtime_modint rhs) const {
    return runtime_modint(*this) -= rhs;
  }
  runtime_modint operator*(const runtime_modint rhs) const {
    return runtime_modint(*this) *= rhs;
  }
  runtime_modint operator/(const runtime_modint rhs) const {
    return runtime_modint(*this) /= rhs;
  }
  runtime_modint &operator+=(const runtime_modint rhs) {
    a += rhs.a;
    if (a >= get_mod()) {
      a -= get_mod();
    }
    return *this;
  }
  runtime_modint &operator-=(const runtime_modint rhs) {
    if (a < rhs.a) {
      a += get_mod();
    }
    a -= rhs.a;
    return *this;
  }
  runtime_modint &operator*=(const runtime_modint rhs) {
    a = a * rhs.a % get_mod();
    return *this;
  }
  runtime_modint &operator/=(runtime_modint rhs) {
    u64 exp = get_mod() - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }

  runtime_modint pow(unsigned long n){
    runtime_modint res(1),a=*this;
    while(n){
      if(n%2){
        res*=a;
      }
      a*=a;
      n/=2;
    }
    return res;
  }


  static void set_mod(const u64 x) { mod() = x; }
  static u64 get_mod() { return mod(); }
};
using mint=runtime_modint;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;cin>>n>>k;
  mint::set_mod(1e9+7);
  vector<vector<mint>>dp(n+1,vector<mint>(n*n+1));
  auto tdp=dp;
  dp[0][0]=1;
  rep(i,n){
    rep(j,n+1)tdp[j].assign(n*n+1,0);
    rep(j,n+1){
      if(j<n)rep(k,n*n+1-2*j){
        tdp[j+1][k+2*j]+=dp[j][k];
      }
      rep(k,n*n+1-2*j){
        tdp[j][k+2*j]+=dp[j][k]*(2*j+1);
      }
      if(j>0)rep(k,n*n+1-2*(j)){
        tdp[j-1][k+2*(j)]+=dp[j][k]*(j)*(j);
      }
    }
    swap(dp,tdp);
  }
  cout<<dp[0][k].value()<<endl;
  return 0;

}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S seconnd
#define PB push_back
#define int ll

int n;
int f[1100][110];
ll p[1100][110];
ll ans=-INF;


void g(bool b[],int k){

  if(k==10){
    bool flag = false;
    rep(i,10){
      flag = flag||b[i];
    }
    if(!flag){
      return;
    }

    int res=0;
    rep(i,n){
      int t=0;
      rep(j,10){
        if(b[j]&&f[i][j]) t++;
      }
      res+=p[i][t];
    }
    ans = max(ans,res);
    return;
  }


  g(b,k+1);
  b[k]=true;
  g(b,k+1);
  b[k]=false;
}


signed main(){
  cin>>n;
  rep(i,n){
    rep(j,10){
      cin>>f[i][j];
    }
  }

  rep(i,n){
    rep(j,11){
      cin>>p[i][j];
    }
  }

  bool b[11]={};
  g(b,0);

  cout<<ans<<endl;

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,e;
	cin>>a>>b>>c>>d>>e;
	if(!a)cout<<1<<endl;
	if(!b)cout<<2<<endl;
	if(!c)cout<<3<<endl;
	if(!d)cout<<4<<endl;
	if(!e)cout<<5<<endl;
	return 0;
} 

Measured memory_bytes: 3632
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cassert>
#include <iostream>
#include <stdio.h>
#include <time.h>
 
using namespace std;

typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define endl "\n"
 
#define MOD 1000000007

long long modpow(long long a, long long b){ 
  long long r = 1LL;
  while(b){
    if(b & 1LL)r *= a;
    if(r >= MOD)r %= MOD;
    a *= a;
    if(a >= MOD)a %= MOD;
    b >>= 1LL;
  }
  return r%MOD;
}

#define N_MAX 8010

long long fact[N_MAX];
long long rfact[N_MAX];

long long nCr(long long n, long long r){ 
  long long ret = 1LL;
  ret *= fact[n];
  ret %= MOD;
  ret *= rfact[r];
  ret %= MOD;
  ret *= rfact[n-r];
  ret %= MOD;
  return ret;
}

int main(){
clr(fact,0);
fact[0]=1;
rep(i,1,N_MAX){
  fact[i] = fact[i-1]*i;
  fact[i] %= MOD;
}
clr(rfact,0);
rfact[0]=1;
rep(i,1,N_MAX){
  rfact[i] = rfact[i-1]*modpow(i,MOD-2);
  rfact[i] %= MOD;
}

  ll S;
  cin>>S;
  ll ans = 0;
  rep(i,1,700){
    ll a = S-i*3;
    if(a<0)continue;
    ans += nCr(a+i-1,a);
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){

  int i=0,b[10000];
  char a[10000];
  
  while( (scanf("%s",a)) != EOF){

  

    if(a[0] == '+'){
      b[i-2] = b[i-2] + b[i-1];
      i--;
    
    }

    
    else if(a[0] == '-'){
      b[i-2] = b[i-2] - b[i-1];
      i--;
    }

    
    else if(a[0] == '*'){
   
      b[i-2] = b[i-2] * b[i-1];
      i--;
      
    }

  else{
    

      b[i] = atoi(a);
      i++;
    }

    
  }

  
  printf("%d\n",b[i-1]);




  return 0;
}



Measured memory_bytes: 2128
N = gets.to_i
a = gets.split(' ').map(&:to_i)
b = gets.split(' ').map(&:to_i)

cnt = 0
N.times do |i|
	n = [a[i], b[i]].min
	a[i] = a[i] - n
	b[i] = b[i] - n
	cnt += n

	m = [a[i + 1], b[i]].min
	a[i + 1] = a[i + 1] - m
	b[i] = b[i] - m
	cnt += m
end

puts cnt

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

int buses[100005];
int N,K,C;

int main()
{
	int i,j;
	//freopen("at.in", "r", stdin);
	scanf("%d%d%d", &N, &C, &K);

	for(i=0; i<N; i++)
		scanf("%d", &buses[i]);

	sort(buses, buses+N);

	int ans = 0;

	for(i=0; i<N; i++){
		ans++;
		j = i+1;
		while(j<N && buses[j]-buses[i]<=K && j-i<C)
			j++;
		i = j-1;
	}

	printf("%d\n", ans);
	return 0;
}


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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pi;
typedef long double ld;
typedef pair<long double, long double> pld;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll MAX_N = 3030;

ll dp[MAX_N][MAX_N][4];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll i, j, k;
    ll R, C, K;
    cin >> R >> C >> K;
    vector<vll> map(R, vll(C, 0));
    for(i = 0; i < K; i++) {
        ll r, c, v;
        cin >> r >> c >> v;
        r--, c--;
        map[r][c] = v;
    }
    for(i = 0; i < R; i++) {
        for(j = 0; j < C; j++) {
            for(k = 0; k < 4; k++) {
                dp[i][j][k] = 0;
            }
        }
    }
    if(map[0][0] > 0) {
        dp[0][0][1] = map[0][0];
    }
    for(i = 0; i < R; i++) {
        for(j = 0; j < C; j++) {
            ll pmax = 0;
            if(i > 0) {
                pmax = max(dp[i - 1][j][0],
                           max(dp[i - 1][j][1],
                               max(dp[i - 1][j][2], dp[i - 1][j][3])));
            }
            // 0
            dp[i][j][0] = pmax;
            if(j > 0) {
                dp[i][j][0] = max(pmax, dp[i][j - 1][0]);
            }
            // 1
            if(map[i][j] == 0) {
                if(j > 0) {
                    dp[i][j][1] = dp[i][j - 1][1];
                }
            } else {
                dp[i][j][1] = pmax + map[i][j];
                if(j > 0) {
                    dp[i][j][1] = max(dp[i][j][1], dp[i][j - 1][1]);
                    dp[i][j][1] = max(dp[i][j][1], dp[i][j - 1][0] + map[i][j]);
                }
            }
            // 2, 3
            if(map[i][j] == 0) {
                if(j > 0) {
                    dp[i][j][2] = dp[i][j - 1][2];
                    dp[i][j][3] = dp[i][j - 1][3];
                }
            } else {
                if(j > 0) {
                    dp[i][j][2] =
                        max(dp[i][j - 1][2], dp[i][j - 1][1] + map[i][j]);
                    dp[i][j][3] =
                        max(dp[i][j - 1][3], dp[i][j - 1][2] + map[i][j]);
                }
            }
        }
    }
    ll ans = max(dp[R - 1][C - 1][0],
                 max(dp[R - 1][C - 1][1],
                     max(dp[R - 1][C - 1][2], dp[R - 1][C - 1][3])));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 357560
N=int(input())
A=[]
for i in range(2,55556):
  if i%5==1:
    j=2
    while j<i:
      if i%j==0:
        break
      j+=1
    if i-j==0:
      A.append(i)
  if len(A)>=N:
    break
print(*A[:N])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using p=pair<int,int>;
#define int long long
#define rep(i,N) for(int i=0;i<N;i++)

signed main(){
  string N;
  cin>>N;
  int num=0;
  rep(i,N.size())num+=N[i]-'0';
  string ans="No";
  if(num%9==0)ans="Yes";
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3716
#include <iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long 
#define jaldi_chal  ios_base::sync_with_stdio(0); cin.tie(0);
#define tr(c,i) for(auto i=(c).begin(); i != (c).end(); i++)
#define REP(i,k) for( ll i=0;i<k;i++)
#define REW(i,a,b) for(ll i=a;i<=b;i++)
#define M 1000000007
#define F first
#define dbg(x)  cout<<#x<<" " <<x<<endl;
#define S second
#define inf 1e10
#define endl "\n"


int main() {
jaldi_chal
ll n;
cin>>n;
ll flag=0;
for(ll i=n;i>0;i=i/10)
{
	if(i%10==7) flag=1;
}
if(flag) cout<<"Yes";
else cout<<"No";

	return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod_MOD1(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
ll mod_p(ll n ,ll p){n+= n<0?((-n)/p+1)*p:0; return n%=p;}
ll change_into_num(char s[] , ll len, ll p){ return !p ? 0 : POW(10,p-1)*(s[len-p]-'0') + change_into_num(s,len,p-1); }

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n,ans=0;
    scanf("%lld",&n);
    ll l[n],r[n];
    rep(i,0,n){
        scanf("%lld%lld",&l[i],&r[i]);
    }
    rep(i,0,n){
        ans+=r[i]-l[i]+1;
    }

    
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
import java.lang.*;
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        a += scan.nextInt();
        int b = scan.nextInt();
        
        if(a >= b) System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 21716
import sys
import math

def str_input():
    S = raw_input()
    if S[len(S)-1] == "\r":
        return S[:len(S)-1]
    return S

S = str_input()
n = input()

for i in xrange(n):
    arg = str_input().split()

    arg[1] = int(arg[1]);
    arg[2] = int(arg[2]);

    if arg[0] == "print":
        print S[arg[1]:arg[2]+1]
    elif arg[0] == "reverse":
        S = S[:arg[1]] + S[arg[1]:arg[2]+1][::-1] + S[arg[2]+1:]
    elif arg[0] == "replace":
        S = S[:arg[1]] + arg[3] + S[arg[2]+1:]

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
int n;
#define N 200000
#define LL long long
int ai[N], bi[N]; LL ans[N];
int shed[N], top;
LL sum[N];
int main()
{
    cin >> n;
    for (int i = 1; i <= n; ++ i) cin >> ai[i], bi[i] = ai[i];
    sort(bi + 1, bi + n + 1);
    for (int i = 1; i <= n; ++ i)
        if (ai[i] > ai[shed[top]])
            shed[++ top] = i;

    for (int i = top, j = n; j; -- j)
    {
        ans[shed[i]] += bi[j] - ai[shed[i - 1]];
        if (bi[j - 1] < ai[shed[i - 1]])
        {
            if (i >= 2) ans[shed[i - 1]] += 1ll * (n - j + 1) * (ai[shed[i - 1]] - ai[shed[i - 2]]);
            i --;
        }
    }
    for (int i = 1; i <= n; ++ i) cout << ans[i] << "\n";
}


Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int max = 0, x = 0, i;
		for(i = 0; i < s.length(); i++){
			if(s.charAt(i)== 'I'){
				x += 1;
			}else{
				x -= 1;
			}
			max = Math.max(max, x);
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 23764
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

string normalize(string s, char c, bool isLeft)
{
    if(c != '#'){
        if(s[0] != '#')
            replace(s.rbegin(), s.rend(), s[0], c);
        if(s[s.size()-1] != '#' && !isLeft)
            replace(s.begin(), s.end(), s[s.size()-1], c);
    }

    s += c;
    if(s[0] == 'A' && s.find('A', 1) == string::npos)
        return "";
    s = s.substr(1);

    char x = 'A';
    map<char, char> m;
    m['#'] = '#';
    for(unsigned i=0; i<s.size(); ++i){
        if(m.find(s[i]) == m.end()){
            m[s[i]] = x;
            ++ x;
        }
        s[i] = m[s[i]];
    }

    return s;
}

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

    map<pair<string, int>, long long> dp;
    dp[make_pair(string(w, '#'), s)] = 1;

    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            map<pair<string, int>, long long> next;
            for(map<pair<string, int>, long long>::iterator it=dp.begin(); it!=dp.end(); ++it){
                string s = it->first.first;
                int wall = it->first.second;

                if(wall <= (h-1-y)*w + (w-1-x)){
                    string t = normalize(s, 'Z', x==0);
                    if(t != "")
                        next[make_pair(t, wall)] += it->second;
                }

                if(wall > 0 && !(y == 0 && x == 0) && !(y == h-1 && x == w-1)){
                    string t = normalize(s, '#', x==0);
                    if(t != "")
                        next[make_pair(t, wall-1)] += it->second;
                }
            }
            dp.swap(next);
        }
    }

    long long ret = 0;
    for(map<pair<string, int>, long long>::iterator it=dp.begin(); it!=dp.end(); ++it){
        string s = it->first.first;
        int wall = it->first.second;
        if(s.find('B') == string::npos)
            ret += it->second;
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 5044
/*

*/

#include<stdio.h>

#define SIZE 1000000	//?????§?????????????????°???

int Main(char list[SIZE]);
int GetPrime(char list[SIZE]);	//??¨?????????????????????????????¨??????pl????´???°???????????????????????????

int main(int argc, char *argv[]){
	char pl[SIZE];	//?´???°????????????1???????´???°???0???????´???°??§????????????-1??????????????????
	GetPrime(pl);
	while( Main(pl) == 0 );
	return 0;
}

int Main(char list[SIZE]){
	int a = 0, d = 0, n = 0, sum, count = 0;	//???????????????????±????????´???°????????????????????°?????????????????¨???????????£????´???°?????°???
	if( scanf("%d %d %d", &a, &d, &n) != 3 ){ return -1; }
	if( a == 0 || d == 0 || n == 0 ){ return 1; }
	//n??????????´???°????±??????????
	for( sum = a; sum < SIZE; sum += d ){
		//?´???°??§????????°count???1????¶???????n??????????´???°???????????????????????????????????????
		if( list[sum] == 1 ){ count++; }
		if( count == n ){ break; }
	}
	printf("%d\n", sum);
	return 0;
}

int GetPrime(char list[SIZE]){
	int i = 0, j = 0;
	for( i = 0; i < SIZE; i++ ){ list[i] = -1; }
	list[0] = 0;
	list[1] = 0;
	list[2] = 1;
	//2???????????¶??°?????¨????´???°??§????????????
	for( j = 4; j < SIZE; j+=2 ){ list[j] = 0; }
	//3??\???????\???°??????????????¨????????????????????????????????¨?????????
	for( i = 3; i < SIZE; i+=2 ){
		if( list[i] == 0 ){ continue; }
		list[i] = 1;
		for( j = 2 * i; j < SIZE; j+=i ){ list[j] = 0; }
	}
	return 0;
}

Measured memory_bytes: 1572
#include<cstdio>
#include<cstring>
using namespace std;
char s[20], S[20];
int main()
{
	scanf("%s", s);
	int len = strlen(s);
	int cnt = 0;
	for(int i = 0; i < len; i++)
	{
		if(s[i] == '1')
		{
			S[cnt] = '1';
			cnt++;
		}
		if(s[i] == '0')
		{
			S[cnt] = '0';
			cnt++;
		}
		if(s[i] == 'B')
		{
			if(cnt)cnt--;
			S[cnt] = '\0';
		}
	}
	printf("%s\n", S);
	return 0;
}


Measured memory_bytes: 128
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
// #define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
  void solve()
  {
i64 a,b,c,d;
cin>>a>>b>>c>>d;
i64 ans=-2e18;
uax(ans,a*c);
uax(ans,a*d);
uax(ans,b*c);
uax(ans,b*d);
cout<<ans;

  }
  
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
    #endif
int t=1;
while(t--)
{
  solve();
}

    return 0;
  }


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

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

    int left = 0, right = 0;
    for( int i = 0;  i< N; i++ ){
        if( S[i] == ')' && right == 0 ){
            left++;
        } else if ( S[i] == ')' ){
            right--;
        }
        if( S[i] == '(' ){
            right++;
        }
    }

    for( int i = 0; i < left; i++ ){
        cout << '(';
    }
    cout << S;
    for( int i = 0; i < right; i++ ){
        cout << ')';
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	int a,b;
	while(~scanf("%d%d",&a,&b))
	{
		char c[200][200]={'\0'};
		getchar();
		for(int i=0;i<a;i++)
		scanf("%s",c[i]);
		for(int u=0;u<a;u++)
		for(int i=0;i<a-(u+1);i++)
		{
			if(strcmp(c[i],c[i+1])>0)
			for(int j=0;j<b;j++)
			{
				char s=c[i][j];
				c[i][j]=c[i+1][j];
				c[i+1][j]=s;
			}
		}
		for(int i=0;i<a;i++)
		printf("%s",c[i]);
		printf("\n");
	}
}

Measured memory_bytes: 888
n = int(input())
k = [[0] * 10 for _ in range(10)]
for i in range(n + 1):
    l = int(str(i)[0])
    r = int(str(i)[-1])
    k[l][r] += 1
ans = 0

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


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

using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll solve(ll n, ll k) {
    ll res = 0;
    REP(i, min(n,k+1)) {
        ll tmp = (COM(n, i) * COM(n-1, (n-i)-1)) % MOD;
        res += tmp;
        res %= MOD;
    }
    return res;
}
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    COMinit();
    cout << solve(n,k) << endl;
    return 0;
}


Measured memory_bytes: 12160
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int r, ans = 0;
    cin >> r;
    if(r < 1200){
        cout << "ABC" << endl;
    }else if(r < 2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    return 0;
}


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

int main()
{
    int A,B;
    cin>>A>>B;
    int p = 0;
    int m = 0;
    int k = 0;
    p = A+B;
    m = A-B;
    k = A*B;
    cout<<max({p,m,k})<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e5 + 5;
const int MOD=1e9 + 7;

int32_t main()
{
	IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		int l ,r,d;
		cin >> l >> r >> d;
		int c = 0;
		rep(i,l,r)
		{
			if(i%d==0)
				c++;
		}
		cout << c << endl;
	}
}

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

using namespace std;

#define int          long long
#define mem(a , v)   memset(a , v , sizeof a)
#define all(v)       v.begin() , v.end()
#define err(x)       cerr << #x << " is : " << x << endl
#define endl         "\n"



const int MOD   =   1e9 + 7;
const int N     =   1e6 + 20;
const int big   =   1e14;

void solve()
{
    int n;
    cin >> n;
    for(int i = 1;  ; i++)
    {
        if(i * 1000 >= n)
        {
            cout << i * 1000 - n << endl;
            return;
        }
    }

    return;
}


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

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


Measured memory_bytes: 3688
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(void){
    double r;
    cin>>r;
    
    double pi =acos(-1);
    cout<<fixed<<setprecision(6);
    double area = r * r * pi;
    double cir =(r+r) * pi;
    cout << area << " " << cir << endl;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio() ios_base::sync_with_stdio(false);
#define rmod(x, y) ((((x)%(y))+(y))%(y))
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
template<typename T, typename R = null_type, typename C = less<T>>
tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update> ordered_set(){
	return tree<T, R, C, rb_tree_tag, tree_order_statistics_node_update>();
}

const int maxn = 3005, mod = 998244353;
int n, S, a[maxn], dp[maxn][maxn][3];

/*
k = 0: before starting L
k = 1: currently in [L, R]
k = 2: finished [L, R]
*/

void add(int &x, int y){ y%=mod, x+=y, x%=mod;}

int main(){
	scanf("%d %d", &n, &S);
	for(int i = 1; i<=n; i++) scanf("%d", &a[i]);
	dp[0][0][0] = 1;
	for(int i = 1; i<=n; i++){
		for(int s = 0; s<=S; s++){
			add(dp[i][s][0], dp[i-1][s][0]);
			add(dp[i][s][1], dp[i-1][s][1] + dp[i-1][s][0]);
			add(dp[i][s][2], dp[i-1][s][2] + dp[i][s][1]);
			if (s>=a[i]){
				add(dp[i][s][1], dp[i-1][s-a[i]][0]+dp[i-1][s-a[i]][1]);
				add(dp[i][s][2], dp[i-1][s-a[i]][0]+dp[i-1][s-a[i]][1]);
			}
		}
	}
	printf("%d\n", dp[n][S][2]);
	return 0;
}


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

int main()
{   int a[4],b,i,d,c,n=0,m=0,k=0,x=0,y;
    for(i=0;i<4;i++){
    scanf("%d",&a[i]);
    if(a[i]==1)n++;
    if(a[i]==9)m++;
    if(a[i]==7)k++;
    if(a[i]==4)x++;
    }
    if(n==1&&m==1&&k==1&&x==1)
    printf("YES");
    else printf("NO");

    return 0;
}


Measured memory_bytes: 128
import itertools
import math
s =int(input())
a = s
count = 0
if a <= 2:
    print(4)
    quit()
if a == 3:
    print(9)
    quit()
while a >=4:
    if a % 2 == 0:
        a /= 2
    else:
        a = 3 * a + 1
    count += 1

print(count+3)

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <iomanip>
#include <sstream>

typedef long long ll;

using namespace std;

ll ans[3];

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

  cin>>a>>b>>c;

  int blue=0,red=0;

  int ans1=0,ans2=0,ans3=0;

  if(c%2==1){
    ans[0]=a*b;
  }
  if(b%2==1){
    ans[1]=a*c;
  }
  if(a%2==1){
    ans[2]=b*c;
  }
  sort(ans,ans+3);

  if(a%2==0||b%2==0||c%2==0)ans[0]=0;

  cout<<ans[0]<<endl;

  return 0;
}


Measured memory_bytes: 256