akhauriyash/Code-Regression huggingface dataset:
N, K = map(int, input().split())
A = list(map(lambda x:int(x)-1, input().split()))
db = [[0]*N for _ in range(60)]
db[0] = A[:]
for i in range(1,60):
  for j in range(N):
    db[i][j] = db[i-1][db[i-1][j]]
ans = p = 0
while K>0:
  if K%2==1:
    ans = db[p][ans]
  p += 1
  K >>= 1
print(ans+1)


Measured memory_bytes: 184216
function Main(input) {
  var lines = input.split('\n');
  var N = Number(lines[0]);
  var S = lines[1];
  var count = 0;
  var before = '';
  for (var i = 0; i < N; i ++) {
    var current = S.charAt(i);
    if (before !== current) {
      count++;
    }
    before = current;
  }
  console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    while(1<2)
    {cin >> a >> b;
    if (a==0 && b==0) break;
    else if (a>b) cout << b << " " << a << "\n";
    else cout << a << " " << b << "\n";}
    return 0;
    

}



Measured memory_bytes: 3092
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from math import atan,tan,pi

a,b,x = map(int,read().split())

def max_volume(theta):
    # 弧度法にする
    theta = theta/180*pi
    if theta<atan(b/a):
        # 半分より上のパターン
        area = a*b-a*a*tan(theta)/2
    else:
        area = b*(b/tan(theta))/2
    return area*a

left = 0 # おさまっている
right = 90 # あふれている
while right - left > 1e-7:
    mid = (left+right)/2
    if max_volume(mid) <= x:
        right = mid
    else:
        left = mid

answer = (left+right)/2
print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  int cnt = 0;
  for (int i = A; i <= B; ++i) {
    string s = to_string(i);
    int l = 0;
    int r = s.size() - 1;
    while (l < r && s[l] == s[r]) {
      ++l;
      --r;
    }
    if (l >= r) {
      ++cnt;
    }
  }
  printf("%d\n", cnt);
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int X;
    cin >> X;
    X /= 200;
    cout << 10 - X << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void){

    ll N,K,Q; cin>>N>>K>>Q;
    vector<ll> A(N+1, K);
    for (int i = 1; i <= Q; ++i) {
        ll tmp; cin>>tmp;
        A[tmp]++;
    }
    for (int i = 1; i <= N; ++i) {
        if(A[i]-Q <= 0){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main()
{
  string s,t;
  ll n,i,ans=0;
  cin>>s>>t;
  n=s.length();
  for(i=0;i<n;i++)
  {
    if(s[i]!=t[i])
       ans++;
       }
       cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3916
//by rko27
//One more....
//---------------------------------------------------------------------------------------------------------------------------------------------------

#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int  long long 
#define ll  long long 
#define pb push_back
#define mp make_pair
#define fe first
#define se second
#define nl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)(x.size())
#define god ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

//----------------------------------------------------------------------------------------------------------------------------------------------------


int mod=1000000000+7;
int modu=998244353;

//----------------------------------------------------------------------------------------------------------------------------------------------------

ll power(ll x,ll y){ll res=1;x=x;while(y>0){if(y&1)res=(res*x);y=y>>1;x=(x*x);}return res;}
ll powe(ll x, ll y){ x = x%mod, y=y%(mod-1);ll ans = 1;while(y>0){if (y&1){ans = (1ll * x * ans)%mod;}y>>=1;x = (1ll * x * x)%mod;}return ans;}
void fun()
{
//	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	//#endif
	//786
}
bool isPrime(int n){for(int i=2;i*i<=n;i++)if(n%i==0) return false;return true;}
ll ncr(ll n,ll r){ll res=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){res*=(n-i);res/=(i+1);}return res;}

//-------------------------------------------------------------------------------------------------------------------------------------------------------

const int N=1e6+7;
bool visited[N];
std::vector<int> v[N];
int ans;
int dp[N];

//--------------------------------------------------------------------------------------------------------------------------------------------------------

int dfs(int node)
{
	if(visited[node]) return dp[node];
	int ans=0;
	visited[node]=true;
	for(auto i: v[node])
	{
		//if(!visited[i])
		ans = max(ans, dfs(i)+1);
	}
	//ans=max(ans,k);
	dp[node]=ans;
	return ans;
}

//--------------------------------------------------------------------------------------------------------------------------------------------------------
signed main() 
{
	//god;
	//rko;
	fun();
	int ttt=1; //cin>>ttt;
	while(ttt--)
	{
		memset(dp,-1,sizeof(dp));
		int n,m; cin>>n>>m;
		for(int i=0;i<m;i++)
		{
			int x,y; cin>>x>>y;
			v[x].pb(y);
		}
		int ans=0;
		for(int i=1;i<=n;i++)
		{
			if(!visited[i]) {
				//dfs(i);
				ans=max(ans, dfs(i));
			}
		}
		cout<<ans;
	}
	return 0;
}

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

int main() {
  int N, X_Y;
  cin >> N;
  
  int V[N], C[N];
  for(int i=0; i<N; i++) {
    cin >> V[i];
  }
  
  for(int i=0; i<N; i++) {
    cin >> C[i];
  }
  
  X_Y = 0;
  for(int i=0; i<N; i++) {
    if(V[i] > C[i]) {
      X_Y = X_Y + (V[i] - C[i]);
    }
  }
  
  cout << X_Y << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vector<string> S(N); cin >> S;
    map<string, int> cnt;
    int M = 0;
    REP(i, N){
        cnt[S[i]] += 1;
        Max(M, cnt[S[i]]);
    }

    for(auto x: cnt) if(x.s == M) Out(x.f);

    return 0;
}


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

using namespace std;

#define REP(i,m) for(ll i=0; i<m; i++)
#define FOR(i,n,m) for(ll i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

ll POW(ll a, ll b){
	if(b==0) return 1LL;
	if(b==1) return a;
	if(b%2==0) return POW(a*a%INF,b/2);
	return a*POW(a,b-1)%INF;
}

int main(){
	int m, d;
	cin >> m >> d;
	int ans = 0;
	FOR(i, 1, m+1){
		FOR(j, 1, d+1){
			int s = j/10;
			int t = j%10;
			if(s>=2 && t>=2 && s*t==i) ans++;
		}
	}
	cout << ans << endl;
	return 0;
} 


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>

using namespace std;

int main() {
  int h, w;
  vector <vector <char> > A;

  int i,j, counter; 

  cin >> h >> w; 
  
  A.resize(h);
  for(i=0;i<h;i++){
    A[i].resize(w);
  }
  counter=0;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin >> A[i][j];
      if(A[i][j]=='#')
	counter++;
    }
  }

  if(counter>w+h-1){
    cout << "Impossible" <<endl;
    return 0;
  }
  
  i=0; j=0;
  //  printf("(%d,%d)%c\n",i,j,A[i][j]);    
  
  do{
    if(A[i][j+1]=='#'){
      if(A[i+1][j]!='#'){	
	j++;
      }else{
	cout << "Impossible" << endl;
	return 0;
      }
    }else if(A[i+1][j]=='#'){
      i++; 
    }else{
      cout << "Impossible" << endl;
      return 0;
    }
    //    printf("(%d,%d)%c\n",i,j,A[i][j]);
  }while(i<h-1 && j<w-1);


  if(i==h-1){
    do{      
      if(A[i][j+1]=='#'){
	j++;
      }else{
	cout << "Impossible" << endl;
	return 0;
      }
    }while(j!=w-1);
  }else{
    do{      
      if(A[i+1][j]=='#'){
	i++;
      }else{
	cout << "Impossible" << endl;
	return 0;
      }
    }while(i!=h-1);
  }

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;

const int maxn = 200002;

int n, m;

struct node
{
	int l, r;
	long long maxv, lazy;
} segTree[maxn<<2];

void build(int idx, int l, int r) {
	segTree[idx].l = l;
	segTree[idx].r = r;
	segTree[idx].maxv = segTree[idx].lazy = 0;

	if (l == r)
		return;

	int mid = (l+r)>>1;
	build(idx<<1, l, mid);
	build((idx<<1)+1, mid+1, r);
}

void update(int idx) {
	segTree[idx].maxv = max(segTree[idx<<1].maxv, segTree[(idx<<1)+1].maxv);
}

void pushdown(int idx) {
	if (segTree[idx].lazy) {
		long long v = segTree[idx].lazy;
		segTree[idx].lazy = 0;

		segTree[idx<<1].maxv += v;
		segTree[idx<<1].lazy += v;
		segTree[(idx<<1)+1].maxv += v;
		segTree[(idx<<1)+1].lazy += v;
	}
}

void add(int idx, int st, int en, long long v) {
	if (st <= segTree[idx].l && segTree[idx].r <= en) {
		segTree[idx].maxv += v;
		segTree[idx].lazy += v;
		return;
	}

	pushdown(idx);

	int mid = (segTree[idx].l + segTree[idx].r)>>1;
	if (st <= mid)
		add(idx<<1, st, en, v);
	if (en > mid)
		add((idx<<1)+1, st, en, v);

	update(idx);
}

long long query(int idx, int st, int en) {
	if (st <= segTree[idx].l && segTree[idx].r <= en)
		return segTree[idx].maxv;

	pushdown(idx);

	int mid = (segTree[idx].l + segTree[idx].r)>>1;
	if (en <= mid)
		return query(idx<<1, st, en);
	if (st > mid)
		return query((idx<<1)+1, st, en);

	return max(query(idx<<1, st, en), query((idx<<1)+1, st, en));
}

struct interval
{
	int l, r, v;
};

bool mycmp(const interval& a, const interval &b) {
	return a.r < b.r;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m;

	vector<interval> intervals(m);
	for (int i = 0; i < m; ++i) {
		cin >> intervals[i].l >> intervals[i].r >> intervals[i].v;
	}

	sort(intervals.begin(), intervals.end(), mycmp);
	
	build(1, 1, n);

	int j = 0;
	for (int i = 1; i <= n; ++i) {
		add(1, i, i, query(1, 1, i));

		while (j < m && intervals[j].r == i) {
			add(1, intervals[j].l, intervals[j].r, intervals[j].v);
			++j;
		}
	}

	long long ans = max(0LL, query(1, 1, n));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 16896
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
const ld pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld radian(ld a, ld b, ld c, ld d) {
	return sqrt(pow(a - c, 2) + pow(b - d, 2));
}
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n, m;
	cin >> n >> m;
	cout << (n - 1)*(m - 1) << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

v = Array.new(8, 0)
god = 0

n.times do |i|
  color = a[i]/400
  if color < 8
    v[color] += 1
  else
    god += 1
  end
end

uzomuzo = v.count{|x| x>0}

ans = []
ans << [uzomuzo,1].max
ans << uzomuzo+god


puts ans.join(" ")


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;

ll in[12345678], jikan[12345678], used[12345678];
signed main() {
	ll n, l; cin >> n >> l;
	in[0] = 0; in[n + 1] = 0;
	rep2(i, n) { cin >> in[i]; }
	queue<ll> que;
	rep2(i, n) {
		if (in[i - 1] < in[i] && in[i] > in[i + 1]) { 
			jikan[i] = max(jikan[i - 1], jikan[i + 1]) + (l - in[i]); used[i]++; in[i] = 0;
			if (used[i - 1] == 0) { que.push(i - 1); }
			if (used[i + 1] == 0) { que.push(i + 1); }
		}
	}
	while (que.size()) {
		ll a = que.front(); que.pop();
		if (used[a] != 0) { continue; }
		if (a == 0 || a == n + 1) { continue; }
		if (in[a - 1] < in[a] && in[a] > in[a + 1]) {
			jikan[a] = max(jikan[a - 1], jikan[a + 1]) + (l - in[a]); used[a]++; in[a] = 0;
			if (used[a - 1] == 0) { que.push(a - 1); }
			if (used[a + 1] == 0) { que.push(a + 1); }
		}
	}
	ll ans = 0;
	rep2(i, n) { ans = max(ans, jikan[i]); }
	cout << ans << endl;
	return 0;
}


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

#define MAX_N 100
#define MAX_U 10000

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

	vector<int> v(n),w(n);	//??????n???vector?????£?¨?
	for(int i=0;i<n;i++){
		cin>>v[i]>>w[i];
	}
	
	//dp?????£?¨???¨?????????
	int dp[MAX_N+1][MAX_U+1];
	for(int i=0;i<MAX_N+1;i++){
		for(int j=0;j<MAX_U+1;j++){
			dp[i][j] = 0;
		}
	}
	
	//???????????§????????´??°
	for(int i=1;i<=n;i++){
		for(int j=1;j<=u;j++){
			if( j-w[i-1]>=0 ){	//j-w[i-1]???<0??\????????¨??????????????§????????????????????§?????§??????
				dp[i][j] = max( dp[i-1][j-w[i-1]]+v[i-1] , dp[i-1][j] );
			}
			else dp[i][j] = dp[i-1][j];
		}
	}
	
	int ans = 0;
	for(int i=0;i<=u;i++){
		ans = max(ans,dp[n][i]);	//n???????????§?????¢??????????????????????????????u??\????????¶???????????????
	}
	
	cout<<ans<<endl;
}

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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    
    if(a<=b && a<=c){
        if(b<=c)
            cout << a << " " << b << " " << c << endl;
        else
            cout << a << " " << c << " " << b << endl;
    }
    else if(b<=a && b<=c){
        if(a<=c)
            cout << b << " " << a << " " << c << endl;
        else
            cout << b << " " << c << " " << a << endl;
    }
    else if(c<=a && c<=b){
        if(a<=b)
            cout << c << " " << a << " " << b << endl;
        else
            cout << c << " " << b << " " << a << endl;
    }
    else{
        cout << a << " " << b << " " << c << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/
 
const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<ll, ll, ll> T;

ll dp[110][4][4][4];

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

    int n; cin >> n;
    dp[0][3][3][3] = 1;

    for(int i=1; i<=n; ++i){
        for(int j=0; j<4; ++j){
            for(int k=0; k<4; ++k){
                for(int l=0; l<4; ++l){

                    for(int a=0; a<4; ++a){

                        if(j==0 && k==1 && a==2) continue;
                        if(j==0 && l==1 && a==2) continue;
                        if(k==0 && l==2 && a==1) continue;
                        if(k==0 && l==1 && a==2) continue; 
                        if(k==1 && l==0 && a==2) continue;

                        dp[i][k][l][a] += dp[i-1][j][k][l];
                        chmod(dp[i][k][l][a]);
                    }
                }
            }
        }
    }

    ll ans = 0;
    for(int j=0; j<4; ++j) for(int k=0; k<4; ++k) for(int l=0; l<4; ++l){
        ans += dp[n][j][k][l];
        chmod(ans);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

int main(){
int n,sol=0;
cin>>n;
while(n>5){
    if(n>=500){
        sol=sol+1000;
        n=n-500;
    }else{
     if(n>=5){
        sol=sol+5;
        n=n-5;
     }

    }
} cout<<sol;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int DP1[20000][5000], DP2[20000][5000];

int main() {
  string S;
  cin>>S;
  int x, y;
  cin>>x>>y;
  vector<int> xarr, yarr;
  yarr.push_back(0);
  bool nowx = true;
  bool firstx = true;
  int num = 0;
  for(int i=0;i<S.size();++i) {
    if(S[i]=='F') num++;
    else {
      if(nowx) {
        xarr.push_back(num);
      }
      else {
        yarr.push_back(num);
      }
      nowx ^= 1;
      num = 0;
    }
  }
  if(nowx) xarr.push_back(num);
  else yarr.push_back(num);
  DP1[10000][0] = 1;
  DP2[10000][0] = 1;
  for(int i=0;i<xarr.size();++i) {
    for(int j=0;j<20000;++j) {
      if(DP1[j][i]>0) {
        if(i==0) {
          DP1[j+xarr[i]][i+1] = 1;
        }
        else {
          DP1[j+xarr[i]][i+1] = 1;
          DP1[j-xarr[i]][i+1] = 1;
        }
      }
    }
  }
  for(int i=0;i<yarr.size();++i) {
    for(int j=0;j<20000;++j) {
      if(DP2[j][i]>0) {
        DP2[j+yarr[i]][i+1] = 1;
        DP2[j-yarr[i]][i+1] = 1;
      }
    }
  }
  if(DP1[10000+x][xarr.size()]==1 && DP2[10000+y][yarr.size()]==1) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 73448
n = int(input())
h = list(map(int,input().split()))

# 簡易版最長増加部分列問題...?
# 右に移動できるマスに 1 を代入
# そうでないマスに -1 を代入
for i in range(n-1):
    if h[i] >= h[i+1]:
        h[i] = 1
    else:
        h[i] = -1
h[-1] = 0
cnt = 0
for i in range(n):
    if h[i] == 1:
        cnt += 1
    else:
        h[i-1] = cnt
        cnt = 0
print(max(h))

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

int main() {
	int n;
	long long k,c[100000]={0},d=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
	    int a,b;
	    cin>>a>>b;
	    c[a-1]+=b;
	}
	for(int i=0;i<100000;i++){
	    d+=c[i];
	    if(k<=d){
	        d=i+1;
	        i=100000;
	    }
	}
	cout<<d<<endl;
}

Measured memory_bytes: 1024
n, m, c = map(int, input().split())
B = list(map(int, input().split()))
A = []
cnt = 0
for i in range(n):
    tmp = list(map(int, input().split()))
    A.append(tmp)


for i in range(n):
    tmp = c
    for j in range(m):
        tmp += A[i][j]*B[j]
    
    if tmp > 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
#define ll long long


char c[3][3];


int main(){

	for (int i = 0; i < 3; i++){
		for (int j = 0; j < 3; j++){
			cin >> c[i][j];
		}
	}

	cout << c[0][0] << c[1][1] << c[2][2] << endl;

	return 0;
}


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

int N;
string s;

typedef pair<string,string> P;

map<P,int> A[2];

void cal(string s, int idx){
  
  for(int i=0;i<(1<<N);i++){
    
    string a, b;
    
    for(int j=0;j<N;j++){
      if( ( i >> j ) & 1 ) a += s[j];
      else b += s[j];
    }
    
    reverse( b.begin(), b.end() );
    
    A[idx][P(a+b,b)]++;
    
  }
  
}

void solve(){
  
  cal( s.substr( 0, N ), 0 );
  
  string tmp = s.substr( N, N );
  reverse(tmp.begin(), tmp.end());
  
  cal( tmp, 1 );
  
  int ans = 0;
  
  for(pair<P,int> p : A[0] ) ans += p.second * A[1][p.first];
  
  cout<<ans<<endl;
  
}

signed main(){
  
  cin>>N>>s;
  
  solve();
  
  return 0;
}


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

int main(){
  string S;
  cin >> S;
  int N = S.size();
  vector<int> ans(N, 0);
  vector<int> temp(2, 0);
  char dirNow, dirNext;
  dirNext = S[0];
  int count = 0;
  for(int i = 0; i < N - 1; i++){
    dirNow = dirNext;
    dirNext = S[i+1];
    if(dirNow == 'L'){
      count = 0;
      temp = {0,0};
      continue;
    }
    if(count % 2 == 0) temp.at(0) += 1;
    else temp.at(1) += 1;
    if(dirNext == 'L'){
      if(count % 2 == 0) temp.at(1) += 1;
      else temp.at(0) += 1;
      if(count % 2 == 0){
        ans.at(i) += temp.at(0);
        ans.at(i+1) += temp.at(1);
      }else{
        ans.at(i) += temp.at(1);
        ans.at(i+1) += temp.at(0);     
      }
    }
    count++;
  }//i
  dirNext = S[N-1];
  count = 0;
  temp = {0,0};
  for(int i = N-1; i > 0; i--){
    dirNow = dirNext;
    dirNext = S[i-1];
    if(dirNow == 'R'){
      count = 0;
      temp = {0,0};
      continue; 
    }
    if(dirNext == 'R'){
      if(count % 2 == 0){
      ans.at(i) += temp.at(1);
      ans.at(i-1) += temp.at(0);
      }else{
              ans.at(i) += temp.at(0);
      ans.at(i-1) += temp.at(1);
      }
      count = 0;
      continue;
    }
    if(count % 2 == 0) temp.at(1) += 1;
    else temp.at(0) += 1;
    count++;
  }//i
  for(int i = 0; i < N-1; i++){
    cout << ans.at(i) << " ";
  }
  cout << ans.at(N-1) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_utility.hpp>
#include <utility>
#include <boost/foreach.hpp>
#include <cmath>

long long int n, a, b;

template <typename T> class Mod {
  T m;
  T __swap(T *a, T *b) {
    T tmp;

    tmp = *a;
    *a = *b;
    *b = tmp;
  }
  T __modinv(T a) {
    T b = m, u = 1, v = 0;
    while (b) {
      T t = a / b;
      a -= t * b; __swap(&a, &b);
      u -= t * v; __swap(&u, &v);
    }
    u %= m;
    if (u < 0) {
      u += m;
    }
    return u;
  }
public:
  Mod(T param) {
    m = param;
  }
  T plus(T a, T b) {
    // O(1)
    a %= m;
    b %= m;
    return (a + b) % m;
  }
  T minus(T a, T b) {
    // O(1)
    T ret;
    a %= m;
    b %= m;
    ret = a - b;
    if (ret < 0) {
      return ret + m;
    }
    return ret;
  }
  T mul(T a, T b) {
    // O(1)
    a %= m;
    b %= m;
    return (a * b) % m;
  }
  T div(T a, T b) {
    // O( max(log(a), log(b)) ) (?)
    T ret;

    a = a % m;
    ret = a * __modinv(b) % m;

    return ret;
  }
};

Mod<long long int> md(1000000000 + 7);

long long int func1(long long int n) {
  long long int tmp = 1;
  long long int nino_1000 = 1;

  // 10^3を求める
  for (long long int i = 1; i <= 1000; i++) {
    nino_1000 = md.mul(nino_1000, 2);
  }
  // 10^nを求める
  for (long long int i = 1; i <= n / 1000; i++) {
    tmp = md.mul(tmp, nino_1000);
  }
  for (long long int i = 1; i <= n % 1000; i++) {
    tmp = md.mul(tmp, 2);
  }
  tmp = tmp - 1;

  return tmp;  
}

long long int func2(long long int n, long long int a) {
  long long int tmp = 1;

  for (long long int i = n; i >= n - a + 1; i--) {
    tmp = md.mul(tmp, i);
  }
  for (long long int i = 1; i <= a; i++) {
    tmp = md.div(tmp, i);
  }

  return tmp;
}

long long int ans = 0, t1 = 0, t2 = 0, t3 = 0;

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

  t1 = func1(n);
  t2 = func2(n, a);
  t3 = func2(n, b);

  ans = md.minus(t1, t2);
  ans = md.minus(ans, t3);

  std::cout << ans << std::endl;

  return 0;
}

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

template<class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int N,H;
pv<int,int> sw;

void input() {
	cin>>N>>H;
	init(sw,N);
}

void solve() {
	sort(all(sw),[&](intpair l, intpair r){
		return l.fi==r.fi ? l.se > r.se : l.fi < r.fi;
	});
	intpair tuyoi = sw[N-1];
	sw.pop_back();

	sort(all(sw),[&](intpair l, intpair r) {
		return l.se > r.se;
	});

	int i;
	for(i=0; i<N-1; i++) {
		if(tuyoi.se >= H) {
			cout<<i+1<<endl;
			return;
		}
		if(sw[i].se <= tuyoi.fi) {
			if(tuyoi.fi < tuyoi.se) {
				H-=tuyoi.se; i++;
				if(H<=0) {
					cout<<i<<endl;
					return;
				}
			}
			cout<<i+(H+tuyoi.fi-1)/tuyoi.fi<<endl;
			return;
		}
		H-=sw[i].se;
		if(H<=0) {
			cout<<i+1<<endl;
			return;
		}
	}

	if(tuyoi.fi < tuyoi.se) {
		H-=tuyoi.se; i++;
		if(H<=0) {
			cout<<i<<endl;
			return;
		}
	}
	cout<<i+(H+tuyoi.fi-1)/tuyoi.fi<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


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

using namespace std;

int main()
{
    string s = "1974";
    string s1="";
    int flag = 1;
    for(int i=0; i<4; i++) {
      char a;
      cin >> a;
      s1+=a;
    }
    int ans = 1;
    sort(s1.begin(), s1.end());
    sort(s.begin(), s.end());
//    cout << s << "\n";
//    cout << s1 << "\n";
    for(int i=0; i<s.size(); i++) {
      if(s[i] != s1[i]) {
        flag = 0;
        break;
      }
    }
//    cin >> n1 >> n2 >> n3 >> n4;
//    int flag1=0, flag2=0, flag3=0, flag4=0;
//    if (n1 == 1 || n1 == 9 || n1 == 4 || n1 == 7) {
//      flag1 = 1;
//    }
//    else if (n2 == 1 || n2 == 9 || n2 == 4 || n2 == 7) {
//      flag2 = 1;
//    }
//    else if (n3 == 1 || n3 == 9 || n3 == 4 || n3 == 7) {
//      flag3 = 1;
//    }
//    else if (n4 == 1 || n4 == 9 || n4 == 4 || n4 == 7) {
//      flag4 = 1;
//    }
    if(flag) {
      cout << "YES\n";
    }
    else {
      cout << "NO\n";
    }
    return 0;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

ll fun(ll a,ll b){
  if(a > b)swap(a,b);
  return (b-a)/2;
}

int main(){
  ll n,a,b; cin >> n >> a >> b;
  if(a > b)swap(a,b);
  if((a-b)%2){
    cout << min({b-1, n-a, a+fun(1,b-a), n-b+1+fun(n,a+(n-b)+1)}) << endl;    
  } else {
    cout << fun(a,b) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
n,m,x = map(int,input().split())

ans = 0
C = []
A = []

money = [0]*2**n
moneymoney = []

for _ in range(n):
    c,*a = map(int,input().split())
    C += [c]
    A += [a]

for i in range(2**n):
    sum = [0]*m
    for j in range(n):
        if (i>>j)&1 == 1:
            for k in range(m):
                sum[k] += A[j][k]
            money[i] += C[j]
    if min(sum)>=x:
        moneymoney += [money[i]]
        
if moneymoney == []:
    ans = -1
else:
    ans = min(moneymoney)

print(ans)


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

using namespace std;

#define int long long
#define mem(v , val) memset(v , val , sizeof val)
#define endl '\n'

int big = 1000000000000010;
vector <int> v;

int n;

void rec(string &s , int level , int val)
{
    if(level == 1)
    {
        val = (val - 1 + 26) % 26;
        s += 'a' + val;
        return;
    }

    int idx = val % 26;
    idx = (idx - 1 + 26) % 26;

    s += 'a' + idx;
    rec(s , level - 1 , (val - 1) / 26);
    return;
}


void solve()
{
    cin >> n;

    int mul = 26 , x = 0;

    int start = -1;

    for(int i = 1 ; x <= big ; i++)
    {
        x += mul;
        mul = mul * 26;
        v.push_back(x);
        if(x >= n and start == -1)
            start = i;
    }

    string s;
    rec(s , start , n);

    reverse(s.begin() , s.end());
    cout << s << endl;
    return;
}


int32_t main()
{
    int t = 1;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
  ll a, b; cin >> a >> b;
  if(a <= 5) cout << 0 << endl;
  else if(a <= 12) cout << b / 2 << endl;
  else cout << b << endl;
}


Measured memory_bytes: 256
A1=input()

A2=input()

A3=input()

#N=int(N)

list1 = A1.split()

list1 = [int(i) for i in list1]


list2 = A2.split()

list2 = [int(i) for i in list2]


list3 = A3.split()

list3 = [int(i) for i in list3]


N = input()

N=int(N)

num=[]

for i in range(N):
    num.append(int(input()))


T1 = all([(i in num ) for i in list1])

T2 = all([(i in num ) for i in list2])

T3 = all([(i in num ) for i in list3])

T4 = all([(list1[0] in num),(list2[0] in num),(list3[0] in num)])

T5 = all([(list1[1] in num),(list2[1] in num),(list3[1] in num)])

T6 = all([(list1[2] in num),(list2[2] in num),(list3[2] in num)])

T7 = all([(list1[0] in num),(list2[1] in num),(list3[2] in num)])

T8 = all([(list1[2] in num),(list2[1] in num),(list3[0] in num)])

if (any([T1,T2,T3,T4,T5,T6,T7,T8])) == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9228
#include <iostream>
#include <algorithm>
#include <functional>
#include <numeric>
using namespace std;

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

int main() {
    int N;
    cin >> N;
    int a[110];
    rep(i, N)cin >> a[i];
    sort(a, a + N);
    cout << a[N - 1] - a[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    long long x, a, b;

    cin >> x >> a >> b;

    if(b-a <= 0){
        cout << "delicious" << endl;
    }

    else if(b-a <= x){
        cout << "safe" << endl;
    }

    else{
        cout << "dangerous" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    ll n, k;
    cin>>n>>k;
    n;
    vl sum(200015, 0);
    for(ll i=1; i<200015; i++)
    {
        sum[i]=i+sum[i-1];
        sum[i]%=MOD;
    }
    ll ans=0;
    for(ll j=k; j<=1+n; j++)
    {
        ll sum1=sum[n]-sum[n-j<0?0:n-j];
        ll sum2=sum[j-1];
        ans+=sum1-sum2+1;
        ans%=MOD;
        //cout<<sum1<<" "<<sum2<<endl;
    }
    if(ans<0)
    ans+=MOD;
    cout<<ans;
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector <double> v;
    v.resize(n);
    for(int i = 0; i < n; i++)
        cin >> v[i];
    sort(v.begin(), v.end());
    double ans = (v[0] + v[1]) / 2;
    for(int i = 2; i < n; i++)
        ans = (ans + v[i]) /  2;
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
const int maxn=110;
LL w[maxn],v[maxn];
LL  f[maxn][maxn<<2][maxn];
LL n,W;
void dp();
int main() {
    scanf("%lld%lld",&n,&W);
    for(int i=1; i<=n; ++i) {
        scanf("%lld%lld",&w[i],&v[i]);
    }
    LL tem=w[1];
    for(int i=1; i<=n; ++i) {
        w[i]-=tem;
    }
    dp();
    LL ret=0;
    for(int j=0; j<301; ++j) {
        for(int m=0; m<=n; ++m) {
            if(j+m*tem<=W)ret=std::max(f[n][j][m],ret);
        }
    }
    printf("%lld\n",ret);
    return 0;
}
void dp() {
    for(int i=1; i<=n; ++i) {
        for(int j=0; j<301; ++j) {
            for(int m=1; m<=n; ++m) {
                if(j<w[i]) f[i][j][m]=f[i-1][j][m];
                else f[i][j][m] = std::max(f[i-1][j-w[i]][m-1]+v[i],f[i-1][j][m]);
            }
        }
    }
}


Measured memory_bytes: 38272
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long k = sc.nextLong();
		int q = sc.nextInt();
        int[] a = new int[q];

        for(int i = 0; i < q; i++){
            a[i] = sc.nextInt();
        }

        long[] p = new long[n];
        Arrays.fill(p, 0);

        for(int i = 0; i < q; i++){
            p[a[i] - 1]++;
        }

        for(int i = 0; i < n; i++){
            if(p[i] > q - k) System.out.println("Yes");
            else System.out.println("No");
        }

    }

}


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

#define int long long
#define pb push_back
#define ff first
#define ss second

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int l,r,d;
    cin>>l>>r>>d;
    
    int ans=0;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
            ans++;
    }
    cout<<ans<<"\n";
    
}

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

template <typename T> void chmin(T &x,const T &y)
{
	if(x>y)x=y;
}
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=2000+5;
int n,k,m,ans;
int a[N],b[N];
bool mark[N];
bool a_xiao(int x,int y)
{
	return a[x]<a[y];
}
int q[N],top,nq[N];
void check(int l,int r)
{
	int nt=r-l+1;
	if(nt<k)return ;
	rep(i,l,r)nq[i-l+1]=a[i];
	int can=nt-k+1;
	nth_element(nq+1,nq+can,nq+nt+1);
	rep(i,1,can)q[++top]=nq[i];
}
void check(int x)
{
	top=0;
	int last=0;
	mark[n+1]=1;
	rep(i,1,n+1)
	if(mark[i])
	{
		check(last+1,i-1);
		last=i;
	}
	if(top<m){cout<<ans;exit(0);}
	nth_element(q+1,q+m,q+top+1);
	chmin(ans,q[m]-a[x]);
	mark[x]=1;	
}

int main()
{
	//freopen("1.in","r",stdin);
	cin>>n>>k>>m;
	rep(i,1,n)scanf("%d",a+i);
	rep(i,1,n)b[i]=i;
	sort(b+1,b+n+1,a_xiao);
	ans=1e9;
	rep(i,1,n)check(b[i]);
	cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#define L 10007
typedef struct Hash {
	struct Hash *n;
	long long k,v;
}hash;
int main(){
  long int s=0,t,n,m,i,j,x=0;
  hash *h[L],d[100001],*p;
  scanf("%ld%ld",&n,&m);
  d[0].k=0;d[0].v=1;d[0].n=NULL;h[0]=&d[0];
  for(i=1;i<=n;i++){
    scanf("%ld",&t);s=(s+t)%m;
    for(p=h[s%L];p!=NULL;p=p->n)if(p->k==s)break;
    if(p!=NULL)p->v++;
    else{d[i].k=s;d[i].v=1;d[i].n=h[s%L];h[s%L]=&d[i];}
  }
  for(i=0;i<L;i++)for(p=h[i];p!=NULL;p=p->n)x+=p->v*(p->v-1)/2;
  printf("%ld",x);
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
template < typename T > std::string to_string( const T& n ){
	std::ostringstream stm ;
	stm << n ;
	return stm.str() ;
}


int main(void){
	int n,m;
	cin >> n >> m;
	int A[n][m];
	int B[m];
	int C[n];
	for(int i = 0; i < n; i++){
		C[i] = 0;
		for(int j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}
	for(int i = 0; i < m; i++){
		cin >> B[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			C[i] += A[i][j]*B[j];
		}
	}
	for(int i = 0; i < n; i++){
		cout << C[i] <<"\n";
	}
	return 0;
}


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


int main(void){
    long  k,a,b;
    
    cin >> k;
    cin >> a;
    cin >> b;
    
    long pre = int(a/k) * k;
    long big = pre + k;
    
    if(pre < a and b < big){
        cout << "NG" << endl;
    }else{
        
        cout << "OK" << endl;
    }
}


Measured memory_bytes: 3644
package main
import "fmt"
func main() {
  var n,k int
  fmt.Scan(&n,&k)
  if n < k {
    var c float64
    for i:=1;i<=n;i++ {
      var t int = i
      var p float64 = 1/float64(n)
      for t < k {
        t *= 2
        p *= 0.5
      }
      c += p
    }
    fmt.Println(c)
  } else {
    var c float64 = float64(n-k+1)/float64(n)
    for i:=1;i<k;i++ {
      var t int = i
      var p float64 = 1/float64(n)
      for t < k {
        t *= 2
        p *= 0.5
      }
      c += p
    }
    fmt.Println(c)
  }
}

Measured memory_bytes: 512
use proconio::input;

fn main() {
    input! {
        (n, m): (usize, usize),
        a_vec: [usize; m],
    }

    let w: usize = a_vec.iter().sum();
    let p: isize = n as isize - w as isize;

    if p >= 0 {
        println!("{}", p);
    } else {
        println!("-1")
    }
}


Measured memory_bytes: 2276
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


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

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

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

int main(){

    int x;
    cin >> x;
    int n = 1e5;
    int max_dst;
    for(int i=0; i<n; i++){
        max_dst = (1.0/2.0)*i*(i+1);
        if(max_dst >= x){
            cout << i << endl;
            break;
        }
    }


}

Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))
tot=0
dic={}
for i in a:
  if i not in dic:
    dic[i]=1
  else:
    dic[i]+=1
for i in dic:
  tot+=int((dic[i]*(dic[i]-1))/2)

for i in range(N):
  c=dic[a[i]]-1
  print(tot-c)

Measured memory_bytes: 26268
H, W = (int(i) for i in input().split())
str = [input() for i in range(H)]

for i in range(W+2):
        print('#', end = "")
print("")

for i in range(H):
        print('#', end = "")
        print(str[i], end = "")
        print('#')

for i in range(W+2):
        print('#', end = "")
print("")


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

bool compare(const pair<long,long> &a,const pair<long,long> &b)
{
    if(a.first<b.first)
        return true;
    else if(a.first==b.first)
        return a.second>b.second;
    else
        return false;
}

int main()
{
    long n,m,i;
    cin>>n>>m;
    
    long p,q;
    
    vector<pair<long,long>> vect;
    vector<pair<long,long>>::iterator it;
    
    for(i=0;i<m;i++)
    {
        cin>>p>>q;
        vect.push_back(make_pair(p,q));
    }
    
    sort(vect.begin(),vect.end(),compare);
    
    long cnt=1,left=vect[0].first,right=vect[0].second;
    
    for(i=1;i<m;i++)
    {
        if(vect[i].first<right)
        {
            if(vect[i].second<right)
                right=vect[i].second;
        }
        else
        {    cnt++;
            right=vect[i].second;
        }    
    }
    cout<<cnt<<"\n";
    return 0;
}

Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		if(a >= b){
			for(int i = 0; i < a; i++){
				System.out.print(b);
			}
		}
		else{
			for(int i = 0; i < b; i++){
				System.out.print(a);
			}
		}
		stdIn.close();
	}
}


Measured memory_bytes: 35724
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    repi(i, h, 0)
    {
        string s;
        repi(j, w, 0)
        {
            if (i < b)
            {
                if (j < a)
                {
                    s.push_back('0');
                }
                else
                {
                    s.push_back('1');
                }
            }
            else
            {

                if (j < a)
                {
                    s.push_back('1');
                }
                else
                {
                    s.push_back('0');
                }
            }
        }
        cout << s << "\n";
    }
    return 0;
}

Measured memory_bytes: 1280