akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>
#include <stack>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator<< (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

istream& operator>> (istream& a, pii& b) {
    cin >> b.first >> b.second;
    return a;
}

ostream& operator<< (ostream& a, const pii& b) {
    cout << "{" << b.first << ", " << b.second << "}";
    return a;
}

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 &y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 &y) {if (x < y) x = y;}


#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 100;
    // const int mod = 2600000069;
    // const int p = 10;
    // const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e15;
    // const int mod = 2600000069; 
    // const int p = 179;
    // const ld PI = 3.1415926535;
#endif

// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,sse3,sse4")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC optimize("fast-math")
// #pragma GCC target("avx2")  
// #pragma GCC optimize("section-anchors")
// #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
// #pragma GCC optimize("vpt")
// #pragma GCC optimize("rename-registers")
// #pragma GCC optimize("move-loop-invariants")
// #pragma GCC optimize("unswitch-loops")
// #pragma GCC optimize("function-sections")
// #pragma GCC optimize("data-sections")

mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

const int MAXN = 5e5 + 10;
const int mod = 1e9 + 7;

int f[MAXN];

int powmod(int a, int p) {
    if (p == 0) return 1;
    if (p == 1) return a % mod;
    int k = powmod(a, p / 2);
    if (p & 1) return (k * k % mod) * a % mod;
    return k * k % mod;
}

int rev(int k) {
    return powmod(k, mod - 2);
}

int C(int n, int k) {
    int ans = f[n];
    ans = ans * rev(f[n - k]) % mod;
    ans = ans * rev(f[k]) % mod;
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    f[0] = 1;
    for (int i = 1; i < MAXN; i++) {
        f[i] = f[i - 1] * i % mod;
    }
    int n, m;
    cin >> n >> m;
    int ans = C(m, n) * f[n] % mod;
    for (int i = 1; i <= n; i++) {
        int cur = C(n, i) * C(m - i, n - i) % mod;
        cur = cur * f[n - i] % mod;
        if (i & 1) ans = (ans - cur + mod) % mod;
        else ans = (ans + cur) % mod;
    }
    ans = ans * f[n] % mod;
    ans = ans * C(m, n) % mod;
    cout << ans;
}
/*

*/


Measured memory_bytes: 7512
#![allow(unused_imports)]

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt::{Debug, Display};
use std::io::{self, Read};
use std::str::{self, FromStr};


fn solve(n: u32, a: u32) -> u32 {
    n * n - a
}


fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    println!("{}", solve(sc.next(), sc.next()));
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(256),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: Debug,
    {
        self.buf.clear();
        for c in self.bytes
            .by_ref()
            .map(|c| c.unwrap())
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
        {
            self.buf.push(c);
        }
        str::from_utf8(&self.buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<A: FromStr, B: FromStr>(&mut self, n: usize) -> Vec<(A, B)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<A: FromStr, B: FromStr, C: FromStr>(&mut self, n: usize) -> Vec<(A, B, C)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
        <C as FromStr>::Err: Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.vec(m)).collect()
    }
}


#[allow(dead_code)]
fn print_yesno(x: bool, yes: &'static str, no: &'static str) {
    println!("{}", if x { yes } else { no });
}


#[allow(dead_code)]
fn print_foreach<T: Display, I: IntoIterator<Item = T>>(xs: I) {
    for x in xs.into_iter() {
        println!("{}", x);
    }
}


#[allow(dead_code)]
fn print_or<T: Display>(x: Option<T>, or: &'static str) {
    if let Some(x) = x {
        println!("{}", x);
    } else {
        println!("{}", or);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define int long long
int findLowerBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{

    auto low = lower_bound(arr.begin(),
                           arr.end(), p);

    return low - arr.begin();
}
int findUpperBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{
    auto up = upper_bound(arr.begin(),
                          arr.end(), p);

    return up - arr.begin();
}
bool vis[200005];
vector<int> vec[100005];
int child[100005];
void dfs(int node)
{
    vis[node] = 1;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            dfs(vec[node][i]);
            child[node] += child[vec[node][i]];
        }
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str;
    //  cin >> str;
    int z, b, c;
    cin >> z >> b >> c;
    if (c >= z && c <= b)
        cout << "Yes"
             << "\n ";
    else
    {
        cout << "No"
             << "\n";
    }
    return 0;
}


Measured memory_bytes: 5960
#import pysnooper
#import os,re,sys,operator,math,heapq,string
from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy
setrecursionlimit(10**6)
input=stdin.readline

n=int(input().rstrip())
gragh=[[] for _ in range(n)]
q=deque()
for i in range(n):
    u=list(map(int,input().rstrip().split()))
    for j in u[2:]:
        gragh[u[0]-1].append(j-1)
#print(gragh)
dis=[-1]*n
dis[0]=0
q.append(0)
while len(q)!=0:
    v=q.popleft()
    for i in gragh[v]:
        if dis[i]!=-1:
            continue
        dis[i]=dis[v]+1
        q.append(i)
for i,j in enumerate(dis,1):
    print(i,j)


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

int main(){
  bool a=true;
  string s;
  cin>>s;
  int size=s.size();
  string t;
  cin>>t;
  for(int i=0;i<size;i++){
    if(s[i]!=t[i]) a=false;
  }
  if(a==1) cout<<"Yes"<<endl;
  if(a==0) cout<<"No"<<endl;
}

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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

const int MAX_V = 200010;
int V,E,d[MAX_V];
struct edge{int from,to,cost;};
vector<edge> es;
void bellmanford(int s){
  //初期化
  rep(i,V){
    d[i] = INF;
  }
  d[s] = 0;

  rep(i,V){
    bool update = false;
    rep(j,es.size()){
      edge e = es[j];
      if(d[e.from]+e.cost < d[e.to]){
        d[e.to] = d[e.from] + e.cost;
        update = true;
      }
    }
    if(!update) break;
  }
}

int main(){
  cin >> V >> E;
  rep(i,E){
    int a,b;
    cin >> a >> b;
    a--;b--;
    es.push_back({a,b,1});
    es.push_back({b,a,1});
  }

  bellmanford(0);

  /*rep(i,V){
    cout << es[i].from << " " << es[i].to << " " << es[i].cost << endl;
  }
  cout << endl;*/

  if(d[V-1] == 2){
    cout << "POSSIBLE" << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 8560
#include "bits/stdc++.h"
#include<assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define MRE assert(0);
const int inf = 1e17;
const int mod = 1000000007;
typedef pair<int, int> P;
typedef pair<int, P> PP;
string s[1005];
string cpy[1006];
int modpow(int a, int x) {
	int res = 1;
	while (x) {
		if (x & 1)res = res*a%mod;
		a = a*a%mod;
		x >>= 1;
	}
	return res;
}
int moddiv(int a, int b) {//a/b
	return a*modpow(b, mod - 2) % mod;
}

signed main() {
	int h, w, k; cin >> h >> w >> k;
	rep(i, h)cin >> s[i];
	int rc = 0, cc = 0;
	rep(i, h) {
		if (s[i][w - 1] == '#'&&s[i][0] == '#')rc++;
	}
	rep(i, w) {
		if (s[0][i] == '#'&&s[h - 1][i] == '#')cc++;
	}
	int B = 0;
	rep(i, h)rep(j, w)if (s[i][j] == '#')B++;

	if (rc&&cc)cout << 1 << endl;
	else if (k == 0) {
		cout << 1 << endl;
	}
	else if (!rc && !cc) {
		cout << modpow(B, k-1) << endl;
	}
	else {
		if (rc == 0) {
			rep(i, w)cpy[i].resize(h);
			rep(i, h) {
				rep(j, w) {
					cpy[w - 1 - j][i] = s[i][j];
				}
			}
			rep(i, w)s[i] = cpy[i];
			swap(h, w);
			swap(rc, cc);
		}

		int S = 0;//
		rep(i, h) {
			rep(j, w - 1) {
				if (s[i][j] == '#'&&s[i][j + 1] == '#')S++;
			}
		}

		int T = rc;
		//A_k=A_(k-1)*B-S*T^{k-1}
		int alpha = moddiv(S, B - T);
		int res = modpow(B, k-1)*(mod + 1 - alpha) % mod + modpow(T, k-1)*alpha%mod;
		cout << res%mod << endl;
	}
}

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

int main()
{
    int X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X), B(Y), C(Z);
    for(int i = 0;i < X;i++){
        cin >> A[i];
    }
    for(int i = 0;i < Y;i++){
        cin >> B[i];
    }
    for(int i = 0;i < Z;i++){
        cin >> C[i];
    }
    vector<ll> AB(X * Y);
    for(int i = 0;i < X;i++){
        for(int j = 0;j < Y;j++){
            AB[i * Y + j] = A[i] + B[j];
        }
    }
    sort(AB.rbegin(), AB.rend());
    using pii = pair<ll, int>;
    priority_queue<pii> pq;
    for(int i = 0 ;i < Z;i++){
        pq.emplace(C[i] + AB[0], i);
    }
    vector<int> it(Z);
    for(int j = 0;j < K;j++){
        ll val;
        int id;
        tie(val, id) = pq.top(); pq.pop();
        if(++it[id] < X * Y) pq.emplace(C[id] + AB[it[id]], id);
        printf("%lld\n", val);
    }
    return 0;
}


Measured memory_bytes: 8192
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
maxA = max(A)
dp = {}
for each in A:
    dp[each] = True
for i in range(N):
    if dp[A[i]]:
        tmp = 2 * A[i]
        while maxA >= tmp:
            if tmp in dp and dp[tmp]:
                dp[tmp] = False
            tmp += A[i]
counter = 0
t = Counter(A)
for i in range(N):
    if dp[A[i]] and t[A[i]] == 1:
        counter += 1
print(counter)

Measured memory_bytes: 151580
#include <iostream>
#include <vector>
#include <bits/stdc++.h>
#include<map>
using namespace std;

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

int main(){
    // Your code here!!
    long long N,M;
    cin >>N>>M;

    if(N>=3&&M>=3){
        cout << (N-2)*(M-2) <<endl;
    }else if(N==2||M==2){
        cout << 0 <<endl;
    }else if(N==1&&M==1){
        cout << 1 <<endl;
    }else{
        if(N==1){
            cout << (M-2) <<endl;
        }
        if(M==1){
            cout << (N-2) <<endl;
        }
    }
    
}

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

int n, k, d, a, ans, v[105];
int main() {
	cin >> n >> k;
	ans = n;
	while(k--) {
		cin >> d;
		while(d--) {
			cin >> a;
			if(!v[a]) v[a] = 1, ans--;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#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)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
lint power(lint x, lint n, lint mod) {
  lint ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lint N, K;
    cin >> N >> K;
    lint ans = 0;
    FOR(i, K, N+2) {
        ans = (ans + (N+1)*(N)/2 % MOD - (N+1-i)*(N-i)/2 % MOD - (lint)i*(i-1)/2%MOD + 1 + MOD*2) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3688
S = input()
Q = int(input())
L = ''
R = ''
rev = False
for _ in range(Q):
    Query = input().split()
    if Query[0] == '1':
        rev = not rev
    else:
        if rev:
            if Query[1] == '1':
                R = R + Query[2]
            else:
                L = Query[2] + L
        else:
            if Query[1] == '1':
                L = Query[2] + L
            else:
                R = R + Query[2]
S = L + S + R
if rev:
    S = S[::-1]
print(S)


Measured memory_bytes: 4420
/*
 *  AUTHOR : MANAV PATEl
*/
#include<bits/stdc++.h>
#include<functional>
//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

namespace fastio {

	template <class T> istream &operator>>(istream &os, vector<T> & vec) {
		for (auto &u : vec)os >> u;
		return os;
	}
	template <class T> ostream &operator<<(ostream &os, const vector<T> & vec) {
		for (auto &u : vec)os << u << " ";
		return os;
	}
	template<class T1, class T2> inline istream& operator>>(istream& os, pair<T1, T2>& p) {
		return os >> p.first >> p.second;
	}
	template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
		return os << p.first << " " << p.second;
	}
	template <class T> ostream &operator<<(ostream &os, set<T> & con) {
		for (auto &u : con) os << u << " ";
		return os;
	}
	void re() {}
	template <typename T, typename... args> void re(T& x, args&... tail) {
		cin >> x;
		re(tail...);
	}
	void pr() {}
	template <typename T> void pr(const T& x) {
		cout << x;
	}
	template <typename T, typename... args> void pr(const T& x, const args&... tail) {
		cout << x << " ";
		pr(tail...);
	}
	template <typename... args> void prln(const args&... tail) {
		pr(tail...);
		cout << "\n";
	}
}
using namespace fastio;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

int main()
{
	cin.sync_with_stdio(false);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	ll n, a, b;
	re(n,a,b);
	cout<<min(n*a,b);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define removeDuplicate(a) sort(a.begin(), a.end()); a.resize(distance(a.begin(), unique(a.begin(), a.end())));

long long q, h, s, d, n; 
int main() {
    #define file "in"
    //freopen(file".inp", "r", stdin); freopen(file".out", "w", stdout);
    cin >> q >> h >> s >> d >> n; 
    h = min(h, 2 * q); 
    s = min(s, 2 * h); 
    d = min(d, 2 * s); 
    if (n & 1) cout << (n / 2) * d + (s);
    else cout << (n / 2) * d;  
    return 0;
}

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

namespace AtCoderCs
{
    class Program
    {
        static void Main()
        {

            Num = int.Parse(Console.ReadLine());
            var Dimention = 0;
            i = 0;

            for (; RunRunGetter(Dimention, -1); Dimention++) ;


        }

        static int[] RunRun = new int[0];
        static int Num;
        static int i;
        static bool RunRunGetter(int Dimention, int PreviousDimention = -1)
        {


            int Start, End;
            var NowDimention = PreviousDimention + 1;

            if (PreviousDimention == -1)
            {

                RunRun = new int[Dimention + 1];

                Start = 1;
                End = 10;

            }
            else
            {

                if (RunRun[PreviousDimention] == 9)
                {

                    Start = 8;
                    End = 10;

                }
                else if (RunRun[PreviousDimention] == 0)
                {

                    Start = 0;
                    End = 2;

                }
                else
                {

                    Start = (RunRun[PreviousDimention] - 1);
                    End = (RunRun[PreviousDimention] + 2);

                }

            }

            for (RunRun[NowDimention] = Start; RunRun[NowDimention] < End; RunRun[NowDimention]++)
            {

                if (Dimention == NowDimention)
                {
                    i++;

                    if (i == Num)
                    {

                        RunRun.ToList().ForEach(x => Console.Write(x));
                        return false;

                    }

                }
                else
                {

                    if (!RunRunGetter(Dimention, NowDimention)) return false;

                }

            }

            return true;

        }

    }
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    int A, B, C;
    cin >> A >> B >> C;
    cout << max(C - (A - B), 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(1e7)+5;

int pr[ms];

void pre()
{
    int n=1e7;
    int i,j;
    for(i=1;i<=n;i++)pr[i]=i;

    for(i=2;i*i<=n;i++)
    {
        if(pr[i]==i)
        {
            for(j=i*i;j<=n;j+=i)pr[j]=min(pr[j],i);
        }
    }
}

int main()
{
    idfc;
    pre();

    int n;
    cin>>n;

    ll ans=0;
    ll r;
    int i;
    map<int,int>mm;
    int e;
    for(i=1;i<=n;i++)
    {
        r=1;
        mm.clear();
        e=i;
        while(e>1)
        {
            mm[pr[e]]+=1;
            e/=pr[e];
        }
        for(auto it:mm)
        {
            r=r*(it.second+1);
        }
       // cout<<r<<"\n";
        r*=i;
        ans+=r;
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 42660
// Author: Mrigank
/* Science is what we understand well enough to explain to a computer, 
    Art is everything else we do - Donald E. Knuth */

#include <bits/stdc++.h>
#include <iostream>
#include <unordered_map>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <string> 
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, int> PLI;
typedef pair<int, int> PII;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < pair < ll , ll > > vpl;
typedef vector < pair < ll , bool > > vpb;
typedef vector < vector < int > > vvi;
typedef vector < vector < ll > > vvl;


#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x , val) memset(x , val , sizeof(x))
#define deb(x) cout<<#x<<" :: "<<x<<"\n"
#define deb2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define deb3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n"
#define all(x) x.begin() , x.end()
#define alls(x , y) x.begin() , x.end() , y
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl "\n"

const ll mxsize = 5e6 + 5;
const ll linf = 1e9;
const ld inf = 10000000000.0;
const ll mod = 1e9 + 7;
 
/******************************************** CODE STARTS FROM HERE *************************************************/ 

int main()
{
    fastIO;
    ll n;
    cin >> n;
    vl arr(n - 1);
    vl check(n + 1 , 0);
    ll i;
    fo(i , n - 1)
    {
        cin >> arr[i];
    }
    fo(i , n - 1)
    {
        check[arr[i]]++;
    }
    Fo(i , 1 , n + 1)
    {
        cout << check[i] << endl;
    }
}

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

int main() {
    ll n, sum = 0;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        sum += a[i];
    }
    ll toSub = (n + 1) * n / 2;
    if (sum % toSub != 0) {
        puts("NO");
        return 0;
    }
    a.push_back(a[0]);
    ll k = sum / toSub;
    ll cumul = 0;
    rep(i, n) {
        ll diff = a[i + 1] - a[i];
        // diff = k - t * n
        diff = k - diff;
        if (diff < 0 || diff % n != 0) {
            puts("NO");
            return 0;
        }
        cumul += diff / n;
    }
    cout << (cumul == k ? "YES" : "NO") << endl;
}

Measured memory_bytes: 4760
#include <stdio.h>

int serchsum(int,int,int);

int main(void)
{
    int n,s;

    while (1){
        scanf("%d %d", &n, &s);
        if (n == 0 && s == 0){
            break;
        }
        printf("%d\n",serchsum(10, n, s));
    }
    return (0);
}

int serchsum(int now, int n, int s){
    int i;
    int sum = 0;
    if (n == 1){
        if (s < now && s >= 0){
            return (1);
        }else{
            return (0);
        }
    }
    if (now < n){
        return (0);
    }
    if (s < 0){
        return (0);
    }
    for (i = now-1; i >= 0; i--){
        sum += serchsum(i, n-1, s-i);
    }
    return (sum);
}


Measured memory_bytes: 2040
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: ABC Edit
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;

  int ans = (n <= k) ? n * x : k * x + (n - k) * y;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int N,M;
vint adj[100001];
int dp[100001];
int rec(int p){
	if(dp[p]>=0) return dp[p];
	if(adj[p].empty()){
		dp[p]=0;
		return 0;
	}
	rep(i,adj[p].size()){
		dp[p]=max(dp[p],rec(adj[p][i])+1);
	}
	return dp[p];
}
int main(){
	scan(N);scan(M);
	rep(i,M){
		int a,b;
		scan(a);scan(b);
		a--; b--;
		adj[a].push_back(b);
	}
	fill(dp,dp+N,-1);
	rep(i,N) rec(i);
	int ans=0;
	rep(i,N) ans=max(ans,dp[i]);
	prin(ans);
	return 0;
}


Measured memory_bytes: 8192
import java.util.*;

public class Main{
	public static int[] solve(int[][] treasure, int W){
		int[] save = new int[W+1];
		for(int i = 0; i < treasure.length; i++){
			for(int j = W; j >= 0; j--){
				if( save[j] != 0 && j + treasure[i][1] <= W ){
					save[j+treasure[i][1]] = Math.max(treasure[i][0] + save[j], save[j+treasure[i][1]]);
				}
			}
			save[treasure[i][1]] = Math.max(treasure[i][0], save[treasure[i][1]]);
		}
		int max = 0;
		for(int i = 0; i <= W; i++){
			 if( save[max] < save[i] ){
			 	max = i;
			 }
		}
	
		int[] ans = new int[2];
		ans[0] = save[max];
		ans[1] = max;
		return ans;
	}
		
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int index = 0;
		int W;
		while( (W = stdIn.nextInt()) != 0 ){
			int n = stdIn.nextInt();
			int[][] treasure = new int[n][2];
			for(int i = 0; i < n; i++){
				String[] s = stdIn.next().split(",");
				treasure[i][0] = Integer.parseInt(s[0]);
				treasure[i][1] = Integer.parseInt(s[1]);
			}
			int[] ans = solve(treasure, W);
			System.out.println("Case " + (++index) + ":");
			System.out.println(ans[0]);
			System.out.println(ans[1]);
		}
	}
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
typedef pair<ll,ll> pll;

#define reps(i,f,n) for(int i = int(f); i <= int(n); i++)
#define rep(i,n) reps(i,0,int(n)-1)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)

#define all(x) (x).begin(),(x).end()
#define X first
#define Y second

#define sz size()
#define eb emplace_back
#define pb push_back

vector<int> l,r;
vector<int> ans;
const bool DBG = false;

int main(void){
  string s;
  cin >> s;
  int n = s.size();
  l.resize(n);
  r.resize(n);
  ans.resize(n);
  rep(i,n){
    if(s[i] == 'R') r[i] = i;
    else r[i] = r[i-1];
  }
  for(int i = n-1; i >= 0; i--){
    if(s[i] == 'L') l[i] = i;
    else l[i] = l[i+1];
  }
  if(DBG){
    rep(i, n){
      printf("%3d", r[i]);
    }puts("");
    rep(i, n){
      printf("%3d", l[i]);
    }puts("");
  }
  rep(i, n){
    if(s[i] == 'R'){
      if((l[i]-i)%2==0){
        ans[l[i]]++;
        if(DBG)cout << l[i] << endl;
      }else{
        ans[l[i]-1]++;
        if(DBG)cout << l[i]-1 << endl;
      }
    }else{
      if((i-r[i])%2 == 0){
        ans[r[i]]++;
        if(DBG)cout << r[i] << endl;
      }else{
        ans[r[i]+1]++;
        if(DBG)cout << r[i]+1 << endl;
      }
    }
  }

  rep(i, n){
    cout << ans[i] << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

	/* ----- 変数宣言 ----- */
	int n;
	cin >> n;

	vector<vector<int>> a(2, vector<int>(n, 0));

	vector<int> ame(n);

	int x;
	int y;

	int i;

	int ans=0;


	/* ----- 入力 ----- */
	for (i = 0; i<n; i++) {
		cin >> a[0][i];
	}
	for (i = 0; i<n; i++) {
		cin >> a[1][i];
	}

	/* ----- 計算 ----- */
	for (x = 0; x < n; x++) {
		ans = 0;
		y = 0;
		for (i = 0; i < n; i++) {
			ans += a[y][i];
			if (i == x) {
				y = 1;
				ans += a[y][i];
			}
		}
		ame[x] = ans;
	}

	sort(ame.begin(), ame.end());

	ans = ame.back();

	cout << ans << endl;
}

Measured memory_bytes: 256
'use strict';
function main(input) {
  input = input.split(" ");
  const p = Number(input[0]) + Number(input[1]);
  const m = Number(input[0]) - Number(input[1]);
  const t = Number(input[0]) * Number(input[1]);

  console.log(Math.max(p, m, t));

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


Measured memory_bytes: 7372
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
 
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		Main m = new Main();
		//*
		m.input();
		m.solve();
		m.output();
		/*/
		m.debug();
		//*/
	}
	
	public void debug() {
	}
	
	/*
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	/*/
	InputUtil in = new InputUtil();
	//*/
	PrintWriter out = new PrintWriter(System.out);
	int N = 0;
	int[] C = null;
	int[] S = null;
	int[] F = null;
	int[] ans = null;

	public void input() throws IOException {
		/*
		String[] tmp = br.readLine().split(" ");
		A = Integer.parseInt(tmp[0]);
		B = Integer.parseInt(tmp[1]);
		S = br.readLine().toCharArray();
		/*/
		N = in.nextInt();
		C = new int[N];
		S = new int[N];
		F = new int[N];
		ans = new int[N];
		for(int i=0; i<N-1; i++) {
			C[i] = in.nextInt();
			S[i] = in.nextInt();
			F[i] = in.nextInt();
			ans[i] = 0;
		}
		//*/
	}
	
	public void solve() throws IOException {
		for(int i=0; i<N-1; i++) {
			for(int j=0; j<=i; j++) {
				ans[j] = Math.max(S[i],ans[j]);
				int tmp = (ans[j] % F[i] == 0)?0:F[i];
				ans[j] = ans[j] / F[i] * F[i] + tmp;
				ans[j] += C[i];
			}
		}
	}
	
	
	public void output() {
		for(int i=0; i<N; i++) {
			out.println(ans[i]);
		}
		out.flush();
	}
}

//*
class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }
 
	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}
 
	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}
}
//*/

Measured memory_bytes: 20948
#include <stdio.h>
int main(void){
         int sum,a,b;
        while(scanf("%d %d",&a,&b)!=EOF){
       
        
        sum=a+b;
        
        if(0<=sum&&sum<=9)
        printf("1\n");
        if(10<=sum&&sum<=99)
        printf("2\n");
        if(100<=sum&&sum<=999)
        printf("3\n");
        if(1000<=sum&&sum<=9999)
        printf("4\n");
        if(10000<=sum&&sum<=99999)
        printf("5\n");
        if(100000<=sum&&sum<=999999)
        printf("6\n");
        if(1000000<=sum&&sum<=9999999)
        printf("7\n");
        }
}




Measured memory_bytes: 2036
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    for (int i = 0; i < n; i++) {
        int tem = 0;
        for (int k = 0; k < m; k++) {
            tem += a[i][k] * b[k];
        }
        tem += c;

        if (0 < tem) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var count = 0;
            var a = input[0];
            var b = input[1];
            if(a == 2){
                count = b - 1;
            }else{
                count = b / (a - 1);
            count = b % (a - 1) > 1 ? count + 1 : count;
            }

            Console.WriteLine(count);
        }
    }
}


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  int N; cin >> N;
  map<string, ll> ana;
  rep(i,N) { 
    string s; cin >> s; 
    char tmp[10]; rep(j,10) tmp[j]=s[j];
    sort(tmp,tmp+10);
    string ss = ""; rep(j,10) ss+=tmp[j];
    ana[ss]++; 
    // cout << ss << endl;
    }
    ll result = 0;
    for (auto x: ana) result += x.second*(x.second-1)/2;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <cmath>

using namespace std;

int main(void) {

	int X;
	cin >> X;
	int xm = (int)sqrt(X);

	int	vmax = 0;
	for (int n = 1; n <= xm; n++) {
		for (int power = 2; power <= 10; power++) {
			double v = pow((double)n, (double)power);
			if (v > X) {
				break;
			}
			if (v > vmax) {
				vmax = v;
			}
		}
	}

	cout << vmax << endl;

	return 0;
}



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;
using P =pair<int,int>;

int main(){
	int N;
	string S;
	cin>>N>>S;
	int id=0;
	int max=0;
	rep(i,N){
		if(S.at(i)=='I'){
			id++;
		}else{
			id--;
		}
		if(id>max){
			max=id;
		}
	}
	cout<<max;
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    int x, a;
    cin >> x >> a;
    if (x < a) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

void prime_map(map<ll, ll> &m, ll num) {
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }

    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }
        return;
    } else {
        prime_map(m, num);
    }
}


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


void solve(long long N, long long K, long long R, long long S, long long P, std::string T){
    ll sum=0;
    rep(i,N){
        if(i>=K){
            (T[i]==T[i-K])?T[i]='x':1;
        }
    }
    rep(i,N){
            if(T[i]=='r') sum+=P;
            else if(T[i]=='s') sum+=R;
            else if(T[i]=='p') sum+=S;
    }
    
    cout<<sum<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long R;
    scanf("%lld",&R);
    long long S;
    scanf("%lld",&S);
    long long P;
    scanf("%lld",&P);
    std::string T;
    std::cin >> T;
    solve(N, K, R, S, P, T);
    return 0;
}


Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = []
c = []
for i in range(q):
    _ = list(map(int, input().split()))
    c.append(_[1])
    b.append(_[0])

s = sum(a)

# 辞書型で度数を持つ
hist = {}
for i in range(n):
    if a[i] in hist:
        hist[a[i]] += 1
    else:
        hist[a[i]] = 1
# print(hist)

for i in range(q):
    diff = c[i] - b[i]
    if b[i] in hist:
        s += hist[b[i]]*diff
        print(s)
        if c[i] in hist:
            hist[c[i]] += hist[b[i]]
            del hist[b[i]]
        else:
            hist[c[i]] = hist[b[i]]
            del hist[b[i]]
    else:
        print(s)
    # print(hist)


Measured memory_bytes: 26880
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
    char a;
    int ans = 0;
    for (int i = 0; i < 4; i++){
        cin >> a;
        if (a == '+')ans++;
        else ans--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll N,K;
	cin>>N>>K;
	vector<ll> A(N);
	FDS(i,N){
		cin>>A[i];
	}
	VSORT(A);
	int k=1;
	FDS(i,N-1){
		if(A[i]!=A[i+1]){
			k++;
		}
	}
	vector<int> kazu(k);
	FDS(i,k){
		kazu[i]=1;
	}
	int j=0;
	FDS(i,N-1){
		if(A[i]==A[i+1]){
			kazu[j]++;
		}
		else{
			j++;
		}
	}

	VSORT(kazu);
	VREV(kazu);
	if(K>=k){
	    cout<<0<<endl;
	}
	else{
	    int ans=0;
	    for(int i=K;i<k;i++){
	        ans+=kazu[i];
	    }
	    cout<<ans<<endl;
	}
}

Measured memory_bytes: 2560
# ある学校には、N 人の生徒がいます。
# 生徒たちをいくつかのグループに分け、グループごとにあるテーマについて話し合ってもらうこととなりました。
# あなたは、2 人以下のグループだと効果的な話し合いが出来ないと考えており、
# なるだけ多くのグループを 3 人以上にしたいです。
# 生徒たちを上手く分けて、3 人以上のグループの数を最大化してください。

n = gets.to_i
puts n / 3

Measured memory_bytes: 1788
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)

func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func()
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx++
		return cur
	}
	this.initWordIdx = func() {
		idx = 0
	}
	return &this
}

func (me *ReaderEx) ScanAndSplit() (isScanned bool) {
	isScanned = me.baseScanner.Scan()

	me.words = strings.Fields(me.baseScanner.Text())
	me.initWordIdx()
	return
}

func (me *ReaderEx) Scan() (ok bool) {
	ok = me.baseScanner.Scan()
	return
}
func (me *ReaderEx) getString() string {
	return me.baseScanner.Text()
}

func (me *ReaderEx) getInt() int {
	n, err := strconv.Atoi(me.baseScanner.Text())
	defer func() {
		if err != nil {
			panic(err)
		}
	}()

	return n
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, fa)
		}
	}
	if n > 1 {
		facts = append(facts, factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}
func solve(stdin io.Reader, stdout io.Writer) {
	r := NewScannerEx(stdin)
	r.Scan()
	n := r.getInt()
	ans := 0
	shift := uint(0)
	for n != 0 {
		m := (n + 2) % 4
		m = ((m + 4) % 4) ^ 2
		ans |= m << shift
		n = int(math.Floor(float64(n+2) / 4))
		shift += 2
	}

	for _, v := range dec2bin(ans) {
		var out byte
		if v {
			out = '1'
		} else {
			out = '0'
		}
		fmt.Fprint(stdout, string(out))
	}
	fmt.Fprintln(stdout)
}



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

int a[100001];

struct Event {
    int time,num;
    Event(int t,int n) : time(t), num(n) {;}
};

bool operator<(const Event &e,const Event &f) {
    return e.time > f.time;
}

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

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

    if(n == 1) {
        cout<<a[0]<<endl;
        return 0;
    }
    priority_queue<Event> q;
    if(a[0] > a[1])
        q.push(Event(l-a[0],0));

    for(int i=1; i<n-1; ++i) {
        if(a[i] > a[i-1] && a[i] > a[i+1])
            q.push(Event(l-a[i],i));
    }
    if(a[n-1] > a[n-2]) {
        q.push(Event(l-a[n-1],n-1));
    }

    int cnt = 0,ans = 0;

    while(!q.empty()) {
        Event e = q.top(); q.pop();
        if(a[e.num] == 0) continue;
        cnt++; a[e.num] = 0;
        if(cnt == n) ans = e.time;
        if(e.num-1 >= 0 && a[e.num-1] != 0) {
            if(e.num-1 == 0 || a[e.num-2] < a[e.num-1])
                q.push(Event(e.time+l-a[e.num-1],e.num-1));
        }
        if(e.num+1 < n && a[e.num+1] != 0) {
            if(e.num+1 == n-1 || a[e.num+2] < a[e.num+1])
                q.push(Event(e.time+l-a[e.num+1],e.num+1));
        }
    }

    cout<<ans<<endl;
}

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


vector<bool> seen;//訪れたか否か
int count1 = 1;//今まで幾つの頂点に訪れたか

int DFS(vector<vector<int>> &G, int v, int N){  
  
  bool all_seen = true;//全て訪れたかの判定
  for(int i = 0; i < N; i++){
     if(!seen[i]){
       all_seen = false;
     }
  }
  
  

  
  if(all_seen){
    return 1;
    //全て訪れたなら１を返す
  }
  
  int ans = 0;
  //vから行ける場所に行く
  for(int next_v: G[v]){
    if(seen[next_v]) continue;//既に訪れているなら別の頂点へ
    
    seen[next_v] = true;//頂点vは訪れた
    ans += DFS(G, next_v, N);
    seen[next_v] = false;//頂点vに訪れたことをリセット
  }
 
  return ans;
}
 
  

int main(){
  int N, M;
  cin >> N >> M;
  
 //グラフの受け取り
  vector<vector<int>> G(N);
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  
  seen.assign(N, false);
  seen[0] = true;
  cout << DFS(G, 0, N) << endl;
}
  

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

namespace _0087
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                string line = Console.ReadLine();
                if (string.IsNullOrEmpty(line)) return;

                string[] items = line.Trim().Split(' ');
                Stack<double> st = new Stack<double>();

                foreach (var item in items)
                {
                    int res;
                    if (int.TryParse(item, out res)) st.Push(res);
                    else
                    {
                        double d2 = st.Pop();
                        double d1 = st.Pop();
                        switch (item)
                        {
                            case "+":
                                st.Push(d1 + d2);
                                break;
                            case "-":
                                st.Push(d1 - d2);
                                break;
                            case "*":
                                st.Push(d1 * d2);
                                break;
                            case "/":
                                st.Push(d1 / d2);
                                break;
                        }
                    }
                }
                Console.WriteLine(st.Pop());
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}



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

int main() {
  int A = 0, a = 0, a2 = 0,b = 0,b2 = 0,c = 0,d = 0;
  cin >> A;

  a = A / 1000;
  a2 = a * 1000;
  
  b = A - a2;
  b = b / 100;
  b2 = b * 100;
  
  c = A - a2 - b2;
  c = c / 10;
  
  d = A - a2 -b2 - c * 10;

  if((a == b)&&(b == c)){
    cout << "Yes" << endl;
  }
  else if((b == c)&&(c == d)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
constexpr long INF = 1LL << 60;

long n, a[404], dp[404][404];

long rec(int l, int r) {
  if(l == r) return 0;
  if(~dp[l][r]) return dp[l][r];

  long ret = INF;
  for(int i = l; i < r; ++i) 
    chmin(ret, rec(l, i) + rec(i+1, r) + a[r+1] - a[l]);
  return dp[l][r] = ret;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    for(int i = 0; i < n; ++i) a[i+1] += a[i];
    for(int i = 0; i < n; ++i) for(int j = 0; j < n; ++j) dp[i][j] = -1;
    cout << rec(0, n-1);
    return 0;
}

Measured memory_bytes: 1536