akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int keta(int x) {
    int ret = 0;
    while(x > 0) {
        ret++;
        x /= 10;
    }
    return ret;
}

int main() {
    int N, M;
    cin >> N >> M;
    using pii = pair<int, int>;

    vector<string> res(M);
    vector<pair<pii, int>> city(M);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        city[i] = MP(MP(a, b), i);
    }

    sort(All(city), [](const pair<pii, int> &x, const pair<pii, int> &y) {
        return x.first < y.first;
    });
    int now = 0;
    int old = 0;
    rep(i, M) {
        now++;
        string s = "";
        if(city[i].first.first != old) {
            now = 1;
            old = city[i].first.first;
        }
        rep(i, 6 - keta(old)) s += '0';
        int tmp = old;
        string tmps = "";
        while(tmp > 0) {
            int a = tmp % 10;
            tmps = (char)(a + '0') + tmps;
            tmp /= 10;
        }
        s += tmps;
        tmp = now;
        tmps = "";
        while(tmp > 0) {
            int a = tmp % 10;
            tmps = (char)(a + '0') + tmps;
            tmp /= 10;
        }
        rep(i, 6 - keta(now)) s += '0';
        s += tmps;
        res[city[i].second] = s;
    }
    rep(i, M) { cout << res[i] << endl; }
    return 0;
}

Measured memory_bytes: 9728
//--------------------------------------------------template----------------------------------------//
//c
#include <stdio.h>
#include <time.h>
#include <math.h>
//c++
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <complex>
#include <cmath>
//c++11
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.rbegin(),v.rend())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int main() {
	int a, b;
	while (cin>>a>>b) {
		int c = a + b;
		int digit = 0;
		while (c > 0) {
			c /= 10;
			digit++;
		}
		cout << digit << endl;
	}
}

Measured memory_bytes: 3016
#include<stdio.h>
#define N 100
int main(){
  int i,j,A[N],n,temp,cnt=0,minj;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d",&A[i]);
  }
  
  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(A[j]<A[minj])minj=j;
    }
      	temp=A[i];
	A[i]=A[minj];
	A[minj]=temp;
	if(i!=minj)cnt++;
  }
  
  for(i=0;i<n-1;i++){
  printf("%d ",A[i]);
  }
  printf("%d\n%d\n",A[n-1],cnt);
  return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  if(n<=k)cout << x*n << endl;
  else cout << x*k+y*(n-k) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;

const int N_MAX = 605;

int N, M;
int8_t adj[N_MAX][N_MAX];
vector<double> dp;

double solve_dp() {
    dp.assign(N, 1e9);
    dp[N - 1] = 0;

    for (int i = N - 2; i >= 0; i--) {
        double sum = 0;
        int count = 0;

        for (int j = i + 1; j < N; j++)
            if (adj[i][j]) {
                sum += dp[j] + 1;
                count++;
            }

        dp[i] = sum / count;
    }

    return dp[0];
}

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

    cout << fixed << setprecision(12);

    cin >> N >> M;

    for (int i = 0; i < M; i++) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        adj[s][t] = 1;
    }

    double best = solve_dp();

    for (int s = 0; s < N; s++) {
        int worst = -1;

        for (int t = s + 1; t < N; t++)
            if (adj[s][t] && (worst == -1 || dp[t] > dp[worst]))
                worst = t;

        adj[s][worst] = 0;
        best = min(best, solve_dp());
        adj[s][worst] = 1;
    }

    cout << best << '\n';
}


Measured memory_bytes: 640
// ABC 15b-B
// 2020.3.7 bal4u

#include <stdio.h>

typedef long long ll;

int main()
{
	ll N, A, B, ans;

	scanf("%lld%lld%lld", &N, &A, &B);
	if (A == 0) ans = 0;
	else {
		ans = N/(A+B)*A;
		N %= (A+B);
		if (N >= A) ans += A;
		else ans += N;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define forn(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pb push_back
 
 
// debug templates 
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
 

void solve(){
	int n,k; cin >> n >> k;
	int a[n]; 
	forn(i,0,n) cin >> a[i];
	sort(a,a+n);
	int ans = 0;
	forn(i,0,k) ans += a[i];
	cout << ans;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	solve();
	return 0;
}
 


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

using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vii = vector<vi>;
using pii = pair<int, int>;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i, a, b) for(int (i) = a; (i) < (b);(i)++)
#define MAX(a, b) ((a > b) ? a : b)
#define MIN(a, b) ((a > b) ? b : a)

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int QUA = 1e9 + 7;


int main(){
  ll n; cin >> n;
  ll i = 0, s = 0;
  while(s < n){
    i += 1;
    s += i;
  }
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 256
a;long d[2<<17],m=1e9+7;f(j){d[j]+=d[j+1];j>0&&f(j-1);d[j]=(d[j]-d[j+a+1])%m;}main(k){scanf("%*d%d",&k);for(d[k]=1;~scanf("%d",&a);)f(k);printf("%ld",*d);}

Measured memory_bytes: 4096
#include <iostream>
#include "math.h"
using namespace std;
#define pb push_back

typedef long long ll;
int main(){
  ll x; bool d = 0;
  cin>>x;
  	for(ll i=150; i>=0; --i){
  		for(ll j=i; j>=0; --j){
  			if(pow(i,5) - pow(j,5) == x) {cout<<i<<' '<<j;d=1; break;}
  			else if(pow(i,5)+pow(j,5) == x){cout<<i<<' '<<-j; d=1;break;}
  		}
  		if(d)break;
  	}	

  
  
}


Measured memory_bytes: 3976
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean a = s.indexOf("A") > -1;
        boolean b = s.indexOf("B") > -1;
        System.out.println(a&b ? "Yes" : "No");
        sc.close();

    }

}


Measured memory_bytes: 21844
N = gets.to_i
A = gets.split.map(&:to_i).sort

def f(n)
  b = 2

  while b <= n
    b *= 2
  end

  b - n
end

def c(list)
  cnt = 0

  counter = Hash.new(0)
  list.each do |l|
    counter[l] += 1
  end

  until list.empty?
    n = list.pop
    next if counter[n] <= 0
    counter[n] -= 1
    t = f(n)
    r = list.bsearch { |x| x >= t }

    if r && r == t && counter[r] > 0
      counter[r] -= 1
      cnt += 1
    end
  end

  cnt
end

puts c(A)



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

const int mod = 1e9+7;
const int INF = 2000000;

int main() {
    int k;
    string s;
    cin >> k >> s;
    if(s.size() > k) {
        string tem = s.substr(0,k) + "...";
        cout << tem << endl;
    }
    else cout << s << endl;

}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X;
    cin >> X;
    vector<bool> dp(101010, false);

    dp[0] = true;
    for(int i=0;i<100000;i++){
        if(dp[i]){
            for(int j=0;j<=5;j++){
                dp[i+100+j] = true;
            }
        }
    }
    
    if(dp[X]) cout << 1 << endl;
    else cout << 0 << endl;
}


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

/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}

/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*最大公約数*/
unsigned long long GCD(long long L,long long R){
    if(L>R){
        long long temp=R;
        R = L;
        L = temp;
    }
    unsigned long long pp=0,ppt=0;
    unsigned long long ans=0;
    if(R%L==0){
        ans = L;
    }else{
        while(true){
            ppt = pp;
            pp=R%L;
            if(pp == 0){
                ans = ppt;
                break;
            }
            R = L;
            L = pp;
        }
    }    
    return ans;    
}

/*最小公倍数*/
unsigned long long LCM(long long L,long long R){
    unsigned long long ans;
    unsigned long long gcd = GCD(L,R);
    ans = (L/gcd)*R;
    return ans;
}

/*Combination set*/
#define mod 1000000007
#define maxcomb 3000/*大きいものを求めるときはここを変える*/
vector<long long> fc(maxcomb+1);
vector<long long> ifc(maxcomb+1);
long long modpow(long long x,long long n){
    long long ans = 1;
    while(n > 0){
        if(n & 1) {
            ans = ans*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return ans;
}
void Conb(){
    fc[0]= 1;
    ifc[0]=1;
    for(long long i=0;i<maxcomb;i++){
        fc[i+1] = fc[i]*(i+1)%mod;//n!(mod)
        ifc[i+1] = ifc[i]*modpow(i+1,mod-2)%mod;//k!^{M-2} (mod)
    }
}
unsigned long long Combination(long long L,long long R){
    unsigned long long up=1,ans;
    Conb();
    if(L==0&&R==0){
        return 1;
    }else if(L<R||L<0){
        return 0;
    }else{
        long long t = ifc[L-R]*ifc[R]%mod;
        ans = t*fc[L]%mod;
    }
    return ans;
}
/*Combination set ここまで*/

/*ここから*/
int main() {
    int K,X;
    cin >> K >> X;
    for(int i=X-K+1;i<X+K;i++){
        cout << i ;
        if(i!=X+K-1){
            cout << " ";
        }else{
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list=new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//int[] array = new int[1000000000*2];
		int n = sc.nextInt();
		int m = sc.nextInt();
		if(n==m) {
			System.out.println("Yes");
		}
		else
			System.out.println("No");
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <set>
using namespace std;
typedef long long ll;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;

int main()
{
    int a,b;
    double t;
    cin>>a>>b>>t;
    t+=0.5;
    double time =0;
    int p=1;
    int ans =0 ;
    while(time<t)
    {
        time=a*p;
        if(time > t) break;
        ans+=b;
        p++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
const double eps = 1e-8;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<class T> ostream& operator << (ostream& os, const set<T>& s) { for (auto si : s) os << si << " "; return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    int n;
    cin >> n;
    vector<ll> l(n);
    cin >> l;
    sort(all(l));
    
    int ans = 0;
    rep(i, n) rep3(j, i + 1, n) rep3(k, j + 1, n) {
        if (l[i] != l[j] && l[j] != l[k] && l[i] != l[k] && l[i] + l[j] > l[k]) {
            // cerr << i << " " << j << " " << k << endl;
            ++ans;
        }
    }
    cout << ans << endl;
}







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

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

  B = N % 500;
  
  if (A >= B) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;
// Binary Indexed Tree (Fenwick Tree)
template <typename T>
struct BIT {
    int n,p;
    vector<T> d;
    BIT(int n=0) :n(n), d(n+1) {
        p = 1;
        while(p < n)p *= 2;
    }
    //更新
    void add(int i,T x=1){
        for(i++;i <= n;i += i&-i) d[i] += x;
    }
    //[0,i)の和
    T sum(int i){
        T res = 0;
        for(;i;i -= i&-i) res += d[i];
        return res;
    }
    //[l,r)の和
    T sum(int l,int r){ return sum(r) - sum(l);}
    //v0+v1+…vx>=mを満たすmin(x)を返す
    int lower_bound(T w){
        if(w <= 0) return 0;
        T x = 0;
        for ( int i=p;i;i/=2){
            if(i+x <=n &&d[i+x] < w){
                w -= d[i+x];
                x += i;
            }
        }
        return x;
    }
};

signed main(){
    int n,k;cin>>n>>k;
    int b[n+1];
    b[0]=0;
    REP(i,n){
        int a;cin>>a;
        b[i+1]=b[i]+a-k;
    }
  	
    //press
    {
    map<int,int>p;
    map<int,int>c;
    REP(i,n+1)p[b[i]]++;
    int i=0;
    for(auto v:p){
        c[v.first]=i;
        i++;
    }
    REP(i,n+1)b[i]=c[b[i]];
    }
  
    BIT<int> bit(n+1);
    int ans=0;
    for(int i=n;i>=0;i--){
        ans += bit.sum(b[i],n+1);
        bit.add(b[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 26752
import random

D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]

plus=0
minus=0
data=[[1 for i in range(D)] for j in range(26)]
ans=[0]*D
for i in range(D):
    t=random.randint(1,26)
    ans[i]=t
    plus+=s[i][t-1]
    if i!=0:
        for j in range(26):
            data[j][i]=data[j][i-1]+1
    data[t-1][i]=0
    minus+=sum(c[j]*data[j][i] for j in range(26))

eval=plus-minus
count=1000
while count:
    d=random.randint(1,D)
    q=random.randint(1,26)
    if ans[d-1]==q:
        continue
    testplus=plus+s[d-1][q-1]-s[d-1][ans[d-1]-1]
    testminus=minus
    pre=ans[d-1]
    #print("pre",pre)
    "ans[d-1]=q"

    day=0
    for j in range(d-1,D):
        if data[q-1][j]!=0:
            if j==d-1:
                testminus+=day*c[q-1]-data[q-1][d-1]*c[q-1]
            else:
                testminus+=(day+1-data[q-1][j])*c[q-1]
                day+=1
        else:
            break

    day=0
    for j in range(d-1,D):
        if j==d-1:
            if j==0:
                day=1
                testminus+=c[pre-1]*day
            else:
                day=1+data[pre-1][j-1]
                testminus+=c[pre-1]*day
        elif data[pre-1][j]!=0:
            testminus+=(day+1-data[pre-1][j])*c[pre-1]
            day+=1
        else:
            break

    if testplus-testminus>eval:
        eval=testplus-testminus
        plus=testplus
        minus=testminus
        ans[d-1]=q
        for j in range(d-1,D):
            if data[q-1][j]!=0:
                if j==d-1:
                    data[q-1][d-1]=0
                else:
                    data[q-1][j]=data[q-1][j-1]+1
            else:
                break

        for j in range(d-1,D):
            if j==d-1:
                if j==0:
                    data[q-1][j]=1
                else:
                    data[q-1][j]=1+data[pre-1][j-1]
            elif data[pre-1][j]!=0:
                data[q-1][j]=data[q-1][j-1]+1
            else:
                break
    count-=1

for i in range(D):
  print(ans[i])


Measured memory_bytes: 84996
#085_D
n, h = map(int, input().split())
attacks = []
for _ in range(n):
    a, b = map(int, input().split())
    attacks.append((a, 'a'))
    attacks.append((b, 'b'))
attacks.sort(reverse= True)

cnt = 0
for damage, kind in attacks:
    if kind == 'b':
        h -= damage
        cnt += 1
        if h <= 0:
            break
            
    else:
        cnt += -(-h // damage)
        break

print(cnt)

Measured memory_bytes: 24348
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace aojpro
{
    class Program
    {

        static long[] a;
        static long[] p;
      
        static long Paty(long N, long X)
        {
            if(N == 0)
            {
                if(X <= 0)
                {
                    return 0;
                }
                else
                {
                    return 1;
                }
            }
            else if(X > a[N - 1] + 1)
            {
                return Paty(N - 1, X - a[N - 1] - 2) + 1 + p[N - 1];
            }
            else
            {
                return Paty(N - 1, X - 1);
            }

        }


        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');

            long n = long.Parse(str[0]);
            long x = long.Parse(str[1]);

            a = new long[n + 1];
            p = new long[n + 1];

            a[0] = 1;
            p[0] = 1;

            for(int i = 1; i <= n; i++)
            {
                a[i] = 2 * a[i - 1] + 3;
                p[i] = 2 * p[i - 1] + 1;
            }

            Console.WriteLine(Paty(n, x));

        }
    }
}


Measured memory_bytes: 13140
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    int s,k;cin >> k >> s;
    int cnt=0;
    for(int a=0;a<=k;a++){
        for(int b=0;b<=k;b++){
            int c=s-(a+b);
            if(c>=0 && c<=k)cnt++;
        }
    }
    out(cnt);
    return 0;
}


Measured memory_bytes: 256
while True:
    n,x=map(int,input().split())
    if n==x==0:
        break
    count=0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k==x:
                    count +=1
    print(count)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    vector<ll> rightCandles;
    vector<ll> leftCandles;
    rightCandles.push_back(0);//0本取るときは0にして後のループを一つにまとめる(0本のケースも対応できるようにする)
    leftCandles.push_back(0);
    for (int i = 0; i < N; i++)
    {
        ll point;
        cin >> point;
        if (point >= 0)
        {
            rightCandles.push_back(point); //0込とする(左に含めてもよい)
        }
        else
        {
            leftCandles.push_back(abs(point));
        }
    }
    sort(leftCandles.begin(), leftCandles.end());
    ll answer = 1e14;
    for(ll i = min(K, (ll)leftCandles.size() - 1); i >= 0; i--)
    {
        if(rightCandles.size() - 1 < K - i)
        {
            break;
        }
        //左→右
        answer = min(answer, leftCandles.at(i) * 2 + rightCandles.at(K - i));
        //右→左
        answer = min(answer, rightCandles.at(K - i) * 2 + leftCandles.at(i));
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 1656
x = int(input())
temp = int(x ** 0.25)
flag = True
for i in range(-temp, temp + 1):
    for j in range(-temp, temp + 1):
        if i ** 5 - j ** 5 == x:
            print(i, j)
            flag = False
            break
    if flag == False:
        break

Measured memory_bytes: 9436
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;



int main() {
    int a,b;
    cin >> a >> b;
    if(a < 10 && b < 10) {
        cout << a*b;
    }else {
        cA(-1);
    }
}



Measured memory_bytes: 256
def main():
    A, B = map(int, input().split())

    def xor_world(k):
        """[0,k]"""
        r = k % 4
        if r == 0:
            return k
        elif r == 1:
            return 1
        elif r == 2:
            return 1 ^ k
        else:
            return 0

    ans = xor_world(B) ^ xor_world(A) ^ A
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define forn(i,n) for(int i=0;i<n;i++)
#define fornn(i,a,b)  for(int i=a;i<b;i++)
typedef long long int ll;
using namespace std;


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


	int h[n],dif[n];

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

	   int dp[n-1];

	   dp[0]=abs(dif[0]);
	   dp[1]=min(dp[0]+abs(dif[1]),abs(dif[1]+dif[0]));
     //  cout<<dif[1]<<" "<<dif[0]<<" "<<abs(dif[1]-dif[0])<<"#";

	   for(int i=2;i<n-1;i++)
	   {


           dp[i]=min(dp[i-1]+abs(dif[i]),dp[i-2]+abs(dif[i]+dif[i-1]));


	   }

     cout<<dp[n-2];

	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
using namespace std;
int main() {
	int n, x;
	double sum=0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> x;
		sum += (1.0 / x);
	}
	printf("%.6f\n", 1 / sum);
	return 0;
}

Measured memory_bytes: 256
use std::cmp::max;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let x: u32 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut ans = 1;
    for b in 1..x {
        for p in 2..x {
            let n = b.pow(p);
            if n > x {
                break;
            } else {
                ans = max(ans, n);
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    d = collections.defaultdict(int)
    for i in range(1, n + 1):
        t = i
        for j in range(2, i + 1):
            while True:
                if t % j == 0:
                    d[j] += 1
                    t //= j
                else:
                    break
    t = 1
    for k, v in d.items():
        t = t * (v + 1) % (10 ** 9 + 7)
    print(t)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 40304
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;

int main(void)
{
    int a, b;
    cin >> a >> b;

    if (a <= b)
    {
        cout << a << endl;
    }
    else
    {
        cout << a - 1 << endl;
    }

    return (0);
}

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

using namespace std;

int find(vector < int > &lab, int x) {
  if(lab[x] == -1) return x;
  return lab[x] = find(lab, lab[x]);
}

void join(vector < int > &lab, int x, int y) {
 // cout << x << " " << y << endl;
  if(find(lab, x) == find(lab, y)) return;
  x = find(lab, x);
  y = find(lab, y);
  lab[x] = y;
}

int main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); cout.tie(NULL);
	
  int n, m;
  cin >> n >> m;

  vector < string > a(n);
  for(int i = 0; i < n; ++i) cin >> a[i];

  vector < int > lab(n * m, -1);
  
  for(int i = 0; i < n; ++i){
    for(int j = 0; j < m; ++j) {
      if(i > 0 && a[i][j] != a[i - 1][j]) join(lab, i * m + j, i * m - m + j);
      if(j > 0 && a[i][j] != a[i][j - 1]) join(lab, i * m + j, i * m + j - 1);
    }
  }

  vector < int > cntblack(n * m, 0), cntwhite(n * m, 0);

  for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j) {
    if(a[i][j] == '.') ++cntwhite[find(lab, i * m + j)];
    else ++cntblack[find(lab, i * m + j)];
  }

  long long ans = 0;

  for(int i = 0; i < n * m; ++i) {
    ans += 1LL * cntwhite[i] * (cntblack[i]);
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll ans = 0;
    cin >> N;
    for(ll i = 1; i <= N; i++) {
        if(i % 3 and i % 5) ans += i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3652
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    S = list(map(int, input().split()))

    ans = 0
    for C in range(1, N//2):
        n = N // C
        point = 0
        used = set([0])
        for k in range(1, n):
            A = N - 1 - k*C

            if A in used or k*C in used or A == k*C:
                break
            used.add(A)
            used.add(k*C)

            point += S[A] + S[k*C]
            ans = max(ans, point)

    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 17360
#include <iostream>
#define ll long long int
using namespace std;

int main()
{
     string ai ,bi ,ci ;
     cin>>ai>>bi>>ci ;
     int a = stoi(ai);
     int b = stoi(bi);
     int c = stoi(ci);
     bool flag =false ;
     int sum = 0;
     int k = 1 ;
     int z ;
      while(sum <= b-1 || k <= b-1)
        {

         sum += a ;
         if(sum % b ==  c % b)
         {
             flag = true ;
             break ;
         }
        if((a*k) % b == c % b && (a*k) < b )
        {
            flag   =true ;
            break;
        }

         ++k;

      }
     if(flag)
        cout<<"YES\n";
     else
        cout<<"NO\n";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var N = NM[0];
            var M = NM[1];
            var abList = Enumerable.Range(0, M)
                .Select(_ => Console.ReadLine().Split(' ').Select(int.Parse).ToArray());

            var outputList = new int[N];
            foreach (var ab in abList)
            {
                var a = ab[0];
                var b = ab[1];

                outputList[a - 1]++;
                outputList[b - 1]++;
            }

            foreach (var output in outputList)
            {
                Console.WriteLine(output);
            }
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }
    }
}


Measured memory_bytes: 13396
r=0;(n,),*m=$<.map{|e|e.split.map &:to_i};n.times{|i|(i+1...n).each{|j|z=m[i][j];(0...n).all?{|k|(0<d=z-m[i][k]-m[k][j])&&(p -1;exit);i==k||j==k||d<0}&&r+=z}};p r

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

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    int tmp;
    if ( x > y ) {
        tmp = x;
        x = y;
        y = tmp;
    }
    if ( y > z ) {
        tmp = y;
        y = z;
        z = tmp;
    }
    if ( x > y ) {
        tmp = x;
        x = y;
        y = tmp;
    }
    cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
const int maxn = 200007;
const ll inf = 1e9 + 7;
ll dp[maxn];
ll arr[maxn];
int n;

ll solve(ll pos)
{
    if (pos == n - 1)
        return 0;
    if (pos >= n)
        return inf;

    if (dp[pos] != -1)
    {
        return dp[pos];
    }

    ll ans1 = inf, ans2 = inf;
    if (pos + 1 < n)
        ans1 = solve(pos + 1) + abs(arr[pos] - arr[pos + 1]);
    if (pos + 1 < n)
        ans2 = solve(pos + 2) + abs(arr[pos] - arr[pos + 2]);
    dp[pos] = min(ans1, ans2);
    return min(ans1, ans2);
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    for (int i = 0; i < maxn; i++)
    {
        dp[i] = -1;
    }
    cout << solve(0);

    return 0;
}

Measured memory_bytes: 12164
#include<iostream>
using namespace std;
int main( ){
  int n,y,a[4][13]={};
  char x;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    cin >> x >> y;
    if(x==83){
      a[0][y-1]=1;
    }
    if(x==72){
      a[1][y-1]=1;
    }
    if(x==67){
      a[2][y-1]=1;
    }
    if(x==68){
      a[3][y-1]=1;
    }
  }
  for(int j=0;j<4;j++){
    for(int s=0;s<13;s++){
      if(a[j][s]==0){
	if(j==0)printf("S %d\n",s+1);
	if(j==1)printf("H %d\n",s+1);
	if(j==2)printf("C %d\n",s+1);
	if(j==3)printf("D %d\n",s+1);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3192
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
b=[int(input()) for i in range(n)]
for i in range(3):
  for j in range(3):
    for k in range(n):
      if b[k]==a[i][j]:
        a[i][j]=0
if (a[0][0]==0 and a[1][0]==0 and a[2][0]==0) or (a[0][1]==0 and a[1][1]==0 and a[2][1]==0) or (a[0][2]==0 and a[1][2]==0 and a[2][2]==0) or a[0]==[0,0,0] or a[1]==[0,0,0] or a[2]==[0,0,0] or (a[0][0]==0 and a[1][1]==0 and a[2][2]==0) or (a[0][2]==0 and a[1][1]==0 and a[2][0]==0):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 100000000
#define MOD 100000007
#define SIZE 100005
#define PI 	3.14159265358979323846

int main(){
    ll a,b;
    cin >> a >> b;
    if(a+b==15){
        cout << "+" << endl;
        return 0;
    }
    if(a*b==15){
        cout << "*" << endl;
        return 0;
    }
    cout << "x" << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [list(map(int, input().split())) for _ in range(M)]
h = {}
ans = 0
for row in AB:
    if row[0] in h:
        h[row[0]].append(row[1])
    else:
        h[row[0]] = [row[1]]
    if row[1] in h:
        h[row[1]].append(row[0])
    else:
        h[row[1]] = [row[0]]
ans += sum([1 for i in range(1, N+1) if i not in h.keys()])
for hidx, otherh in h.items():
    if H[hidx-1] > max([H[idx-1] for idx in otherh]):
        ans += 1
print(ans)

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

int main(){
    int a, b, c, t;
    
    cin >> a >> b >> c;
    if (a>b){
        t=a;
        a=b;
        b=t;
    }
    if (b>c){
        t=b;
        b=c;
        c=t;
    }
    if (a>b){
        t=a;
        a=b;
        b=t;
    }
    
    cout << a << " " << b << " " << c << '\n';
    
    return 0;
}


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

typedef long long ll;

void print()
{
  std::cout << std::endl;
}

template<class T>
void print(T param)
{
  std::cout << param << std::endl;
  return;
}

template<class T, class... S>
void print(T param1, S... param2)
{
  std::cout << param1 << " "; print(std::forward<S>(param2)...);
}

int main()
{
  ll A, B, K;
  std::cin >> A >> B >> K;

  for (ll i = 0; i < K; i++) {
    A /= 2;
    B += A;
    std::swap(A, B);
  }

  if (K % 2 == 1) {
    std::swap(A, B);
  }

  print(A, B);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll a,b,n;
    cin >> a >> b >> n;
    cout << (a*min(n,b-1))/b << endl;
} 

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

using namespace std;

int main() {

    int e[3];
    int square = 0, rhombus = 0;

    char split;

    while(cin >> e[0] >> split >> e[1] >> split >> e[2]) {

        if(e[0] * e[0] + e[1] * e[1] == e[2] * e[2]) {
            ++square;
        } else if(e[0] == e[1]) {
            ++rhombus;
        }

    }

    cout << square << endl << rhombus << endl;

}

Measured memory_bytes: 1160
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using namespace std;

int main () {
    int n,k;
    vector <int> a;
    cin >> n >> k;
    for (int i=0;i<n;i++) {
        int m;
        cin >> m;
        a.push_back(m);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int sum=0;
    for (int i=0;i<k;i++) {
        sum+=a[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
	string s,a="CF";
	int ok=0;
	cin>>s;
	int l=s.length();
	for(int i=0;i<l;i++)
	{
		if(s[i]==a[ok]) ok++;
		if(ok==2) break;
	}
	if(ok==2) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const double pi = 3.141592653589793;



int main(){
    ll N;
    cin>>N;
    ll Q=pow(N, 0.5);
    ll Ans=0;
    vector<ll> B(41, 0);
    rep(i, 40){
        B[i+1]+=B[i]+i+1;
    }
    for(ll i=2; i<=Q; i++){
        ll K=0;
        while(N%i==0){
            K++;
            N/=i;
        }
      	//cout<<K<<" ";
        auto itr=upper_bound(ALL(B), K);
      	//cout<<itr-B.begin()<<endl;
        Ans+=itr-B.begin()-1;
    }
  	if(N>1)Ans++;
    cout<<Ans<<endl;
  	
}

Measured memory_bytes: 4060
/*
 * aoj/alds1_14_a/main.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }

#define ull unsigned long long

/*
 * 1. 短い方の長さまでのハッシュを取る.
 * 2. 比較する.
 */
const ull b = 100000007;
void solve() {
  string t, s;
  ull tl, sl;
  cin >> t >> s;
  tl = t.size();
  sl = s.size();

  ull th = 0, sh = 0; // オーバーフローを利用した2^64 mod計算
  loop(i,0,sl) th = th * b + t[i];
  loop(i,0,sl) sh = sh * b + s[i];

  ull b_sl = 1;
  loop(i,0,sl) b_sl *= b;

  vector<int> ans;
  for (int i=0; i+sl<=tl; i++) {
    if (th == sh) ans.push_back(i);
    if (i+sl<tl) th = th * b + t[i+sl] - t[i] * b_sl;
  }

  for(auto&&a: ans) cout << a << endl;
}



Measured memory_bytes: 8432
n, s = list(map(int, input().split()))
al = list(map(int, input().split()))
dp = [[0]*(s+1) for _ in range(n+1)]
dp[0][0] = 1
for i in range(n):
    for j in range(s+1):
        dp[i+1][j] += dp[i][j]
        if j+al[i] <= s:
            dp[i+1][j+al[i]] += dp[i][j]
        dp[i+1][j] %= 998244353
    dp[i+1][0] += 1
    if j+al[i] <= s:
        dp[i+1][al[i]] += 1
for i in range(n):
    for j in range(s+1):
        dp[i+1][j] %= 998244353
ans = 0
for i in range(n):
    ans += dp[i+1][s]
    ans %= 998244353
print(ans)


Measured memory_bytes: 113116
#include<iostream>
#include<cstdio>
#include<cstring>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,L;
ll ans;
struct Inter{
	int pos,val,l,r;
	Inter(int _p=0,int _v=0,int _l=0,int _r=0){pos=_p,val=_v,l=_l,r=_r;}
};
struct cmp1{
	bool operator ()(const Inter a,const Inter b)const{
		return a.pos<b.pos;
	}
};
struct cmp2{
	bool operator ()(const Inter a,const Inter b)const{
		return a.val==b.val?a.pos<b.pos:a.val<b.val;
	}
};
set<Inter,cmp1> p;
set<Inter,cmp2> s;
inline ll calc(vector<Inter> &v){
	ll tot=0,sum=0;
	for(int i=0;i+L-1<(int)v.size();++i){
		sum+=v[i].l;
		tot+=sum*v[i+L-1].r;
	}
	return tot;
}
int main(){
	n=read(),L=read();
	for(int i=1;i<=n;++i){
		int x=read();
		Inter zyk(i,x,1,1);
		p.insert(zyk),s.insert(zyk);
	}
	while(!s.empty()){
		int w=s.begin()->val;
		vector<Inter> t;
		while(s.begin()->val==w){
			t.push_back(*s.begin());
			s.erase(s.begin());
		}
		for(int l=0,r=1;l<(int)t.size();l=r++){
			while(r<(int)t.size()&&(--p.find(t[r]))==p.find(t[r-1]))++r;
			int len=r-l,cnt=len/L;
			if(!cnt)continue;
			vector<Inter> myh,zyy;
			myh.insert(myh.begin(),t.begin()+l,t.begin()+r);
			for(auto x:myh){
				p.erase(x);
			}
			ans+=calc(myh);
			for(int i=0;i<cnt;++i){
				zyy.push_back(Inter(myh[0].pos+i,w+1,0,0));
			}
			for(int i=0;i+L-1<(int)myh.size();++i){
				zyy[cnt-((int)myh.size()-i)/L].l+=myh[i].l;
			}
			for(int i=L-1;i<(int)myh.size();++i){
				zyy[(i-L+1)/L].r+=myh[i].r;
			}
			ans-=calc(zyy);
			for(auto x:zyy){
				p.insert(x),s.insert(x);
			}
		}
	}
	printf("%lld\n",ans+n);
	return 0;
}



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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
struct edge {int to; int index;};

vector<vector<edge>> g(100000+1);
int c = 0;
vector<int> ans;

void dfs(int now = 1, int par_c = 0, int par = 0) {
  int cc = 1;
  for(auto next : g[now]) {
    if(next.to == par) continue;
    if(cc == par_c) ++cc;
    ans[next.index] = cc;
    dfs(next.to, cc, now);
    ++cc;
  }
}

int main()
{
  int n; cin >> n;
  ans.resize(n-1);
  rep(i, n-1) {
    int a, b; cin >> a >> b;
    edge x = {b, i};
    edge y = {a, i};
    g[a].push_back(x);
    g[b].push_back(y);
  }
  for(int i = 1; i <= n; ++i) chmax(c, SZ(g[i]));

  dfs();
  cout << c << endl;
  for(auto x : ans) cout << x << endl;
}

Measured memory_bytes: 12056