akhauriyash/Code-Regression huggingface dataset:
n = int(input())
k, *b = map(int, input().split())
t = sum(1<<i for i in b)
for i in range(1 << n):
    if i & t != t:
        continue
    rs = [str(i) + ":"]
    for j in range(n):
        if i & (1 << j) != 0:
           rs.append(j)
    print(*rs) 


Measured memory_bytes: 6180
import numpy as np

c1 = [int(i) for i in input().split(" ")]
c2 = [int(i) for i in input().split(" ")]
c3 = [int(i) for i in input().split(" ")]
c = np.array([c1, c2, c3])

a = [[i[2] - i[1], i[1] - i[0]] for i in c.T]
b = [[i[2] - i[1], i[1] - i[0]] for i in c]

if a[0] == a[1] and a[2] == a[1] and b[0] == b[1] and b[1] == b[2]:
    print("Yes")
else:
    print("No")

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

int main(){
    long long n;
    cin>>n;

    long long h[n+1];
    h[0]=0;
    long long ans=0;
    long long cost[n+1];
    cost[0]=0;


    for(int i=1;i<=n;i++)
        cin>>h[i];


     cost[1]=0;
     cost[2]=abs(h[2]-h[1]);


    for(int i=3;i<=n;i++){
         cost[i]=min((abs(h[i]-h[i-1])+cost[i-1]),(abs(h[i]-h[i-2])+cost[i-2]));
    }

    cout<<cost[n]<<endl;

}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    long int n, T;
    cin >> n >> T;
    long int t[n];
    rep(i, n) cin >> t[i];
    long int ans = 0;
    long int dif = 0;

    rep(i, n - 1){
        ans += min(T, t[i+1] - t[i]);
    }
    ans += T;
    cout << ans << endl;
}


Measured memory_bytes: 1792
a,b=map(int,input().split())

if a>0 and b>0:
    print('Positive')
    exit()

elif a<=0 and 0<=b:
    print('Zero')
    exit()
else:
    if abs(b-a)%2==0:
        print('Negative')
        exit()
    else:
        print('Positive')
        exit()

Measured memory_bytes: 9140
#include<iostream>
using namespace std;
void trace(int n, int *A)
{
	cout << A[0];
	for(int i = 1; i<n;i++)
		cout<<" "<<A[i];
	cout << endl;
}

void ist(int n, int *A)
{
	int i,j,v;
	for(i = 1; i<n;i++)
	{
		v = A[i];
		j = i-1;
		while(j>=0 && A[j] > v)
			{
				A[j+1] = A[j];
				j--;
			}
		A[j+1] = v;
		trace(n,A);	
	}
}

int main()
{
	int array[200];
	int n;
	cin >> n;
	for(int i =0; i<n;i++)
		cin>>array[i];
	trace(n,array);
	ist(n,array);
	
	return 0;
	
	
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int t[100009],x[100009],y[100009];
  cin>>n;
  for(int i=1;i<=n;i++)cin>>t[i]>>x[i]>>y[i];
  t[0]=0;
  x[0]=0;
  y[0]=0;
  for(int i=0;i<n;i++){
    int m=abs(x[i+1]-x[i])+abs(y[i]-y[i+1]);
    if(m>(t[i+1]-t[i])||m%2!=(t[i+1]-t[i])%2){
	cout<<"No"<<endl;
	return(0);
    }
  }
  cout<<"Yes"<<endl;
  return(0);
}


Measured memory_bytes: 1408
N,M=list(map(int,input().split()))
ans=-1
tmp=[]
A=[]
S=[]
C=[]

for m in range(M):
  s,c=list(map(int,input().split()))
  S.append(s)
  C.append(c)

x=1 if N==1 else 0
for i in range(10**(N-1)-x,10**N):
  tmp.clear()
  for m in range(M):
    try:
      if int(list(str(i))[S[m]-1])==C[m]:
        tmp.append(True)
      else:
        tmp.append(False)
    except IndexError:
      tmp.append(False)
  if tmp.count(True)==M:
    if int(list(str(i))[0])!=0 or N==1:
      ans=i
    break
  
if M==0:
  ans=10**(N-1)
  if N==1:
    ans=0
print(ans)
      

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
  char s[100] = {};
  char t[100] = {};
  int n = 0;
  int i = 0;
  int j = 0;
  int hoge = -1;
  int flag = 0;
  
  scanf("%d",&n);
  scanf("%s",s);
  scanf("%s",t);
  for(i=0;i<n;i++){
    flag = 1;
    for(j=0;j<n-i;j++){
      if(s[j+i] == t[j]){
        flag = 1;
      }else{
      	flag = 0;
        break;
      }
    }
    if(flag){
      hoge = i;
      break;
    }
  }
  
  if(hoge != -1){
    printf("%d",(n-hoge)+2*(hoge));
  }else{
    printf("%d",2*n);
  }
  return 0;
}

Measured memory_bytes: 128
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<vector<int> > d(10, vector<int>(10));
	for (int i = 1; i <= N; ++i) {
		string s = to_string(i);
		++d[s.front() - '0'][s.back() - '0'];
	}
	long long ans = 0;
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			ans += 1LL * d[i][j] * d[j][i];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {

    int i, j;
    for (i = 1; i <= 9; i++) {
        for (j = 1; j <= 9; j++){
            cout << i << "x" << j << "=" << i*j <<"\n";
        }
            }
    
    return 0;
}

Measured memory_bytes: 0
import numpy as np

n, k = map(int, input().split())
a = np.array(list(map(int, input().split())))
mod = 10 ** 9 + 7

cnt1 = 0
cnt2 = 0
for i in range(n - 1):
    cnt1 += (a[i + 1:] < a[i]).sum()

for i in range(n):
    cnt2 += (a < a[i]).sum()

cnt1 = int(cnt1) * k % mod
cnt2 = int(cnt2) * (k * (k - 1) // 2) % mod
print((cnt1 + cnt2) % mod)

Measured memory_bytes: 13088
#include <stdio.h>

int main(){
	int a,b,i,H,W;
	
	for (i=0;i<=1;){
		scanf ("%d %d",&H,&W);
		if (W+H==0){
		break;
		}
		for (a=1;a<=H;a++){
			for (b=1;b<=W;b++){
				if (a==1||a==H||b==1||b==W){
					printf ("#");
				}
				else {
					printf (".");
				}
			}
			printf ("\n");
		}
		printf ("\n");
	}
	return 0;
}

Measured memory_bytes: 572
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
/*int inv[1000001]={0};
void findinverse(){inv[1] = 1;for(int i = 2; i <=1e6 ; ++i)	inv[i] = (mod - (mod/i) * inv[mod%i] % mod) % mod;}
*/
using namespace std;
int solve()
{
	int n,m,k;
	cin>>n>>m>>k;
	int a[n],b[m];
	int sum=0;
	int cnt[n+1]={0},cnt2[m+1]={0};
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
		cnt[i+1]=sum;
	}
	sum=0;
	for(int i=0;i<m;i++){
		cin>>b[i];
		sum+=b[i];
		cnt2[i+1]=sum;
	}
	int mx=INT_MIN;
	forci(0,n+1){
		if(k-cnt[i]>=0){
			int x=upper_bound(cnt2,cnt2+m,k-cnt[i])-cnt2;
			if(cnt2[x]>k-cnt[i])
				x--;
			mx=max(i+x,mx);
		}	
	}
	forci(0,m+1){
		if(k-cnt2[i]>=0){
			int x=upper_bound(cnt,cnt+n,k-cnt2[i])-cnt;
			if(cnt[x]>k-cnt2[i])
				x--;
			mx=max(i+x,mx);
		}	
	}
	cout<<mx<<endl;
	return 0;
}
signed main()
{
	fastio;
//	test
		solve();
}






Measured memory_bytes: 9868
#include<iostream>
#include<string>
#include<cmath>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int n,m;
	while(cin>>n>>m && n && m)
	{
		int card1[100000]={};
		int card2[100000]={};
		int sum1=0,sum2=0,mi,sum3=0;
		int ans[3]={};
		
		rep(i,n)
		{
			cin>>card1[i];
			sum1+=card1[i];
		}
		rep(i,m)
		{
			cin>>card2[i];
			sum2+=card2[i];
		}
		
		mi=sum1+sum2;
		
		rep(i,n)
		{
			rep(j,m)
			{
				if( sum1-card1[i]+card2[j] == sum2-card2[j]+card1[i] )
				{
					sum3=card1[i]+card2[j];
					mi=min(sum3,mi);
					
					if(sum3==mi)
					{
						ans[0]=card1[i];
						ans[1]=card2[j];
					}
				}
			}
		}
		if(ans[0])cout<<ans[0]<<" "<<ans[1]<<endl;
		else cout<<"-1"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1944
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

H, W, M = map(int, input().split())
P = [list(map(int, input().split())) for _ in range(M)]

Xs = [0] * (W + 1)
Ys = [0] * (H + 1)
s = set()

for p in P:
    Xs[p[1]] += 1
    Ys[p[0]] += 1
    s.add((p[1], p[0]))

xmax = max(Xs)
ymax = max(Ys)

XMs = []
YMs = []
for i in range(W + 1):
    if Xs[i] == xmax:
        XMs.append(i)

for i in range(H + 1):
    if Ys[i] == ymax:
        YMs.append(i)


def ans():
    for x in XMs:
        for y in YMs:
            if (x, y) not in s:
                return xmax + ymax

    return xmax + ymax - 1


if len(XMs) * len(YMs) > M:
    print(xmax + ymax)
else:
    print(ans())


Measured memory_bytes: 119648
//O.cpp
#include <bits/stdc++.h>
using namespace std;
#define N 1000000007;

int dp_util(vector< vector<int> > &dp, vector< vector<bool> > &A, int M, int women){

		if(dp[M][women] != -1)
			return dp[M][women];

		int n = A.size();
		int one = 1;
		int a, b;
		long long int ans = 0;
		if(!M){
			for(int j = 0; j < n; j++){
				if(A[0][j] && ((one << j) & women)){
					dp[0][women] = 1;
					return 1;
				}
			}
			dp[0][women] = 0;
			return 0;
		}
		
		
		
		for(int j = 0; j < n; j++){
			if(A[M][j] && ((one << j) & women)){
				
				b = women & ~(one << j);
				ans = (ans + dp_util(dp, A, M-1, b))%N;
			}
		}
		
		dp[M][women] = ans;
		return ans;
}

int main(){	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int M = pow(2, 21);
	int n;
	cin >> n;
	vector< vector<int> > dp(n, vector<int>(M, -1));

	vector< vector<bool> > A(n, vector<bool>(n, 0));
	int temp;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> temp;
			A[i][j] = temp;
		}
	}

	int p = pow(2, n) - 1;
	int ans = 0;
	ans = dp_util(dp, A, n-1, p);
	cout << ans << endl;
	

	return 0;
}
//https://atcoder.jp/contests/dp/submissions/11206860




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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int N;
    cin >> N;
    vector<pair<int,int>> task(N); 
    REP(i, N) cin >> task[i].second >> task[i].first;

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

    // 締め切りが早い順に仕事を行うのが最適
    bool ans = true;
    long long time = 0;
    REP(i, N){
        if(time + task[i].second > task[i].first){
            ans = false;
            break;
        }
        time += task[i].second;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
 
int main(){
  
  string A,B,C;
  cin>>A>>B>>C;
  if(A.at(A.size()-1)==B.at(0)&&B.at(B.size()-1)==C.at(0)){
      cout<<"YES"<<endl;
  }
  else{
      cout<<"NO"<<endl;
  }
}

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

int main(){
	int a, b;
	scanf("%d%d", &a, &b);
	int answer;
	if((1<=a)&&(a<=9)&&(1<=b)&&(b<=9)){
		answer = a*b;
	}
	else answer = -1;
	
	printf("%d\n", answer);
	
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception{
		// TODO ?????????????????????????????????????????????
		int a, b, c;
		String str[];
		int div_cnt = 0;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        str = br.readLine().split(" ");
        a = Integer.parseInt(str[0]);
        b = Integer.parseInt(str[1]);
        c = Integer.parseInt(str[2]);

        for(int i = 1; i <= c; i++){
        	if(c % i == 0){
        		for(int j = a + div_cnt; j <= b; j++){
        			if(i == j){
        				div_cnt++;
        			}
        		}
        	}
        }
        System.out.println(div_cnt);

	}

}

Measured memory_bytes: 24468
x, y = map(int, input().split())

b = abs(abs(x)-abs(y))
if x * y < 0:
    print(b+1)
elif 0 < y < x or y < x < 0:
    print(b+2)
elif (y == 0 and x > 0) or (x == 0 and y < 0):
    print(b+1)
else:
    print(b) 


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

#define MAX 100000

int partition(int A[], int p, int r)
{
  int n, i, j, x, tmp;

  x = A[r];
  i = p - 1;

  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i + 1];
  A[i + 1] = A[r];
  A[r] = tmp;

  return i + 1;
}

int main(void)
{
  int i, n, q, A[MAX];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }

  q = partition(A, 0, n - 1);

  for(i = 0; i < n; i++){
    if(i) printf(" ");

    if(i == q) printf("[");
    printf("%d", A[i]);
    if(i == q)  printf("]");

  }
  printf("\n");
  return 0;
}



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

using namespace std;

typedef long long ll;

ll mod=1e9+7;

ll  Suan(ll  a, ll  n, ll  m)	//a的n次幂对m取模
{
    long long ans = 1;
    while(n)
    {
        if(n&1)
        {
            ans = (ans * a) % m;
        }
        a = (a * a) % m;
        n >>= 1;
    }
    return ans;
}

ll CC(ll n,ll m)    //n小于1e5,可以阶乘打表
{
    if(m>n)
        return 0;
    ll a=1,b=1,i;
    for(i=1; i<=m; ++i)
    {
        a=a*(n-m+i)%mod;
        b=b*i%mod;
    }
    return a*Suan(b,mod-2,mod)%mod; //费马小定理
}

ll Lucas(ll n,ll m) //C(n,m)%mod
{
    if(m==0)
        return 1;
    else
        return (CC(n%mod,m%mod)*Lucas(n/mod,m/mod))%mod;
}

int main()
{
    ll x,y,z,a,b,c,d,e,i,j;
    scanf("%lld%lld",&x,&y);
    z=x+y;
    if(z%3)
    {
        printf("0\n");
    }
    else
    {
        a=z/3,b=2*a;
        c=abs(x-a);
        d=abs(y-b);
        if(x-a<0||y-a<0)
        {
            printf("0\n");
            return 0;
        }
        if(c!=d)
        {
            printf("0\n");
        }
        else
        {
            if(c<=a)
            {
                e=Lucas(a,c);
                printf("%lld\n",e);
            }
            else
            {
                while(1);
            }
            //cout<<c<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
#define TIME ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

    const ll N = 1e2 + 7;
    const ll mod = 1e9 + 7;
    const ll inf = 1e9;



void solve(){
    int a , b;
    int k;
    cin >> k >> a >> b;
    while(a <= b){
        if(a % k == 0){
            cout << "OK";
            return;
        }
        ++ a;
    }
    cout << "NG";
}

int main(){
    TIME
    int tt = 1;
    //cin >> tt;
    while(tt --){
            solve();
    }
}

/**

**/


Measured memory_bytes: 3648
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=1e5+19;

int A[N];
int n,x,tmp;
ll res;

int main(){
	n=IN(),x=IN();
	For(i,1,n+1) A[i]=IN();
	For(i,2,n+1){
		if (A[i]+A[i-1]<=x) continue;
		tmp=min(A[i]+A[i-1]-x,A[i]);
		res+=tmp;
		A[i]-=tmp;
		if (A[i]+A[i-1]<=x) continue;
		tmp=A[i]+A[i-1]-x;
		res+=tmp;
		A[i-1]-=tmp;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
  long long n,m;
  cin>>n>>m;
  if(n>=m/2) cout<<m/2<<endl;
  else cout<<n+(m-2*n)/4<<endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int,input().split()))
    x = 0
    for i in range(n):
        x = x + a[i]*(-1)**i
    ans = [x//2]
    for i in range(n-2):
        ans.append(a[i]-ans[-1])
    ans.append(a[n-1]-ans[0])
    for i in range(n):
        ans[i] = ans[i]*2
    print(' ' .join(list(map(str,ans))))

if __name__ == "__main__":
    main()


Measured memory_bytes: 24856
n =int(input())
A = list(map(int,input().split()))

ans = [0]*n

for i in range(n)[::-1]:
  if i >= n//2:
    ans[i] = A[i]
  else:
    tmp = 0
    j = i+1
    while j<=n:
      tmp += ans[j-1]
      j += i+1
    if A[i] == 1:
      if tmp % 2 != A[i]:
        ans[i] = A[i]              
    else:      
      if tmp % 2 == 1:
        ans[i] = 1
    
print(sum(ans))
print(*[i+1 for i in range(n) if ans[i] == 1])

Measured memory_bytes: 17836
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

tmp = 10**6

ans = [[0] * w for _ in range(h)]
for i in range(h):
   for j in range(w):
      if s[i][j] == '#':
         ans[i][j] = tmp
         if i-1 >= 0:
            ans[i-1][j] += 1
            if j-1 >= 0:
               ans[i-1][j-1] += 1
         if j-1 >= 0:
            ans[i][j-1] += 1
         if i+1 < h:
            ans[i+1][j] += 1
            if j+1 < w:
               ans[i+1][j+1] += 1
         if j+1 < w:
            ans[i][j+1] += 1
         if i-1 >= 0 and j+1 < w:
            ans[i-1][j+1] += 1
         if i+1 < h and j-1 >= 0:
            ans[i+1][j-1] += 1

for x in ans:
   print(''.join(['#' if y >= tmp else str(y) for y in x]))


Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

int get_int2(int64_t *a1, int64_t *a2) {
  scanf("%lld %lld", a1, a2);
  return 0;
}

struct product {
    int64_t value;
    int64_t weight;
};

#define NUM_MAX 40
#define NUM_2_MAX (1<<20)

int asc(const void *a1, const void *a2) {
    struct product *pa1 = (struct product*)a1;
    struct product *pa2 = (struct product*)a2;
    if(pa1->weight == pa2->weight) {
        if(pa1->value < pa2->value) return -1;
        if(pa1->value == pa2->value) return 0;
        return 1;
    }
    if(pa1->weight < pa2->weight) return -1;
    return 1;
}

void enum_sum(struct product *ps, int offset, int size, struct product *out, int *idx) {
    int pat;
    int i;
    static struct product tmp[NUM_2_MAX];
    memset(tmp, NUM_2_MAX, sizeof(struct product)*(NUM_2_MAX));
    for(pat = 0; pat < (1<<size); pat++) {
        struct product p = {0, 0};
        for(i = 0; i < size; i++) {
            if(!(pat & (1<<i))) continue;
            p = (struct product){p.value+ps[i+offset].value, p.weight+ps[i+offset].weight};
        }
        tmp[pat] = p;
    }
    qsort(tmp, pat, sizeof(struct product), asc);
    tmp[pat++] = (struct product){0, INT64_MAX};
    int64_t prev = tmp[0].weight;
    int pidx = 0;
    int64_t value_max = 0;
    for(i = 0; i < pat; i++) {
        struct product p = tmp[i];
        if(prev != p.weight) {
            out[pidx++] = (struct product){value_max, prev};
            prev = p.weight;
        }
        value_max = max(value_max, p.value);
    }
    *idx = pidx;
    return;
}

int lower_bound(struct product *ps, int size, int64_t key) {
    int low = -1;
    int high = size;
    while(low + 1 < high) {
        int mid = (low + high) / 2;
        // upper bound
        if(ps[mid].weight <= key) {
            low = mid;
        } else {
            high = mid;
        }
    }
    return low;
}

int main(void) {
    int num;
    int64_t limit;
    get_int2((int64_t*)&num, &limit);
    int i;
    struct product prods[NUM_MAX];
    for(i = 0; i < num; i++) {
        get_int2(&prods[i].value, &prods[i].weight);
    }

    int num_2 = num/2;
    static struct product prods1[NUM_2_MAX];
    int pidx1 = 0;
    static struct product prods2[NUM_2_MAX];
    int pidx2 = 0;
    enum_sum(prods, 0, num_2, prods1, &pidx1);
    enum_sum(prods, num_2, num - num_2, prods2, &pidx2);
#ifdef DEBUG
    printf("%d %d\n", pidx1, pidx2);
#endif

    int64_t ans = 0;
    for(i = 0; i < pidx1; i++) {
        struct product p = prods1[i];
        if(p.weight > limit) continue;
        int idx = lower_bound(prods2, pidx2, limit-p.weight);
#ifdef DEBUG
        printf("%d, %lld -> %lld+%lld\n", idx, limit-p.weight, p.value, prods2[idx].value);
#endif
        ans = max(p.value + prods2[idx].value, ans);
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 67320
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2709
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<array>

using namespace std;

int log(int base, int n, int count)
{
    return n == 0 ? count : log(base, (n - 1) / base, count + 1);
}

int main()
{
    int N, M, K;
    cin >> N >> M >> K;

    map<int, int> toDR{};

    vector<int> d(0);
    for(int i = 0; i < M; i++)
    {
        int tmp{ 0 };
        cin >> tmp;
        d.push_back(tmp);
        toDR.insert(make_pair(tmp, i));
    }

    vector< vector<int> > v{};
    for(int i = 0; i < N; i++)
    {
        vector<int> tmp_v{};
        for(int j = 0; j < K; j++)
        {
            int tmp{ 0 };
            cin >> tmp;
            tmp_v.push_back(tmp);
        }
        v.push_back(tmp_v);
    }

    //???????????????????????????????????????
    //?????§??????????????? ?????§????????????

    queue<int> que{};

    //?????????????????¨??????????????¨?±??????????
    //?????????
    que.push((1 << M) - 1);

    array<int, 1 << 16 > come;
    come.fill(-1);
    come[que.front()] = 0;

//    int loopCount = 0;
    while(que.front() != 0)
    {

        int dr = que.front();

        for(int i = 0; i < K; i++)
        {
            //loopCount++;

            int nextState = 0;
            for(int j = 0; j < M; j++)
            {
                if( dr & (1 << j) )
                {
                    if(toDR.count(v[d[j] - 1][i]) == 0)continue;

                    //v[d[j]][i]????§????
                    nextState |= (1 << (toDR[v[d[j] - 1][i]]) );
                }

            }

            if(nextState == 0)
            {
                //?????????
          //      for(int i = 0; i < 10; i++)
        //            cout << come[i] << " ";

                cout << come[dr] + 1 << endl;
                return 0;
            }

            //que?????????
            if(come[nextState] == -1)
            {
                que.push(nextState);
                come[nextState] = come[dr] + 1;
            }
        }
        que.pop();
    }

    return 0;
}

Measured memory_bytes: 3548
#include <stdio.h>

int main() {
    int i, ans = 0;
    unsigned long n, h, w, a, b;

    scanf("%lu%lu%lu", &n, &h, &w);

    for (i = 0; i < n; i++) {
        scanf("%lu%lu", &a, &b);
        if (h <= a && w <= b) {ans++;}
    }

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


Measured memory_bytes: 128
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        A: [i64; N],
    }
    let mut ans1 = 0_i64;
    let mut ans2 = 0_i64;
    let mut res = 0_i64;
    for i in 0..N{
        res += A[i];
        if i%2==0{
            if res <= 0{
                ans1 -= res-1;
                res = 1;
            }
        }else{
            if res >= 0{
                ans1 += res+1;
                res = -1;
            }
        }
    }

    res = 0;
    for i in 0..N{
        res += A[i];
        if i%2==1{
            if res <= 0{
                ans2 -= res-1;
                res = 1;
            }
        }else{
            if res >= 0{
                ans2 += res+1;
                res = -1;
            }
        }
    }
    println!("{}",min(ans1,ans2));
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<int> arr(n+1,0);
    for(int i=1;i<n;i++){
        int x;
        cin>>x;
        arr[x]++;
    }
    for(int i=1;i<=n;i++){
        cout<<arr[i]<<endl;
    }
}

Measured memory_bytes: 4048
#2019/10/25
# N = int(open(0).read())
N = int(input())
maxCake = N//4+1
maxDon = N//7+1
flg =False
for i in range(maxCake):
    for j in range(maxDon):
        if i*4+j*7==N:
            print('Yes')
            flg = True
            break;
    if flg == True:
        break
if flg == False:
    print('No')
       

Measured memory_bytes: 2940
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;
int n,m;
int a[200000];

int main(){
  cin >> n >> m;
  REP(i,m){
    int m1,m2;
    cin >> m1 >> m2;
    a[m1-1]++;
    a[m2-1]++;
  }
  REP(i,n){
    cout << a[i] << endl;
  }
  return 0;
}


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


int main() {
    long long a, b;
    cin >> a >>b;

    if (a > 0 && b > 0) {
        cout << "Positive" << endl;
        return 0;
    }

    if (a < 0 && b > 0) {
        cout << "Zero" << endl;
        return 0;
    }

    if (abs(a - b) % 2 == 0) {
        cout << "Negative" << endl;
    } else {
        cout << "Positive" << endl;
    }

}

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

const int N = 300004;
int E[N], W[N];

int main() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i = 0 ; i < n; ++i) {
        E[i + 1] = (s[i] == 'E') ? 1 : 0;
        W[i + 1] = (s[i] == 'W') ? 1 : 0;
        E[i + 1] += E[i];
        W[i + 1] += W[i];
    }
    int mint = INT_MAX;
    for(int i = 1; i <= n; ++i) {
        int curt = 0;
        curt = W[i-1] + E[n] - E[i];
        mint = min(mint, curt);
    }

    cout<<mint<<endl;

    return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd



int main() {
  ll n,m;
  cin>>n>>m;
  if(n==1&&m!=1){
    cout<<m-2;
  }else if(m==1&&n!=1){
    cout<<n-2;
  }else if(m==1&&n==1){
    cout<<1;
  }else{
  cout<<(n-2)*(m-2);
  }
  return 0;
}



Measured memory_bytes: 256
N = int(input())
if 400<= N < 600:
    c = '8'
elif 600<= N < 800:
    c = '7'
elif 800 <= N < 1000:
    c = '6'
elif 1000 <= N < 1200:
    c = '5'
elif 1200 <= N < 1400:
    c = '4'
elif 1200 <= N < 1600:
    c = '3'
elif 1600 <= N < 1800:
    c = '2'
elif 1800 <= N < 2000:
    c = '1'
print(c)

Measured memory_bytes: 9180
a, b = map(int, input().split())
flag = False
if a % 3 == 0 :
    flag = True
elif b % 3 == 0 :
    flag = True
elif (a+b) % 3 == 0 :
    flag = True
if flag == True :
    print("Possible\n")
else :
    print("Impossible\n")


Measured memory_bytes: 2940
#include<iostream>
#include<string>
using namespace std;
string s,t;
int dp[3001][3001];
char ans[3005];
int main()
{
	cin>>s>>t;s=" "+s;t=" "+t;
	int ns=s.size()-1,nt=t.size()-1;
	for(int i=1;i<=ns;i++)
		for(int j=1;j<=nt;j++)
		{
			if(s[i]==t[j])dp[i][j]=dp[i-1][j-1]+1;
			dp[i][j]=max(dp[i][j],max(dp[i][j-1],dp[i-1][j]));
		}
	int i=ns,j=nt,cnt=dp[i][j];ans[cnt+1]='0';
	while(i&&j)
		if(s[i]==t[j])
			ans[cnt--]=s[i],i--,j--;
		else if(dp[i][j]==dp[i-1][j])
			i--;
		else j--;
	for(int i=1;i<=dp[ns][nt];i++)
		cout<<ans[i];
	return 0;
}

Measured memory_bytes: 38740
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  std::string S; std::cin >> S;
  ll K; std::cin >> K;

  char ans = 0;
  for(ll i=0; i<std::min((ll)S.size(),K); i++) {
    if ( S[i] != '1' ) {
      ans = S[i];
      break;
    }
    else ans = S[i];
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#安定なソート
N = int(input())
*A, = input().split()

def stableSort(N,A):
    cnum1 = [(a[0], int(a[1:])) for a in A]
    
    #バブルソート
    flag = 1
    i = 0
    while i < N-1:
        for j in range(N-1, i, -1):
            if cnum1[j][1] < cnum1[j-1][1]:
                tmp = cnum1[j]
                cnum1[j] = cnum1[j-1]
                cnum1[j-1] = tmp
        i += 1
    print(' '.join([''.join([cn[0], str(cn[1])]) for cn in cnum1]))
    print('Stable')
    
    #選択ソート
    cnum2 = [(a[0], int(a[1:])) for a in A]
    count = 0
    for i in range(N):
        minj = i
        for j in range(i+1, N):
            if cnum2[j][1] < cnum2[minj][1]:
                minj = j
        if not minj == i:
            tmp = cnum2[i]
            cnum2[i] = cnum2[minj]
            cnum2[minj] = tmp
            count += 1
    print(' '.join([''.join([cn[0], str(cn[1])]) for cn in cnum2]))
    print('Not stable' if cnum1 != cnum2 else 'Stable' )

stableSort(N,A)
    


Measured memory_bytes: 5616
// abc057_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)
#define EPS (1e-8)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


vector<vector<ll>> make_nCk_table(int N){
    vector<vector<ll>> nCk;
    nCk.assign(N+1, vector<ll>(N+1, 0));
    REP(i, N+1) {
        nCk[i][0] = 1;
        nCk[i][i] = 1;
        REPN(j, 1, i) nCk[i][j] = nCk[i-1][j-1] + nCk[i-1][j];
    }
    return nCk;
}

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll N, A, B;
    cin >> N >> A >> B;

    vector<ll> v(N);
    map<ll, int> mp;
    REP(i, N) {
        cin >> v[i];
        mp[v[i]]++;
    }

    sort(ALL(v));

    double mx = 0;
    ll x = 0;
    REP(i, A) {
        mx += v[N-1-i];
        x = v[N-1-i];
    }

    mx /= A;
    print(mx);

    auto nCk = make_nCk_table(N);

    ll ans = 0;
    if (x == v[N-1]){
        ll n = mp[v[N-1]];
        REPN(k, A, min(n, B)+1){
            ans += nCk[n][k];
        }
    } else {
        ll n = mp[x];
        ll tmp = N - (upper_bound(ALL(v), x) - v.begin());
        ll k = A - tmp;
        ans += nCk[n][k];
    }

    print(ans);


    return 0;
}


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

int isPrime(int);

int main(){
  int n;
  int i,count = 0,j;
  
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&j);
    if(isPrime(j)){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

int isPrime(int x){
  int i;
  if(x == 2)
    return 1;

  if(x < 2 || x % 2 == 0)
    return 0;

  i = 3;
  while(i <= sqrt(x)){
    if(x % i == 0)
      return 0;
    i = i + 2;
  }
  return 1;
}



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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define lli long long
#define vi vector<int>
#define vli vector<li>
#define vlli vector<lli>
#define pi pair<int,int>
#define pli pair<li, li>
#define vpi vector<pi>

using namespace std;

int main() {

    ios_base::sync_with_stdio(false);

    int n;

    cin >> n;

    int arr[n];

    for(int i = 0; i < n; i++) cin >> arr[i];

    sort(arr, arr + n);

    int ans = abs(arr[n/2-1] - arr[n/2]);

    cout << ans << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int N, N_, Q; 
long long seg[524300], lazy[524300]; 
void init(int N_){
	N = 1; 
	while(N < N_) N *= 2; 
	for(int i = 0; i < N * 2 - 1; i++){
		seg[i] = 0; lazy[i] = 0;  
	}
}
void update(int k){
	if(lazy[k] == 0) return; 
	seg[k] += lazy[k]; 
	if(k * 2 + 2 < N * 2 - 1){
		lazy[k * 2 + 1] += lazy[k]; 
		lazy[k * 2 + 2] += lazy[k]; 
	}
	lazy[k] = 0; 
}
void add(int a, int b, int k, int l, int r, long long x){
	update(k); 	
	if(b <= l || r <= a) return; 
	if(a <= l && r <= b){
		lazy[k] += x; 
		update(k); 
	}else{
		add(a, b, k * 2 + 1, l, (l+r)/2, x);
		add(a, b, k * 2 + 2, (l+r)/2, r, x);
		seg[k] = min(seg[k * 2 + 1], seg[k * 2 + 2]);
	}
}
long long query(int a, int b, int k, int l, int r){
	if(b <= l || r <= a) return 1145141919810364364LL; 
	update(k); 
	if(a <= l && r <= b) return seg[k];
	long long vl = query(a, b, k * 2 + 1, l, (l+r)/2);
	long long vr = query(a, b, k * 2 + 2, (l+r)/2, r);
	return min(vl, vr); 
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N_ >> Q;
	init(N_);
	while(Q--){
		int a; cin >> a; 
		if(a == 0){
			int s, t; long long x; 
			cin >> s >> t >> x; 
			add(s, t+1, 0, 0, N, x);
		}else if(a == 1){
			int s, t; cin >> s >> t;
			cout << query(s, t+1, 0, 0, N) << "\n"; 
		}	
	}
}


Measured memory_bytes: 7284
#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
char q[100000];
bool k;
int main(){
	cin>>q;
	for (int i=97;i<123;i++){
		k=0;
		for (int j=0;j<strlen(q);j++)
		if (q[j]==char(i))
			k=1;
		if (k==0){
		
			cout<<char(i)<<endl;
			return 0;}
			}
	if (k)
		cout<<"None"<<endl;
    return 0;
}

Measured memory_bytes: 384
/****************### With The name of ALLAH, most Gracious, most Compassionate ###****************/

/**============================================================================**\
|   Author      : Md Jubayer Hossen Jame
|   Study       : CSE, BRUR
|   Today       : Sunday, 13 September, 2020
|   Source      : AtCoder Online Judge
|   Problem link: https://atcoder.jp/contests/abc178/tasks/abc178_b
|   Algorithm   :

    After about 2 years latter ---> see you again
|
\**============================================================================**/

#include "bits/stdc++.h"
using namespace std;

#define FI                    freopen("input.txt", "r", stdin)
#define FO                    freopen("output.txt", "w", stdout)
#define FasterIO              ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

typedef long long             ll;
typedef unsigned long long    ull;
typedef unsigned int          ui;

#define mem(x,y)              memset(x,y,sizeof(x));
#define pii                   pair<int,int>
#define mk                    make_pair
#define ff                    first
#define ss                    second
#define pb                    push_back
#define ppb                   pop_back
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define for0(i, n)            for (int i = 0; i < (int)(n); ++i)
#define endl                  '\n'

const double PI = acos(-1.0);

#define gcd(a,b)              __gcd(a,b)
#define lcm(a,b)              (a*(b/gcd(a,b)))

///Direction Array
// 4 Direction - DOWN, UP, RIGHT, LEFT
int dx4[]= {+1, -1, +0, +0};
int dy4[]= {+0, +0, +1, -1};
#define isValid(a, b, R, C)   (0 <= a && a < R) && (0 <= b && b < C)
int dx8[]= {+0, +0, +1, -1, -1, +1, -1, +1};
int dy8[]= {-1, +1, +0, +0, +1, +1, -1, -1};

///Knight Moves
int dr[] = {-1, 1, -2, -2, -1, 1, 2, 2};
int dc[] = {-2, -2, -1, 1, 2, 2, 1, -1};
/**************************************************************************************************/

void test_case()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    /*set <ll> s;
    s.insert(a*c); s.insert(a*d);
    s.insert(b*c); s.insert(b*d);

    ll lst;
    for(auto x: s)lst = x;
    cout << lst << endl;*/
    cout << max( max(a*c, a*d), max(b*c, b*d) ) << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    //FI;
    //FO;
#endif // ONLINE_JUDGE
    //FasterIO

    int T = 1;
    //cin >> T;
    for(int tc = 1; tc <= T; ++tc)
    {
        //cout << "Case #" << tc << ":" << endl;
        test_case();
    }
    return 0;
}


Measured memory_bytes: 3576
import java.util.Scanner;

public class Main 
{
    public static void main( String[] args )
    {
        try (Scanner scan = new Scanner(System.in)) {
            String input = scan.nextLine();
            int rain = 0, repeat = 0;
            for (char c : input.toCharArray()) {
                if (c == 'R') repeat++;
                else repeat = 0;
                if (rain < repeat) rain = repeat;
            }
            System.out.println(rain);
        }
    }
}

Measured memory_bytes: 35752
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=200005;
ll a[N],x[N],s[N],t[N],L,R;
int op[N],n,Q;

ll Div(ll a,ll b){
	if(a>=0) return a/b;
	return -((-a)/b);
}

ll calc(ll a){
	rep(i,1,Q){
		if(op[i]==1&&a>=x[i]){
			a=t[i]*(a+s[i]);
		}
		if(op[i]==2&&a<=x[i]){
			a=Div(a-s[i],t[i]);
		}
	}
	return a;
}

int solveL(){
	int l=1,r=n+1,mi;
	while(l<r){
		mi=(l+r)>>1;
		if(calc(a[mi])>=L) r=mi;
		else l=mi+1;
	}
	return l;
}

int solveR(){
	int l=0,r=n,mi;
	while(l<r){
		mi=(l+r+1)>>1;
		if(calc(a[mi])<=R) l=mi;
		else r=mi-1;
	}
	return l;
}

int main(){
	read(n),read(Q);
	read(L),read(R);
	rep(i,1,n){
		read(a[i]);
	}
	rep(i,1,Q){
		read(op[i]),read(x[i]);
		read(s[i]),read(t[i]);
	}
	sort(a+1,a+n+1);
	int ansL=solveL();
	int ansR=solveR();
	cout<<max(0,ansR-ansL+1)<<endl;
	return 0;
}


Measured memory_bytes: 9980
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string str1, str2;
  cin >> str1 >> str2;
  int n = stoi(str1);
  int d = stoi(str2);
  int m = 2 * d + 1;
  int x = n / m;
  if(x * m < n)
    ++x;
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#
# Author: Tetsuya Ishikawa <tiskw111@gmail.com>
# Date  : July 05, 2020
##################################################### SOURCE START #####################################################

hist = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

N = int(input().strip())

for _ in range(N):
    s = input().strip()
    hist[s] += 1

print("AC x", hist["AC"])
print("WA x", hist["WA"])
print("TLE x", hist["TLE"])
print("RE x", hist["RE"])

##################################################### SOURCE FINISH ####################################################
# vim: expandtab tabstop=4 shiftwidth=4 fdm=marker


Measured memory_bytes: 9192
#include <iostream>

using namespace std;

int main()
{
	int n, m;
	char change[60][2];
	char moji;
	string ans;

	while (cin >> n, n){
		ans = "";

		for (int i = 0; i < n; i++){
			cin >> change[i][0] >> change[i][1];
		}

		cin >> m;

		for (int i = 0; i < m; i++){
			cin >> moji;
			for (int j = 0; j < n; j++){
				if (change[j][0] == moji){
					ans += change[j][1];
					break;
				}
				else if (j == n - 1){
					ans += moji;
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}

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

using namespace std;


void solve() {
    string s; cin >> s;
    long long res = 0;
    int cnt = 0;
    for (char c: s) {
        if (c == 'B') cnt++;
        else res += cnt;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 720
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
using namespace std;
const int INF = 2000000005;
string blue[105], red[105];
int main() {
	int n, m;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> blue[i];
	cin >> m;
	for(int i=0;i<m;i++) cin>>red[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		string s = blue[i];
	
		int kans = 1;
		for (int j = i+1; j < n; j++) {
			if (blue[j] == s) kans++;
		}
		for (int j = 0; j < m; j++) {
			if (red[j] == s) {
				kans--;
			}
		}
		ans = max(kans, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
long long n,i,x,y,z;
scanf("%lld",&n);
x=n/sqrt(n);
for(i=x;i>=1;i--)
{
    y=n/i;
    if(n%i==0)
    {
        z=y+i-2;
        break;
    }
}

printf("%lld",z);

}

Measured memory_bytes: 128
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    X=list(map(int,input().split()))
    Y=list(map(int,input().split()))
    X.sort()
    Y.sort()
    I=0
    J=0
    coef=-(n-1)
    for x in X:
        I+=coef*x
        I%=MOD
        coef+=2
    coef=-(m-1)
    for y in Y:
        J+=coef*y
        J%=MOD
        coef+=2
    print(I*J%MOD)
resolve()

Measured memory_bytes: 74520
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define ll long long
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
static const int MAXN = 100000;
static const int MAX = 1000000007;

ll A, B, N, x;

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

    if(N < B) x = N;
    else x = B-1;

    ll ans = (A*x / B) - A * (x/B);
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3648
n = int(input())
list = []

for i in range(n):
    sp = input().split()
    s = str(sp[0])
    p = int(sp[1])
    list.append([i+1, s, p])

list.sort(key=lambda x:(x[1],-x[2]))
for l in list:
    print(l[0])


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		long[] cnt = new long[n + 1];
		final int MOD = 1000000007;

		for (int i = 2; i <= n; i++) {
			int tmp = i;
			int div = 2;
			while (tmp != 1) {
				if (tmp % div == 0) {
					cnt[div]++;
					tmp /= div;
				} else {
					div++;
				}
			}
		}

		long sum = 1;
		for (int i = 2; i <= n; i++) {
			sum *= (cnt[i] + 1);
			sum %= MOD;
			//			System.out.println(cnt[i]);
		}

		System.out.println(sum);
		sc.close();
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 1e2 + 5, M = 1e6 + 6, OO = 0x3f3f3f3f;
 
int n, m, A[N], sum, tgt, cnt;
 
int main()
{
	cin >> n >> m;
	for(int i = 0 ; i < n ; ++i)
	{
		cin >> A[i];
		sum += A[i];
	}
	tgt = sum % (4 * m) == 0 ? sum / (4 * m) : (sum / (4 * m)) + 1;
	for(int i = 0 ; i < n; ++i)
	{
		if(A[i] >= tgt) ++cnt;
	}
	if(cnt >= m)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256