akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#define MAXN 100
#define MOD 1000000007
int b[4][4][4][4];
int d[101][4][4][4][4];

int main(){
//  freopen("in.in", "r", stdin);
//  freopen("out.out", "w", stdout);
  int n, i, j, k, l, p, m, rez = 0;
  scanf("%d", &n);
  if(n == 3)
    printf("61");
  else{
    for(i = 0; i < 4; i++){
      for(j = 0; j < 4; j++)
        for(k = 0; k < 4; k++)
          for(l = 0; l < 4; l++)
            b[i][j][k][l] = 1;
    }
    b[0][0][1][2] = b[1][0][1][2] = b[2][0][1][2] = b[3][0][1][2] = 0;
    b[0][1][2][0] = b[0][1][2][1] = b[0][1][2][2] = b[0][1][2][3] = 0;
    b[0][0][1][2] = b[0][1][1][2] = b[0][2][1][2] = b[0][3][1][2] = 0;
    b[0][1][0][2] = b[0][1][1][2] = b[0][1][2][2] = b[0][1][3][2] = 0;
    b[0][2][1][0] = b[0][2][1][1] = b[0][2][1][2] = b[0][2][1][3] = 0;
    b[0][0][2][1] = b[1][0][2][1] = b[2][0][2][1] = b[3][0][2][1] = 0;
    b[1][0][2][0] = b[1][0][2][1] = b[1][0][2][2] = b[1][0][2][3] = 0;
    b[0][1][0][2] = b[1][1][0][2] = b[2][1][0][2] = b[3][1][0][2] = 0;
    for(i = 0; i < 4; i++)
      for(j = 0; j < 4; j++)
        for(k = 0; k < 4; k++)
          for(l = 0; l < 4; l++)
            d[4][i][j][k][l] = b[i][j][k][l];
    for(p = 5; p <= n; p++){
      for(i = 0; i < 4; i++){
        for(j = 0; j < 4; j++){
          for(k = 0; k < 4; k++){
            for(l = 0; l < 4; l++){
              for(m = 0; m < 4; m++){
                d[p][i][j][k][l] += b[i][j][k][l] * d[p - 1][m][i][j][k];
                if(d[p][i][j][k][l] >= MOD)
                  d[p][i][j][k][l] -= MOD;
              }
            }
          }
        }
      }
    }
    rez = 0;
    for(i = 0; i < 4; i++){
      for(j = 0; j < 4; j++){
        for(k = 0; k < 4; k++){
          for(l = 0; l < 4; l++){
            rez += d[n][i][j][k][l];
              if(rez >= MOD)
                rez -= MOD;
          }
        }
      }
    }

    printf("%d", rez);
  }
  return 0;
}


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

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int N, H; cin >> N >> H;
    vector<int> a(N), b(N);
    for (int i = 0; i < N; i++) cin >> a[i] >> b[i];

    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());

    int a_max = a[0];

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (b[i] < a_max) break;

        H -= b[i];
        cnt++;

        if (H <= 0) {
            cout << cnt << '\n';
            return;
        }
    }

    cnt += (H + a_max - 1) / a_max;

    cout << cnt << '\n';
}

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

    solve();

    return 0;
}

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

using namespace std;

#define DEBUG

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

template<typename T>
inline std::ostream &operator << (std::ostream & os, const std::vector<T>& v)
{
    bool first = true;
    os << "[";
    for(unsigned int i = 0; i < v.size(); i++)
    {
        if(!first)
            os << ", ";
        os << v[i];
        first = false;
    }
    return os << "]";
}

template<typename T>
inline std::ostream &operator << (std::ostream & os, const std::set<T>& v)
{
    bool first = true;
    os << "[";
    for (typename std::set<T>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if(!first)
            os << ", ";
        os << *ii;
        first = false;
    }
    return os << "]";
}

template<typename T1, typename T2>
inline std::ostream &operator << (std::ostream & os, const std::map<T1, T2>& v)
{
    bool first = true;
    os << "[";
    for (typename std::map<T1, T2>::const_iterator ii = v.begin(); ii != v.end(); ++ii)
    {
        if(!first)
            os << ", ";
        os << *ii ;
        first = false;
    }
    return os << "]";
}

struct debugger
{
	bool first;

	debugger() {
		first = true;
	}

    template<typename T> debugger& operator , (const T& v)
    {
    	if (!first) cout << ", ";
        cout << v;
        first = false;
        return *this;    
    }
};

// Debug macro that prints out "expression: value" for clarity
#ifdef DEBUG
    #define debug(args...)          { cout << #args << ": "; (debugger()), args; cout << endl; }
#else
    #define debug(args...)
#endif

#define int long long

// Union-Find Disjoint-Sets data structure with path compresion and efficient union
// class UnionFind {
//     private:
//         vector<int> p, rank;
//     UnionFind(int n) {
//         rank.assign(n, 0);
//         for (int i = 0; i < n; i++) {
//             p[i] = i;
//         }
//     }
//     int findSet(int i) {
//         return (p[i] == i) : i ? (p[i] = findSet(i));
//     }
//     int unionSet(int i, int j) {
//         int x = findSet(i), y = findSet(j);
//         if (x != y) {
//             if (rank[x] < rank[y]) p[x] = y;
//             else {
//                 p[y] = x;
//                 if (rank[x] == rank[y]) rank[y]++;
//             }
//         }
//     }
// }

int32_t main(void) {
    string s; cin >> s;
    int ans = s.size();
    for (int i = 0; i < s.size() - 1; i++) {
        if (s[i] != s[i + 1]) {
            ans = min(ans, max(i + 1, (int)s.size() - i - 1));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int main(){
    int N ,M;
    cin >> N >> M;
    
    int A[100]={};
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        A[a]++;
        A[b]++;
    }
    
    for (int i = 1; i <= N; i++) {
        cout << A[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )
import Data.List

import qualified Data.Vector.Unboxed as U

cReadLn :: IO Int
cReadLn = fst . fromJust . C.readInt <$> C.getLine

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,k] <- getParms
  as    <- getParms
  print $ f k as

f :: Int -> [Int] -> Int
f k as 
  | k >= l = 0 -- There are enough, no need to rewrite.
  | k <  l = g ns (l-k) 0
  where
    as' = map U.fromList . group . sort $ as
    l   = length as' -- # of kinds.
    ns  = U.fromList . sort . map U.length $ as' -- A list of # of kinds.

    g :: U.Vector Int -> Int -> Int -> Int
    g _ 0 x = x -- Assuming k<=n.
    g v k x = g (U.tail v) (k-1) (x + U.head v)

Measured memory_bytes: 55676
N, K = map(int, input().split())
p = list(map(int, input().split()))

sum_k = [0] * N
tmp = 0
for i in range(K):
    tmp += p[i]
sum_k[0] = tmp
max_sum = tmp
candidate = 0
for i in range(len(p)-K):
    sum_k[i+1] = sum_k[i] - p[i] + p[i+K]
    if max_sum < sum_k[i+1]:
        max_sum = sum_k[i+1]
        candidate = i+1


dice = [-1] * 10000

ans = 0
for i in range(candidate, candidate + K):
    tmp = 0
    if dice[p[i]+1] != -1:
        ans += dice[p[i]+1]
        continue
    for j in range(1, p[i]+1):
        tmp += j * (1 / p[i])
    dice[p[i]+1] = tmp
    ans += tmp
print(ans)

Measured memory_bytes: 25732
#include <iostream>
#include <algorithm>
#define llint long long

using namespace std;

llint L, n;
llint x[200005];
llint d[200005], sumd[200005];

llint calc()
{
	llint ret = 0, sum = 0;
	llint s = n-n/2, l = 2*s-n;
	for(int i = s+1, t = 0; i <= n; i++, t+=2) sum += t*d[i];
	for(int i = s, t = 1; i > l; i--, t+=2) sum += t*d[i];
	for(int i = 1; i <= l; i++) sum += (2*(n-s)-1)*d[i];
	
	ret = sum;
	for(int i = s+2; i <= n; i++){
		sum -= (sumd[n]-sumd[i-1])*2;
		sum += d[i-1];
		sum -= sumd[l+1]*2;
		sum += (sumd[i-2]-sumd[l+2])*2;
		l+=2;
		ret = max(ret, sum);
	}
	
	
	sum = 0;
	s = n-n/2, l = 2*s-n-1;
	for(int i = s+1, t = 1; i <= n; i++, t+=2) sum += t*d[i];
	for(int i = s, t = 0; i > l; i--, t+=2) sum += t*d[i];
	for(int i = 1; i <= l; i++) sum += 2*(n-s)*d[i];
	
	ret = max(ret, sum);
	for(int i = s+2; i <= n; i++){
		sum -= (sumd[n]-sumd[i-1])*2;
		sum -= d[i-1];
		sum -= sumd[l+1]*2;
		sum += (sumd[i-2]-sumd[l+2])*2;
		l+=2;
		ret = max(ret, sum);
	}
	
	return ret;
}

int main(void)
{
	cin >> L >> n;
	for(int i = 1; i <= n; i++) cin >> x[i];
	for(int i = 1; i <= n; i++) d[i] = x[i] - x[i-1];
	d[n+1] = L-x[n];
	n++;
	
	for(int i = 1; i <= n; i++) sumd[i] = sumd[i-1] + d[i]; 
	llint ans = calc();
	
	//for(int i = 1; i <= n; i++) cout << d[i] << " "; cout << endl;
	
	reverse(d+1, d+n+1);
	for(int i = 1; i <= n; i++) sumd[i] = sumd[i-1] + d[i]; 
	ans = max(ans, calc());
	
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int a, b, c, d, e, n, m, k;
string s, t, r;
char c1, c2, c3;

int A[200005];
int B[200005];
int C[200005];

int main() {
	cin >>s;
  	if (s == "RRR") cout <<3<<endl;
  	else if (s == "RRS" or s == "SRR") cout <<2<<endl;
  	else if (s == "SSS") cout <<0<<endl;
  	else cout <<1<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
  int n,ans=0;
  cin>>n;
  vector<int> v(2*n);
  rep(i,2*n) cin>>v[i];
  sort(v.begin(),v.end());
  rep(i,n){
    ans+=v[2*i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
MOD = 10**9+7

n, a, b = map(int, input().split())


def cmb(n, r, mod):
    x = 1
    y = 1
    for i in range(1, r + 1):
        x = (x * (n - i + 1)) % MOD
        y = (y * i) % MOD

    return (x * pow(y, MOD - 2, MOD)) % MOD


ans = pow(2, n, MOD) - 1 - cmb(n, a, MOD) - cmb(n, b, MOD)
if ans < 0:
    while ans < 0:
        ans += MOD
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

#ifdef LOCAL
clock_t timer = clock();
#endif

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string a, b;
	cin >> a >> b;
	pair<int, pi> dp[a.size() + 1][b.size()+ 1];
        for(int i = 0; i <= a.size(); i++){
                for(int j = 0; j <= b.size(); j++){
                        dp[i][j] = {-1, {0, 0}};
                }
        }
        dp[0][0] = {0, {0, 0}};
	for(int i = 0; i < a.size(); i++){
		for(int j = 0; j < b.size(); j++){
			if(a[i] == b[j]){
				dp[i + 1][j + 1] = max(dp[i + 1][j + 1], mp(dp[i][j].fi + 1, mp(i, j)));
			}
			dp[i][j + 1] = max(dp[i][j + 1], mp(dp[i][j].fi, mp(i, j)));
			dp[i + 1][j] = max(dp[i + 1][j], mp(dp[i][j].fi, mp(i, j)));
		}
	}
	pair<int, pi> ans = mp(0, mp(0, 0));
	for(int i = 0; i <= a.size(); i++){
		for(int j = 0; j <= b.size(); j++){
			ans = max(ans, mp(dp[i][j].fi, mp(i, j)));
		}
	}
	pi cur = ans.se;
	string answer = "";
	while(!(cur.fi == 0 && cur.se == 0)){
		int i = cur.fi;
		int j = cur.se;
		pi prev = dp[i][j].se;
		if(prev == mp(i - 1, j - 1)){
			answer += a[i - 1];
		}
		cur = prev;
	}
	if(answer.size() == 0) answer = " ";
	reverse(all(answer));
	cout << answer << endl;
#ifdef LOCAL
        cout << "Total Time: " << (double)(clock() - timer) / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 105856
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

template <typename T>
std::vector<int> sort_indexes(const std::vector<T> &v) {
  std::vector<int> idx(v.size());
  std::iota(idx.begin(), idx.end(), 0);
  std::sort(idx.begin(), idx.end(), [&v](int i1, int i2) {return v[i1] < v[i2];});
  return idx;
}


signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	std::set<int> set;
	auto idx=sort_indexes(a);
	set.emplace(-1);
	set.emplace(n);
	int ans=0;
	rep(i,n) {
		auto x=set.emplace(idx[i]).first;
		ans+=(*x-*std::prev(x))*(*std::next(x)-*x)*a[idx[i]];
	}
	print(ans);
	return 0;
}


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

int main(){

  int n, l;
  string s[100];

  cin>>n>>l;
  for(int i=0;i<n;i++) cin>>s[i];

  sort(s, s+n);

  for(int i=0;i<n;i++) cout<<s[i];
  cout<<endl;

  return 0;
}


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

namespace AtTest.ABC_175
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            long[] xkd = ReadLongs();
            long x = xkd[0];
            long k = xkd[1];
            long d = xkd[2];
            x = Abs(x);
            long cnt = x / d;
            if (cnt > k)
            {
                WriteLine(x - k * d);
            }
            else
            {
                x = x % d;
                k -= cnt;
                if (k % 2 == 0)
                {
                    WriteLine(x);
                }
                else
                {
                    WriteLine(d - x);
                }
            }
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27316
#include "bits/stdc++.h"
using namespace std;

//wierd debugging stuff
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n" ; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
//end of weird debugging stuff
using ll = long long;
using ld = long double;
using vi = vector<int>;
using ii = pair<int,int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
 
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define fo(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define foe(i,x) for(auto& i: x)
#define ar array
#define pb push_back
#define vt vector

template<class T> bool umin(T& a,const T& b){return b<a?a=b,1:0;}
template<class T> bool umax(T& a,const T& b){return b>a?a=b,1:0;}

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
	cin >> x;
}
void read(double& d) {
	string t;
	read(t);
	d=stod(t);
}
void read(long double& d) {
	string t;
	read(t);
	d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
	read(h);
	read(t...);
}
template<class A> void read(vt<A>& x) {
	foe(a, x)
		read(a);
}

// no change 
const ll MOD = 1e9+7;  
int n;
void Titan(){
	read(n);
	vi v(n);
	foe(a,v)cin >> a;
	int ans = 1e9;
	fo(i,1,101){
		int cur = 0;
		foe(x,v)
			cur += (x - i)* (x -i);

		umin(ans,cur);
	}

	cout << ans;
	
}

int main() {
	FASTER;
	int T = 1;
	//cin >> T;		//cmt if one test case
    fo(T)Titan();
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
//llじゃなく

int main(){
  int n;cin>>n;
  if(n==7||n==5||n==3){
    cout << "YES" <<endl;
  }else{
    cout << "NO" << endl;
  }
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int x = l[0], a = l[1], b = l[2];

            Console.WriteLine(Math.Abs(x-a)<Math.Abs(x-b) ? "A":"B");
        }
    }
}


Measured memory_bytes: 13268
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, -1, sizeof(mat))
typedef long long ll;
int a[100005];
int t[100005];
int N, L; 
int dfs(int x) {
  if(t[x] != -1) return t[x];
  if(x == 0) {
    if(a[x] > a[x+1]) {
      return t[x] = L - a[x];
    } else {
      return t[x] = L - a[x] + dfs(x+1);
    }
  } else if(x == N - 1) {
    if(a[x] > a[x-1]) {
      return t[x] = L - a[x];
    } else {
      return t[x] = L - a[x] + dfs(x-1);
    }
  } else {
    if(a[x] > a[x-1] && a[x] > a[x+1]) {
      return t[x] = L - a[x];
    } else if(a[x] > a[x-1]){
      return t[x] = L - a[x] + dfs(x+1);
    } else if(a[x] > a[x+1]) {
      return t[x] = L - a[x] + dfs(x-1);
    } else {
      return t[x] = L - a[x] + max(dfs(x-1), dfs(x+1));
    }
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> L;
  CLR(t);
  FOR(i,0,N) cin >> a[i];
  FOR(i,0,N) {
    if(t[i] == -1) {
      t[i] = dfs(i);
    }
  }
  int ans = 0;
  FOR(i,0,N) ans = max(ans, t[i]);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5980
/* attention to overflow */
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <queue>
#include <sstream>
#include <set>
#include <map>
#define dump(x) cerr<< #x << " = " << x <<endl

using namespace std;
const int INF=1<<25;
void io(){ cin.tie(0);ios::sync_with_stdio(false);}
/*printf("%.9Lf\n",cf);*/
const int MOD=1000000007;

string get_aizunyan(string s){
	string t=s;
	reverse(t.begin(),t.end());
	int first=s.find('A',0);
	int second=t.find('Z',0);
	//cerr<<first<<' '<<second<<endl;
	if(first != string::npos && second != string::npos && first+second<=s.size()-2 ){
		int length=s.size()-2-first-second;
		string t=s.substr(first+1,length);
		return t;
	}
	return "?";
}

int main(){
	io();
	string s;
	getline(cin,s);

	int num=0;
	while(1){
		s=get_aizunyan(s);
		reverse(s.begin(),s.end());
		if(s=="?"){
			//cout<<s<<endl;
			break;
		}else{
			num++;
		}
	}

	if(num==0){
		cout<<-1<<endl;
	}else{
		for(int i=0;i<num;i++){
			cout<<"AZ";
		}
		cout<<endl;
	}


	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1e9+7;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    ll N, K;
    cin >> N >> K;

    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
    }

    ll count1 = 0;
    ll count2 = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (A[i] > A[j]) {
                count2 ++;
            }
        }
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i >= j) continue;
            if (A[i] > A[j]) {
                count1 ++;
            }
        }
    }


    ll ans = count1 * K % MOD;
    ans += (count2 % MOD) *((K*(K-1)/2) % MOD);
    ans %= MOD;
    cout << ans << endl;

    return 0;
}

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

	int main(){
		vector<int>coordinate;
		int a, k;
		for(int i=0; i<5; i++){
			cin >> a;
			coordinate.push_back(a);
		}
		cin >> k;
		if(coordinate[4] - coordinate[0] > k){
			cout << ":(" << endl;
		}
		else if(coordinate[4] - coordinate[0] <= k){
			cout << "Yay!" << endl;
		}
		return 0;
	}

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

int main(){
    string s;
    cin >> s;
    int len = s.size();
    set<char> c;
    for(auto x: s)
        c.insert(x);
    cout << (c.size() == len ? "yes" : "no") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
using namespace std;
ll n,m,a[1000][1000],ans=0,cnt[40],k;
int32_t main(){
    cin>>n;
    cin>>m;
    for(ll i=0;i<n;i++)
    {
        cin>>k;
        for(ll j=0;j<k;j++){
            cin>>a[i][k];
            cnt[a[i][k]]++;
    }
    }
    sort(cnt,cnt+m+1);
    for(ll i=30;i>0;i--)
        if(cnt[i]==n){
 ans++;
        }
 cout<<ans;
 return 0;}


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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (abs(c - a) <= d || (abs(b - a) <= d && abs(c - b) <= d) ? "Yes" : "No");
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

やるだけ
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 2019;
int n, m, ts, root, st[N][N], fn[N][N], G[N][N], M[N], M2[N];
vector < int > Adj[N], Ag[N];
void DFS(int v, int p, int rt)
{
    st[rt][v] = ts ++;
    for (int &u : Adj[v])
        if (u != p)
            DFS(u, v, rt);
    fn[rt][v] = ts;
}
inline bool CMP(int v, int u)
{
    return (st[root][v] < st[root][u]);
}
int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i < n; i++)
    {
        int v, u;
        scanf("%d%d", &v, &u);
        Adj[v].pb(u);
        Adj[u].pb(v);
    }
    for (int i = 1; i <= m; i++)
    {
        int v, u;
        scanf("%d%d", &v, &u);
        G[v][u] = G[u][v] = 1;
        Ag[v].pb(u);
        Ag[u].pb(v);
    }
    for (int i = 1; i <= n; i++)
        DFS(i, 0, i), ts = 0;
    for (int _ = 1; _ <= n + 5; _ ++)
    {
        for (int v = 1; v <= n; v++)
            for (int i = 0; i < (int)Ag[v].size(); i++)
                if (!G[v][Ag[v][i]])
                    swap(Ag[v][i], Ag[v].back()), Ag[v].pop_back(), i --;
        for (int v = 1; v <= n; v++)
        {
            root = v;
            sort(Ag[v].begin(), Ag[v].end(), CMP);
            Ag[v].resize(unique(Ag[v].begin(), Ag[v].end()) - Ag[v].begin());
            vector < int > vec, oks; vec = Ag[v];
            for (int i = 0; i < vec.size(); i++)
            {
                int &u = vec[i];
                while (oks.size() && !(st[v][oks.back()] <= st[v][u] && fn[v][u] <= fn[v][oks.back()]))
                    oks.pop_back();
                if (G[v][u] && oks.size())
                {
                    G[v][u] --; G[u][v] --;
                    G[u][oks.back()] ++; G[oks.back()][u] ++;
                    Ag[u].pb(oks.back());
                    Ag[oks.back()].pb(u);
                }
                if (G[v][u])
                    oks.pb(u);
            }
        }
    }
    for (int v = 1; v <= n; v++)
        for (int i = 0; i < (int)Ag[v].size(); i++)
            if (!G[v][Ag[v][i]])
                swap(Ag[v][i], Ag[v].back()), Ag[v].pop_back(), i --;
    int tot = 0;
    for (int v = 1; v <= n; v++)
    {
        queue < int > qu;
        memset(M, 0, sizeof(M));
        memset(M2, 0, sizeof(M2));
        qu.push(v); M2[v] = 1;
        while (qu.size())
        {
            int nw = qu.front(); qu.pop();
            M[nw] = 1; tot += M2[nw];
            for (int &u : Adj[nw])
                if (!M[u]) qu.push(u);
            if (M2[nw])
                for (int &u : Ag[nw])
                    if (st[v][nw] <= st[v][u] && fn[v][u] <= fn[v][nw])
                        M2[u] = 1;
        }
    }
    return !printf("%d\n", (tot - n) >> 1);
}

Measured memory_bytes: 64384
s = input()
n= len(s)
rslt = [0]*n
# rslt = [0 for _ in range(n)]
ruiseki=0

for i in range(n-1):
    if s[i]=='R':
        ruiseki+=1
        if s[i+1]=='L':
            rslt[i+1]=ruiseki//2
            rslt[i]=(ruiseki+1)//2
    else:
        ruiseki=0


ruiseki=0
# 右から
for i in range(n-1, 0, -1):
    if s[i]=='L':
        ruiseki+=1
        if s[i-1]=='R':
            rslt[i-1]+=ruiseki//2
            rslt[i]+=(ruiseki+1)//2
    else:
        ruiseki=0

print(*rslt)

Measured memory_bytes: 6400
#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_map>

using namespace std;

int main(){
    int k; cin>>k;
    if(k % 2 == 0){
        cout<<-1<<endl;
        return 0;
    }
    long long mod = k * (1e9 + 7);
    long long num = 7;
    for(int i = 1; i <= k; i++){
        if(num % k == 0){
            cout<<i<<endl;
            return 0;
        }
        num = (num * 10 + 7) % mod;
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n)  for(int i=0;i<(n);++i)
#define ALL(x) (x).begin(),(x).end()
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main() {
  string S;
  cin >> S;
  int min = 1000;
  REP(i, S.size() - 2) {
    int num = stoi(S.substr(i, 3));
    int sub = abs(753 - num);
    if (min > sub) {
      min = sub;
    }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int whi=0;
static const int gra=1;
static const int bla=2;
static const int MAXX=(1<<21);
int color[110];
int a[110][110];
int minni[110];
int parent[110];
int n;

int prim(){
  int b=0;
  int minmin=0;
  int result=0;
  for(int i=0;i<n;i++){
    color[i]=whi;
    minni[i]=MAXX;
    parent[i]=-1;
  }
  minni[0]=0;
  while(1){
    minmin=MAXX;
    b=-1;
    for(int i=0;i<n;i++){
      if(color[i]!=bla&&minni[i]<minmin){
	b=i;
	minmin=minni[i];
	
      }
    }
    if(b==-1){
      break;
    }
    color[b]=bla;
    for(int j=0;j<n;j++){
      if(color[j]!=bla&&a[b][j]!=MAXX){
	if(a[b][j]<minni[j]){
	  minni[j]=a[b][j];
	  parent[j]=b;
	  color[j]=gra;
	}
      }
    }
  }
  for(int i=0;i<n;i++){
    if(parent[i]!=-1) result+=a[i][parent[i]];
  }
  return result;
}

int main(){
  cin>>n;

  int s;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>s;
      a[i][j]=(s==-1) ? MAXX : s;
    }
  }
  cout<<prim()<<endl;
}



Measured memory_bytes: 3128
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map { sc.next().toLong() }
    println(problem067c(n, a))
}

fun problem067c(n: Int, a: List<Long>): Long {
    val dp = Array<MutableList<Long>>(n - 1) { mutableListOf() }
    dp[0].add(a[0])
    dp[0].add(a.takeLast(n - 1).sum())
    dp[0].add(Math.abs(dp[0][0] - dp[0][1]))
    for (i in 1 until n - 1) {
        dp[i].add(dp[i - 1][0] + a[i])
        dp[i].add(dp[i - 1][1] - a[i])
        dp[i].add(Math.abs(dp[i][0] - dp[i][1]))
    }
    return dp.map { it[2] }.min()!!
}

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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  long long a[7], ans1 = 0, ans2 = 0;
  for (int i = 0; i < 7; ++i) {
    cin >> a[i];
  }

  ans1 = ans2 = a[1];
  ans1 += (a[0] / 2 + a[3] / 2 + a[4] / 2) * 2;

  if (a[0] && a[3] && a[4]) {
    ans2 += 3;
    a[0]--;
    a[3]--;
    a[4]--;

    ans2 += (a[0] / 2 + a[3] / 2 + a[4] / 2) * 2;
  }

  cout << max(ans1, ans2) << '\n';

}

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

int main() {
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	int maxX = -100, minY = 100;
	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (maxX < a) maxX = a;
	}
	for (int i = 0; i < m; i++) {
		cin >> a;
		if (minY > a) minY = a;
	}

	string ans = "No War";
	if (maxX >= minY) ans = "War";
	if (maxX >= y) ans = "War";
	if (minY <= x) ans = "War";
	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll, int> ii;
typedef pair <ii,int> iii;

const ll inf = 1e17;
const ll mod = 1e9 + 7;
const int N = 200005;

ll v[N];

void solve(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> v[i];
		v[i] += v[i-1];
	}
	ll ans = inf, l = 1, r = 3;
	for(int i = 2; i <= n-2; i++){
		while(l < i and abs(v[l] - v[0] - (v[i] - v[l])) >= abs(v[l+1] - v[0] - (v[i] - v[l+1])))
			l++;
		while(r < n and abs(v[r] - v[i] - (v[n] - v[r])) >= abs(v[r+1] - v[i] - (v[n] - v[r+1])))
			r++;
		ll a = v[l] - v[0], b = v[i] - v[l], c = v[r] - v[i], d = v[n] - v[r];
		//cout << a <<" " << b << " " << c <<" " << d << endl;
		ans = min(ans, max(a,max(b,max(c,d)))-min(a,min(b,min(c,d))));
	}
	cout << ans << endl;
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 5152
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(a<b){
            System.out.println("a < b");
        }else if(a>b){
            System.out.println("a > b");
        }else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26412
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	char c,abc[27]={"a""b""c""d""e""f""g""h""i""j""k""l""m""n""o""p""q""r""s""t""u""v""w""x""y""z"};
	int ans[27]={0};
	while(scanf("%c",&c)!=EOF){
		if('A'<=c&&c<='Z')c+=32;
		if('a'<=c&&c<='z'){
			int num=c-'a';
			ans[num]++;
		}
	}
	for(int i=0;i<26;i++){
		cout<<abc[i]<<" : "<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3144
use std::io::{stdin, Read};

macro_rules! parse {
    ($iter: ident) => {
        $iter.next().unwrap().parse().unwrap()
    };
    ($iter: ident,2) => {
        (parse!($iter), parse!($iter))
    };
    ($iter: ident,3) => {
        (parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident,4) => {
        (parse!($iter), parse!($iter), parse!($iter), parse!($iter))
    };
    ($iter: ident, $n: ident) => {
        (&mut $iter).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

struct Perm<T> {
    v: Vec<T>,
    cur: usize,
    tails: Option<Box<Perm<T>>>,
    finish: bool,
}

impl<T: Clone> Perm<T> {
    fn new(v: Vec<T>) -> Self {
        let mut w = v.clone();
        w.remove(0);
        let tails = if w.len() > 0 {
            Some(Box::new(Perm::new(w)))
        } else {
            None
        };
        Perm {
            v: v,
            cur: 0,
            tails: tails,
            finish: false,
        }
    }
}

impl<T: Clone> Iterator for Perm<T> {
    type Item = Vec<T>;
    fn next(&mut self) -> Option<Self::Item> {
        if self.finish {
            return None;
        }
        if let &mut Some(ref mut tails) = &mut self.tails {
            if let Some(mut v) = tails.next() {
                v.insert(0, self.v[self.cur].clone());
                return Some(v);
            }
        } else {
            self.finish = true;
            return Some(self.v.clone());
        }

        self.cur += 1;
        if self.cur == self.v.len() {
            self.finish = true;
            return None;
        }
        let mut w = self.v.clone();
        w.remove(self.cur);
        self.tails = Some(Box::new(Perm::new(w)));
        self.next()
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut iter = s.split_whitespace();
    let n: usize = parse!(iter);
    let perm: Vec<Vec<usize>> = Perm::new((1..(n + 1)).collect()).collect();
    let p: Vec<usize> = parse!(iter, n);
    let pi = perm.binary_search(&p).unwrap() as isize;
    let q: Vec<usize> = parse!(iter, n);
    let qi = perm.binary_search(&q).unwrap() as isize;
    println!("{}", isize::abs(pi - qi));
}


Measured memory_bytes: 8444
#include <stdio.h>
#include <math.h>
//入力a,bの平均値の小数点以下を切上げた値を出力
int main(void) {
  int a, b, c;
  // scanfで入力を読み込み
  scanf("%d%d", &a, &b);
  // 平均値の計算 ceil:小数点を切上げる関数
  c = ceil((a + b) / 2.0);
  // 答えの出力
  printf("%d\n", c);
  return 0;
}



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

ll n,v[200000][20],ans,r,l;

int main(){
    cin >> n;
    for(int i = 0;i < n;i ++){
        int a;
        cin >> a;
        for(int j = 0;j < 20;j ++){
            if(a & (1<<j)) v[i][j] = 1 + (i?v[i-1][j]:0);
            else v[i][j] = (i?v[i-1][j]:0);
        }
    }
    while(l!=n-1||r!=n-1){
        bool b = true;
        while(1){
            for(int i = 0;i < 20;i ++){
                if(v[r][i]-(l?v[l-1][i]:0)>1) {b = false;break;}
            }
            if(b) r ++;
            if(r==n||!b){r --;break;}
        }
        ans += r-l+1;
        if(r==l) r ++,l ++;
        while(l<r){
            l ++;
            b = true;
            for(int i = 0;i < 20;i ++){
                if(v[r][i]-(l?v[l-1][i]:0)>1) b = false;
            }
            if(b) break;
        }
    }
    cout << ans+1 << endl;
    return 0;
}


Measured memory_bytes: 31488
a,b,c=map(int,input().split())
l={5:0,7:0}
l[a]=1
if not b in l:
  l[b]=0
l[b]+=1
if not c in l:
  l[c]=0
l[c]+=1

if l[5]==2 and l[7]==1:
  print("YES")
else:
  print("NO")
  

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<set<string>>B(5);
  for(int i=0;i<N;i++){
    string T;
    cin>>T;
    if(T.at(0)=='M'){
      B[0].insert(T);
    }
    if(T.at(0)=='A'){
      B[1].insert(T);
    }
    if(T.at(0)=='R'){
      B[2].insert(T);
    }
    if(T.at(0)=='C'){
      B[3].insert(T);
    }
    if(T.at(0)=='H'){
      B[4].insert(T);
    }
  }
  vector<long long>S(5);
  for(int i=0;i<5;i++){
    S[i]=B[i].size();
  }
  long long Ans=0;
  for(int tmp=0;tmp<(1<<5);tmp++){
    bitset<5>E(tmp);
    int s=0;
    for(int i=0;i<5;i++){
      if(E.test(i)){
        s++;
      }
    }
    if(s==3){
      long long K=1;
      for(int i=0;i<5;i++){
        if(E.test(i)){
          K=K*S[i];
        }
      }
      Ans+=K;
    }
  }
  cout<<Ans<<endl;
}
    


Measured memory_bytes: 9600
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define cy cout << "Yes" << endl
#define cn cout << "No" << endl
typedef long long ll;

void Main()
{
	int x, y;
  	cin >> x >> y;
  	cout << x + y/2 << endl;
	return;
}

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

Measured memory_bytes: 256
N=gets.to_i

x,y=[0,0]
t=0

N.times do
    s,a,b=gets.split.map(&:to_i)
    d = (x-a).abs + (y-b).abs

    if s-t < d || (s-t-d).odd?
        puts 'No'
        exit 0
    end

    x,y=[a,b]
    t=s
end

puts 'Yes'

Measured memory_bytes: 1788
n = input()
k = int(input())
dp = [[[0,0,0,0],[0,0,0,0]] for i in range(len(n))]
#dp[p]は、p桁目まで見たことを表す（p=0は1桁目を見たことになる）
#dp[p][0]は、p桁目まではnより小さいことが確定している
#dp[p][0or1][count]は、p桁目までの「0以外の桁」の登場回数
#(dp[p][1][count]は、例えばn=10275でdp[2][1][1]だった時に、102の中に0がいくつ入っているかを表す。この場合1）
dp[0][0][0] = 0
dp[0][0][1] = 1
dp[0][1][0] = 1
dp[0][1][1] = int(n[0])-1
for i in range(1,len(str(n))):
    if n[i] != '0':
        dp[i][0][0] = 0 #遷移前に同じで、遷移後に0でないものが0個かつ遷移前と同じ遷移はありえない
        dp[i][0][1] = dp[i-1][0][0] #ぴったりの数字(0でない)が入ればOK 下二つも同じ
        dp[i][0][2] = dp[i-1][0][1]
        dp[i][0][3] = dp[i-1][0][2]
        dp[i][1][0] = dp[i-1][1][0] #0を入れればOK
        dp[i][1][1] = dp[i-1][0][0]*(int(n[i])-1)+dp[i-1][0][1]+dp[i-1][1][1]+dp[i-1][1][0]*9
        dp[i][1][2] = dp[i-1][0][1]*(int(n[i])-1)+dp[i-1][0][2]+dp[i-1][1][2]+dp[i-1][1][1]*9
        dp[i][1][3] = dp[i-1][0][2]*(int(n[i])-1)+dp[i-1][0][3]+dp[i-1][1][3]+dp[i-1][1][2]*9
    else:
        dp[i][0][0] = dp[i-1][0][0]
        dp[i][0][1] = dp[i-1][0][1]
        dp[i][0][2] = dp[i-1][0][2]
        dp[i][0][3] = dp[i-1][0][3]
        dp[i][1][0] = dp[i-1][1][0] #0を入れればOK
        dp[i][1][1] = dp[i-1][1][0]*9+dp[i-1][1][1]
        dp[i][1][2] = dp[i-1][1][1]*9+dp[i-1][1][2]
        dp[i][1][3] = dp[i-1][1][2]*9+dp[i-1][1][3]
print(dp[len(n)-1][0][k]+dp[len(n)-1][1][k])

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

int main(){
    int n,count=3;
    char s;
    
    cin>>n;
    
    for(int i=0;i<n;i++){
        cin>>s;
        if(s=='Y'){
            count=4;
            break;
        }
    }
    
    if(count==3)
        cout<<"Three"<<endl;
    else if(count==4)
        cout<<"Four"<<endl;
}


Measured memory_bytes: 3536
import math
A, B, N = map(int, input().split())

if N // B == 0:
    f, _ = math.modf(N / B)
    ans = math.floor(A * f)
else:
    n = (N // B) * B - 1
    f1, _ = math.modf(n / B)
    f2, _ = math.modf(N / B)
    f = max(f1, f2)
    ans = math.floor(A * f)

print(ans)

Measured memory_bytes: 9192
//This is getting accepted!
#include<bits/stdc++.h>
#define ll long long
#define oo 1000000009
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define INARR(a,n) for (int i = 1; i <= (n); ++i) cin >> a[i];
#define ITE(x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define isset(x, i) (((x)>>(i))&1)
#define setbit(x, i) ((x)^(1ll<<(i)))
#define clearbit(x, i) ((x)&(~(1ll<<(i))))
#define twoexp(i) (1ll<<(i))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define FI first
#define SE second
#define son1 (id*2)
#define son2 (id*2+1)

using namespace std;

const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = 2 * acos(0);
const int MAXN = 1e6 + 6;

int n;
int a[MAXN];
vector<int> res(MAXN, 0);
vector<int> vec;

void input() {
	int u, v, w, x, y, qtype;
	
	cin >> n;
	INARR(a, n);
	
}


void preprocess() {
	
	
	
}

void process(int itest) {
	int u, v, w, x, y, qtype;
	
	for (int i = n; i >= 1; --i) {
		int num = 0;
		for (int j = i*2; j <= n; j += i)
			num += res[j];
		num %= 2;
		
		if (num == a[i])
			res[i] = 0;
		else {
			res[i] = 1;
			vec.push_back(i);
		}
	}
	
	cout << vec.size() << "\n";
	for (auto v : vec) cout << v << "\n";
	
}

void oneTest() {
	
	input();
	preprocess();
	process(0);
	
}

void multiTest() {
	
	int t;
	cin >> t;
	
	for (int it = 1; it <= t; ++it) {
		input();
		preprocess();
		process(it);
	}
}

int main(){
    #ifndef ONLINE_JUDGE
//    freopen("../out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	oneTest();
//	multiTest();

    return 0;

}


Measured memory_bytes: 6392
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

int main() {
	int no;
	double w, h;
	while (scanf("%d,%lf,%lf", &no, &w, &h) != EOF) {
		if ((w / pow(h, 2)) >= 25.0)
			cout << no << endl;
	}
	return 0;
}

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

#include <atcoder/all>

using namespace std;
using namespace atcoder;

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int n, m;
    cin >> n >> m;
    scc_graph g(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        g.add_edge(a, b);
    }
    auto vec = g.scc();
    int sz = vec.size();
    cout << sz << '\n';
    rep(i, sz) {
        int k = vec[i].size();
        cout << k;
        for (int v : vec[i]) {
            cout << ' ' << v;
        }
        cout << '\n';
    }

    return 0;
}

Measured memory_bytes: 40076
/**
     **author : _KMS_
     **created : 04-03-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =6e5,MOD=2e9;
typedef long long ll;
int dp[30][M];
int n,q;
string s;
int query(int num,int idx)
{
      int sum=0;
      while(idx>0)
      {
            sum+=dp[num][idx];
            idx-=idx&(-idx);
      }
      return sum;
}
 void update(int num,int idx,int x)
 {
       while(idx<=n)
       {
             dp[num][idx]+=x;
             idx+=idx&(-idx);
             
       }
 }
int main() {
      
   ios::sync_with_stdio(false);
   cin.tie(0);
   cin>>n>>s;
   for(int i=0;i<n;i++)
   {
        update(s[i]-97,i+1,1);
   }
   cin>>q;
   while(q--)
   {
         int type;
         cin>>type;
         if(type==1)
         {
               int idx;char ch;
               cin>>idx>>ch;
               update(s[idx-1]-97,idx,-1);
               update(ch-97,idx,1);
              s[idx-1]=ch;
         }
         else
         {
               int l,r,res=0;
               cin>>l>>r;
               for(int i=0;i<26;i++)
               {
                     int mx=query(i,r);
                     int mi=query(i,l-1);
                     if(mx-mi)res++;
               }
               cout<<res<<"\n";
         }
   }
   
   return 0;
}

Measured memory_bytes: 62236
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  int a,b;
  cin>>a>>b;
  vector<int> c(a);
  rep(i,a)
    cin>>c[i];
  vector<int> d(a,0);
  rep(i,a){
  d[c[i]-1]++;
  }
  rep(i,a){
    if(d[i]==0)
      d[i]=1e9;
      }
  int k=0;
  rep(i,a){
  if(d[i]!=1e9)
    k++;
  }
  sort(all(d));
  if(k-b>0){
    int m=0;
  rep(i,k-b)
    m+=d[i];
    cout<<m<<endl;
  }
    else
      cout<<0<<endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, X;
  cin >> N >> X;
  
  int sum = 0;
  vector<int> vec(N);
  
  //N個のドーナツの質量の和を計算　かつ　N個のドーナツの質量の配列作成
  for(int i = 0; i < N; i++){
    int m;
    cin >> m;
    vec[i] = m;
    sum += m;
  }

  //質量の配列を小さい順に取り出す
  sort(vec.begin(), vec.end());
    
   //最小質量を取り出す
  int mini = vec[0];
  int R;
  R = X - sum; //素の残量R

  cout << R/mini + N << endl;
}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

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

  vector<int> A(N), MINS(N), MAXS(N + 1);

  rep0(i, N) cin >> A[i];

  MAXS[N] = -1;
  repR0(i, N) MAXS[i] = max(MAXS[i + 1], A[i]);

  int temp = 1e9;
  int max_diff = 0;
  rep0(i, N) {
    temp = min(temp, A[i]);
    MINS[i] = temp;
    max_diff = max(max_diff, MAXS[i] - MINS[i]);
  }

  // SHOW(MAXS);
  // SHOW(MINS);

  int ans = 0;
  rep0(i, N) {
    if (MAXS[i] - MINS[i] == max_diff
        && MAXS[i] != MAXS[i + 1]) ans++;
  }

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 1408