akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
  int n;
  cin >> n;
  vector<int> v(100005, 0);
  for (int i = 0; i < n; i++)
  {
    int l, r;
    cin >> l >> r;
    for (int j = l; j <= r; j++)
    {
      v.at(j)++;
    }
  }
  int cnt = 0;
  for (int i = 0; i < 100005; i++)
  {
    if (v.at(i) != 0)
    {
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

using namespace std;

int main(){
        string s;
        cin>>s;
        int L=0,R=s.length()-1;
        int ans=0;
        while (L<R){
                if (s[L]==s[R]){
                        L++,R--;
                        continue;
                }
                if (s[L]=='x') L++,ans++;
                else if (s[R]=='x') R--,ans++;
                else {
                        cout<<"-1";
                        return 0;
                }
        }
        cout<<ans;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define FOR(i,n) for(lli i=0;i<n;i++)
using namespace std;
typedef long long int lli;
typedef vector<lli> vli;
int main()
{
	ios::sync_with_stdio(false);
	int a,b,k;
	bool flag=false;
	cin>>k;
	cin>>a>>b;
	for(int i=a;i<=b;i++)
	  {
	    if((i%k)==0) 
	   	{ cout<<"OK";
	   	  flag=true;
	   	  break;
	   }
}
	if(!flag) cout<<"NG";
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;

int main() {
	int n, data[6];
	int max_mini = 0;
	
	while (cin >> n) {
		if (n == 0)break;
		int x[86401] = { 0 };
		for (int i = 0; i < n; i++) {
			scanf("%d:%d:%d %d:%d:%d",&data[0],&data[1],&data[2],&data[3],&data[4],&data[5]);
			x[data[0] * 3600 + data[1] * 60 + data[2]]++;
			x[data[3] * 3600 + data[4] * 60 + data[5]]--;
			if (max_mini < data[3] * 3600 + data[4] * 60 + data[5])
				max_mini = data[3] * 3600 + data[4] * 60 + data[5];
		}
		int ans = 0, cnt = 0;
		for (int i = 0; i <= max_mini; i++) {
			cnt += x[i];
			ans = max(ans, cnt);
		}
		cout << ans << endl;
	}
	return 0;
	
}

Measured memory_bytes: 3472
#include<stdio.h>
#define MAX 20

int main(void){
    int p[MAX];
    int i,n,count=0;

    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%d",&p[i]);
    }

    for(i=1;i<n-1;i++){
        if( (p[i-1]<p[i] && p[i]<p[i+1]) || (p[i-1]>p[i] && p[i]>p[i+1]) )
            count++;
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
#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++)
using namespace std;
using P = pair<int, int>;
typedef long long ll;

int  main()
{
	int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
	int k; cin >> k;
	abs(a-e) <= k ? cout << "Yay!"<< endl : cout << ":(" << endl;
	return (0);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

ll gcd(ll a, ll b) {
	if (b == 0)return a;

	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

int main() {
	ll n, k;
	cin >> n >> k;

	ll ans = min(n%k, k - n % k);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"	
	typedef long long LL;
	#define ld long double
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define INFINITE 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)	
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define read(a) ll a; cin >> a;
	#define reads(s) string s; cin >> s;
	#define readb(a, b) ll a, b; cin >> a >> b;
	#define readc(a, b, c) ll a, b, c; cin >> a >> b >> c;
	#define readarr(a, n) int a[(n) + 1] = {}; forab(i, 0, (n-1)) {cin >> a[i];}
	#define readmat(a, n, m) int a[n + 1][m + 1] = {}; forab(i, 1, n) {forab(j, 1, m) cin >> a[i][j];}
	#define readv(A,n) vll A(n,0); forn(i,n) cin>>A[i]; 
	#define print(a) cout << a << endl;
	#define printarr(a, n) forab (i, 1, n) cout << a[i] << " "; cout << endl;
	#define printv(v) for (int i: v) cout << i << " "; cout << endl;
	#define printmat(a, n, m) forab(i, 1, n) {forab (j, 1, m) cout << a[i][j] << " "; cout << endl;}
	#define precision(a) cout<<fixed<<setprecision(a);
	#define INF (1e18+5)
	#define inf (1e9+5)
	int dx[4] = { 0, 0, 1, -1 };
	int dy[4] = { 1, -1, 0, 0 };
	// 8-directions
	//int dx[]={1,1,1,0,0,-1,-1,-1};
	//int dy[]={-1,0,1,-1,1,-1,0,1};
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	int begtime = clock();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	mt19937_64 rngb(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	ll fpow(ll base, ll power, ll MOD) {
    ll result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	ll modinv(ll x,ll MOD) {return fpow(x, MOD - 2, MOD);}
	void solve()
	{
		ll n,k,x,y;
		cin>>n>>k;
		map<ll,ll> pq;
		forn(i,k)
		{
			cin>>x;
			forn(j,x)
			{

				cin>>y;
				pq[y]++;
			}
		}
		ll ans=0;
		forab(i,1,n)
		{
			if(pq[i]==0)ans++;
		}
		cout<<ans<<endl;
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
	//	cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		#ifndef ONLINE_JUDGE
    		cerr << "Time elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
    		#endif
		return 0;
	}

	
	
	
	

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

typedef long long ll;
ll mod = 998244353;

ll n;
ll d[100010];
ll cnt[100010];

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

ll mypow(ll a, ll b) {
    if (b == 0) return 1LL;
    if (b == 1) return a;
    ll ret = mypow(a,b/2);
    ret *= ret;
    ret %= mod;
    if (b&1) {
        ret *= a;
        ret %= mod;
    }
    return ret;
}

void solve() {
    if (d[0] != 0) {
        cout << 0 << endl;
        return;
    }
    sort(d,d+n);
    ll ans = 1;
    ll pre;
    ll cnt = 0;
    ll num = 1;
    for (int i = 0; i < n; i++) {
        if (d[i] == 0) {
            cnt++;
        } else {
            break;
        }
    }
    if (cnt != 1) {
        cout << 0 << endl;
        return;
    }
    pre = cnt;
    cnt = 0;
    for (int i = 0; i < n; i++) {
        if (d[i] == 0) continue;
        if (d[i] == num) {
            cnt++;
            continue;
        }
        if (d[i] != num + 1) {
            cout << 0 << endl;
            return;
        }
        num++;
        ans *= mypow(pre, cnt);
        ans %= mod;
        pre = cnt;
        cnt = 1;
    }
    ans *= mypow(pre,cnt);
    ans %= mod;
    cout << ans << endl;
}

int main(int argc, char *argv[]) {
    input();
    solve();
    return 0;
}


Measured memory_bytes: 1024
//AtCoder ABC073 B - Theater
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll N;
    cin>>N;
    ll ans=0;
    for(ll i=0;i<N;++i){
        ll l,r;
        cin>>l>>r;
        ans+=(r-l+1);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    string s;
    cin >> s;
    vint a(4);
    rep(i, 4) a[i] = s[i]-'0';

    rep(i, 8) {
        int sum = a[0];
        string ans = "";
        ans += (a[0]+'0');
        rep(j, 3) {
            if (i&(1<<j)) {
                sum += a[j+1];
                ans += '+';
            }
            else {
                sum -= a[j+1];
                ans += '-';
            }
            ans += (a[j+1]+'0');
        }
        ans += "=7";
        if (sum == 7) {
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
#include <numeric>
#include <utility>
#include <cfloat>

using namespace std;
 
int a[100];
int main(){
    int N;
    int x;
    cin >> N >> x;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(a, a + N);
    int remain = x;
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(remain >= a[i]){
            if(i == N - 1 && remain != a[i]){
                break;
            }
            ans ++;
            remain -= a[i];
        } else {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int a,b,c;
	int x, y,z;
	scanf("%d %d %d", &a, &b, &c);
	x=a+b;
	y=a+c;
	z=b+c;
	
	if(x<=y && x<=z ){
		printf("%d", x);
	}
	else if(y<=x && y<=z ){
		printf("%d", y);
	}
	else if(z<=y && z<=x ){
		printf("%d", z);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)
#define  ll_cout(X) printf("%lld\n",X)

typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)

#define YES_RTN s_cout("Yes");return 0
#define NO_RTN  s_cout("No");return 0


int i_cins(int n, int* A);
int l_cins2(int n, long* A,long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);


int main(void) {

	int    N,L,R,count=0;

	i_cin(N);
	rept(i, 0, N) {
		i_cin2(L, R);
		count += (R - L+1);
	}
	i_cout(count);
	return 0;

	}
	
//降順
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a -*(int*)b);
}
//
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	rept(i, 0, n) {
		i_cin(*(a + i));
	}
	return 0;
}


Measured memory_bytes: 128
N = int(input())
a = list(map(int,input().split()))

new_a = sorted(a)

A = []
B = []

while len(new_a) != 0:
    if len(new_a) != 0:
        A.append(new_a.pop())
    else:
        break

    if len(new_a) != 0:
        B.append(new_a.pop())
    else:
        break
        

print(sum(A) - sum(B))


Measured memory_bytes: 3060
program main
implicit None
	integer(8)::n,i,s
	integer(8),allocatable::a(:)
	
	read *,n
	allocate(a(2*n))
	read *,a
	
	call h2(a,2*n)
	
	s = 0
	do i = 1,2*n
		if(mod(i,2) == 1)then
			s = s + a(i)
		endif
	enddo
	
	print 101,s
101 format(i0)
end program main

subroutine h2(a,n)
implicit None
	integer(8)::a(n),x
	integer(8)::n,i,ie,i0,i1,i2
	
	do i = n/2,1,-1
		x = a(i);ie = n + 1; i0 = i; i1 = i0 * 2
		do while(i1 < ie)
			i2 = i1 + 1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
	do ie = n,2,-1
		x = a(ie)
		a(ie) = a(1)
		a(1) = x
		i0 =1;i1 =2
		do while(i1 <ie)
			i2 = i1 +1
			if(i2 < ie .and. a(i1) < a(i2)) i1 = i2
			if(a(i1) > x)then
				a(i0) = a(i1);a(i1) = x
				else
				exit
			endif
			i0 = i1;i1 = i0 *2
		enddo
	enddo
end subroutine h2


Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int n;cin>>n;
  vector<int> A(n);
  for(int i = 0; n > i; i++){
    cin>>A[i];
  }
  int ans = 0;
  for(int i = 0; n > i; i++){
    for(int j = i+1; n > j; j++){
      ans += A[i]*A[j];
    }
  }
  cout << ans << endl;
}


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

#define INF (i64)1e18
#define MOD (i64)(1e9+7)
#define REP(i, n) for(i64 i = 0; i < n; i++)
#define RANGE(i, a, b) for(i64 i = a; i < b; i++)
#define EACH(v, e, p) for_each(v.begin(), v.end(), [](auto& e) p)

struct ModInt {
  i64 val;
  ModInt() {
    val = 0;
  }
  ModInt(i64 a) {
    val = mod(a);
  }
  inline i64 get() {
    return val;
  }
  inline operator i64(void) {
    return get();
  }
  inline i64 mod(i64 a) {
    a %= MOD;
    if (a < 0) a += MOD;
    return a;
  }
  inline ModInt &operator+=(ModInt a) {
    val = mod(val + a.val);
    return *this;
  }
  inline ModInt &operator-=(ModInt a) {
    val = mod(val - a.val);
    return *this;
  }
  inline ModInt &operator*=(ModInt a) {
    val = mod(val * a.val);
    return *this;
  }
  inline ModInt &operator/=(ModInt a) {
    return *this *= a.inv();
  }
  inline ModInt operator+(ModInt a) {
    return ModInt(*this) += a;
  }
  inline ModInt operator-(ModInt a) {
    return ModInt(*this) -= a;
  }
  inline ModInt operator*(ModInt a) {
    return ModInt(*this) *= a;
  }
  inline ModInt operator/(ModInt a) {
    return ModInt(*this) /= a;
  }
  inline ModInt operator-(void) {
    return ModInt(0 - val);
  }
  inline bool operator==(ModInt a) {
    return val == a.val;
  }
  inline bool operator!=(ModInt a) {
    return val != a.val;
  }
  inline ModInt &operator+=(i64 a) {
    return *this += ModInt(a);
  }
  inline ModInt &operator-=(i64 a) {
    return *this -= ModInt(a);
  }
  inline ModInt &operator*=(i64 a) {
    return *this *= ModInt(a);
  }
  inline ModInt &operator/=(i64 a) {
    return *this /= ModInt(a);
  }
  inline ModInt operator+(i64 a) {
    return ModInt(*this) += a;
  }
  inline ModInt operator-(i64 a) {
    return ModInt(*this) -= a;
  }
  inline ModInt operator*(i64 a) {
    return ModInt(*this) *= a;
  }
  inline ModInt operator/(i64 a) {
    return ModInt(*this) /= a;
  }
  inline bool operator==(i64 a) {
    return val == mod(a);
  }
  inline bool operator!=(i64 a) {
    return val != mod(a);
  }
  inline ModInt pow(i64 n) {
    ModInt a(*this);
    ModInt res = 1;
    while (n) {
      if (n & 1) {
        res *= a;
      }
      n >>= 1;
      a *= a;
    }
    return res;
  }
  inline ModInt inv() {
    return pow(MOD - 2);
  }
};

struct ModComb {
 vector<ModInt> fact = {1};
 vector<ModInt> fact_inv = {1};
 ModComb(i64 n) {
   RANGE(i, 1, n) {
     fact.push_back(fact[i-1] * i);
     fact_inv.push_back(fact[i].inv());
   }
 }
 inline ModInt C(i64 n, i64 k) {
   if (k < 0 || k > n) return 0;
   return fact[n] * fact_inv[k] * fact_inv[n-k];
 }
 inline ModInt P(i64 n, i64 k) {
   if (k < 0 || k > n) return 0;
   return fact[n] * fact_inv[n-k];
 }
 inline ModInt H(i64 a, i64 b) {
   if (a == 0 && b == 0) return 1;
   if (a <= 0 || b < 0) return 0;
   return C(a+b-1, b);
 }
};

int main() {
  i64 n, m;
  cin >> n >> m;

  ModComb c(m+1);
  ModInt ans = 0;
  REP(k, n+1) {
    ModInt val = c.C(n, k) * c.P(m, k) * c.P(m-k, n-k) * c.P(m-k, n-k);
    if (k % 2 == 0) ans += val;
    else ans -= val;
  }

  cout << ans.val << endl;

  return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 998244353;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

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

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  string s; cin >> s;
  int n = SZ(s);
  vector<int> r(n);
  REP(i, n) {
    if(s[i] == '0') r[i] = 2;
    else if(s[i] == '1') r[i] = 1;
  }

  vector<int> su(2*n+1);
  REP(i, n) {
    su[i+1] = su[i] + r[i];
  }
  FOR(i, n, 2*n + 1) {
    su[i+1] = su[i];
  }

  vvll dp(2*n+1, vll(2*n+1, 0));
  dp[0][0] = 1;
  REP(i, 2*n) {
    REP(j, 2*n+1) {
      if(dp[i][j] == 0) continue;
      int nowr = su[i+1] - j;
      int nowb = 2 * min(i+1, n) - su[i+1] - (i - j);
      //cout << i << ":" << j << " " << nowr << ":" << nowb << endl;
      if(nowr > 0) {
        (dp[i+1][j+1] += dp[i][j]) %= MOD;
      }
      if(nowb > 0) {
        (dp[i+1][j] += dp[i][j]) %= MOD;
      }
    }
  }


  ll ans = 0;
  REP(j, 2*n+1) {
    (ans += dp[2*n][j]) %= MOD;
  }
  cout << ans << endl;

  return 0;
}








Measured memory_bytes: 128604
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;

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

bool valid(int H, int W, int x, int y) {
    return x >= 0 && x < W && y >= 0 && y < H;
}

int main() {
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> A;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A.push_back(a);
    }

    vector<vector<int> > m(H, vector<int>(W, 0));

    int x = 0;
    int y = 0;
    int d = 0;
    int color = 1;
    for (int cnt = 0; cnt < H * W; cnt++) {
        m[y][x] = color;
        if (cnt == H * W - 1) break;
        if (!valid(H, W, x + dx[d], y + dy[d]) || m[y + dy[d]][x + dx[d]] != 0) d = (d + 1) % 4;
        y += dy[d];
        x += dx[d];
        if (--A[color - 1] == 0) {
            color++;
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << m[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

const MOD: usize = 1_000_000_007;

fn check(v: [char; 4]) -> bool {
    if func(v) {
        return true;
    }
    for i in 0..3 {
        let mut v = v.clone();
        let mut a1 = v[i];
        let mut a2 = v[i+1];
        std::mem::swap(&mut a1, &mut a2);
        v[i] = a1;
        v[i+1] = a2;
        if func(v) {
            return true;
        }
    }
    return false;
}

fn func(v: [char; 4]) -> bool {
    let po = ['A', 'G', 'C'];
    let mut ok = true;
    for k in 0..3 {
        if v[k] != po[k] {
            ok = false;
        }
    }
    if ok {
        return true;
    }
    ok = true;
    for k in 1..4 {
        if v[k] != po[k-1] {
            ok = false;
        }
    }
    if ok {
        return true;
    }
    return false;
}

fn main() {
    let n: usize = read();
    
    let po = ['A', 'C', 'G', 'T'];
    let mut dp = vec![[[[0; 4]; 4]; 4]; n];
    for i in 0..4 {
        for j in 0..4 {
            for k in 0..4 {
                let nya = [['A','G','C'], ['A','C','G'], ['G','A','C']];
                let mut ok = true;
                for l in 0..3 {
                    if po[i] == nya[l][0] && po[j] == nya[l][1] && po[k] == nya[l][2] {
                        ok = false;
                    }
                }
                dp[0][i][j][k] = if ok {1} else {0};
            }
        }
    }
    for i in 0..n-3 {
        for j in 0..4 {
            for k in 0..4 {
                for l in 0..4 {
                    for m in 0..4 {
                        if !check([po[j], po[k], po[l], po[m]]) {
                            dp[i+1][k][l][m] += dp[i][j][k][l];
                            dp[i+1][k][l][m] %= MOD;
                        }
                    }
                }
            }
        }
    }
    let mut ans = 0;
    for j in 0..4 {
        for k in 0..4 {
            for l in 0..4 {
                ans += dp[n-3][j][k][l];
                ans %= MOD;
            }
        }
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

ll dp[3030][3030][4];
ll R, C, K;
ll item[3030][3030];

int main() {
  //
  cin >> R >> C >> K;
  rep(i, 0, K) {
    ll r, c, v;
    cin >> r >> c >> v;
    item[r][c] = v;
  }

  repe(i, 1, R) {
    repe(j, 1, C) {
      repe(k, 0, 3) { chmax(dp[i][j][0], dp[i - 1][j][k]); }
      repe(k, 0, 3) { chmax(dp[i][j][k], dp[i][j - 1][k]); }
      if (item[i][j] != 0) {
        //
        repe(k, 0, 3) { chmax(dp[i][j][1], dp[i - 1][j][k] + item[i][j]); }
        repe(k, 1, 3) { chmax(dp[i][j][k], dp[i][j - 1][k - 1] + item[i][j]); }
      }
    }
  }

  ll ans = 0;
  repe(k, 0, 3) { chmax(ans, dp[R][C][k]); }
  cout << ans;
}


Measured memory_bytes: 358444
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<int> as(n-1);
  for(int i=0;i<n-1;i++) cin>>as[i];
  int sum=0;
  for(int i=2;i<n-1;i++) sum+=as[i];

  deque<int> dp(sum+1);
  iota(dp.begin(),dp.end(),0);
  for(int i=2;i<=n-2;i++){
    vector<int> vs;
    for(int j=1;j<=as[i];j++)
      vs.emplace_back(dp[j]);
    for(int v:vs) dp.emplace_front(v);
  }

  int m;
  cin>>m;
  for(int i=0;i<m;i++){
    int x;
    cin>>x;
    cout<<(x>sum?x-sum:dp[x])+as[0]-as[1]<<endl;
  }
  return 0;
}


Measured memory_bytes: 13164
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define f first 
#define s second
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MAX 1000005
#define pb push_back
int flag[1000006];
ll gcd(ll a, ll b)
{
  if(a == 0)
    return b;
  return gcd(b%a,a);
}
ll power(ll a,ll b)
{
  ll res = 1;
  while(b > 0)
  {
    if(b%2 == 1)
      res = res*a;
    a = a*a;
    b/=2;
  }
  return res;
}
bool cmp(pair<pair<string,int>,int>&a, pair<pair<string,int>,int>&b)
{
  if(a.f.f!=b.f.f)
    return a.f.f < b.f.f;
  return a.f.s > b.f.s;
}
int main(){
  FIO;
  int n,p;
  cin >> n >> p;
  cout << (n*3+p)/2 << " ";
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
  int N,*V,*C;
  int cost;
  scanf("%d",&N);
  V = malloc(N * sizeof(int));
  C = malloc(N * sizeof(int));
  for(int i=0;i<N;i++) scanf("%d",&V[i]);
  for(int i=0;i<N;i++) scanf("%d",&C[i]);

  for(int i=0;i<N;i++)
  {
    if(V[i] - C[i] > 0) cost+= V[i] - C[i];
  }

  printf("%d\n",cost);

  // for(int i=0;i<N;i++) printf("%d ",V[i]);
  // printf("\n");
  // for(int i=0;i<N;i++) printf("%d ",C[i]);

  free(C);
  free(V);

}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main
{

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

		String s = sc.next();
		int min = 1000;

		for (int i = 0; i < s.length() - 2; i++) {
			int num = Math.abs(Integer.parseInt(s.substring(i, i + 3)) - 753);
			if (num < min) min = num;
		}

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

Measured memory_bytes: 21716
#include <iostream>
#include <string>

using namespace std;

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

    int n; cin >> n;
    int arr[50][50]{};
    for(int k = 0; k < n; ++k)
    {
        string s; cin >> s;
        long long y = 0;
        bool pt = false; int cnt = 9;
        for(auto c : s)
        {
            if(c == '.')
            {
                pt = true;
            }
            else
            {
                y *= 10;
                y += c - '0';
                if(pt) --cnt;
            }
        }
        while(cnt--) y *= 10;
        int i = 0; while(y % 2 == 0) y /= 2, ++i;
        int j = 0; while(y % 5 == 0) y /= 5, ++j;
        ++arr[i][j];
    }

//    for(int i = 0; i < 50; ++i)
//    {
//        for(int j = 0; j < 50; ++j)
//        {
//            for(int k = 0; k < arr[i][j]; ++k)
//                cout << i << ' ' << j << endl;
//        }
//    }

    long long ans = 0;
    for(int i = 0; i < 50; ++i)
    {
        for(int j = 0; j < 50; ++j)
        {
            int tmp = 0;
            for(int _i = max(0, 18 - i); _i < 50; ++_i)
            {
                for(int _j = max(0, 18 - j); _j < 50; ++_j)
                {
                    tmp += arr[_i][_j];
                    if(_i == i && _j == j) --tmp;
                }
            }
            ans += 1ll * tmp * arr[i][j];
        }
    }

    cout << ans / 2;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <string.h>
using namespace std;
bool IsYYMM(string &S)
{
	char *p=(char*)S.c_str()+2;
	int m=atoi(p);
	if (m>=1 && m<=12){
		return true;
	}
	return false;
}
bool IsMMYY(string &S){
	char p[10];
	strncpy(p,(char*)S.c_str(),2);
	int m=atoi(p);
	if (m>=1 && m<=12){
		return true;
	}
	return false;
}
	
int main(int argc, char* argv[])
{
	string S;
	cin>>S;
	bool isYYMM=IsYYMM(S);
	bool isMMYY=IsMMYY(S);
	if (isYYMM && isMMYY){
		cout<<"AMBIGUOUS"<<endl;
	}else if (isYYMM){
		cout<<"YYMM"<<endl;
	}else if (isMMYY){
		cout<<"MMYY"<<endl;
	}else{
		cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>

using namespace std ;

const int MAXN=1e5+100;

int h[MAXN];
int n , k ;

int main ()
{
	int i ;
	scanf("%d%d",&n,&k);
	for ( i=1 ; i<=n ; i++ ) scanf("%d",h+i);
	sort(h+1,h+n+1);
	int res=1000000007;
	for ( i=1 ; i+k-1<=n ; i++ ) res=min(res,h[i+k-1]-h[i]);
	printf("%d\n",res);
	return 0 ;
}

Measured memory_bytes: 640
// AGC030D
#include <bits/stdc++.h>
using namespace std;
typedef pair < int , int > pii;
typedef long long LL;
#define mpr make_pair
#define FS first
#define SC second
#define PB push_back
template < typename T > T MAX(T a,T b){return (a>b)?a:b;}
template < typename T > T MIN(T a,T b){return (a<b)?a:b;}
template < typename T > void UMAX(T &a,T b){a=(a>b?a:b);}
template < typename T > void UMIN(T &a,T b){a=(a<b?a:b);}
int readint(){
	char c=getchar();
	int ret=0;
	while(!(c>='0' && c<='9')) c=getchar();
	while(c>='0' && c<='9'){
		ret=ret*10+c-'0';
		c=getchar();
	}
	return ret;
}
void putint(int v){
	if(!v){
		putchar('0');
		return;
	}
	if(v>=10) putint(v/10);
	putchar('0'+(v%10));
}
const LL MOD=1000000007ll,i2=(MOD+1ll)/2ll;
int n,q,a[3005],dp[3005][3005];
int pw[3005];
int main(){
	int i,j,k;
	scanf("%d%d",&n,&q);
	for(i=0;i<n;++i) scanf("%d",a+i);
	pw[0]=1;
	for(i=1;i<=q;++i){
		pw[i]=(LL)pw[i-1]*2ll%MOD;
	}
	for(i=0;i<n;++i){
		for(j=0;j<n;++j){
			dp[i][j]=(a[i]>a[j]);
		}
	}
	for(i=0;i<q;++i){
		int x,y;
		scanf("%d%d",&x,&y);
		--x;--y;
		for(j=0;j<n;++j){
			if(j==x || j==y) continue;
			dp[x][j]=dp[y][j]=(LL)(dp[x][j]+dp[y][j])*(LL)i2%MOD;
		}
		for(j=0;j<n;++j){
			if(j==x || j==y) continue;
			dp[j][x]=dp[j][y]=(LL)(dp[j][x]+dp[j][y])*(LL)i2%MOD;
		}
		dp[x][x]=dp[y][y]=0;
		dp[x][y]=dp[y][x]=(LL)(dp[x][y]+dp[y][x])*(LL)i2%MOD;
	}
	LL res=0ll;
	for(i=0;i<n;++i){
		for(j=i+1;j<n;++j){
			res+=(LL)dp[i][j]*(LL)pw[q]%MOD;
			res%=MOD;
		}
	}
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 35456
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
from numba import njit
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()

B = range(1,N+1)
AB = zip(A,B)
# print(*AB)
sAB = sorted(AB)
# print(*sAB)
_,ans=zip(*sAB)
print(*ans)


#AB = [LI() for _ in range(N)]
#A,B = zip(*AB)
#Ap = np.array(A)
#C = np.zeros(N + 1)
# index 順 要素のindex

# ans = []
# for i in range(N):
#     ans.append(A.index(i+1)+1)
# print(*ans)

Measured memory_bytes: 113148
N = int(input())
H = [0]+list(map(int, input().split()))
C = [10**10] + [0]*N
for i in range(2,N+1):
    C[i] = min(C[i-1]+abs(H[i-1]-H[i]), C[i-2]+abs(H[i-2]-H[i]))
print(C[-1])

Measured memory_bytes: 13924
#include<cstdio>
#define umin(m,u) u<m&&(m=u)

const int inf=1e9;
int dp[401][401];
int main()
{
  int n,ma,mb,a,b,c,i,j,sa=0,sb=0;scanf("%d%d%d",&n,&ma,&mb);
  for(i=0;i<=400;i++)
	for(j=0;j<=400;j++)
	  dp[i][j]=inf;
  dp[0][0]=0;
  while(n--){
	scanf("%d%d%d",&a,&b,&c);
	for(i=sa;i>=0;i--)
	  for(j=sb;j>=0;j--)
		umin(dp[i+a][j+b],dp[i][j]+c);
	sa+=a,sb+=b;
  }
  int ans=inf;
  for(int k=1;ma*k<=sa&&mb*k<=sb;k++)
	umin(ans,dp[ma*k][mb*k]);
  printf("%d\n",ans==inf?-1:ans);
}

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

int main()
{
  int n;
  cin >> n;
  unordered_set<string> gacha;

  for (int i = 0; i < n; i++)
  {
    string tmp;
    cin >> tmp;
    gacha.insert(tmp);
  }
  
  cout << gacha.size() << endl;
}


Measured memory_bytes: 17792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin >> s >> t;
  int ans=100000000;
  int cnt=0;
  for (unsigned int i=0;i<s.size()-t.size()+1;i++) {
    for (unsigned int j=0;j<t.size();j++) {
      if(s.at(i+j)!=t.at(j)){
        cnt++;
      } 
    }
    if(cnt<ans){
      ans=cnt;
    }
    cnt=0;
  }
  cout << ans << endl;
} 

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);++(i))
#define EACH(e,v) for(auto& e:v)
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(),(v).rend())
#define PERM(v) SORT(v);for(bool c##p=1;c##p;c##p=next_permutation(ALL(v)))
#define UNIQUE(v) SORT(v);(v).erase(unique(ALL(v)),(v).end())
template<typename A,typename B> inline bool chmax(A &a,const B &b){if(a<b){a=b;return 1;}return 0;}
template<typename A,typename B> inline bool chmin(A &a,const B &b){if(a>b){a=b;return 1;}return 0;}

const int MOD = (int)1e9 + 7;
const int INF = 1 << 30;
const ll INFF = 1LL << 62;

int N, K, Q;
vector<int> A;

signed main() {

    cin >> N >> K >> Q;

    A.resize(N);
    REP(i, N) cin >> A[i];

    int res = INT_MAX;

    // A[i]をXにする
    REP(i, N) {
        vector<int> cand, v;
        REP(j, N) {
            if (A[j] < A[i]) {
                int sz = v.size();
                if (sz != 0) {
                    SORT(v);
                    REP(k, max(0, sz - K + 1)) {
                        cand.emplace_back(v[k]);
                    }
                    vector<int>().swap(v);
                }
            } else {
                v.emplace_back(A[j]);
            }
        }
        int sz = v.size();
        if (sz != 0) {
            SORT(v);
            REP(k, max(0, sz - K + 1)) {
                cand.emplace_back(v[k]);
            }
            vector<int>().swap(v);
        }
        SORT(cand);
        if ((int)cand.size() < Q) continue;
        res = min(res, cand[Q - 1] - A[i]);
    }

    cout << res << endl;

}

Measured memory_bytes: 256
fn main() {
    let scan = std::io::stdin();
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let v: Vec<&str> = line.split_whitespace().collect();
    let n: usize = v[0].parse().unwrap();
    let m: usize = v[1].parse().unwrap();
    
    let mut A = vec![vec!['\n']; n];
    for i in 0..n {
        let mut line = String::new();
        let _ = scan.read_line(&mut line);
        A[i] = line.chars().collect();
    }
    let mut B = vec![vec!['\n']; m];
    for i in 0..m {
        let mut line = String::new();
        let _ = scan.read_line(&mut line);
        B[i] = line.chars().collect();
    }
    
    let mut ok = false;
    'outer: for i in 0..(n - m + 1) {
        for j in 0..(n - m + 1) {
            let mut same = true;
            'inner: for r in 0..m {
                for c in 0..m {
                    if A[i + r][j + c] != B[r][c] {
                        same = false;
                        break 'inner;
                    }
                }
            }
            if same {
                ok = true;
                break 'outer;
            }
        }
    }
    println!("{}", if ok {"Yes"} else {"No"});
}

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

typedef long long ll;
typedef long double ld;

using namespace std;

void INeedIt() {
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
	INeedIt();
	string s;
	cin>>s;
	if (s=="Sunny") cout<<"Cloudy";
	else if (s=="Cloudy") cout<<"Rainy";
	else  cout<<"Sunny";
	
	return 0;
}

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

# if k == 1:
#     print(0)
# else:
#     for i in range(1000000000000000000):
#         if n > abs(n-k):
#             n = abs(n-k)
#         elif n <= abs(n-k):
#             break
#     print(n)
amari = n % k
if abs(amari-k) < amari:
    print(abs(amari-k))
else:
    print(amari)

Measured memory_bytes: 3064
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, c, k = map(int, readline().split())
t = sorted([int(readline()) for i in range(n)])
cnt = 0
ans = 1
time = t[0] + k
for i in range(n):
    if cnt >= c or time < t[i]:
        ans += 1
        cnt = 0
        time = t[i] + k
    cnt += 1
print(ans)


Measured memory_bytes: 8276
c = []
for i in range(3):
    c.append(list(map(int,input().split())))

if c[0][1] - c[0][0] == c[1][1] - c[1][0] and c[1][1] - c[1][0] == c[2][1] - c[2][0]:
    if c[0][2] - c[0][1] == c[1][2] - c[1][1] and c[1][2] - c[1][1] == c[2][2] - c[2][1]:
        print("Yes")
        exit()

print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
signed main(){
	double a;
	while( scanf("%lf", &a) != EOF ){
		double y = a*a/2/9.8;
		int n = y/5 + 2;
		cout << n << endl;
	}
	return 0;
}

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

int main() {
  int n;
  int data[100] = {};

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

  int c = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = n - 1; 0 < j; --j) {
      if (data[j] < data[j-1]) {
        int tmp = data[j];
        data[j] = data[j - 1];
        data[j - 1] = tmp;
        ++c;
      }
    }
  }

  cout << data[0];
  for (int i = 1; i <  n; ++i)
    cout << " " << data[i];
  cout << endl << c << endl;

  return EXIT_SUCCESS;
}



Measured memory_bytes: 3088
#include <iostream>

using namespace std;

int f(int n) {
    int res = 0;
    while(n != 0) {
        res += n % 10;
        n /= 10;
    }
    return res;
}

int main() {
    int n;
    cin >> n;
    if (n % f(n) == 0 ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int read()
{
    char c=getchar();int f=1,sum=0;
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
    return sum*f;
}
int n,m,a[100005];
LL sum[100005],ans=12346567915644LL;
int num[100005];
void add1(int l,int r,int v){sum[l]+=v;sum[r+1]-=v;}
void add2(int l,int r,int v){num[l]+=v;num[r+1]-=v;}
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<n;i++)
	{
		int x=a[i],y=a[i+1];
		if(x<y)
		{
			add1(1,x,y-x);
			add1(y+1,m,y-x);
			add1(x+1,y,y+1);
			add2(x+1,y,-1);
		}
		else
		{
			add1(y+1,x,y+m-x);
			add1(x+1,m,y+m+1);
			add2(x+1,m,-1);
			add1(1,y,y+1);
			add2(1,y,-1);
		}
	}
	for(int i=1;i<=m;i++)
	{
		sum[i]+=sum[i-1];
		num[i]+=num[i-1];
		ans=min(ans,(LL)num[i]*i+sum[i]);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi l(87);
    l.at(0) = 2;
    l.at(1) = 1;
    for(int i=2; i<n+1; i++){
        l.at(i) = l.at(i-1) + l.at(i-2);
    }
    cout << l.at(n) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define rint register int 
#define pa pair<ll,ll>
#define mk make_pair
#define db double
using namespace std;
int N;
map<pa,int> mp;
int main(){
	cin>>N;
	for(rint i=1;i<=N;++i){
		long db x;
		cin>>x;
		ll t; 
		t=llround(x*1e9);
		int cnt1=0,cnt2=0;
		while(t%2==0) {
			cnt1++;
			t/=2;
		}
		while(t%5==0) {
			cnt2++;
			t/=5;
		}
		mp[mk(cnt1,cnt2)]++;
	}
	ll ans=0;
	for(auto i:mp){
		for(auto j:mp) {
			if(i==j) {
				if(i.first.first*2>=18&&i.first.second*2>=18)
					ans+=1ll*i.second*(i.second-1);
			}
			else {
				if(i.first.first+j.first.first>=18&&i.first.second+j.first.second>=18)
				ans+=1ll*i.second*j.second;
			}
		}
	}cout<<ans/2;
	return 0;
}

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

using namespace std;
#define sf(n) scanf("%d", &n)
#define pd(n) printf("%.12lf", n)
#define pf(n) printf("%d", n)
#define p() printf("\n")
#define ps() printf(" ")
#define ll long long
#define ull unsigned long long
#define MAX 1e9
#define mod 1000 * 1000 * 1000 + 7
#define ex 1e18
#define dbl 2e09
#define qu(q) queue<int> q
#define pqu(q) priority_queue<int> q
#define len(s) s.length()
#define sz(x) int(x.size())
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define clr(x) x.clear()
#define LOG(x) std::cout << x << std::endl;

const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265359;

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

int x[100005];

int main()
{
    string s;
    cin>>s;
    int l=-1,r=-1;
    for(int i=0;i<sz(s);++i){
        if(s[i]=='A'){
            l=i+1;
            break;}
    }
    for(int i=sz(s)-1;i>=0;--i){
        if(s[i]=='Z'){
            r=i+1;
            break;}
    }
    cout<<r-l+1<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a,b,c) for(b=(c);b<(a);b++)
#define ender {return 0;}
#define tosasuretu(a) (a*(a+1)/2)
inline ll kaizyo(ll);
ll combination(ll, ll);
int main() {
	int a, b;
	cin >> a >> b;
	if (a != 2) {
		if (b != 2) {
			cout << "Yes";
		}
		else {
			cout << "No";
		}
	}
	else {
		cout << "No";
	}
	return 0;
}


inline ll kaizyo(ll x) {
	long ans = 1;
	for (int z = 0; z < x; z++) {
		ans *= (x - z);
	}
	return ans;
}

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

int main(){
	int n;
	int ai;
	int ai2;
	int i;
	int max;
	int min;
	long sum;

	cin >> n;
	cin >> ai;
	max = ai;
	min = ai;
	sum = 0;
	ai2 = ai;

	for(i=2;i<=n;i++){
		cin >> ai;

		sum += ai;

		if(max <= ai)
			max = ai;

		if(min >= ai)
			min = ai;

	}

	sum += ai2;

	cout << min << " " << max << " " << sum << endl;

	return 0;

}

Measured memory_bytes: 3108
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define INF 1000000000000
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;

int main() {
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    // 最小値にいけない時
    if (x / k >= d) {
        cout << x - k * d << endl;
        return 0;
    }
    // 最小値にいける時
    ll mi = x % d;
    if (abs(k - int(x / d)) % 2 == 1)
        cout << abs(mi - d) << endl;
    else
        cout << mi << endl;

    return 0;
}

Measured memory_bytes: 3152