akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

#ifdef DEBUG
bool debug = true;
#else
bool debug = false;
#endif
int N;

string to_str(LL n){
    stringstream ss;
    ss << n;
    string s;
    ss >> s;
    return s;
}

bool query(LL n){
    if(debug){
        string s = to_str(n);
        string S = to_str(N);
        if(n <= N && s <= S)return true;
        if(n > N && s > S)return true;
        return false;
    }
    string ans;
    cout << "? " << n << endl;
    cin >> ans;
    return ans[0] == 'Y';
}

int solve(){
    if(query(1e9)){
        for(LL i=2; i<=1e10; i*=10){
            if(query(i))return i/2;
        }
        return -1;
    }
    for(LL len=1e9; len>1; len/=10){
        if(!query(len/10))continue;
        LL lb = len/10;
        LL ub = len-1;
        while(ub-lb>1){
            LL mid = (lb+ub)>>1;
            bool res = query(mid*10);
            cerr << lb << " " << ub << " " << mid << " " << res << endl;
            if(res){
                ub = mid;
            }else{
                lb = mid;
            }
        }
        return ub;
    }
    return -1;
}

int main(){
    if(debug){
        cin >> N;
    }
    int res = solve();
    cout << "! " << res << endl;
    return 0;
}



Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

signed main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    vector<int> X(N);
    ll ans = 0ll;
    rep(i, N)
    {
        cin >> X[i];
    }
    rep(i, N - 1)
    {
        ans += min(A * (X[i + 1] - X[i]), B);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,w,h) rep(j,h)rep(i,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> a(n);rep(i,n)std::cin >> a[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
    int n,m;
    std::cin >> n>>m;
    std::vector<int> a(m),aa(n+1,0);
    rep(i,m){
        std::cin >> a[i];
        //a[i]--;
        aa[a[i]]++;
    }
    std::vector<ll> dp(n+1,0);
    //int cou=0;
    if(!aa[1]){
        dp[1]=1;
    }
    dp[2]=dp[1];
    if(!aa[2])dp[2]++;
    rrep(i,3,n+1){
        if(!aa[i-1])dp[i]+=dp[i-1];
        if(!aa[i-2])dp[i]+=dp[i-2];
        dp[i]%=MOD;
    }
    std::cout << dp[n] << std::endl;
    
}

Measured memory_bytes: 1792
/** e==m*pow(c,2) **/
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define LL long long
#define int long long
//#define OFFLINE 2585
#define pii pair<int, int>
#define SQR(n) (n*n)
#define pb push_back
//#define endl '\n'
#define yes cout << "YES" << endl
#define no cout << "NO" << endl
#define INF 100000000000
#define PI (acos(0.0) * 2.0)
#define time_start clock_t tStart = clock()
#define time_end (double)(clock() - tStart)/CLOCKS_PER_SEC
#define maxn 100009
//#pragma GCC diagnostic warning "-std=c++11"
#define check(n, i) (int)(bool(!((n)&(1<<(i)))))
#define set(n, i) (((n)|(1<<(i))))
#define mod 100000007
 
#define dbg(a) cout << #a << " = " << a << endl;

 
void faster(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
 
int lcm(int a, int b)
{
    return (a*b) / __gcd(a, b);
} 
 
double dp[3005][3005], ara[3005]; 

int32_t main()
{
    #ifdef ONPC
      freopen("in.txt", "r", stdin);
      freopen("out.txt", "w", stdout);
    #endif
    faster();
    int n, i, j;
    memset(dp, 0, sizeof(dp));
    cin >> n;
    for(i=1;i<=n;i++) cin >> ara[i];
    dp[1][0]=1.0-ara[1];
    for(i=2;i<=n;i++) dp[i][0]=(1-ara[i])*dp[i-1][0];
    dp[1][1]=ara[1];
    for(i=2;i<=n;i++)
    {
    	for(j=1;j<=n;j++)
    	{	
    		if(j>i) break;
    		if(DEBUG)
    		{for(int x=0;x<=n;x++)
    		{
    			for(int y=0;y<=n;y++)
    			{
    				cout<<dp[x][y]<<"      ";
    			}
    			cout<<endl;
    		}	
    		cout<<endl;}
    		//cout << i<<' '<<j<<endl;
    		//cout<<dp[i-1][j-1]<<' ' <<ara[i] <<' '<< dp[i-1][j]<<' '<<(1.0-ara[i])<<endl;
    		dp[i][j] = dp[i-1][j-1]*ara[i] + dp[i-1][j]*(1.0-ara[i]);
    	}
    }
    double ans=0;
    for(i=n/2+1;i<=n;i++) ans += dp[n][i];
    cout << fixed << setprecision(25) <<ans<<endl;
    return 0;
}



Measured memory_bytes: 70784
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
  string o,e,sum;
  cin >> o >> e;
 
  int os=o.size(), es=e.size();
  
  if(os==es){
  	for(int i=0; i<es; i++) sum = sum + o[i] + e[i];
  }
  else{
    for(int i=0; i<es; i++) sum = sum + o[i] + e[i];
    sum += o[os-1];
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
ll mod=1e9+7;
ll ex(ll x,ll p){
	ll a=1;
	while(p){
		if(p%2) a=a*x%mod;
		x=x*x%mod;
		p/=2;
	}
	return a;
}
int N,X;
vector<int> ds;
ll dp[10000];
int main(){
	cin>>N>>X;
	for(int i=1;i*i<=N;i++){
		if(N%i==0){
			ds.pb(i);
			if(i*i!=N) ds.pb(N/i);
		}
	}
	sort(all(ds));
	int K=ds.size();
	rep(i,K){
		int L=ds[i];
		ll tmp=ex(X,(L+1)/2);
		rep(j,i) if(ds[i]%ds[j]==0) tmp-=dp[j];
		tmp=(tmp%mod+mod)%mod;
		dp[i]=tmp;
	}
	ll ans=0;
	rep(i,K){
		ll ad=dp[i]*ds[i];
		if(ds[i]%2==0) ad/=2;
		ans=(ans+ad)%mod;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int n, m;
    while(cin >> n >> m, n){
        auto dp = make_v(m, n, 0.0);
        auto G = make_v(n, n, 0.0);
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                cin >> G[i][j];
            }
        }
        for (int i = 0; i < n; ++i) {
            dp[0][i] = 1.0;
        }
        for (int i = 0; i < m-1; ++i) {
            for (int j = 0; j < n; ++j) {
                for (int k = 0; k < n; ++k) {
                    chmax(dp[i+1][k],dp[i][j]*G[j][k]);
                }
            }
        }
        printf("%.2lf\n", *max_element(dp.back().begin(),dp.back().end()));
    }
    return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<int, int>  pii;
typedef pair<ld, ld>  pld;
ll n, k;
ll a[200009];
map<ll, ll> mpp;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    cin >> n >> k;
    for(ll i = 0; i < n; ++i){
        cin >> a[i];
        --a[i];
        a[i] %= k;
        //cout << a[i] << " ";
    }
    if(k == 1){
        cout << "0\n";
        return 0;
    }
    //cout << "\n";
    ll ans = 0;
    ll add = 0;
    queue<pll> q;
    for(ll i = 0; i < n; ++i){
        if(a[i] == 0)
            ++ans;
        while(!q.empty() && i-q.front().ff >= k-1){
            mpp[q.front().ss]--;
            q.pop();
        }
        ll tmp = (k-a[i]+add)%k;
        while(tmp < 0)
            tmp += k;
        ans += mpp[tmp];
        add -= a[i];
        tmp = (a[i]+add)%k;
        while(tmp < 0)
            tmp += k;
        mpp[tmp]++;
        q.push({i, tmp});
    }
    //cout << "\n";
    cout << ans << "\n";
}

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

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
int W, H;
char board[30][30];

int dfs(int y, int x) {
   board[y][x] = '#';
   int ret = 1;
   for (int i = 0; i < 4; i++) {
      int ny = y + dy[i], nx = x + dx[i];
      if (nx >= 0 && nx < W && ny >= 0 && ny < H && board[ny][nx] == '.') {
         ret += dfs(ny, nx);
      }
   }
   return ret;
}

int main() {
   while (cin >> W >> H, W) {
      for (int i = 0; i < H; i++) {
         cin >> board[i];
      }
      for (int i = 0; i < H; i++) {
         for (int j = 0; j < W; j++) {
            if (board[i][j] == '@') {
               cout << dfs(i, j) << endl;
            }
         }
      }
   }

   return 0;
}


Measured memory_bytes: 2944
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>
#include <numeric>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
//const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 1LL * 1e18;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 1e6 + 10;





signed main() {
	speed;
	int ans, n;
	cin >> n;
	for (int i = 1; i <= 11; ++i) {
		if (n - 1000 * i <= 0) {
			ans = 1000 * i - n;
			break;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3636
'use strict'
const main = arg => {
	const input = arg.trim().split("\n");
	let As = input[1].split(' ')
	let costs = []
	for(let i = -100; i <= 100 ; i++) {
		let cost = 0
		for(let j = 0 ; j < As.length ; j++) {
			let tmp = i - As[j]
			cost += tmp * tmp
		}
		costs.push(cost)
	}
	console.log(costs.sort((a, b) => a - b)[0])
}   
 main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int isM(char *c){
    if(c[0] == '1'){
        if(c[1] == '0' || c[1] == '1' || c[1] == '2'){
            return 1;
        }
    }else if(c[0] == '0'){
        if(c[1] != '0'){
            return 1;
        }
    }
    return 0;
}

int main(void){
    char c[4];
    for(int i = 0;i < 4;i++)    cin >> c[i];
    int yymm, mmyy;

    yymm = isM(&c[2]);
    mmyy = isM(&c[0]);

    if(yymm){
        if(mmyy){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "YYMM" << endl;
        }
    }else{
        if(mmyy){
            cout << "MMYY" << endl;
        }else{
            cout << "NA" << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 
 
 
 int main(){ 
     int a, b; 
     char op; 
     while(1){ 
         scanf("%d %c %d", &a, &op, &b); 
         if(op=='?'){ 
             break; 
     	}else if(op=='+'){ 
     	    printf("%d\n", a+b); 
     	}else if(op=='-'){ 
     	    printf("%d\n", a-b); 
     	}else if(op=='*'){ 
     	    printf("%d\n", a*b); 
     	}else if(op=='/'){ 
     	    printf("%d\n", a/b); 
         } 
     } 
     return 0; 
 } 



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

int main() {
  int N ; cin >> N;
  int count = 0;
  if (N == 1){
    count = 2;
  }
  if (N == 2){
    count = 1;
  }

  while(N != 1){
    if(N % 2 == 0){
      N /= 2;
      count++;
    }
    else
    {
      N = 3 * N + 1;
      count++;
    }
  }
cout << count + 2 << endl;

  }
  


Measured memory_bytes: 256
DICT = {
  'C' => 0, 'C#' => 1, 'D' => 2, 'D#' => 3, 'E' => 4, 'F' => 5,
  'F#' => 6, 'G' => 7, 'G#' => 8, 'A' => 9, 'A#' => 10, 'B' => 11,
}

def check(stairs, music, k)
  (music.size - 1).downto(0) do |i|
    return false unless 0 <= k && k < stairs.size && k < (i + 1) * 2
    tone = music[i]
    stair = stairs[k]
    case (tone - stair) % 12
    when 1
      k -= 2
    when 0
      k -= 1
    when 11
      k += 1
    else
      return false
    end
  end
  k == -1
end

def work(stairs, music)
  check(stairs, music, stairs.size - 2) || check(stairs, music, stairs.size - 1)
end

s = STDIN.gets.to_i
s.times do
  STDIN.gets
  stairs = STDIN.gets.split.map!{|x| DICT[x]}
  music = STDIN.gets.split.map!{|x| DICT[x]}
  puts work(stairs, music) ? 'Yes' : 'No'
end

Measured memory_bytes: 17352
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll a=0,b=0,h,m,w,n,z=0,min=100000000000,k,ans=0;
    string s1,s2,s3;
    cin >> n;
    VI t(n);
    rep(i,n){
        cin >> t[i];
    }
    cin >> m;
    VI p(m);
    VI x(m);
    rep(i,m){
        cin >> p[i] >> x[i];
    }
    int temp;
    rep(i,m){
        temp = t[p[i]-1];
        t[p[i]-1] = x[i];
        rep(i,n){
            ans += t[i];
        }
        cout << ans << endl;
        ans=0;
        t[p[i]-1] = temp;
    }


    return 0;
}

Measured memory_bytes: 256
/*
    なるべく諦めない！
    なせば大抵なんとかなる！
*/

#define VERNIY st();int ver=0,niy=0,hbk=0

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <float.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <functional>
#include <set>
#define LLU unsigned long long int
#define LL long long int
using namespace std;
#define Lfmax DBL_MAX
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vpd vector<pair<int,int>>
#define vLL vector<long long int>
#define vpLL vector<pair<long long int,long long int>>
#define vLLU vector<unsigned long long int>
#define vpLLU vector<pair<unsigned long long int,unsigned long long int>>
#define pd pair<int,int>
#define pLL pair<long long int,long long int>
#define pLLU pair<unsigned long long int,unsigned long long int>
#define qd queue<int>
#define qpd queue<pair<int,int>>
#define maxpqd priority_queue<int>
#define minpqd priority_queue<int, vector<int>, greater<int>>
#define fr front
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; ++a)
#define forineq(a,b,c) for(int a=b ; a<=c ; ++a)
#define forde(a,b,c) for(int a=b ; a>=c ; --a)
#define UPC(oo) (oo>='A' && oo<='Z')
#define LWC(oo) (oo>='a' && oo<='z')
#define DGT(oo) (oo>='0' && oo<='9')
#define UPCVOC(oo) (oo=='A' || oo=='E' || oo=='I' || oo=='U' || oo=='O')
#define LWCVOC(oo) (oo=='a' || oo=='e' || oo=='i' || oo=='u' || oo=='o')
#define filein freopen("in.txt","r",stdin);
#define fileout freopen("out.txt","w",stdout);

inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void sctlld(LL &a,LL &b,LL &c){scanf("%I64d %I64d %I64d",&a,&b,&c);}
inline void scdlld(LL &a,LL &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(LL &a){scanf("%I64d",&a);}
inline void scllu(LLU &a){scanf("%I64u",&a);}
inline void scdllu(LLU &a,LLU &b){scanf("%I64u %I64u",&a,&b);}
inline void sctllu(LLU &a,LLU &b,LLU &c){scanf("%I64u %I64u %I64u",&a,&b,&c);}

template<class Ver>
inline void prd(Ver a){cout<<a<<"\n";};
template<class Ver>
inline void prdd(Ver a,Ver b){cout<<a<<" "<<b<<"\n";};
template<class Ver>
inline void prtd(Ver a, Ver b, Ver c){cout<<a<<" "<<b<<" "<<c<<"\n";};

inline void debug(){printf("asd\n");}
template<class Ver>
inline void debugd(Ver a){cout<<"--- "<<a<<endl;};
template<class Ver>
inline void debugdd(Ver a,Ver b){cout<<"--- "<<a<<" "<<b<<endl;};
template<class Ver>
inline void debugtd(Ver a,Ver b,Ver c){cout<<"--- "<<a<<" "<<b<<" "<<c<<endl;};

#define grav 9.8
#define pi 3.14159265

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

int main()
{
	VERNIY;
	sctd(hbk,ver,niy);
	if(hbk*ver<niy)
	prd(hbk*ver);
	else
	prd(niy);

	return 0;
}

/*
    なるべく諦めない！
    なせば大抵なんとかなる！
*/


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

using namespace std;

#define rep(i , j , k) for (int i = j; i < (int)k; i++)
#define pb push_back
#define mt make_tuple
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef complex<ld> point;
typedef pair<ld , ld> pld;
typedef vector<ll> vi;

inline void fileIO(string s) {
	//	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

template<class T , class S>
inline bool smin(T &a, S b) { return (T)b < a ? a = b , 1 : 0; }
template<class T , class S>
inline bool smax(T &a, S b) { return a < (T)b ? a = b , 1 : 0; }

constexpr int N = 2e5 + 10;
constexpr int MOD = 1e9;

template<typename T>
inline T mod(T &v) { return v = (v % MOD + MOD) % MOD; }
template<typename S, typename T>
inline S add(S &l, T r) { return mod(l += r); }

int n, q;

vi vec;
map<ll , ll> mp;

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

	cin >> n >> q;
	vec.pb(n);
	rep(i , 0 , q) {
		ll q2; cin >> q2;
		while (vec.size() && vec.back() >= q2) vec.pop_back();
		vec.pb(q2);
	}

	mp[vec.back()] = 1;

	reverse(all(vec));
	for (auto e : vec) 		while (mp.size() && (*mp.rbegin()).first > e) {
		auto me = *mp.rbegin();
		mp[me.first % e] += me.second;
		mp[e] += (me.first / e) * me.second;
		mp.erase(mp.find(me.first));
	}


	mp[n];
	vi ans;
	rep(i , 0 , n) {
		ans.pb(mp[n - i]);
		mp[n - i - 1] += mp[n - i];
	}
	reverse(all(ans));
	for (auto e : ans) cout << e << '\n';

	return 0;
}


Measured memory_bytes: 9588
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1000000000;
const double PI = acos(-1);


long long int N, M, K, H, W, L, R;
multimap<pair<int, int>, pair<pair<int, int>, int>>edge;
map<pair<int, int>, int>dis;
priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>>PQ;


void dijkstra() {
	dis[{1, 0}] = 0;
	PQ.push({ 0,{ 1,0 } });
	while (!PQ.empty()) {
		auto cn = PQ.top().second;
		int c = PQ.top().first;
		PQ.pop();
		if (c > dis[cn])continue;
		auto m = edge.equal_range(cn);
		for (auto i = m.first; i != m.second; ++i) {
			if (dis.find(i->second.first) == dis.end()) {
				dis[i->second.first] = dis[cn] + i->second.second;
				PQ.push({ dis[i->second.first], i->second.first });
			}
			else if (dis[i->second.first] > dis[cn] + i->second.second) {
				dis[i->second.first] = dis[cn] + i->second.second;
				PQ.push({ dis[i->second.first], i->second.first });
			}
		}
	}
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> L >> R >> K;
		edge.insert({ { L,K },{ { R,K },0 } });
		edge.insert({ { R,K },{ { L,K },0 } });
		edge.insert({ { L,0 },{ { L,K },1 } });
		edge.insert({ { R,0 },{ { R,K },1 } });
		edge.insert({ { R,K },{ { R,0 },0 } });
		edge.insert({ { L,K },{ { L,0 },0 } });
	}
	dijkstra();
	if (dis.find({ N,0 }) == dis.end()) {
		cout <<-1<<endl;
	}
	else {
		cout << dis[{N, 0}] << endl;
	}
}

Measured memory_bytes: 101552
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	int a,b,c,d,e,f,k,l,m,n,x,y,z;
	int ans;
	String[] S;

	Main(){
		switch(sc.next()){
			case "Sunny":
				System.out.println("Cloudy");
				break;
			case "Cloudy":
				System.out.println("Rainy");
				break;
			case "Rainy":
				System.out.println("Sunny");
				break;
        }
	}

	public static void main(String[] args){
		new Main();
	}
}

Measured memory_bytes: 23124
#! python3
# official_house.py

n = int(input())
rooms = [[int(x) for x in input().split(' ')] for i in range(n)]

rooms_people = [[[0 for k in range(10)] for j in range(3)] for i in range(4)]
for i in range(n):
    rooms_people[rooms[i][0]-1][rooms[i][1]-1][rooms[i][2]-1] += rooms[i][3]

for i in range(4):
    if i != 0: print('####################')
    for j in range(3):
        for k in range(10):
            print('', rooms_people[i][j][k], end='')
        print('')



Measured memory_bytes: 5636
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<int, int> P;

llint n, a[3];
string s[100005];
string ans;

llint get(string s)
{
	if(s == "AB") return 0;
	if(s == "BC") return 1;
	if(s == "AC") return 2;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	llint sum = 0;
	for(int i = 0; i < 3; i++) cin >> a[i], sum += a[i];
	for(int i = 1; i <= n; i++) cin >> s[i];
	
	for(int i = 1; i <= n; i++){
		llint x = get(s[i]), y = (x+1)%3, p, q;
		if(a[x] >= 2) p = x;
		else if(a[y] >= 2) p = y;
		else if(a[x] == 1 && a[y] == 1){
			if(i == n || get(s[i+1]) == y) p = x;
			else p = y;
		}
		else if(a[x] == 1) p = x;
		else if(a[y] == 1) p = y;
		else{
			cout << "No" << endl;
			return 0;
		}
		q = x;
		if(p == x) q = y;
		
		a[p]--, a[q]++;
		ans += "ABC"[q];
	}
	
	cout << "Yes" << endl;
	for(int i = 0; i < ans.size(); i++) cout << ans[i] << endl;
	
	return 0;
}

Measured memory_bytes: 6916
#include <iostream>
#include <string.h>
using namespace std;

int main(){
    string s;
    int ans = 0;
    cin >> s;
    for(int i = 0; i  < s.length(); i++) if(s[i] == 'p') ans++;
    if(s.length() % 2 == 0) cout << (s.length() / 2) - ans;
    else cout << (s.length() - 1) / 2 - ans;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<map>
using namespace std;
int N;
vector<int>G[1<<17];
map<long,int>M;
long B1=1000000181,B2=1000999943;
long ans;
long dfs(int u,int p)
{
	long ret=0;
	for(int v:G[u])
	{
		if(v!=p)
		{
			ret+=dfs(v,u);
		}
	}
	ret=(ret*B1+1)%B2;
	ans+=M[ret]++;
	return ret;
}
main()
{
	cin>>N;
	for(int i=1;i<N;i++)
	{
		int u,v;cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1,0);
	cout<<ans<<endl;
}



Measured memory_bytes: 21852
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;


LL mem[2001][2001];
LL N;
vector<P> ps;
LL f(LL p, LL q)
{
	if(mem[p][q]>=0){
		return mem[p][q];
	}
	if(p+q==N){
		return mem[p][q]=0;
	}
	LL v=ps[p+q].first;
	LL i=ps[p+q].second;
	return mem[p][q]=max(f(p+1,q)+abs(p-i)*v,f(p,q+1)+abs(N-1-q-i)*v);
}
void solve(std::vector<long long> A){
	for(int i=0;i<N;i++){
		ps.push_back(P(A[i],i));
	}
	sort(ps.rbegin(),ps.rend());
	cout << f(0,0) << endl;

}

int main(){
	memset(mem,-1,sizeof(mem));
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(std::move(A));
    return 0;
}


Measured memory_bytes: 34700
#include<bits/stdc++.h>
using namespace std;
 
void print_vec(vector<int> B)
{
 
	for(int i =0;i<B.size();i++)
	{
		cout<<B[i]<<" ";
	}
	cout<<endl;
}

void print_vec_vec_bool(vector<vector<bool>> A)
{
	for(int i = 0 ; i < A.size() ; i++)
	{
		for(int j = 0 ; j < A[i].size() ; j++)
		{
			cout<<A[i][j]<<" ";
		}
		cout<<endl;
	}
	cout<<endl;
}

bool compare(string A1,string A2)
{
  if( A1[1] == '=' && A2[1] == '!')
  {
    return (A1<(A2));
  }
  return (A2 < A1);
}

void print_vec_string(vector<string> A)
{
	for(int i = 0 ; i <A.size() ;i++)
	{
		cout<<A[i]<<" ";
	}
	cout<<endl;
}
 
void print_multiset(multiset<pair<int,pair<int,int>>> s)
{
	auto itr = s.begin();
	while(itr != s.end())
	{
		pair<int,pair<int,int>> p = *itr;
		cout<<"(("<<p.first<<"),("<<p.second.first<<","<<p.second.second<<") ";
		itr++;
	}
	cout<<endl;
}

bool check_1(int x,vector<int> &connection_1, vector<vector<bool>> &adj)
{
  for(int i = 0 ; i < connection_1.size() ; i++)
  {
    if(adj[x][connection_1[i]] == true)
    {
      return false;
    }
  }
  return true;
}

bool check_2(int x,vector<int> &connection_2, vector<vector<bool>> &adj)
{
  for(int i = 0 ; i < connection_2.size() ; i++)
  {
    if(adj[x][connection_2[i]] == true)
    {
      return false;
    }
  }
  return true;
}

int main()
{
	int n ;
	cin>>n;
	vector<long long> A(n);
	for(int i = 0 ; i < n ;i++)
	{
		cin>>A[i];
	}
	vector<int> count(n);
	count[0] = 0;
	for(int i= 1; i < n ; i++)
	{
		if(A[i] > A[i-1])
		{
			count[i] = 0;
		}
		else
		{
			count[i] = (count[i-1]+1);
		}
	}
	int ans = 0;
	for(int i = 1 ; i < n ; i++)
	{
		ans = max(ans, count[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define INTMAX  99999999

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

#define MAX_N 100000

int N;
int A[MAX_N+5];
int Win[MAX_N+5];
// int Parent[MAX_N+5];
vector<int>   Children[MAX_N+5];
int Depth[MAX_N+5];
// int parent[MAX_N+5];

struct CompChild
{
	bool operator()(const int &lhs, const int &rhs) const
	{
		return Depth[lhs] > Depth[rhs];
	}
} CompObject;

void dfs(int n)
{
	// int child_depth = 0;
	vector<int>::iterator it_child;
	for(it_child=Children[n].begin();it_child!=Children[n].end();it_child++) {
		// DOUT << "> Win["<<n<<"]="<<Win[n]<<", Win["<<*it_child<<"]="<<Win[*it_child]<<endl;
		dfs(*it_child);
		// DOUT << "* Win["<<n<<"]="<<Win[n]<<endl;
	}
	int i=1;
	int d = 0;
    sort(Children[n].begin(), Children[n].end(), CompObject);
	for(it_child=Children[n].begin();it_child!=Children[n].end();it_child++, i++) {
		// DOUT << n <<"> Depth["<<*it_child<<"](="<<Depth[*it_child]<<") + i(="<<i<<") = "<< Depth[*it_child]+i<<endl;
		d = max(d, Depth[*it_child]+i);
	}
	// Win[n] = max(Win[n], child_depth);
	// Win[n] = child_depth;
	// DOUT << "Win["<<n<<"]="<<Win[n]<<endl;
	Depth[n] = d;
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> N;
	FORULE(n,1,N) {
		Win[n] = 0;
	}
	FORULE(n,2,N) {
		cin >> A[n];
		Win[A[n]] += 1;
		// DOUT << "Win[A["<<n<<"](="<<A[n]<<")]="<<Win[A[n]]<<endl;
		Children[A[n]].push_back(n);
	}
	dfs(1);

	// int depth = Win[1];
	// DOUT << "Win[1]="<<Win[1]<< endl;

	cout << Depth[1] << endl;

	return 0;
}



Measured memory_bytes: 14720
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

int A,B;
inline void solve(){
  IN2(A,B);
  OUT((A+B)%24);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void co(void){cout << '\n';}
template <typename T>
void co(const T n){cout << n << '\n';}
template <typename T1, typename T2>
void co(pair<T1, T2> p){cout << p.fs << ' ' << p.sc << '\n';}
template <typename T>
void co(const Vec1<T> &v){for(T i : v) cosp(i); co();}
template <typename T>
void co(initializer_list<T> v){for(T i : v) cosp(i); co();}
template <typename T>
void ce(const T n){cerr << n << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18+1;
constexpr ll MOD = 1e9+7;
//constexpr ll MOD = 998244353;
constexpr ld EPS = 1e-11;
const ld PI = acos(-1);

Vec2<P> graph;

int main(void){
	ll n, m, s;
	cin >> n >> m >> s;
	graph.resize(n);
	Vec a(m), b(m);
	rep(i, m){
		ll u, v;
		cin >> u >> v >> a[i] >> b[i];
		u--, v--;
		graph[u].pb({v, i});
		graph[v].pb({u, i});
	}
	Vec c(n), d(n);
	rep(i, n) cin >> c[i] >> d[i];

	Vec2<ll> dist(n, Vec(2500, LINF));
	using PP = pair<ll, P>;
	priority_queue<PP, vector<PP>, greater<> > pq;
	pq.push({0, {s, 0}});
	while(!pq.empty()){
		auto p = pq.top(); pq.pop();
		ll x = p.fs, y = p.sc.fs, z = p.sc.sc;
		//co({x, y, z});
		chmin(y, 2499LL);
		if(!chmin(dist[z][y], x)) continue;
		pq.push({x + d[z], {y + c[z], z}});
		for(P i : graph[z]){
			if(y >= a[i.sc]) pq.push({x + b[i.sc], {y - a[i.sc], i.fs}});
		}
	}

	Vec ans(n, LINF);
	rep(i, n) rep(j, 2500) chmin(ans[i], dist[i][j]);
	REP(i, 1, n) co(ans[i]);

	return 0;
}


Measured memory_bytes: 10532
#include <stdio.h>
int main(){
    int a, b, c, i, ans;
    scanf("%d %d %d", &a, &b, &c);
    for (i = a; i <= b; i++){
        if(c % i == 0){
            ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 596
#include<stdio.h>

int main(){
	//nを入力
	int n;
	scanf("%d", &n);
	//計算と表示
	int cnt = 0;
	if(n >= 10){
		cnt = 9;
		if(n >= 1000){
			cnt += 900;
			if(n>= 100000){
				cnt += 90000;
			}else if(n >= 10000){
				cnt += n - 9999;
			}
		}else if( n >= 100){
			cnt += n - 99;
		}
	}else{
		cnt += n;
	}

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

	return 0;
}

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

using namespace std;
#define intMax 2147483647
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repp(i, a, b) for (int i = a; i >= b; i--)
#define be(a) (a.begin(), a.end())
#define rbe(p) (p.rbegin(), p.rend())
#define pb push_back
vector<vector<char>> A;
set<pair<int, int>> Vis;
int ans = -intMax, maxi = -intMax;
void bfs(int a, int b, int aa, int bb)
{
    queue<pair<pair<int, int>, int>> B;
    B.push({{a, b}, 0});
    while (!B.empty())
    {
        a = B.front().first.first;
        b = B.front().first.second;
        int k = B.front().second;
        // cout << a <<"  "<< b << endl;
        if (a == aa && b == bb)
        {
            maxi = k;
            break;
        }
        Vis.insert({a, b});
        B.pop();
        if (A[a + 1][b] == '.' && !Vis.count({a + 1, b}))
        {
            B.push({{a + 1, b}, k + 1});
            Vis.insert({a+1, b});
        }
        if (A[a - 1][b] == '.' && !Vis.count({a - 1, b}))
        {
            B.push({{a - 1, b}, k + 1});
            Vis.insert({a-1, b});
        }
        if (A[a][b + 1] == '.' && !Vis.count({a, b + 1}))
        {
            B.push({{a, b + 1}, k + 1});
            Vis.insert({a, b+1});
        }
        if (A[a][b - 1] == '.' && !Vis.count({a, b - 1}))
        {
            B.push({{a, b - 1}, k + 1});
            Vis.insert({a, b-1});
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int l = 0;
    int n, m;
    cin >> n >> m;
    A.resize(n + 2, vector<char>(m + 2, '#'));
    rep(i, 1, n + 1)
    {
        rep(j, 1, m + 1)
        {
            cin >> A[i][j];
            if ( A[i][j] == '.' ){
                l++;
            }
        }
    }
    if ( l == n*m ){
        cout << n + m - 2;
        return 0;
    }
    rep(i, 1, n + 1)
    {
        rep(j, 1, m + 1)
        {
            if (A[i][j] != '.')
            {
                continue;
            }
            rep(ii, 1, n + 1)
            {
                rep(jj, 1, m + 1)
                {
                    if (A[ii][jj] != '.')
                    {
                        continue;
                    }
                    //cout << i << " " << j << " " << ii << " " << jj << endl;
                    maxi = -intMax;
                    bfs(i, j, ii, jj);
                    ans = max(ans, maxi);
                    Vis.clear();
                }
            }
        }
    }
    cout << ans;
}
/*
20 20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
*/

Measured memory_bytes: 256
s = input()
s = s.split('/')

for i in range(len(s)):
	s[i] = int(s[i])

if s[0] >= 2019:
	if s[1] >= 5:
		print('TBD')
		exit()
	else:
		print('Heisei')
		exit()
else:
	print('Heisei')
	exit()

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

/*
fukuzawaがa枚, higuchiがb枚, noguchiがc枚あるとして、制約よりn = a + b + c
for分を三重にせずともcはc = n - a - bで求まるので、二重で済む。
これにより最悪計算量が8,000,000,000から4,000,000に減る。
1秒間で処理できるforループの回数は10^8 = 100,000,000回程度。三重では2秒間に収まらない。
*/

int main() {
  int n, y;
  cin >> n >> y;
  
  int fukuzawa = -1, higuchi = -1, noguchi = -1;
  for (int i = 0; i <= n; i++) {  // n = a
    for (int j = 0; (i + j) <= n; j++) {  // n = a + b
      int k = n - i - j;  // n = a + b + c
      int total = (10000 * i) + (5000 * j) + (1000 * k);
      if (total == y) {
        fukuzawa = i;
        higuchi = j;
        noguchi = k;
      }
    }
  }
  
  cout << fukuzawa << " " << higuchi << " " << noguchi << endl;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        Regex reg = new Regex("[ATCG]*");

        var S = Console.ReadLine();

        var max = 0;

        foreach(Match match in reg.Matches(S))
        {
            max = Math.Max(max, match.Length);
        }

        Console.WriteLine(max);
    }
}


Measured memory_bytes: 15692
import sys
sys.setrecursionlimit(10**7)
S = input()
T = input()

dp = [[0] * (len(T) + 1) for _ in range(len(S) + 1)]
for i in range(1, len(S) + 1):
    for j in range(1, len(T) + 1):
        indicator = 1 if S[i - 1] == T[j - 1] else 0
        dp[i][j] = max(dp[i - 1][j - 1] + indicator, dp[i - 1][j], dp[i][j - 1])

ans = ''


def print_lcs(s, t, dp_table, i, j):
    global ans
    if i == 0 or j == 0:
        return
    if S[i - 1] == T[j - 1]:
        print_lcs(s, t, dp, i - 1, j - 1)
        ans += S[i - 1]
    else:
        if dp[i - 1][j] >= dp[i][j - 1]:
            print_lcs(S, T, dp, i - 1, j)
        else:
            print_lcs(S, T, dp, i, j - 1)


print_lcs(S, T, dp, len(S), len(T))
print(ans)


Measured memory_bytes: 116828
N, M = map(int, input().split())

H = list(map(int, input().split()))

better = [[] for _ in H]

for _ in range(M):
  A, B = map(int, input().split())
  A -= 1
  B -= 1
  if H[A] >= H[B]:
    better[B].append(A)
  if H[A] <= H[B]:
    better[A].append(B)
print(sum([1 for b in better if not b]))

Measured memory_bytes: 25452
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Scanner;
import java.util.HashSet;
import java.util.Iterator;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n - 1];
        for (int i = 0; i < n - 1; i++) {
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            a[i] = Math.min(b[Math.min(Math.max(i - 1, 0),n-2)], b[Math.min(Math.max(i, 0),n-2)]);
        }
        // a[n-2]=Math.min(b[n-2],b[n-3]);
        // a[n-1]=b[n-2];
        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans += a[i];
        }
        // System.out.println(Arrays.toString(b));
        // System.out.println(Arrays.toString(a));
        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <string.h>
#define MAX 100
int main(){
	int i,j;
	char flag='N';
	char s[2*MAX+1],p[MAX+1];
	gets(s);
	gets(p);
	sprintf(s,"%s%s", s, s);
//	strcat(s,s);
/*	for(i=0; s[i] != '\n'; i++){
		if(p[0]==s[i]){
			for(j=0; p[j]==s[i+j]; j++){
				if(p[j+1] == '\0'){flag = 'Y';}
			}
		}
	}

	if(flag == 'Y'){printf("Yes\n");}
	else if(flag == 'N' ){printf("No\n");}
*/
	if(strstr(s,p) != '\0'){printf("Yes\n");}
	else{printf("No\n");}

	return 0;
}

Measured memory_bytes: 532
def main():
    _, n_teleport = map(int, input().split())
    towns = [0] + list(map(int, input().split()))

    visited_list = []
    visited_set = set()

    next_town = 1
    while 1:
        if next_town in visited_set:
            loop_start_at = visited_list.index(next_town)
            loop_length = len(visited_list) - loop_start_at
            break

        visited_list.append(next_town)
        visited_set.add(next_town)
        next_town = towns[next_town]

    if n_teleport < loop_start_at:
        end_point = n_teleport
    else:
        end_point = loop_start_at + (n_teleport - loop_start_at) % loop_length

    print(visited_list[end_point])


if __name__ == "__main__":
    main()


Measured memory_bytes: 32376
void main() {
  problem();
}

void problem() {
  auto N = scan!long, M = scan!long;

  long solve() {
    long answer;
    if (N > 0) answer += N*(N-1)/2;
    if (M > 0) answer += M*(M-1)/2;
    return answer;
  }

  solve().writeln;
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

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

    int ans = 0;
    int at = 0;
    for(int i = n-2; i >= 0; i--) {
        if(arr[i] >= arr[i+1]) at++;
        else {
            ans = max(ans, at);
            at = 0;
        }
    }
    ans = max(ans, at);
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;
void solve(){
  string w; cin >> w;
  map<char, int> mp;
  for(int i = 0; i < w.size(); i++){
    mp[w[i]]++;
  }
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    if(itr->second % 2 != 0){
      cout << "No\n";
      return;
    }
  }
  cout << "Yes\n";
  return;
}
 
int main(){
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
// 125

using namespace std;

string str;

inline char ask(int pos) {
    cout << pos << "\n";
    cin >> str;
    if(str[0] == 'M')
        return 0;
    if(str[0] == 'F')
        return 1;
    exit(0);
}

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int n;
    ios::sync_with_stdio(false);
    cin >> n;
    char type = ask(0);
    int rez = 0;
    for(int pas = 1 << 15; pas; pas >>= 1) {
        if(2 * (rez + pas) < n) {
            char cur = ask(2 * (rez + pas));
            if(cur == type)
                rez += pas;
        }
    }
    ask(2 * rez + 1);
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 852
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    int N;
    cin >> N;
    bool b = true;
    for(int i = 0; i < N; i++){
        ll tmp;
        cin >> tmp;
        if(tmp % 2 == 0 &&!(tmp % 3 == 0 || tmp % 5 == 0)){
            b = false;
        }
    }
    if(b){
        cout << "APPROVED" << endl;
    }else{
        cout << "DENIED" << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define endl ("\n")

using ll = long long;
using ld = long double;
const ll M = 1000000007;
const ld pi = 3.14159265358979323846;

long long mod(long long x)
{
    return ((x%M + M)%M);
}

long long add(long long a, long long b)
{
    return mod(mod(a)+mod(b));
}

long long mul(long long a, long long b)
{
    return mod(mod(a)*mod(b));
}

void solve();

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

	int tt = 1;
	// cin >> tt;
	for(int test_case = 1; test_case <= tt; test_case++)
	{
		//cout << "Case #" << test_case << ": ";
		solve();
	}
	return 0;
}

void solve()
{			
	int a, b;
	int ans = 0;
	cin >> a >> b;
	if(a >= b)	
	{
		ans += a;
		a--;
	}
	else
	{
		ans += b;
		b--;
	}
	if(a >= b)
		ans += a;
	else
		ans += b;
	cout << ans << endl;
}

Measured memory_bytes: 3588