akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;

int N, K;
int t[100010];
ll  d[100010];
 
typedef tuple<ll, int> sushi;
vector<sushi> V;
priority_queue<sushi, vector<sushi>, greater<sushi>> Q;
int cnt[100010];

int main() {
    cin >> N >> K;
    for (auto i = 0; i < N; i++)
    {
        cin >> t[i] >> d[i];
        t[i]--;
        V.push_back(sushi(d[i], t[i]));
    }
    sort(V.begin(), V.end());
    reverse(V.begin(), V.end());
    fill(cnt, cnt + N, 0);
  
    ll ans = 0;
    ll tans = 0;
    for (auto i = 0; i < K; i++)
    {
        ll cost = get<0>(V[i]);
        int val = get<1>(V[i]);
        tans += cost;
        cnt[val]++;
        Q.push(V[i]);
    }
    ll v = 0;
    for (auto i = 0; i < N; i++)
    {
        if (cnt[i] > 0)
        {
             v++;
        }
    }
    ans = tans + v * v;
    for (auto i = K; i < N; i++)
    {
        ll cost = get<0>(V[i]);
        int val = get<1>(V[i]);
        if (cnt[val] == 0)
        {
            while (!Q.empty())
            {
                ll cost_q = get<0>(Q.top());
                int val_q = get<1>(Q.top());
                Q.pop();
                if (cnt[val_q] >= 2)
                {
                    cnt[val_q]--;
                    tans -= cost_q;
                    cnt[val]++;
                    tans += cost;
                    v++;
                    ans = max(ans, tans + v * v);
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}

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

int main() {

  int a, b, c;
  cin >> a >> b >> c;

  int count = 0;
  for(int i = a; i <= b; ++i) {
    if(c % i == 0) ++count;
  }

  cout << count << endl;

  return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1; i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i >= 0;i--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back

#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second

const int INF = (INT_MAX/2);
const double eps = 1e-14;
const double PI = M_PI;

#define DEB cout<<"!"<<endl
#define SHOW(a,b) cout<<(a)<<" "<<(b)<<endl



int main(){
  ll N,X; cin >> N >> X;
  ll gcd = __gcd(N,X);
  cout << N*3 - 3 * gcd << endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

using namespace std;

long long PRIME = 1000000007;


bool check(string& s, int start, int end){
    int count = 0;

    for(int i = start; i <= end; ++i){
        if(s[i - 1] == '#'){
            ++count;
            if(count == 2){
                return false;
            }
        }
        else{
            count = 0;
        }
    }

    return true;
}


int main(int argc, char* argv[]){
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;

    string S;
    cin >> S;

    if(!check(S, B, D) || !check(S, A, C)){
        cout << "No";
        return 0;
    }

    if(C < D){
        cout << "Yes";
    }
    else{
        int count = 0;
        for(int i = B - 1; i <= D + 1; ++i){
            if(S[i - 1] == '.'){
                ++count;
                if(count == 3){
                    cout << "Yes";
                    return 0;
                }
            }
            else{
                count = 0;
            }
        }

        cout << "No";
    }

}


Measured memory_bytes: 640
n = int(input())
A = list(map(int, input().split()))
SUM = sum(A)
init = SUM - 2*sum(A[1::2])
dp = [0]*n
dp[0] = init
for i in range(1, n):
    dp[i] = 2*A[i-1]-dp[i-1]
print(*dp)


Measured memory_bytes: 14092
//ΔATCODER B
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
const int N = 222222;
int a[N],b[N];
int main()
{
	int n,m,i,j;
	scanf("%d",&n);
	for(i=1;i<=n;i=i+1)
		scanf("%d",a+i);
	scanf("%d",&m);
	for(i=1;i<=m;i=i+1)
		scanf("%d",b+i);
	sort(a+1,a+n+1);
	sort(b+1,b+m+1);
	i=1;
	j=1;
	while(i<=n&&j<=m){
		if(a[i]>b[j]){
			cout<<"NO\n";
			return 0;
		}
		if(a[i]==b[j])
			j++;
		i++;
	}
	if(j>m)
		cout<<"YES\n";
	else
		cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 1792
n=int(input())
col=[-1]*n
e=[[[],[]]for i in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    u-=1
    v-=1
    w%=2
    e[u][w].append(v)
    e[v][w].append(u)
col[0]=1
from collections import deque
dq=deque([])
#pop/append/(append,pop)_left/in/len/count/[]/index/rotate()(右へnずらす)
dq.append(0)
while dq:
    a=dq.pop()
    b=col[a]
    for i in range(2):
        for ne in e[a][i]:
            if col[ne]==-1:
                col[ne]=b^i
                dq.appendleft(ne)
print(*col,sep='\n')

Measured memory_bytes: 44108
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll A, B, N;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> A >> B >> N;
    ll x = min(B-1, N);
    cout << (A*x)/B-A*(x/B) << endl;
}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int64_t r=0;
  int64_t g=0;
  int64_t b=0;
  //RGBの数それぞれ数える
  
  for(int i=0; i<N; i++){
    if(S.at(i) == 'R'){
      r++;
    }
    if(S.at(i) == 'G'){
      g++;
    }
    if(S.at(i) == 'B'){
      b++;
    }
  }
  
  int64_t onaji=0;
  for(int i=0; i<N; i++){
    for(int d=1; i+2*d<N; d++){
      if(S.at(i)!=S.at(i+d) && S.at(i)!=S.at(i+2*d) && S.at(i+d)!=S.at(i+2*d)){
        onaji++;
      }
    }
  }
  
  int64_t ans = r*g*b - onaji;
  
  
  cout << ans << endl;
}


Measured memory_bytes: 3572
#include <cstdio>
#include <iostream>
#include <cmath>
#include <set>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
using namespace std;
typedef long long ll;
const int N=200000+10;
int n,dp[N],h[N];
int main()
{
    //freopen("a.in","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>h[i];
    memset(dp,0x3f,sizeof(dp));
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n]<<"\n";
    return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), l[] = new int[n];
		for(int i = 0; i < n; ++i)l[i] = sc.nextInt();
		sc.close();
		Arrays.sort(l);
		int sum = 0;
		for(int i = 0; i < n-1; ++i) sum += l[i];
		if(sum > l[n-1])System.out.println("Yes");
		else System.out.println("No");

	}

}


Measured memory_bytes: 22740
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const ll MOD = 1000000007;
// const int INF = 2000000000;

string S;

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

  ll ans = 0;
  ll num_w = 0;
  for (ll i = S.size() - 1; i >= 0; i--) {
    if (S[i] == 'W') {
      num_w++;
    } else {
      ans += num_w;
    }
  }

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

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
int mod=1e9+7;

int po(int x,int y,int m){
	if (y==0)
		return 1;
	int t=po(x,y/2,m)%m;
	t=(t*t)%m;
	if (y&1)
		return (t*x)%m;
	return t%m;
}

int lb(int a[],int n,int x){
    int l=-1;  //a[l]<x
    int r=n;   //a[r]>=x
    while(r>l+1){
    	int m=l+(r-l)/2;
    	if (a[m]<x)
    		l=m;
    	else
    		r=m;
    }
    return r;
}

int ub(int a[],int n,int x){
    int l=-1;  //a[l]<=x
    int r=n;   //a[r]>x
    while(r>l+1){
    	int m=l+(r-l)/2;
    	if (a[m]>x)
    		r=m;
    	else
    		l=m;
    }
    return l;
}

signed main() {

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   	
   	int a,b,c;
   	cin>>a>>b>>c;
   	if (a%b==0)
   		cout<<(a/b)*c;
   	else
   		cout<<((a/b)+1)*c<<endl;
    
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
    string s,ans = "yes";
    map<char,int>m;

    cin >> s;

    for(int i = 0;i < s.size();i++)
        m[s[i]]++;

    for(auto &i:m)
        if(i.second > 1)ans = "no";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func reverseInts(s []int) []int {
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
	return s

}

func main() {
	var A, B int
	fmt.Scanf("%v %v", &A, &B)

	sum := A + B
	minus := A - B
	multi := A * B

	if sum >= minus && sum >= multi {
		fmt.Println(sum)
	} else if minus >= sum && minus >= multi {
		fmt.Println(minus)
	} else if multi >= sum && multi >= minus {
		fmt.Println(multi)
	}

}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
int main(void){
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,T;
  cin >> N >> T;
  int a = 10000;
  for(int i = 0; i < N; i++){
    int c_i,t_i;
    cin >> c_i >> t_i;
    //cout << c_i << t_i << i << endl;
    if(t_i <= T && c_i <= a){
      a = c_i;
    }
  }
  if(a == 10000){
    cout << "TLE" << endl;
  }
  else{
    cout << a << endl;
  }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2589>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
string S;
string solve(){
    string res;
    int i = (int)S.length()-1, a = 0, k = 1;
    while(S[i] != 'n' && S[i] != 'w') i--;
    if(S[i] == 'n') a = 0;
    else if(S[i] == 'w') a = 90;
    if(i > 0) i--;
    while(i!= 0){
        i--;
        if(S[i] == 'n'){
            a*=2; a -= 90; k *= 2;
        }else if(S[i] == 'w'){
            a*=2; a += 90; k *= 2;
        }
    }
    while(a%2==0&&k%2==0){ a/=2; k/=2;}
    if(k == 1) res = to_string(a);
    else res = to_string(a) + "/" + to_string(k);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    while(cin >> S){
        if(S == "#") break;
        cout << solve() << endl;
    }
    return 0;
}



Measured memory_bytes: 3252
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const int MAXN=1e5+5;
int a[MAXN];
int G[105][105];

int main()
{
    int h,w;
    while(scanf("%d%d",&h,&w)!=EOF)
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;++i)
            scanf("%d",&a[i]);
        int cnt=1;
        for(int i=1;i<=h;++i)
        {
            if(i&1)
            {
                for(int j=1;j<=w;++j)
                {
                   if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                   else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }else
            {
                for(int j=w;j>=1;--j)
                {
                    if(a[cnt]>0) {G[i][j]=cnt;--a[cnt];}
                    else if(a[cnt]==0) {++cnt;G[i][j]=cnt;--a[cnt];}
                }
            }
        }
        for(int i=1;i<=h;++i)
        {
            for(int j=1;j<=w;++j)
            {
                if(j!=w) printf("%d ",G[i][j]);
                else printf("%d\n",G[i][j]);
            }
        }
    }


}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main()
{
    map<char,char> mp;
    mp['A']  = 'T';
    mp['T'] = 'A';
    mp['C'] = 'G';
    mp['G'] = 'C';

    char x;
    cin >> x;
    cout << mp[x];
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long int ans=1;
    int N;
    cin>>N;
    
    for(int i=1;i<=N;i++){
        ans *= i;
        
        if(ans>1000000007){
            ans %= 1000000007;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int (i) = 0; i < (n); i++)

int main(){
  int N, X, x[100000], dif[100000] = {(int)1e9}, ans;
  cin >> N >> X;
  rep(i, N) {
    cin >> x[i];
    dif[0] = min(dif[0], abs(X - x[i]));
  }
  sort(x, x + N);
  rep(i, N - 1) dif[i + 1] = x[i + 1] - x[i];
  ans = dif[0];
  rep(i, N - 1) {
    int r;
    if(ans < dif[i]) swap(ans, dif[i]);
    r = ans % dif[i];
    while(r != 0){
      ans = dif[i];
      dif[i] = r;
      r = ans % dif[i];
    }
    ans = dif[i];
  }
  cout << ans << endl;
}	

Measured memory_bytes: 1024
from collections import deque

N = int(input())
E = [[] for _ in range(N)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    E[a-1].append((b-1, c))
    E[b-1].append((a-1, c))

Q, K = map(int, input().split())
distance = [0] * N
stack = deque([K-1])
# checked = [False] * N
while stack:
    v = stack.pop()
    for u, c in E[v]:
        if distance[u] != 0:
            continue
        distance[u] = distance[v] + c
        stack.append(u)
    # checked[v] = True

ans = [0] * Q
for i in range(Q):
    x, y = map(int, input().split())
    ans[i] = distance[x-1] + distance[y-1]

[print(a) for a in ans]

Measured memory_bytes: 49396
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  string s;
  cin >> s;
  if(s[0] != s[1] && s[1] != s[2] && s[2] != s[3]){
    cout << "Good";
  } else {
    cout << "Bad";
  }
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0; i<n ; ++i)
#define all(v) v.begin() , v.end()
#define sz(v) (int(v.size()))
typedef unsigned long long ul;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<char, int> pci;
typedef vector<pii> vp;
typedef vector<pci> vpc;
typedef pair<int,pii> piii;

int OO = 2e9;
const double eps = 1e-9 ;
const int N = 500000;
ll mx = -1e9 , mn = 1e16 ;
int arr[N] ;
pii pir[5];


int main()
{   ll n; cin >> n;
    ll ans = 4;
    lp(i,5){
        ll x ;cin >> x;
        mn = min(mn,x);
    }
    cout << ans + ll(ceil(double(n)/double(mn))) << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define GET(_1, _2, _3, _4, F, ...) F
#define IN1(a) \
    ll a;          \
    cin >> a;
#define IN2(a, b) \
    ll a, b;          \
    cin >> a >> b;
#define IN3(a, b, c) \
    ll a, b, c;          \
    cin >> a >> b >> c;
#define IN4(a, b, c, d) \
    ll a, b, c, d;          \
    cin >> a >> b >> c >> d;
#define in(...)                           \
    GET(__VA_ARGS__, IN4, IN3, IN2, IN1) \
    (__VA_ARGS__)
int main() {
  in(D, T, S);
  cout << (S * T >= D ? "Yes" : "No") << endl;
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   int x;
   cin>>x;
   if(x<600) cout << 8 << endl;
   else if(x<800) cout<<7<<endl;
   else if(x<1000) cout<<6<<endl;
   else if(x<1200) cout<<5<<endl;
   else if(x<1400) cout<<4<<endl;
   else if(x<1600) cout<<3<<endl;
   else if(x<1800) cout<<2<<endl;
   else if(x<2000) cout<<1<<endl;
   return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <deque>

using namespace std;

const int MAX = 8009 * 2, ORIGIN = 8009;
int b[MAX][MAX], x, y;
vector<int> sy, sx, d;

bool valid(int p);
deque<vector<int>> dp(const vector<int> &iv, const vector<int> &sv);

bool valid(int p) {
	return (0 <= p && p < MAX);
}

void printv(const vector<int> &v) {
	for (int i = ORIGIN - 10; i < ORIGIN + 10; i++) {
		cerr << v[i] << ' ';
	}
	cout << '\n';
}

void debug(const vector<int> &v) {
	for (auto ch : v) {
		cout << ch << ' ';
	}
	cout << '\n';
}

deque<vector<int>> dp(const vector<int> &iv, const vector<int> &sv) {
	deque<vector<int>> l;
	l.push_back(iv);
	for (int i = 0; i < sv.size(); i++) {
		vector<int> newv(MAX);
		for (int j = 0; j < MAX; j++) {
			 if (valid(j - sv[i]) && l.front()[j - sv[i]] == 1) {
			 	newv[j] = 1;
			 } else if (valid(j + sv[i]) && l.front()[j + sv[i]] == 1) {
			 	newv[j] = 1;
			 }
		}
		l.push_back(newv);
//		printv(newv);
		l.pop_front();
	}
	return l;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	
	string s;
	cin >> s >> x >> y;
	int dist = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'T') break;
		dist++;
	}
	int dir = -1, start = dist;
	dist = 0;
	for (int i = start + 1; i < s.size(); i++) {
		if (s[i] == 'F') dist++;
		else {
			if (dist != 0) d.push_back(dir * dist);
			dir *= -1;
			dist = 0;
		}
	}
	if (dist != 0) d.push_back(dir * dist);
	for (int i = 0; i < d.size(); i++) {
		if (d[i] < 0) sy.push_back(abs(d[i]));
		else sx.push_back(abs(d[i]));
	}
//	debug(sx);
//	debug(sy);
	vector<int> ix(MAX), iy(MAX);
	ix[ORIGIN + start] = iy[ORIGIN] = 1;
	vector<int> dy = dp(iy, sy).front(), dx = dp(ix, sx).front();
	if (dy[ORIGIN + y] && dx[ORIGIN + x]) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	
	return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
const long long INF = 1LL<<60;
const long long mod=1e9+7;

int main(){
    int N;
    cin >> N;
    int l[N];
    REP(i,N) cin >> l[i];
    int max = 0;
    int sum = 0;
    REP(i,N){
        if(l[i] > max) max = l[i], sum += l[i];
        else sum += l[i];
    }
    if(sum > 2 * max) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

  static int[] n;

  public static void main(String[] args) {

    String S = sc.next();
    n = new int[S.length()];

    for (int i=0; i<n.length; i++) {
      n[i] = Integer.parseInt(S.substring(n.length-i-1, n.length-i));
    }

    int sum = g(n.length-1, 0, 0, 0);
    for (int i=2; i<n.length-1; i++) {
      sum += h(i, 0, 0, 0);
    }

    System.out.println(sum);

  }

  static int g(int m, int seven, int five, int three) {

    if (m < 0) return (seven + five + three == 3) ? 1 : 0;

    if (n[m] < 3) {
      return 0;
    } else if (n[m] == 3) {
      return g(m-1, seven, five, 1);
    } else if (n[m] < 5) {
      return h(m-1, seven, five, 1);
    } else if (n[m] == 5) {
      int a = h(m-1, seven, five, 1);
      int b = g(m-1, seven, 1, three);
      return h(m-1, seven, five, 1) + g(m-1, seven, 1, three);
    } else if (n[m] < 7) {
      return h(m-1, seven, five, 1) + h(m-1, seven, 1, three);
    } else if (n[m] == 7) {
      return h(m-1, seven, five, 1) + h(m-1, seven, 1, three) + g(m-1, 1, five, three);
    } else {
      return h(m-1, seven, five, 1) + h(m-1, seven, 1, three) + h(m-1, 1, five, three);
    }
  }

  static int h(int m, int seven, int five, int three) {

    int a = seven + five + three;

    if (m < 0) {
      return (seven + five + three == 3) ? 1 : 0;
    } else if (m == 0) {
      if (a < 2) {
        return 0;
      } else if (a == 2) {
        return 1;
      } else {
        return 3;
      }
    } else if (m == 1) {
      if (a == 0) {
        return 0;
      } else if (a == 1) {
        return 2;
      } else if (a == 2) {
        return 5;
      } else if (a == 3) {
        return 9;
      }
    }

    switch(a) {
      case 0: return (int)Math.pow(3, m+1) - 3 * (int)Math.pow(2, m+1) + 3;
      case 1: return (int)Math.pow(3, m+1) - 2 * (int)Math.pow(2, m+1) + 1;
      case 2: return (int)Math.pow(3, m+1) -     (int)Math.pow(2, m+1);
      case 3: return (int)Math.pow(3, m+1);
      default: return Integer.MIN_VALUE;
    }
  }

}


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

int week(int m,int d){

  struct tm t;
  t.tm_year  = 104; // 2004 - 1900
  t.tm_mon   = m-1;
  t.tm_mday  = d;
  t.tm_hour  = 0;           
  t.tm_min   = 0;               
  t.tm_sec   = 0;               
  t.tm_isdst = -1;
  
  if (mktime(&t) == -1)
	return (-1);
  return(t.tm_wday);
}

int main(){
  int m,d;
  static string w[] = {"Sunday","Monday","Tuesday","Wednesday",
					   "Thursday","Friday","Saturday"};
  while(cin >> m >> d,m||d){
  cout << w[week(m,d)] << endl;
  }
  return 0;
}

Measured memory_bytes: 1292
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pii pair<long long,long long>
#define endl '\n'
#define N 300001
int mod=1000000007;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
vector<int> parent(N),sz(N),indegree(N),vis(N); char st[N];
vector<int> adj[N];
int modexp(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        
        return modexp((x*x)%M,n/2,M);
    else                             
        return (x*modexp((x*x)%M,(n-1)/2,M))%M;
}
void make_set(int s)
{
    parent[s]=s;
    sz[s]=1;
}
int find_parent(int p)
{
    if(p==parent[p])
    return p;
    return parent[p]=find_parent(parent[p]);
}
void union_set(int a,int b)
{
    a=find_parent(a);b=find_parent(b);
    if(a!=b)
    {
        if(a<b)
        swap(a,b);
        parent[b]=parent[a];
        sz[a]+=sz[b];
    }
}
bool comp(const pii a, const pii b)
{
    if(a.se==b.se)
    return a.fi<b.fi;
    return a.se<b.se;
}
vector<vector<int>> dp,v;
void solve()
{
    string s; cin>>s;
    if(s[1]=='R')
    cout<<"ABC";
    else
    cout<<"ARC";
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test; test=1;
    while(test--)
    {
        solve();
    }
    return 0;
}


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

int main() {
  //n時間、a*n円、b円
  int n, a, b;
  cin >> n >> a >> b;
  
  if (n * a <= b) {
    cout << n * a << endl;
  }else{
    cout << b << endl;
  }
}

Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

const long long MOD = 1000000007;


ll gcd (ll a, ll b){ return b == 0? a : gcd(b, a % b); }
ll lcm (ll a, ll b){ return a * (b / gcd(a, b));}

ll extgcd(ll a, ll b, ll &x, ll &y){
    if(b == 0){
        x = 1; y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
    return d;
}

//* calculate a^-1 mod m
ll mod_inverse(ll a, ll m){
    ll x, y;
    extgcd(a, m, x, y);
    return(m + x%m) % m;
}

//* calculate n! % p in O(n)
ll mod_fact_simple(ll n, ll p){
    ll res = 1;
    if(n == 0) return res;
    for(ll i=1; i<= n; i++){
        res *= i;
        res = res % p;
    }
    return res;
}
//* calculate C(n, k)%p in O(n)
ll mod_comb(ll n, ll k, ll p){
    if(n < 0 || k < 0 || n < k) return 0;
    ll a1 = mod_fact_simple(n, p);
    ll a2 = mod_fact_simple(k, p);
    ll a3 = mod_fact_simple(n-k, p);
    return (a1 * mod_inverse(a2 * a3 % p, p)) % p;
}

vll genCombList(ll K, ll N){
    ll len = N-K+1;
    vll res(len, 1);
    for(ll i=1; i< len; i++){
        res[i] = (res[i-1]* (i+K) ) % MOD;
        ll tmp = mod_inverse(i%MOD, MOD);
        res[i] = (res[i] * tmp) %MOD;
    }
    return res;
}

void solve(long long N, long long K, std::vector<long long> A){
    vll comb_list = genCombList(K-1, N-1);
    ll res = 0;
    sort(ALL(A));
    for(ll i= K-1; i<= N-1; i++){
        ll tmp = (A[i]* comb_list[i - (K-1)]) % MOD;
        res = (res + tmp) % MOD;
    }

    REP(i, N){
        A[i] = -A[i];
    }
    sort(ALL(A));
    for(ll i= K-1; i<= N-1; i++){
        ll tmp = (A[i]* comb_list[i - (K-1)]) % MOD;
        res = (res + tmp) % MOD;
    }
    cout << res << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 1408
n=int(input())
a=list(map(int,input().split()))
dig=1
ans=0
m=max(a)
k=0
mod=10**9+7
while m>>k >0:
    k+=1
k=max(0,k)
for j in range(k):
    cnt=0
    for i in range(n):
        if a[i]>>j & 1:
            cnt+=1
    cnt=cnt*(n-cnt)%mod
    ans=(ans+dig*cnt%mod)%mod
    dig=dig*2%mod
print(ans)

Measured memory_bytes: 122808
/* x の条件を満たすモノの中では、
y 座標の制約をできるだけギリギリ満たしているものを選ぶ方が良い。
*/

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

int main(){
    int n;
    cin >> n;
    pair<int, int> red[n], blue[n];
    for (int i = 0; i < n; i++){
        cin >> red[i].first >> red[i].second;
    }
    for (int i = 0; i < n; i++){
        cin >> blue[i].first >> blue[i].second;
    }

    sort(red, red + n);
    sort(blue, blue + n);

    ll ans = 0;
    bool used[n];
    fill(used, used + n, false);
    for (int i = 0; i < n; i++){
        int maxy = -1;
        int index = -1;
        int j = 0;
        while (blue[i].first > red[j].first){
            if (blue[i].second > red[j].second && !used[j]){
                if (red[j].second > maxy){
                    maxy = red[j].second;
                    index = j;
                }
            }

            j++;
        }
        if (index != -1){
            ans++;
            used[index] = true;
        }
    }

    cout << ans << endl;    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  vector<char>vec(4);
  for(ll i=0;i<4;i++){
    cin>>vec.at(i);
  }
  sort(vec.begin(),vec.end());
  if(vec.at(0)==vec.at(1)&&vec.at(2)==vec.at(3)&&vec.at(1)!=vec.at(2)){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;

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


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

#define INF 1e9
using namespace std;

int main() {

    int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;

    int vx1 = x2 - x1;
    int vy1 = y2 - y1;

    cout << x2 - vy1 << " " << y2 + vx1 << " " << x2 - vy1 - vx1 << " " << y2 + vx1 - vy1 << endl;
}

Measured memory_bytes: 256
while z=gets
 m=z.chomp.to_i
 n=1000-m
 if m!=0
  a=n/500
  b=(n%500)/100
  c=((n%500)%100)/50
  d=(((n%500)%100)%50)/10
  e=((((n%500)%100)%50)%10)/5
  f=(((((n%500)%100)%50)%10)%5)/1
  sum=a+b+c+d+e+f
  puts sum.to_s
 else
 end
end

Measured memory_bytes: 6096
#include<bits/stdc++.h>
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
#define fo(i, x, y)   for (__typeof(x) i = x; i < y; ++i)
#define fr(i, x, y)   for (__typeof(x) i = x; i > y; i--)
#define vdp(n,x) vector<vector<ll>>dp(n+1,vector<ll>(x+1));
const ll mod=1000000007;
const ll AM=2e5+5;
using namespace std;
int main()
{
    fast;
    string s,t; cin>>s>>t;
    ll n1=s.size(),n2=t.size();
    vdp(n1+1,n2+1);
    for(ll i=0;i<=n1;i++)
    {
    	for(ll j=0;j<=n2;j++)
    	{
    		if(i==0 || j==0)
    			dp[i][j]=0;
    		else if(s[i-1]==t[j-1])
    			dp[i][j]=dp[i-1][j-1]+1;
    		else
    			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    		//cout<<dp[i][j]<<" ";
    	}
    	//cout<<endl;
    }
    ll ls=dp[n1][n2],l;
    l=ls;
    char lcs[ls+1];
    lcs[ls]='\0';
    while(n1>0 && n2>0)
    {
    	if(s[n1-1]==t[n2-1])
    	{
    		lcs[ls-1]=s[n1-1];
    		n1--; n2--;
    		ls--;
    	}
    	else if(dp[n1-1][n2]>dp[n1][n2-1])
    		n1--;
    	else
    		n2--;
    }
    //cout<<ls<<endl;
    //fo(i,2,l) cout<<lcs[i];
    cout<<lcs;
}

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

using namespace std;

typedef double D;
typedef long long int LL;

#define st first
#define nd second
#define pb push_back
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 1e5 + 7;
const int T = 1 << 18;

const int MX = 1e9 + 7;
const LL INF = 1e18 + 9LL;

int n;
int in[N];
int ord[N];
int tree[T + T + 7];

void add(int x){
	x += T;
	while(x){
		tree[x]++;
		x >>= 1;
	}
}

int ask(int from, int to){
	int ret = 0;
	from += T, to += T;

	while(from < to){
		if(from & 1)
			ret += tree[from];
		if(!(to & 1))
			ret += tree[to];
		
		from = (from + 1) >> 1;
		to = (to - 1) >> 1;
	}
	
	if(from == to)
		ret += tree[from];
	return ret;
}

LL solve(int v){
	for(int i = 1; i < T + T; ++i)
		tree[i] = 0;

	add(N); 
	LL ret = 0LL; int pref = 0;
	for(int i = 1; i <= n; ++i){
		if(in[i] <= v)
			pref--;
		else
			pref++;

		ret += ask(pref + N + 1, N + N);
		add(pref + N);
	}
	
	return ret;
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i){
		scanf("%d", &in[i]);
		ord[i] = in[i];
	}
	
	int p = 1, k = n;
	long long s = (1LL * n * (n + 1) / 2LL) / 2LL + 1;

	sort(ord + 1, ord + n + 1);
	while(p < k){
		int m = (p + k) >> 1;
		if(solve(ord[m]) < s)
			p = m + 1;
		else
			k = m;
	}
	
	printf("%d\n", ord[p]);
	return 0;
}

Measured memory_bytes: 3072
#include<iostream>
using namespace std;
int main() {
    int a; cin >> a;
    cout << ((a % 1000 % 111 && a / 10 % 111) ? "No" : "Yes") << endl;
    /*
     a % 1000 : 下3桁
     % 111 : すべて同じなら0になる
     a / 10 : 最下位桁なくなる
     ex) 113 / 10 = 11
     どっちか0になればいい
     */
    return 0;
}


Measured memory_bytes: 256
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n, d, pow;
  cin >> n >> d >> pow;
  vector<pll> xx(n);
  for(ll i = 0; i < n; i++) cin >> xx[i].ff >> xx[i].ss;
  sort(all(xx));
  vll a(n), b(n);
  for(ll i = 0; i < n; i++) {a[i] = xx[i].ff; b[i] = xx[i].ss;}
  ll can = 2*d; 
  multiset<pll> st;
  multiset<pll> last;
  for(ll i = 0; i < n; i++) st.insert(xx[i]);
  ll curr = 0;
  ll ans = 0;
  while(!st.empty()) {
  	pll now = *st.begin();
  	ll at = now.ff;
  	if(!last.empty()) {
  		while(1) {
  			if(last.empty()) break;
  			pll gvv = *last.begin();
  			ll tt = gvv.ff;
  			if(at - tt <= can or last.empty()) break;
  			curr-= gvv.ss;
  			last.erase(last.begin());
  		}
  	}
   ll rem = now.second;
   rem = max(0LL, rem - curr);
   ll needed = ((rem + pow - 1))/pow;
   ans+= needed;
   curr+= needed*pow;
   st.erase(st.begin());
   last.insert(mp(at, needed*pow));
  } 
  cout << ans << endl;
  return 0;
} //good night.

Measured memory_bytes: 19072
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  N=N%10;
  N=N%10;
  if (N==2||N==4||N==5||N==7||N==9){
      cout << "hon" << endl;
  }
  else if(N==0||N==1||N==6||N==8){
      cout << "pon" << endl;
  }
  else
    cout << "bon" << endl;
} 

Measured memory_bytes: 3632
#include<bits/stdc++.h> 
using namespace std;
#define ll long long
#define endl "\n"
 
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;
    if(n%1000==0)cout<<"0";
    else
    cout<<1000-n%1000;
    
    return 0; 
} 

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	string s;
	cin>>s;
	bool bad=false;
	REP(i, 3){
		if(s[i]==s[i+1]){
			bad=true;
			break;
		}
	}
	cout<<(bad ? "Bad" : "Good")<<'\n';
	return 0;
}


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

int digit(int x){
  int test = 0;
  while(0<x){
    test+=x%10;
    x/=10;
  }
  return test;
}
int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int ans=0;
  for (int i =1 ; i <=N ; i++) {
    if(A<=digit(i) and digit(i)<=B) {
      ans+=i;
    }
  }
  cout<< ans << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  vector<Int> C(N);
  cin>>C;
  C.insert(C.begin(), -1);
  
  Int dp[200010][2] = {}; //dp[i][0]->左が同じ色、 dp[i][1]->左が異なる色
  map<Int, Int> cnt;
  
  dp[0][1] = 1;
  cnt[-1] = 1;
  for(Int i=1;i<=N;i++){
    
    if(C[i] != C[i-1]) dp[i][0] += cnt[ C[i] ];
    
    if(C[i] == C[i-1]){
      dp[i][0] += dp[i-1][0];
      dp[i][1] += dp[i-1][1];
    }
    else{
      cnt[ C[i] ] = (cnt[ C[i] ] + dp[i-1][1] + dp[i-1][0]) % mod;
      dp[i][1] += dp[i-1][1];
      dp[i][1] += dp[i-1][0];
    }
    
    
    dp[i][0] %= mod;
    dp[i][1] %= mod;
  }

  //for(Int i=0;i<=N;i++)pr(i, dp[i][0]);
  //for(Int i=0;i<=N;i++)pr(i, dp[i][1]);

  //pr(dp[N][0], dp[N][1]);
  Int ans = (dp[N][0] + dp[N][1])%mod;
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 18148
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#define endl '\n'
#define ll long long
#define mod 1000000007

using namespace std;

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	int a, b, c; cin >> a >> b >> c;
	int ret = a + b + c;
	cout << ret - max(a, max(b, c));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n,a;
	cin>>n;
	int num[n];
	for(int i=0;i<n;i++){
		cin>>a;
		num[i]=a;
	}
	for(int j=n-1;j>=0;j--){
		if(j==0){
		  cout<<num[j]<<endl;
		}
		else{
		cout<<num[j]<<" ";
		}
		
	}
	return 0;


}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
using namespace std;
int n,h,a[100010],b[100010],mx,ans;
int main()
{
	cin>>n>>h;
	for(int i=0;i<n;i++)
    cin>>a[i]>>b[i];
	sort(a,a+n,greater<int>());
	mx=a[0];
	sort(b,b+n,greater<int>());
	for(int i=0;i<n;i++) 
	    if(b[i]>mx && h>0) {h-=b[i];ans++;}
	if(h>0) ans+=(h+mx-1)/mx;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
K = int(input())
sumDis = 0
if N == 1:
    x = int(input())
    disA = x * 2
    disB = (K - x) * 2
    sumDis += min(disA, disB)
else:
    x = list(map(int, input().split()))
    for i in range(N):
        disA = x[i] * 2
        disB = (K - x[i]) * 2
        sumDis += min(disA, disB)
print(sumDis)

Measured memory_bytes: 9148
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstdio>
#include<vector>
#include<iostream>
#include<string>
#include<algorithm> 
using namespace std;
int n;
vector<int> v;
bool pri(int i){
	for(int j=2;j*j<=i;j++){
		if(i%j==0){
			return false;
		}
	}
	return true;
}
bool ctf(int k){
	for(int i=0;i<v.size();i++){
		if(v[i]==k){
			return false;
		}
	}
	return true;
}
bool can(int o){
	if(o%5==2){
		return true;
	}
	return false;
}
void f(){
	for(int i=2;i<=55555;i++){
		if(pri(i)){
			if(ctf(i)){
				if(can(i)){
					v.push_back(i);
					break;
				}
			}
		}
	}
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		f();
	}
	for(int i=0;i<n;i++){
		cout<<v[i]<<' ';
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
#define ll long long int 
#define endl '\n'
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
const ll INF=2e18;

typedef vector<ll>   vi;
/*
bool isPrime(ll n){
	if(n<=1)
	return false;
	if(n<=3)
	return true;
	if(n%2==0 || n%3==0)
	return false;
	for(ll i=5;i*i<=n;i=i+6)
	{
		if(n%i==0 || n%(i+2)==0)
		return false;
	}
	return true;
}
*/

void fuck_off_bitch()
{
ll n,sum=0,i;
cin>>n;
for(i=1;i<=n;i++){
	if(i%3==0 || i%5==0 || i%15==0)
	{
		;
	}
	else
	sum+=i;
}
cout<<sum;
}
signed main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);    
    ll t = 1;
    clock_t start, end; 
    start = clock(); 
 
    cout << fixed << setprecision(11);
   /* #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif*/
   //cin>>t;
    while(t--){
        fuck_off_bitch();
    }
 
    end = clock();
    double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    //cerr<<time_taken;
}

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

int main () {
    double n, k;
    cin >> n >> k;
    cout << ceil((n - 1) / (k - 1)) << endl;
}

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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  int X, N;
  cin >> X >> N;

  vector<int> p(N);
  for(int i = 0; i < N; ++i) {
    cin >> p[i];
  }

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

  int plus_minus[] = {-1, 1};
  for(int i = 0; i <= X; ++i) {
    for(int j : plus_minus) {
      int a = X + i * j;
      bool judge = false;
      for(int k : p) {
        if(k == a) {
          judge = true;
        }
      }
      if(!judge) {
        cout << a << endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3600
#include <cmath>

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define MOD 1000000007

typedef long long ll;
typedef std::pair< int, int > P;


int n, k;
std::string s;

int main() {
    std::cin >> n >> k;
    if ( (n+1)/2 >= k) s = "YES";
    else               s = "NO";
    std::cout << s << std::endl;
    return 0;
}

Measured memory_bytes: 256
x,y=map(str,input().strip().split())
d={}
d["A"]=1
d["B"]=2
d["C"]=3
d["D"]=4
d["E"]=5
d["F"]=6
xn=int(d[x])
yn=int(d[y])

if xn > yn:
  print(">")
elif xn < yn:
  print("<")
else:
  print("=")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;

int main(){
  int N; cin>>N;
  vector<int> p,n;
  rep(i,N){
    int a; cin>>a;
    if(a>=0) p.push_back(a);
    else n.push_back(a);
  }
  vector<pair<ll,ll>> ans;
  if(p.size()) sort(p.begin(),p.end());
  if(n.size()) sort(n.begin(),n.end());
  if(n.size()==0){
    ll tmp=p[0];
    for(int i=1;i<p.size()-1;i++){
      ans.push_back({tmp,p[i]});
      tmp-=p[i];
    }
    ans.push_back({p[p.size()-1],tmp});
    cout<<p[p.size()-1]-tmp<<endl;
  }else if(p.size()==0){
    ll tmp=n[n.size()-1];
    for(int i=0;i<n.size()-1;i++){
      ans.push_back({tmp,n[i]});
      tmp-=n[i];
    }
    cout<<tmp<<endl;
  }else{
    ll tmp=n[n.size()-1];
    for(int i=1;i<p.size();i++){
      ans.push_back({tmp,p[i]});
      tmp-=p[i];
    }
    ll tmp2=p[0];
    for(int i=0;i<n.size()-1;i++){
      ans.push_back({tmp2,n[i]});
      tmp2-=n[i];
    }
    ans.push_back({tmp2,tmp});
    cout<<tmp2-tmp<<endl;
  }
  for(auto p:ans){
    cout<<p.first<<" "<<p.second<<endl;
  }
  return 0;
}


Measured memory_bytes: 4208
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n;
int x[MAXN];
pair<int,int> o[MAXN];
ll ret[MAXN];

void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&x[i]);
	REP(i,n) o[i]=MP(-x[i],i); sort(o,o+n);
	REP(i,n) ret[i]=0;

	int at=o[0].second,h=x[at],cnt=1;
	FOR(i,1,n) {
		int to=o[i].second,nh=x[to];
		ret[at]+=(ll)cnt*(h-nh);
		h=nh; if(to<at) at=to; ++cnt;
	}
	ret[at]+=(ll)cnt*h;
	REP(i,n) printf("%lld\n",ret[i]);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 3072
/*
author : seryu
title : ABC165C_"Many Requirements"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

int n, m, q;
vector<int> a, b, c, d;

int dfs(vector<int> arr)
{
	int res = 0;
	if(sz(arr) == n)
	{
		rep(i, q)
		{
			if(arr[b[i]]-arr[a[i]] == c[i])res += d[i];
		}
	}
	else
	{
		int s = 1;
		if(sz(arr))s = arr.back();
		for (int i = s; i <= m; i++)
		{
			auto next = arr;
			next.push_back(i);
			chmax(res,dfs(next));
		}
	}
	return res;
}

void solve()
{
	cin >> n >> m >> q;
	a.resize(q);
	b.resize(q);
	c.resize(q);
	d.resize(q);
	rep(i, q) 
	{
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		a[i]--;b[i]--;
	}
	int ans = dfs(vector<int>());
	cout << ans << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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

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

  if ((A != 1) && (B != 1)) {
    cout << 1 << endl;
  } else if((A != 2) && (B != 2)) {
    cout << 2 << endl;
  } else {
    cout << 3 << endl;
  }

  return 0;
}


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

template <typename T = int64_t>
static constexpr auto inf = static_cast <T> (0x0de0b6b43b9aca00);

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n;
  cin >> n;

  vector <int64_t> a (n);
  for (auto && elem : a) cin >> elem;

  vector <vector <int64_t>> dp (n + 1, vector <int64_t> (n + 1, - inf <>));

  auto f = [&] (auto self, auto i, auto j) {
    if (dp[i][j] > - inf <>) return dp[i][j];
    if (i + 1 == j) return dp[i][j] = a[i];
    return dp[i][j] = max (a[i] - self (self, i + 1, j), a[j - 1] - self (self, i, j - 1));
  };

  cout << f (f, size_t {0}, n) << endl;
}


Measured memory_bytes: 71040