akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <climits>

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

int main() {
	LL n, sum = 0, min = LLONG_MAX;
	cin >> n;
	vector<LL> a(n), x(n);
	REP(i, n) {
		cin >> a[i];
		sum += a[i];
		x[i] = i == 0 ? a[i] : x[i - 1] + a[i];
	}
	REP(i, n - 1) {
		min = min > llabs(sum - x[i] * 2) ? llabs(sum - x[i] * 2) : min;
		//cout << x[i] << " : " << llabs(sum - x[i] * 2) << endl;
	}
	cout << min << endl;
}

Measured memory_bytes: 3328
/**
*    created: 05.07.2020 17:23:01
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (b < a) {a = b; return 1;} return 0;}
const long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    cout << s[0] << s.size() - 2 << s[s.size()-1] << endl;
    return 0;
}

Measured memory_bytes: 3656
import math

a, b, c, x, y = map(int, input().split())

cost_a = min(2*c,a)
cost_b = min(2*c,b)
cost_ab = min(2*c,cost_a+cost_b)
min_xy = min(x,y)

cost_res = 0
if 2*c < a+b:
    cost_res = min_xy * (2*c)
    cost_res += (x-min_xy)*cost_a+(y-min_xy)*cost_b
else:
    cost_res = min_xy * (a+b)
    cost_res += (x-min_xy)*cost_a+(y-min_xy)*cost_b
print(cost_res)

Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
// #include<unordered_map>
#include<set>
// #include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y, idx;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

template<typename T>
T minT(T a, T b) {
	if (a < b) return a;
	else return b;
}

template<typename T>
T maxT(T a, T b) {
	if (a > b) return a;
	else return b;
}

template<typename T>
T absT(T a) {
	if (a < 0) a *= -1;
	return a;
}

template<typename T>
T powT(T a, T x) {
	T res = 1;
	while (x > 0) {
		if (x & 1) res = res*a;
		a = a*a;
		x >>= 1;
	}
	return res;
}

ll StoLL(string str) {
	ll ret = 0, ini = 0;
	if (str[0] == '-') ini = 1;
	repi(i, ini, str.length()) {
		ret *= 10;
		ret += (ll)(str[i] - '0');
	}
	if (ini) ret *= -1;
	return ret;
}

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


int main() {
	ll n, mina = MAX_10p18, maxa = -1;
	rd(n);
	repi(i, 0, n) {
		ll a;
		rd(a);
		mina = min(mina, a);
		maxa = max(maxa, a);
	}
	wrln(maxa - mina);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#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=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    FOR(x,1,9) FOR(y,1,9){
        if (x * y == n){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No"<< endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n,k,p[200000];
    cin>>n>>k;
    int sum=0,ans=0;
    for(int i=0;i<n;i++){
        cin>>p[i];
        sum+=p[i];
        if(i>=k-1){
            ans=max(ans,sum);
            sum-=p[i-k+1];
        }
    }
    cout<<fixed<<setprecision(20)<<(ans+k)/2.<<endl;
}


Measured memory_bytes: 1792
n = int(input())
ans = 0

if n // 100 == 1:
    n -= 100
    ans += 100*9
else:
    n -= 900
    ans+= 100
if n // 10 == 1:
    n -= 10
    ans += 10*9
else:
    n -= 90
    ans += 10
if n // 1 == 1:
    ans += 9
else:
    ans += 1

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
#define MAX 1000100
//#define NIL -1

int main() {
    int n;
    int ans=0;
    vector<bool> num(MAX, true);
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for(int i=0; i<n; i++){
        if(num[a[i]]==false){
            continue;
        }
        if(i<n-1){
            if(a[i]!=a[i+1]){
                ans++;
            }
        }else{
            ans++;
        }
        for(int j=a[i]; j<=a[n-1]; j=j+a[i]){
            num[j]=false;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4300
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
#define PI acos(-1.0)
typedef long long ll;
typedef double db;
typedef vector<ll> ve;
typedef vector< vector <int> >vee;
typedef vector<pair<int,int> >vepa;
typedef set<char>se;
typedef map<ll,ll> mpp;
const int N=1e5+5;
bool f;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
        int a,b,c,d,ans=0;
        cin>>a>>b>>c>>d;
        if(a>=d)
        {
            cout<<d;
            return 0;
        }else if(d>a){
         d=d-a;
         ans+=a;
        }
        if(b>=d){
            cout<<ans;
            return 0;
        }else if(d>b){
          d-=b;
        }
        if(c>=d)
        {
            cout<<ans-d;
           return 0;
        }else if(d>c)
        {
            cout<<ans-c;
            return 0;
        }



go;
}


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

#define ll long long

typedef pair< int, int > ii;
typedef vector< ii > vii;

void solve(){
	int n; cin>>n;
	int ans = 1;
	while(n / 2){
		n /= 2;
		ans *= 2;
	}
	cout<<ans<<endl;
}

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



Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "D:\C++\test_lib_projects\testlib.h"
using namespace std;
#define LL long long
#define ULL unsigned long long
#define INF 0x3f3f3f3f
#define mm(a,b) memset(a,b,sizeof(a))
#define PP puts("*********************");

// 0x3f3f3f3f3f3f3f3f
//0x3f3f3f3f

const int MAXN = 200050, SIZE = 26;
struct SAM {
	int len[MAXN], link[MAXN], next[MAXN][SIZE];
	int total, last;
	inline int newNode(int L) {
		len[++total] = L;
		link[total] = 0;
		for(int i = 0; i < SIZE; ++i) next[total][i] = 0;
		return total;
	}
	inline void Add(int c) {
		int i, p = last, cur = newNode(len[last] + 1);
		for(; p && !next[p][c]; p = link[p]) next[p][c] = cur;
		if(!p) link[cur] = 1;
		else {
			int q = next[p][c];
			if(len[q] == len[p] + 1) link[cur] = q;
			else {//>
				int clone = newNode(len[p] + 1);
				for(i = 0; i < SIZE; ++i) next[clone][i] = next[q][i];
				link[clone] = link[q];
				link[q] = link[cur] = clone;
				for(; p && next[p][c] == q; p = link[p]) next[p][c] = clone;
			}
		}
		last = cur;
	}
	void Init () {
		total = 0;
		last = newNode(0);
	}
} sam;
char str[MAXN];
int num[MAXN],idx[MAXN];
int dp[MAXN];
void solve(int k) {
	int now=1,L=0;
	while(k) {
		for(int j=0; j<SIZE; j++) {
			if(sam.next[now][j]==0)
				continue;
			int x=sam.next[now][j];
			if(k>dp[x])
				k-=dp[x];
			else {
				str[L++]='a'+j;
				now=x;
				k--;
				break;
			}
		}
	}
	str[L]='\0';
	puts(str);
}
int main() {

	int Q,k;
	scanf("%s",str);
	sam.Init();
	for(int i=0; str[i]!='\0'; i++)
		sam.Add(str[i]-'a');
	for(int i=1; i<=sam.total; i++)
		num[i]=0;
	for(int i=1; i<=sam.total; i++)
		num[sam.len[i]]++;
	for(int i=1; i<=sam.total; i++)
		num[i]+=num[i-1];
	for(int i=1; i<=sam.total; i++)
		idx[num[sam.len[i]]--]=i;

	for(int i=sam.total; i>=1; i--) {
		int now=idx[i];
		dp[now]=1;
		for(int j=0; j<SIZE; j++)
			dp[now]+=dp[sam.next[now][j]];
	}

	scanf("%d",&k);
	solve(k);

	return 0;
}

Measured memory_bytes: 4480
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    String S;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.S = sc.next();
    }
    
    //解答処理
    private String solve() {
        String nickName = S.substring(0,3);
        
        return nickName;
    }
    
    //出力
    public void show(String answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35656
use std::io;

fn next_int() -> i64 {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

fn next_vec() -> Vec<i64> {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace().map(|n| n.parse().unwrap()).collect()
}

fn main() {
    let n = next_int();
    let mut max_a = 0;
    let mut min_b = 0;
    for _ in 0..n {
        let v = next_vec();
        max_a = if v[0] > max_a {
            min_b = v[1];
            v[0]
        } else {max_a};
    }
    println!("{:?}", max_a + min_b);
}


Measured memory_bytes: 4352
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}


 main()

{
    fast
    int n;
    int ses=0;
    map<int,int>cnt;
    cin>>n;
    cnt[0]=1;
    int yo=0;
    f(i,1,n)
    {
        int x;
        cin>>x;
        yo+=x;
        ses+=cnt[yo];
        cnt[yo]++;
    }
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 16024
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int N;	cin>>N;
	string S;	cin>>S;
	int cntW=0;
	rep(i,0,N){
		if(S[i]=='W') cntW++;
	}
	reverse(all(S));
	int ans=0;
	rep(i,0,cntW){
		if(S[i]=='R') ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3752
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int a,b;
    char op;
    cin>>a>>op>>b;
    if(op=='+')cout<<a+b<<endl;
    else cout<<a-b<<endl;
    return 0;
}


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

int main(){
	int i;
	string s;
	cin >> s;
	string t;
	for(i = 0; i < s.size(); i++){
		if(s[i] == '0'){
			t.push_back('0');
		}
		else if(s[i] == '1'){
			t.push_back('1');
		}
		else if(t.size() > 0){
			t.pop_back();
		}
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

struct node{
    int id, m, cost;
};

template<typename T>
bool chmin(T &_a, T _b){
    if(_a > _b){
        _a = _b;
        return true;
    }else{
        return false;
    }
}

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

    int n, m;
    cin >> n >> m;

    vector< vector<int> > g(n);
    rep(i, m){
        int u, v;
        cin >> u >> v;
        g[--u].emplace_back(--v);
    }

    int s, t;
    cin >> s >> t;
    --s;
    --t;

    vector< vector<int> > cost(n, vector<int>(3, IINF));
    cost[s][0] = 0;
    queue<node> que;
    que.push({s, 0, 0});
    while(!que.empty()){
        node now = que.front();
        que.pop();
        if(cost[now.id][now.m] < now.cost){
            continue;
        }
        for(auto to : g[now.id]){
            if(chmin(cost[to][(now.m + 1) % 3], now.cost + 1)){
                que.push({to, (now.m + 1) % 3, now.cost + 1});
            }
        }
    }

    if(cost[t][0] < IINF){
        cout << cost[t][0] / 3 << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <string>
#include <tuple>

using namespace std;

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

	if (abs(n - m) >= 2) {
		cout << 0 << endl;
		return 0;
	}

	unsigned long long int count = 1;
	unsigned long long int mod = 1000000007;

	for (int i = 2; i <= n; i++) {
		count = ((count % mod) * i) % mod;
	}
	for (int i = 2; i <= m; i++) {
		count = ((count % mod) * i) % mod;
	}
	if (n == m) {
		count = ((count % mod) * 2) % mod;
	}
	cout << (count % mod) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

char jug(int m, int f, int r);

int main() {
    int m, f, r;
    for (int i=0;;i++) {
        scanf("%d %d %d", &m, &f, &r);
        if (m == -1 && f == -1 && r == -1) {break;}
        printf("%c\n", jug(m, f, r));
    }
    return 0;
}

char jug(int m, int f, int r) {
    if ((m == -1) || (f == -1)) {return 'F';}
    if (m + f >= 80) {return 'A';}
    else if (m + f >= 65) {return 'B';}
    else if (m + f >= 50) {return 'C';}
    else if ((m + f >= 30) && (r >= 50)) {return 'C';}
    else if (m + f >= 30) {return 'D';}
    else {return 'F';}
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll int m,n,a[200000],j,i,c=0,p=0;
cin>>n;
for(i=1;i<=n;i++)
{
    cin>>a[i];
}
p=0;
for(i=1;i<=n;i++)
{
    if((i-p)!=a[i])
    {
        c++; // breaked
        p++;
    }
}
if(c==n)
{
 cout<<"-1"<<endl;
}
else
{
  cout<<c<<endl;
}


return 0;
}


Measured memory_bytes: 1792
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    N,K=pin()
    MAGICNUMBER=17 #2**MAGICNUMBER>10**5>=M
    ans_x3=0
    for i in range(1,N+1):
        temp=i
        coins=0
        for j in range(MAGICNUMBER+1):
            if temp>=K:
                coins=j
                break
            temp*=2
        #print()
        ans_x3+=(2**(0-coins))*(2**30)
    t=int(ans_x3//N)
    print(t/(2**30))   
#%%submit!
resolve()

Measured memory_bytes: 38896
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: usize,
        a: [f64; n],
    }
    println!("{}", 1.0 / a.into_iter().fold(0.0, |sum, x| sum + 1.0 / x));
}


Measured memory_bytes: 4352
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var S = items[0];
            var W = items[1];
            Console.WriteLine((W >= S) ? "unsafe" : "safe");
        }
    }
}


Measured memory_bytes: 28312
N = int(input())
lst_a = list(map(int, input().split()))
lst_color = [0] * 8
cnt_super = 0


for a in lst_a:
    if 1 <= a <= 399:
        lst_color[0] += 1
    elif 400 <= a <= 799:
        lst_color[1] += 1
    elif 800 <= a <= 1199:
        lst_color[2] += 1
    elif 1200 <= a <= 1599:
        lst_color[3] += 1
    elif 1600 <= a <= 1999:
        lst_color[4] += 1
    elif 2000 <= a <= 2399:
        lst_color[5] += 1
    elif 2400 <= a <= 2799:
        lst_color[6] += 1
    elif 2800 <= a <= 3199:
        lst_color[7] += 1
    else:
        cnt_super += 1
cnt_existed = sum(1 for x in lst_color if x!=0)


if cnt_existed == 0:
    ans_min = 1
    ans_max = cnt_super
else:
    ans_min = cnt_existed
    ans_max = cnt_existed + cnt_super


print(ans_min, ans_max)

Measured memory_bytes: 3064
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	char mat[101][101];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
			cin>>mat[i][j];
	}
	queue<int> qi;
	queue<int> qj;
	qi.push(0);
	qj.push(0);
	bool visited[101][101];
	memset(visited,0,sizeof(visited));
	visited[0][0]=1;
	while(!qi.empty())
	{
		int topi=qi.front();
		qi.pop();
		int topj=qj.front();
		qj.pop();
		if(topi+1<n&&topj+1<m)
		{
			if(mat[topi+1][topj]=='.'&&mat[topi][topj+1]=='.')
			{
				cout<<"Impossible"<<endl;
				return 0;
			}
			else if(mat[topi+1][topj]=='#'&&mat[topi][topj+1]=='#')
			{
				cout<<"Impossible"<<endl;
				return 0;
			}
			else if(mat[topi+1][topj]=='#')
			{
				qi.push(topi+1);
				qj.push(topj);
				visited[topi+1][topj]=true;
			}
			else if(mat[topi][topj+1]=='#')
			{
				qi.push(topi);
				qj.push(topj+1);
				visited[topi][topj+1]=true;
			}
		}
		else if(topi+1<n)
		{
			if(mat[topi+1][topj]=='#')
			{
				qi.push(topi+1);
				qj.push(topj);
				visited[topi+1][topj]=true;
			}
			else
			{
				cout<<"Impossible"<<endl;
				return 0;
			}
		}
		else if(topj+1<m)
		{
			if(mat[topi][topj+1]=='#')
			{
				qi.push(topi);
				qj.push(topj+1);
				visited[topi][topj+1]=true;
			}
			else
			{
				cout<<"Impossible"<<endl;
				return 0;
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(mat[i][j]=='#'){
			if(!visited[i][j])
			{
				cout<<"Impossible"<<endl;
				return 0;
			}
			}
		}
	}
	cout<<"Possible"<<endl;
	return 0;
}

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

int n,q;
char s[500005];
int bit[26][500005];

int sum(int op,int pos){
    int res=0;
    while(pos>0){
        res+=bit[op][pos];
        pos-=pos&-pos;
    }
    return res;
}

void add(int op,int pos,int val){
    while(pos<=n){
        bit[op][pos]+=val;
        pos+=pos&-pos;
    }
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    cin>>s+1;
    for(int i=1;i<=n;i++){
        add(s[i]-'a',i,1);
    }
    cin>>q;
    while(q--){
        int typ;
        cin>>typ;
        if(typ==1){
            int pos;char val;
            cin>>pos>>val;
            add(s[pos]-'a',pos,-1);
            s[pos]=val;
            add(val-'a',pos,1);
        }else{
            int l,r,cnt=0;
            cin>>l>>r;
            for(int i=0;i<26;i++){
                if(sum(i,r)-sum(i,l-1)){
                    cnt++;
                    //cerr<<(char)(i+'a')<<' ';
                }
            }
            cout<<cnt<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 51584
import std.stdio;
import std.string;
import std.ascii;
 
void main() {
    string s = readln.chomp;
    writeln( (s.length >= 6 && s.count!(isDigit) >= 1 && s.count!(isUpper) >= 1 && s.count!(isLower) >= 1) ?  "VALID" : "INVALID" );
}

Measured memory_bytes: 1024
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int res = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        res += x >= k;
    }
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  char a[3];
  for(int i = 0;i < 3;i++){
    cin >> a[i];
  }
  if(a[0] != a[1] && a[0] != a[2] && a[1] != a[2]){
    cout << "Yes" << endl;
  }
  else{cout << "No" << endl;}
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#include<stdio.h>
//#include<string.h>
typedef long long ll;
int main()
{
	int n,sum;
	scanf("%d",&n);
	sum=n/2;
	if(sum*2!=n)
	{
		sum++;
	}
	printf("%d",sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
 int n;
  
  int min = 101;
  int max = -101;
  int sum = 0;
  int min_sum = INT_MAX;
  cin>>n;
vector<int> a(n);
  for(int i=0; i<n; i++)
  {
   	cin>>a[i];
    if(a[i] < min)
      min = a[i];
    if(a[i] > max)
      max = a[i];
  }
  for(int i=min; i<=max; i++)
  {
    sum = 0;
    for(int j=0; j<n; j++)
    {
     	sum += pow(i-a[j],2);
      	
    }
	if(sum < min_sum)
          min_sum = sum;
}
cout<<min_sum;
}

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

#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000000
#define ll long long
#define db double
#define str string
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foreq(i,s,e) for (ll i=(s); i<=(e); i++)
#define Forrev(i,s,e) for (ll i=(s); i>=(e); i--)
#define all(v) v.begin(),v.end()
#define vll vector<ll>
#define vs vector<string>

#define mapll map<ll,ll>
#define mapss map<string,string>
#define mapsl map<string,ll>
#define mapls map<ll,string>

#define pll pair<ll,ll>
#define pss pair<string,string>
#define psl pair<ll,string>
#define pls pair<string,ll>

#define minheap priority_queue<ll>
#define maxheap priority_queue<ll,vector<ll> ,greater<ll>>

#define ff first
#define ss second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
const ll mod=1e9 + 7;


ll takemod(ll a) {
    return ((a%mod)+mod)%mod;
}

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

ll fast_exp(ll base, ll expo) {
    ll res=1;
    while(expo>0) {
        if(expo&1) res=(res*base)%mod;
        base=(base*base)%mod;
        expo>>=1;}
    return res;
}

ll modinv(ll a) {
    return takemod(fast_exp(takemod(a), mod-2));
}
vector<pll> graph[100005];
ll n;
ll visited[100005];

void dfs(ll source)
{
    for(pll a: graph[source])
    {
        if(visited[a.ff]==-1)
        {
            if(a.ss%2==0)
            {
                if(visited[source]==0)
                    visited[a.ff]=0;
                else
                    visited[a.ff]=1;
            }
            else
            {
                if(visited[source]==0)
                    visited[a.ff]=1;
                else
                    visited[a.ff]=0;
            }
            dfs(a.ff);
        }
    }
}
signed main() 
{
    fast_cin();
    memset(visited,-1,sizeof(visited));
    cin>>n;
    For(i,0,n-1)
    {
        ll a,b,c;
        cin>>a>>b>>c;
        graph[a].pb(mp(b,c));
        graph[b].pb(mp(a,c));
    }
    visited[1]=0;
    dfs(1);
    For(i,1,n+1)
        cout<<visited[i]<<" ";
    cout<<endl;
    return 0;    
}

Measured memory_bytes: 9472
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	ll n,h;
	cin >> n >> h;
	vector<ll> a(n),b(n);
	REP(i,n){
		cin >> a[i] >> b[i];
	}
	
	sort(a.begin(),a.end(),greater<ll>());
	sort(b.begin(),b.end(),greater<ll>());
	
	ll amax = a[0];
	ll ans = 0;
	REP(i,n){
		if(h<=0 || amax>b[i]) break;
		ans++;
		h -= b[i];
	}
	
	if(h>0){
		ans += (ll)ceil((double)h/amax);
	}
	
	cout << ans << endl;
	
	
	return 0;
}

Measured memory_bytes: 4816
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  int a,b,c;

  cin >> a >> b >> c;
 
  if(a+b==c || a+c==b || b+c==a) {
      cout << "Yes" << endl;
  } else {
      cout << "No" << endl;
  }
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

signed main(){

	lli n,m;
	cin>>n>>m;

	lli flag[100100]={0};
	lli boal[100100]={1};
	REP(i,0,100100){
		flag[i]=0;
		boal[i]=1;
	}
	boal[0]=0;
	flag[1]=1;
	REP(i,0,m){
		lli x,y;
		cin>>x>>y;
		if(flag[x]==1){
			flag[y]=1;
		}
		boal[x]--;
		boal[y]++;
		if(DEBUG)cout<<"x="<<x<<" boalX="<<boal[x]<<" y="<<y<<" boalY="<<boal[y]<<endl;
		if(boal[x]==0){
			flag[x]=0;
		}
	}

	lli sum=0;
	REP(i,0,n+1){
		if(DEBUG)cout<<"i="<<i<<"flag[i]="<<flag[i]<<endl;
		sum+=flag[i];
	}

	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(){
  int MAX = 1010101;
  vector<int> is_prime(MAX, 1);
  is_prime[0] = 0, is_prime[1] = 0;
  for(int i =2; i< MAX; i++){
    if(!is_prime[i]) continue;
    for(int j = i*2; j< MAX; j+=i) is_prime[j] = 0;
  }

  vector<int> pn(MAX,0), sum(MAX+1,0);
  for(int i=0; i<MAX; i++){
    if(is_prime[i] && is_prime[(i+1)/2]){
      pn[i]++;
    }
    sum[i+1]=sum[i]+pn[i];
  }

  int q;
  cin >> q;
  vector<int> l(q), r(q);
  for(int i=0; i<q; i++) cin >> l[i] >> r[i];

  for(int i=0; i<q; i++){
    cout << sum[r[i]]-sum[l[i]]+pn[r[i]] << endl;
  }

  return 0;
}

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

int T[2019],ans;

int main(){
  string s;cin>>s;
  T[0]++;
  for(int i=s.size()-1,keta=1,pre=0;~i;i--){
    ans+=T[(pre+=(s[i]-'0')*keta)%=2019]++;
    (keta*=10)%=2019;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
int N, C, X;
int D[30][30];
int t[3][30];

int main()
{
    cin >> N >> C;
    for(int i = 0; i < C; ++i) {
        for(int j = 0; j < C; ++j) {
            cin >> D[i][j];
        }
    }

    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            cin >> X;
            t[(i+j)%3][X-1]++;
        }
    }

    int res = 1<<30;
    rep(i, C)rep(j, C)if(i != j)rep(k, C)if(i != k && j != k)
    {
        int tt = 0;
        rep(l, C) tt += D[l][i]*t[0][l];
        rep(l, C) tt += D[l][j]*t[1][l];
        rep(l, C) tt += D[l][k]*t[2][l];
        if(tt < res) res = tt;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
n, a, b = list(map(int, input().split()))
ans = 0
for i in range(1, n+1):
    s = str(i)
    total = 0
    for j in range(len(s)):
        total += int(s[j])
    
   # print(str(i)+" total="+str(total))
    if a <= total <= b:
      ans += i

print(ans)

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

int main(){
  string S;
  
  cin >> S;
  int N = S.size();
  
  for(int i=0; i<N; i++){
    if(i%2==0){
      if(S[i]!='R' and S[i]!='U' and S[i]!='D'){
        cout << "No" << endl;
        return 0;
      }
    }else{
      if(S[i]!='L' and S[i]!='U' and S[i]!='D'){
        cout << "No" << endl;
        return 0;
      }
    }
  
  }
  
  cout << "Yes" << endl;

  return 0;
}


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

int main() {
  int N, A, counter, answer;
  answer = 50;
  cin >> N;
  for (int i = 0; i < N; i++) {
    counter = 0;
    cin >> A;
    while (true) {
      if (A%2==1) {
        break;
      }
      else {
        A /= 2;
        counter++;
      }
    }
    if (counter < answer) {
      answer = counter;
    }
  }
  cout << answer << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	int N, K, X, Y;

	cin >> N >> K >> X >> Y;

	int ans = 0;

	for (int i = 1; i <= N; ++i) {
		if (i <= K) ans += X;
		else ans += Y;
	}

	cout << ans << endl;

	
}

Measured memory_bytes: 3628
# 長さ N の整数列 A が与えられます。 
# A の（添字の）異なる 2 要素の差の絶対値の最大値を求めてください。

# 入力は以下の形式で標準入力から与えられる。
# N
# A1 A2... AN
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i).sort

# A の（添字の）異なる 2 要素の差の絶対値の最大値を出力せよ。
p (a.last - a.first).abs

Measured memory_bytes: 1788
import java.util.Arrays;
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        try {
            String s = scanner.next();
            String s2 = s + s;
            String p = scanner.next();
            if (s2.contains(p)){
                System.out.println("Yes");
            }else {
                System.out.println("No");
            }
           /* for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i)==p.charAt(i)){

                }
            }*/

        } catch (Exception e) {

        } finally {

        }

    }

}




Measured memory_bytes: 26264
#include <bits/stdc++.h>
using namespace std;
int n, edge[5][5], num[5];
int main()
{
	n = 4;
	for (int i = 1; i < n; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		edge[a][b] = edge[b][a] = 1;
	}
	iota(num, num+n, 1);
	do
	{
		bool works = 1;
		for (int i = 0; i < n-1; i++)
		{
			if (!edge[num[i]][num[i+1]]) works = 0;
		}
		if (works)
		{
			printf("YES\n");
			exit(0);
		}
	}
	while (next_permutation(num, num+n));
	printf("NO\n");
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<set>
using namespace std;
#define MAXN 100000
int N, Dp[MAXN + 5];
int main() {
	cin >> N;
	fill(Dp, Dp + N + 1, MAXN);
	Dp[0] = 0;
	for (int i = 0; i <= N; i++) {
		Dp[i + 1] = min(Dp[i + 1], Dp[i] + 1);
		for (int j = 6; i + j <= N; j *= 6)
			Dp[i + j] = min(Dp[i + j], Dp[i] + 1);
		for (int j = 9; i + j <= N; j *= 9)
			Dp[i + j] = min(Dp[i + j], Dp[i] + 1);
	}
	cout << Dp[N];
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9)+7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
  vector< pair<ll, ll> > p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    p.push_back(make_pair(i, 0));
    while ((n % i) == 0) {
      n /= i;
      p[i].second += 1;
    }
    p.push_back(make_pair(n, 0));
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
	ll b = MOD, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b;
		swap(a, b);
		u -= t * v;
		swap(u, v);
	}
	u %= MOD;
	if (u < 0) { u += MOD; }
	return u;
}
// 順列
ll permutation(const ll n, const ll m) {
	ll result = 1;
	for (ll i = n; i > n - m; i--) { result = (result * i) % MOD; }
	return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
	if (x == 0) return 1;
	ll res = repeat_square(n, x/2);
	res = res * res % MOD;
	if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ
ll combination(const ll n, const ll a) {
	ll x = 1, y = 1;
  for(ll i = 0; i < a; i++){
    x = x * (n-i) % MOD;
    y = y * (i+1) % MOD;
  }
  return x * repeat_square(y, MOD-2) % MOD;
}

int main() {
  ll X, Y;
  cin >> X >> Y;

  ll ans = 0;
  ll x = X;
  while(x <= Y) {
    ans++;
    x *= 2;
    // cout << x << endl;
    if (x > Y) break;
  }

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


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

int main(){
	int a,b;
	char op;
	for(int i=1;i>=1;i++){
		cin>> a >> op >> b ;
		if((op=='?')){
		    break;
		}
		if(op=='+'){
			cout<< a+b <<endl;
		}
		if(op=='-'){
			cout<< a-b <<endl;
		}	
		if(op=='*'){
			cout<< a*b <<endl;
		}
		if(op=='/'){
			cout<< a/b <<endl;
		}
	}
	return 0;
}


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

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli power(lli x, lli y){
    lli res = 1;
    x = x ;
    while (y > 0) {
        if (y & 1)
            res = (res*x) ;
        y = y>>1;
        x = (x*x);
    }
    return res;
}
lli solve(){
	lli n, k;
	cin>>n>>k;
	vll A(n);
	loop(i, 0, n)	cin>>A[i];
	lli M = 1e9 + 7;
	sort(A.begin(), A.end());
	vector<vector<pii> > dp(n, vector<pii> (k+1, {0, 0}));
	loop(i, 0, n)	dp[i][0] = {1, 1};
	loop(i, 1, k+1){
		if(i <= A[0])
			dp[0][i] = {1, dp[0][i-1].se + 1};
		else
			dp[0][i] = {0, dp[0][i-1].se};
	}
	loop(i, 1, n){
		loop(j, 1, k+1){
			if(j <= A[i])
				dp[i][j] = {dp[i-1][j].se % M, ((dp[i][j-1].se + dp[i-1][j].se)%M + M)%M};
			else	
				dp[i][j] = {((dp[i-1][j].se - dp[i-1][j - A[i] - 1].se)%M + M)%M, ((dp[i][j-1].se + dp[i-1][j].se - dp[i-1][j - A[i] - 1].se)%M + M)%M};
		}
	}
//	loop(i, 0, n){
//		loop(j, 0, k+1)
//			cout<<dp[i][j].fi<<" ";
//		cout<<"\n";
//	}
	cout<<dp[n-1][k].fi<<"\n";
	return 0;
	
}
int main(){
	fastio;
	lli t;
//	cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}

Measured memory_bytes: 158208
def minorChange(s, t):
    changes = abs(len(s) - len(t))
    i = 0
    while i < len(s) and i < len(t):
        if s[i] != t[i]:
            changes += 1
        i += 1
    return changes

def start():
    S = input()
    T = input()
    changes = minorChange(S, T)
    print(changes, end="")

start()

Measured memory_bytes: 9424
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  int n;
  int ans = 0;
  cin >> n;
  vector<int>A(n);
  vector<int>B(n);
  vector<int>C(n-1);

  for(int i=0;i<n;i++) cin >> A[i],A[i]--;
  for(int i=0;i<n;i++) cin >> B[i];
  for(int i=0;i<n-1;i++) cin >> C[i];

  for(int i=0;i<n;i++){
    ans += B[A[i]];
    if(i!=0 && A[i]==(A[i-1]+1)) ans += C[A[i-1]];
  }
  cout<< ans <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  ll N,T;
  cin >> N >> T;
  v(ll) t(N);
  ll sum = T * N;
  ll last = -LINF;
  ll dup = 0;
  rep(i,N) {
    cin >> t[i];
    if(last > t[i]) {
      dup += last - t[i];
    }
    last = t[i]+T;
  }
  cout << sum - dup << endl;
  
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  string s;
  cin >> s;
  bool ans = true;
  sort(all(s));
  rep(i,sz(s)-1){
    if(s[i]==s[i+1]){
      ans = false;
    }
  }
  if(ans){
    print("yes");
  }
  else{
    print("no");
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];
int f[1000000];

void solve() {
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}




int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
   /* int t;
    cin>>t;
    while(t--)
    {
      solve();
    } */
    solve();
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}


void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}


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

#define ll long
#define ld double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define setpr(pp) fixed<<setprecision(pp)
#define FOR(I,N) for(I=0;I<N;++I)
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod	%1000000007
#define pi 3.141592653
#define NL -5000000

vector<ll> adj[100005];
bool vis[100005];
ll dpw[100005];
ll dpb[100005];

void DFS(ll x)
{
	vis[x]=1;
	ll i,n = adj[x].size();
	dpb[x] = dpw[x] = 1;
	for(auto y:adj[x])
	{
		if(vis[y]==0)
		{
			DFS(y);
			dpb[x] = (dpb[x] * dpw[y] )mod;
			dpw[x] = ( dpw[x] * (dpw[y] + dpb[y])mod )mod;
		}
	}
}

int main()
{	IOS;
	ll n,i,j,x,y;
	cin>>n;
	FOR(i,n-1)
	{
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	MS0(vis);
	DFS(1);
	cout<<(dpb[1]+dpw[1])mod;
}


Measured memory_bytes: 11520