akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <vector>
#include <functional>
#include <algorithm>

using i64 = long long;

int main() {
    int n; scanf("%d", &n); std::vector<i64> a(n);
    std::vector<std::vector<int>> g(n);
    for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
    for(int i = 0; i < n - 1; i++) {
        int a, b; scanf("%d%d", &a, &b);

        g[a - 1].push_back(b - 1);
        g[b - 1].push_back(a - 1);
    }
    
    bool ans = true;
    std::function<i64 (int, int)> solve = [&](int v, int par) {
        std::vector<i64> vec;
        for(auto e: g[v]) {
            if(e == par) continue;
            vec.push_back(solve(e, v));
        }
        sort(begin(vec), end(vec));

        if(vec.empty()) return a[v];

        i64 sum = 0;
        for(auto v: vec) sum += v;
        if(a[v] > sum or sum > 2 * a[v] or vec.back() > a[v]) {
            ans = false;
            return 0LL;
        }
        return a[v] - (sum - a[v]);
    };
    i64 ret = solve(0, -1);
    if(g[0].size() > 1 and ret) ans = false;

    if(ans) printf("YES\n");
    else printf("NO\n");
    return 0;
}


Measured memory_bytes: 15872
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <tuple>
using namespace std;


int main() {
    string S;
    cin>>S;
    int L=S.size();
    int ans=0;
    for(int i=0;i<L-1-i;i++) {
        // i and L-1-i
        int j=L-1-i;
        ans += (S[i]!=S[j]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int k= 1;
        HashMap<String,Integer> hashMap = new HashMap<>();
        hashMap.put("SUN",7);
        hashMap.put("MON",6);
        hashMap.put("TUE",5);
        hashMap.put("WED",4);
        hashMap.put("THU",3);
        hashMap.put("FRI",2);
        hashMap.put("SAT",1);
        String s1;
        int a,b;
        while(k-->0){
            a=s.nextInt();
            System.out.println(1-a);
        }
    }

    private static int binary_search(
            int arr[], int l,
            int h, int x)
    {
        while (l <= h) {
            int mid = (l + h) / 2;
            if (arr[mid] <= x)
                l = mid + 1;
            else
                h = mid - 1;
        }
        return h;
    }
    static int gcd(int a, int b)
    {
        if(b==0) {
            return a;
        }
        return gcd(b,a%b);
    }
    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 27040
import numpy as np
N,M,Q = map(int,input().split())
lis = np.zeros((N,N))
for i in range(M):
    L,R = map(int,input().split())
    lis[L-1,R-1] += 1
#二次元累積和
for i in range(N-2,-1,-1):
    lis[i] += lis[i+1]
for j in range(1,N):
    lis[:,j] += lis[:,j-1]

for _ in range(Q):
    p,q = map(int,input().split())
    print(int(lis[p-1,q-1]))


Measured memory_bytes: 15064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a);i>int(b);--i)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define show(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl;
#define MOD 1000000007
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define SZ(x) ((int)(x).size())
#define sum(v,i) accumulate(all(v),i)
//#define int long long
using ll = long long;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }//最大公約数
int lcm(int a, int b) { return a * b / gcd(a, b); }	//最小公倍数
//template <typename... Args>void IN(Args& ... args) {cin >>args;IN(args...);return;} //まとめて入力　IN(a,b,c,d...)

void Main()
{
	ll n;
	cin >> n;
	rrep(i, sqrt(n)) {
		if (n % i==0) {
			//cout << i << " " << n / i << " "<<n<<endl;
			cout << i + n / i - 2;
			return;
		}
	}
}

signed main() {
	Main();

	return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> a(M), b(M);
    vector<bool> ok1(N, false), ok2(N, false);
    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b[i];
        if (a[i] == 1) ok1[b[i]] = true;
        if (b[i] == N) ok2[a[i]] = true;
    }

    for (int i = 2; i < N; i++) {
        if (ok1[i] && ok2[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;
    return 0;
}


Measured memory_bytes: 1920
import collections
import sys


def solve():
    input = sys.stdin.readline
    mod = 998244353
    n = int(input().rstrip('\n'))
    d = list(map(int, input().rstrip('\n').split()))
    mn = 0
    dic = collections.defaultdict(list)
    for i in range(n):
        dic[d[i]] += [i+1]
        mn = max(mn, d[i])
    if len(dic[0]) == 1 and d[0] == 0:
        ln = 1
        t = 1
        for i in range(1, mn+1):
            if len(dic[i]) != 0:
                t *= ln ** len(dic[i])
                t %= mod
                ln = len(dic[i])
            else:
                print(0)
                exit()
        print(t)
    else:
        print(0)
        exit()


if __name__ == '__main__':
    solve()


Measured memory_bytes: 68076
#include <array>
#include <iostream>
#include <map>
#include <vector>

template <typename Map, typename Value = typename Map::mapped_type>
Value &
MapIncrementCount(Map &map, typename Map::key_type key, Value value)
{
    auto [it, flag] = map.try_emplace(key, 0);
    (void)flag;
    auto &v = it->second;
    v += value;
    return v;
}

int
main()
{
    std::ios::sync_with_stdio(false);
    std::size_t n;
    std::cin >> n;

    long long sum = 0;
    std::map<int, int> valueCounts;
    for (std::size_t i = 0; i<n; ++i)
    {
        int input;
        std::cin >> input;
        MapIncrementCount(valueCounts, input, 1);
        sum += input;
    }

    std::size_t operationCount;
    std::cin >> operationCount;
    for (std::size_t i = 0; i<operationCount; ++i)
    {
        int b, c;
        std::cin >> b >> c;

        auto findB = valueCounts.find(b);
        if (findB==valueCounts.end())
        {
            std::cout << sum << "\n";
            continue;
        }

        sum -= static_cast<long long>(b)*findB->second;
        sum += static_cast<long long>(c)*findB->second;

        MapIncrementCount(valueCounts, c, findB->second);
        valueCounts.erase(b);
        std::cout << sum << "\n";
    }
}


Measured memory_bytes: 6576
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

long long GCD(long long m, long long n){
    if(n == 0) return m;
    else return GCD(n, m % n);
}

long long LCM(long long m, long long n){
    long long g = GCD(m, n);
    return m / g * n;
}

signed main(){
    ll a,b;
    cin >> a >> b;
    cout << LCM(a,b) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] d = new int[n];
            for (int i = 0; i < n; i++) {
                d[i] = in.nextInt();
            }
            Arrays.sort(d);
            int m = in.nextInt();
            int[] t = new int[m];
            for (int i = 0; i < m; i++) {
                t[i] = in.nextInt();
            }
            Arrays.sort(t);
            int i = 0;
            for (int x : t) {
                while (i < n && d[i] < x) {
                    ++i;
                }
                if (i >= n || d[i] != x) {
                    out.println("NO");
                    return;
                }
                ++i;
            }
            out.println("YES");
        }

    }

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

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

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

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

    }
}



Measured memory_bytes: 62788
#include <stdio.h>
#include <stdlib.h>
    
int main(void){
    int ant[5],k;
    scanf("%d\n%d\n%d\n%d\n%d\n%d",&ant[0],&ant[1],&ant[2],&ant[3],&ant[4],&k);

    for (int i = 0;i < 5;i++){
        for(int j = i+1;j < 5;j++){
            if(abs(ant[i] - ant [j]) > k){
                printf(":(");
                return 0;
            }
        }
    }

    printf("Yay!");
    return 0;
}

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

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int a, b;
	if (A >= B) {
		a = B;
	}
	else {
		a = A;
	}
	if (C >= D) {
		b = D;
	}
	else {
		b = C;
	}
	cout << a + b << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

const ll MOD=1e9+7;

ll ad(ll x,ll y=0){
  return (x+y)%MOD;
}

ll mlt(ll x,ll y=1){
  return (x*y)%MOD;
}

ll pwr(ll x,ll y){
  ll pw[32]={},w=1;
  pw[0]=x;
  fr(i,31) pw[i+1]=mlt(pw[i],pw[i]);
  fr(i,32){
    w=mlt(w,1+(y%2)*(pw[i]-1));
    y/=2;
  }
  return w;
}

ll inv(ll x){
  return pwr(x,MOD-2);
}

ll fc[200010]={1};
ll fct(ll x){
  if(fc[x]==0) fc[x]=mlt(x,fct(x-1));
  return fc[x];
}

ll ifc[200010]={1};
ll ifct(ll x){
  if(ifc[x]==0) ifc[x]=inv(fct(x));
  return ifc[x];
}

ll comb(ll n,ll r){
  if(n<0 || r<0 || n<r) return 0;
  return mlt(fct(n),mlt(ifct(r),ifct(n-r)));
}

ll pt(ll a,ll b){
  return comb(a+b-2,a-1);
}

int main(){
  ll h,w,a,b,ans=0;
  cin>>h>>w>>a>>b;
  Fr(i,h-a) ans=ad(ans,mlt(pt(i,b),pt(h-i+1,w-b)));
  cout<<ans<<endl;
}

Measured memory_bytes: 4096
import java.util.Scanner;
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int  n=sc.nextInt();
		int i=1;
		do{
		int x=i;
			 if ( x % 3 == 0 ){
    	System.out.print(" "+i);
    	continue;
		} 
		while(true){
		if ( x % 10 == 3 ){
			System.out.print(" "+i);
			break;
		}
		x/=10;
		if(x!=0) continue;
		if(x==0) break;
	}
		}while(++i<=n);
		System.out.println();
	}
}

Measured memory_bytes: 28544
from collections import deque

s = input().strip()
s = deque(list(s))
q = int(input())

queries = [input().strip().split() for _ in range(q)]
is_reversed = False

for query in queries:
    t = query[0]
    if t == '1':
        is_reversed = not is_reversed
    else:
        f = query[1]
        c = query[2]
        if f == '1':
            if is_reversed:
                s.append(c)
            else:
                s.appendleft(c)
        else:
            if is_reversed:
                s.appendleft(c)
            else:
                s.append(c)

str_list = list(s)
if is_reversed:
    str_list = reversed(str_list)

ans = ''.join(str_list)
print(ans)


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

int main() {
  int A, B;
  cin >> A >> B;
  int count = B - A + 1;
  int X = A;
  int sum = 0;
  for (int i = 0; i < count; i++) {
    //cout << "X:" << X << endl;
    int XTEMP = X;
    int X4 = X / 10000;
    if (X4 > 0) X -= X4*10000;
    int X3 = X / 1000;
    if (X3 > 0) X -= X3 * 1000;
    int X2 = X / 100;
    if (X2 > 0) X -= X2 * 100;
    int X1 = X / 10;
    int X0 = X - X1 * 10;
    if (X4 == X0 && X3 == X1 ) {
      //cout << X4 << X3 << X2 << X1 << X0 << endl;
      sum ++;
    }
    X = XTEMP + 1;
  }
  cout << sum << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int mod=1000000007 ;

void solve(){
	
	int n ;
	cin>>n ;

	unordered_set<string> st ;

	for(int i=0;i<n;i++){
		string s ;
		cin>>s ;
		st.insert(s) ;

	}

	cout<<st.size() ;
}



int main(){


	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 17652
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch FiveTransportations | diff FiveTransportations.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address FiveTransportations.cpp && ./a.out

/*
 
 4/7/2019
 
 20:07-
 
 */

LL A[5];
LL N;

void solve() {
  int k=min_element(A,A+5)-A;
  LL mina=A[k];
  LL res=4+(N+mina-1)/mina;
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,5) cin>>A[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi pair<int,int>
vector<int>per;
pi ara[10];
int n,pos[10],cnt;
bool mark[10];

void precal(int take)
{
    if(take==n)
    {
        cnt++;
        for(int i=1; i<=n; i++)per.push_back(pos[i]);
    }
    for(int i=1; i<=n; i++)
    {
        if(!mark[i])
        {
            mark[i]=true,pos[take+1]=i;
            precal(take+1);
            mark[i]=false;
        }
    }
}

int main()
{
    int i,j;
    double a,b,ans=0;
    cin>>n;
    precal(0);
    for(i=1; i<=n; i++)scanf("%d %d",&ara[i].first,&ara[i].second);
    for(i=1; i<per.size(); i++)
    {
        for(j=1; j<n; j++,i++)
        {
            int x=per[i];
            int y=per[i-1];
            a=(ara[x].first-ara[y].first);
            b=(ara[x].second-ara[y].second);
            ans+=(sqrt((a*a)+(b*b)));
        }
    }
    ans/=(cnt*1.0);
    printf("%.10lf\n",ans);
    return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll n;
vector<ll> a;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    a.resize(n);
    rep(i,0,n) cin>>a[i];
    vector<ll> ans(n,-1);
    rer(i,n+1,1){
        ll t=n/i*i;
        ll res=0;
        while(t>i){
            res+=ans[t-1];
            t-=i;
        }
        ans[t-1]=(res+a[i-1])%2;
    }
    ll cnt=0;
    rep(i,0,n) if(ans[i]==1) cnt++;
    cout <<cnt<<"\n";
    rep(i,0,n){
        if(ans[i]==1) cout <<i+1<<"\n";
    }
}

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

using namespace std;

int roma[128];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    roma['I']=1;
    roma['V']=5;
    roma['X']=10;
    roma['L']=50;
    roma['C']=100;
    roma['D']=500;
    roma['M']=1000;
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string str;
    while(getline(cin, str)){
        int ans=roma[(unsigned)str[str.length()-1]];
        for(int i=str.length()-2; i>=0; i--){
            int rn=roma[(unsigned)str[i]];
            if(rn>=roma[(unsigned)str[i+1]]) ans+=rn;
            else ans-=rn;
        }
        cout<<ans<<'\n';
    }
    return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ff first
#define ss second
typedef long long ll;
ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        ll a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        ll val=a[0];
        ll ans=0ll;
        for(int i=0;i<n;i++){
            val=max(val,a[i]);
            ans+=val-a[i];
        }
        cout<<ans<<"\n";
                
    }
    return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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


    lint n;
    cin >> n;
    lint ans, tmp;

    vector<lint> p(n);
    REP(i, n-1) {
        lint a;
        cin >> a;
        p[a-1]++;
        }

    REP(i, n){
        cout << p[i] << "\n";
    }
    

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  int A[N];
  
  bool flag = true;
  
  while(flag){
    for (int i=0; i<N; i++){
      cin >> A[i];
      
      if(A[i] % 2 != 0){
        flag = false;
        break;
      }
      A[i] /= 2;
     }
    if(flag)
    sum += 1;
    
  }
  cout << sum << endl;
}


  
  
  
  

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	long long int a[100000],n,i,m,sum=0;
	scanf("%lld %lld",&m,&n);
	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
		sum=sum+a[i];
	}
	if(sum>=m){
		printf("Yes");
	}
	else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int m=sc.nextInt();
		int n=sc.nextInt();
		if(n==m)System.out.println("Yes");
		else System.out.println("No");
	}
	
} 

Measured memory_bytes: 21844
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N;
    cin >> N;
    int A[N], B[N], C[N - 1];

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

    int ans = B[A[0]];
    for (int i = 1; i < N; i++) {
        ans += B[A[i]] + (A[i] - A[i - 1] == 1 ? C[A[i - 1]] : 0);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e3+5;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n;
	cin >> n;
	int a[n], b[n], c[n];
	for (int i = 0; i < n; cin >> a[i++]);
	for (int i = 0; i < n; cin >> b[i++]);
	for (int i = 0; i < n; cin >> c[i++]);
	sort(a, a + n), sort(b, b + n), sort(c, c + n);
	ll acc[n];
	int low = 0, high, mid, val;
	for (int i = 0; i < n; i++)
	{
		low = 0, high = n - 1, val = n;
		while(low <= high)
		{
			mid = (low + high) / 2;
			if (b[i] < c[mid])
				high = mid - 1, val = mid;
			else
				low = mid + 1;
		}
		acc[i] = n - val;
	}
	for (int i = n - 2; i >= 0; i--)
		acc[i] += acc[i + 1];
	ll ans = 0;
	for (int i = 0; i < n; i++)
	{
		low = 0, high = n - 1, val = -1;
		while(low <= high)
		{
			mid = (low + high) / 2;
			if (a[i] < b[mid])
				high = mid - 1, val = mid;
			else
				low = mid + 1;
		}
		if (~val)
			ans += acc[val];
	}
	cout << ans;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define PI 3.1415926535

int main(void)
{

    double r;
    cin >> r;

    double ans = r * 2.0 * PI;
    printf("%.10lf\n", ans);

    return 0;
}


Measured memory_bytes: 3784
import math
import numpy as np
def get_prime(n):
    if n<= 1:
        return[]
    prime = [2]
    limit = int(math.sqrt(n))
    
    data = [i + 1 for i in range(2,n,2)]
    while limit > data[0]:
        prime.append(data[0])
        data = [j for j in data if j % data[0] != 0]
    return prime + data
def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
n = int(input())
a = get_prime(10**5+1)
b = np.array([0]*(10**5+2))
c =0
d = 0
add = 0
for i in range(1,len(a)):
    if is_prime((a[i]+1)/2):
        d = a[i] 
        b[c:d] = add 
        c = d
        add +=1
b[c:] = add 
b[0::2] = 0

for i in range(n):
    l, r =map(int,input().split())
    print(b[r] - b[max(0, l - 2)] )
    

Measured memory_bytes: 30368
n,x = map(int,input().split())
a = [1]
p = [1]
for i in range(n):
    a.append(2*a[i]+3)
    p.append(2*p[i]+1)
def f(n,x):
    if x == 1:
        return int(n <= 0)
    elif 1 < x <= a[n-1]+1:
        return f(n-1,x-1)
    elif x == 2 + a[n-1]:
        return 1+p[n-1]
    elif 2 + a[n-1] < x <= 2+2*a[n-1]:
        return p[n-1]+1+f(n-1,x-2-a[n-1])
    elif x == 2*a[n-1]+3:
        return 2*p[n-1]+1

print(f(n,x))

Measured memory_bytes: 9228
#include <iostream>
using namespace std;
int main(){
    int a,b,c,d,s,t=0,n,m;
    cin>>n>>m;
    int x[m]={0};
    for(a=0;a<n;a++){
        cin>>s;
        for(b=0;b<s;b++){
            cin>>c;
            x[c-1]++;
        }
    }
    for(d=0;d<m;d++){
        if(x[d]==n){
            t++;
        }
    }
    cout<<t;
}

Measured memory_bytes: 256
#include<stdio.h>
long long a,b; 
long long f(long long x){return ((a*x)/b)-a*(x/b);}  
int main(){
  long long m,i,m1,m2,l=0,r;
  scanf("%lld %lld %lld",&a,&b,&r);
  r++;
  while(r-l>10){//printf("%lld %lld\n",l,r);
    m1=(l+l+r)/3LL;
    m2=(l+r+r)/3LL;
    //printf("%lld %lld\n",
    if(f(m1)<=f(m2))l=m1;
    else           r=m2+1;
  }
  m=0;
  for(i=l;i<r;i++){
    if(m<f(i))m=f(i);
  }
  printf("%lld\n",m);
  return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>a>>b>>c;
    ll now=c;
    while(1){
        if(now+b+c>a)break;
        now+=b;
        now+=c;
        ans++;
    }
    Cout(ans);
    return 0;
}


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

int main()
{
    ll n;
    cin >> n;
    vector<ll> A(n);
    rep(i, n) cin >> A[i];

    sort(A.begin(), A.end(), greater<ll>());

    ll ans = 0;
    if (n % 2 == 0)
    {
        for (int i = 0; i < n / 2 - 1; i++)
        {
            ans += A[i];
        }
        for (int i = 1; i < n / 2; i++)
        {
            ans += A[i];
        }
        ans += A[n / 2 - 1];
        cout << ans << endl;
        return 0;
    }

    if (n % 2 == 1)
    {
        for (int i = 0; i < n / 2; i++)
        {
            ans += A[i];
        }
        for (int i = 1; i <= n / 2; i++)
        {
            ans += A[i];
        }
        cout << ans << endl;
        return 0;
    }
}

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

using namespace std;

int main()
{
    string s, t, st;
    int l, x;

    getline(cin, s);
    getline(cin, t);

    l = s.size();

    st = t.substr(0, l);


    if(st == s)
    {
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    cout << endl;



    return 0;
}


Measured memory_bytes: 3588
//解説コピー
//テスト用　自力では無い

#include <bits/stdc++.h>

using namespace std;
using ll=long long;
const ll mod = 1e9 + 7;
const ll INF = 1LL<<60;

int main() {
    int N,M;
    cin>>N>>M;
    vector<pair<int,ll>> tonari[1001];
    for(int i = 0; i < M; ++i) {
        int a,b; ll w;
        cin>>a>>b>>w;
        tonari[a-1].push_back({b-1,-w});
    }

    bool heikei=false;
    vector<ll> dist(N,INF);
    dist[0]=0;
    for(int i=0;i< 2*N ;i++){
        for(int v=0;v<N;v++) {
            if (dist[v] >= INF) continue;
            for (auto next:tonari[v]) {
                if (dist[next.first] > dist[v] + next.second) {
                    dist[next.first] = dist[v] + next.second;
                    if (next.first == N - 1 &&i >= N) heikei=true;
                }
            }
        }
    }
    if(heikei) cout<<"inf"<<endl;
    else cout<<-dist[N-1]<<endl;

    return 0;
}



Measured memory_bytes: 384
N = int(input())

def dfs(s):
  if int(s) > N:
    return 0
  ret = 0
  if s.count('3') > 0 and s.count('5') > 0 and s.count('7') > 0:
    ret = 1
  ret += dfs(s+'3') + dfs(s+'5') + dfs(s+'7')
  return ret

print(dfs('0'))

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

int main(){
int ans=100;
int sum1=0;
int sum2=0;
int n;cin>>n;
vector<int>w(n);
rep(i,n)cin>>w[i]; 
rep(i,n-1){
    sum1=0;sum2=0;
 for(int j=0;j<=i;j++){
     sum1=sum1+w[j];

 }
 for(int k=i+1;k<n;k++){
     sum2=sum2+w[k];
 }
 ans=min(ans,abs(sum1-sum2));
}
cout<<ans;



}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		String a = sc.next();
		String t = sc.next();
		
		if(a.equals(t)) {
			System.out.println("H");
		}else{
			System.out.println("D");
		}
		
		sc.close();
	}

}


Measured memory_bytes: 21844
#include <cstdio>
const int N=2005,mo=1000000007;
int f[N];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	f[0]=1;
	for (int i=n;i>1;i--)
		for (int j=n-i+1;j>=0;j--){
			if (j) f[j]=f[j-1];else f[j]=0;
			(f[j]+=f[j+1])%=mo;
		}
	for (int i=1;i<n-k;i++) (f[n-k]<<=1)%=mo;
	printf("%d\n",f[n-k]);
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(){
  string s;
  string ans = "0000000000";
  int num = 0;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s[i]=='0'){
      ans[num] = '0';
      num++;
    }else if(s[i] == '1'){
      ans[num] = '1';
      num++;
    }else if(num > 0){
      num --;
    }
  }
  
  for(int i = 0; i < num; i++){
    cout << ans[i];
  }
  cout << endl;
}

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

int main() {
	string O, E;
	cin >> O >> E;
	for (int i = 1; i <= O.length() + E.length(); i++) cout << (i % 2 == 1 ? O : E).substr((i - 1) / 2, 1);
	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
	
int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	string res;
	for(int i = 0; i < n; i++){
		if(s[i] != res[res.size()-1]){
			res += s[i];
		}
	}
	cout << res.size() << endl;

}



Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n,x;
    cin>>n>>x;
    int tmp,sum=0;
    REP(i,n){
        cin>>tmp;
        sum+=tmp;

        if(x<sum){
            cout<<i+1<<endl;
            return 0;
        }
    }


            cout<<n+1<<endl;
            
    return 0;
}


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


int main() {
	int a, b, l, r;
	cin >> a >> b;
	l = min(a * 100 / 8, b * 10);
	r = max((a + 1) * 100 / 8, (b + 1) * 10);
	for (int i = l; i <= r; i++) {
		//printf("%d\n", i);
		if (i * 8 / 100 == a && i / 10 == b) {
			printf("%d\n", i);
			return 0;
		}
	}
	printf("%d\n", -1);
	return 0;
}

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

int W, N;
int v[1000], w[1000];
pair<int, int> dp[1100][1100];

pair<int, int> rec(int i, int j)
{
	pair<int, int> ans;

	if (dp[i][j].first != -1 && dp[i][j].second != -1)
	{
		return dp[i][j];
	}

	if (i == N)
	{
		ans = pair<int, int>(0, W - j);
	}
	else if (j < w[i])
	{
		ans = rec(i + 1, j);
	}
	else
	{
		pair<int, int> vw1 = rec(i + 1, j);
		pair<int, int> vw2 = rec(i + 1, j - w[i]);
		vw2.first += v[i];
		if (vw1.first > vw2.first)
		{
			ans = vw1;
		}
		else if (vw1.first < vw2.first)
		{
			ans = vw2;
		}
		else if (vw1.first == vw2.first)
		{
			if (vw1.second < vw2.second)
			{
				ans = vw1;
			}
			else
			{
				ans = vw2;
			}
		}
	}

	dp[i][j] = ans;

	return ans;
}

signed main()
{
	int cnt = 1;

	while (true)
	{
		cin >> W;
		if (W == 0)
		{
			break;
		}
		cin >> N;
		rep(i,N)
		{
			scanf("%d,%d", &v[i], &w[i]);
		}

		rep(i,1100)
		{
			rep(j,1100)
			{
				dp[i][j] = pair<int, int>(-1, -1);
			}
		}

		pair<int, int> ans = rec(0, W);

		printf("Case %d:\n", cnt);
		printf("%d\n", ans.first);
		printf("%d\n", ans.second);

		cnt++;
	}
}

Measured memory_bytes: 10764
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int n, a, b;


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

	if ((b - a) % 2 == 0)cout << "Alice" << endl;
	else cout << "Borys" << endl;

	return 0;
}


Measured memory_bytes: 256
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define CLR2d(x,m,n) memset(x, -1, sizeof(x[0][0]) * m * n)
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
ll po(ll b,ll p){
    ll res=1;
    while(p){
        res*=b;
        p--;
    }
    return res;
}
ll lg2(ll x){
    ll res=0;
    while(x>1){
        res++;
        x/=2ll;
    }
    return res;
}
void solve(){
    int r;
    cin>>r;
    cout<<(int)sq(r)<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("input.txt","r",stdin);
        freopen ("output.txt","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




Measured memory_bytes: 3484
def GCD(x,y):
    x,y=max(x,y),min(x,y)
    if x%y==0:
        return y
    else:
        return GCD(y,x%y)

N=int(input())
A=list(map(int,input().split()))

ans=A[0]
for i in range(1,N):
    ans=GCD(ans,A[i])
print(ans)

Measured memory_bytes: 62704
#include<bits/stdc++.h>
    using namespace std;
    string s;
    int main()
    {
    	cin>>s;
    	int k;
    	cin>>k;
    	for(int i=0;i<s.length();i++)
    	{
    		if(s[i]=='a')
    		continue;
    		if(k>='z'-s[i]+1)
    		{
    			k-='z'-s[i]+1;
    			s[i]='a';	
    		}
    	}
    	int n=s[s.length()-1]-'a';
    	n=(n+k)%26;
    	s[s.length()-1]=n+'a';
    	cout<<s<<endl;
    	return 0;
    }

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
using namespace std;

long long mod=998244353;
struct mint{
    long long x;
    mint(long long 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{return mint(*this)+=a;}
    mint operator-(const mint a)const{return mint(*this)-=a;}
    mint operator*(const mint a)const{return mint(*this)*=a;}
    mint pow(long long t)const{
        if(!t)return 1;
        mint a=pow(t>>1);
        a*=a;
        if(t&1)a*=*this;
        return a;
    }
    mint inv()const{return pow(mod-2);}
    mint& operator/=(const mint a){return *this*=a.inv();}
    mint operator/(const mint a)const{return mint(*this)/=a;}
};
istream& operator>>(istream& is,mint& a){return is>>a.x;}
ostream& operator<<(ostream& os,const mint& a){return os<<a.x;}

int main() {
    ll n,s;
    cin>>n>>s;
    V a(n);
    rep(i,n)cin>>a[i];
    vector<vector<mint>> dp(n+1,vector<mint>(s+1,0));
    mint ans=0;
    rep(i,n){
        dp[i][0]+=1;
        rep(j,s+1){
            dp[i+1][j]+=dp[i][j];
            if(j+a[i]<=s)dp[i+1][j+a[i]]+=dp[i][j];
        }
        ans+=dp[i+1][s];
    }
    cout<<ans<<endl;
}


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

#define rep(i,x,y) for(int (i)=(x);(i)<(y);(i)++)

int solve(int Y,int M,int D)
{
  return (Y-1)/3*200+((Y-1)-(Y-1)/3)*195+(M-1)*20-((Y%3==0)?0:(M-1)/2)+D;
}

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

  int temp=solve(1000,1,1);

  rep(i,0,n){
    int Y,M,D;
    cin>>Y>>M>>D;
    cout<<temp-solve(Y,M,D)<<endl;
  }

  return 0;
}

Measured memory_bytes: 3096
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  int sm = 0;
  for(int i = 0; i < n; i++) cin >> x[i], sm += x[i];
  int av = sm/n;
  int ans1 = 0;
  for(int i = 0; i < n; i++) ans1 += (x[i]-av)*(x[i]-av);
  int ans2 = 0;
  for(int i = 0; i < n; i++) ans2 += (x[i]-av-1)*(x[i]-av-1);
  int ans3 = 0;
  for(int i = 0; i < n; i++) ans3 += (x[i]-av+1)*(x[i]-av+1);
  cout << min(ans1, min(ans2, ans3)) << endl;
}


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

ll A,B,N; 

ll floor(ll xx) {
    ll a = A*xx/B;
    ll bb = xx/B;
    ll b = A*bb;
    return a - b;
}

int main(void) {
    cin >> A >> B >> N;
    ll ans;
    if(N<B) {
        ll x = N;
        ans = floor(x);
    }
    else {
        ll x = B-1;
        ans = floor(x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int d(int a, int y) {
  int re = 0;
  while (a > 0) {
    re += a % y;
    a /= y;
  }
  return re;
}

int main() {
  int n;
  cin >> n;
  int ans = 100000;
  for (int i = 0; i <= n; i++) {
    int tmp = d(i, 6) + d(n - i, 9);
    ans = min(ans, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int A, B;
	
	cin >> A >> B;
	
	int wa = A + B;
	int sa = A - B;
	int seki = A * B;
	
	if (wa >= sa && wa >= seki) cout << wa << endl;
	else if (sa >= wa && sa >= seki) cout << sa << endl;
	else if (seki >= wa && seki >= sa) cout << seki << endl;
}


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

using namespace std;

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

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

ll K;

void solve() {
    cin >> K;
    ll A[K];
    rep(i,K) cin >> A[i];
    if (A[K-1] != 2) {
        cout << -1 << endl;
        return;
    }
    ll mn = 2, mx = 3;
    for (int i = K-2; i >= 0; --i) {
        ll p1 = (ll)ceil(1. * mn / A[i]) * A[i];
        ll p2 = mx / A[i] * A[i];
        if (p1 > mx || p2 < mn) {
            cout << -1 << endl;
            return;
        }
        mn = p1;
        mx = p2 + A[i] - 1;
    }
    cout << mn << " " << mx << endl;
}

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


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int N,W;
struct item
{
    int v;
    int w;
}I[110];
int V[110][10010];
int main()
{
    cin>>N>>W;
    for(int i=0;i<N;i++)
        cin>>I[i].v>>I[i].w;
    for(int i=0;i<=N;i++)
        for(int c=0;c<=W;c++)
        {
            if(i<=0||c<=0)
                V[i][c]=0;
            else if(c-I[i-1].w<0)
                V[i][c]=V[i-1][c];
            else if(c-I[i-1].w>=0)
                V[i][c]=max(V[i-1][c],V[i][c-I[i-1].w]+I[i-1].v);
        }
        cout<<V[N][W]<<endl;
        return 0;
}


Measured memory_bytes: 7028
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        String a, b;

        Scanner input = new Scanner(System.in);

        a = input.next();
        b = input.next();

        if (a.equals("H") && b.equals("H")) {

            System.out.println("H");
            
        } else if (a.equals("H") && b.equals("D")) {

            System.out.println("D");
            
        } else if (a.equals("D") && b.equals("H")) {

            System.out.println("D");
            
        } else if (a.equals("D") && b.equals("D")) {

            System.out.println("H");
        }
    }

}


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


int main(){
  
  


  int n;
  cin>>n;
  
  int answer=0;
  
  for (int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    
    int count=0;
    
    while (tmp%2==0){
      tmp/=2;
      count++;
    }
    
    answer+=count;
  }
  
  cout<<answer<<endl;
  
    
    

  
  

  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  unordered_map<string,int> um;
  while(n--)
  {
    string s;
    cin>>s;
    um[s]++;
  }
  cout<<"AC x "<<um["AC"]<<endl;
  cout<<"WA x "<<um["WA"]<<endl;
  cout<<"TLE x "<<um["TLE"]<<endl;
  cout<<"RE x "<<um["RE"]<<endl;


  return 0;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main(){
  string s1,s2;
  std::cin >> s1;
  std::cin >> s2;
  if(s1[0]==s2[2]&&s1[1]==s2[1]&&s1[2]==s2[0]){
    std::cout << "YES" << '\n';
  }else{
    std::cout << "NO" << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>

#include <stack>
#include <queue>
// #include <deque>
// #include <set>
// #include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>

#include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;


typedef long long ll;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
typedef pair<long long, long long> pllll;
typedef pair<long long, int> plli;
typedef pair<int,long long> pill;
typedef vector<vector<long long>> vvll;
typedef vector<vector<long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;

#define emplace_back pb
const char el = '\n';

/*
Edge cases:


*/

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

    int n,r; cin>>n>>r; cin.ignore();

    if (n>=10) {
        cout<<r;
    } else {
        cout<<r+100*(10-n);
    } cout<<el;
}

Measured memory_bytes: 256