akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

void mex(ll i,vector<ll>&ans,vector<vector<ll>>&G,set<ll>base){
  for(auto u:G[i]){
    base.erase(ans[u]);
  }
  ans[i]=*base.begin();
}

bool solve(){
  ll n,K;cin>>n>>K;
  vector<vector<ll>>G(K+1);
  vector<ll>a(n);
  rep(i,n)cin>>a[i];

  set<ll>base;
  rep(i,120)base.insert(i);

  rep(i,n)rep(j,K+1){
    if(j+a[i]<=K)G[j+a[i]].push_back(j);
  }

  vector<ll>ans(K+1,-1);
  rep(i,K+1){
    mex(i,ans,G,base);
  }

  cout<<(ans[K]!=0 ? "First" : "Second")<<endl;

  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 105472
mod = 1000000007

pow3 = [1] * 100001
for i in range(1, 100001):
    pow3[i] = pow3[i - 1] * 3 % mod

s = input()

all_a = 0
all_c = 0
all_q = 0
for c in s:
    if c == 'A':
        all_a += 1
    elif c == 'C':
        all_c += 1
    elif c == '?':
        all_q += 1
sum_a = 0
sum_c = 0
sum_q = 0
ans = 0

for c in s:
    n = 0
    if c == 'B':
        n += sum_a * (all_c - sum_c) * pow3[all_q] % mod
        n += sum_a * (all_q - sum_q) * pow3[all_q - 1] % mod
        n += sum_q * (all_c - sum_c) * pow3[all_q - 1] % mod
        n += sum_q * (all_q - sum_q) * pow3[all_q - 2] % mod
    elif c == '?':
        n += sum_a * (all_c - sum_c) * pow3[all_q - 1] % mod
        n += sum_a * (all_q - sum_q - 1) * pow3[all_q - 2] % mod
        n += sum_q * (all_c - sum_c) * pow3[all_q - 2] % mod
        n += sum_q * (all_q - sum_q - 1) * pow3[all_q - 3] % mod
    ans += n % mod
    if c == 'A':
        sum_a += 1
    elif c == 'C':
        sum_c += 1
    elif c == '?':
        sum_q += 1
print(int(ans % mod))


Measured memory_bytes: 7156
<?php
fscanf(STDIN, "%d%d", $n, $k);
$a = array_map("intval", explode(" ", fgets(STDIN)));
$p = -10**10;
$sum = 0;
foreach($a as $b){
    $sum+=$k;
    $sum -= max(0, $k - ($b - $p));
    $p = $b;
}
echo $sum,"\n";

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int n;
  cin >> n;
  int sum = 0;
  rep(i, 0, n) {
    int a;
    cin >> a;
    sum += --a;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
from sys import stdin

N = int(stdin.readline().rstrip())

XL = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(N)]
R = []
for i in range(N):
    R.append([XL[i][0] - XL[i][1], XL[i][0] + XL[i][1]])
R.sort(key=lambda x:x[1])
ans = [R[0]]

for i in range(1, N):
    if R[i][0] >= ans[-1][1]:
        ans.append(R[i])

print(len(ans))


Measured memory_bytes: 75484
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
char s[N];
bool a[N];
int n;

int main() {	
	scanf("%d%s",&n,s);
	for(int i = 0; i < 4; ++i) {
		a[0] = i&1, a[1] = (i&2)>>1;
		for(int j = 2; j < n; ++j) {
			a[j] = a[j-2];
			if(a[j-1] ^ (s[j-1] == 'x')) a[j] ^= 1;
		}
		if((a[1] == a[n-1]) != ((s[0] == 'o')^a[0])) continue;
		if((a[0] == a[n-2]) != ((s[n-1] == 'o')^a[n-1])) continue;
		for(int i = 0; i < n; ++i) {
			if(a[i]) printf("W");
			else printf("S");
		}
		printf("\n");
		return 0;
	}
	printf("-1\n");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;
/*
ordered_set(both these operations in log)
1. find_by_order : it returns iterator to the ith largest element.
2. order_of_key  : The number of items in a set that are strictly smaller than k.
*/

//memset(dp,-1,sizeof(dp));
//fill(v.begin(), v.end(), -1);
//priority_queue< pii, vector <pii> , greater<pii>> pq;
//vector<int> dist(V, INF);


#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define lb lower_bound
#define ub upper_bound

#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define pii                 pair<int,int>
#define vi                  vector<int>
#define vii                 vector<pii>
#define mi                  map<int,int>
#define mii                 map<pii,int>
#define all(a)              (a).begin(),(a).end()
#define fi                  first
#define se                  second
#define sz(x)               (int)x.size()
#define endl                '\n'
#define md                  1000000007
#define rep(i,a,b)          for(int i=a;i<b;i++)
#define pcout(x)	          cout<<fixed<<setprecision(x)
#define debug(x)            cout<<#x<<"::"<<x<<endl;
#define debug2(x,y)         cout<<#x<<"::"<<x<<"\t"<<#y<<"::"<<y<<endl;
#define boost               ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)



typedef long long ll;
typedef double ld;

inline ll prodm(ll a,ll b)  {return ((a%md)*(b%md))%md;}
inline ll summ(ll a,ll b)   {return ((a%md)+(b%md))%md;}
inline bool ispow2(ll x)    {return  x && (!(x&(x-1)));}

const int N = 1e5 + 5;
const ll  infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;

/**************************BounceBackBolt*********************************/
ll fastexpo(ll n,ll pwr)
{
  if(pwr==0)
    return 1;
  if(pwr==1)
    return n;
  ll ans=fastexpo(n,pwr/2);
  ans=prodm(ans,ans);
  if(pwr&1)
  {
      ans=prodm(ans,n);
  }
    return ans;
}

ll modInverse(ll base)
{return fastexpo(base,md-2);}


vector < int > g[N];
int d[N];
void dfs(int v, int p, int dd){
    d[v] = dd;
    for(int to : g[v]){
        if(to == p) continue;
        dfs(to, v, dd + 1);
    }
}

/*********************************************************************/
int main()
{
  boost;
  int T;
  T=1;
  while(T--)
  {
    int n;
    cin>>n;
    ll i,j,k;
    ll ans=0;
    for(i=1;i<=n;i++)
    {
      for(j=1;j<=n;j++)
      {
        for(k=1;k<=n;k++)
        {
          ans+= __gcd(__gcd(i,j),k);
        }
      }
    }
    cout<<ans;


  }
  return 0;
}


Measured memory_bytes: 6004
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;


const long long int mod = 998244353;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
const long long int pl=1000000;

char ch;

int main(){

    cout << fixed << setprecision(18);
    cin>>ch;
    if('A'<=ch&&ch<='Z'){
        cout<<'A'<<endl;
    }else{
        cout<<'a'<<endl;
    }
}




Measured memory_bytes: 3568
'''
ITP-1_5-A
 ????????¢?????????
??????H cm ?????? W cm ???????????¢?????????????????°?????????????????????????????????
1 cm ?? 1cm ???????????¢??? '#'??§??¨????????????
???Input
??\???????????°????????????????????????????§???????????????????????????????????????????????????¢????????\????????¨????????§??????
H W
H, W ?????¨?????? 0 ?????¨????????\?????????????????¨????????????
???Output
????????????????????????????????????H ?? W ?????? '#' ??§????????????????????¢???????????????????????????
?????????????????????????????????????????????????????\??????????????????
'''
# import
import sys

for line in sys.stdin:
    # ?????°??????????????????
    H, W = map(int, line.split())
    if H == 0 and W == 0:
        break
    # ?????¢??????
    print(('#' * W + '\n') * H)

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 11111

const int INF = 1 << 29 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
    ios::sync_with_stdio(0) ;

    ll L[100] ,n ;
    cin >> n ;
    L[0] = 2LL , L[1] = 1LL ;

    for(int i = 2 ;i<=n ;i++) 
        L[i] = L[i-1] + L[i-2] ;
    cout << L[n] << endl ;
    
    return 0 ;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N; cin>>N;
  int score=0;
  int min_score=10000;
  for(int i=0;i<N;i++){
    int s; cin>>s;
    score+=s;
    if(s%10!=0) min_score=min(min_score,s);
  }
  if(score%10==0)
    score-=min_score;
  if(score<0) score=0;
  cout<<score<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


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

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::string s, t, u;

  std::cin >> s >> t >> u;

  std::cout << s[0] << t[0] << u[0] << std::endl;

  return 0;
}


Measured memory_bytes: 256
#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)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    int n;
    cin >> n;
    string s[n];
    REP(i, n) cin >> s[i];

    map<string, int> mp;
    int maxCount = 0;
    REP(i, n) {
        mp[s[i]]++;
        maxCount = max(maxCount, mp[s[i]]);
    }
    vector<string> v;
    for(auto a: mp) {
        if(a.second == maxCount) v.push_back(a.first);
    }
    sort(v.begin(), v.end());
    for(auto a: v) cout << a << endl;



    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int a,b,c,d;
    cin>>a>>b>>c>>d;
    long long int ans1=a*c;
    long long int ans2=a*d;
    long long int ans3=b*c;
    long long int ans4=b*d;
    long long int ans=max(max(ans1,ans2),max(ans3,ans4));
    if((a<=0LL and 0LL<=b) or (c<=0LL and 0LL<=d)) cout<<max(ans,0LL)<<"\n";
    else cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/arc103_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  unordered_map<int, int> even;
  unordered_map<int, int> odd;

  rep(i, N) {
    int c;
    cin >> c;
    if (i % 2 == 0)
      even[c]++;
    else
      odd[c]++;
  }

  priority_queue<P> evenQue;
  priority_queue<P> oddQue;

  for (auto kv : even) {
    evenQue.push({kv.second, kv.first});
  }
  for (auto kv : odd) {
    oddQue.push({kv.second, kv.first});
  }
  evenQue.push({0, -1});
  oddQue.push({0, -1});

  P maxE = evenQue.top();
  evenQue.pop();
  P maxO = oddQue.top();
  oddQue.pop();

  int ans;

  if (maxE.second != maxO.second) {
    ans = (N / 2) - maxO.first + ceil((float)N / 2) - maxE.first;
  } else {
    P nextE = evenQue.top();
    P nextO = oddQue.top();
    if (nextE.first > nextO.first) {
      ans = (N / 2) - maxO.first + ceil((float)N / 2) - nextE.first;
    } else {
      ans = (N / 2) - nextO.first + ceil((float)N / 2) - maxE.first;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 8312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
auto chmin = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto chmax = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
ll N, K;
ll a[200000];
ll ans = 0;
ll sum[200500];
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 1; i <= N; i++) {
        sum[i] = sum[i-1] + a[i-1];
    }
    for(int i = 0; i + K <= N; i++) {
        chmax(ans, sum[i+K] - sum[i]);
    }
    ans += K;
    cout << fixed << setprecision(20) << ans / 2.0;
    return 0;
}

Measured memory_bytes: 6876
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
const int maxn = 2e5 + 5;
const int mod = 998244353;
vector<pii> a;
ll dp[maxn];
int n , k;
int lowbit (int x) {return x & -x;}
void add (int x , ll c){
    c = (c%mod + mod) % mod;
    while (x <= n){
        dp[x] = (dp[x] + c) % mod;
        x += lowbit(x);
    }
}
ll ask (int x){
    ll ans = 0;
    while (x){
        ans = (ans + dp[x]) % mod;
        x -= lowbit(x);
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for (int i = 1 ; i <= k ; i++){
        int x , y; cin >> x >> y;
        a.push_back(make_pair(x , y));
    }
    add(1 , 1);
    add(2 , -1);
    for (int i = 1 ; i <= n ; i++){
        for (auto p : a){
            if (i + p.first > n) continue;
            int l = min (i + p.first , n);
            int r = min (i + p.second , n);
            ll d = ask(i);
            add(l , d); add(r + 1 , -d);
       //     cout << i << " " << l << " " << r << " " << d << endl;
        }
    }
    cout << ask(n) << endl;
    return 0;
}


Measured memory_bytes: 5212
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,vector<ll> > P;
typedef pair<P,ll>Q;
 

 
int main(void){
    int a,p;
    cin>>a>>p;
    cout<<(3*a+p)/2<<endl;
  return 0;
}

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

using namespace std;

using ll = long long;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int max_ac = max(a, c);
    int min_bd = min(b, d);

    if (min_bd <= max_ac) cout << "0\n";
    else cout << min_bd - max_ac << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio> 
#include <cstdlib> 
#include <cmath> 
#include <cstring> 
#include <climits> 
#include <cfloat> 
#include <map> 
#include <utility> 
#include <set> 
#include <iostream> 
#include <memory> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <functional> 
#include <sstream> 
#include <complex> 
#include <stack> 
#include <queue> 
#include <numeric>
#include <cassert>

#define FOR(i, min, max) for (int i = (min); i < (max); ++i) 
#define FORE(i, min, max) for (int i = (min); i <= (max); ++i) 
#define REP(i, n) for (int i = 0; i < (n); ++i) 
#define REPV(vec, i) for (int i = 0; i < (int)(vec.size()); ++i) 
#define FOR_EACH(vec, it) for (typeof((vec).begin()) it = (vec).begin(); it != (vec).end(); ++it)

using namespace std; 
static const double EPS = 1e-12; 
typedef long long ll; 

template<typename T>
vector<T> getVector(int N) {
    vector<T> v(N);
    REP(i, N) cin >> v[i];
    return v;
}

int main(void)
{
    string s;
    cin >> s;
    int N = s.size();
    reverse(s.begin(), s.end());
    vector<int> w(N+1);
    
    int n = 1;
    int c = 0;
    w[0] = 0;
    REP(i, N) {
        int d = (s[i]-'0');
        c = (d*n + c) % 2019;
        w[i+1] = c;
        n = (n*10)%2019;
    }
    map<int, int> w2;
    int ret = 0;
    REP(i, N+1) {
        ret += w2[w[i]];
        w2[w[i]]++;
    }
    cout << ret << endl;
    
    return 0;
}


Measured memory_bytes: 4360
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	rep(ki, k){
		vector<ll> b(n+1);
		rep(i,n){
			ll l = max(ll(0), i-a[i]);
			ll r = min(n, i+a[i]+1);
			b[l]++;
			b[r]--;
		}
		rep(i,n) b[i+1]+=b[i];
		b.pop_back();
		if(a == b) break;
		a = b;
	}
	rep(i,n-1) cout << a[i] << " ";
	cout << a[n-1] << endl;
 	return 0;
}

Measured memory_bytes: 6424
#include<stdio.h>
int main(void)
{
	int n, h, m, s;
	scanf("%d", &n);
	h = n / 3600;
	m = (n - h * 3600) / 60;
	s = n - (h * 3600)- (m * 60);
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}


Measured memory_bytes: 2756
#include<bits/stdc++.h>
using namespace std;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int N = 1e6;
const int inf = 1e9;

int main(){
	ios_base::sync_with_stdio(0);
	int a,b,n,k,T,cas=0;
	cin>>n>>k;
	vector<int> A(n);
	for(int &x: A) {
		cin>>x;
	}
	vector<int> dp(n, inf);
	dp[0]=0;
	for(int i=0;i<n;++i) {
		for(int j=i+1, cnt=1;j<n && cnt<=k;++j,++cnt) {
			dp[j] = min(dp[j], dp[i] + abs(A[j]-A[i]));
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
G = [[] for i in range(n)] #G(i): 頂点iと隣接する頂点のlist
for i in range(n):
    a = [int(i) for i in input().split()]
    G[a[0]-1] = [i-1 for i in a[2:]]

d = [-1] * n
todo = [0]
d[0] = 0

while(todo != []):
    v = todo.pop(0)
    for i in G[v]:
        if d[i] == -1:
            d[i] = d[v]+1
            todo.append(i)

for i in range(n):
    print(i+1, d[i])


Measured memory_bytes: 5628
"use strict";
function Main(input) {
    let nums = input.split(/\s/).map((v) => v - 0);
    let a = nums[0];
    let b = nums[1];

    let ans = (b % a == 0) ? a + b : b - a;
    console.log(ans);
}

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


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    REP(i, N) cin >> A[i];
    sort(A.begin(), A.end(), greater<long long>());
    long long ans = A[0];
    int pos = 1;
    for(int i=0; i<N-2; i++){
        ans += A[pos];
        if(i%2) pos++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4840
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ab = Console.ReadLine().Split(" ");
            string a = ab[0];
            string b = ab[1];
            string A = "";
            string B = "";
            for(int i = 0; i < int.Parse(b); i++)
            {
                A += a;
            }
            for(int i = 0; i < int.Parse(a); i++)
            {
                B += b;
            }
            string[] titles = new string[] { A, B };
            Array.Sort(titles);
            Console.WriteLine(titles[0]);
        }
    }
}
//int[] N = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();

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

using namespace std;

typedef long long ll;

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

int main(void){
    
    string S;
    cin >> S;
    
    ll size = S.size();
    ll sum = 0;
    if (size == 1){
        cout << S << endl;
        return 0;
      }
    for(ll bit = 0;bit < ( 1 << (size - 1) );bit++){

        //cout << "chiba" << endl;
        ll now = S[0] - '0';
        rep(i,size - 1){
            //cout << "(" << bit << ")" << endl;
            //cout << (i+1) * (bit+1) << endl;
            if (bit & (1<<i)){
                //cout << "Pre:" << now << endl;
                sum += now;
                now = S[i + 1] - '0';
                //cout << "Now:" << now << endl;
                if (i == size - 2) sum += now;
            }else {
                now *= 10;
                now += S[i + 1] - '0';
                if (i == size - 2) {
                    //cout << "Pre:" << now << endl;
                    sum += now;
                    //now = S[i + 1] - '0';
                    //cout << "Now:" << now << endl;
                }
            }
        }

        //cout << sum << endl;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n = II()
    ans = n * 800
    print(ans-(n//15)*200)
    return

#B
def B():
    k = II()
    a = k // 2
    b = (k + 1) // 2
    print(a*b)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 5092
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

int main() {
    ll n,k;
    cin >> n >> k;
    n=n%k;
    cout << min(k-n,n) << endl;
}


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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T>
constexpr T INF = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()

template<typename T, typename U> istream& operator>>(istream& in, pair<T, U>& a) { cin >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& in, vector<T>& a) { for (T& x : a) cin >> x; }

void LOG(const int& x) { cerr << x << "\n"; }
void LOG(const vector<int>& a) { for (int x : a) cerr << x << " "; cerr << "\n"; }

int ceil(int a, int b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

class UnionFind { private: vector<int> par; vector<int> rnk; int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); } public: UnionFind(int size) { par.resize(size); rnk.resize(size); REP(i, size) par[i] = i, rnk[i] = 0; } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if (rnk[x] < rnk[y]) { par[x] = y; } else { par[y] = x; if (rnk[x] == rnk[y]) rnk[x]++; } } bool same(int x, int y) { return find(x) == find(y); } };

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

signed main() {
  string s;
  cin >> s;
  int c = 0;
  REP(i, s.size() - 1) {
    c += s[i] != s[i + 1];
  }
  cout << c << endl;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

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

const int N = 1e5+23;

int h[N];
pair<int, int> a[N];

void solve() {
  int n, m; scanf("%d%d", &n, &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &a[i].second, &a[i].first);
    ++h[a[i].second];
  }
  for (int i = 1; i <= n; ++i) {
    h[i] += h[i-1];
  }
  sort(a, a+m);
  int prev = 0, ans = 0;
  for (int i = 0; i < m; ++i) {
    if (h[a[i].first-1] == h[prev]) continue;
    if (a[i].second <= prev) continue;
    ++ans;
    prev = a[i].first-1;
  }
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 5024
/*
 * main.c
 *
 *  Created on: 2019/02/03
 *      Author: family
 */


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

int x_move[100002] = {0};
int distance[100002] = {0};

int compare_pos(const void* a, const void *b)
{
	//printf("a=%d b=%d\n", *(int*)a, *(int*)b);
	return (*(int*)b - *(int*)a);
}

void calc_dist(int m_place)
{
	int loop = 0;
	while((loop+1) < m_place) {
		//printf("x=%d y=%d\n",x_move[loop], x_move[loop+1]);
		distance[loop] = abs(x_move[loop] - x_move[loop+1]);
		loop++;
	}
	return ;
}

int get_sum(int n_koma, int m_place)
{
	int count = 0;
	int loop = 0;
	m_place -= 1;
	for (loop = (n_koma - 1); loop < m_place; loop++) {
		//printf("%d\n",distance[loop]);
        count += distance[loop];
	}
	return count;
}

int main()
{
    int n_koma, m_place;
    int loop = 0;
    int count = 0;

    scanf("%d %d", &n_koma, &m_place);
    for(loop = 0; loop < m_place; loop++) {
    	scanf("%d", &x_move[loop] );
    }

    if (n_koma >= m_place) {
    	printf("0\n");
    	return 0;
    }
    qsort(x_move, m_place, sizeof(int), compare_pos);
    calc_dist(m_place);
    qsort(distance, m_place - 1, sizeof(int), compare_pos);
    count = get_sum(n_koma, m_place);

    printf("%d\n",count);
	return 0;
}


Measured memory_bytes: 1268
#include<iostream>
using namespace std;
long long a, ans, c, b, d;
int main()
{
	scanf("%lld%lld.%lld", &a, &b, &c);
	d = b * 100 + c;
	ans = a * d / 100;
	printf("%lld\n", ans);
	return 0;
} 

Measured memory_bytes: 3812
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

long long power(long long x, long long n){
	long long ans = 1;
	for(;n;n>>=1,x*=x,ans%=MOD,x%=MOD)
		if(n&1)ans*=x;
	return ans%MOD;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	int ans = 0, temp = 1;
	vector<int> A;
	map<int,int> mp;
	
	cin>>N;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
	}
	
	for(int i = 0; i < N; i++){
		int a = A[i];
		
		for(int j = 2; j * j <= a; j++){
			int con = 0;
			
			while(a%j == 0){
				a /= j;
				con++;
			}
			
			if(con) {
				mp[j] = max(mp[j], con);
			}
			
		}
		if(a != 1) {
			mp[a] = max(mp[a], 1ll);
		}
	}
	
	for(pair<int,int> y : mp){
		for(int i = 0; i < y.second; i++){
			temp *= y.first;
			temp %= MOD;
		}
	}
	// cout<<temp<<endl;
	
	// temp *= N;
	// temp %= MOD;
	
	for(int i = 0; i < N; i++){
		ans += temp * power(A[i], MOD-2)%MOD;
		ans %= MOD;
	}
	
	cout<<ans<<endl;
	
	return 0;
}

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

const int N = 1e5 + 5;
const int mod = 1e9 + 7;

string s;
vector<int> v;
long long dp[N][2];
void f (){
    dp[0][1] = 1;
    for (int i = 0; i < v.size() - 1; ++i){
        for (int nxt = 0; nxt <= 1; ++nxt){
            for (int nxt1 = 0; nxt1 <= 1; ++nxt1){
                for (int j = 0; j <= 1; ++j){
                    if (nxt && nxt1) continue;
                    if (j && (nxt + nxt1) > v[i + 1]) break;
                    dp[i + 1][(j & (nxt + nxt1 == v[i + 1]))] += dp[i][j];
                    dp[i + 1][(j & (nxt + nxt1 == v[i + 1]))] %= mod;
                }
            }
        }
    }
    cout << (dp[(int)v.size() - 1][1] + dp[(int)v.size() - 1][0]) % mod << '\n';
}
int main(){


    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> s;
    v.push_back(0);
    for (int i = 0; i < s.size(); ++i) v.push_back(s[i] - '0');
    f ();

}


Measured memory_bytes: 2504
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

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

    string s;
    cin >> s;

    ll m = (s[5]-'0') *10 + (s[6]-'0');
    if(m <=4 ) cout << "Heisei" << endl;
    else cout << "TBD" << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
/**==Info==
*Program:2
*Problem:すぬけ君の地下鉄旅行 / Snuke's Subway Trip
*Date:2018-7-14
*Algorithm:Dsu
*Stats:WA*/

bool debug=false;

const int A=2e5+2;
const int B=2e6+2;

int n,m;
int dsu[B];
vector<pii> q[B];
int id[B];
bool use[B];

int stpos;

vector<int> nei[B];

int dis[B];

int getFa(int num){
	if(dsu[num]==num){
		return num;
	}
	return dsu[num]=getFa(dsu[num]);
}

void Unite(int a,int b){
	if(getFa(a)==getFa(b)){
		return;
	}
	dsu[getFa(a)]=getFa(b);
}

void initize(int a){
	dsu[a]=a;
}


void Add(int p){
	if(use[p]){
		return;
	}
	
	use[p]=true;
	int r=getFa(p);
	if(id[r]==-1){
		id[r]=stpos;
		stpos++;
	}
	
	nei[p].push_back(id[r]);
	nei[id[r]].push_back(p);
}

int main(int argc,char* argv[]){
	scanf("%d%d",&n,&m);
	
	for(int i=0;i<m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		a--;b--;c--;
		
		q[c].push_back(make_pair(a,b));
	}
	
	stpos=n;
	
	for(int i=0;i<B-1;i++){
		if(q[i].empty()){
			continue;
		}
		
		//Init
		for(int j=0;j<q[i].size();j++){
			initize(q[i][j].first);
			initize(q[i][j].second);
			id[q[i][j].first]=-1;
			id[q[i][j].second]=-1;
			use[q[i][j].first]=false;
			use[q[i][j].second]=false;
		}
		
		//Unite
		for(int j=0;j<q[i].size();j++){
			Unite(q[i][j].first,q[i][j].second);
		}
		
		//Check
		for(int j=0;j<q[i].size();j++){
			Add(q[i][j].first);
			Add(q[i][j].second);
		}
		
		
	}
	
	//Solve
	queue<int> q;
	
	fill(dis,dis+B,-2);
	dis[0]=0;
	q.push(0);
	while(!q.empty()){
		int last=q.front();
		q.pop();
		
		for(int i=0;i<nei[last].size();i++){
			if(dis[nei[last][i]]==-2){
				dis[nei[last][i]]=dis[last]+1;
				q.push(nei[last][i]);
			}
		}
	}
	
	cout<<dis[n-1]/2;
	return 0;
}



Measured memory_bytes: 122752
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define EQ(a,b) (abs((a)-(b))<EPS)
int m;
int cal(int a)
{
	int k=m/a;
	m-=a*k;
	return k;
}
int main()
{
	while(1)
	{
		int n;
		cin >> n;
		if(n==0)break;
		m=1000-n;
		int ans=0;
		ans+=cal(500);
		ans+=cal(100);
		ans+=cal(50);
		ans+=cal(10);
		ans+=cal(5);
		ans+=cal(1);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int n,a[100001],b,c,m,k,sum;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+1+n);
	reverse(a+1,a+1+n);
	for(int i=1;i<=k;i++)
	sum+=a[i];
	cout<<sum<<endl;
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = 1001002003004005006ll;
const int inf = 1001001001;
const int mod = 1000000007;

int n;
vector<int> g[100005];

vector<int> res;

void dfs(int s,int d = 0, int p = -1) {
	res[s] = d;
	for (auto& c : g[s]) {
		if (c == p) continue;
		dfs(c, d + 1, s);
	}
	return;
}

vector<int> dist(int s) {
	res = vector<int>(n);
	dfs(s);
	return res;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int u, v;
	cin >> n >> u >> v;
	u--; v--;
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	vector<int> distA = dist(u);
	vector<int> distT = dist(v);
	int ans = 0;
	rep(i, n) {
		if (distA[i] < distT[i]) maxs(ans, distT[i]);
	}
	cout << ans - 1 << endl;
	return 0;
}

Measured memory_bytes: 10744
def calc(a, y, o)
  results = o.map do |soc, air, aoc|
    r = a
    if soc.to_i == 0
      i = 0
      y.times do
        i += (r * air).to_i
        r -= aoc.to_i
      end
      r += i
    else
      y.times do
        r += (r * air).to_i - aoc.to_i
      end
    end
    r
  end
  results.max
end
gets.to_i.times do
  a = gets.to_i
  y = gets.to_i
  o = []
  gets.to_i.times do
    o.push(gets.split.map(&:to_f))
  end
  puts calc(a, y, o)
end

Measured memory_bytes: 8828
//直接构造两个等差数列a,b，公差为20000
//然后从小到大枚举p，让靠前的减去一个较大的数
//虽然不知道为什么....qwq......atcoder的题解不是中文，阅读起来较大障碍...
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int MAXN=20000,base=20009;
int a[MAXN+5],b[MAXN+5];
int n,x;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		a[i]=base*i;
	for(int i=1;i<=n;i++)
		b[i]=base*(n-i+1);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		a[x]-=(n-i+1);
	}
	for(int i=1;i<=n;i++)
		printf("%d ",a[i]);
	printf("\n");
	for(int i=1;i<=n;i++)
		printf("%d ",b[i]);
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int main()
{
    ll n; cin >> n;
    int l = 2;
    int ans = 0;
    while (l <= floor(sqrt(n)))
    {
        int count = 0;
        while (n % l == 0)
        {
            n /= l;
            count++;
        }
        int a = 1;
        while (a <= count)
        {
            count -= a;
            ans++;
            a++;
        }
        l++;
    }
    if (n > 1)
        ans++;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3676
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

int main() {
  int N, K; cin >> N >> K;
  vector<int> A(N); cin >> A;
  int S = accumulate(A.begin(), A.end(), 0);

  // Enumerate common divisors, and sort descent.
  vector<int> d;
  for (int i = 1; i * i <= S; ++i) {
    if (S % i == 0) {
      d.push_back(i);
      d.push_back(S/i);
    }
  }
  sort(d.rbegin(), d.rend());

  for (int x : d) {
    vector<int> d2;
    for (int v : A) {
      if (v % x != 0) d2.push_back(v % x);
    }
    int N2 = d2.size();
    if (N2 == 0) {
      cout << x << endl;
      return 0;
    }

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

    vector<int> S1(N2 + 1), S2(N2 + 1);
    S1[0] = 0, S2[N2] = 0;
    for (int i = 0; i < N2; ++i) S1[i + 1] = S1[i] + d2[i];
    for (int i = N2; i > 0; --i) S2[i - 1] = S2[i] + (x - d2[i-1]);

    for (int i = 0; i < N2; ++i) {
      if (S1[i] == S2[i] && S1[i] <= K) {
        cout << x << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3620
#include <cstdio>
using namespace std;
int n,m,c,cnt;
int a[10005],ans[105][105];
bool b[105][105];
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
inline void next(int &x,int &y)
{
	b[x][y]=true;
	for (int i=0;i<4;++i)
	{
		int nx=x+dx[i],ny=y+dy[i];
		if (nx>=0 && nx<n && ny>=0 && ny<m)
		{
			if (!b[nx][ny])
			{
				x=nx,y=ny;
				return;
			}
		}
	}
}
int main()
{
	scanf("%d%d%d",&n,&m,&c);
	for (int i=0;i<c;++i)
	{
		scanf("%d",a+i);
	}
	int x=0,y=0;
	for (int i=0;i<c;++i)
	{
		while (a[i]--)
		{
			ans[x][y]=i+1;
			next(x,y);
		}
	}
	for (int i=0;i<n;++i)
	{
		for (int j=0;j<m;++j)
		{
			printf("%d%c",ans[i][j]," \n"[j==m-1]);
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
  ll W,H,N,X,Y,A;cin >> W >> H >> N;
  ll u=H,d=0,l=0,r=W;
  rep(i,N){
    cin >> X >> Y >> A;
    if(A==1){
      l=max(X,l);
    }
    if(A==2){
      r=min(X,r);
    }
    if(A==3){
      d=max(Y,d);
    }
    if(A==4){
      u=min(Y,u);
    }
  }
  ll h=0;
  cout << (max(h,(u-d)))*(max(h,(r-l))) << endl;
}

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

using namespace std;
//#pragma GCC optimize("O3")

typedef long long ll;
typedef long double ld;
ll a, b;
const ll one = 1;
ll solve(int bit, ll a, ll b, int pref, bool should_take) {
    if (bit == -1) return 1;
    assert(a < (one << (bit + 1)));
    assert(b < (one << (bit + 1)));
    if (pref >= bit && !should_take) return (one << (bit + 1));
    if (a >= (one << bit)) {
        ll f = solve(bit - 1, a - (one << bit), b - (one << bit), pref, true);
        if (!should_take) f += (one << (pref + 1));
        return f;
    }
    if (b < (one << (bit))) {
        return solve(bit - 1, a, b, pref, should_take);
    }
    ll ans = solve(bit - 1, a, (one << bit) - 1, pref, should_take);
    //with bit
    ll diff = b - (one << bit);
    for (int j = 0; j <= bit; j++) {
        if (diff < (one << j)) {
            pref = max(pref, j - 1);
            break;
        }
    }

    return ans + solve(bit - 1, a, (one << bit) - 1, pref, false);
}
int main() {
   // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> a >> b;
    cout << solve(59, a, b, -1, true);
    return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
#include<string.h>
#include<tuple>
#define all(c) c.begin(),c.end()
#define pb push_back
#define em emplace_back
#define ll long long int
#define mp make_pair
#define isro ios_base::sync_with_stdio(false);
#define debug(c) cout<<c<<endl;
#define find(v,x) find(all(v),x)!=v.end()
using namespace std;

typedef vector<ll>vi;
typedef vector<vi>vii;
typedef pair<ll,ll>pi;
typedef tuple<ll,ll,ll>ti;

int MAXN=100;
int MAXW=100;


int main(){
   isro; 
   ll n;
   cin>>n;
   vi v(n),cost(n,0);
   for(auto i=0;i<n;i++){
       cin>>v[i];
   }

   ll minn=1e9;   
   cost[0]=0;
   cost[1]=max(v[0]-v[1],v[1]-v[0]);
   for(auto i=2;i<n;i++){
       ll t2,t1;
       t1=max(v[i]-v[i-1],v[i-1]-v[i])+cost[i-1];
       t2=max(v[i]-v[i-2],v[i-2]-v[i])+cost[i-2];
       cost[i]=min(t1,t2);
   }

   cout<<cost[n-1]<<endl;
}

Measured memory_bytes: 1920
import java.util.Scanner;
import java.util.ArrayDeque;
import java.awt.Point;

public class Main{
/*
public static void pDisp(int [][]house,int h,int w){
int ret=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){System.out.printf("%d ",house[j][i]);}
	System.out.printf("\n");
	}System.out.printf("\n");
}
*/
public static int psum(int [][]house,int h,int w){
int ret=0;

for(int i=0;i<h;i++){
	for(int j=0;j<w;j++)if(house[j][i]==1)ret++;
}
  return ret;
}
	
public static Point pfound(int [][]house,int h,int w){
for(int i=0;i<h;i++){
  for(int j=0;j<w;j++)if(house[j][i]==1)return new Point(j,i);
}
  return new Point(-1,-1);
}

public static int kukaku(int[][]house,int h,int w){
	int cnt=psum(house,h,w);
	Point[] Dir={new Point(1,0),new Point(0,1),new Point(-1,0),new Point(0,-1)};
	int ret=0;
	ArrayDeque<Point>dq=new ArrayDeque<>();
	while(cnt>0){
		Point fpt=pfound(house,h,w);
		if(fpt.x==-1 && fpt.y==-1)return ret;
		dq.add(fpt);
		ret++;
		
		while(dq.size()>0){
			Point p=dq.removeFirst();
			house[p.x][p.y]=0;
			for(int i=0;i<4;i++){
				Point np=new Point(p.x+Dir[i].x,p.y+Dir[i].y);
			 	int nx=np.x;int ny=np.y;
				if(nx>=0 && nx<w && ny>=0 && ny<h && house[nx][ny]==1){dq.addLast(new Point(nx,ny));
				cnt--;
				house[nx][ny]=0;
				}
			
			}
		}
		
	}
return ret;
}


public static void main(String []ag){
Scanner sc=new Scanner(System.in);
int h=12,w=12;
while(sc.hasNext()){
	int [][]house=new int[w][h];
	for(int i=0;i<h;i++){
		String str=sc.next();
		for(int j=0;j<w;j++)house[j][i]=str.charAt(j)-'0';
	}
	//pDisp(house,h,w);
	int ret=kukaku(house,h,w);
	System.out.printf("%d\n",ret);

	if(sc.hasNext()==false)break;
}

}

}



Measured memory_bytes: 25936