akhauriyash/Code-Regression huggingface dataset:
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define Rd(a) (a=read())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int read(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	c^'-'?(k=1,x=c&15):k=x=0;
	while(isdigit(Gc(c)))x=(x<<1)+(x<<3)+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
#define N (100010)
int k;
vector<int>s{1};
void opt(int x);
signed main(){
	Rd(k);
	Frn1(i,2,k)opt(0);
	Frn_(i,s.size()-1,0)wr(s[i]);
	exit(0);
}
void opt(int x){
	if(x==s.size()-1){
		if(s[x]==9)s.push_back(1),s[x]=0;
		else ++s[x];
	}else if(s[x]<=s[x+1]&&s[x]<9)++s[x];
	else opt(x+1),s[x]=max(0,s[x+1]-1);
}


Measured memory_bytes: 256
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	vector<bool> a(n);
	int ans = n;
	for(int i = 0; i < k; i++) {
		int d;
		cin >> d;
		for(int j = 0; j < d; j++) {
			int x;
			cin >> x;
			ans -= !a[x - 1];
			a[x - 1] = true;
		}
	}
	cout << ans;
	
	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<x ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a, b, t, l, r;
vector<vi> e(100000);
int d0[100000], dn[100000];

void dfs0(int v, int d) {
	d0[v] = d;
	rep(i,e[v].size()) {
		t = e[v][i];
		if (d0[t]==inf) dfs0(t, d+1);
	}
}

void dfsn(int v, int d) {
	dn[v] = d;
	rep(i,e[v].size()) {
		t = e[v][i];
		if (dn[t]==inf) dfsn(t, d+1);
	}
}

int main() {
	cin >> n;
	rep(i,n-1) {
		cin >> a >> b;
		a--, b--;
		e[a].pb(b);
		e[b].pb(a);
	}
	
	// dfsで0からの最短距離とn-1からの最短距離を全ての点について求める
	// d0[i]<=dn[i]なら先手(Fennecくん)がそのマスを塗れる
	fill(d0, d0+n, inf);
	dfs0(0, 0);
	fill(dn, dn+n, inf);
	dfsn(n-1, 0);
	rep(i,n) {
		if (d0[i]<=dn[i]) l++;
		else r++;
	}
	if (l>r) cout << "Fennec" << ln;
	else cout << "Snuke" << ln;
}

Measured memory_bytes: 11264
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int i;
		int ar[] = new int[100];
		
		int idx = 0;
		
		while ( sc.hasNext() ) {
			int n = sc.nextInt();
			i = idx - 1;
			while (i >= 0 && n < ar[i]) {
				ar[i + 1] = ar[i];
				--i;
			}
			ar[i + 1] = n;
			++idx;
		}
		for ( i = idx - 1 ; i >= 0 && i >= idx - 3 ; --i ) {
			System.out.println(ar[i]);
		}
	}

}

Measured memory_bytes: 17240
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

ll factorialTable[200010];
ll inverseFactorialTable[200010];

//Aのp乗を求めるアルゴリズム。計算量はO(logp)
ll modpow(ll A, int p) {
    if(p == 0) {
        return 1;
    }
    if(p%2 == 0) {
        //pが偶数の時
        int halfP = p/2;
        ll half = modpow(A, halfP);
        //a^(p/2)をhalfとして、half*halfを計算
        return half * half % mod;
    }
    else {
        //pが奇数の時は、pを偶数にするために1減らす
        return A * modpow(A, p-1) % mod;
    }
}

void makeFactorialTable() {
    ll x = 1LL;
    factorialTable[0] = x;
    for(int i = 1; i < 200010; i++) {
        x *= i;
        x %= mod;
        factorialTable[i] = x;
    }
}

void makeInverseFactorialTable() {
    inverseFactorialTable[0] = 1LL;
    for(int i = 1; i < 200010; i++) {
        inverseFactorialTable[i] = modpow(factorialTable[i], mod-2);
    }
}

ll Comb(int n, int r) {
    ll bunbo = inverseFactorialTable[r]*inverseFactorialTable[n-r]%mod;
    ll bunshi = factorialTable[n];
    return bunshi*bunbo%mod;
}

int main() {
    int h, w, a, b;
    ll ans = 0;
    cin >> h >> w >> a >> b;

    makeFactorialTable();
    makeInverseFactorialTable();
 
    for(int i = b; i < w; i++) {
        ll k = Comb(h-a-1+i, h-a-1)*Comb(w+a-2-i, w-1-i)%mod;
        ans += k;
        ans %= mod;
    }

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

Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

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

	long long ans = max(a * c, max(a * d, max(b * c, b * d)));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3636
H,W = map(int,input().split())
Data1 = []

tbl = str.maketrans({'.':'0','#':'1'})
for _ in range(H):
    s = input().translate(tbl)
    s = list(map(int,list(s)))
    if sum(s) > 0:
        Data1.append(s)

dellist = []
for w in range(W):
    flag = False
    for data in Data1:
        if data[w] == 1:
            flag = True
            break
    if flag == False:
        dellist.append(w)

for i in range(len(dellist)-1,-1,-1):
    for data in Data1:
        data.pop(dellist[i])

for data in Data1:
    for i in range(len(data)):
        if data[i] == 0:
            print('.',end='')
        else:
            print('#',end='')
    print("")

Measured memory_bytes: 4596
#include <stdio.h>

int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    if (a < b)
      printf("a < b\n");
    else if (a > b)
      printf("a > b\n");
    else
      printf("a == b\n");

    return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,k;
  vector<int> data = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin >> k;
  cout << data.at(k - 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>>A(H,vector<char>(W));
  vector<bool>h(H,false), w(W,false);
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A.at(i).at(j);
    }
  }
  for (int i = 0; i < H; i++) {
     for (int j = 0; j < W; j++) {
       if (A.at(i).at(j) == '#') {
         h.at(i) = true;
         w.at(j) = true;
       }
     }
  }
         
  for (int i = 0; i < H; i++) {
    if (h.at(i)) {
      for (int j = 0; j < W; j++) {
        if (w.at(j)) {
          cout << A.at(i).at(j);
        }        
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
from collections import deque
n = int(input())
tree = [[]*(n+1) for _ in range(n+1)]
for i in range(n-1):
    a,b,c = map(int,input().split())
    tree[a].append((b,c))
    tree[b].append((a,c))
q,k = map(int,input().split())
parent = [-1]*(n+1)
distance = [-1]*(n+1)
distance[k] = 0
d = deque()
d.append(k)
while d:
    x = d.popleft()
    for child,length in tree[x]:
        if parent[x] == child:
            continue
        parent[child] = x
        distance[child] = distance[x] + length
        d.append(child)
for i in range(q):
    x,y = map(int,input().split())
    print(distance[x]+distance[y])


Measured memory_bytes: 82720
#include <stdio.h>          // printf(), fprintf(), scanf()
#include <stdlib.h>         // exit()
#include <string.h>         // strlen(), strcpy()

#define QUE_SIZE 100000
#define L_STRINGS (11 * 100000)

typedef struct que_tbl
{
	const char* name;
	int time;
} que_t;

int que_in;
int que_out;
que_t queue[QUE_SIZE];
char strings[L_STRINGS];
int ix;

void
cleanup(int ecode)
{
	exit(ecode);
}

int
que_size()
{
	if (que_in >= que_out)
		return que_in - que_out;

	return que_in + QUE_SIZE - que_out;
}

void
que_push(que_t* que)
{
	queue[que_in].name = que->name;
	queue[que_in].time = que->time;
	que_in++;
	if (que_in >= QUE_SIZE)
		que_in = 0;

	if (que_in == que_out)
	{
		fprintf(stderr, "Queue area overflow. size:%d\n", QUE_SIZE);
		cleanup(1);
	}
}

void
que_pop()
{
	if (que_out != que_in)
	{
		que_out++;
		if (que_out >= QUE_SIZE)
			que_out = 0;
	}
}

void
que_front(que_t* que)
{
	que->name = queue[que_out].name;
	que->time = queue[que_out].time;
}

int
main(int argc, char** argv)
{
	char name[11];
	int time;
	que_t que;
	int q;
	int n, i;
	char* s;
	int t;

	ix = 0;
	que_in = 0;
	que_out = 0;

	scanf("%d %d", &n, &q);
	for (i = 0; i < n; ++i)
	{
		scanf("%s %d", name, &t);
		s = &strings[ix];
		strcpy(s, name);
		ix += strlen(name) + 1;

		que.name = s;
		que.time = t;
		que_push(&que);
	}

	time = 0;
	i = 0;
	while (i < n)
	{
		que_front(&que); que_pop();
		if (que.time <= q)
		{
			time += que.time;
			printf("%s %d\n", que.name, time);
			i++;
		}
		else
		{
			que.time -= q;
			time += q;
			que_push(&que);
		}
	}

	return 0;
}

Measured memory_bytes: 2508
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace __init {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
#include "../debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

int main() {
    ll A, B;
    cin >> A >> B;
    if(A >= 13) cout << B;
    else if(A <= 5) cout << 0;
    else cout << B / 2;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int n, d, ans;

int main(){

	cin >> n >> d;

	d = d * 2 + 1;

	if (n % d != 0)ans = n / d + 1;
	else ans = n / d;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

typedef vector<vi> vv;

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

ll N, M;
vi K;
vv A;

int main()
{
    cin >> N >> M;
    K = vi(N);
    A = vv(N);
    REP(i, N)
    {
        cin >> K[i];
        A[i] = vi(K[i]);
        REP(j, K[i])
        {
            cin >> A[i][j];
        }
    }

    vi cnt = vi(M);
    REP(i, N)
    {
        REP(j, K[i])
        {
            ++cnt[A[i][j] - 1];
        }
    }
    ll ans = 0;
    REP(i, M)
    {
        if (cnt[i] == N)
        {
            ++ans;
        }
    }

    OUT(ans);
}

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

vector<int>graph[100001];
int dp[100001];

int solve(int x)
{
    if(dp[x]!=-1)
        return dp[x];
    bool leaf=1;
    int bestChild=0;
    for(int child :graph[x])
    {
        leaf=0;
        bestChild=max(bestChild,solve(child)+1);
    }
    return dp[x]=bestChild;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    memset(dp,-1,sizeof(dp));   
    int n,m;
    cin>>n>>m; 
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        graph[u].push_back(v);
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=max(solve(i),ans);
    }
        cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11412
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	string s;
	cin >> n >> s;
	
	int ans = n;
	for(int i = 0; i < n - 1; ++i) {
		if( s[i] == s[i + 1] ) ans--;
	}	
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    vector<int> c(3);
    rep(i,3) cin>>c[i];
    sort(etob(c));
    int ans=c[1]+c[2];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll a,v,b,w,t;
	cin>>a>>v>>b>>w>>t;
	ll l=abs(a-b);
	if(v<=w){
		cout<<"NO"<<endl;
	}else{
		ll rel=v-w;
		if(l<=rel*t){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(container) container.begin(),container.end()
#define fast ios::sync_with_stdio(0); cin.tie(0)
// #ifndef ONLINE_JUDGE
// #include "debug.cpp"
// #endif
#define int long long
const int mod = 1e9+7;  
int power(int a,int b) { if(b==0) return 1; int res = power(a,b/2); if(b&1) return res * res * a; else return res * res; }


int32_t main(){
    
  fast;
  int a,b; cin >> a >> b;
  bool flag[4] = {false};
  flag[a] = flag[b] = true;
  
  for(int i=1;i<=3;i++){
    if(flag[i]==false){
    	cout << i << '\n';
          break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <limits.h>
using namespace std;


int main(void) {

  int N;
  long long K;
  cin >> N >> K;
  
  vector<int> P(N + 1); //move
  for (int i = 1; i < N + 1; i++) {
    cin >> P[i];
  }
  vector<long long> C(N + 1); //point
  for (int i = 1; i < N + 1; i++) {
    cin >> C[i];
  }

  long long max_point = LLONG_MIN;
  long long tmp_point = 0;
  int current_p = 0;

  max_point = LLONG_MIN;
  for (int m_first = 1; m_first < N + 1; m_first++) {
    tmp_point = 0;
    current_p = m_first;
    //cout << "m_first: " << m_first << ", current: " << current_p << endl;
    for (int total = 1; total <= K; total++) {
      //cout << "total: " << total << ", current: " << current_p << endl;
      //cout << "tmp_point: " << tmp_point << endl;
      tmp_point += C[P[current_p]];
      if (max_point <= tmp_point) max_point = tmp_point;
      current_p = P[current_p];

      if (m_first == current_p && tmp_point <= 0) {
	tmp_point += C[P[current_p]];
	if (max_point <= tmp_point) max_point = tmp_point;
	break;
      } else if (m_first == current_p && tmp_point > 0){
	int cycle_num = K/total;
	int amari = K % total;
	// cout << "cycle_num: " << cycle_num << endl;
	// cout << "amari: " << amari << endl;
	// cout << "tmp_potnt: " << tmp_point << endl;
	tmp_point = tmp_point * (cycle_num - 1);
	if (max_point <= tmp_point) max_point = tmp_point;
	for (int l = 0; l < amari + total; l++) {
	  //cout << "tmp_point:" << tmp_point << endl;
	  tmp_point += C[P[current_p]];
	  if (max_point <= tmp_point) max_point = tmp_point;
	  current_p = P[current_p];
	}
	break;
      }
      
    }
    //cout << "" << endl;
  }

  cout << max_point << endl;
    
  return 0;
} 

Measured memory_bytes: 3652
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <atcoder/all>

#define REPI(i, S, N) for(int i=int(S); i<int(N); i++)
#define REP(i, N) REPI(i, 0, N)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::integer;

using ll = long long;
namespace bst = boost;
using mint = atcoder::modint1000000007;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

ll op(ll a, ll b) { return max(a, b); }

ll e() { return 0; }

ll targett;

bool f(ll v) { return v < targett; }

auto solve() {
  in<ll> N, K;
  invec<ll> A(N);
  map<int, ll> memo;
  atcoder::segtree<ll, op, e> segki(300001);
  
  segki.set(A[0], 1);
  for (int i = 1; i < N; i++) {
    ll ooi = segki.prod(max(0LL, A[i] - K), min(A[i] + K + 1, 300001LL));
    
    segki.set(A[i], ooi + 1);
  }


  return segki.all_prod();
}

template<typename T> void plot(const T& func) { cout << setprecision(9) << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 16232
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int ans[100]={0};
  vector<int>seki(17,-1);
  vector<int>machi;
  rep(i,100000){
    //cout<<machi.size()<<endl;
    if(i>510&&machi.size()==0)break;
    if(i<500&&i%5==0)machi.pb(i/5);
    rep(j,17){
      if(seki[j]==1)seki[j]=-1;
      else if(seki[j]!=-1)seki[j]--;
    }
    while(1){
      if(machi.size()==0)break;
      int n;
      if(machi[0]%5==1)n=5;
      else n=2;
      bool han=false;
      rep(j,17-n+1){
	bool h=true;
	rep(k,n)if(seki[k+j]!=-1){h=false;break;}
	if(h){
	  han=true;
	  ans[machi[0]]=i-machi[0]*5;
	  rep(k,n)seki[k+j]=17*(machi[0]%2)+3*(machi[0]%3)+19;
	  machi.erase(machi.begin());
	  break;
	}
	//cout<<i<<endl;
      }
      if(han==false)break;
    }
    //if(i<100)cout<<i;
    //if(i<100)rep(l,17)printf(" %3d",seki[l]);//cout<<" "<<seki[l];
    //if(i<100)cout<<endl;
  }
  int in;
  while(cin>>in)cout<<ans[in]<<endl;
  //rep(i,100)printf("%2d %d\n",i,ans[i]);
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K,X,Y;
  cin>>N>>K>>X>>Y;
  if(N<K){
    cout<<N*X<<endl;
  }
  else{
    cout<<K*X+(N-K)*Y<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>

using namespace std;

int main()
{
    int N;
    cin >> N;
    string s;
    set<string> S;
    for (int i = 0; i < N; i++)
    {
        cin >> s;
        S.insert(s);
    }

    cout << S.size() << endl;

    return 0;
}


Measured memory_bytes: 19256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {n: usize};

    let mut result: Vec<usize> = vec![0; n];
    let mut v: Vec<usize> = vec![0; 3];

    dfs(&mut v, &mut result, 0, n);

    for r_i in result.iter() {
        println!("{}", r_i);
    }
}

fn dfs(v: &mut Vec<usize>, result: &mut Vec<usize>, index: usize, n: usize) {
    if index == 3 {
        let sum = v[0] * v[0] + v[1] * v[1] + v[2] * v[2] + v[0] * v[1] + v[1] * v[2] + v[2] * v[0];

        // 20↓
        if sum <= n {
            // 1 -> 20
            for i in 1..n + 1 {
                if sum == i {
                    result[i - 1] += 1;
                    break;
                }
            }
        }
    } else {
        let x = (n as f64).sqrt() as usize + 1;
        for i in 1..x {
            v[index] = i;
            dfs(v, result, index + 1, n);
        }
    }
}


Measured memory_bytes: 2088
#include<stdio.h>

int main(){
  int A,B;
  scanf("%d %d", &A, &B);
  int C =  A+B;
  int D =  A-B;
  int E = A *B;
   
 int  max;
 max = C;
 if(D > max)
   max = D;
 if(E > max)
   max = E;

   printf("%d", max);
   return 0;

}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%MOD;
        }
        x = (x*x)%MOD;
        n >>= 1;
    }
    return ret;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll m,n;
    cin >> m >> n;

    vector<ll> k(n);
    vector<vector<ll>> sw(n);

    for(int i = 0; i < n; i++){
        cin >> k[i];
        for(int j = 0; j < k[i]; j++){
            ll t;
            cin >> t;
            sw[i].push_back(t);
        }
    }

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

    ll ans = 0;

    for(int i = 0; i < (1 << m); i++){
        bool flag = true;
        for(int j = 0; j < n; j++){
            int count = 0;
            for(int x = 0; x < k[j]; x++){
                if((1 << (sw[j][x] - 1))&i){
                    count++;
                }
            }
            if(count%2 != p[j]){
                flag = false;
            }
        }
        if(flag){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
const int M=2e2+20;
ll v[N];
ll C[M][M];
//ÌâÒâ:n¼þÎïÆ·,¿ÉÒÔÑ¡a~b¼þ,ÇóÆ½¾ùÖµ×î´óÊÇ¶àÉÙºÍ·½·¨Êý? n<=50,vi<=1e15
//¹Ì¶¨µÄk=a~b ave=sum/k aveÒª´ó sumÒª×î´ó Ñ¡×î´óµÄk¸ö 
// 1/k*segma(vi) i=0~k-1 - 1/(k+1) segma(vi) i=0~k >=0
//ËùÒÔÑ¡A¸öÊ±µÄÆ½¾ùÖµ×î´ó;

//e.g a=2,b=4 a[i]={20,20,20,20,10} ·½·¨ÊýÎª11  
//Ê²Ã´Ê±ºòÔö¼ÓÑ¡µÄ¸öÊý ×î´óave²»±ä?
//sum/k=(sum+x)/(k+1) - > x=sum/k=ave
//(ÈôÖ»ÓÐÑ¡A¸ö²ÅÄÜ×î´ó ÔòÍ³¼ÆA¸öÖÐÃ¿ÖÖÊýµÄ¸öÊýki Ôò´Óni¸öÊýÖÐÑ¡ki¸ö¼´¿É)
//ÒòÎªv´Ó´óµ½Ð¡ÅÅÐò ÈôÈ»Ö»ÄÜÑ¡A¸ö,Ôò·½·¨ÊýÖ»ÒªC(mp[v[A-1]],mk[v[A-1])  
map<ll,ll> mp,mk;
void init()
{
	memset(C,0,sizeof(C));
	C[0][0]=1;
	for(int i=1;i<=50;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=C[i-1][j-1]+C[i-1][j];
	}
}
int main()
{
	int n,A,B;
	init();
	while(cin>>n>>A>>B)
	{
		double ave=0;
		mp.clear(),mk.clear();
		for(int i=0;i<n;i++)
			cin>>v[i],mp[v[i]]++;
		sort(v,v+n);
		reverse(v,v+n);//´ó->Ð¡
		for(int i=0;i<A;i++) 
			ave+=v[i];
		ave/=A;
		
		ll ans=0;
		if(v[A]==ave)
		{
			int cnt=0;
			for(int i=0;i<n;i++)
			{
				if(v[i]==ave)
					cnt++;
			}
			for(int i=A;i<=B;i++)
				ans+=C[cnt][i];
		}
		else
		{
			//×î´óÖµÖ»ÄÜÎªÑ¡A
			for(int i=0;i<A;i++)
				mk[v[i]]++;
			/*for(int i=0;i<A;i++)
			{
				if(mk[v[i]])
				{
					
					ans=ans*C[mp[v[i]]][mk[v[i]]];
					mk[v[i]]=0;
				}
			}
			*/
			ans+=C[mp[v[A-1]]][mk[v[A-1]]];		
		}
 			cout.precision(20);
 		cout<<fixed<<ave<<endl;
 		cout<<ans<<endl;
	}
	return 0;
}

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

int main() {
    int x, y;
    string s, t;
    cin >> s >> t;
    vector<int> a(26,-1);
    vector<int> b(26,-1);
    bool flag=true;
    for(int i=0; i<s.size(); i++) {
        x=s[i]-'a';
        y=t[i]-'a';
        if(a[x]!=-1 && a[x]!=y) {
            flag=false;
            break;
        }
        else if (b[y]!=-1 && b[y]!=x) {
            flag=false;
            break;
        }
        else {
            a[x]=y;
            b[y]=x;
        }
    }
    if(flag) cout << "Yes";
    else cout << "No";
}

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



int main() {
  ll a,b,c,k;
  cin >> a >> b >> c>>k;
  if(k<a){cout << k << endl;
  return 0;}
  if(a+b>=k){cout << a << endl;
  return 0;}
  if(a+b+c>k && a+b<=k){cout << a-(k-(a+b)) << endl;
  return 0;}
  if(a+b+c<=k){cout << a-c << endl;}
}

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

int main() {
    int n, minimum = INT_MAX, temp, sum = 0, ans = 0;
    cin >> n;
    rep(i, n) {
        cin >> temp;
        sum += temp;
        if(temp % 10 && minimum > temp) minimum = temp;
    }
    if(sum % 10) ans = sum;
    else if(minimum != INT_MAX) ans = sum - minimum;
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  int x;
  cin >> x;
  int s=0;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  
  sort(a.begin(),a.end());
  
  long long as=0;
  for(int i=0; i<n; i++){
    as += a[i];
  }
  
  if(x <= as){
   for(int i=0; i<n; i++){
     if(x >= a[i]){
     x -= a[i];
     s++;
     }
     else{
       break;
     }
   }
  }
  
  if(x > as){
    s = n-1;
  }
  
  cout << s << endl;
	return 0;
}


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

using namespace std;

const int MAXN = 2e3 + 10;
const int MOD = 1e9 + 7;

long long dp[MAXN][MAXN];
long long fac[MAXN * MAXN];
int n, k;

long long po(long long v, long long u)
{
	return u ? (po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD) : 1;
}

long long ente(int i, int j)
{
	long long res = po(fac[i], MOD - 2) * po(fac[j - i], MOD - 2);
	res %= MOD;
	res *= fac[j];
	return res % MOD;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	fac[0] = 1;
	for (int i = 1; i < MAXN * MAXN; i++)
		fac[i] = (fac[i - 1] * i) % MOD;
	if (k == 1)
		return cout << 1 << '\n', 0;
	dp[0][0] = 1;
	for (int i = 0; i <= n; i++)
	{
		for (int j = i; j <= n; j++)
		{
			if (i)
				dp[i][j] = dp[i - 1][j];
			if (j)
				dp[i][j] += dp[i][j - 1] * ente(k - 2, i + j * (k - 1) - 1);
			dp[i][j] %= MOD;
		}
	}
	dp[n][n] = (dp[n][n] * fac[n]) % MOD;
	cout << dp[n][n] << '\n';
	return 0;
}

Measured memory_bytes: 62080
n,m=map(int,input().split())
p=[]
s=[]
ac=["WA"]*n
wa=[0]*n
for i in range(m):
	pp,ss=input().split()
	p.append(int(pp))
	s.append(ss)
for i in range(m):
	if s[i]=="AC":
		ac[p[i]-1]="AC"
	else:
		if ac[p[i]-1]=="WA":
			wa[p[i]-1]+=1
for i in range(n):
	if ac[i]=="WA":
		wa[i]=0
print(ac.count("AC"),sum(wa))

Measured memory_bytes: 14888
from collections import defaultdict
n, m = map(int, input().split())
P = list(map(lambda x:int(x)-1,input().split()))

class UnionFind( ):
    def __init__(self, N):
        self.rank = [0] * N
        self.par = [i for i in range(N)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] > self.rank[y]:
            self.par[y] = x
        else:
            self.par[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


uf = UnionFind(n)

for i in range(m):
    x,y = map(lambda x:int(x) - 1,input().split())
    uf.unite(x,y)
    
ans = 0 
for i in range(n):
    if uf.find(i)==uf.find(P[i]):
        ans+=1
print(ans)

Measured memory_bytes: 95084
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    s = list(_ for _ in input())
    t = list(_ for _ in input())
    s.sort()
    t.sort()
    t=t[::-1]
    if ''.join(s) <''.join(t):        
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()


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

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		var m = p[1];
		var min = 0;
		var max = n;
		for(int i = 0; i < m; i++)
		{
			p = Input().ToInt();
			min = Math.Max(p[0], min);
			max = Math.Min(p[1], max);
		}
		Console.WriteLine(Math.Max(0, max-min+1));
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}



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

int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> A(N), S(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  ll s = 0;
  for (int i = 0; i < N; i++) {
    s += A.at(i);
    S.at(i) = s;
  }
  int i = N - 2;
  for (; i >= 0; i--) {
    if (S.at(i) * 2LL < A.at(i+1)) break;
  }
  cout << N - 1 - i << endl;
  
  return 0;
}



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

using namespace std;

int main(void)
{
    int A, B;
    cin >> A >> B;
    if(A < 13){
        B /= 2;
        if(A <= 5){
            B = 0;
        }
    }

    cout << B << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <string> vs;
typedef vector <long long> vll;
typedef vector <pii> vpii;

#define forz(a, b) for((a) = 0; (a) < (b); (a)++)
#define forf(a, f, b) for((a) = f; (a) < (b); (a)++)
#define vsort(v) sort((v).begin(), (v).end()


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll k;
    string s;

    cin >> k >> s;

    if (s.size() <= k)
    {
        cout << s;
    }
    else
    {
        cout << s.substr(0, k) << "...";
    }

    return 0;
}

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

int main(){
    ll ans, I, O, T, S, L, J, Z;
    cin >> I >> O >> T >> J >> L >> S >> Z;
    ans = O;
    if (I && J && L) {
        vector<int> a(3);
        a[0] = I%2;
        a[1] = J%2;
        a[2] = L%2;
        if ((int)count(a.begin(), a.end(), 1) >= 2) {
            ans += 3;
            I--;J--;L--;
        }
    }
    ans += I/2*2+J/2*2+L/2*2;
    cout << ans << endl;
    return 0;
}


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

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray();
            long n = s[0];
            long m = s[1];

            int[] input = ReadLine().Split(' ').Select(int.Parse).ToArray();

            var dic = new Dictionary<int, int>();

            for (int i = 0; i < n; i++)
            {
                if (!dic.ContainsKey(input[i]))
                {
                    dic.Add(input[i], 1);
                }
                else
                {
                    dic[input[i]]++;
                }
            }
            var hoge = dic.OrderBy(x => x.Value).ToArray();
            int ans = 0;
            for (int i = 0; i < hoge.Count()-m; i++)
            {
                ans += hoge[i].Value;
            }
            WriteLine(ans);
        }
        
    }



}

Measured memory_bytes: 41680
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

int main(){
    ll h, w, k;
    cin >> h >> w >> k;

    //dp[i][j] : 高さiで幅jに行ける本数
    ll dp[h+2][w+2] = {};
    dp[0][0] = 1;
    rep(i, h)rep(j, w){
        //
        rep(bit, (1<<(w-1))){
            //正しい線の引き方か？
            bool isok = true;
            rep(b, w)if(1<<b & bit){
                if(1<<(b+1) & bit){
                    isok = false;
                    break;
                }
            }
            if(!isok)continue;

            //右方向へ移動する
            if((1<<j) & bit){
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j+1] %= MOD;
            }
            //左方向へ移動する
            else if(j > 0 && ((1<<(j-1)) & bit)){
                dp[i+1][j-1] += dp[i][j];
                dp[i+1][j-1] %= MOD;
            }
            //そのまま下へ
            else {
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
        }
    }

    cout << dp[h][k-1] << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,ans=0,a,b;
    cin>>n>>m;
    int h[n];
    bool ig[n];
    for(int i=0;i<n;i++)ig[i]=true;
    for(int i=0;i<n;i++)cin>>h[i];
    for(int i=0;i<m;i++){
        cin>>a>>b;
        if(h[a-1]<=h[b-1])ig[a-1]=false;
        if(h[a-1]>=h[b-1])ig[b-1]=false;
    }
    for(int i=0;i<n;i++){
        if(ig[i])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4060
#include<stdio.h>
#include<string.h>
int main(void)
{
    char x[1000][1001];
    long long int i = 0,j = 0,sum = 0,a,b = 0;
    while(1){
        scanf("%s",x[i]);
        if(x[i][0] == '0')break;
        i++;
        b++;
    }
    while(1){
        a = strlen(x[j]);
        for(i = 0;i < a;i++){
            //printf("%d\n",x[i] - '0');
            sum += x[j][i] - '0';
        }
        printf("%lld\n",sum);
        sum = 0;
        j++;
        if(j == b)break;
    }
 
 
    return 0;
}


Measured memory_bytes: 2036
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>

int main(){
	std::string a,b;
	std::cin>>a>>b;
	std::sort(a.begin(),a.end(),[](const char &a,const char &b){
		return a<b;
	});
	std::sort(b.begin(),b.end(),[](const char &a,const char &b){
		return a>b;
	});
	printf("%s\n",a<b?"Yes":"No");
	return 0;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  ll n, k;
  cin >> n >> k;
  string s;
  cin >> s;

  int h = 0;
  rep(i, 0, n) {
    if (s[i] == 'L') {
      if (i == 0) continue;
      if (s[i - 1] == 'L') h++;
    }

    if (s[i] == 'R') {
      if (i == n - 1) continue;
      if (s[i + 1] == 'R') h++;
    }
  }

  h = min(n - 1, h + (k * 2));
  cout << h << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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;
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

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

    int cost[N];
    for(int i = 0; i < N; i++) cost[i] = inf;
    cost[0] = 0;
    for(int i = 0; i < N - 1; i++) {
        cost[i + 1] = min(cost[i + 1], cost[i] + abs(h[i] - h[i + 1]));
        if(i == N - 2) break;
        cost[i + 2] = min(cost[i + 2], cost[i] + abs(h[i] - h[i + 2]));
    }

    cout << cost[N - 1] << "\n";
    return 0;
}

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

int main() {
  vector<int> vecA(9);
 
  for (int i = 0; i < 9; i++) {
    cin >> vecA.at(i);
  }
  
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    int B;
    cin >> B;
    for (int i = 0; i < 9; i++) {
      if (B == vecA.at(i)) {
        vecA.at(i) = 0;
      }
    }
  }
  
  if (vecA.at(0) == 0 && vecA.at(3) == 0 && vecA.at(6) == 0) {
    cout << "Yes" << endl;
  }
  else if (vecA.at(1) == 0 && vecA.at(4) == 0 && vecA.at(7) == 0) {
    cout << "Yes" << endl;
  }
  else if (vecA.at(2) == 0 && vecA.at(5) == 0 && vecA.at(8) == 0) {
    cout << "Yes" << endl;
  }
  else if (vecA.at(0) == 0 && vecA.at(1) == 0 && vecA.at(2) == 0) {
    cout << "Yes" << endl;
  }
  else if (vecA.at(3) == 0 && vecA.at(4) == 0 && vecA.at(5) == 0) {
    cout << "Yes" << endl;
  }
  else if (vecA.at(6) == 0 && vecA.at(7) == 0 && vecA.at(8) == 0) {
    cout << "Yes" << endl;
  }
  else if (vecA.at(0) == 0 && vecA.at(4) == 0 && vecA.at(8) == 0) {
    cout << "Yes" << endl;
  }
  else if (vecA.at(2) == 0 && vecA.at(4) == 0 && vecA.at(6) == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0];
		var A = (uint)I[1];
		var B = (uint)I[2];
		if (BitCount(A ^ B) % 2 == 0) { WriteLine("NO"); return; }
		WriteLine("YES");
		var l = Generate(N, A, B);
		WriteLine(string.Join(" ", l));
	}
	List<uint> Generate(int N, uint A, uint B)
	{
		if (N == 1) return new List<uint> { A, B };
		B ^= A;
		var cnt = BitCount(B);
		var perm = new int[N];
		var one = N - 1;
		var zero = 0;
		for (var i = 0; i < N; i++) perm[i] = (B & (1u << i)) != 0 ? one-- : zero++;
		var iperm = new int[N];
		for (var i = 0; i < N; i++) iperm[perm[i]] = i;
		B = ((1u << cnt) - 1) << (N - cnt);
		var ans = new List<uint>();
		var lim = 1u << (N - 1);
		for (var i = 0u; i < lim; i++) ans.Add(i ^ (i >> 1));
		foreach (var i in Generate(N - 1, 1u << (N - 2), B ^ lim)) ans.Add(i ^ lim);
		for (var i = 0; i < ans.Count; i++)
		{
			var s = 0u;
			for (var j = 0; j < N; j++) if ((ans[i] & (1u << j)) != 0) s |= 1u << iperm[j];
			ans[i] = s ^ A;
		}
		return ans;
	}
	public static int BitCount(uint n)
	{
		n = (n & 0x55555555) + ((n >> 1) & 0x55555555);
		n = (n & 0x33333333) + ((n >> 2) & 0x33333333);
		n = (n & 0x0f0f0f0f) + ((n >> 4) & 0x0f0f0f0f);
		n = (n & 0x00ff00ff) + ((n >> 8) & 0x00ff00ff);
		return (int)((n & 0x0000ffff) + ((n >> 16) & 0x0000ffff));
	}
}


Measured memory_bytes: 24924
a,b = map(int,input().split())
if a == 0 or b == 0:
  print("Zero")
else:
  if 0<a<=b<=10**9+1:
    print("Positive")
  elif a<=0<=b<=10**9+1:
    print("Zero")
  elif a<=b<0:
    if (b-a+1)%2 == 0:
      print("Positive")
    else:
      print("Negative")

Measured memory_bytes: 3060