akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 2e9;

int main() {
    string S;
    cin >> S;
    for (int i = 0; i < S.length() - 1; i++) {
        if (S[i] == S[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
        if (i >= 1) {
            if (S[i - 1] == S[i + 1]) {
                cout << i << " " << i + 2 << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1" << endl;
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    set<string> S;
    unordered_map<string, int> cnt;
    int MAX = 0;
    for(int i=0;i<N;i++) {
        string s;
        cin >> s;
        cnt[s]++;
        MAX=max(MAX, cnt[s]);
        S.insert(s);
    }

    vector<string> V;
    for(auto itr = S.begin();itr != S.end();itr++){
        if (cnt[*itr] == MAX) V.push_back(*itr);
    }
    sort(V.begin(), V.end());
    for(auto & s:V) cout << s << "\n";
}

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

int main() {
  int n;cin>>n;
  long double ans=0;
  long double u;
  string s;
  for(int i=0;i<n;++i){
    cin>>u>>s;
    if(s=="JPY") ans += u;
    else ans += u * 380000.0;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};module.exports=I;

function main(input) {
  const o = new I(input, String);

  const b = o.a();
  console.log({
    A: "T",
    C: "G",
    G: "C",
    T: "A"
  }[b]);

}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll A, B, N;
	cin >> A >> B >> N;
	ll x;
	if (N >= B)
		x = B - 1;
	else
		x = N;

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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())

int main() {
    int n;
    cin >> n;
    int F[50];
    F[0] = F[1] = 1;
    for (int i = 2; i <= n; i++) {
        F[i] = F[i - 1] + F[i - 2];
    }
    cout << F[n] << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};

int main(){
  int N,M;  cin>>N>>M;
  vector<vector<int> > v(100000);
  vector<int> ans(N, -1);
  rep(i,0,M){
    int x,y;  cin>>x>>y;
    --x;  --y;
    v[x].pb(y);
    v[y].pb(x);
  }
  if(v[0].size()==0){
    cout<<"No"<<endl;
    return 0;
  }
  queue<int> que;
  que.push(0);
  while(que.size()){
    int now=que.front();
    que.pop();

    for(auto j : v[now]){
      if(ans[j]>=0) continue;
      ans[j] = now;
      que.push(j);
    }
  }
  cout<<"Yes"<<endl;
  for(int i=1 ; i<N ; i++){
    cout<<ans[i]+1<<endl;
  }
  return 0;
}


Measured memory_bytes: 10116
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const int INF=1e9;
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(int argc, char const *argv[]) {
  string s;
  std::cin >> s;
  int ans=0;
  int res=0;
  for(int i=0; i<s.size(); i++){

    if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
      res++;
      ans=max(ans,res);
    }
    else res=0;
  }
  std::cout << ans << '\n';



  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int t,answer;
  bool a=false;
  cin>>t;
  for(int i=0; i<11;i++){
    if(t==1000*i) a=true;
    else if(t>1000*i) answer=1000*(i+1)-t;
  }
  if(a) cout<<0<<endl;
  else cout<<answer<<endl;
}


Measured memory_bytes: 3616
import sys
input = sys.stdin.readline
n = int(input())
ab = [list(map(int,input().split())) for i in range(n-1)]
graph = [[] for i in range(n+1)]
deg = [0]*(n+1)
for a,b in ab:
  graph[a].append(b)
  graph[b].append(a)
  deg[a] += 1
  deg[b] += 1
deg[1] += 1
dp = [[] for i in range(n+1)]
mark = [0]*(n+1)
stack = []
for i in range(1,n+1):
  if deg[i] == 1:
    stack.append(i)
    mark[i] = 1
while stack:
  x = stack.pop()
  if dp[x]:
    t = 0
    for z in dp[x]:
      t ^= z
    mark[x] = t+1
  if x == 1:
    break
  for y in graph[x]:
    if deg[y] > 1:
      dp[y].append(mark[x])
      deg[y] -= 1
      if deg[y] == 1:
        stack.append(y)
if mark[1] == 1:
  print("Bob")
else:
  print("Alice")

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

int main(){
    const int N = pow(10,5) + 5;
    long int x[N] = {},ans,n,k;

    cin >> n >> k;

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

    long int L,R;

    for(int i = 0; i + k - 1 < n; ++i){
        L = abs(x[i]) + abs(x[i] - x[i + k - 1]);
        R = abs(x[i + k - 1]) + abs(x[i] - x[i + k - 1]);
        if(i == 0){
            ans = min(R,L);
        }else{
            ans = min(ans,min(L,R));
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
ll test[12345678], res[12345678];
signed main() {
	map<ll, ll> cost;
	ll n, m, a, b, c, x, cnt = 0, ans = 0; string s, t, u;
	cin >> n; vector<ll> v(n);
	for (int h = 0; h < n; h++) {
		cin >> v[h];
	}
	if (n % 2 == 0) {
		for (int h = n - 1; h >= 0; h -= 2) {
			if (h == n - 1) { cout << v[h]; }
			else { cout << ' ' << v[h]; }
		}
		for (int h = 0; h < n; h += 2) {
			cout << ' ' << v[h];
		}
		cout << endl;
	}
	else {
		for (int h = n - 1; h >= 0; h -= 2) {
			if (h == n - 1) { cout << v[h]; }
			else { cout << ' ' << v[h]; }
		}
		for (int h = 1; h < n; h += 2) {
			cout << ' ' << v[h];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k; cin >> n >> k;
    vector<ll> a(n);
    ll res = 0;
    rep(i, n){
        ll buf; cin >> buf;
        a[buf]++;
    }
    sort(all(a), greater<ll>());
    rep(i, k){
        res += a[i];
    }
    res = n - res;
    cout << res;
    cout << endl;
    return 0;
}



Measured memory_bytes: 1792
# D - Preparing Boxes

# 先頭にダミーを加える

N = int(input())
a = [-1] + list(map(int, input().split()))

box = [-1] + [0]*N

for idx in reversed(range(1,N+1)):
    if sum([box[i] for i in range(idx, N+1, idx)]) % 2 == a[idx]:
        box[idx] = 0
    else:
        box[idx] = 1

print(sum(box[1:]))
for idx in range(N+1):
    if box[idx] == 1:
        print(idx)

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

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

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int H,W,M;
    cin >> H >> W >> M;
    set<pair<int,int>> S;

    vector<vector<int>> Aw(W,vector<int> (2,0));
    vector<vector<int>> Ah(H,vector<int> (2,0));
    rep(i,W) {
        Aw[i][1] = i;
    }
    rep(i,H) {
        Ah[i][1] = i;
    }

    rep(i,M) {
        int h,w;
        cin >> h >> w;
        h--,w--;
        S.insert(make_pair(h,w));
        Ah[h][0]++;
        Aw[w][0]++;
    }
    sort(Aw.begin(),Aw.end());
    sort(Ah.begin(),Ah.end());
    ll ans = 0;

    ll wnum = Aw.back()[0];
    ll wint = Aw.back()[1];
    vector<int> wmax;
    int idx = W-1;
    while(Aw[idx][0]==wnum) {
        wmax.push_back(Aw[idx][1]);
        idx--;
        if (idx<0) break;
    }
    
    ll hnum = Ah.back()[0];
    ll hint = Ah.back()[1];
    vector<int> hmax;
    idx = H-1;
    while(Ah[idx][0]==hnum) {
        hmax.push_back(Ah[idx][1]);
        idx--;
        if (idx<0) break;
    }

    int cnt = 0;
    rep(h,hmax.size()) {
        rep(w,wmax.size()) {
            ll tmp = hnum + wnum;
            //cout << hmax[h]+1 << " " << wmax[w]+1 << endl;
            if(S.count(make_pair(hmax[h],wmax[w]))) {
                tmp--;
            }
            ans = max(ans,tmp);
            cnt++;
        }   if (cnt>1000000) break;
        if (cnt>1000000) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 54328
#include <stdio.h>
#include<math.h>
int main(void){
    // Your code here!
    int a, b;
    
    scanf("%d %d", &a,&b);
    
    int a2=(int)ceil((double)a/(double)0.08);
    int b2=(int)ceil((double)b/(double)0.10);

    int a3=(int)ceil((double)(a+1)/(double)0.08);
    int b3=(int)ceil((double)(b+1)/(double)0.10);
    
    //printf("%d %d %d %d\n", a2,b2,a3,b3);
    if(b2<=a2 && a2<b3) printf("%d", a2);
    else if(a2<=b2 && b2<a3) printf("%d", b2);
    else printf("-1");
}


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

const int MAXK = 1e5 + 10;
const int MAXN = 1e3 + 10;

int A[MAXN],dp[MAXK],N,K;

int solve(int k)
{
	if(dp[k] != -1) return dp[k];
	if(k == 0) return dp[k] = 0;
	int ans = 0;
	for(int i = 1;i<=N;i++){
		if(A[i] > k) continue;
		if(solve(k - A[i]) == 0){
			ans = 1;
			break;
		}
	}
	return dp[k] = ans;
}

int main()
{
	memset(dp,-1,sizeof(dp));
	cin >> N >> K;
	for(int i = 1;i<=N;i++){
		cin >> A[i];
	}
	if(solve(K)) printf("First\n");
	else printf("Second\n");
}

Measured memory_bytes: 7080
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n:usize,
        l:[isize; n]
    }

    let mut ans = 0;

    for i in 0..n {
        for j in i + 1..n {
            for k in j + 1..n {
                let l1 = l[i];
                let l2 = l[j];
                let l3 = l[k];
                if l1 == l2 || l2 == l3 || l3 == l1 {
                    continue;
                }
                if l1 + l2 <= l3 || l2 + l3 <= l1 || l3 + l1 <= l2 {
                    continue;
                }

                ans += 1;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2172
#include <bits/stdc++.h>
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
int main(){
    int a,b,c,x,y; cin>>a>>b>>c>>x>>y;
    int ans=2e9;
    for (int i=0; i<=max(x,y); ++i)
	ans=min(ans,max((x-i),0)*a+max((y-i),0)*b+2*i*c);
    cout<<ans;
    return 0;
}


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

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

    vector<long long int> a(n, 0), b(0);

    for(int i=0; i<n; i++){
        cin >> num;
        if(i==0) a[i] = num;
        else a[i] = a[i-1] + num;
    }

    long long int ans = 1e11;
    for(int i=0; i<n-1; i++){
        ans = min(ans, abs(a[i] - (a[n-1] - a[i])));
    }

    /*cout << num1 << " " << num2 << " " << ave << " " << min << endl;*/
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll,ll>
#define pi 3.14
#define maxn 10009
#define eps (long double)1e-9 
#define MOD 1000000007
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    map<string,ll> cont;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        cont[s]++;
    }
    ll ans=0;
    for(auto e: cont){
        ans+=(e.second*(e.second-1))/2;
    }
    cout<<ans<<endl;
    return 0;   
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } //charを整数に
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];

int main()
{
    int N, M;
    cin >> N >> M;
    set<int> start;
    set<int> end;
    rep(i,M){
        int one=0;
        int n=0;
        cin >> one >> n;
        if(one==1 && n!=N){
            start.insert(n);
        }
        else if(one!=1 && n==N){
            end.insert(one);
        }
    }
    stl_rep(i,start){
        int tmp=*(i);
        if(end.count(tmp)){
            cout << "POSSIBLE" <<endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> vec(N,0);

    for (int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        vec.at(a-1)++;
        vec.at(b-1)++;
    }
    
    for(int i=0; i<N; i++){
        cout << vec.at(i) << endl;
    }
}

Measured memory_bytes: 256
from itertools import combinations
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for a, b in combinations(X, 2):
    dist = 0
    for i in range(D):
        dist += (a[i] - b[i]) ** 2
    if dist ** 0.5 % 1 == 0:
        cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, M, X;
  int C[12], A[12][12];

  scanf("%d%d%d", &N, &M, &X);

  for (int i = 0; i < N; i++) {
    scanf("%d", C + i);
    for (int j = 0; j < M; j++) {
      scanf("%d", A[i] + j);
    }
  }

  int ans = INF;

  for (int i = 0; i < (1 << N); i++) {
    int sum[12] = {}, price = 0;

    for (int j = 0; j < N; j++) {
      if (!(i & (1 << j))) continue;

      for (int k = 0; k < M; k++)
        sum[k] += A[j][k];

      price += C[j];
    }

    bool ok = true;
    for (int j = 0; j < M; j++) ok &= sum[j] >= X;

    if (ok) ans = min(ans, price);
  }

  if (ans == INF) ans = -1;

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 3728
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        System.out.println((int)cubed(x));
    }
    
    public static double cubed(int x) {
        return Math.pow(x, 3);
    }
}


Measured memory_bytes: 26240
R,C,K = map(int,input().split()) #行、列、個数
G = [[0]*C for _ in range(R)] #G[i][j]でi行目のj番目にある価値
for i in range(K):
  a,b,v = map(int,input().split())
  a-=1;b-=1 #0index
  G[a][b] = v
#print(G)

dp = [[0]*4 for _ in range(C+1)]
#dp[j][k]ある行において、j個目まで見て、その行でk個拾っている
for i in range(R):
  p = [[0]*4 for _ in range(C+1)] #pが前の行、dpが今の行
  p,dp = dp,p
  for j in range(C):
    #print(j+1,dp)
    for k in range(4):
      if k == 0: #その行で一個も取っていなければ上の行から来るだけ
        dp[j+1][k] = max(p[j+1])
      elif k == 1: #一個目をとるということは横からきて取るか、上から来て取るか
        if G[i][j] == 0: #そこにない場合は横から
          dp[j+1][k] = dp[j][k]
        else: #ある場合は横からくるか上から来て一個取るか
          dp[j+1][k] = max(dp[j][k],max(p[j+1])+G[i][j])
      else: #二個以上の場合には上からは来れない。
        if G[i][j] == 0: #そこになければ横からくるだけ
          dp[j+1][k] = dp[j][k]
        else: #あればとったほうがよいか比較
          dp[j+1][k] = max(dp[j][k],dp[j][k-1]+G[i][j])
  #print(p,dp)

ans = max(dp[C])
print(ans)

Measured memory_bytes: 224260
import queue
H,W=map(int,input().split())
s=[list(input()) for i in range(H)]
dist=[[-1 for i in range(W)] for i in range(H)]
q=queue.Queue()
q.put((0,0))
dist[0][0]=0
dx=[-1,1,0,0]
dy=[0,0,1,-1]
while(not(q.empty())):
    r=q.get()
    x,y=r
    for k in range(4):
        nx=x+dx[k]
        ny=y+dy[k]
        if 0<=nx<H and 0<=ny<W:
            if dist[nx][ny]!=-1:
                continue
            if s[nx][ny]=="#":
                continue
            dist[nx][ny]=dist[x][y]+1
            q.put((nx,ny))
ans=dist[H-1][W-1]
sharp=0
for i in range(H):
    for j in range(W):
        if s[i][j]=="#":
            sharp+=1
if ans==-1:
    print(ans)
else:
    print(H*W-ans-1-sharp)


Measured memory_bytes: 3952
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;

const ll mod197 = 1000000007LL;
const ll INF = 200LL * 200 * 100000 + 10;

const double PI11 = 3.14159265359;


int main() {

	char c[4];

	for (int i = 0; i < 4; i++) {
		cin >> c[i];
		c[i] -= '0';
	}

	for (int i = 0; i < 8; i++) {
		int t = c[0];

		for (int j = 0; j < 3; j++) {
			if (i & (1 << j)) {
				t -= c[j + 1];
			}
			else {
				t += c[j + 1];
			}
		}

		if (t == 7) {

			cout << (int)c[0];

			for (int j = 0; j < 3; j++) {
				if (i & (1 << j)) {
					cout  << "-" << (int)c[j + 1];
				}
				else {
					cout << "+" << (int)c[j + 1];
				}
			}
			cout << "=7" << endl;

			return 0;
		}

	}

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#define Max 1000000
#define maxi 100000000000
using namespace std;
int total = 0;
int A[Max], B[Max];

void mergesort(int A[Max], int left, int right)
{
	int n = right - left;
	int mid = (left + right) / 2;
	int n1 = mid - left;
	int n2 = right - mid;
	int a[Max], b[Max];
	for (int i = 0; i < n1; i++)
	{
		a[i] = A[left + i];
	}
	for (int i = 0; i < n2; i++)
	{
		b[i] = A[mid + i];
	}
	a[n1] = maxi;
	b[n2] = maxi;
	int m1 = 0, m2 = 0;
	for (int i = left; i < right; i++)
	{
		total++;
		if (a[m1] < b[m2])
			A[i] = a[m1++];
		else
			A[i] = b[m2++];
	}
}


void merge(int A[Max], int left, int right)
{
	if (left+1 < right)
	{
		int mid = (left + right) / 2;
		merge(A, left, mid);
		merge(A, mid, right);
		mergesort(A, left, right);
	}
}


int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	merge(A, 0, n);
	for (int i = 0; i < n; i++)
	{
		cout << A[i];
		if (i < n - 1)
			cout << ' ';
	}
	cout << endl;
	cout << total << endl;
	return 0;
}


Measured memory_bytes: 7032
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a[51];
int main(){
    int n,p;
    while(cin>>n>>p,n|p){
        memset(a,0,sizeof(a));
        int cur=p;
        int t=0;
        while(1){
            if(cur>0){
                ++a[t],--cur;
                if(a[t]==p){
                    break;
                }
            }
            else{
                cur=a[t],a[t]=0;
            }
            t=(t+1)%n;
        }
        cout<<t<<endl;
    }
    return 0;
}


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

#include <unordered_map>

//#include <iostream>//POJ
//#include <vector>
//#include <string>
//#include <iomanip>
//#include <math.h>
//#include <algorithm>
//#include <cstring>
using namespace std;
#define setc cin.tie(0);ios::sync_with_stdio(0)
#define dd(n) cout<<fixed<<setprecision(n)
#define inp(x) (cin>>x,x)
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define repir(i,a,b) for(int i=(a)-1, i##_first=(b); i>=i##_first; --i)
#define repr(i,n) repir(i,n,0)
#define repir_(i,a,b) for(int i=(a), i##_first=(b); i>=i##_first; --i)
#define repr_(i,n) repir_(i,n,0)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
//template<typename T> T vpop(vector<T> *v) {
//	T res = v->back();
//	v->pop_back();
//	return res;
//}
//char vpop(string *v) {
//	char res = v->back();
//	v->pop_back();
//	return res;
//}
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define contain(q) !q.empty()
#define cont(q) !q.empty()
//#define qpop(q, a, b) a=q.back().first;b=q.back().second;q.pop()
//#define pqpop(p, a, b) a=q.top().first;b=q.top().second;q.pop()
#define el "\n"
#define sp " "
#define pi 3.14159265358979
#define co(x) cout<<x<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#define wildcard(T) numeric_limits<T>::min()

#define pb push_back
#define pq priority_queue
#define np next_permutation

#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
const unsigned int bf0 = (1 << 0);
const unsigned int bf1 = (1 << 1);
const unsigned int bf2 = (1 << 2);
const unsigned int bf3 = (1 << 3);
const unsigned int bf4 = (1 << 4);
const unsigned int bf5 = (1 << 5);
const unsigned int bf6 = (1 << 6);
const unsigned int bf7 = (1 << 7);

//#define lint long long
typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;
typedef vector<lint> lvec;
typedef vector<vector<int>> ivvec;
typedef pair<int, int> P;

const int
dx8[8] ={ 0,1,1,1,0,-1,-1,-1 },
dy8[8] ={ 1,1,0,-1,-1,-1,0,1 },
dx9[9] ={ 0,1,1,1,0,0,-1,-1,-1 },
dy9[9] ={ 1,1,0,-1,0,-1,-1,0,1 },
dx4[4] ={ 0,1,0,-1 },
dy4[4] ={ 1,0,-1,0 };

template<class T>inline bool maxi(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main(){
	setc;

	lint a,b,c;cin>>a>>b>>c;
	Yes(a+b==c||b+c==a||c+a==b);
	gc();
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int a = in.nextInt(), b = in.nextInt(), c = in.nextInt();
        if (c >= a && c <= b){
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
    
}

Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
#define fst first
#define snd second
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}
inline int Log2(ll x) {int k; for(k=0; x>0; ++k) x>>=1; return k;} // number of binary digits
template<typename T> inline int count_between(vector<T>& a, T l, T r) {
  return lower_bound(all(a), r) - lower_bound(all(a), l); // [l, r)
}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {
  rep(i, v.size()) is >> v[i]; return is;
}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
  rep(i, v.size()) os << v[i] << " "; return os;
}
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


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

  ll ans = 0;

  ans += divisor(n-1).size() - 1;

  Vll div = divisor(n);

  for (auto d : div) {
    if (d == 1) continue;
    
    ll x = n;
    while (x % d == 0) x /= d;

    if ((x-1) % d == 0) ++ans;
  }

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


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

int main(){
    int n;
    cin >> n;
    vector<P> plot(n);
    rep(i,n)cin >> plot[i].first >> plot[i].second;

    int left_down;
    int right_up;
    int right_down;
    int left_up;

    int min_dist= 1e9*2;
    rep(i,n){
        int dist = abs(plot[i].first -1)+abs(plot[i].second-1);
        if(dist < min_dist){
          left_down = i;
          min_dist = dist;  
        } 
    }
    min_dist = 1e9*2;
    rep(i,n){
        int dist = abs(plot[i].first -1e9)+abs(plot[i].second-1e9);
        if(dist < min_dist) {
            right_up = i;
            min_dist = dist; 
        }
    }

    min_dist = 1e9*2;
    rep(i,n){
        int dist = abs(plot[i].first -1e9)+abs(plot[i].second-1);
        if(dist < min_dist) {
            right_down = i;
            min_dist = dist; 
        }
    }

    min_dist = 1e9*2;
    rep(i,n){
        int dist = abs(plot[i].first -1)+abs(plot[i].second-1e9);
        if(dist < min_dist){
            left_up = i;
            min_dist = dist; 
        }
    }

    int dist1 = abs(plot[left_down].first -plot[right_up].first)+abs(plot[left_down].second-plot[right_up].second);
    int dist2 = abs(plot[left_up].first -plot[right_down].first)+abs(plot[left_up].second-plot[right_down].second);
    int ans = max(dist1,dist2);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4772
#include<stdio.h>

int main(){
	int N, i, j;
	
	//N, A[]の決定
	scanf("%d", &N);
	int  A[N], B[N], C[N];
	
	A[0]=0;
	for(i=1; i<=N; i++){
		scanf("%d", &A[i]);
	}
	A[N+1]=A[0];	A[N+2]=A[1];

/*	//A[]の表示
	printf("\n");
	for(i=0; i<=N+2; i++){
		printf("A[%d]=%d\n", i, A[i]);
	}
	printf("\n");*/


	//一つ飛ばしの距離B[]の設定
	for(i=0; i<=N; i++){
		if(A[i]-A[i+1]>0)	B[i] = A[i]-A[i+1];
		else			B[i] = A[i+1]-A[i];
	}
	
/*	//B[]の表示
	for(i=0; i<=N; i++){
		printf("B[%d]=%d\n", i, B[i]);
	}
	printf("\n");*/

	//飛ばさなかったときの距離の合計
	int sum=0;
	for(i=0; i<=N; i++){
		sum += B[i];
	}
	
	//二つ飛ばしの距離C[]の設定
	for(i=0; i<=N; i++){
		if(A[i+2] - A[i] > 0)	C[i] = A[i+2] - A[i];
		else			C[i] = A[i] - A[i+2];
	}
	
/*	//C[]の表示
	for(i=0; i<=N; i++){
		printf("C[%d]=%d\n", i, C[i]);
	}
	printf("\n");*/
	
	//結果表示
	for(i=1; i<=N; i++){
		printf("%d\n", sum-B[i-1]-B[i]+C[i-1]);
	}
	
	return 0;
}


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

int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for(int i = 0; i < m; i++){
    cin >> a[i];
  }

  int last_yasumi=n;
  for(int i = 0; i < m; i++){
    last_yasumi -= a[i];
  }

  if(last_yasumi<0){
    cout << -1 << endl;
  } else {
    cout << last_yasumi << endl;
  }
}


Measured memory_bytes: 3636
n = int(input())
#indexが負の場合、末尾から参照されるので多めにとる
dp = [0]*100200
dp[0] = 1
for i in range(0,100200):
    if dp[i-105]:
        dp[i] = 1
    if dp[i-104]:
        dp[i] = 1
    if dp[i-103]:
        dp[i] = 1
    if dp[i-102]:
        dp[i] = 1
    if dp[i-101]:
        dp[i] = 1
    if dp[i-100]:
        dp[i] = 1

print(dp[n])

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(a>=k) cout<<k<<endl;
  else if(a+b>=k) cout<<a<<endl;
  else cout<<a-(k-a-b)<<endl;
  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(9)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
 
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
	while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
	if(n==1 || r==0)return 1;
	ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=(((ans * n )/i)%mod);n--;sum+=ans;sum%=mod;}return sum;
}
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true; 
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
		
vll factor(ll n){
	vll ans;
	if(n>0)ans.pb(1);if(n==2)ans.pb(2);
	for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
	return ans;
}
ll numoffactor(ll n){ return factor(n).sz;}
ll gcd(ll a,ll b) 
{ 
	if (a == 0) 
		return b; 
	return gcd(b%a, a); 
} 
 
int main()
{
	ll n,m,k;
	string s;
	cin>>n>>m;
	if(n>=m)
	{
		while(n--)
		cout<<m;
	}
	else
	{
		while(m--)
		cout<<n;
	}
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 100000000
#define MOD 100000007

#define writeln(n) cout<<n<<endl

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
//vector<tuple<long long, long long, long long>>vec;

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;
}

llong pownew(llong m, llong n) {
    if (n == 0) { return 1; }
    if (n % 2 == 0) { return pow(m*m, n/2); }
    return pow(m, n-1) * m;
}

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const int inf=100000000;

long long modpow(long long a, long long n, long long mod) //a^n
{
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

llong gcd(llong a, llong b) {
    return b != 0 ? gcd(b, a % b) : a;
}
//setprecision(10);



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<int> a(n,0);
    REP(i,n) cin>>a[i];
    llong ans=pownew(3,n);
    llong cnt=1;
    for(int i=0; i<n; i++)
    {
        int tmp=0;
        if(a[i]%2!=0) tmp=1;
        else tmp=2;
        cnt*=tmp;
    }
    cout<<ans-cnt<<endl;

    return  0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int main(){
  int k,ans;
  cin>>k;
  if(k%2==0){
    ans=(k/2)*(k/2);
  }else ans=(k/2+1)*(k/2);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#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=100;
const int MAXHAVE=100000;
const int MOD=1000000007;
void inc(int &a,int b) { if((a+=b)>=MOD) a-=MOD; }

int n,shave;
int limit[MAXN];

int dp[MAXHAVE+1];
int ndp[MAXHAVE+1];
int sum[MAXHAVE+2];

int solve() {
	memset(dp,0,sizeof(dp)); dp[0]=1;
	REP(i,n) {
		memset(ndp,0,sizeof(ndp));
		sum[0]=0; REPE(j,shave) sum[j+1]=(sum[j]+dp[j])%MOD;
		REPE(j,shave) {
			inc(ndp[j],sum[j+1]);
			if(j>=limit[i]) inc(ndp[j],MOD-sum[j-limit[i]]);
		}
		REPE(j,shave) dp[j]=ndp[j];
		//printf("after %d:",i); REPE(j,shave) printf(" %d",dp[j]); puts("");
	}
	return dp[shave];
}


void run() {
	scanf("%d%d",&n,&shave);
	REP(i,n) scanf("%d",&limit[i]);
	printf("%d\n",solve());
}

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


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

N,K,L=map(int,input().split())
R=[list(map(int,input().split())) for i in range(K)]
T=[list(map(int,input().split())) for i in range(L)]

Group1=[i for i in range(N+1)]#グループ分け.Group[i]=jのときiとjは同じグループ
Group2=[i for i in range(N+1)]#グループ分け.Group[i]=jのときiとjは同じグループ

def find1(x):#find(a)=find(b)のとき同じグループ
    while Group1[x] != x:
        x=Group1[x]
    return x

def Union1(x,y):#xとyが同じグループになるよう更新
    if find1(x) != find1(y):
        Group1[find1(y)]=Group1[find1(x)]=min(find1(y),find1(x))

def find2(x):#find(a)=find(b)のとき同じグループ
    while Group2[x] != x:
        x=Group2[x]
    return x

def Union2(x,y):#xとyが同じグループになるよう更新
    if find2(x) != find2(y):
        Group2[find2(y)]=Group2[find2(x)]=min(find2(y),find2(x))

for i,j in R:
    Union1(i,j)

for i,j in T:
    Union2(i,j)

from collections import defaultdict
ANS = defaultdict(int)

for i in range(1,N+1):
    ANS[(find1(i),find2(i))]+=1

for i in range(1,N+1):
    print(ANS[(find1(i),find2(i))])


Measured memory_bytes: 97940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

int main()
{
    int H, A;
    cin >> H >> A;
    int ans = ceil((double)H/A);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
int main(){
	int N, L;
	cin >> N >> L;
	int MINi = 0;
	bool check = (L < 0);
	bool check1 = (L + N - 1 < 0);
	if(check != check1) MINi = 0;
	else{
		if(check) MINi = N;
		else MINi = 1;
	}
	int ans = 0;
	for(int i=1;i<=N;i++){
		if(i != MINi)ans+= L + i - 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a_lst = list(map(int,input().split()))
a_lst.sort()
b_lst = a_lst.copy()

for _ in range(10**5+1):
    new_lst = []
    min_b = b_lst[0]
    new_lst.append(min_b)

    for i in range(1, len(b_lst)):
        x = b_lst[i]
        tmp = x//min_b
        b = x- min_b*tmp
        if b!=0:
            new_lst.append(b)

    if len(new_lst)==1:
        print(new_lst[0])
        break
    else:
        b_lst = new_lst.copy()
        b_lst.sort()

Measured memory_bytes: 14224
h, w, a, b = map(int,input().split())
mod = 10**9 + 7

def inv(x, p):
    pp = p-2
    ans = 1
    while pp > 0:
        if pp % 2 == 1:
            ans = (ans * x) % p
        x = (x ** 2) % p
        pp //= 2
    return ans

I = [1] + [inv(i, mod) for i in range(1, h+w+1)]

a0 = 1
a1 = 1
for i in range(w-b+a-1, (w-b+a-1)-(w-b-1), -1):
    a1 = (a1 * i) % mod
# print(a1)
for i in range(w-b-1+1):
    #print("i",i)
    a1 = (a1 * I[i]) % mod

A0 = [a0]
A1 = [a1]
for i in range(1, h-a):
    a0 = (a0 * (b-1+i)) % mod
    a0 = (a0 * I[i]) % mod
    A0.append(a0)

    a1 = (a1 * (w-b+a-1+i)) % mod
    a1 = (a1 * I[(w-b+a-1)-(w-b-1)+i]) % mod
    A1.append(a1)

# print(A0)
# print(A1)
ans = 0
for i in range(h-a):
    pl = (A0[i] * A1[-i-1]) % mod
    ans = (ans + pl) % mod

print(ans)

Measured memory_bytes: 63196
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void solve(){
    int d;
    cin >> d;
    assert(d == 365);
    vector<int> c(26);
    for(int i = 0; i < 26; i++){
        cin >> c[i];
    }
    vector<vector<int> > s(d, vector<int> (26));
    for(int i = 0; i < d; i++){
        for(int j = 0; j < 26; j++){
            cin >> s[i][j];
        }
    }
    vector<int> t(d), satisfaction(d), last(26);
    for(int i = 0; i < d; i++){
        vector<int> temp = last, fin;
        int curr = 0, ans = 0, choose = 1;
        for(int x = 1; x <= 26; x++){
            temp[x - 1] = i + 1;
            curr += s[i][x - 1];
            for(int j = 0; j < 26; j++){
                curr -= (i + 1 - temp[j]) * c[j];
            }
            if(curr > ans){
                ans = curr;
                choose = x;
                fin = temp;
            }
        }
        t[i] = choose;
        last = fin;
        satisfaction[i] = ans;
    }
    // int sat = 0;
    // for(int i = 0; i < d; i++){
    //     last[t[i] - 1] = i + 1;
    //     sat += s[i][t[i] - 1];
    //     for(int j = 0; j < 26; j++){
    //         sat -= (i + 1 - last[j]) * c[j];
    //     }
    //     satisfaction[i] = sat;
    // }
    // for(int i = 0; i < d; i++){
    //     cout << satisfaction[i] << "\n";
    // }
    // for(int i = 0; i < d; i++){
    //     cout << t[i] << "\n";
    // }
    int res = max(1000000 + satisfaction[d - 1], 0);
    for(int i = 0; i < d; i++){
        cout << t[i] << "\n";
    }
    // cout << res << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#define debug(...)                                                             \
    { cerr << "# " << __VA_ARGS__ << "\n"; }
#else
#define debug(...)
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
  public:
    void solve() {
        int n, m;
        cin >> n >> m;
        int st, ed;
        if (n == 1)
            st = 0, ed = 10;
        else if (n == 2)
            st = 10, ed = 100;
        else if (n == 3)
            st = 100, ed = 1000;
        int s[11], c[11];
        for (int i = 0; i < m; ++i)
            cin >> s[i] >> c[i];
        for (int i = st; i < ed; ++i) {
            string ss = to_string(i);
            bool ok = 1;
            for (int j = 0; j < m; ++j) {
                if (ss[s[j] - 1] != c[j] + '0') {
                    ok = 0;
                    break;
                }
            }
            if (ok) {
                cout << i << '\n';
                return;
            }
        }
        cout << -1;
    }
} NSPACE;
int main() {
    FPEN;
    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    NSPACE.solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl
#define first(v) get<0>(v)
#define second(v) get<1>(v)
#define third(v) get<2>(v)
template <typename T> bool chmax(T &a, T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    vector<ll> A(N,0);
    for(ll i=0;i<N;i++){
        cin>>A[i]
    ;}
    Map M;
    for(ll i=0;i<N;i++){
        M[A[i]]++;
    ;}
    vector<ll> vec(0);
    for(auto p: M){
        vec.emplace_back(second(p));
    ;}
    sort(vec.begin(), vec.end());
    if(vec.size()<=K){
        print(0);return 0;
    }
    ll ans=0;
    for(ll i=0;i<vec.size()-K;i++){
        ans+=vec[i]
    ;}
    print(ans);
    
    return 0;
}


Measured memory_bytes: 16500
#include<stdio.h>
int main()
{
    int i,j,k,m,W,H;
    for(m=1;;m++)
    {
        scanf("%d%d",&H,&W);
        if(H==0 && W==0)break;

        for(i=1; i<=H; i++)
        {
            if(i%2!=0)
            {
                for(j=1; j<=W; j++)

                {
                    if(j%2!=0)
                        printf("#");
                    else
                        printf(".");
                }

            }


            else
            {
                for(k=1; k<=W; k++)
                {
                    if(k%2!=0)
                        printf(".");
                    else
                        printf("#");
                }
            }
            printf("\n");

        }

    printf("\n");
    }


    return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    double p[n],q[n],l[4]={};
    for (int i = 0; i < n; i++)cin>>p[i];
    for (int i = 0; i < n; i++)cin>>q[i];
    for (int i = 0; i < n; i++){
        int k=abs(p[i]-q[i]);
        l[0]+=k;
        l[1]+=pow(k,2);
        l[2]+=pow(k,3);
        if(k>l[3])l[3]=k;
    }
    printf("%.6f\n",l[0]);
    printf("%.6f\n",sqrt(l[1]));
    printf("%.6f\n",cbrt(l[2]));
    printf("%.6f\n",l[3]);
}


Measured memory_bytes: 3504