akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 1<<30;
constexpr int mod = 1e9+7;
constexpr ll infl = 1ll<<60;

constexpr int nr = 800;
vector<pair<int,int>> mo[nr];
pair<int,int> query[500050];
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n,q;
    cin>>n>>q;
    vector<int> c(n);
    for(int i=0;i<n;++i) cin>>c[i];
    for(int i=0;i<q;++i){
        cin>>query[i].first >> query[i].second;
        query[i].first--;
        mo[query[i].first/nr].push_back({query[i].second,i});
    }
    int x;
    array<int,500050> num{};
    array<int,500050> ret{};
    for(int i=0;i<nr;++i){
        sort(mo[i].begin(),mo[i].end());
        fill(num.begin(),num.end(),0);
        int curl,curr;
        curl = curr = 0;
        int count =0 ;
        for(auto && a : mo[i]){
            x = a.second;
            while(curr <query[x].second){
                if(num[c[curr]] == 0 ){
                    count++;
                }
                num[c[curr]]++;
                curr++;
            }
            while(curl < query[x].first){
                num[c[curl]]--;
                if(num[c[curl]] == 0)count--;
                curl++;
            }
            while(curl > query[x].first){
                curl--;
                num[c[curl]]++;
                if(num[c[curl]] == 1)count++;
            }
            ret[x] = count;
        }
    }
    for(int i=0;i<q;++i)cout << ret[i] << endl;
    return 0;
}

Measured memory_bytes: 19872
// 2011/02/12 Tazoe

#include <iostream>
using namespace std;

int main()
{
	bool ham[1000001];
	for(int i=0; i<=1000000; i++)
		ham[i] = false;

	for(int i=1; i<=1000000; i*=2)
		for(int j=i; j<=1000000; j*=3)
			for(int k=j; k<=1000000; k*=5)
				ham[k] = true;

	while(true){
		int m;
		cin >> m;
		if(m==0)
			break;

		int n;
		cin >> n;

		int cnt = 0;
		for(int i=m; i<=n; i++)
			if(ham[i])
				cnt++;

		cout << cnt << endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.OptionalLong;
import java.util.stream.LongStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] a = new int[N];
            int[] b = new int[N];
            int[] c = new int[N];
            for (int i = 0; i < N; i++) {
                a[i] = in.nextInt();
                b[i] = in.nextInt();
                c[i] = in.nextInt();
            }

            long[][] happy = new long[N][3];
            happy[0] = new long[]{a[0], b[0], c[0]};
            for (int i = 1; i < N; i++) {
                happy[i][0] = Math.max(happy[i - 1][1], happy[i - 1][2]) + a[i];
                happy[i][1] = Math.max(happy[i - 1][2], happy[i - 1][0]) + b[i];
                happy[i][2] = Math.max(happy[i - 1][0], happy[i - 1][1]) + c[i];
            }
            out.println(LongStream.of(happy[N - 1]).max().getAsLong());
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 49092
//電光掲示板
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N ,K ;
  cin >> N >> K;
  int sum = 1;
  
  for (int i = 0; i < N; i++) {
  sum = min(sum*2, sum+K);
  }
  cout << sum << endl;
  return 0;
  }


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <cctype>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
		cout << "vowel" << endl;
	else
		cout << "consonant" << endl;
	return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc175/tasks/abc175_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int32_t i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int32_t N, K;
    cin >> N >> K;
    vector<int> P(N), C(N);
    REP(i, N) cin >> P[i], P[i]--;
    REP(i, N) cin >> C[i];

    int ans = -1e12;
    // スタート位置
    REP(i, N) {
        vector<int> v;
        int now = i;
        while (true) {
            now = P[now];
            v.emplace_back(C[now]);
            if (now == i) {
                break;
            }
        }
        int loopSum = accumulate(ALL(v), 0LL);
        int32_t cnt = v.size();
        int t = 0;
        REP(j, min(cnt, K)) {
            t += v[j];
            // ループ内の合計x残りループ回数を加算する
            // ループ内の合計が負なら無視
            ans = max(ans, t + max(0LL, loopSum) * ((K - j - 1) / cnt));
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3824
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	vector<int>x;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int r;
		cin >> r;
		x.push_back(r);
	}
	int a = 0;
	sort(x.begin(), x.end());
	for (int i = 1; i < n; i++) {
		a += x[i] - x[i - 1];
	}
	cout << a << endl;
	return 0;

}




Measured memory_bytes: 256
#include <iostream>
#define rep(i, n)for(int i=0; i<n; i++)
using namespace std;
using ll = long long;

int main(){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int sum = 1000000000;
    for(int i=0; ;i+=2){
        int j, k;
        if(x-i/2>=0) j = x-i/2;
        if(y-i/2>=0) k = y-i/2;
        int cursum = a*j + b*k + c*i;
        if(cursum<sum) sum = cursum;
        if(i/2>x && i/2>y) break;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3596
#define _USE_MATH_DEFINES
#include <math.h>
#include <time.h>
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)

#define PI M_PI
#define INF 1000000000
#define MOD 1000000007;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<bool>> vvb;

int main()
{
	int N, H;
	cin >> N >> H;
	vi a(N), b(N);
	rep(i, N) cin >> a[i] >> b[i];

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());

	int ans = 0;
	int num = N;
	while (H > 0)
	{
		if (num > 0 && b[num - 1] > a[N - 1])
		{
			H -= b[num - 1];
			num--;
			ans++;
		}
		else
		{
			H -= a[N - 1];
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define p 3.1415926535
int main()
{
	double n, m, x;
	cin >> n >> m >> x;
	double g = n * n * m;
	double left = g - x;
	if (left <= g / 2)
	{
		double sum = left / n / n * 2;
		double ans = atan(sum / n) * 180 / p;
		printf("%.9lf", ans);
	}
	else
	{
		double sum = x / m / n * 2;
		double ans = atan(m / sum) * 180 / p;
		printf("%.9lf", ans);
	}



}

Measured memory_bytes: 256
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# from time import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    a,b,c,d = readInt()
    ans = a * c
    ans = max(ans,b * c)
    ans = max(ans,a * d)
    ans = max(ans,b * d)
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9172
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
  int n, k, ck, ckmax, ckmax2, maxa, point, max, min;
  vector<int> c;
  vector<int>::iterator it, p, q;
  while(1) { 
    cin >> n >> k;   
    if(n==0 && k==0) break;  
    max=maxa=0;  
    for(int i=0; i<n; i++) {  
      cin >> ck;     
      c.push_back(ck);    
      if(max<ck) max = ck; 
    }    
    ckmax=ckmax2=1; 
    for(int i=0; i<=n-k; i++) {  
      ck=1;  
      for(it = c.begin()+i; it != c.begin()+i+k; it++) {  
	ck*=*it; 
      }  
      min = *min_element(c.begin()+i, c.begin()+i+k);  
      if(ck > ckmax) {  
	ckmax=ck;  
	p = c.begin()+i;   
      }   
      if(ck/min > ckmax2) {  
	ckmax2=ck/min;  
	q = c.begin()+i;  
      }  
    }     
    for(it=c.begin(); it!=c.end(); it++) {   
      if(*it>maxa && (it<q || it>=q+k)) maxa = *it;  
    } 
    if(maxa>min) ckmax2*=maxa;   
    else ckmax2*=min;  
    point = ckmax2-ckmax;  
    cout << point << endl;    
    c.clear(); 
  }  
  return 0;
}


Measured memory_bytes: 1216
#include <iostream>
using namespace std;
using ll = long long;

int main() {
  ll A, B;
  cin >> A >> B;
  ll ans = 0;
  if (B - A < 4) {
    for (ll i = A; i <= B; i++) {
      ans ^= i;
    }
    cout << ans << endl;
    return 0;
  }

  while (A % 4 != 0) ans ^= A++;
  while (B % 4 != 3) ans ^= B--;

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

Measured memory_bytes: 256
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("mmx,sse,sse2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree <T, null_type ,  less<T> ,  rb_tree_tag ,  tree_order_statistics_node_update>;

template<class T>
using ordered_multiset = tree <T, null_type ,  less_equal<T> ,  rb_tree_tag ,  tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvii = vector<vii>;

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	while(b <= a) b <<= 1, --k;
	while(c <= b) c <<= 1, --k;
	cout << (k >= 0 ? "Yes\n" : "No\n");
	return 0;
}

Measured memory_bytes: 3652
N = int(input())
points = [[int(s) for s in input().split()] for i in range(N)]
points.sort(key=lambda x: x[2], reverse=True)

for Cx in range(101):
    for Cy in range(101):
        H = None
        for xi, yi, hi in points:
            dx = abs(xi - Cx)
            dy = abs(yi - Cy)
            if hi > 0:
                """観測点の高さが1以上なら頂点高を予測"""
                H_calc = hi + dx + dy
                if H is None:
                    H = H_calc
                elif H != H_calc:
                    H = None
                    break  # 頂点高が一意ではない場合はNG
            else:
                """観測点の高さが0なら式を満たしているかチェック"""
                if H > dx + dy:
                    H = None
                    break  # 満たしていない場合はNG

        if H:
            print('{} {} {}'.format(Cx, Cy, H))
            exit()


Measured memory_bytes: 3064
def circum(x1,y1,x2,y2,x3,y3):
    a1 = 2 * (x2 - x1)
    b1 = 2 * (y2 - y1)
    c1 = x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2
    a2 = 2 * (x3 - x1)
    b2 = 2 * (y3 - y1)
    c2 = x1 ** 2 - x3 ** 2 + y1 ** 2 - y3 ** 2
    X = (b1 * c2 - b2 * c1)/(a1 * b2 - a2 * b1)
    Y = (c1 * a2 - c2 * a1)/(a1 * b2 - a2 * b1)
    R = ((x1 - X) ** 2 + (y1 - Y) ** 2) ** 0.5
    return map(lambda n: round(n,3), [X,Y,R])
N = int(input())
ans = []
for i in range(N):
    ans.append(circum(*list(map(float,input().split()))))
for i in range(N):
    print('{0:.3f} {1:.3f} {2:.3f}'.format(*ans[i]))

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

#define ll            long long
#define pb            push_back
#define si            set <int>
#define F             first
#define S             second
#define mii           map<int ,int >
#define msi           map<string,int >
#define mis           map<int , string>
#define fr(i,a,b)     for(int  i=a;i<=b;i++)
#define loop(i,n)     for(int i=0;i<n;i++)
#define all(v)        v.begin(),v.end()
#define vi            vector<int >
#define vii           vector<pair<int , int >>
#define vs            vector<string>
#define sz(x)         (int )x.size()
#define M             1000000007
#define mp            make_pair
#define input(arr,n)  loop(i,n) cin>>arr[i]
#define output(arr,n) loop(i,n) cout<<arr[i]<<" "
#define mod           998244353
#define sof           sizeof
using namespace std;
int gcd(int a,int b){
  if(b==0)return a;
  return gcd(b,a%b);
}

bool isPrime(int num){
    
    if(num==2) return true;
    if(num<2 || num%2==0) return false;
    for(int i = 3; i*i <=num; i+=2) {
       if(num % i == 0) {
          
          return false;
       }
    }
    return true;
   
}

bool comp(const pair<int,int> &a,const pair<int,int> &b){
  return a.F>b.F;
}



void solve(){
  // a simple dp problem
  int n,k;
  cin>>n>>k;
  ll arr[n];
  input(arr,n);
  ll f[n];
  k=min(n,k);
  loop(i,k){
    f[i]=abs(arr[i]-arr[0]);
  }
 
  fr(i,k,n-1){
    ll mi=INT_MAX;
    fr(j,1,k){
      mi=min(mi,abs(arr[i]-arr[i-j])+f[i-j]);
    
    }
    f[i]=mi;
  }
  cout<<f[n-1];
 


}




signed main()   
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  cout.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout); 
  #endif  

  int t;
  t=1;
  //cin>>t;
  loop(i,t){

      solve();
      if(i<t-1) cout<<"\n";
  }

  
  
  //directed graph
    



}
  


  



Measured memory_bytes: 5184
from copy import copy
N = int(input())
D = list(map(int,input().split()))

H = copy(D)
H.sort()



if D[0] != 0: print(0)
elif H[0] == 0 and H[1] == 0: print(0)
else:
  D.sort()
  flg = True
  A = []
  a = 1
  c = 0
  for i in range(1,N):
    if D[i] == D[i-1] + 1:
      A.append(a)
      a = 1
      c += 1
    elif D[i] == D[i-1]:
      a += 1
    else:
      flg = False
      break
  
  A.append(a)
  c += 1

  ans = 1

  if flg:
    for i in range(1,c):
      ans *= (A[i-1]%998244353)**A[i]
    print(ans%998244353)

  else:
    print(0)
  




Measured memory_bytes: 15036
import sys
sys.setrecursionlimit(10**6)

V, E = list(map(int, input().split()))
G = [[] for i in range(V)]

for i in range(E):
    s, t = list(map(int, input().split()))
    G[s].append(t)
    G[t].append(s)

class LowLink:
    def main(G, V):
        LowLink.G = G
        LowLink.used = [False] * V
        LowLink.ord = [0] * V
        LowLink.low = [0] * V
        LowLink.aps = []
        LowLink.bridges = []
        n = 0
        
        for i in range(V):
            if not LowLink.used[i]: n = LowLink.dfs(i, n, -1)
            
        LowLink.aps.sort()
        LowLink.bridges.sort()
        
    def dfs(v, n, par):
        LowLink.used[v] = True
        LowLink.ord[v] = n+1
        n += 1
        LowLink.low[v] = LowLink.ord[v]
        
        is_aps = False
        chi = 0
        
        for u in LowLink.G[v]:
            if not LowLink.used[u]:
                chi += 1
                n = LowLink.dfs(u, n, v)
                LowLink.low[v] = min(LowLink.low[v], LowLink.low[u])
                if par != -1 and LowLink.ord[v] <= LowLink.low[u]: is_aps = True
                if LowLink.ord[v] < LowLink.low[u]: LowLink.bridges.append((min(v, u), max(v, u)))
                
            elif u != par:
                LowLink.low[v] = min(LowLink.low[v], LowLink.ord[u])
                
        if par == -1 and chi >= 2: is_aps = True
        if is_aps: LowLink.aps.append(v)

        return n

LowLink.main(G, V)      

for v in LowLink.bridges:
    print(*v)


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, -1, -1, 0, 1, 1, 1};
int dj[] = {1, 1, 0, -1, -1, -1, 0, 1};
// }}}


int main() {
    std::ios::sync_with_stdio(false);
    int h, w;cin >> h >> w;
    char c[50][50];
    for(int i=0;i<h;i++){
        string s;cin >> s;
        for(int j=0;j<w;j++){
            c[i][j] = s[j];
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(c[i][j] == '.'){
                int count = 0;
                for(int k=0;k<8;k++){
                    int ni = i + di[k];
                    int nj = j + dj[k];
                    if(ni >= 0 && ni < h && nj >= 0 && nj < w){
                        if(c[ni][nj] == '#'){
                            count++;
                        }
                    }
                }
                c[i][j] = char('0'+count);
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout << c[i][j];
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

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

    int n;
    cin >> n;
    int p[n];
    int sum = 0;
    rep(i, n){
        cin >> p[i];
    }

    sort(p, p+n);

    rep(i, n-1){
        sum += p[i];
    }

    sum += p[n-1]/2;

    ppp(sum);


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define LL long long
#define swap(x,y) (x^=y^=x^=y)
#define min(x,y) ((x)<(y)?(x):(y))
using namespace std;
LL n,a,b;
int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);if(a>b&&swap(a,b),(a&1)==(b&1)) return printf("%lld",b-a>>1),0;
	return printf("%lld",min((b-a-1>>1)+a,(b-a+1>>1)+(n-b))),0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{

  unsigned long long a = 100;
  unsigned long long x;
  scanf("%lld",&x);
  int year = 1;

//    printf("%d",x);
  while(1){
    a = a + a*0.01;
    if(a >= x){
      printf("%d",year);
      return 0;
    }
    year ++;
//    printf("%d %d\n",a,year);
  }

}



Measured memory_bytes: 1736
#include <stdio.h>

int main(void)
{
	int n, m;
	int i = 0, j = 0, a = 1, b = a + 1, c = b + 1, kazu = 0;

	while (1)
	{
		scanf("%d %d", &n, &m);
		
		if (n == 0 && m == 0)break;

		for (a = 1; a <= n; a++) 
		{
			for (b = a + 1; b <= n; b++) 
			{
				for (c = b + 1; c <= n; c++) 
				{
					if (a + b + c == m)
					{
						kazu++;
					}
				}

			}
		}

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

		kazu = 0;
	}

	return 0;
}



Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int h, w;
  cin >> h >> w;
  vector<vi> fi(h + 2, vi(w + 2, -1));
  rep(i, h) rep(j, w) {
    char c;
    cin >> c;
    if(c == '#') fi[i + 1][j + 1] = -2;
  }
  rep2(i, 1, h + 1) rep2(j, 1, w + 1) {
    int num = 0;
    if(fi[i][j] == -1) {
      rep(k, 8) {
        int ni = i + dir[k], nj = j + dir[k + 1];
        if(fi[ni][nj] == -2) num++;
      }
      fi[i][j] = num;
    }
  }
  rep2(i, 1, h + 1) {
    rep2(j, 1, w + 1) {
      if(fi[i][j] >= 0)
        cout << fi[i][j];
      else
        cout << '#';
    }
    cout << endl;
  }
}

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

using namespace std;

int main()
{
  int N; cin >> N;
  
  vector<int> v;
  for (int i=0; i<N; i++) 
  {
      int a; cin >> a;
      v.push_back(a);
  }

  int xorNum = 0;
  for (int i=0; i<N; i++) {
    xorNum ^= v.at(i);
  }
  
  cout << ((xorNum == 0) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 892
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	string s; cin >> s;
	cout << (s.length() >= 4 && s.substr(0, 4) == "YAKI" ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  long long t = 1, a = 1;
  for (int i = 0; i < N; ++i) {
    long long T, A;
    cin >> T >> A;
    long long k = max((t + T - 1) / T, (a + A - 1) / A);
    t = T * k;
    a = A * k;
  }

  cout << t + a << endl;
}


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

int main() {
    string w;
    cin>>w;
    vector<int> W(26, 0);
    for(int i=0;i<w.size();i++){
        W.at(int(w.at(i))-97)+=1;
    }
    /*for(int k=0;k<26;k++){
        cout<<W.at(k)<<endl;
    }*/
    for(int l=0;l<26;l++){
        if(W.at(l)%2==0){
            
        }else{
            cout<<"No"<<endl;
            return 0;
        }
        
    }
    cout<<"Yes"<<endl;
    /*for(int j=0;j<26;j++){
        if(W.at(j)%2==0){

        }else{
            cout<<"No"<<endl;
        }
        cout<<"Yes"<<endl;
    }*/
return 0;}
/*
g++ code.cpp
./a.out
*/

Measured memory_bytes: 256
from collections import Counter
def cmb(n):
    if n < 2:
        return 0
    else:
        return (n * (n-1)) // 2

n = int(input())
ls = list(map(int,input().split()))

cs = Counter(ls)
s = 0

for v in cs.values():
    s += cmb(v)

for a in ls:
    print(s - cmb(cs[a]) + cmb(cs[a] - 1))

Measured memory_bytes: 26908
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let v: Vec<i32> = read_vec();
    let (a,b) = (v[0], v[1]);
    println!("{}",
        if a < b {
            "a < b"
        } else if a > b {
            "a > b"
        } else {
            "a == b"
        });
}


Measured memory_bytes: 5028
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;

bool kaibun(string s){
    size_t len = s.length();
    for(int i = 0; i < len/2; i++){
        if(s[i] != s[len-i-1]) return false;
    }
    return true;
}

int main(){
    int N,R=0;
    cin >> N >> R;
    if(N>9) cout << R << endl;
    else cout << R + 100*(10-N) << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<ll>A(N);
    vector<ll>sum(N+1, 0);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        A[i] *= 2;
        sum[i+1] = sum[i] + A[i];
    }
    ll mid = sum[N] / 2;
    auto iter = lower_bound(sum.begin(), sum.end(), mid);
    ll right = *iter;
    iter--;
    ll left = *iter;
    ll ans = min(right - mid, mid - left);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main(void){
	// string s;	cin >> s;
	int A, B; cin >> A >> B;
	int ans = 0;
	int cnt = 0;
	while (cnt < 2)	{
		if (A >= B)	{
			ans += A;
			A--;
		}	else	{
			ans += B;
			B--;
		}
		cnt++;
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);
	
	int k;
	string s;
	cin >> k >> s;
	
	if(s.length() <= k) cout << s << endl;
	else {
		cout << s.substr(0, k) << "..." << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll par[100005];
ll sz[100005];
ll ans;
int findd(int x)
{
    if(par[x]==x)
        return x;
    return par[x]=findd(par[x]);
}
void unionn(int x,int y)
{
    int u=findd(x);
    int v=findd(y);
    if(u!=v)
    {
        if (sz[u] < sz[v])
            swap(u, v);
        par[v] = u;
        ans += (sz[u]*(sz[u]-1))/2LL;
        ans += (sz[v]*(sz[v]-1))/2LL;
        sz[u] += sz[v];
        ans -= (sz[u]*(sz[u]-1LL))/2LL;
    }
}
int main()
{
    ll n,m;
    cin>>n>>m;
    vector<pair<int,int> > arr;
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        arr.push_back(make_pair(x,y));
    }
    for(int i=1;i<=n;i++)
    {
        par[i]=i;
        sz[i]=1LL;
    }
    ll res[m+1];
    ans=(n*(n-1LL))/2LL;
    for(int i=m-1;i>=0;i--)
    {
        res[i+1]=ans;
        int x=arr[i].first;
        int y=arr[i].second;
        unionn(x,y);
    }
    for(int i=1;i<=m;i++)
    {
        cout<<res[i]<<endl;
    }

    return 0;
}


Measured memory_bytes: 4596
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n;
  cin >> n;
  string a,b,c;
  cin >> a >>b >> c;
  int ans = 0;
  REP(i,n){
    if(a[i]==b[i]&&b[i]==c[i])continue;
    if(a[i]==b[i]||b[i]==c[i]||a[i]==c[i]){
      ans++;
      continue;
    }
    ans+=2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> PSI;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
/*bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second > secondElof.second;
}*/
int main(){
   int n, a,cntk = 0,cnt2 = 0,cnt4 =0;
   bool flg=false;
   cin >> n;
   REP(i,n){
       cin >> a;
       if(a%4==0){
           cnt4++;
       }else if(a%2==0&&a%4!=0){
           cnt2++; 
       }else cntk++;
   }
   if(cnt2!=0){
       if(cnt4>=cntk) flg = true;
   }else {
     if(cnt4+1>=cntk) flg = true;
   }
   if(flg == true) cout << "Yes" << endl;
   else cout << "No" << endl;
   /*if(cntk<=cnt4&&n>=4){
       cout << "Yes" << endl;
   }else if(cntk>cnt4&&n>=4) cout << "No" << endl;
   else if(n==3&&cnt4>=1) cout << "Yes" << endl;
   else if(n==3&&cnt2==3) cout << "Yes" << endl;
   else if(n==2&&cnt2==2) cout << "Yes" << endl;
   else if(n==2&&cnt4>=1) cout << "Yes" << endl;
   else cout << "No" << endl;*/
}


Measured memory_bytes: 256
# by the authority of GOD     author: manhar singh sachdev #

import os,sys
from io import BytesIO, IOBase
from collections import deque

def update(seg_tree,value,index,x):
    curr = deque([(1,1,x)])
    while len(curr):
        y = curr.popleft()
        if y[1] <= index <= y[2]:
            seg_tree[y[0]] = max(seg_tree[y[0]],value)
            if y[1] != y[2]:
                curr.append((2*y[0],y[1],(y[1]+y[2])//2))
                curr.append((2*y[0]+1,(y[1]+y[2])//2+1,y[2]))

def traversal(seg_tree,l,r,x):
    curr = deque([(1,1,x)])
    ans = 0
    while len(curr):
        y = curr.popleft()
        if y[1]>=l and y[2]<=r:
            ans = max(ans,seg_tree[y[0]])
        elif not(y[1]>r or y[2]<l):
            curr.append((2*y[0],y[1],(y[1]+y[2])//2))
            curr.append((2*y[0]+1,(y[1]+y[2])//2+1,y[2]))
    return ans

def main():
    n,k = map(int,input().split())
    x = 524288
    seg_tree = [0]*(2*x)
    for _ in range(n):
        y = int(input())+1
        an = traversal(seg_tree,max(1,y-k),min(x,y+k),x)
        update(seg_tree,an+1,y,x)
    print(seg_tree[1])

#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
if __name__ == '__main__':
    main()

Measured memory_bytes: 84248
#include <bits/stdc++.h>
using namespace std;
int n, m;
struct valcnt {
    long long value;
    int cnt;
};

bool cmp(const valcnt &a, const valcnt &b) {
    return a.value > b.value;
}

int main() {
    cin >> n >> m;
    vector<valcnt> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i).value;
        a.at(i).cnt = 1;
    }

    valcnt input;
    for(int i = 0; i < m; ++i) {
        cin >> input.cnt >> input.value;
        a.push_back(input);
    }

    sort(a.begin(), a.end(), cmp);

    long long sum = 0;

    for(int i = 0; ; ++i) {
        if(n > 0) {
            if(n > a.at(i).cnt) {
                sum += a.at(i).cnt * a.at(i).value;
                n -= a.at(i).cnt;
            }else {
                sum += a.at(i).value * n;
                n = 0;
            }
        }else {
            break;
        }
    }

    cout << sum << endl;
}

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

using namespace std;
typedef long long ll;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
const ll mod = 1e9 + 7;
#define REP(i, o, n) for (ll i = o; i < n; i++)
#define rep(i, n) REP(i, 0, n)

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

void actual() {
    // Resolve the problem.
    string s;
    cin >> s;
    string result;
    if (s == "Sunny") {
        result = "Cloudy";
    } else if (s == "Cloudy") {
        result = "Rainy";
    } else if (s == "Rainy") {
        result = "Sunny";
    }

    cout << result << endl;
}

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


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		ArrayList<Integer[]> resultList = new ArrayList<Integer[]>();
		try{
			BufferedReader std = new BufferedReader(new InputStreamReader(System.in));
			int len;
			while( (len = Integer.parseInt(std.readLine())) != 0){
				Integer scores[] = {0, 0};
				for(int i=0; i<len; i++){
					String num[] = std.readLine().split(" ");
					if(num[0].compareTo(num[1]) > 0){       scores[0] += Integer.parseInt(num[0]) + Integer.parseInt(num[1]); }
					else if(num[0].compareTo(num[1]) < 0){  scores[1] += Integer.parseInt(num[0]) + Integer.parseInt(num[1]); }
					else{                                   scores[0] += Integer.parseInt(num[0]);  scores[1] += Integer.parseInt(num[1]); }
				}
				resultList.add(scores);
			}
		}
		catch(IOException e){}
		catch(NumberFormatException e){}
		for(Integer result[] : resultList)
			System.out.println(result[0] + " " + result[1]);
	}
}

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

int main(){
  int N;
  cin >> N;
  int a[N];
  
  for(int i = 0; i<N; i++){
    cin >> a[i];
  }
  
  sort(a,a+N);
  reverse(a,a+N);
  int A = 0, B = 0;
  for(int i = 0; i<N; i++){
    if(i%2==0){
      A += a[i];
    }else{
      B += a[i];
    }
  }
  cout << abs(A - B) << endl;
}

Measured memory_bytes: 3560
#!/usr/bin/env python3

import re

a = []
for i in range(6):
    b = int(input())
    a.append(b)

count = 0
for i in range(5):
    for j in range(i+1,5):
        if(a[j] - a[i] > a[5]):
            count += 1
        else:
            pass
if(count == 0):
    print("Yay!")
else:
    print(":(")


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<int,int>;

const int MOD = 1e9 + 7;

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

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

    cout << min(a, b) + min(c, d) << endl;

    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<ll> v(n);
    vector<ll> l(n+2);
    vector<ll> r(n+2);
    
    FOR(i,0,n){
        cin>>v[i];
        l[i+1] = v[i];
        r[i+1] = v[i];
    }
    FOR(i,1,n+2){
        l[i] = (ll)gcd(l[i],l[i-1]);
    }
    FORr(i,0,n){
        r[i] = (ll)gcd(r[i], r[i+1]); 
    }
    ll ans = 1;

    FOR(i,1,n+1){
        ans = max(ans, (ll)gcd(l[i-1],r[i+1]));
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 2560
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <cstdio>
#include <string>
#include <vector>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 998244353
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { cin.sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	long long n, s; cin >> n >> s;
	vector<long long> a(n + 1, 0); for (long long i = 1; i <= n; i++) cin >> a[i];

	vector<vector<long long>> dp(n + 1, vector<long long>(s + 1, 0)); //dp[i][j]=no. of subsequences ending at i, that can make 'j'

	if (a[1] <= s) dp[1][a[1]] = 1;
	for (long long i = 0; i <= n; i++) dp[i][0] = 1;
	dp[1][0] = 2;

	for (long long i = 2; i <= n; i++) {
		for (long long j = a[i]; j <= s; j++) dp[i][j] = dp[i - 1][j - a[i]];
		for (long long j = 0; j <= s; j++) dp[i][j] = ((dp[i][j] % MOD) +  (dp[i - 1][j] % MOD)) % MOD;
	}
	debug(dp);
	long long ans = 0;
	for (long long i = 1; i <= n; i++) {
		ans = ((ans % MOD) +  (((dp[i][s] - dp[i - 1][s] + MOD) % MOD) * ((n - i + 1) % MOD)) % MOD) % MOD;
	}

	cout << ans;
	return 0;
}

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

using ll = long long;

int main()
{   
    int n;
    scanf("%d", &n);
    int cnt[200000];
    ll sum = 0;
    for(int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        cnt[x]++;
        sum += x;
    }
    int q;
    scanf("%d", &q);
    while(q--) {
        int x , y;
        scanf("%d%d", &x, &y);
        cnt[y] += cnt[x];
        sum += (y-x) * cnt[x];
        cnt[x] = 0;
        printf("%lld\n", sum);
    }
}


Measured memory_bytes: 4188
#include <iostream>

using namespace std;

int main() {
  int N;
  int A[200];

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

  int ans = 0;
  int two = 2;
  bool ok = true;

  while (ok) {
    for (int i = 0; i < N; ++i) {
      if (A[i] % two) {
        ok = false;
        break;
      }
    }
    ++ans;
    two *= 2;
  }

  cout << ans - 1 << endl;

  return 0;
}


Measured memory_bytes: 256
object Main extends App {
	val sc = new java.util.Scanner(System.in)
	val pw = new java.io.PrintWriter(System.out)

	val a = Seq.fill(sc.nextInt)(sc.nextInt)
	
	pw.println(if (a.filter(_ % 2 == 0).forall(ai => (ai % 3 == 0) || (ai % 5 == 0))) "APPROVED" else "DENIED")
	pw.flush()
}

Measured memory_bytes: 25812
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")

//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
#include <iostream>
#include <bitset>
#include <algorithm>        // sort()
#include <vector>           // for vectors
#include <map>              // for ordered map
#include <unordered_map>
#include <list>             // for list
#include <iomanip>          // for setprecision()
#include <cmath>            // for pow(), sqrt(), log(), log10(), ....
#include <cstring>          // for memset()
#include <unordered_set>    // for unordered_set
#include <climits>          // for INT_MAX & INT_MIN
#include <set>              // for ordered set

#define C ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long ll;
#define INF INT_MAX
#define NINF INT_MIN
const double pi=acos(-1); // value of pi


bool isVowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') {
        return 1;
    }
    return 0;
}

bool compare(pair<ll, ll> a, pair<ll, ll> b) {
    return a.second<b.second;
}

// map<ll, list<ll>> m;
map<ll, ll> m;

bool isPrime(ll n) {
    for(ll i=3; i*i<=n; i+=2) {
        if(n%i==0) {
            return false;

        }
    }
    return true;
}

int main() {
    C
//     freopen("input.txt","r",stdin);
// 	freopen("output.txt","w",stdout);
    int t=1;
    //cin >> t;
    while(t--) {
        char a;
        cin >> a;
        if(a>='a' && a<='z') {
            cout << "a" << endl;
        }
        else {
            cout << "A" << endl;
        }
    }
}


Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const long long mod = 1000000007;
struct mint {
  long long x;
  mint(ll x = 0):x(x%mod) {}
  mint& operator+=(const mint a) {
    (x += a.x) %= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    (x += mod-a.x) %= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint ret(*this);
    return ret += a;
  }
  mint operator-(const mint a) const {
    mint ret(*this);
    return ret -= a;
  }
  mint operator*(const mint a) const {
    mint ret(*this);
    return ret *= a;
  }
  mint pow(ll t) const {
    if(t==0) return mint(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 ret(*this);
    return ret /= a;
  }
};
ostream &operator<<(ostream& os, const mint& x) {
  os << x.x;
  return os;
}
class modutils {
  vector<mint> fact, invfact;
public:
  modutils(int n = 200005):fact(n+1),invfact(n+1) {
    fact[0] = 1;
    for(int i=1; i<=n; i++) fact[i] = fact[i-1] * i;
    invfact[n] = fact[n].inv();
    for(int i=n; i>=1; i--) invfact[i-1] = invfact[i] * i;
  }
  mint pow(mint x, ll n) {
    return x.pow(n);
  }
  mint comb(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[k] * invfact[n-k];
  }
  mint perm(ll n, ll k) {
    if(n<0 || k<0 || n<k) return 0;
    return fact[n] * invfact[n-k];
  }
  mint fac(ll n) {
    return fact[n];
  }
};
modutils mutil;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }

  sort(ALLOF(v));

  mint ret(0);
  rep(i,N){
    mint x = mutil.comb(N-(i+1), K-1);
    mint y = mutil.comb(i, K-1);

    ret += y * mint(v[i]);
    ret -= x * mint(v[i]);
  }
  
  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 3964