akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main {
	int output[][] = new int[100][100];
	int dataset = 0;//????????°
	int touch = 0;//??£??\??°
	int number = 0;//?????¨?????\?????´???
	String input = null;
	BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String []args){
		Main run = new Main();
		run.Run();
	}
	public void Run(){
		for(int z = 0;z < 100;z++){
			for(int y = 0;y < 100;y++){
				output[z][y] = -1;
			}
		}
		while(true){
			try{
				input = read.readLine();
				if(dataset == 0){
					dataset = Integer.parseInt(input);
				}for(int z = 0;z < dataset;z++){
					input = read.readLine();
					String get[] = input.split(" ");
					for(int n = 0; n < get.length;n++){
						if(n == 0)number = Integer.parseInt(get[n]);
						if(n >= 2){
							touch = Integer.parseInt(get[n]);
							output[number-1][touch-1] = 1;
						}
					}
				}for(int z = 0;z < dataset;z++){
					for(int y = 0;y < dataset;y++){
						if(output[z][y] == -1)output[z][y] = 0;
					}
				}break;
			}catch(Exception e){
				
			}
		}
		for(int z = 0;z < dataset;z++){
			for(int y = 0;y < dataset;y++){
				if(y != dataset-1)System.out.print(output[z][y]+" ");
				else System.out.println(output[z][y]);
			}
		}
	}
}

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

int main() {
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  vector<int> X(N);
  X.at(0) = 0;
  for (int i = 1; i < N; i++) {
    if (S.at(i) == 'C' && S.at(i - 1) == 'A') {
      X.at(i) = X.at(i - 1) + 1;
    }
    else X.at(i) = X.at(i - 1);
  }
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    cout << X.at(r - 1) - X.at(l - 1) << endl;
  }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll ;
long long gcd(long long aaa,long long bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}
int main (){

    int N;
    string S,tmp = "abcdefghijklmnopqrstuvwxyz";
    cin >> N >> S;
    int count[100] = {},countt[100] = {},ans[100] = {};

    for(int i = 0; i < N-1; i++) {
        for(int j = 0; j < 26; j++) {
            for(int k = 0; k < N; k++) {
                if(i <= k) {
                    if(tmp[j] == S[k]) count[i] = 1;
                }else {
                    if(tmp[j] == S[k]) countt[i] = 1;
                }
            }
            if(count[i] == 1 && countt[i] == 1) {
                ans[i]++;
            }
            count[i] = 0;
            countt[i] = 0;
        }
    }
    int anss = 0;
    for(int i = 0; i < N-1; i++) {
        anss = max(anss,ans[i]);
    }
    cout << anss << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	if(n*a<b){
		printf("%d\n",n*a);
	}
	else{
		printf("%d\n",b);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll H, W;
  cin >> H >> W;
  vector<string> s(H);
  for(int i = 0; i < H; i++){
    cin >> s.at(i);
  }
  //W*i+jで点を表す
  vll p(H*W, INF);

  priority_queue<Pll, vector<Pll>, greater<Pll>> que;
  ll def = (s.at(0).at(0) == '.')?0:1;
  que.push(Pll(def, W*0+0));
  p.at(W*0+0) = def;
  vll dy = {1, 0};
  vll dx = {0, 1};
  while(!que.empty()){
    ll v = que.top().second;
    ll pp = que.top().first;
    que.pop();

    if(p.at(v) < pp) continue;
    for(int i = 0; i < 2; i++){
      ll yy = v / W + dy.at(i);
      ll xx = v % W + dx.at(i);
      if(yy >= H || xx >= W) continue;
      ll nextv = W * yy + xx;

      ll nextp;
      if(s.at(yy).at(xx) == '#' && s.at(v/W).at(v%W) == '.') nextp = pp + 1;
      else nextp = pp;

      if(nextp < p.at(nextv)){
        p.at(nextv) = nextp;
        que.push(Pll(nextp, nextv));
      }
    }
  }
  cout << p.at(H*W-1) << endl;
}

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

int H, W;
char S[25][25];

int d[450][450]; 

const int INF = 1.0e9;

void warshall_floyd(int n) {
  for (int k = 0; k < n; k++){       
    for (int i = 0; i < n; i++) {    
      for (int j = 0; j < n; j++) {  
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }
    
    for (int i = 0; i < H*W; i++) {
        for (int j = 0; j < H*W; j++) {
            d[i][j] = INF;
        }
    }
    
    for (int i = 0; i < H*W; i++) {
        d[i][i] = 0;
    }
    

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W-1; j++) {
            if (S[i][j] == '.' && S[i][j+1] == '.') {
                d[i*W + j][i*W + j+1] = 1;
                d[i*W + j+1][i*W + j] = 1;
            }
        }
    }

    for (int j = 0; j < W; j++) {
        for (int i = 0; i < H-1; i++) {
            if (S[i][j] == '.' && S[i+1][j] == '.') {
                d[i*W + j][(i+1)*W + j] = 1;
                d[(i+1)*W + j][i*W + j] = 1;
            }
        }
    }


    warshall_floyd(H*W);

    int ans = 0;
    for (int i = 0; i < H*W; i++) {
        for (int j = 0; j < H*W; j++) {
            if (d[i][j] != INF) {
                ans = max(ans, d[i][j]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <cstdlib>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

#define size(s) (ll)(s).size()

const ll inf = 1e9;

void bye() {
    cout << '\n';
    exit(0);
}

int n, m;
vector<vector<bool> > used;
vector<vector<char> > g;
vector<vector<pair<int, int> > > p;

bool check(int a, int b) {
	return a >= 0 && b >= 0 && a < n && b < m;
}

void dfs(int i, int j) {
	used[i][j] = 1;
	int tx = i;
	int ty = j + 1;
	if (check(tx, ty) && g[tx][ty] == '#') {
		p[tx][ty] = {i, j};
		dfs(tx, ty);
	}
	tx = i + 1;
	ty = j;
	if (check(tx, ty) && g[tx][ty] == '#') {
		p[tx][ty] = {i, j};
		dfs(tx, ty);
	}
}

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    cin >> n >> m;
    used.resize(n, vector<bool>(m));
	g.resize(n, vector<char>(m));
	p.resize(n, vector<pair<int, int> >(m));
	int num = 0;
	p[0][0] = {-1, -1};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> g[i][j];
			if (g[i][j] == '#') {
				num++;
			}
		}
	}
	dfs(0, 0);
	pair<int, int> v = p[n-1][m-1];
	int pth = 1;
	while (v.first != -1 && v.second != -1) {
		pth++;
		v = p[v.first][v.second];
	}
	if (pth == num) {
		cout << "Possible";
	} else {
		cout << "Impossible";
	}
    bye();
}


Measured memory_bytes: 256
#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;
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;
};
struct H {
    int x, y;
};
ll gcd(ll i, ll j) {//?????§??¬?´???°
    if (i > j) swap(i, j);
    if (i == 0) return j;
    return gcd(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
    return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad?????§?¨???????2??????????????¢
//---------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++
string a;
int b[3];
signed main(){
	cin>>a;
	for(int i=0;i<a.size();i++){
		b[(int)a[i]-'a']++;
	}
	int s=min(b[0],min(b[1],b[2]));
	b[0]-=s,b[1]-=s,b[2]-=s;
	if(b[0]<=1&&b[1]<=1&&b[2]<=1){
		cout<<"YES\n";
	}
	else{
		cout<<"NO\n";
	}
    getchar(); getchar();
}


Measured memory_bytes: 512
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &A[i]);
  }

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

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

  return 0;
}


Measured memory_bytes: 4812
#include <bits/stdc++.h>
using namespace std;
long long n,a[100050],dp[100400],k;
main()
{
    cin >> n >> k;
    for ( int i=1; i<=n; i++ )
        cin >> a[i];
    dp[1]=0;
    for ( int i=2; i<=n; i++ )
    {  dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
        if(i>k)
            for(int j=i-k; j<i-1; j++)
                dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
    else
        for(int j=1; j<i-1; j++)
                dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
    }
    cout << dp[n];
}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

struct SegTree {
	std::vector<std::pair<int, int> > data;
	int n;
	std::pair<int, int> merge(std::pair<int, int> a, decltype(a) b) {
		if (a.first <= b.first) return b;
		else return a;
	}
	SegTree(int n_, const std::vector<int> &a) {
		assert(n_ == (int) a.size());
		for (n = 1; n < n_; n *= 2);
		data.resize(2 * n);
		for (int i = 0; i < n_; i++) data[i + n] = {a[i], i};
		for (int i = n_; i < n; i++) data[i + n] = {-100, 0};
		for (int i = n - 1; i; i--) data[i] = merge(data[i << 1], data[i << 1 | 1]);
	}
	std::pair<int, int> max() {
		return data[1];
	}
	void set(int i, int val) {
		data[i + n] = {val, i};
		for (i += n; i >>= 1; ) data[i] = merge(data[i << 1], data[i << 1 | 1]);
	}
};

int n, k;
std::vector<int> a;
std::vector<int> depth;
std::vector<std::set<int> > child;
void dfs(int i, int de) {
	depth[i] = de;
	for (auto j : child[i]) {
		dfs(j, de + 1);
	}
}
std::vector<bool> used;
SegTree *tree;
void use(int i) {
	used[i] = true;
	tree->set(i, 0);
	for (auto j : child[i]) {
		if (!used[j]) use(j);
	}
}

int main() {
	n = ri();
	k = ri();
	a.resize(n);
	child.resize(n);
	depth.resize(n);
	used.resize(n);
	for (int i = 0; i < n; i++) a[i] = ri() - 1;
	for (int i = 1; i < n; i++) child[a[i]].insert(i);
	dfs(0, 0);
	
	int res = (a[0] != 0);
	tree = new SegTree(n, depth);
	while (1) {
		auto next = tree->max();
		if (next.first <= k) break;
		
		int min_depth = next.first - k + 1;
		int cur = next.second;
		for (int i = 0; i < next.first - min_depth; i++) cur = a[cur];
		assert(depth[cur] == min_depth);
		use(cur);
		res++;
	}
	
	std::cout << res << std::endl;
	
	return 0;
}



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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    bool flag=true;
    int n,m,X,Y;
    cin>>n>>m>>X>>Y;
    V x(n);V y(m);
    rep(i,n){
        cin>>x[i];
        if(x[i]==X)flag=false;
    }
    sort(RALL(x));
    rep(i,m){
        cin>>y[i];
        if(y[i]==Y)flag=false;
    }
    sort(ALL(y));
    if(y[0]-x[0]<1)flag=false;
    //y[0]~Yまでの数がx[0]ごえか
    if(Y-y[0]<1)flag=false;
    if(x[0]-X<1)flag=false;
    cout<<(flag?"No War":"War")<<endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FASTio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int 
#define endl '\n'
const int mod=1e9+7;

int main()
{
   FASTio;
  	int n,d;
  	cin>>n>>d;
  int ans=0;
  	while(n--)
    {
      double x,y;
      cin>>x>>y;
      if( d>=sqrt(pow(x,2)+pow(y,2)) )
         ans++;
    }
         cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//const int mod = 1e9 + 7;
const int mod = 998244353;
const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;//n乗を効率的に求める
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint dp[3005][3005];

int main() {
    int n,s;
    cin >> n >> s;
    vector<int> a(n);
    sort(a.begin(),a.end());
    rep(i,n) cin >> a[i];
    dp[0][0]=1;
    rep(i,n) {
      rep(j,s+1) {
        dp[i+1][j]+=dp[i][j]*2;
        if(j+a[i]<=s) dp[i+1][j+a[i]]+=dp[i][j];
         
      }
    }
  cout << dp[n][s].x << endl; 
    return 0;
}


Measured memory_bytes: 74164
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n; cin >> n;
	int64_t a = 0, b = 0, x = 0;

	cin >> a >> b;
	REP(n - 2) {
		int64_t s; cin >> s;
		x ^= s;
	}

	int64_t y = (a + b - x);
	//cout << y << endl;
	if (y & 1) {
		cout << -1 << endl;
		return 0;
	}
	//cout << y << " " << a + b << endl;
	if ((a + b) < y) {
		cout << -1 << endl;
		return 0;
	}
	//cout << y / 2 << " " << a << endl;
	if (a < (y / 2)) {
		cout << -1 << endl;
		return 0;
	}

	int64_t z = (a + b) - y;
	//cout << y / 2 << " " << z << endl;
	if (z & (y / 2)) {
		cout << -1 << endl;
		return 0;
	}

	int64_t ans = y / 2;
	FOR_DW(i, 62, 0) {
		if (z & ((int64_t)1 << i)) {
			if ((ans + ((int64_t)1 << i)) <= a) ans += (int64_t)1 << i;
		}
	}
	if (ans == 0) {
		cout << -1 << endl;
		return 0;
	}

	cout << (a - ans) << endl;

	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long x,k,d,e;
    cin>>x>>k>>d;
    e=x/d;
    e=abs(e);
  if(k<=e){
      if(x>0)
        x-=(k*d);
  else x+=(k*d);

  }
  else{
    if((k-e)%2==0){
        if(x>0)
            x-=e*d;
    else x+=e*d;
    }
    else{
 if(x>0)
            x-=e*d;
    else x+=e*d;

    x=min(abs(x-d),abs(x+d));
    }
  }
    cout<<abs(x)<<endl;
}


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

int main() {
  string str;
  cin >> str;
  int countA = 0;
  int countZ = 0;

  for(int i = 0; i < (int)str.size(); i += 1){
    if(str[i] == 'A'){
      countA = i;
      break;
    }
  }
  for(int i = (int)str.size(); i >= 0; i -= 1){
    if(str[i] == 'Z'){
      countZ = i;
      break;
    }
  }

  cout << countZ - countA + 1 << endl;

}


Measured memory_bytes: 640
#include  <iostream>
#include <algorithm>

constexpr int MAX_N=100000;

using ll=long long int;

int n;
ll A[MAX_N*2+1];

bool C(ll x) {
	for(int i=1;i<=n;++i) {
		int l=std::lower_bound(A+i,A+n+i,A[i-1]+x)-A;
		if(l==n+i)
			continue;
		int r=std::lower_bound(A+l+1,A+n+i,A[l]+x)-A;
		if(r==n+i)
			continue;
		if(A[n+i-1]-A[r]>=x)
			return true;
	}
	return false;
}

int main() {
	std::cin>>n;
	for(int i=1;i<=n;++i) {
		std::cin>>A[i];
		A[i+n]=A[i];
	}
	for(int i=1;i<=n*2;++i)
		A[i]+=A[i-1];

	ll lb=1,rb=(ll)n*1e9+1,mid=(lb+rb)/2;

	while(lb<rb-1) {
		if(C(mid)){
			lb=mid;
		}
		else{
			rb=mid;
		}
		mid=(lb+rb)/2;
	}

	std::cout<<lb<<std::endl;

	return 0;
}

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

int main(){
  int X,Y; cin >> X >> Y;
  
  if(2*X<=Y && Y<=4*X && Y%2==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}


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

int main()
{
	std::string S;
	std::cin >> S;
	using vi = std::vector<int>;
	using vvi = std::vector<vi>;
	vvi dp(S.size(), vi(2, -1));
	dp[0][0] = dp[0][1] = 1;
	for (int i{1}; i < (int)S.size(); i++)
	{
		if (i - 2 >= 0 && dp[i - 2][1] >= 0)
			dp[i][0] = dp[i - 2][1] + 1;
		if (i < (int)S.size() - 1 && dp[i - 1][0] >= 0)
			dp[i][1] = dp[i - 1][0] + 1;
		if (S[i - 1] != S[i] && dp[i - 1][0] >= 0)
			dp[i][0] = std::max(dp[i][0], dp[i - 1][0] + 1);
		if (i - 2 >= 0 && i + 1 < (int)S.size() && (S[i - 2] != S[i] || S[i - 1] != S[i + 1]) && dp[i - 2][1] >= 0)
			dp[i][1] = std::max(dp[i][1], dp[i - 2][1] + 1);
	}
	int ans{dp.back()[0]};
	if (dp.size() >= 2) ans = std::max(ans, dp[dp.size() - 2][1]);
	printf("%d\n", ans);

	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(3*n);
    rep(i, 3*n) cin >> a[i];
    sort(a.begin(), a.end());
    Int ans = 0;
    for (int i = n; i < n*3; i+=2) {
        ans += (Int)a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
z,*s=gets.split(/[
T]/,-1).map &:size;Y=Z=1<<8000;X=Y<<z;s.each_slice(2){|t,u|Y=Y>>t|Y<<t;u&&X=X>>u|X<<u};eval"puts X>>%d&Y>>%d&Z>0?:Yes: :No"%gets.split

Measured memory_bytes: 10748
using System;
using System.Text;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using static System.Array;

namespace AtcoderExpress
{


    class Program
    {

        static void Main(string[] args)
        {
            //var NK = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var L = double.Parse(Console.ReadLine());
            var L3 = L / 3;
            Console.WriteLine(Math.Pow(L3,3));
        }


    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int x, a, b; cin >> x >> a >> b;
	if( abs(a-x) > abs(b-x) ) cout << "B" << endl;
	else cout << "A" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int x,y;
	
	scanf("%d %d",&x,&y);
	if((x==2)&&(y==2)){
		puts("Yes");
	}else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)){
		puts("Yes");
	}else if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12)){
		puts("Yes");
	}else{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main()
{
	int N;
	string f1,f2;
	int ans;
	while(cin >> N && N)
	{
		ans=0;
		f1 = f2 = "";
		rep(nth, N)
		{
			cin >> f1 ;

			if((f1=="lu" && f2=="ru") || (f1=="ru" && f2=="lu")){
				ans++;
			}
			else if((f1=="ld" && f2=="rd") || (f1=="rd" && f2=="ld")){
				ans++;
			}
			f2 = f1;	
		}
		cout << ans << endl;
	}

	return 0;
}

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

using namespace std;

int main() {
    int n;
    vector<int> v;
    cin >> n;
    while (n) v.push_back(n % 10), n /= 10;
    for (int i = 0; i < v.size(); i++) {
        if (v[i] != v[v.size() - 1 - i]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

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

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

  int ans = 1000 - (N%1000);

  cout << ans%1000 << endl;

  //cout << M << endl;*/

  /*int N = 3;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }*/

  /*for (int i = 0; i < vec.size(); i ++){
    cout << vec.at(i) << endl;
  }

  for (int i = 0; i < vec.size()-1; i ++){
    cout << vec.at(i) << " ";
  }
  cout << vec.at(vec.size() - 1) << endl;*/
}


Measured memory_bytes: 3640
import sys


def slove():
    input = sys.stdin.readline
    n, t = list(map(int, input().rstrip('\n').split()))
    tl = list(map(int, input().rstrip('\n').split()))
    mt = 0
    for i in range(n-1):
        mt += (min(tl[i] + t, tl[i+1]) - tl[i])
    print(mt + t)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 78064
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int N = 0;
	scanf("%d", &N);
	int remain = N%2 + N/2;
	double ans = (double) remain / (double)N;
	printf("%f\n", ans);
    return 0;
}


Measured memory_bytes: 128
# AOJ 1600 Entrance Examination
# Python3 2018.7.13 bal4u

while True:
	m, nmin, nmax = map(int, input().split())
	if m == 0: break
	p = [int(input()) for i in range(m)]
	gap = 0
	for i in range(nmax-1, nmin-2, -1):
		d = p[i]-p[i+1]
		if d > gap: gap, ans = d, i
	print(ans+1)


Measured memory_bytes: 5620
import java.util.Scanner;

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

        int r = scanner.nextInt();
        int g = scanner.nextInt();

        // レーティングの計算式に引数を当てはめる
        System.out.println(2 * g - r);
    }
}


Measured memory_bytes: 21844
N,K = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))
seen = set()
circuits = []

for x in range(N):
    cir = []
    point = 0
    while True:
        if x in seen: 
            if cir != []: circuits.append((cir,point))
            break
        seen.add(x)
        point += C[x]
        cir.append(x)
        x = P[x] - 1
ans = -1000000000000
for x in circuits:
    tmp = 0
    if  K >= len(x[0]) * 2: 
        if x[1] > 0: tmp = (K // len(x[0]) - 1) * x[1]
        r = K % len(x[0]) + len(x[0])
    else:
        r = K
    for y in x[0]:
        tmp2 = 0
        for _ in range(r):
            y = P[y] - 1
            tmp2 += C[y]
            ans = max(ans, tmp + tmp2)
print(ans)




Measured memory_bytes: 68640
N = int(input())
a = [int(input()) for i in range(N)]
num = a[0]
ans = 0
check = -1
for n in range(0, N+2):
    if num == 2:
        ans = n + 1
        check = 1
        break
    num = a[num - 1]
if check != 1:
    print(check)
else:
    print(ans)


Measured memory_bytes: 7084
/////////////////////////////////////////////template 1
#include <bits/stdc++.h>
#define MOD 1000000007
//for(int i=0; i<n; ++i)
using namespace std;
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " is " << (x) << endl
#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> h(n), dp(n);
    for (int i = 0; i < n; ++i)
        cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[0] - h[1]);
    for (int i = 2; i < n; ++i)
        dp[i] = min(
            dp[i - 2] + abs(h[i] - h[i - 2]),
            dp[i - 1] + abs(h[i] - h[i - 1]));
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
typedef pair<int,LL>P;
vector<P>G[100001];
bool used[100001];
LL dp[100001];
void dfs(int x){
	used[x]=true;
	REP(i,G[x].size()){
		if(used[G[x][i].first]==false){
			dp[G[x][i].first]=dp[x]+G[x][i].second;
			dfs(G[x][i].first);
		}
	}
}

int main(){
	cin>>N;
	REP(i,N-1){
		LL u,v,w;
		cin>>u>>v>>w;
		u--;
		v--;
		G[u].push_back(P(v,w));
		G[v].push_back(P(u,w));
	}
	REP(i,N){
		used[i]=false;
		dp[i]=0;
	}
	dfs(0);
	REP(i,N){
		if(dp[i]%2==0){
			cout<<0<<endl;
		}else{
			cout<<1<<endl;
		}
	}
}

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

typedef long long LL;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;

const int INF = 1000000007;
const LL INFLL = 1000000000000000007;

#define st first
#define nd second
#define pb push_back
#define _boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// ***************************** CODE ***************************** //

const int MAX = 1e5 + 7;
int dp[MAX][3];

int main() {
    _boost;

    int n;  cin >> n;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < 3; j++)
            cin >> dp[i][j];

    for(int i = 1; i < n; i++)
    {
        dp[i][0] += max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] += max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] += max(dp[i-1][0], dp[i-1][1]);
    }

    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]});

    return 0;
}


Measured memory_bytes: 1408
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    long long N;
    cin >> N;

    int n = 5;
    vector<long long> A(n);
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }

    long long res = 0;

    long long mn = 1LL << 60;
    int x = -1;
    for (int i = 0; i < n; ++i) {
        if (A[i] <= mn) {
            mn = A[i];
            x = i;
        }
    }

    res = (N + mn - 1) / mn + 5 - 1;

    cout << res << "\n";


    return 0;
}

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

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

	int R;
	cin>>R;

	double cir = 2 * 3.14159265 * R;

	cout<<cir<<endl;

	return 0;
}

Measured memory_bytes: 3800
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int ma = 1e9;

int main() {
    int n, k, s;
    cin >> n >> k >> s;
    VI a(n, s);
    FOR(i,k,n-1){
        if (s < ma) a[i] = s + 1;
        else a[i] = 1;
    }
    REP(i,n) cout << a[i] << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string t;
    cin>>t;
    string s[10];
    s[1]="SAT";
    s[2]="FRI";
    s[3]="THU";
    s[4]="WED";
    s[5]="TUE";
    s[6]="MON";
    s[7]="SUN";
    for(int i=1;i<=7;i++)
        if(t==s[i])
            cout<<i<<endl;
    return 0;
}


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

#define fastio  ios::sync_with_stdio(false); cin.tie(0);

// minCost(i) = min( abs(a[i]-a[i-1]) + minCost(i-1), abs(a[i]-a[i-2]) + minCost(i-2))
// minCost(2) = abs(a[1]-a[0])
// minCost(3) = min(abs(a[2]-a[0]), abs(a[1]-a[2]) + abs(a[0]-a[1])

class BeingZero{
    public:
        ll minCost(vector<int> a){
            ll n = a.size();
            int dp[n];
            dp[0] = 0;
            dp[1] = abs(a[1]-a[0]);
            //dp[2] = min(abs(a[2]-a[0]), dp[1]+abs(a[2]-a[1]));
            //dp[3] = min(abs(a[2]-a[0]), abs(a[1]-a[0]) + abs(a[2]-a[1]));
            for(int i=2;i<n;i++)
                dp[i] = min( abs(a[i]-a[i-1]) + dp[i-1], abs(a[i]-a[i-2]) + dp[i-2]);
            // for(int i=0;i<n;i++)
            //     cout<<i<<" : "<<dp[i]<<"\n";
            return dp[n-1];
        }
};


int main() {
    fastio;
    BeingZero bz;
    int n;
    while(cin>>n){
        if(n==-1) break;
        vector<int> v(n);
        for(int i=0;i<n;i++)
            cin>>v[i];
        cout<<bz.minCost(v)<<"\n";
    }
    return 0;
}



Measured memory_bytes: 4500
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
using namespace std;
using ll = long long;

int main() {
    ll H, W; cin >> H >> W;
    vector<string> S(H);
    for (auto & s : S) cin >> s;
    vector<vector<ll>> C(H, vector<ll>(W, 0));
    ll left, right, counter;
    for (int h = 0; h < H; h++) {
        left = right = counter = 0;
        while (left < W) {
            if (S[h][right] == '#') {
                for (int i = left; i < right; i++) {
                    C[h][i] += counter;
                }
                counter = 0;
                right++;
                left = right;
            }
            else {
                counter++;
                right++;
                if (right >= W) {
                    for (int i = left; i < right; i++) {
                        C[h][i] += counter;
                    }
                    break;
                }
            }
        }
    }
    ll up, down;
    for (int w = 0; w < W; w++) {
        up = down = counter = 0;
        while (up < H) {
            if (S[down][w] == '#') {
                for (int i = up; i < down; i++) {
                    C[i][w] += counter;
                }
                counter = 0;
                down++;
                up = down;
            }
            else {
                counter++;
                down++;
                if (down >= H) {
                    for (int i = up; i < down; i++) {
                        C[i][w] += counter;
                    }
                    break;
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            ans = max(ans, C[i][j]);
        }
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 35712
#include <stdio.h>
#include <string.h>

int main(void)
{
  int n, i, j, c = 0;
  char w[100][11];

  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%s", w[i]);
  for (i = 1; i < n; i++) {
    if (w[i-1][strlen(w[i-1])-1] != w[i][0]) {
      puts("No");
      c++;
      break;
    }
    for (j = 0; j < i; j++) {
      if (strcmp(w[i], w[j]) == 0) {
        puts("No");
        c++;
        break;
      }
    }
  }
  if (c == 0)
    puts("Yes");
}


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

using namespace std;

int main(int argc, char* argv[]) {
  int N, x;
  cin >> N >> x;

  vector<int> a(N);
  for (int i = 0; i < N; ++i)
    cin >> a.at(i);

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

  int i;
  for (i = 0; i < N; ++i) {
    if (i == N - 1 && x > a[i]) {
      break;
    }
    if (a[i] > x)
      break;
    x -= a[i];
  }

  cout << i << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  if ((a - b) % 2 == 0) {
    cout << "Alice\n";
  } else {
    cout << "Borys\n";
  }

  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

int main() {
    lint x, y;
    cin >> x >> y;

    lint ans = 0;
    if(x == 1)  ans += 3e5;
    if(x == 2)  ans += 2e5;
    if(x == 3)  ans += 1e5;

    if(y == 1)  ans += 3e5;
    if(y == 2)  ans += 2e5;
    if(y == 3)  ans += 1e5;

    if(x == 1 && y == 1)  ans += 4e5;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  string s, t; cin >> s >> t;
  if(s == t.substr(0, t.length() - 1)) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3624
import math
a,b,h,m=map(float,input().split())
angle=0
if(h*5<m):
    angle=(m/60*2*math.pi)-(h/12*2*math.pi+m/60*2*math.pi/12)
else:
    angle=(h/12*2*math.pi+m/60*2*math.pi/12)-(m/60*2*math.pi)
ans=math.sqrt(a**2+b**2-2*a*b*math.cos(angle))
print(ans)

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

int main(){
	int n;
	cin >>n;
	
	long long a,min=0,max=0,sum=0;
	
	for (int i=1; i<=n; i++){
		cin>> a;
		if (i==1)min=a, max=a;
		if (a<min)min=a;
		if (a>max)max=a;
		sum +=a;
	}
	
	cout<< min <<" "<< max <<" "<< sum <<"\n";
	
	return 0;
}

Measured memory_bytes: 1172
N = int(input())
A = list(map(int, input().split()))
A_2 = [a%2 for a in A]
A_4 = [a%4 for a in A]
x4 = A_4.count(0)
odd = A_2.count(1)
x2 = A_2.count(0)-x4
if x4-odd>=0:
    print('Yes')
elif x2==0 and x4-odd>=-1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 15020
j = input().split()
a = int(j[2])
b = int(j[1])
c = int(j[0])
if a == b and b== c:
 print("1")
elif a == b:
 print("2")
elif b == c:
 print("2")
elif a==c:
 print("2")
else:
 print("3")

Measured memory_bytes: 3060
/**
 * Created by hiramekun at 20:55 on 2019-09-07.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    ll ans = 0;
    rep(i, n - 1) {
        if (s[i] == s[i + 1]) ans++;
    }
    ans += 2 * k;
    cout << min(n - 1, ans) << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N,C,K;
const int MN=100000;
int t[MN];
int main(){
	cin>>N>>C>>K;
	rep(i,N) cin>>t[i];
	sort(t,t+N);
	int now=0;
	int ans=0;
	while(now!=N){
		int nxttime = t[now]+K;
		int nxtid = now+C;
		int id = upper_bound(t,t+N,nxttime) - t;
		int nxt = min(nxtid,id);
		now=nxt;
		ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<stdio.h>
#define INF 100000
#define N 101
int min(int,int);
int main(){
  int n,l,i,j,k,x[N],m[N][N];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&x[i-1],&x[i]);
}
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
    m[i][j]=0;
    }
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=INF;
      for(k=i;k<=j-1;k++){
	m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+x[i-1]*x[k]*x[j]);
      }
    }
  }
  printf("%d\n",m[1][n]);
}
int min(int x,int y){
  int z;
  z=(x>y) ? y : x;
  return z;
}

  



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

using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define REP(i, n) for(int i=1;i<=n;i++)
typedef long long ll;

vector<int> seen;
vector<int> a;
ll r, l;

void dfs(int i, int count) {
	if (seen[i] != -1) {
		r = count;
		l = seen[i];
		return;
	}
	seen[i] = count;
	dfs(a[i], count + 1);
}

int main() {
	ll n, k;
	cin >> n >> k;
	seen.resize(n + 1, -1);
	a.resize(n + 1);
	REP(i, n) cin >> a[i];
	dfs(1, 0);
	if (k > l) {
		k -= l;
		k %= r - l;
		k += l;
	}
	REP(i, n) {
		if (seen[i] == k) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 4828
import java.util.Scanner;

public class Main {

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

		StringBuilder newS = new StringBuilder("");
		for (char x : s.toCharArray()) {
			if (x == 'A' || x == 'C' || x == 'G' || x == 'T') {
				newS.append(1);
			} else {
				newS.append(0);
			}
		}

		int max = 0;

		for (String x : newS.toString().split("0")) {
			if (max < x.length()) max = x.length();
		}

		System.out.println(max);
		sc.close();
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, C, K; cin >> N >> C >> K;
    vector<int> T(N);
    for (int i = 0; i < N; i++) cin >> T[i];
    sort(begin(T), end(T));
    int ans = 0;
    for (int i = 0; i < N;) {
        int deadline = T[i] + K;
        int passanger = 0;
        while (i < N && T[i] <= deadline && passanger < C) {
            passanger++, i++;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
/*
ID: Aman Raj
LANG: C++
TASK: milk3
*/
#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef long long ll;
 #include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

vector<vector<pair<ll,ll > > > v;
vector<ll > vans;
vector<ll > vis;
ll n;
  void aman(ll i)
  { if(i==1)vans[i]=1;vis[i]=1;
    for(ll j=0;j<v[i].size();j++)
     { if(!vis[v[i][j].first])
       { if(v[i][j].second%2==0)vans[v[i][j].first]=vans[i];
          else
          {
              if(vans[i]==1)vans[v[i][j].first]=0;
              else vans[v[i][j].first]=1;
          }

        aman(v[i][j].first);
       }
     }

  }
int main()
{    ifstream fin ("milk3.in");
     ofstream fout ("milk3.out");
     cin>>n;
       v.resize(n+1);
         for(ll i=0;i<n-1;i++)
         {
             ll a,b,w;cin>>a>>b>>w;v[a].push_back(make_pair(b,w));
                       v[b].push_back(make_pair(a,w));

         }

         vans.resize(n+1);

          vis.resize(n+1);
          aman(1);
          for(ll i=1;i<=n;i++)cout<<vans[i]<<endl;
    return 0;

}


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

int main(){
	int a, b;
	cin >> a >> b;
	cout << a + b/2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
using namespace std;

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll turn = 0;
    while (a > 0 and c > 0)
    {
        if (turn == 0)
            c -= b;
        else
            a -= d;
        turn = (turn + 1) % 2;
    }
    if (a <= 0)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

Measured memory_bytes: 3636
# 解説AC
N,M = map(int, input().split())
S = [int(i) for i in input().split()]
T = [int(i) for i in input().split()]

MOD = 10 ** 9 + 7

# dp[i][j]: S[:i]とT[:j]での共通部分列の個数
dp = [[0] * (M + 1) for _ in range(N + 1)]

def main():
    # 初期条件
    for i in range(N + 1):
        dp[i][0] = 1
    for j in range(M + 1):
        dp[0][j] = 1

    # 貰うDP
    for i, s in enumerate(S):
        for j, t in enumerate(T):
            dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j]

            if s == t:
                dp[i + 1][j + 1] += dp[i][j]
            
            # ダブルカウントを除く
            dp[i + 1][j + 1] -= dp[i][j]

            dp[i + 1][j + 1] %= MOD

    print(dp[N][M])

if __name__ == "__main__":
    main()

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

mt19937_64 llrand((int) chrono::steady_clock::now().time_since_epoch().count());

#define st first
#define nd second
#define pb push_back

#ifndef ONLINE_JUDGE
  #define db(x) cerr << #x << " == " << x << endl
  #define dbs(x) cerr << x << endl
  #define _ << ", " <<
#else
  #define db(x) ((void)0)
  #define dbs(x) ((void)0)
#endif

typedef long long ll;
typedef long double ld;

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

const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 1e5+5;

int k, a, b;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> k >> a >> b;
  int want = a/k * k;
  if(want < a) want += k;
  if(want <= b) cout << "OK\n";
  else cout << "NG\n";
}


Measured memory_bytes: 3640
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>

using namespace std;

char s[3001];
char t[3001];
int dp[3001][3001];

int main() {
    int n, m, x, y, i, j;
    string ans = "";
    
    scanf("%s", s);
    scanf("%s", t);
    
    n = strlen(s);
    m = strlen(t);
    
    for (i = 0; i <= n; i++) {
        for (j = 0; j <= m; j++) {
            if (i < n) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j < m) dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);
            if (i < n && j < m) {
                if (s[i] == t[j]) {
                    dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
                } else {
                    dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j]);
                }
            }
        }
    }
    
    x = n;
    y = m;
    
    while (x > 0 && y > 0) {
        if (s[x - 1] == t[y - 1] && dp[x - 1][y - 1] + 1 == dp[x][y]) {
            ans += s[x - 1];
            x--;
            y--;
        } else if (dp[x - 1][y - 1] == dp[x][y]) {
            x--;
            y--;
        } else if (dp[x - 1][y] == dp[x][y]) {
            x--;
        } else {
            y--;
        }
    }
    
    reverse(ans.begin(), ans.end());
    printf("%s\n", ans.c_str());
    
    return 0;
}


Measured memory_bytes: 35456