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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}


template<typename T>
struct RangeToRange{
  using E = pair<int, T>;
  const int n;
  vector<vector<E>> G;
  // (0n, 2n) : top segtree (to)
  // (2n, 4n) : bottom segtree (from)
  RangeToRange(int n):n(n){
    G.resize(n*4);
    for(int i=1;i<n;i++){
      int l=(i<<1)|0;
      int r=(i<<1)|1;
      G[0*n+i].emplace_back(0*n+l,0);
      G[0*n+i].emplace_back(0*n+r,0);
      G[2*n+l].emplace_back(2*n+i,0);
      G[2*n+r].emplace_back(2*n+i,0);
    }
    for(int i=0;i<n;i++)
      G[1*n+i].emplace_back(3*n+i,0);
  }
  // [l1, r1) -> [l2, r2)
  void add_edge(int l1,int r1,int l2,int r2,T c){
    int k=G.size();
    for(l1+=n,r1+=n;l1<r1;l1>>=1,r1>>=1){
      if(l1&1) G[2*n+(l1++)].emplace_back(k,0);
      if(r1&1) G[2*n+(--r1)].emplace_back(k,0);
    }
    vector<E> es;
    for(l2+=n,r2+=n;l2<r2;l2>>=1,r2>>=1){
      if(l2&1) es.emplace_back(l2++,c);
      if(r2&1) es.emplace_back(--r2,c);
    }
    G.emplace_back(es);
  }
  int idx(int v)const{return 1*n+v;}
  size_t size()const{return G.size();}
  const vector<E>& operator[](int k)const{return G[k];}
};


template<typename T>
struct Dijkstra{
  struct Edge{
    int to;
    T cost;
    Edge(int to,T cost):to(to),cost(cost){}
    bool operator<(const Edge &o)const{return cost>o.cost;}
  };

  vector< vector<Edge> > G;
  vector<T> ds;
  vector<int> bs;
  Dijkstra(int n):G(n){}

  void add_edge(int u,int v,T c){
    G[u].emplace_back(v,c);
  }

  void build(int s){
    int n=G.size();
    ds.assign(n,numeric_limits<T>::max());
    bs.assign(n,-1);

    priority_queue<Edge> pq;
    ds[s]=0;
    pq.emplace(s,ds[s]);

    while(!pq.empty()){
      auto p=pq.top();pq.pop();
      int v=p.to;
      if(ds[v]<p.cost) continue;
      for(auto e:G[v]){
        if(ds[e.to]>ds[v]+e.cost){
          ds[e.to]=ds[v]+e.cost;
          bs[e.to]=v;
          pq.emplace(e.to,ds[e.to]);
        }
      }
    }
  }

  T operator[](int k){return ds[k];}

  vector<int> restore(int to){
    vector<int> res;
    if(bs[to]<0) return res;
    while(~to) res.emplace_back(to),to=bs[to];
    reverse(res.begin(),res.end());
    return res;
  }
};

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  using ll = long long;

  int n,m;
  cin>>n>>m;
  RangeToRange<ll> G(n);
  for(int i=0;i<m;i++){
    int l,r,c;
    cin>>l>>r>>c;
    l--;
    G.add_edge(l,r,l,r,c);
  }

  Dijkstra<ll> D(G.size());
  for(int v=0;v<(int)G.size();v++)
    for(auto [u,c]:G[v]) D.add_edge(v,u,c);

  D.build(G.idx(0));
  if(D.bs[G.idx(n-1)]<0) drop(-1);

  cout<<D[G.idx(n-1)]<<newl;
  return 0;
}


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

using namespace std;

int main() {
	string up;
	string down;

	cin >> up >> down;

	bool flag = false;

	if (up[0] == down[2] && up[1] == down[1] && up[2] == down[0])
		flag = true;

	if (flag) cout << "YES" << endl;
	else cout << "NO";

	return 0;
}

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

int main()
{
    int k;
    cin >> k;
    int a;
    cin >> a;
    int b;
    cin >> b;
    cout<<endl;
    for (int i = a; i <= b; i++)
    {
        if (i % k == 0)
        {
            cout << "OK";
            return 0;
        }
    }
    cout << "NG";
    return 0;
}

Measured memory_bytes: 3632
import sys
input = sys.stdin.readline

n,m = map(int, input().split())
qp = [tuple(map(int, input().split())) for _ in range(m)]

qp.sort(key=lambda x:x[1])

ans = 0
pre = 0

while qp:
    a,b = qp.pop(0)
    if pre<a:
        ans += 1
        pre = b-1
print(ans)

Measured memory_bytes: 18668
#include <iostream>
#include <string>
using namespace std;
int chtoi(string str)
{
	int tmp=0;
	for(int i=0;i<str.size();i++)
	{
		char ch; ch=str[i];
		tmp=tmp*10+(ch-'0');
	}
	return tmp;
}
int main()
{
	string str; int sum=0;
	while(cin>>str)
	{
		for(int s=0,l=0;s<str.size();s=++l)
		{
			if(str[l]-'0'<0 || str[l]-'9'>0) continue;
			while(l+1<str.size() && str[l+1]-'0'>=0 && str[l+1]-'9'<=0) l++;
			string ss=str.substr(s,l-s+1);
			sum+=chtoi(ss);
		}
	}
	cout << sum << endl;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


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

    return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))
ans = 0
for i in range(len(H)):
  if i ==0 :
    ans += 1
  else :
    isOK = 0
    for j in range(i):
      if H[j] > H[i]:
        isOK += 1
    if isOK == 0:
      ans += 1

print(ans)
    

Measured memory_bytes: 2940
while True:
    s = input()
    if s == "END OF INPUT":break
    t = ""
    while True:
        if s[0] == " ":
            while s[0] == " ":
                t += "0"
                s = s[1:]
        else:
            try:
                i = s.index(" ")
                t += str(i)
                s = s[i + 1:]
            except:
                t += str(len(s))
                break
    print(t)


Measured memory_bytes: 5560
r,c = map(int,raw_input().split())
a = [map(int,raw_input().split()) for _ in range(r)]
b = [0 for _ in range(c)]

for i in range(r) :
    for j in range(c) :
        b[j] = b[j] + a[i][j]
    a[i].append(sum(a[i]))
    print ' '.join(map(str,a[i]))
b.append(sum(b))
print ' '.join(map(str,b))

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


template<typename T> vector<T> compress(vector<T> &C1, vector<T> &C2, vector<T> &C3){
    vector<T> vals;
    REP(i,C1.size()){
        vals.push_back(C1[i]);
        vals.push_back(C1[i]+1);
    }
    REP(i,C2.size()){
        vals.push_back(C2[i]);
        vals.push_back(C2[i]+1);
    }
    REP(i,C3.size()){
        vals.push_back(C3[i]);
        vals.push_back(C3[i]+1);
    }

    sort(ALL(vals));
    vals.erase(unique(ALL(vals)), vals.end());

    REP(i,C1.size()) C1[i] = lower_bound(ALL(vals), C1[i]) - vals.begin();
    REP(i,C2.size()) C2[i] = lower_bound(ALL(vals), C2[i]) - vals.begin();
    REP(i,C3.size()) C3[i] = lower_bound(ALL(vals), C3[i]) - vals.begin();

    return vals;
}

vector<int> dx{1,0,-1,0};
vector<int> dy{0,-1,0,1};

int main(){

    int N,M; cin >> N >> M;
    vector<ll> A,B,C,D,E,F;
    REP(i,N){
        ll a,b,c; cin >> a >> b >> c;
        A.push_back(2LL*a);
        B.push_back(2LL*b);
        C.push_back(2LL*c);
    }
    REP(i,M){
        ll a,b,c; cin >> a >> b >> c;
        D.push_back(2LL*a);
        E.push_back(2LL*b);
        F.push_back(2LL*c);
    }

    vector<ll> X = compress(A,B,D);
    vector<ll> Y = compress(C,E,F);

    vector<vector<int>> G(X.size()+2, vector<int>(Y.size()+2, 2));
    REP(i,X.size()){
        REP(j,Y.size()){
            G[i+1][j+1] = 0;
        }
    }

    REP(i,N){
        FOR(x,A[i],B[i]+1){
            G[x+1][C[i]+1] = 1;
        }
    }
    REP(i,M){
        FOR(y,E[i],F[i]+1){
            G[D[i]+1][y+1] = 1;
        }
    }
    pair<ll,ll> s;
    s.first = upper_bound(ALL(X), 0) - X.begin();
    s.second = upper_bound(ALL(Y), 0) - Y.begin();
    // cout << X[s.first-1] << ", " << Y[s.second-1] << endl;
    G[s.first][s.second] = 8;

    // REP(i,X.size()+2){
    //     REP(j,Y.size()+2){
    //         cout << G[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    ll ans = 0;
    queue<pair<ll,ll>> q;
    q.push(s);
    while(!q.empty()){
        auto pos = q.front(); q.pop();
        int x = pos.first;
        int y = pos.second;
        if(x%2==0 && y%2==0){
            ans += ((X[x]-X[x-2])/2) * ((Y[y]-Y[y-2])/2);
            //cout << X[x] << ", " << X[x-2]<< ", " << Y[y] << ", " << Y[y-2] << endl;
        }
        REP(i,4){
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(G[nx][ny] == 2){
                cout << "INF" << endl;
                return 0;
            }else if(G[nx][ny] == 0){
                G[nx][ny] = 1;//到達済みに更新
                q.push({nx,ny});
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 144476
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

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

	ll res = 0;
	
	for(int i = 0; i < n; i++)
	{
		int in;
		cin >> in;
		res += in;
	}
	
	cout << res / n << endl;	
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int main(void){
    string o,e;
    cin >> o;
    cin >> e;
    string ans = "";
    for(int i = 0;i < e.size();i++){
          ans += o[i];
          ans += e[i];
    }
    if(o.size() > e.size()) ans += o[o.size() - 1];
    cout << ans << endl;
}


Measured memory_bytes: 256
#shellSort(A, n)
n=int(input())
A=[int(input()) for i in range(n)]
cnt = 0
G=[1]
S=str(G[0])
#if 5<n<13:
t=n//5
#elif n<3000:
  #  t=n//9
#else:
  #  t=n//17
#Gt=[4, 9, 20, 46, 103, 233, 525, 1182,2660, 5985, 13467]
f=1.0
while f<t:
    f*=2.2
    f=int(f)
    G.insert(0,f)
  #  print (i)
    S=str(G[0])+" "+S
m=len(G)
print (m)
print(S)
for i in range(m):
    g=G[i]
    for j in range(g,n):
        v = A[j]
        k = j - g
        while k >= 0 and A[k] > v:
              A[k+g] = A[k]
              k = k - g
              cnt+=1
        A[k+g] = v 
print(cnt)
for i in range(n):
    print(A[i])

Measured memory_bytes: 47632
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
/* null
 * one pair
 * two pair
 * three card
 * straight
 * full house
 * four card
 * */
int main() {
	vector<int> cards(5);
	while (scanf("%d,%d,%d,%d,%d",&cards[0],&cards[1],&cards[2],
				&cards[3],&cards[4])!=EOF) {
		vector<int> cnt(13, 0);
		for (int i=0; i<5; i++) cnt[cards[i]-1]++;
		int two = 0, three = 0, four = 0;
		for (int i=0; i<13; i++) {
			if (cnt[i] == 2) two++;
			if (cnt[i] == 3) three++;
			if (cnt[i] == 4) four++;
		}
		if (four == 1) {
			printf("four card\n");
			continue;
		} else if (two == 1 && three == 1) {
			printf("full house\n");
			continue;
		} else if (three == 1) {
			printf("three card\n");
			continue;
		} else if (two == 2) {
			printf("two pair\n");
			continue;
		} else if (two == 1) {
			printf("one pair\n");
			continue;
		}
		int c = 0;
		bool flag = false;
		for (int i=0; i<9; i++) {
			if (cnt[i] == 1) {
				if (cnt[i+1]==1&&cnt[i+2]==1&&cnt[i+3]==1&&
						cnt[i+4]==1) {
					flag = true;
					break;
				}
			}
		}
		if (flag||
				(cnt[9]==1&&cnt[10]==1&&cnt[11]==1&&cnt[12]==1&&cnt[0]==1)) {
			printf("straight\n");
		} else {
			printf("null\n");
		}
	}	
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>

void setnum(char cc[]){
	int j,len=strlen(cc);
	for(j=len;j>-1;j--){
		cc[80-len+j]=cc[j];
	}
	memset(cc,'0', 80-len);
}

int main(void) {
	
	char a[999],b[999];
	int ca,i,n;
	scanf("%d",&n);
	for(1;n>0;n--){

		scanf("%s",a);scanf("%s",b);
		if(strlen(a)>80 || strlen(b)>80 ){printf("overflow\n");continue;}
		setnum(a);setnum(b);
		ca=0;
		
		for(i=79;i>-1;i--){
			ca+=a[i]+b[i]-'0'*2;
			a[i]=ca%10+'0';
			if(ca>9)ca=1; else ca=0;
		}

		if(ca==1) printf("overflow\n");

		else {
			for(i=0;i<80;i++){
				if(ca!=0 || a[i]>'0' || i==79){
				ca=1;
				printf("%c",a[i]);
				}
			}
			printf("\n");
		}
		
	}

	return 0;
}

Measured memory_bytes: 596
#include <iostream>

void ArrayDump(int *A, int N)
{
    for (int i = 0; i < N; i++) {
        std::cout << *(A + i);
        if (i != N - 1) {
            std::cout << " ";
        }
    }
    std::cout << std::endl;
}

int BubbleSort(int *A, int N)
{
    bool flag = true;
    int exchange_num = 0;
    while (flag) {
        flag = false;
        for (int j = N-1; j > 0; j--) {
            if (A[j] < A[j-1]) {
                int tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                flag = true;
                exchange_num++;
            }
        }
    }
    return exchange_num;
}

int main(int argc, char* argv[])
{
    int array_size = 0;
    int array[100];

    std::cin >> array_size;
    for (int i = 0; i < array_size; i++) {
        std::cin >> array[i];
    }

    int exchange_num = BubbleSort(array, array_size);
    ArrayDump(array, array_size);
    std::cout << exchange_num << std::endl;
}


Measured memory_bytes: 3108
from math import log10

class Mod:
    fac = []
    inv = []
    finv = []
    mod = 0
    def __init__(self,maxi:int ,mod:int):
        self.mod = mod
        self.fac = [1]*maxi
        self.inv = [1]*maxi
        self.finv = [1]*maxi
        for i in range(2,maxi):
            self.fac[i] = self.fac[i - 1]*i%mod
            self.inv[i] = mod - self.inv[mod%i]*(mod//i)%mod
            self.finv[i] = self.finv[i-1]*self.inv[i]%mod


    def com(self,n:int, k:int)->int:
        #return nCk
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return self.fac[n]*(self.finv[k]*self.finv[n-k]%self.mod)%self.mod


def main():
    s = int(input())
    m =  Mod(s,10**9 + 7)
    ans = 0
    for n in range(1,s // 3 + 1):
        if 3*n == s:
            ans = (ans+1)%(10**9 + 7)
            break
        ans = (ans + m.com(-2*n + s - 1,s - 3*n))%(10**9 + 7)
    print(ans)
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 9288
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9 + 7;

vector<int>G;
vector<int> dist;
vector<int> visit;

int dfs(int n){
  if(visit[n] == 1){
    return -1;
  }else if(visit[n] == 2){
    return dist[n];
  }
  visit[n] = 1;
  ll res;
  if(G[n] == -1){
    res = 0;
  }else {
    int d = dfs(G[n]);
    if(d == -1){
      return -1;
    }
    res = d + 1;
  }
  visit[n] = 2;
  return dist[n] = res;
}

int main(void){
  string s,t;
  cin >> s >> t;
  int tsize = t.size();
  int ssize = s.size();
  ll bpmax = 1;
  ll hasht = 0;
  for(int i = 0;i < tsize;++i){
    bpmax = (bpmax * 3) % mod;
    hasht = (hasht * 3) % mod;
    hasht = (hasht + (t[i] - 'a')) % mod;
  }
  ll hashs = 0;
  for(int i = 0;i < tsize;++i){
    int idx = i % ssize;
    hashs = (hashs * 3) % mod;
    hashs = (hashs + (s[idx] - 'a')) % mod;
  }
  G = vector<int>(ssize,-1);
  for(int i = 0;i < ssize;++i){
    if(hashs == hasht){
      int next = (i + tsize) % ssize;
      G[i] = next;
    }
    ll delta1 = bpmax * (s[i] - 'a') % mod;
    ll delta2 = s[(i + tsize) % ssize] - 'a';
    hashs = (hashs * 3) % mod;
    hashs = (hashs - delta1 + mod) % mod;
    hashs = (hashs + delta2) % mod;
  }
  /*
  for(int i = 0;i < ssize;++i){
    cout << G[i] << " ";
  }
  cout << endl;
  */
  dist = vector<int>(ssize,-1);
  visit = vector<int>(ssize,0);
  int res = 0;
  for(int i = 0;i < ssize;++i){
    int d = dfs(i);
    if(d == -1){
      puts("-1");
      return 0;
    }
    res = max(res,d);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 22792
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)

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

  cout << 3*N*N << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    R = [-1] * (N+1)
    A = list(map(int,input().split()))
    for idx, a in enumerate(A):
        R[a] = idx+1

    for idx in range(1, len(R)):
        print(R[idx], end=" ")
    print("\n")
    

if __name__ == "__main__":
    main()



Measured memory_bytes: 85964
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
dmin = 10 ** 9
res = -1
for i in range(n):
    x = h[i]
    avg = t - x * 0.006
    d = abs(a - avg)
    if d < dmin:
        dmin = d
        res = i + 1  # indexは0から始まるので+1
print(res)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int a[1000000], b[1000000];
  a[0] = b[0] = 0;
  for (int i = 1; i < 1000000; ++i)
  {
    a[i] = b[i] = i;
    for (int j = 1;; ++j)
    {
      int t = j * (j + 1) * (j + 2) / 6;
      if (t > i)
        break;
      a[i]=min(a[i],a[i-t]+1);
      if(t%2==1)
      {
        b[i]=min(b[i],b[i-t]+1);
      }
    }
  }
  int n;
  while (cin >> n, n)
  {
    cout<<a[n]<<' '<<b[n]<<endl;
  }

  return 0;
}



Measured memory_bytes: 10884
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    double x;
    cin >> x;
    double minimum = x, maximum = x;
    while(cin >> x){
	minimum = min(minimum, x);
	maximum = max(maximum, x);
    }
    cout << maximum - minimum << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
int main()
{
    char s[120];
    bool flg = true;
    scanf("%s", s);
    for (int i = 0; s[i] != '\0'; i++)
    {
        if (i % 2 == 0)
        {
            if (s[i] == 'L')
            {
                flg = false;
                break;
            }
        }
        else if (i % 2 == 1)
        {
            if (s[i] == 'R')
            {
                flg = false;
                break;
            }
        }
    }
    if (flg)
        printf("Yes\n");
    else
        printf("No\n");
}

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

long long n;
long long ans;

void init() {
	scanf("%lld", &n);
	return ;
}

void solve() {
	if(n % 2 == 1) {
		printf("0");
	}
	else {
		ans = n/=10;
		while(n) {
			ans += n/5ll;
			n /= 5ll;
		}
		printf("%lld", ans);
	}
	return ;
}

int main() {
	init();
	solve();
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
typedef pair<lli, pii> ppi;
typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
    }
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const{
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        uint64_t x = hash1 ^ hash2;
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M ;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}
lli solve(){
    lli n;
    cin>>n;
    vector<string> S(n);
    loop(i, 0, n)
        cin>>S[i];
    umap<string, lli> mp;
    loop(i, 0, n)
        mp[S[i]]++;
    vector<pair<lli, string> > A;
    for(auto x : mp){
        A.pb({x.se, x.fi});
    }
    sort(A.begin(), A.end(), [](const pair<lli, string>& v1, const pair<lli, string>& v2){
        return v1.fi > v2.fi;
    });
    vector<string> res;
    lli i = 0;
    if(A.size() > 1)
        while(A[i].fi == A[i+1].fi){
            res.pb(A[i].se);
            i++;
        }
    res.pb(A[i].se);
    sort(res.begin(), res.end());
    loop(i, 0, res.size())
        cout<<res[i]<<"\n";
    return 0;
}
int main(){
    fastio;
    lli t;
    // cin>>t;
    t = 1;
    while(t>0){
        t--;
        solve();
    }
    return 0;
}


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


typedef struct p_tag{
    char c;
    struct p_tag *prev;
    struct p_tag *next;
} string;

int main(){
    char str[100002];
    int qn;
    int i;
    char q[10];
    int rot = 0;
    string *head, *tail, *buf, *buf_prev=NULL;

    (void)fgets(str, 100002, stdin);

    i = 0;
    while(str[i] != '\n'){
        buf = malloc(sizeof(string));
        if(i == 0){
            head = buf;
        }
        buf->c = str[i];
        buf->prev = buf_prev;
        buf->next = NULL;
        if(buf_prev != NULL){
            buf_prev->next = buf;
        }
        buf_prev = buf;
        i++;
    };
    tail = buf;

    (void)scanf("%d", &qn);
    (void)getchar();

    for(i=0; i < qn; i++){
        (void)fgets(q, 10, stdin);
        if(q[0] == '1'){
            rot++;
        }else{
            if(q[2] == '1' && rot % 2 == 0 || q[2] == '2' && rot % 2 == 1){
                buf = malloc(sizeof(string));
                buf->c = q[4];
                buf->next = head;
                buf->prev = NULL;
                head->prev = buf;
                head = buf;
            }else{
                buf = malloc(sizeof(string));
                buf->c = q[4];
                buf->next = NULL;
                buf->prev = tail;
                tail->next = buf;
                tail = buf;
            }
        }
    }
    if(rot % 2 == 0){
        putchar(head->c);
        while(1){
            head = head->next;
            if(head == NULL){
                putchar('\n');
                return 0;
            }
            putchar(head->c);
        }
    }else{
        putchar(tail->c);
        while(1){
            tail = tail->prev;
            if(tail == NULL){
                putchar('\n');
                return 0;
            }
            putchar(tail->c);
        }
    }
}



Measured memory_bytes: 9984
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

ll modpow(ll a, ll n) {
    a %= MOD;
    if (n == 0)
        return 1;
    if (n == 1)
        return a % MOD;
    if (n % 2)
        return a * modpow(a, n - 1) % MOD;
    else
        return (modpow(a, n / 2) * modpow(a, n / 2)) % MOD;
}

ll culc(ll a, ll n) {
    ll up = 1;
    ll down = 1;
    for (ll i = n - a + 1; i <= n; i++) {
        up *= i % MOD;
        up %= MOD;
    }
    for (ll i = 1; i <= a; i++) {
        down *= i % MOD;
        down %= MOD;
    }
    down = modpow(down, MOD - 2);
    return up * down % MOD;
}

void ch(int &n) {
    n += 10 - n % 10;
    //n /= 10;
}

int main() {
    vector<int> a(5);
    int s = -1;
    int as = 10;
    rep(i, 5) {
        cin >> a[i];
        if (a[i]%10 != 0 && a[i]%10 < as) {
            as = a[i]%10;
            s = i;
        }
    }
    int sum = 0;
    rep(i, 5) {
        if (i != s){
			if (a[i]%10)
            ch(a[i]);
            sum += a[i];
		}
    }
    int d=0;
    if (s != -1) {
        d = a[s];
    }
    cout << sum + d << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

#define LL long long
#define Maxn 200010

using namespace std;

const LL MOD = 1ll * (1e9 + 7);

inline LL read() {
    LL x = 0, f = 1;
    char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while('0' <= c && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}

int n, k;
LL a[Maxn];

int cmp(LL fir, LL sec) {
    LL absfir = fir > 0 ? fir : -fir;
    LL abssec = sec > 0 ? sec : -sec;
    return absfir > abssec; 
}

int main() {
    n = read(); k = read();
    bool flagg = 1;
    for(int i = 1; i <= n; ++i) {
        a[i] = read();
        if(a[i] > 0) flagg = 0;
    }
    sort(a + 1, a + n + 1, cmp);
    LL ans = 1, cnt = 0;
    if(flagg && k % 2) {
        for(int i = n; i >= n - k + 1; --i) ans = ans * a[i] % MOD;
        cout << (ans % MOD + MOD) % MOD << endl;
        return 0;
    }
    for(int i = 1; i <= k; ++i) if(a[i] < 0) ++cnt;
    if(n == k) {
        for(int i = 1; i <= n; ++i) ans = ans * a[i] % MOD;
    }
    else if(cnt % 2 == 0) {
        for(int i = 1; i <= k; ++i) ans = ans * a[i] % MOD;
    }
    else {
        LL p1 = 0, q1 = 0, p2 = 0, q2 = 0;
        for(int i = k + 1; i <= n; ++i) if(a[i] >= 0) {q1 = a[i]; break;}
        for(int i = k; i >= 1; --i) if(a[i] <= 0) {p1 = -a[i]; break;}
        for(int i = k + 1; i <= n; ++i) if(a[i] <= 0) {q2 = -a[i]; break;}
        for(int i = k; i >= 1; --i) if(a[i] >= 0) {p2 = a[i]; break;}
        if(!q2 || !p2 || q1 * p2 > p1 * q2) {
            // cout << "debug1" << endl;
            bool flag = 1;
            for(int i = k; i >= 1; --i) {
                if(a[i] < 0 && flag) {flag = 0; continue;}
                ans = ans * a[i] % MOD;
            }
            for(int i = k + 1; i <= n; ++i) if(a[i] >= 0) {ans = ans * a[i] % MOD; break;}
        }
        else {
            // cout << "debug2" << endl;
            bool flag = 1;
            for(int i = k; i >= 1; --i) {
                if(a[i] > 0 && flag) {flag = 0; continue;}
                ans = ans * a[i] % MOD;
            }
            for(int i = k + 1; i <= n; ++i) if(a[i] <= 0) {ans = ans * a[i] % MOD; break;}
        }
    }
    cout << (ans % MOD + MOD) % MOD << endl;
    return 0;
}

Measured memory_bytes: 5128
#include<stdio.h>
int main()
{
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    int ans;
    if (a*b > c*d)
        ans = a * b;
    else
        ans = c * d;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())
M = 10**9 + 7
A = [0 for _ in range(N+1)]
RA = [0 for _ in range(N+1)]
for i in range(1, N+1):
    A[i] = A[i-1] + i

RA[0] = N
for j in range(1, N+1):
    RA[j] = N-j + RA[j-1]

ans = 0
# print(A)
# print(RA)
for k in range(K, N+2):
    minv = A[k-1]
    maxv = RA[k-1]
    ans += ((maxv - minv) + 1)%M
    ans %= M
    # print(k, (maxv-minv)+1)

print(ans)

Measured memory_bytes: 30400
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B = MAP()

print(min(N*A, B))

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


int main(){
    int n,i,evensum=0;
    cin >> n;
    vector<int> v(n,0);
    for(i=0;i<n;i++){
        cin >>v.at(i);
    }
    int allsum=0;
    for(i=0;i<n;i++){
        allsum+=v.at(i);
    }
    int a[n];
    for(i=1;i<n;i+=2){
        evensum+=v.at(i)*2;
    }
    a[0]=allsum-evensum;
    cout << a[0] << ' ';
    for(i=1;i<n;i++){
        a[i]=2*v.at(i-1)-a[i-1];
        cout << a[i] <<' ';
        }
    }


Measured memory_bytes: 2048
import sys

for line in sys.stdin:
    [a, b] = [int(x) for x in line.split()]

    if [a, b] == [0, 0]:
        break

    if b < a:
        print(" ".join([str(x) for x in [b, a]]))
    else:
        print(" ".join([str(x) for x in [a, b]]))

Measured memory_bytes: 6384
#include <bits/stdc++.h>
#define For(i,x,y) for(int i=(x);i<=(y);++i)
#define Rof(i,x,y) for(int i=(x);i>=(y);--i)
#define FoR(i,x,y,z) for(int i=(x);i<=(y);i+=(z))
#define RoF(i,x,y,z) for(int i=(x);i>=(y);i-=(z))
#define Edge(x) for(int i=head[x],to=e[i].v;i;i=e[i].nxt,to=e[i].v)
typedef long long ll;
const int N=100005;
const int mod=1e9+7;
using namespace std;
char s[N];
int pre[N],f[N],pos[3],hve[N];
void add(int &x,int y){ x+y>=mod?x=x+y-mod:x=x+y; }
int main(){
	scanf("%s",s+1); int n=strlen(s+1);
	For(i,1,n){
		pre[i]=(pre[i-1]+s[i]-'a'+1)%3;
		if(i!=n) hve[i]=(s[i]==s[i+1]);
	}
	For(i,1,n) hve[i]+=hve[i-1];
	if(!hve[n]) return puts("1"),0;
	f[0]=1;pos[0]=0,pos[1]=pos[2]=-1;
	For(i,1,n){
		if(!pre[i] && i!=n) add(f[i],1);
		add(f[i],f[i-1]);
		int fr=pos[(pre[i]+s[i]-'a'+1)%3];
		if(~fr && hve[i-1]-hve[fr]) add(f[i],f[fr]);
		pos[pre[i]]=i;		
	}
	printf("%d\n",f[n]);
}

Measured memory_bytes: 1536
S = int(input())

if(S <= 10**9):
 X1,Y1 = 0,0
 X2,Y2 = 1,0
 X3,Y3 = 0,S
elif(S != 10**18):  
 X1,Y1 = 0,0
 X2,Y2 = 10**9,1
 a,b = S//(10**9),S%(10**9)
 X3,Y3 = (10**9)-b,a+1
else:
 X1,Y1 = 0,0
 X2,Y2 = 10**9,0
 X3,Y3 = 0,10**9

print(X1,Y1,X2,Y2,X3,Y3)


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

int main(){
  int N;cin>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++) cin>>A.at(i);
  int lowest=A.at(0);
  int count=1;
  for(int i=1;i<N;i++){
    if(A.at(i)<lowest){
      lowest=A.at(i);
      count++;
    }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 4020
H,W = list(map(int,input().split()))
N = int(input())
a = list(map(int,input().split()))

lst = [[0]*W for i in range(H)]
cnt = 0
color = 1
i = 0

while True:
    for j in range(W):
        lst[i][j] = color
        cnt += 1
        if cnt == a[color-1]:
            color += 1
            cnt = 0
    if color == N+1:
        break
    i += 1
    for j in range(W-1,-1,-1):
        lst[i][j] = color
        cnt += 1
        if cnt == a[color-1]:
            color += 1
            cnt = 0
    if color == N+1:
        break
    i += 1
for row in lst:
    print(*row)

Measured memory_bytes: 3916
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  string s; cin >> s;
  string s1 = s.substr(0,5), s2 = s.substr(6,7), s3 = s.substr(14,5);
  cout << s1 << " " << s2 << " " << s3 << endl;
  return 0;
}

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

using namespace std;

int main(){
	char w[102] = {'0'};
	int counter[26] = {0};
	bool flag = true;

	scanf("%s", w);

	for(int i = 0; i < 102; i++){
		if(w[i] != '0'){
		counter[(int)w[i]-97]++;
		}
	}

	for(int i = 0; i < 26; i++){
		if(counter[i] % 2 != 0){
			flag = false;
		}
	}

	if(flag == true){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;

int main(){
    int h,w,cnt=0;
	cin>>h>>w;
	int a[h][w];
	vector<string> ans;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w-1;j++){
			if(a[i][j]%2==1){
				a[i][j+1]++;
				cnt++;
				ans.push_back(to_string(i+1)+' '+to_string(j+1)+' '+to_string(i+1)+' '+to_string(j+2));
			}
		}
	}
	for(int i=0;i<h-1;i++){
		if(a[i][w-1]%2==1){
			a[i+1][w-1]++;
			cnt++;
			ans.push_back(to_string(i+1)+' '+to_string(w)+' '+to_string(i+2)+' '+to_string(w));
		}
	}
	cout<<cnt<<endl;
	for(int i=0;i<ans.size();i++){
		cout<<ans[i]<<endl;
	}
}


Measured memory_bytes: 11892
import sys
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

x,y=map(int,input().split())
if (x+y)%3!=0:
  print(0)
  sys.exit()
n=(x+y)//3

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

print(cmb(n,x-n,mod))

Measured memory_bytes: 118764
{-#LANGUAGE BangPatterns#-}
import Data.Functor

main::IO ()
main=do
  (x:y:_) <- map read . words <$> getLine ::IO [Int]
  print $ gcdEuclid x y

gcdEuclid::Integral a=>a->a->a
gcdEuclid x 0=x
gcdEuclid !x !y=gcdEuclid y (x `mod` y)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;

#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = ll(b)-1; i >= (a); i--)
#define MAPIT(i,c,k) for (auto i = (c).equal_range((k)).first; i!= (c).equal_range((k)).second; i++)

#define sz(c) ll((c).size())
#define all(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define xx first
#define yy second
#define has(c, i) ((c).find(i) != (c).end())
#define DBG(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

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

	int H, W;
	cin >> H >> W;
	int N;
	cin >> N;
	vll d(N);
	FOR(i, 0, N) cin >> d[i];

	vector<vll> grid(H, vll(W));

	int act = 0;
	FOR(i, 0, H){
		if(i % 2){
			FOR(j, 0, W){
				grid[i][j] = act+1;
				d[act]--;
				if(d[act] == 0)
					act++;
			}
		} else {
			FORD(j, 0, W){
				grid[i][j] = act+1;
				d[act]--;
				if(d[act] == 0)
					act++;
			}
		}
	}

	FOR(i, 0, H){
		FOR(j, 0, W){
			cout << grid[i][j] << " ";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.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() {
    char S[10];
    int N,M,K;
    scanf("%s",&S);
    if(S[1]== 'B'){
        printf("ARC");
    }
    else{
        printf("ABC");
    }

    int A[N+1];
    return 0;
}


Measured memory_bytes: 3868
import numpy as np

X, Y, A, B, C = map(int, input().split())
p = np.array(tuple(map(int, input().split())))
q = np.array(tuple(map(int, input().split())))
r = np.array(tuple(map(int, input().split())))

p = np.partition(p, A - X)
q = np.partition(q, B - Y)

pqr = np.concatenate((p[-X:], q[-Y:], r))
pqr = np.partition(pqr, len(pqr) - (X + Y))

ans = sum(pqr[-(X + Y) :])

print(ans)


Measured memory_bytes: 24956
#include<iostream>
#include<vector>
#include<array>

using namespace std;

int main(){
  int n,i,c=0;
  cin >> n;
  vector<vector<int>> a(2,vector<int>(111));
  for(i=0;i<n;i++){
    cin >> a[0][i];
    c+=a[0][i];
  }
  for(i=0;i<n;i++){
    cin >> a[1][i];
  }
  c+=a[1][n-1];
  int max=c;
  for(i=n-1;i>0;i--){
    c+=a[1][i-1]-a[0][i];
    if(c>max) max=c;
  }
  cout << max << endl;
}

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

#define f first
#define s second
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

#define x1 aseasfd                         	
#define y1 sadasd
#define left come
#define right sdsfd

using namespace std;

const int maxn = 1e6 + 7;
const ll inf = 1e9 + 7;
const ll mod = 1e9 + 7;
const ld eps = (ld)1e-12;
const double pi = 3.141592653;
const ll linf = 1e18 + 7;
const int logn = 20;                                                             

ll n,x;

ll gcd (ll a, ll b) {
	if (!b)return a;
	else return gcd(b, a%b);
}
    
int main () {

cin >> n >> x;
                 
cout << 3 * (n - gcd(n,x));

return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<climits> //INT_MIN/MAX
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
#define FOR(i,s,e) for(ll (i)=(s);(i)<(e);(i)++)
#define FORR(i,s,e) for(ll (i)=(s);(i)>(e);(i)--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = { 0,0,1,-1,1,1,-1,-1 };
int dy[8] = { 1,-1,0,0,1,-1,1,-1 };
 
/* -----  xtimex  Problem: ABC 0 ABCD / Link:  ----- */
/* ------蝠城｡---
 
 
 
-----問題ここまで----- */
/* -----解説等-----
 
 
 
----解説ここまで---- */
 
ll N, A, B;
ll v[60];
ll ans = 0;
ll comb[100][100];
 
double ave = 0;
 
int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
 
    cin >> N >> A >> B;
    FOR(i, 0, N) {
        cin >> v[i];
    }
 
 
    for (int i = 0; i <= 60; i++) {
        for (int j = 0; j <= i; j++) {
            if (j == 0 || j == i)
                comb[i][j] = 1;
            else
                comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
        }
    }
 
 
    sort(v, v + N);
    reverse(v, v + N);
 
    if (v[0] != v[A - 1]) {
        int cnt = 0, ne = 0;
        FOR(i, 0, N) {
            if (v[A - 1] == v[i]) {
                cnt++;
                if (i < A) {
                    ne++;
                }
            }
            if (i < A)ave += v[i];
        }
        //debug(cnt);
        ave /= A;
        ans = comb[cnt][ne];
    }
    else if (v[0] == v[A - 1]) {
        int cnt = 0;
        FOR(i, 0, N) {
            if (v[0] == v[i])cnt++;
        }
        ave = v[0];
        FOR(i, A, B + 1) {
            if (cnt>=i) {
                ans += comb[cnt][i];
            }
        }
 
    }
 
    printf("%.10f\n", ave);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  n -= m;
  int seki = pow(2, m);
  int ans = m*1900*seki + 100*n*seki;
  cout << ans << endl;
}

Measured memory_bytes: 256
if __name__ == '__main__':
    N = int(input())
    for h in range(1, 3501):
        for n in range(1, 3501):
            if 4 * h * n - N * (n + h) > 0 and (N * h * n) % (4 * h * n - N * (n + h)) == 0:
                w = (N * h * n) // (4 * h * n - N * (n + h))
                print(str(h) + " " + str(n) + " " + str(w))
                exit()



Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   unik(v)       v.erase(unique(all(v)),v.end())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll p[n];
    for(ll i=0;i<n;i++){
        cin>>p[i];
    }
    ll  ans=0;
    sort(p,p+n);
    for(ll i=0;i<k;i++)
        ans+=p[i];
    cout << ans <<"\n";

}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000
void countingsort(short *,short *,int);
int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  for(i=0;i<n;i++)scanf("%hu",&A[i+1]);
  
  /* your code */
  countingsort(A,B,n);
  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
    
  }printf("\n");

  return 0;
}

void countingsort(short A[],short B[],int n){
 int C[VMAX+1];
 int i,j;
  for(i=0;i<=VMAX;i++)C[i]=0;

  /*count the number of i*/
  for(j=1;j<=n;j++)C[A[j]]++;

  /*count the number of figure less than i+1*/
  for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];

  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

}



Measured memory_bytes: 9652
#include <iostream>
#include <cmath>
#include <vector>

#define N 1000000
using namespace std;

vector<int> p(1000000);

int main(){
	int a, d, n;
	for(int i = 0; i < N; i++) p[i] = 0;
	for(int i = 3; i < N; i += 2) p[i] = 1;
	p[2] = 1;
	for(int i = 3; i < (int)sqrt(N); i += 2){
		if(p[i] == 0) continue;
		for(int j = i + i; j <= N; j = j + i) p[j] = 0;
	}		
	
	while(cin >> a >> d >> n, a != 0 && d != 0 && n != 0){
		int pr;
		for(int i = 0, j = 0; j < n; ){
			if(p[a + i * d]){
				pr = a + (i * d);
				j++;
			} 
		i++;
		}		
	cout << pr << endl;
	}	
	return 0;
}

Measured memory_bytes: 4968
#pragma GCC optimize("03")
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long 
using namespace std;
int f[200000];
int find(int x){
	if(f[x]==x)
		return x;
	else
		return f[x]=find(f[x]);
}
void merge(int c,int d){
	f[d]=c;
}
int main()
{
    ios::sync_with_stdio(0);cin .tie(NULL);
    ll a,b,num;
   	cin >> a >> b;
   	for(int i=0;i<a;i++)
	f[i]=i;
    for(int i=0;i<b;i++)
    {
    	ll c,d;
    	cin >> c >> d;
    	c=find(c);
    	d=find(d);
   		merge(c,d);
	}
	cin >> num;
	for(int i=0;i<num;i++)
	{
		ll e,g;
		cin >> e >> g;
		if(find(e)==find(g))
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
}


Measured memory_bytes: 3528
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	w := getNextInt(scanner)

	vw := make([][2]int, n)

	for i := 0; i < n; i++ {
		vw[i][0] = getNextInt(scanner)
		vw[i][1] = getNextInt(scanner)
	}

	dp := make([][]int, n)
	for i := 0; i < n; i++ {
		dp[i] = make([]int, w+1)
		for ii := 1; ii <= w; ii++ {
			if i == 0 {
				if ii-vw[i][1] >= 0 {
					dp[i][ii] = vw[i][0] + dp[i][ii-vw[i][1]]
				}
				continue
			}
			dp[i][ii] = dp[i-1][ii]
			if ii-vw[i][1] < 0 {
				continue
			}
			if dp[i-1][ii-vw[i][1]]+vw[i][0] > dp[i][ii] {
				dp[i][ii] = dp[i-1][ii-vw[i][1]] + vw[i][0]
			}
			if dp[i][ii-vw[i][1]]+vw[i][0] > dp[i][ii] {
				dp[i][ii] = dp[i][ii-vw[i][1]] + vw[i][0]
			}
		}
	}

	fmt.Fprintln(writer, dp[n-1][w])
	writer.Flush()
}



Measured memory_bytes: 9616
#include<bits/stdc++.h>
#define MOD 1000000007
#define md 998244353
#define INF LLONG_MAX
#define F first
#define S second
#define sz(x) (long long)x.size()
#define vi vector<int>
#define vll vector<long long>
#define vpl vector<pair<long long,long long> >
#define vpi vector<pair<int,int> >
#define pb push_back
#define debug(x) cerr<<#x<<"= "<<x<<endl
#define all(v) v.begin(),v.end()
#define TT ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define endl '\n'
#define MAXN 200005
typedef long long ll;
typedef long double ld;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll x;
    cin>>x;
    cout<<(!x);
    

    return 0;
}



Measured memory_bytes: 3608