akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <memory.h>

using namespace std;

int N, A, X[55];

long long cache[55][55][2505];
long long rec(int idx, int n, int v) {
    long long& ret = cache[idx][n][v];
    if (ret != -1) return ret;
    if (n == 0 && v == 0) return ret = 1;
    if (idx == N) return ret = 0;
    ret = 0;
    ret += rec(idx+1, n, v);
    if (n-1 >= 0 && v-X[idx] >= 0) ret += rec(idx+1, n-1, v-X[idx]);
    return ret;
}

long long solve() {
    memset(cache, -1, sizeof(cache));
    long long ret = 0;
    for (int n = 1; n <= N; n++) ret += rec(0, n, n*A);
    return ret;
}

int main() {
    scanf("%d%d", &N, &A);
    for (int i = 0; i < N; i++) scanf("%d", X+i);
    long long ans = solve();
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 59392
def main():
    N = int(input())
    buttons = {}
    for i in range(N):
        buttons.update({i+1:int(input())})
    # print(buttons)
    p = 1
    ans = 0
    while ans <= N:
        p = buttons[p]
        ans += 1
        if p == 2:
            print(ans)
            return
    print(-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 88252
#include <stdio.h>
#include <string.h>
#define DIV 1000000007
int n;
int from[1001],to[1001];
char node[1001][3];
int res[1001];

long long solve(int no)
{
  char *p;
  int i;
  long long acc;
  
  p=&node[no][0];
  
  if(*p=='E')
    {
      for(i=0,acc=1;i<n-1;i++)
	if(from[i]==no)
	  acc = (acc * solve(to[i])) % DIV;
      if(p[1]=='?')
	  acc = (acc + 1) % DIV;
    }

  if(*p=='R')
    {
      for(i=0,acc=1;i<n-1;i++)
	if(from[i]==no)
	  {
	    acc = (acc * (1+solve(to[i]))) % DIV;
	  }
      if(p[1]!='?')
	acc  = (acc - 1) % DIV;
    }
  
  if(*p=='A')
    {
      for(i=0,acc=0;i<n-1;i++)
	if(from[i]==no)
	  {
	    acc = (acc + solve(to[i])) % DIV;
	  }
      if(p[1]=='?')
	acc  = (acc + 1)  % DIV;
    }
  res[no]=acc;
  return(acc);
}

int main()
{
  int i,ret;
  
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    scanf("%s",&node[i][0]);

  for(i=0;i<n;i++)
    scanf("%d %d",&from[i],&to[i]);
  ret=solve(1);
  printf("%d\n",ret);
  return(0);
}

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

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long

const int N = 1e5+5;
int a[N];

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

Measured memory_bytes: 256
a = []
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
a.append(int(input()))
wait_max = max([(130-x)%10 for x in a])
t = sum([(x+9)//10*10 for x in a]) - wait_max
print(str(t))



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	long long N,A,B,C,D,E;
  long long minute = 5,m2 = 0,max = 0;
  int m = 0;
  cin >> N >> A >> B >> C >> D >> E;
  vector<long long> p(6,0);
  vector<long long> v(5);
  vector<long long> x(5);
  v.at(0) = A;v.at(1) = B;v.at(2) = C;v.at(3) = D;v.at(4) = E;
  p.at(0) = N;
  froop1(0,5){
    if((N - 1) / v.at(i) > max){
      max = (N - 1) / v.at(i);
    }
  }
minute += max;
  cout << minute << endl;
 
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define eachdo(e,array) for(const auto& e : array)
#define all(v) (v).begin(), (v).end()
#define lower_index(v, a) (int)distance(v.begin(), lower_bound((v).begin(), (v).end(), a))
#define upper_index(v, a) (int)distance(v.begin(), upper_bound((v).begin(), (v).end(), a))
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
typedef long long ll;
const int inf = 1<<28;
const ll INF = 1LL<<57;
const ll COMBMAX = 500005;
const ll MOD = 1e9+7;

struct mint {
ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += MOD-a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
    	fact[0] = 1;
    	for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    	ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
        if (COMBMAX < n){
            mint ret = 1;
            rep1(i,k){
                ret *= (n-i+1);
                ret /= i;
            }
            return ret;
        }
		return fact[n]*ifact[k]*ifact[n-k];
	}
} com(COMBMAX);

int main(){
    ll N,a,b; cin >> N >> a >> b;
    mint ans = 0,t = 2;
    ans = t.pow(N);
    ans -= 1;
    ans -= com(N, a);
    ans -= com(N, b);
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 8064
//bismillah
//created by anaksoleh
//26 Nov 2019
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<pair<int,ll>> vii;
vii myitem;
int N,W;
ll dp[105][100005];

void solve()
{
    for(int barang = 1 ; barang <= N ; barang++){
        for(int weight = 0 ; weight <= W ; weight++){
            ll best = dp[barang - 1][weight];
            if(weight >= myitem[barang].first){
                ll ambil = dp[barang - 1][weight - myitem[barang].first] + myitem[barang].second;
                best = max(best,ambil);
            }
            dp[barang][weight] = best;
        }
    }
}

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

    cin >> N >> W;
    myitem.push_back(make_pair(0,0));
    ll w,v;
    for(int i = 1 ; i <= N ; i++){
        cin >> w >> v;
        myitem.push_back(make_pair(w,v));
    }
    solve();
    cout << dp[N][W] << '\n';
    return 0;
}


Measured memory_bytes: 79360
import fractions
import copy

A, B, K= map(int, input().split())

ab_gcd = fractions.gcd(A, B)
if ab_gcd == 1:
    print(ab_gcd)
    quit()

p = 2
elem = []
while p * p <= ab_gcd:
    while ab_gcd % p == 0:
        ab_gcd //= p
        elem.append(p)
    p = p + 1

if ab_gcd > 1:
    elem.append(ab_gcd)

cds = []
for c in elem:
    for i in range(2):
        e = c ** i
        if cds:
            copy_cds = copy.deepcopy(cds)
            for cd in copy_cds:
                cds.append(cd*e)
        cds.append(e)

cds = list(set(cds))
cds.sort(reverse=True)
print(cds[K-1])


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

int Merge(int A[], int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1+1], R[n2+1];
	int cnt = 0;
	
	for(int i=0; i<n1; i++){
		L[i] = A[left + i];
	}
	for(int i=0; i<n2; i++){
		R[i] = A[mid + i];
	}
	L[n1] = 1000000000;
	R[n2] = 1000000000;
	
	int i=0, j=0;
	
	for(int k=left; k<right; k++){
		if(L[i] <= R[j]){
			A[k] = L[i];
			i++;
			cnt++;
		}else{
			A[k] = R[j];
			j++;
			cnt++;
		}
	}
	
	return cnt;
}

int Merge_Sort(int A[], int left, int right){
	int cnt = 0;
	
	if(left+1 < right){
		int mid = (left + right)/2;
		cnt += Merge_Sort(A, left, mid);
		cnt += Merge_Sort(A, mid, right);
		cnt += Merge(A, left, mid, right);
	}
	
	return cnt;
}


int main(void){
	int A[500000], n, left, right, cnt;
	
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> A[i];
	}
	
	left = 0;
	right = n;
	
	cnt = Merge_Sort(A, left, right);
	
	for(int i=0; i<n-1; i++){
		cout << A[i] << " ";
	}
	cout << A[n-1] << "\n";
	
	cout << cnt << "\n";
	
	return 0;
}


Measured memory_bytes: 6976
#include <bits/stdc++.h>
using namespace std;
int n,p[200020];double z;
int main() {
	scanf("%d",&n),n*=2;
	for(int i=0;i<n;i++)
		scanf("%d",&p[i]);
	sort(p,p+n);
	for(int i=0;i<n;i++)
		z+=p[i]/(n-1.)*i;
	printf("%.10f\n", z);
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ld = long double;
const ld eps = 1e-9;


int main() {
	cout << fixed << setprecision(10);
	ld  a, l, x;
	while (cin >> a >> l >> x) {
		ld h = sqrt(powl(l, 2) - powl(a / 2, 2));
		ld w = sqrt(powl((l + x) / 2, 2) - powl(l / 2, 2));
		ld ans = a*h / 2 + l*w;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3172
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main() {
	string str;
	cin >> str;
	string a, b, c;
	a = str.substr(0, 5);
	b = str.substr(6, 7);
	c = str.substr(14, 5);
	cout << a << " " << b << " " << c;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ap[1005],bp[1005],cp[1005],abc[1005],r[1005];
int n,n1,n2,n3;

int main(){

    while(1){

    cin >> n1 >> n2 >> n3;
    if(n1==0&&n2==0&&n3==0)break;
    cin >> n;

   for(int i=0;i<=n1+n2+n3;i++)abc[i]=2;

    for(int i=0;i<n;i++){

        cin >> ap[i] >> bp[i] >> cp[i] >> r[i];

        if(r[i]==1){
        abc[ap[i]]=1,abc[bp[i]]=1,abc[cp[i]]=1;
        }
    }

    for(int i=0;i<n;i++){
     if(abc[ap[i]]==1&&abc[bp[i]]==1&&r[i]==0)abc[cp[i]]=0;
     else if(abc[cp[i]]==1&&abc[bp[i]]==1&&r[i]==0)abc[ap[i]]=0;
     else if(abc[cp[i]]==1&&abc[ap[i]]==1&&r[i]==0)abc[bp[i]]=0;
    }

    for(int i=1;i<n1+n2+n3+1;i++)cout << abc[i] << endl;

    }


return 0;
}

Measured memory_bytes: 1180
import math

K = int(input())

Sum = []
for a in range(1, K+1):
    for b in range(1, K + 1):
        gcd2 = math.gcd(a, b)
        for c in range(1, K + 1):
            gcd = math.gcd(gcd2, c)
            Sum.append(gcd)

print(sum(Sum))

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    cout << t << s << endl;
    return 0;
}

Measured memory_bytes: 256
def abc174b_distance():
    n, d = map(int, input().split())
    cnt = 0
    for i in range(n):
        x, y = map(int, input().split())
        di = (x ** 2 + y ** 2) ** 0.5
        if di <= d:
            cnt += 1
    print(cnt)

abc174b_distance()

Measured memory_bytes: 9440
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N, M;
vector<int> s, t;
vector<int> g[600], rg[600];

double e[600], p[600];

int main() {
	cin >> N >> M;
	s.resize(M);
	t.resize(M);
	REP(i, M) {
		scanf("%d %d", &s[i], &t[i]);
		
		s[i]--; t[i]--;
		g[s[i]].push_back(t[i]);
		rg[t[i]].push_back(s[i]);
	}
	
	e[N - 1] = 0;
	for (int i = N - 2; i >= 0; i--) {
		for (int v : g[i]) e[i] += e[v];
		e[i] /= g[i].size();
		e[i]++;
	}
	
	p[0] = 1;
	REP(i, N) {
		double cur = p[i] / g[i].size();
		for (int v : g[i]) p[v] += cur;
	}
	
	double ans = e[0];
	
	REP(i, M) {
		if (g[s[i]].size() == 1) continue;
		double sum = (e[s[i]] - 1) * g[s[i]].size();
		sum -= e[t[i]];
		sum /= g[s[i]].size() - 1;
		sum++;
		double diff = sum - e[s[i]];
		double cur = diff * p[s[i]] + e[0];
		chmin(ans, cur);
	}
	
	printf("%.15f\n", ans);
	
	return 0;
}



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

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

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            StringBuilder sb = new StringBuilder();
            String s = in.next();
            for (int i = 0; i < s.length(); i += 2) {
                sb.append(s.charAt(i));
            }
            out.println(sb);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

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

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



Measured memory_bytes: 21460
a=input().split()
b=a[0]
c=a[1]
d=input().split()
e=d[0]
f=d[1]
g=input().split()
h=g[0]
i=g[1]
L=[b,c,e,f,h,i]
if L.count('1')==3 or L.count('2')==3 or L.count('3')==3 or L.count('4') ==3:
    print('NO')
else:
    print('YES')


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

#define MAX_N 100010

vector<int> G[MAX_N];
int n,m;
int num[MAX_N],low[MAX_N];
int cnt;
vector<int> res;
int root=0;

void dfs(int v,int prev){
	num[v]=low[v]=++cnt;
	int dcnt=0;
	bool is_art=false;
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i];
		if(num[nv]==-1){
			dcnt++;
			dfs(nv,v);
			low[v]=min(low[v],low[nv]);
			if(v!=root&&num[v]<=low[nv])is_art=true;
		}else if(nv!=prev){
			low[v]=min(low[v],num[nv]);
		}
	}
	if((v==root&&dcnt>1)||is_art)res.pb(v);
}

void art_points(){
	memset(num,-1,sizeof(num));
	cnt=0;
	dfs(root,-1);
	sort(res.begin(),res.end());
}

int main(){
	cin.sync_with_stdio(false);
	cin>>n>>m;
	rep(i,m){
		int s,t;
		cin>>s>>t;
		G[s].pb(t); G[t].pb(s);
	}
	art_points();
	rep(i,res.size())cout<<res[i]<<endl;
	return 0;
}

Measured memory_bytes: 7344
def solve(h,w,ch,cw,dh,hw,s):
    d=[[1,0],[-1,0],[0,1],[0,-1]]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + d]
    INF=10**12
    path=[[INF]*w for _ in range(h)]
    ans=0
    st=[]
    st=deque()
    st.append((ch,cw,0))
    wp=[]
    wp=deque()
    while st:
      nx,ny,ncost=st.popleft()
      wp.append((nx,ny,ncost))
      path[nx][ny]=ncost
      for dx,dy in d:
        x=nx+dx
        y=ny+dy
        if (0<=x<=h-1) and (0<=y<=w-1):
          if s[x][y]!='#' and path[x][y]>ncost:
            path[x][y]=ncost
            st.append((x,y,ncost))
      if len(st)==0:
        while wp:
          nx,ny,ncost=wp.popleft()
          for dx,dy in warp:
              x,y=nx+dx,ny+dy
              if (0<=x<=h-1) and (0<=y<=w-1):
                if s[x][y]!='#' and path[x][y]>ncost+1:
                  path[x][y]=ncost+1
                  st.append((x,y,ncost+1))
    if path[dh][dw]==INF:
      print(-1)
    else:
      print(path[dh][dw])

if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    from collections import deque
    h,w=map(int,input().split())
    ch,cw=map(int,input().split())
    dh,dw=map(int,input().split())
    ch-=1
    cw-=1
    dh-=1
    dw-=1
    s=[input() for _ in range(h)]
    solve(h,w,ch,cw,dh,dw,s)

Measured memory_bytes: 98468
N = int(input())
card = [[0 for i in range(13)] for i in range(4)]

for _ in range(N):
    a, b = map(str, input().split())
    if a == "S":
      card[0][int(b)-1] = 1
    elif a == "H":
      card[1][int(b)-1] = 1
    elif a == "C":
      card[2][int(b)-1] = 1
    elif a == "D":
      card[3][int(b)-1] = 1 
for i in range(4):
  for j in range(13):
    if card[i][j] == 0:
    	if i == 0:
          print(f'S {j+1}')
    	elif i == 1:
          print(f'H {j+1}')      
    	elif i == 2:
          print(f'C {j+1}')        	
    	elif i == 3:
          print(f'D {j+1}')  


Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define ld double
#define X first
#define Y second
#define pb push_back
#define EPS 1e-22
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
using namespace std;
typedef pair<int, int> II;
typedef pair<II, int> III;

int main()
{
    ios::sync_with_stdio(0);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    string s, t;
    cin >> s >> t;
    FOR(i,0,s.length()-1) {
        cout << s[i];
        if (i == t.length()) continue;
        cout << t[i];
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val A = nextIntList().sorted()
    val n = A.max()!!
    val r = A.dropLast(1).bfind(n / 2)
    println("$n $r")
}

fun List<Int>.bfind(v: Int, l: Int = 0, r: Int = this.size): Int {
    if (r - l == 1) {
        if (r == this.size) return this[l]
        return if (Math.abs(this[r] - v) <= Math.abs(this[l] - v)) this[r] else this[l]
    }
    val m = (l + r) / 2
    val vm = this[m]
    return when {
        vm < v -> bfind(v, m, r)
        vm > v -> bfind(v, l, m)
        else -> v
    }
}

Measured memory_bytes: 54688
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {

	ll N, A, B;
	cin >> N >> A >> B;
	vector<ll> X(N + 1);
	repn(i, N) cin >> X[i];

	ll ans = 0;

	repn(i, N - 1) {
		ans += min(B, A*(X[i + 1] - X[i]));
	}

	cout << ans;
	

	system("PAUSE");
}


Measured memory_bytes: 1272
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cassert>
using namespace std;

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

const int B = 500;
int color[100010], par[100010], depth[100010];
int depthTop[100010];
int goUp[100010];
int vis[100010];
int n;
vector<vector<int>> g;

void decomp(int root){
    rep(i,n) vis[i] = false, par[i] = -1;
    queue<int> q;
    q.push(root);
    vector<int> tord;
    while(q.size()){
        int v = q.front(); q.pop();
        vis[v] = true;
        tord.push_back(v);
        for(int c : g[v]){
            if(!vis[c]){
                q.push(c);
                par[c] = v;
                depth[c] = depth[v] + 1;
            }
        }
    }
    rep(i,n) vis[i] = false;
    int c = 0;
    for(int u : tord){
        if(vis[u]) continue;
        q.push(u);
        int k = 0;
        while(q.size() && k < B){
            int v = q.front(); q.pop();
            vis[v] = true;
            color[v] = c;
            goUp[v] = par[u];
            depthTop[v] = depth[u];
            k++;
            for(int c : g[v]){
                if(!vis[c]) q.push(c);
            }
        }
        while(q.size()) q.pop();
        c++;
    }
}

int solve(int u, int v){
    while(color[u] != color[v]){
        if(depthTop[u] > depthTop[v]) u = goUp[u];
        else v = goUp[v];
    }
    while(u != v){
        if(depth[u] > depth[v]) u = par[u];
        else v = par[v];
    }
    return u;
}

int main(){
    cin >> n;
    g.assign(n,{});
    rep(i,n){
        int k;
        cin >> k;
        rep(j,k){
            int c;
            cin >> c;
            g[i].push_back(c);
            par[c] = i;
        }
    }
    decomp(0);
    int q;
    cin >> q;
    rep(i,q){
        int u,v;
        cin >> u >> v;
        cout << solve(u,v) << endl;
    }
}

Measured memory_bytes: 9380
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    n %= 10;
    if(n==2 || n==4 || n==5 || n==7 || n==9){
        cout << "hon";
    }else if(n==3){
        cout << "bon";
    }else{
        cout << "pon";
    }

    return 0;
}

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

#define debug_input freopen("stdin.in", "r", stdin)
#define debug_output freopen("stdout.out", "w", stdout)
#define FOR(i, a, b) for(ll i = a; i <= b; i++)
#define FORALL(i, n) for(ll i = 0; i < n; i++)
#define FORD(i, a, b) for(ll i = a; i >= b; i--)
#define SORT(a) sort(a.begin(), a.end())
#define REV(a) reverse(a.begin(), a.end())
#define NP(a) next_permutation(a.begin(), a.end())
#define ALL(a) a.begin, a.end()
#define mp make_pair
#define pb push_back
#define endl "\n"
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ll n, x, m;
vector<ll> v;
map<ll, bool> vis;

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

	cin >> n >> x >> m;	 

	while(not vis[x]) {
		v.pb(x);
		vis[x] = 1;
		x = (x * x) % m;
	}

	ll loopStart = 0;
	while(v[loopStart] != x) loopStart++;

	ll s = v.size();
	ll tot = 0;
	ll totLoop = 0;

	if(n <= loopStart) {
		FORALL(i, n) tot += v[i];
		cout << tot << endl;

		return 0;
	}

	FORALL(i, loopStart) tot += v[i];
	FOR(i, loopStart, s - 1) totLoop += v[i];

	n -= loopStart;
	tot += totLoop * (n / (s - loopStart));
	n %= s - loopStart;
	FORALL(i, n) tot += v[loopStart + i];

	cout << tot << endl;
	return 0;
}

Measured memory_bytes: 6712
def factorial(x)
  product = 1
  for i in 1..x do
    product *= i
  end
  return product
end

n = gets.to_i
p = gets.split.map(&:to_i)
q = gets.split.map(&:to_i)
pp = (1..n).to_a
qq = (1..n).to_a
a = 0
b = 0
for i in 0...n do
  a += pp.index(p[i]) * factorial(n-i-1)
  b += qq.index(q[i]) * factorial(n-i-1)
  pp.delete(p[i])
  qq.delete(q[i])
end
puts (a-b).abs


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  
  ll sum = 0;
  for(int i=1; i<(N+1); i++){
    if((0 == i%3 && 0 == i%5) || (0 == i%3) || (0 == i%5)){
      continue;
    }else{
      sum += i;
    }
  }
  
  cout << sum << endl;
}

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

ns = str(n)

numarr = range(1, n+1)

keta = [0]


for num in numarr:
    sum1 = 0

    for i in range(len(str(num))):

        sum1 += int(str(num)[i])

    if (a <= sum1 and sum1 <= b):
        keta.append(num)

print(sum(keta))

Measured memory_bytes: 3404
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

typedef long long ll;

const int kMaxN = 41, kState = 1 << 17, kMod = 1e9 + 7;
int n, x, y, z, end_state;
ll f[kMaxN][kState], pow10[kMaxN];

int DP(int now, int cur) {
  if (now == n)
    return 0;
  if (~f[now][cur])
    return f[now][cur];
  ll res = 0;
  for (int i = 1; i <= 10; ++i) {
    int next_state = (cur << i) | 1;
    if ((next_state & end_state) == end_state)
      res += pow10[n - now - 1];
    else
      res += DP(now + 1, next_state & ((1 << 17) - 1));
  }
  return f[now][cur] = res % kMod;
}

int main() {
  ios::sync_with_stdio(false);
  memset(f, 0xff, sizeof f);
  cin >> n >> x >> y >> z;
  pow10[0] = 1;
  for (int i = 1; i < 41; ++i)
    pow10[i] = 10LL * pow10[i - 1] % kMod;
  end_state = (1 << x) + (1 << (x + y)) + (1 << (x + y + z));
  cout << DP(0, 1) << endl;
  return 0;
}

Measured memory_bytes: 42368
package main

import (
	"fmt"
	"strconv"
)

const mod = 1e9 + 7

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	var s string
	fmt.Scan(&s)
	l := len(s)
	a := [13]int{}
	a[0] = 1
	for j := 0; j < l; j++ {
		b := [13]int{}
		k := s[j : j+1]
		if k == "?" {
			for o := 0; o < 13; o++ {
				ai := a[o]
				ii := o * 10 % 13
				for m := 0; m < 10; m++ {
					b[(ii+m)%13] += ai
				}
			}
			for o := 0; o < 13; o++ {
				b[o] %= mod
			}
		} else {
			tt, _ := strconv.ParseInt(k, 10, 64)
			t := int(tt)
			for o := 0; o < 13; o++ {
				ai := a[o]
				ii := (o*10 + t) % 13
				b[ii] = ai
			}
		}
		a = b
	}
	fmt.Println(a[5])
}


Measured memory_bytes: 1280
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
 
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
#define ll long long
int main()
{
    string s;
    cin>>s;
    for(int i=1;i<s.size();i++)
    {
        if(s[i]==s[i-1])
        {
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    cout<<"Good"<<endl;
}

Measured memory_bytes: 256
MOD = 998244353
N,S = map(int,input().split())
A = list(map(int,input().split()))
dp = [[0]*(S+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for j in range(S+1):
        # dp[i+1][j] = dp[i][j]
        dp[i+1][j] = 2*dp[i][j]
        if j - A[i] >= 0:
            dp[i+1][j] += dp[i][j-A[i]]
        dp[i+1][j] %= MOD


print(dp[N][S])

Measured memory_bytes: 132704
#from collections import deque, Counter
#from heapq import heapify, heappop, heappush
#from bisect import insort
#from math import gcd
#from decimal import Decimal
#mod = 1000000007
#mod = 998244353
N = int(input())
#N, K = map(int, input().split())
#A = list(map(int, input().split()))

#flag = True
ans = ''
for k in range(N):
  ans += 'ACL'
#ans = 0
print(ans)
#print('Yes')
#print('No')

Measured memory_bytes: 61556
//
//  main.cpp
//  ALDS1_5_B
//
//  Created by ptyuan on 2018/10/28.
//  Copyright © 2018 Sy. All rights reserved.
//

#include <iostream>
#include <cstdio>
using namespace std;

const int kMaxValue = 2000000000;
const int kMax = 500000;

int A[kMax] = {0};

int L[kMax / 2 + 2];
int R[kMax / 2 + 2];
int cmpCount = 0;

void _merge(int *A, int n, int left, int mid, int right) {
    int n1 = mid - left;
    for (int i = 0; i < n1; i++) {
        L[i] = A[left + i];
    }
    
    int n2 = right - mid;
    for (int i = 0; i < n2; i++) {
        R[i] = A[mid + i];
    }
    
    L[n1] = kMaxValue;
    R[n2] = kMaxValue;
    int l1 = 0;
    int l2 = 0;
    for (int k = left; k < right; k++) {
        ++cmpCount;
        if (L[l1] <= R[l2]) {
            A[k] = L[l1++];
         } else {
             A[k] = R[l2++];
         }
    }
}

void mergeSort(int *A, int n, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        _merge(A, n, left, mid, right);
    }
}



int main(int argc, const char * argv[]) {
    int n = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", A + i);
    }
    
    mergeSort(A, n, 0, n);
    for (int i = 0; i < n; i++) {
        int value = A[i];
        if (i > 0) {
            printf(" ");
        }
        printf("%d", value);
    }
    printf("\n");
    printf("%d\n", cmpCount);
    
    
    return 0;
}



Measured memory_bytes: 7124
//ABC159

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

string S,T,U;
int A,B;

int main() {
  cin >> S >> T;
  cin >> A >> B;
  cin >> U;

  if(S == U){
    A--;
  }
  else{
    B--;
  }

  printf("%d %d\n",A,B);
}


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

int main() {
  int N;
  cin >> N;
  int mod = N%10;
  if(mod == 2 || mod == 4 || mod == 5 || mod == 7 || mod == 9){
	cout << "hon" << endl;
  }else if(mod == 0 || mod == 1 || mod == 6 || mod == 8){
	cout << "pon" << endl;
  }else{
    cout << "bon" << endl;
  }
  
  return(0);
}

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

const int maxn=100000+10;
int n,k;
long long a[maxn];

int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	int index=k-1;
	long long minp=1000000000+10;
	sort(a,a+n);
	while(index<n)
	{
		if(a[index]-a[index-k+1]<minp)
			minp=a[index]-a[index-k+1];
		index++;
		//cout<<minp<<endl;
	}
	cout<<minp<<endl;


	return 0;
}



Measured memory_bytes: 1024
n = int(input())
A = list(map(int, input().split()))[::-1]

import collections

L = [i + A[i] for i in range(n)]
R = [j - A[j] for j in range(n)]

cL = collections.Counter(L)
cR = collections.Counter(R)

cnt = 0

MAX = 200000
for x in range(MAX):
	cnt += cL[x] * cR[x]

print(cnt)

Measured memory_bytes: 142600
// https://atcoder.jp/contests/abc055/tasks/abc055_b
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
const int MOD = 1000000007;
// namespace mp = boost::multiprecision;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    // mp::cpp_int x = 1;
    ll x = 1;
    for (int i = 1; i <= n; i++) {
        x *= i;
        x %= MOD;
    }
    cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var num = ToInt32(ReadLine());
        var str = new string[3];
        for (var i = 0; i < 3; i++)
            str[i] = ReadLine();
        var res = 0;
        for(var i = 0; i < num; i++)
        {
            var set = new HashSet<string>();
            for(var j = 0; j < 3; j++)
            {
                set.Add(str[j].Substring(i, 1));
            }
            res += set.Count-1;
        }
        WriteLine(res);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 13280
package main

import (
        "fmt"
        "strings"
)

var (
        min  int
        n    int
        list []string
)

func r(x string) int {
        if x == "E" {
                return -1
        }   
        return 0
}

func b(x string) int {
        if x == "W" {
                return 1
        }   
        return 0
}

func main() {
  var n int
  fmt.Scan(&n)
  var s string
  fmt.Scan(&s)
        list = strings.Split(s, "") 
  for i := 1; i < n; i++ {
                if list[i] == "E" {
                        min++
                }
        }
        t := min
        for i := 1; i < n; i++ {
                t += b(list[i-1]) + r(list[i])
                if min > t {
                        min = t
                }
        }

        fmt.Print(min)
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a,a+n);
    int A=0;
    int B=0;
    for(int i=0;i<n;i++){
        if(i%2==0)A+=a[n-1-i];
        else B+=a[n-1-i];
    }
    cout << A-B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b)
{
}

int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> a(N);
    for (int i = 0; i < M; i++)
    {
        int x, y;
        cin >> x >> y;
        a[x - 1]++;
        a[y - 1]++;
    }

    REP(i,N){
        cout << a[i] << endl;
    }    
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")

#include <bits/stdc++.h>

#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define all(v) begin(v), end(v)

typedef long long Long;
typedef vector<int> vi;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif

  int n;
  cin >> n;

  map<int, int> cnt;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ++cnt[x];
  }

  if (cnt.size() > 3) {
    cout << "No" << endl;
    return 0;
  }
  if (cnt.size() == 1) {
    if (cnt.begin()->first != 0) {
      cout << "No" << endl;
      return 0;
    } else {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if (cnt.size() == 2) {
    if (cnt.begin()->first != 0 || n % 3 != 0 ||
        cnt.rbegin()->second != 2 * cnt.begin()->second) {
      cout << "No" << endl;
      return 0;
    }
    cout << "Yes" << endl;
    return 0;
  }
  if (cnt.size() == 3) {
    auto it1 = cnt.begin();
    auto it2 = it1;
    ++it2;
    auto it3 = it2;
    ++it3;
    if ((it1->first ^ it2->first) == it3->first && it1->second == it2->second &&
        it2->second == it3->second) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
    return 0;
  }

  return 0;
}


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

int main()
{
  int N;
  cin >> N;
  vector<pair<int, int>> red(N);
  for (int i = 0; i < N; i++)
  {
    int a, b;
    cin >> a >> b;
    red[i].first = a;
    red[i].second = b;
  }
  vector<pair<int, int>> blue(N);
  for (int i = 0; i < N; i++)
  {
    int c, d;
    cin >> c >> d;
    blue[i].first = c;
    blue[i].second = d;
  }
  sort(red.begin(), red.end(), greater<pair<int, int>>());
  int ans = 0;
  vector<bool> used(N, false);
  int match = -1;
  int min = 1000000000;
  for (int i = 0; i < N; i++)
  {
    match = -1;
    min = 1000000000;
    for (int j = 0; j < N; j++)
    {
      if (!used[j] && blue[j].first > red[i].first && blue[j].second > red[i].second)
      {
        int tmp = blue[j].second;
        if (tmp < min)
        {
          min = tmp;
          match = j;
        }
      }
    }
    if (match >= 0)
    {
      used[match] = true;
    }
  }
  for (int i = 0; i < N; i++)
  {
    if (used[i])
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll H,W;
char field[60][60];

ll dfs(ll y, ll x,ll c){
    field[y][x] = '.';
    c++;
    
    for(int dx = -1; dx <= 1; dx += 2){
        ll nx = x + dx,ny = y;
        if(0 <= nx && nx < W && 0 <= ny && ny < H && field[ny][nx] == '#') c = dfs(ny,nx,c);
    }
    for(int dy = -1; dy <= 1; dy += 2){
        ll nx = x,ny = y + dy;
        if(0 <= nx && nx < W && 0 <= ny && ny < H && field[ny][nx] == '#') c = dfs(ny,nx,c);
    }
    
    return c;
} 


int main(){
    cin >> H >> W;
    for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++)
            cin >> field[i][j];
            
    for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++)
            if(field[i][j] == '#')
                if(1 == dfs(i,j,0)){
                    cout << "No" << "\n";
                    return 0;
                }
    cout << "Yes" << "\n";
    return 0;
}


Measured memory_bytes: 384
#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 mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


const int N=1e6+6;
ll fac[N];
void compute()
{ 
    fac[0]=1;
    ll i;
    for(i=1;i<N;i++)
    {
        fac[i]=fac[i-1]*i%mod;
        fac[i]%=mod;
    }
}

long long power(long long x, long long y, long long p)
{
long long res = 1;


x = x % p;


while (y > 0)
{
if (y & 1)
res = (res*x) % p;


y = y>>1;
x = (x*x) % p;
}
return res;
}

long long modInverse(long long n, long long p)
{
return power(n, p-2, p);
}


long long ncrp(long long n, long long r, long long p)
{


if (r==0)
return 1;




 return (fac[n]* modInverse(fac[r], p) % p *modInverse(fac[n-r], p) % p) % p;
}


void solve()
{
    ll s;
    cin>>s;
    ll res=0;
    compute();
    ll no = (s+2)/3;
    ll i;
    for(i=1;i<=no;i++)
    {
        if(i*3<=s)
        {
              
            ll nn = s-3*i;
            ll tans = ncrp(nn+i-1,i-1,mod);
            res+=tans;
            res%=mod;
        }
    }
    cout<<res<<"\n";
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 11456
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
/* テンプレートここまで */

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


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

using Graph = vector<vector<P>>;
Graph g(100000);

// (頂点, 距離)
P dfs(int cur, int pre)
{
    P ret = P(cur, 0);
    for (const auto &e : g[cur])
    {
        if (e.first == pre)
            continue;
        P p = dfs(e.first, cur);
        if (p.second + e.second > ret.second)
        {
            ret.second = p.second + e.second;
            ret.first = p.first;
        }
    }
    return ret;
}

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

    int n;
    cin >> n;

    for (int i = 0; i < n - 1; i++)
    {
        int s, t, w;
        cin >> s >> t >> w;
        g[s].push_back(P(t, w));
        g[t].push_back(P(s, w));
    }
    P p = dfs(0, -1);
    P ret = dfs(p.first, -1);
    cout << ret.second << endl;
}



Measured memory_bytes: 14356
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>

int main()
{
    double a, b, c;
    std::cin >> a >> b >> c;

    double S = 0.5 * a * b * sin(c * M_PI/180);

    double L = a + b + sqrt(a*a + b*b - 2 * a * b* cos(c * M_PI/180));

    double h = b * sin(c*M_PI/180);

    std::cout << std::fixed << std::setprecision(20) << S << std::endl;
    std::cout << L << std::endl;
    std::cout << h << std::endl;

    return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; ++i)
#define repx(i,x,n) for(int i = x; i < n; ++i)
#define ff first
#define ss second
typedef long long ll;
typedef pair<int,int> par;




class ST {
    vector<ll> *arr;
    vector<int> st;
    vector<ll> memo;
    int n;

    void build(int u, int i, int j) {
        if (i == j) {
            memo[u] = i;
            st[u] = u;
            return;
        }
        int m = (i+j)/2, l = u*2+1, r = u*2+2;
        build(l, i, m);
        build(r, m+1, j);
        st[u] = ((*arr)[memo[st[r]]] <= (*arr)[memo[st[l]]]) ? st[l] : st[r];
    }

    int query(int a, int b, int u, int i, int j) {
        if (j < a or b < i) return n*4+5;
        if (a <= i and j <= b) return st[u];
        int m = (i+j)/2, l = u*2+1, r = u*2+2;
        int x = query(a, b, l, i, m);
        int y = query(a, b, r, m+1, j);
        return ((*arr)[memo[y]] <= (*arr)[memo[x]]) ? x : y;
    }

    void update(int a, int u, int i, int j) {
        if (j < a or a < i) return;
        if (i == j){
            st[u] = n*4+5;
        }
        else {
            int m = (i+j)/2, l = u*2+1, r = u*2+2;
            update(a, l, i, m);
            update(a, r, m+1, j);
            st[u] = ((*arr)[memo[st[r]]] <= (*arr)[memo[st[l]]]) ? st[l] : st[r];
        }
    }

public:
    ST(vector<ll>& v) {
        arr = &v;
        n = v.size();
        st.resize(n*4+6);
        memo.resize(n*4+6);
        memo[n*4+5] = n;
        arr->emplace_back(-1);
        build(0, 0, n-1);
    }

    int query(int a, int b) {
        return memo[query(a, b, 0, 0, n-1)];
    }

    void update(int a) {
        update(a,0, 0, n-1);
    }
};


int main(){
    int n,m;
    cin >> n >> m;
    vector<par> P(n);
    rep(i,n){
        cin >> P[i].ff >> P[i].ss;
    }
    sort(P.begin(),P.end());
    vector<ll> temp(n);
    rep(i,n){
        temp[i] = P[i].ss;
    }
    ST T(temp);

    int index = 0;
    ll total = 0;
    for(int i = 1; i <= m; ++ i){
        while(index < n and P[index].ff <= i) ++index;
        int cand = T.query(0,index-1);
        if(cand != n){
            total += P[cand].ss;
            T.update(cand);
        }
    }
    cout << total << '\n';
}

Measured memory_bytes: 7296
#include <stdio.h>
long N(long x){
  return (x+1)*(x+2)*(x+3)/6;
}

int main(){
  long n;
  while(~scanf("%ld",&n)){
    if (n > 2000) n = 4000 - n;
    if (n < 1001) printf("%ld\n",N(n));
    else printf("%ld\n", N(n)-(N(2*(n-1000))-n+999)/2);
  }
  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
#define pii pair<int,int>
map<pii, int> Map;
int n,m,k;
int UF[2][201000];
int Find(int pv, int a) {
  if(UF[pv][a] == a) return a;
  return UF[pv][a] = Find(pv, UF[pv][a]);
}
void Merge(int pv, int a, int b) {
  a = Find(pv, a);
  b = Find(pv, b);
  if(a != b) UF[pv][a] = b;
}
int main(){
  int i, a, b;
  scanf("%d%d%d",&n,&m,&k);
  for(i=1;i<=n;i++)UF[0][i]=UF[1][i]=i;
  for(i=0;i<m;i++){
    cin>>a>>b;
    Merge(0,a,b);
  }
  for(i=0;i<k;i++){
    cin>>a>>b;
    Merge(1,a,b);
  }
  for(i=1;i<=n;i++){
    Map[pii(Find(0,i),Find(1,i))]++;
  }
  for(i=1;i<=n;i++){
    printf("%d%c",Map[pii(Find(0,i),Find(1,i))],i==n-1?'\n':' ');
  }
  return 0;
}


Measured memory_bytes: 13568
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        var R = cin.nextdouble;
        var G = cin.nextdouble;

        WriteLine(2 * G - R);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11092