akhauriyash/Code-Regression huggingface dataset:
//Never stop trying
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;
typedef pair<int, int> pi;
#define fi first
#define se second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<str> vs;
typedef vector<ld> vd;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

const int MOD = 1e9 + 7; //998244353
const ll INF = 1e18;
const int MX = 5e5 + 10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; //right left down up

template<class T> using V = vector<T>;
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
constexpr int log2(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

#define dbg(x) cerr << " - " << #x << " : " << x << endl;
#define dbgs(x,y) cerr << " - " << #x << " : " << x << " / " << #y << " : " << y << endl;
#define dbgv(v) cerr << " - " << #v << " : " << endl << "[ "; for(auto it : v) cerr << it << ' '; cerr << ']' << endl;

void IO() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

vi bit(MX,0);

void update(int i, int v){
	for(;i<MX;i+=i&-i) bit[i]+=v;
}
int getSum(int i){
	int ans=0;
	for(;i>0;i-=i&-i) ans+=bit[i];
	return ans;
}


int32_t main() {
	boost; IO();

	int N,Q; cin>>N>>Q;
	vi c(N);
	FOR(i,0,N) cin>>c[i];
	V<pair<pi,int>> q;
	FOR(i,0,Q){
		int l,r; cin>>l>>r; l--; r--;
		q.pb({{r,l},i});
	}
	sort(all(q));
	FOR(i,0,Q) swap(q[i].fi.fi,q[i].fi.se);

	int a[N+1]; FOR(i,1,N+1) a[i]=-1;
	int idx=0; int res[Q];
	FOR(i,0,N){
		if(a[c[i]]!=-1) update(a[c[i]],-1);
	
		a[c[i]]=i+1;
		update(i+1,1);

		while(idx<Q && q[idx].fi.se<=i){
			res[q[idx].se]=getSum(q[idx].fi.se+1)-getSum(q[idx].fi.fi);
			idx++;
		}
	}
	FOR(i,0,Q) cout << res[i] << endl;





	return 0;
}

/* Careful!!!
	.Array bounds
	.Infinite loops
	.Uninitialized variables / empty containers
	.Order of input

   Some insights:
	.Binary search
	.Graph representation
	.Write brute force code
	.Change your approach
*/


Measured memory_bytes: 31260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
pair<int,int> pii;
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fastio() ios::sync_with_stdio(0);cin.tie(0);

const int nax = (int)(1e5 + 5);
vi graph[nax];

int main(){
	fastio()
	
	int n,m; cin>>n>>m;
	while(m--){
		int a,b; cin>>a>>b;
		graph[a].pb(b); graph[b].pb(a);
	}
	vi par(n+1,-1);
	
	vector<bool> visited(n+1,false);
	queue<int> Q;
	Q.push(1); visited[1]=true;
	
	while(!Q.empty()){
		int v = Q.front();
		Q.pop();
		for(auto u : graph[v]){
			if(!visited[u]){
				par[u]=v;Q.push(u); visited[u]=true;
			}
		}
	}
		
	rep(i,2,n) if(!visited[i]){cout << "No"; return 0;}
	cout<<"Yes\n";
	rep(i,2,n){
		cout <<par[i] << "\n";
	}
	
	return 0;
}


Measured memory_bytes: 10300
#include<stdio.h>
int main()
{
int n, x[100002]={0}, s, i, max;
scanf("%d",&n);
for(i=0;i<n;i++)
{
  scanf("%d",&s);
  x[s]++;
}
 max = 0;
for(i=0;i<=100000;i++)
{
  s=x[i]+x[i+1]+x[i+2];
  if(s>max )
  {
    max = s;
  }
}
printf("%d\n", max);
return 0;
}

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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

int s[maxn],a[maxn],n;

void solve(){
    long long res = 0 ;
    cin>>n;
    for(int i=1;i<=n+1;i++)cin>>s[i];
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++){
        int x = min(a[i],s[i]);
        res += x;
        a[i] -= x;
        x = min(a[i],s[i+1]);
        res += x;
        s[i+1] -= x;
    }
    cout<<res;
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    //scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
   // printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
using namespace std;
long long n,v[19],ct;
long long Min(long long a,long long b){return a<b?a:b;}
long long DP(int l,int r,int s1,int s2)
{
	if(l+1==r)return v[l]*s1+v[r]*s2;
	long long as=2e18;
	for(int i=l+1;i<r;i++)as=Min(as,DP(l,i,s1,s1+s2)+DP(i,r,s1+s2,s2)-v[i]*(s1+s2));
	return as;
}
int main(){scanf("%lld",&n);for(int i=1;i<=n;i++)scanf("%lld",&v[i]);printf("%lld\n",DP(1,n,1,1));}

Measured memory_bytes: 128
using System;
using System.Linq;

class Program
{
    static void Main()
    {
        var nmarr = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int [,]A = new int[nmarr[0], nmarr[1]];
        int []b = new int[nmarr[1]];
        
        for(int i = 0; i < nmarr[0]; i++){
            var Aarr = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            for(int l = 0; l < nmarr[1]; l++){
                A[i, l] = Aarr[l];
            }
        }
        
        for(int i = 0; i < nmarr[1]; i++){
            b[i] = int.Parse(Console.ReadLine());
        }
        
        for(int i = 0; i < nmarr[0]; i++){
            int result = 0;
            
            for(int l = 0; l < nmarr[1]; l++){
                result += A[i, l]*b[l];
            }
            
            Console.WriteLine(result);
        }
    }
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)

typedef long long ll;
typedef pair<ll,ll> P;

ll mp[111111];
ll ans[111111];

int main(){

	ll n, m;cin >> n >> m;
	vector<ll> v(m+1);
	v[m] = n+1;
	REP(i,m)cin >> v[i];

	vector<ll> seica;
	REP(i, v.size() - 1){
		if(i == 0){
			REP(j,111111)mp[j] += v[i] - 1;
		}
		int now = v[i+1] - v[i];
		for(int j = 1;j <= now;j++){
			mp[j] += now - j;
		}
	}

	//SHOW1d(mp, 20);

	int q;cin >> q;
	vector<P> que(q);
	REP(i, q){
		cin >> que[i].FI;
		que[i].SE = i;
	}

	sort(ALL(que), greater<P>());

	int nagasa = 1;
	REP(i,que.size()){
		int id = que[i].SE;
		int d = que[i].FI;
		while(nagasa < 111111 && mp[nagasa] > d)nagasa++;
		if(nagasa != 111111)ans[id] = nagasa;
		else ans[id] = -1;
	}

	REP(i,q){
		cout << ans[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 6696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,r,jdg;cin >> n;
  r=7;
  jdg=0;
  for (int i=1;i<n+1;i++) {
    if (r%n==0 && jdg==0) {
	  cout << i << endl;
	  jdg=1;
	  break;
	}
	r=r%n;
	r=r*10+7;
  }
  if (jdg==0) cout << -1 << endl;
}

Measured memory_bytes: 3616
# E - Sum Equals Xor
l = input()
n =len(l)

# a+b=a^b+a&b*2なので、a+b=a^bということは、a&b=0
# a&b=0となるようにa,bの各桁を決めていく。
# dp[i][j]:上からi桁目みたときの、組(a,b)の数。
#          j=0:i桁目までのa+bがlと一致。j=1:i桁目までのa+bがl未満であることが確定。

MOD = 10**9+7
dp = [[0 for _ in range(2)] for _ in range(n+1)]
dp[0][0] = 1
for i in range(n):
  #a+b=0のパターン(aの桁もbの桁も0)
  if l[i] == '0':
    dp[i+1][0] += dp[i][0]
    dp[i+1][1] += dp[i][1]
  else:
    dp[i+1][1] += dp[i][0]+dp[i][1]
  #a+b=1のパターン(aの桁とbの桁のどちらかが1でどちらかが0。->2パターンある。)
  if l[i] == '0':
    dp[i+1][1] += dp[i][1]*2
  else:
    dp[i+1][0] += dp[i][0]*2
    dp[i+1][1] += dp[i][1]*2
  dp[i+1][0] %= MOD
  dp[i+1][1] %= MOD

print((dp[n][0]+dp[n][1])%MOD)

Measured memory_bytes: 85808
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

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;
        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;
    }
};
ll x[60];
ll y[60];

int main(){
    int n;
    cin >> n;
    rep(i, 60) {
        x[i] = 0;
        y[i] = 0;
    }
    
    rep(i, n) {
        ll a;
        cin >> a;
        rep(j, 60) {
            ll v = a>>j & 1;
            if (v) {
                x[j]++;
            }
        }
    }
    
    
    ll ans = 0;
    rep(i, 60) {
        ll v = x[i] * (n-x[i]);
        v %= mod;
        rep(j, i) {
            v *= 2;
            v %= mod;
        }
        ans += v;
        ans %= mod;
    }
    /*
    rep(i, 60) {
        mint v = mint(x[i] * y[i]);
        mint x = mint(2).pow(i);
        v *= x;
        ans += v;
    }
    */
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<queue>
#include<vector>
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#include<iomanip>
int main(){
  int N;
  double res=0;
  priority_queue<double> V;
  cin >> N;
  rep(i,0,N){
    double temp;
    cin >> temp;
    V.push(-temp);
  }
  while(!V.empty()){
    double temp1 = -V.top();V.pop();
    if(!V.empty()){
      double temp2 = -V.top();V.pop();
      double temp3 = (temp1+temp2)/2.;
      V.push(-temp3);
    }else{
      res = temp1;
      break;
    }
  }

  cout << setprecision(15)<< res << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int solve()
{
    int N;

    cin >> N;

    int digits = 0;

    int M = N;

    while (M > 0)
    {
        ++digits;
        M /= 10;
    }

    int counter = 0;

    if (digits % 2 == 1)
        counter += N - std::pow(10, digits - 1) + 1;
    
    --digits;

    while (digits > 0)
    {
        if (digits % 2 == 1)
            counter += std::pow(10, digits) - std::pow(10, digits - 1);

        --digits;
    }

    return counter;
}

int main()
{
    cout << solve() << endl;

    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

bool Prime[int(1e5 + 5)];
int Sum[int(1e5 + 5)], Q, L, R;

int main(){
  Prime[2] = true;
  for (int i = 3; i < 1e5 + 5; i++){
    Sum[i] = Sum[i - 1];
    if (i % 2 == 0) continue;

    Prime[i] = true;
    for (int j = 2; j * j <= i; j++){
      if (i % j == 0) Prime[i] = false;
    }
    
    if (Prime[i] && Prime[(i + 1) / 2]) Sum[i]++;
  }

  scanf("%d", &Q);
  for (int i = 0; i < Q; i++){
    scanf("%d%d", &L, &R);
    printf("%d\n", Sum[R] - Sum[L-1]);
  }

  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,A,B,C,D,E; cin>>N;
  A=N/10;
  if(A==0){
    cout<<N<<endl;
  }
  else{
    B=A/10;
    if(B==0){
      cout<<"9"<<endl;
    }
    else{
      C=B/10;
      if(C==0){
        cout<<9+N-99<<endl;
      }
      else{
        D=C/10;
        if(D==0){
          cout<<"909"<<endl;
        }
        else{
          E=D/10;
          if(E==0){
            cout<<909+N-9999<<endl;
          }
          else{
            cout<<"90909"<<endl;
          }
        }
      }
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>

using namespace std;

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

  vector<pair<int, string> > year_name;
  year_name.resize(n);
  
  for (int i = 0; i < n; i++) {
    cin >> year_name[i].first  >> year_name[i].second;
    cin.ignore();
  }

  if (q < year_name[0].first) {
    cout << "kogakubu10gokan" << endl;
    return 0;
  }
  if (q >= year_name[n - 1].first) {
    cout << year_name[n - 1].second << endl;
    return 0;
  }
  for(int i = 0; i < n - 1; i++) {
    if (q >= year_name[i].first && q < year_name[i + 1].first) {
      cout << year_name[i].second << endl;
    }
  }
}



Measured memory_bytes: 3228
#include <iostream>
#include<algorithm>
#include<vector>
#include<string>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <utility>
using namespace std;

int main() {
	string s;
	cin >> s;
	int ans = 1000;
	for (int i = 0; i < s.size() - 2; i++) {
		int temp = ((s[i] - '0') * 100) + ((s[i + 1] - '0') * 10) + (s[i + 2]-'0');
		ans = min(ans, abs(temp - 753));
	}
	cout << ans << endl;
	return 0;
}

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

int main( void )
{
	// prime numbers table
	vector <bool> isPrime( 110000, false );
	isPrime[2] = true;
	for ( int i = 3; i < 110000; i += 2 )
	{
		isPrime[i] = true;
	}

	for ( int i = 3; i < 110000; i += 2 )
	{
		for ( int j = i + i; j <= 110000; j += i )
		{
			isPrime[j] = false;
		}
	}

	int n;
	while ( cin >> n && n > 0 )
	{
		int kotae = 0;
		int cnt = 1;
		for ( int i = 3; cnt < n; i += 2 )
		{
			if ( isPrime[i] )
			{
				kotae += i;
				cnt++;
			}
		}
		if ( n >= 1 )
			kotae += 2;

		cout << kotae << endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;  
int main(){
  int a,b;
  cin >> a >> b;
  if (a < b){
    cout << "a < b\n"; 
  }
  else if (a > b){
    cout << "a > b\n";
  }
  else{
    cout << "a == b\n";
  }
  return 0;
}


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

int main()
{
	int n;
	cin >> n;
	int zorocount=0;
	bool zoro3=false;

	for (int i=0;i<n;++i)
	{
		int d1,d2;
		cin >> d1 >> d2;
		if (d1==d2)
		{
			++zorocount;
			if (zorocount>=3)
			{
				zoro3=true;
			}
		}
		else
		{
			zorocount=0;
		}
	}

	if (zoro3==false)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}
}







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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 9223372036854775807
#define MOD 1000000007

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;

    //初めから奇数の時
    if(a%2==1 || b%2==1 || c%2==1){
        cout << 0 << endl;
        return 0;
    }
    int a_h, b_h, c_h;
    int cnt = 0;

    while (1){
        a_h = a / 2;
        b_h = b / 2;
        c_h = c / 2;

        a = b_h + c_h;
        b = a_h + c_h;
        c = a_h + b_h;
        
        cnt++;

        if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)
            break;
        else if(a == b && b== c){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    N, M = [int(i) for i in input().strip().split()]
    graph = [[] for _ in range(N)]
    sign = [0] * N
    for _ in range(M):
        a, b = [int(i) for i in input().strip().split()]
        a -= 1
        b -= 1
        graph[a].append(b)
        graph[b].append(a)
    candidates = deque([0])
    visited = [False] * N
    visited[0] = True
    while len(candidates) > 0:
        v = candidates.popleft()
        for i in graph[v]:
            if visited[i]:
                continue
            visited[i] = True
            sign[i] = v
            candidates.append(i)
    print("Yes")
    for i in sign[1:]:
        print(i + 1)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 99568
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

#define REP(i, s, n) for (int i = (int)(s); i < (int)(n); ++i)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

ll int_sqrt_floor(ll x) {
  ll lo = 0;
  ll hi = 1e9 + 1;
  while (hi - lo > 1) {
    ll mid = (hi + lo) / 2;
    if (mid * mid <= x) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  return lo;
}

int main(void) {
  int q;
  cin >> q;
  REP(_, 0, q) {
    ll a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    ll lim = a * b - 1;
    ll x = int_sqrt_floor(lim);
    ll ans = 2 * x;
    if (x != 0 && lim / x == x) {
      ans--;
    }
    set<ll> proh;
    if (a <= x) proh.insert(a);
    cout << ans - proh.size() << endl;
  }
}


Measured memory_bytes: 256
p=(""+require("fs").readFileSync(0)).split`
`
n=+p[0]
s=p[1]
m={}
for(b=1<<n;b--;){u=0
for(i=n;i--;)u=b&(1<<i)?s[i]+u:u+s[i]
m[u]=-~m[u]}a=0
for(b=1<<n;b--;){u=0
for(i=n;i--;)u=b&(1<<i)?s[2*n+~i]+u:u+s[2*n+~i]
a+=~~m[u]}console.log(a)

Measured memory_bytes: 65224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main() {
	int H, W, K; std::cin >> H >> W >> K;
	std::vector<std::vector<char>> M(H, std::vector<char>(W));
	for (auto i{ 0 }; i < H; ++i)
		for (auto j{ 0 }; j < W; ++j)
			std::cin >> M[i][j];
	int ans = 0;
	for (int bit_h = 0; bit_h < (1 << H); ++bit_h)
		for (int bit_w = 0; bit_w < (1 << W); ++bit_w) {
			int count = 0;
			for (int h = 0; h < H; ++h)
				for (int w = 0; w < W; ++w) {
					if (bit_h & (1 << h) || bit_w & (1 << w)) continue;
					if (M[h][w] == '#') ++count;
				}
			if (count == K) ++ans;
		}
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << x << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int>a(n);
    vector<int>b(n);
    a[0] = b[0] = 0;
    rep(i,n){
        if(i){
            a[i] = a[i-1];
            b[i] = b[i-1];
        }if(s[i]=='W'){
            a[i]++;
        }else{
            b[i]++;
        }
    }
    int ans = INT_MAX;
    ans = min(b[n-1]-b[0],a[n-2]);
    for(int i = 1;i < n-1;i++){
        ans = min(ans, a[i-1]+b[n-1]-b[i]);
    }
    cout << ans << endl;
}

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

int main() {
  long i = 0;
  long n = -1;
  while (true) {
    ++i;
    cin >> n;
    if (n == 0) {
      break;
    }
    cout << "Case " << i  << ": " << n << "\n";
  }
  return 0;
}

Measured memory_bytes: 2976
#include <stdio.h>

int main () {
	int a, b, c;
	
	scanf("%d %d", &a, &b);
	
	while (1) {
		if (b == 0) {
			printf("%d\n", a);
			break;
		}
		
		c = b;
		b = a % b;
		a = c;
		
	}
	
	
	
	return 0;
}

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

#define MAX 1500005

using namespace std;

int main() {
	int n, m;
	while (cin >> n >> m && (n || m)) {
		vector<int> hdis(MAX, 0);
		vector<int> wdis(MAX, 0);
		vector<int> h(n + 1); h[0] = 0;
		vector<int> w(m + 1); w[0] = 0;
		int tmp;
		for (int i = 1; i <= n; ++i) {
			cin >> tmp; h[i] = h[i - 1] + tmp;
		}
		for (int i = 1; i <= m; ++i) {
			cin >> tmp; w[i] = w[i - 1] + tmp;
		}
		int hmax = 0, wmax = 0;
		for (int i = 1; i <= n; ++i) {
			for (int j = 0; j < i; ++j) {
				hdis[h[i] - h[j]]++;
				hmax = max(hmax, h[i] - h[j]);
			}
		}
		for (int i = 1; i <= m; ++i) {
			for (int j = 0; j < i; ++j) {
				wdis[w[i] - w[j]]++;
				wmax = max(wmax, w[i] - w[j]);
			}
		}
		int maxi = min(wmax, hmax);
		int cnt = 0;
		for (int i = 1; i <= maxi; ++i) cnt += hdis[i] * wdis[i];

		cout << cnt << endl;
	}

	return 0;
}


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

using namespace std;

int main() {
	int A, B, C, K;
	cin>>A>>B>>C>>K;
	
	int sum;
	if(A>=K){
	    sum = K;
	}else if(A < K && K <= (A+B) ){
	    sum = A;
	}else if((A+B) < K && K <= (A+B+C)){
	    sum = A - (K - (A+B));
	}else{
	    sum = 0;
	}
	
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3636
n,q=map(int,input().split())
s=input()
lr=[list(map(int,input().split())) for _ in range(q)]
x=[0]
j=False
t=0
for i in range(n):
    if i==0:
        if s[i]=="A":
            j=True
    elif j==True:
        if s[i]=="C":
            t+=1
            j=False
        if s[i]=="A":
            j=True
        else:
            j=False
    elif s[i]=="A":
        j=True
    x.append(t)
for l,r in lr:
    print(x[r]-x[l])

Measured memory_bytes: 69336
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		int n =  Integer.parseInt(sc.next());
		int x =  Integer.parseInt(sc.next());
		int y =  Integer.parseInt(sc.next());
		int[][] to = new int[n][n];
		int[] ans = new int[n];


		for(int i = 0; i < n ; i++) {
			for(int j = 0; j < n ; j++){
				to[i][j] = Math.abs(j - i);
			}
		}
		to[x-1][y-1] = 1;
		to[y-1][x-1] = 1;


//		for(int k = 0; k < n ; k++) {
			for(int i = 0; i < n ; i++) {
				for(int j = 0 ; j < n ; j++) {
					to[i][j] = Math.min(to[i][j], to[i][x-1] + to[x-1][j]);
				}
			}
			
			for(int i = 0; i < n ; i++) {
				for(int j = 0 ; j < n ; j++) {
					to[i][j] = Math.min(to[i][j], to[i][y-1] + to[y-1][j]);
				}
			}
//		}

		for(int i = 0; i < n ; i++) {
			for(int j = i+1; j < n ; j++){
				ans[to[i][j]]++;
			}
		}

		PrintWriter out = new PrintWriter(System.out);
		for(int i = 1 ; i < n ; i++) {
			out.println(ans[i]);
		}
		out.flush();
	}
}


Measured memory_bytes: 54612
#include <stdio.h>
int main(){
  int H,W;
  while(1){
  scanf("%d %d",&H,&W);
  if(H == 0 && W ==0) break;
  int a,b;
  for( a = 0 ; a < H ; a++){
    for( b = 0 ; b < W ; b++){
     printf("#");
    }
    printf("\n");
   }
   printf("\n");
  }
  return 0;
  }

Measured memory_bytes: 572
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI 3.14159265358979323846264338327950L

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define int long long
#define Graph vector<vector<int> >
#define PII pair<int,int>
#define VI vector<int>
#define VVI vecotor<vector<int> >
#define VPII vector<pair<int,int> >

template<typename A, size_t N, typename T>

void Fill(A (&array)[N], const T &val) {
	std::fill( (T*)array, (T*)(array + N), val );
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここにグローバル変数宣言
int H, W, sh, sw, gh, gw;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};//BFS関連







//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ここに関数宣言
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}










//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
signed main() {
	//入力の高速化用のコード
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	

int N,D;
cin>>N>>D;
int x,y,cnt=0;

REP(i,N){
	cin>>x>>y;
	if(x*x+y*y<=D*D){cnt++;}

}


cout<<cnt<<endl;


























return 0;

}







Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> int_pair;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=501;
ll n,c[N],s[N],f[N];
ll ans;

ll dfs(ll eki,ll time){
	ll an;
	if(eki==n)return time;
	if(time<s[eki])time=s[eki];
	time-=s[eki];
	if(time%f[eki]==0){
		an=time+s[eki];
	}else{
		an=(time/f[eki]+1)*f[eki]+s[eki];
	}
	an+=c[eki];
	dfs(eki+1,an);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n;
	CLR(c);CLR(s);CLR(f);
	FOR(i,1,n){
		cin>>c[i]>>s[i]>>f[i];
	}
	FOR(i,1,n){
		cout<<dfs(i,0)<<endl;
	}
	cout<<"0"<<endl;

	return 0;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

map<lli,lli> dp;
set<lli,greater<lli>> s;

signed main(){

    lli N,W;
    cin>>N>>W;

    dp[0]=0;
    s.insert(0);

    REP(i,0,N){
        lli w,v;
        cin>>w>>v;

        for(auto e:s){
            lli nextW = e+w;
            if(nextW>W)continue;
            dp[nextW] = max(dp[nextW],dp[e]+v);
            if(DEBUG)cout<<"nextW="<<nextW<<" dp[nextW]="<<dp[nextW]<<endl;
        }
        for(auto e:dp){
            s.insert(e.first);
        }
    }

    lli maxV=0;
    for(auto e:dp){
        if(DEBUG)cout<<"e.first="<<e.first<<" e.second="<<e.second<<endl;
        if(e.first>W)continue;
        maxV = max(maxV,e.second);
    }
    cout<<maxV<<endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define pb push_back
#define all(v) v.begin(),v.end()
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
using ll = long long;
using lf = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
ll D[100105];
int h[100105];
int n, k;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> h[i];
    h[0] = 1e9;
    for(int i = 2; i <= n; i++){
        D[i] = INT_MAX;
        for(int j = i - 1; j >= i - k && j >= 1; j--){
            D[i] = min(D[i], D[j] + abs(h[i] - h[j]));
        }
    }
    cout << D[n] << '\n';
}


Measured memory_bytes: 1408
using System;
using System.Linq;

class B
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int n = h[0], k = h[1];
		Console.WriteLine(Enumerable.Range(1, 30).First(i => (n /= k) == 0));
	}
}


Measured memory_bytes: 28224
#include <stdio.h>
int main(void){
    int N,Y;
    scanf("%d%d", &N, &Y);
    Y /= 1000;
    for (int i = 0; i <= N; i++) {
        int x = (Y - N - 4 * i) / 9;
        if ((Y - N == 9 * x + 4 * i) && (0 <= x) && (x <= N)){
            int z = N - x - i;
            if (0 <= z && z <= N) {
                printf("%d %d %d\n", x, i, z);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}


Measured memory_bytes: 256
n=gets.to_i
t=gets.chomp.split(" ").map(&:to_i)
m=gets.to_i
m.times do|i|
  p,x=gets.chomp.split(" ").map(&:to_i)
  ans=0
  t.each_with_index do|num,j|
    if j==p-1
      ans+=x
    else
      ans+=num
    end 
  end
  puts ans
end


Measured memory_bytes: 1788
#include <cmath>
#include <iostream>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <algorithm>

using namespace std;
const int MIN = 200001;

int main() {
	int n, p, min = MIN, r = 0;
	
	cin >> n;
	
	while (n > 0) {
		cin >> p;
		if (p <= min) {
			r++;
			min = p;
		}
		n--;
	}
	
	cout << r << endl;
	
    return 0;
}

Measured memory_bytes: 384
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def sample():
    uf = UnionFind(6)
    print(uf.parents)
    uf.union(0, 2)
    print(uf.parents)
    uf.union(1, 3)
    print(uf.parents)
    uf.union(4, 5)
    print(uf.parents)

def atc001():
    n, q = map(int, input().split())
    uf = UnionFind(n)
    for i in range(q):
        p, a, b = map(int, input().split())
        if p == 0:
            uf.union(a, b)
        else:
            if uf.same(a, b):
                print("Yes")
            else:
                print("No")

def abc049():
    n, k, l = map(int, input().split())
    road = UnionFind(n)
    train = UnionFind(n)
    for i in range(k):
        p, q = map(int, input().split())
        road.union(p - 1, q - 1)
    for i in range(l):
        p, q = map(int, input().split())
        train.union(p - 1, q - 1)

    pair = []
    pair_cnt = {}
    for i in range(n):
        t, r = road.find(i), train.find(i)
        pair.append([t, r])
        key = t * (10 ** 6) + r
        if key in pair_cnt:
            pair_cnt[key] += 1
        else:
            pair_cnt[key] = 1

    for i in range(n):
        [t, r] = pair[i]
        key = t * (10 ** 6) + r
        print(pair_cnt[key], end = " ")

abc049()



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

int main() {
	int n;
	set<int> a;
	cin >> n;
	rep(i, n) {
		int val;
		cin >> val;
		if (a.find(val) == a.end()) a.insert(val);
		else a.erase(val);
	}

	cout << a.size() << endl;
	return 0;
}

Measured memory_bytes: 4864
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    int A, B; cin >> A >> B;
    int ans = 1;
    if (B == 1) {
        cout << 0 << endl;
        return 0;
    }
    REP(i, 100) {
        ans += A - 1;
        if (ans >= B) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3612
//Created by apsp1234

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<string>
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
#define ct continue
#define PI 3.14159265358979323846
#define maxn 100005
#define L length()
#define B begin()
#define T front()
#define E end()
#define Z size()
#define RB rbegin()
#define RE rend()
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define mini(x,y) (y + ((x - y) & ((x - y) >>(sizeof(int) * CHAR_BIT - 1))))
#define maxi(x,y) (x - ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))))
#define fr(j,a,b) for(j=a;j<b;j++)

lli power(lli x, lli y, lli p)
{   lli res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {   if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

int main()
{
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli i, j, q, t, n, y, k, x, m, s;
    cin >> n >> x >> t;
    cout << ((n + x - 1) / x)*t;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin >> n;
  
  vector<double> v(n);
  for(int i; i < n; i++)
    cin >> v.at(i);
  
  sort(v.begin(), v.end());
  
  double s = (v.at(0) + v.at(1)) / 2;
  int j = 2;
  
  while(j < n){
    s = (s + v.at(j)) / 2;
    j++;
  }
  
  cout << s << endl;
}
    
  

Measured memory_bytes: 256
n,k=map(int,input().split( ))
nn,r=n,k
c=[[0 for i in range(r+1)]for i in range(nn+1)]
for i in range(nn+1):
	for j in range(min(i,r)+1):
		if j==0 or j==i:
			c[i][j]=1
		else:
			c[i][j]=c[i-1][j]+c[i-1][j-1]
p=10**9+7
for i in range(1,k+1):
	print(((c[n-k+1][i]%p)*(c[k-1][i-1]%p))%p)


Measured memory_bytes: 357560
//AGC33 A
//Darker Darker
#include <queue>
#include <stack>
#include <cstdio>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
#define MAX_H 1000
#define MAX_W 1000
typedef pair<int,int> P;


char map[MAX_H][MAX_W + 1];
int d[MAX_H][MAX_W];
int H,W;

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

int main(){
  queue<P> que;
  cin >> H >> W;
  rep(i,H){
    cin >> map[i];
    rep(j,W){
      if (map[i][j] == '#'){
        d[i][j] = 0;
        que.push(P(i,j));
      }
      else d[i][j] = -1;
    }
  }
  while (que.size()){
    P p = que.front(); que.pop();

    rep(i,4){
      int nx = p.first + dx[i], ny = p.second + dy[i];
      //std::cout << nx ,std::cout << ny << std::endl;
      if (0 <= nx && nx < H && 0 <= ny && ny < W && d[nx][ny] == -1){
        que.push(P(nx,ny));
        d[nx][ny] = d[p.first][p.second] + 1;
      }
    }
  }
  int res = -1;
  rep(i,H)
  rep(j,W) res = max(res,d[i][j]);
  printf("%d",res);

  return 0;
}

Measured memory_bytes: 13056
#include<stdio.h>
int m[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int main(){
	int a,b,c,d,e,f;
	while(1){
		scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
		if(a<0||b<0||c<0||d<0||e<0||f<0)break;
		a--;d--;
		int one=a*365+a/4-a/100+a/400,two=d*365+d/4-d/100+d/400;
		a++;d++;
		for(int i=0;i<b-1;i++)one+=m[i];
		for(int i=0;i<e-1;i++)two+=m[i];
		one+=c;two+=f;
		if(b>2&&(a%4==0&&((a%100==0&&a%400==0)||a%100)))one++;
		if(e>2&&(d%4==0&&((d%100==0&&d%400==0)||d%100)))two++;
		printf("%d\n",two-one);
	}
}


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

int main()
{
	map<string,int> mm;
	int n,m;
	cin >> n;
	string s;

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

	cin >> m;
	for (int i=0;i<m;++i)
	{
		cin >> s;
		mm[s]--;
	}

	int max_score=0;
	for (pair<string,int> p: mm)
	{
		if (p.second>max_score)
		{
			max_score=p.second;
		}
	}
	cout << max_score << endl;
}







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

int main(){
    int n,k;cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;++i){
        cin>>a[i];
    }
    for(int i=0;i<k;++i){
        vector<int> b(n+1);
        for(int j=0;j<n;++j){
            int l=max(0,j-a[j]);
            int r=min(j+a[j]+1,n);
            b[l]++;b[r]--;
        }
        for(int m=0;m<n;++m)b[m+1]+=b[m];
        b.pop_back();
        if(a==b)break;
        a=b;
    }
    // if(k>=50)k=50;
    // for(int i=0;i<k;++i){
    //     vector<int> cnt(n,0);
    //     for(int j=0;j<n;++j){
    //         if(a[j]==0)cnt[j]++;
    //         else{
    //             cnt[j]++;
    //             for(int k=1;k<=a[j];++k){
    //                 if(j+k<n)cnt[j+k]++;
    //                 if(j-k>=0)cnt[j-k]++;
    //             }   
    //         }
    //     }
    //     for(int l=0;l<n;++l)a[l]=cnt[l];
    // }
    for(int i=0;i<n;++i)cout<<a[i]<<" ";
    cout<<""<<endl;
    return 0;
}

Measured memory_bytes: 4824
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
//作者:中国江苏南京丁天行
using namespace std;
int n;
ll a[100005];
ll l[100005],r[100005];
int main(){
    cin>>n;
    a[0]=1;
    for(int i=1;i<=n;i++)cin>>a[i];
    if(a[n]!=2){
        puts("-1");
        return 0;
    }
    l[n]=r[n]=2;
    for(int i=n;i;i--){
        l[i-1]=l[i]/a[i-1]*a[i-1];
        if(l[i-1]<l[i])l[i-1]+=a[i-1];
        r[i-1]=(r[i]+a[i]-1)/a[i-1]*a[i-1];
        if(l[i-1]>r[i-1]){
            puts("-1");
            return 0;
        }
    }
    cout<<l[0]<<' '<<r[0]<<endl;
	//system("pause");
	return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    ll s = 0;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        s += a[i];
    }
    a.push_back(a[0]);
    ll t = ll(n) * (n + 1) / 2;
    if (s % t) {
        cout << "NO";
        return 0;
    }
    s /= t;
    //(1 - n) * x + y = a[i + 1] - a[i]; x + y == s
    //(1 - n) * x + s - x = d
    ll k = 0;
    for (int i = 0; i < n; ++i) {
        ll d = a[i + 1] - a[i] - s;
        if (d == 0) {
            continue;
        }
        if (d > 0 || abs(d) % n) {
            cout << "NO";
            return 0;
        }
        d /= n;
        k -= d;
    }
    if (k != s) {
        cout << "NO";
    } else {
        cout << "YES";
    }
    return 0;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;



void solve(){
	ll n;
	cin>>n;
	ll ans=1;
	for(int i=1;i<=n;i++)
		ans*=i,ans%=mod;
	cout<<ans;


}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


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

int main() {
  long long n;
  scanf("%lld", &n);
  
  long long s;
  long long fsn = floor(sqrt(n));

  s = -fsn * (fsn+1) * (fsn*2+1) /6;
  for(long long i=1;i<=fsn;i++){
    s += i*(i+n/i)*(n/i+1-i);
  }
  
  printf("%lld", s);
  return 0;
}


Measured memory_bytes: 2164
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<utility>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)

int main(void) {
	int n, t, min = 10000;
	cin >> n >> t;
	int c, b;
	for (int i = 0;i < n;i++) {
		cin >> c >> b;
		if (b <= t&&c<min) {
			min = c;
		}
	}
	if (min == 10000)cout << "TLE" << endl;
	else cout << min << endl;
	return 0;
}

Measured memory_bytes: 256