akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

int cnt(int n) {
    int val = 0;
    while (n) {
        val++;
        n /= 10;
    }
    return val;
}

void solve() {
    int n;
    read(n);
    
    int ans = 1e9;
    
    FOR(i, 1, sqrt(n) + 1) {
        if (n % i == 0) {
            ans = min(ans, max(cnt(i), cnt(n / i)));
        }
    }
    print(ans);
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
//    read(tt);
    FOR(tt) {
//        write("Case #", i + 1, ": ");
        solve();
    }
    
}



Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >>m;
    vector< vector <int> > a(n, vector<int>(m,0));
    vector<int> b(m);
    for(int i = 0; i < n; i++){
        for(int j = 0; j <  m; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }

    for(int i = 0; i < n; i++){
        int c = 0;
        for(int j = 0; j < m; j++){
            c += a[i][j]*b[j];
        }
        cout << c << endl;
    }
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define ll long long
#define eps 1e-7
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define int ll
using pii = pair<int, int>;

int ans[100101];
int32_t main()
{
    int n; cin >> n;
    for (int x = 1; x*x <= n; x++)
    {
        for (int y = 1; y*y <= n; y++)
        {
            for (int z = 1; z*z <= n; z++)
            {
                int u = x*x + y*y + z*z + x*y + y*z + z*x;
                ans[u]++;
            }
        }
    }
    for (int i = 1; i<=n; i++)
        cout << ans[i] << '\n';
}

Measured memory_bytes: 3988
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <fstream>
#include <map>


std::vector<long long> parent;
std::vector<long long> dist;

long long find_par (long long x) {
    if (parent[x] == -1)
        return -1;
    if (x == parent[x])
        return x;

    long long new_parent = find_par(parent[x]);
    dist[x] += dist[parent[x]];
    parent[x] = new_parent;
    return new_parent;
}

void merge(long long x, long long y, long long r) {
    parent[y] = x;
    dist[y] = r;
}


int main() {
    long long n, m;
    std::cin >> n >> m;


    //std::map<long long, long long> pos;

    parent.resize(n + 1, -1);
    dist.resize(n + 1);
    for (long long i = 0; i < m; ++i) {
        long long x, y, z;
        std::cin >> x >> y >> z;
        long long x_par = find_par(x);
        long long y_par = find_par(y);
        if (x_par == -1 && y_par == -1) {
            parent[x] = x;
            dist[x] = 0;
            parent[y] = x;
            dist[y] = z;
        } else if (x_par == -1) {
            parent[x] = y_par;
            dist[x] = dist[y] - z;
        } else if (y_par == -1) {
            parent[y] = x_par;
            dist[y] = dist[x] + z;
        } else {
            if (x_par == y_par) {
                if (dist[x] + z != dist[y]) {
                    std::cout << "No\n";
                    return 0;
                }
            } else {
                merge(x_par, y_par, (dist[x] + z - dist[y]));
            }
        }
    }
    std::cout << "Yes\n";
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int N;
long long K;
int Q;

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

	int S[100002] = {0};

	cin >> N >> K >> Q;
	for(int i=1; i<=Q; i++){
		int a;
		cin >> a;
		S[a]++;
	}

	for(int i=1; i<=N; i++){
		long long p = K - Q + S[i];
		if(p <= 0){
			printf("No\n");
		}
		else{
			printf("Yes\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#undef int
#define mk make_pair
#define pb push_back
#define pf push_front
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

int N;
deque<int> dque;

signed main()
{
    cin >> N;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        if(i % 2){
            dque.pb(a);
        }
        else{
            dque.pf(a);
        }
    }
    if(N % 2){
        while(dque.size()){
            printf("%d", dque.front());
            dque.pop_front();
            if(dque.size()){
                printf(" ");
            }
        }
        printf("\n");
    }
    else {
        while(dque.size()){
            printf("%d", dque.back());
            dque.pop_back();
            if(dque.size()){
                printf(" ");
            }
        }
        printf("\n");
    }



    return 0;
}
/*


*/




Measured memory_bytes: 2944
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> N,K,S;
  vector<ll> r(N);
  ll hoge = 1;
  for (int i = 0; i < N; i++) {
    if (i < K)
      r[i] = S;
    else
      r[i] = (S == 1) ? 2 : S - 1;
  }
  
    


  for (auto i : r)
    cout << i << endl;
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }

int main() {
  plot(solve);

  return 0;
}




Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

int main(){
    int W, a, b;
    cin >> W >> a >> b;
    int v = b - (a+W);
    //最初から連結
    if((b>=a && b<= a+W) || (b+W >= a && b+W<= a+W)){
        cout << 0 << endl;
    }else if(b+W < a){
        cout << a - (b+W);
    }else{
        cout << b - (a+W) << endl;
    }

}

Measured memory_bytes: 256
#sys.stdin.readline()
import sys
input = sys.stdin.readline

def counter(n):
  count1 = 0
  while(1):
    if(n%2 == 1):
      break
    else:
      n = n//2
      count1 += 1
  return count1

N = int(input())
A = list(map(int,input().split()))
count = 0
for a in A:
  count += counter(a)

print(count)

Measured memory_bytes: 4084
import sys
def main():
    n, m = map(int, input().split())
    s = [tuple(map(int, input().split())) for _ in range(m)]
    s = set(s)
    len_s = len(s)
    if len_s != len(set([sc[0] for sc in s])):
        print(-1)
        sys.exit()
    if m == 0 and n == 1:
        print(0)
        sys.exit()

    r = -1
    for i in range(10**n):
        i_s = str(i)
        i_s = i_s.zfill(n)
        flag = True
        for sc in s:
            if i_s[sc[0]-1] != str(sc[1]):
                flag = False
                continue
        if n == 3 and i_s[0] == '0':
            flag = False
        elif n == 3 and i_s[0] == '0' and i_s[1] == '0':
            flag = False
        elif n == 2 and i_s[0] == '0':
            flag = False
        if flag:
            r = i
            break
    print(r)
main()

Measured memory_bytes: 3064
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;
ll llmin(ll a,ll b){
    if(a>=b) return b;
    return a;
}
ll llmax(ll a,ll b){
    if(a<=b) return b;
    return a;
}
int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);


    string S,T;
    
    cin >> S;
    cin >> T;
    ll ssize = S.size();

    ll ans = ssize+10;
    for( ll ni = 0 ; ni <ssize-T.size()+1 ; ni++ ){
        stmp = S.substr(ni,T.size());
        ll tmp = 0;
        rep(si,T.size()){
            if(stmp.substr(si,1)==T.substr(si,1)) tmp++;
        }
        ans = llmin(T.size()-tmp,ans);
        //cout << ans << endl;
    }
    cout << ans << endl;
    

}

Measured memory_bytes: 3648
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC130_a solver = new ABC130_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC130_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            int A = in.nextInt();

            if (X >= A) {
                out.println(10);
            } else {
                out.println(0);
            }


        }

    }
}



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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

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



Measured memory_bytes: 256
#include <stdio.h>
#define N 101

int maxes(const int *n, int *max_array) // 要素数を返す(いくつ最大値があったか)
{
        int counter     = 0;
        int max         = 0;
        int i;
        for (i=0; i<N; i++) { 
                if (max < n[i]) {
                        max = n[i];
                } 
        }
        for (i=0; i<N; i++) { 
                if (n[i] == max) {
                        max_array[counter] = i;
                        counter++;
                }
        }
        return counter;
}

int main(void)
{
        int n[N]                = {0};
        int max_array[N]        = {0};
        int i;

        while (scanf("%d", &i) != EOF) {
                n[i]++;
        }

        int size = maxes(n, max_array);

        for (i=0; i<size; i++) {
                printf("%d\n", max_array[i]);
        }
        return 0;
}

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

int main(){
  
  //variables
  string S[60];
  int H,W;
  int cnt=0;
  
  //input
  cin >> H >> W;
  for(int i=0;i<H;i++) cin >> S[i];


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

  //output
  //cout << " " << endl;
  for(int i=0;i<H;i++) cout << S[i] << endl;
    
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n,a,b;
  cin >> n >> a >> b;
  ll sa = abs(a-b);
  ll ans= 2000000000000000000;
  if(sa%2==0) {
    pri(sa/2);
    return 0;
  }else {
    chmin(ans,min(a-1,n-a));
    chmin(ans,min(b-1,n-b));
    pri((sa-1)/2 + ans + 1 );
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a>b?b:a)
#define INF 0x3f3f3f3f
#define sz size()
#define pb push_back
#define ph push
#define mem(x, y) memset(x, y, sizeof(x));
#define mem0(x) mem(x,0)
#define mem1(x) mem(x,-1)
#define memINF(x) mem(x,INF)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
#define setI freopen("input.txt","r",stdin);
#define setIO freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
using namespace std;
typedef long long ll;

typedef vector<int> vi;
typedef pair<int, int> pii;

int const Max_N = 3e3+50;

int main()
{
    #ifdef Anani_leaf
      setI;
    #endif

    int A,B,C,D,E,F;
    scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);
    int aa,bb,cc,dd;
    int ansa = 0,ansb = 0;
    rep(i,0,31)
    {
        if(i*A*100>F) continue;
        rep(j,0,31)
        {
            if(i==0&&j==0) continue;
            if(i*A*100 + j*B*100> F) continue;
            rep(k,0,3001)
            {
                if(i*A*100 + j*B*100 + k*C> F) continue;
                if(k*C>(i*A+j*B)*E) continue;
                rep(z,0,3001)
                {
                    if(i*A*100 + j*B*100 + k*C + z*D > F) continue;
                    if(k*C + z*D > (i*A + j*B)*E) continue;
                    int a = i*A*100 + j*B*100;
                    int b = k*C + z*D;
                    if(ansa==0)
                    {
                        ansa = a;ansb = b;
                    }
                    else if(b*(ansa+ansb) > ansb*(a+b))
                    {
                        ansa = a;ansb = b;
                    }


                }
            }
        }
    }
    printf("%d %d\n",ansa+ansb,ansb);

    return 0;
}
    //freopen("in.txt","r",stdin);
//std::ios::sync_with_stdio(false);


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

int main()
{

    long long  i,n=0,k=0,l,c=0;
     string s;
     cin>>s;
     for(i=0;i<s.size();i++)
     {
        if(s[i]=='C') n=i+1;
        if(s[i]=='F') k=i+1;

     }
     if((n>0&&k>0)&&(n<k)) cout<<"Yes"<<endl;
     else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 3600
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M = mapint()
As = list(mapint())
from heapq import heappush, heappop
Q = []

for a in As:
    heappush(Q, -a)

for i in range(M):
    a = -heappop(Q)
    heappush(Q, -(a//2))

print(-sum(Q))

Measured memory_bytes: 90908
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	int n, x, t;
	cin >> n >> x >> t;
	cout << (n + x - 1) / x * t;
	return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

struct UF {
  vector<int> data;
  int nDistinct;
  UF() {}
  UF(int n) : data(n, -1), nDistinct(n) {}
  void init(int n) { data.assign(n, -1); nDistinct = n; }
  int size(void) const { return nDistinct; }
  int rootOf(int a) { return data[a] >= 0 ? data[a] = rootOf(data[a]) : a; }
  int count(int a) { return -data[rootOf(a)]; }
  bool isSameGroup(int a, int b) { return rootOf(a) == rootOf(b); }
  bool unify(int a, int b) {
    int ra = rootOf(a), rb = rootOf(b);
    if(ra == rb) return false;
    if(data[ra] < data[rb]) swap(ra, rb);
    data[rb] += data[ra]; data[ra] = rb; --nDistinct;
    return true;
  }
};

vector<int> vs[100000+10];
vector<int> is[100000+10];

int ps[100000+10];
int main(void) {
  int nNode, nEdge;
  scanf("%d%d", &nNode, &nEdge);
  REP(i, nNode) {
    scanf("%d", &ps[i]);
    --ps[i];
    vs[i].push_back(ps[i]);
    is[i].push_back(i);
  }
  UF uf(nNode);
  REP(i, nEdge) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x;
    --y;
    int rx = uf.rootOf(x);
    int ry = uf.rootOf(y);
    if(uf.unify(x, y)) {
      int nr = uf.rootOf(x);
      if(vs[rx].size() > vs[ry].size()) {
        vs[rx].swap(vs[ry]);
        is[rx].swap(is[ry]);
      }
      REP(i, vs[rx].size()) {
        vs[ry].push_back(vs[rx][i]);
        is[ry].push_back(is[rx][i]);
      }
      vs[rx].clear();
      is[rx].clear();
      if(nr == rx) {
        vs[rx].swap(vs[ry]);
        is[rx].swap(is[ry]);
      }
    }
  }
  int res = 0;
  REP(i, nNode) {
    if(uf.rootOf(i) == i) {
      sort(vs[i].begin(), vs[i].end());
      sort(is[i].begin(), is[i].end());
      int ii = 0;
      REP(iv, vs[i].size()) {
        while(ii < (int)is[i].size() && is[i][ii] < vs[i][iv]) {
          ++ii;
        }
        if(ii < (int)is[i].size() && is[i][ii] == vs[i][iv]) {
          ++res;
          // cerr << "> " << vs[i][iv] << endl;
        }
      }
    }
  }
  cout << res << endl;
  
  return 0;
}


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

const int MOD = (int)1e9+7;

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> B(N);
  for(int i=0;i<N;i++)  cin >> A.at(i) >> B.at(i);

  long long ans=0;
  for(int i=N-1;i>=0;i--){
    long long now=A.at(i)+ans;
    if(now%B.at(i)!=0)  ans+=B.at(i)-now%B.at(i);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
/*
  Contest 090
  A - Diagonal String
  Rakesh Kumar --> 18/09/2020
 */

#include <bits/stdc++.h>

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0); std::cout.tie(0);

    for (int i = 0; i < 3; ++i) {
        std::string s;
        std::getline(std::cin, s);
        std::cout << s[i];
    }
    std::cout << std::endl;

    return 0;
}


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

signed main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> a(3,vector<int>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[j][i];
        }
    }
    
    int max = - (1e9);
    for (int bit = 0; bit < 1 << 3; bit++) {
        vector<int> v(N, 0);
        for (int j = 0; j < 3; j++) {
            for (int i = 0; i < N; i ++) {
                if (bit & (1 << j)) {
                    v[i] += a[j][i];
                } else {
                    v[i] -= a[j][i];
                }
            }
        }
        sort(v.begin(), v.end(), greater<int>());
        int sum = 0;
        for (int i = 0; i < M; i++) {
            sum += v[i];
        }
        if (sum > max) {
            max = sum;
        }
    }
    cout << max << endl;
    return 0;
}

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

int min(int a, int b){
    if(a > b)return b;
    else return a;
}

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static int max(int[] a){
		int ans = 0;
		for(int i=0;i<a.length;i++){
			if(ans < a[i]){
				ans = a[i];
			}
		}
		return ans;
	}


	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String stra = br.readLine();
			if (stra == null){break;}
			String strb = br.readLine();
			int n = stra.length();
			int m = strb.length();
			int[][] mapp = new int [n+1][m+1];
			for(int i=0; i<n; i++){
				for(int j=0;j<m; j++){
					if (stra.charAt(i) == strb.charAt(j)){
						mapp[i+1][j+1] = mapp[i][j] + 1;
					}
				}
			}

			int ans = 0;
			for (int i=0; i<n+1; i++){
				ans = Math.max(ans, max(mapp[i]));
			}
			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 274556
n = int(input())
plan = [tuple(map(int, input().split())) for _ in range(n)]
plan = [(0, 0, 0)] + plan
for i in range(n):
    ct, cx, cy = plan[i]
    nt, nx, ny = plan[i+1]
    t = nt - ct
    x = nx - cx
    y = ny - cy
    if abs(x) + abs(y) > t or (abs(x) + abs(y) - t) % 2:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 18092
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mx 1007
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t,m,n,a,b,c,d,e,f;
    cin>>n>>a>>b;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        d=1;
        while(d<=a)
        {
            ans++;
            d+=arr[i];
        }
    }
    ans+=b;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const int MAXN = 3001;

int main()
{
    string s,t;
    cin >> s >> t;

    int n = s.size(),m = t.size();

    vector<vector<int> > dp(n+1),flag(n+1);
    for(int i = 0; i <= n; i++){
        dp[i].resize(m+1,0);
        flag[i].resize(m+1,0);
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(s[i] == t[j]){
                dp[i+1][j+1] = dp[i][j] + 1;
                flag[i+1][j+1] = 1;
            }else dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
        }
    }
    //cout << s << endl;
    int max_len = dp[n][m];
    string ans="";
    int k = m;
    for(int i = n; i > 0; i--){
        for(int j = k; j > 0; j--){
            if(flag[i][j] == 1 && dp[i][j] == max_len){
                ans = s[i-1] + ans;
                dp[i][j] = -1;
                max_len--;
                k = j-1;
                break;
            }
        }
    }

    cout << ans << endl;


    // for(int i = 0; i <= n; i++){
    //     for(int j = 0; j <= m; j++){
    //         if(i == 0 && j != 0){
    //             cout << t[j-1] << " ";
    //             continue;
    //         }
    //         if(i != 0 && j == 0){
    //             cout << s[i-1] << " ";
    //             continue;
    //         }
    //         cout << dp[i][j] << " ";
    //     }printf("\n");
    // }

    return 0;
}

Measured memory_bytes: 70784
#include <stdio.h>
int main(void){
  int N;
  int H[1000010];
  int i;
  scanf("%d",&N);
  for(i=1;i<=N;i++){
    scanf("%d",&H[i]);
  }
  
  int max=0;
  int s=0;
  for(i=N;i>=1;i--){
    if(H[i]<=H[i-1]){
      s=s+1;
    }
    else{
      if(max<s){
        max=s;
      }
    s=0;
    }
  }
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 2108
a, b ,c= input().split()
a = int(a)
b = int(b)
c = int(c)
d = a - c
if d < 0:
    a = 0
    e = b + d
    if e < 0:
        b = 0
    else:
        b = b + d
else:
    a = a - c
print(str(a)+" "+str(b))

Measured memory_bytes: 3064
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: f32
  }
  
  println!("{}", (n / 2f32).ceil());
}

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

int main(){
    long long int a, b, c;
    cin >> a >> b >> c;
    if(a%2 || b%2 || c%2)cout << 0 << endl;
    else if(a == b && a == c)cout << -1 << endl;
    else{
        int ans = 0;
        while(a%2 == 0 && b%2 == 0 && c%2 == 0){
            long long int aw = a, bw = b, cw = c;
            a = (bw + cw) / 2;
            b = (aw + cw) / 2;
            c = (aw + bw) / 2;
            ans++;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#![allow(unused)]
use std::io::{self, Read};

fn get_stdin() -> String {
    let mut buf = String::new();
    let mut stdin = io::stdin();
    stdin.read_to_string(&mut buf);
    return buf
}

fn to_nums(ss: &str) -> Vec<i32> {
    ss.split_whitespace()
        .map(|x| x.parse::<i32>().unwrap())
        .collect()
}

fn main() {
    let input = get_stdin();
    let v = to_nums(&input);
    let rect = Rectangle {
        width: v[0],
        height: v[1],
    };
    let circ = Circle {
        center: Point(v[2], v[3]),
        radius: v[4],
    };
    let cond1 = circ.edge(Direction::Left).0 >= 0;
    let cond2 = circ.edge(Direction::Right).0 <= rect.width;
    let cond3 = circ.edge(Direction::Bottom).1 >= 0;
    let cond4 = circ.edge(Direction::Top).1 <= rect.height;

    if cond1 && cond2 && cond3 && cond4 {
        println!("Yes");
    } else {
        println!("No");
    }
}

struct Rectangle {
    width: i32,
    height: i32,
}

struct Point(i32,i32);

struct Circle {
    center: Point,
    radius: i32,
}

enum Direction {
    Left,
    Right,
    Top,
    Bottom,
}

impl Circle {
    fn edge(&self, direction: Direction) -> Point {
        let p = &self.center;
        let r = self.radius;
        match direction {
            Direction::Left => Point(p.0 - r, p.1),
            Direction::Right => Point(p.0 + r, p.1),
            Direction::Top => Point(p.0, p.1 + r),
            Direction::Bottom => Point(p.0, p.1 - r),
        }
    }
}



Measured memory_bytes: 5032
n,m,l = map(int,input().split())
A = [list(map(int,input().split())) for i in range(n)]
B = [list(map(int,input().split())) for i in range(m)]
AB = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            AB[i][j] += A[i][k]*B[k][j]
for i in range(n):
    print(' '.join(map(str,AB[i])))



Measured memory_bytes: 6888
#include<iostream>

using namespace std;

int main() {
	int tate, yoko;
	int menseki, shu;
	cin >> tate >> yoko;

	menseki = tate * yoko;
	shu = tate + tate + yoko + yoko;

	cout << menseki << " " << shu <<"\n";

	return 0;
}

Measured memory_bytes: 3088
#include <stdio.h>

int main(void)
{
	int i,j,k,l;
	
	while (scanf("%d %d",&i,&j) != EOF){
		k = i + j;
		for (l = 1;(k /= 10) != 0;++l){}
		printf("%d\n",l);
	}
	
	return(0);
}

Measured memory_bytes: 596
#include <stdio.h>
#define N 500000
#define INFTY 1000000000

void merge(int*, int, int, int);
void mergeSort(int*, int, int);

int count;

main(){
  int seq[N];
  int i, n;
  
  scanf("%d", &n);
  
  for( i = 0; i < n; i++){
    scanf("%d", &seq[i]);
  }
  
  mergeSort(seq, 0, n);
  
  for( i = 0; i < n; i++){
    if( i == n-1 ) printf("%d\n", seq[i]);
    else printf("%d ", seq[i]);
  }
  
  printf("%d\n", count);
  
  return 0;

}


void merge(int *seq, int left, int mid, int right){
  int n1, n2, i, j, k;
  int L[N], R[N];
  
  n1 = mid - left;
  n2 = right - mid;
  
  for( i = 0; i < n1; i++){
    L[i] = seq[left+i];
  }
  
  for( i = 0; i < n2; i++){
    R[i] = seq[mid+i];
  }
  
  L[n1] = INFTY;
  R[n2] = INFTY;
  
  i = 0;
  j = 0;
  
  for( k = left; k < right; k++){

    if( L[i] <= R[j] ){
      seq[k] = L[i];
      i = i + 1;
    }
    
    else{
      seq[k] = R[j];
      j = j + 1;
    }

    count++;
    
  }
  
}


void mergeSort(int *seq, int left, int right){
  int mid; 
 
  if( left+1 < right ){
    
    mid = ( left + right ) / 2;
    
    mergeSort(seq, left, mid);

    mergeSort(seq, mid, right);

    merge(seq, left, mid, right);
    
  }

}

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

/*  */
int main() {
    int A, B, C;
    cin >> A >> B >> C;

    int ans = A * B /2;
    cout << ans << endl;
    return 0;
}


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

int fnc1(int *,int);
int fnc2(int *,int);

int main(){
    int a[100];
    int i,n,ans;
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
    }

    ans=fnc1(a,n)-fnc2(a,n);
    printf("%d\n",ans);
    return 0;
}
 
int fnc1(int *a,int n){
    int i,max;
    max=a[0];
    for(i=1; i<n; i++){
        if(max<a[i]){
            max=a[i];
        }
    }
    return max;
}
int fnc2(int *a,int n){
    int i,min;
    min=a[0];
    for(i=1; i<n; i++){
        if(min>a[i]){
            min=a[i];
        }
    }
    return min;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi ans;
    while (sz(ans) < n) {
        int m = sz(a);
        for (int i = m-1; i >=0; --i) {
            if (a[i] == i+1) {
                a.erase(a.begin()+i);
                ans.pb(i+1);
                break;
            }
            if (i == 0) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    for (int i = n-1; i >= 0; i--) cout << ans[i] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
using namespace std;
int dp[(1<<13)+5][15];
int main(){
	int m,w;
	while(1){
		scanf("%d%d",&m,&w);
		if(m+w == 0) return 0; int A[15],B[15];
		for(int i=0;i<m;i++) scanf("%d",&A[i]);
		for(int i=0;i<w;i++) scanf("%d",&B[i]);
		for(int i=0;i<(1<<13)+5;i++) for(int j=0;j<15;j++) dp[i][j] = -100000000;
		dp[0][0] = 0;
		for(int i=0;i<(1<<m);i++){
			for(int j=0;j<w;j++){
				if(dp[i][j] < 0) continue;
				for(int k=0;k<m;k++){
					dp[i][j+1] = max(dp[i][j+1],dp[i][j]);
					if(!((i>>k)&1)){
						int x = abs(B[j]-A[k]);
						dp[i + (1<<k)][j+1] = max(dp[i + (1<<k)][j+1] ,dp[i][j]+(x * (x-30) * (x-30)));
					}
				}
			}
		}
		int res = 0;
		for(int i=0;i<(1<<13)+5;i++) for(int j=0;j<15;j++) res = max(res,dp[i][j]);
		cout << res << endl;
	}
}

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

#define ll long long
#define ld long double
#define COIN const int
#define ite iterator
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define REPD(i,n) for((i)=(n)-1;(i)>=0;(i)--)

#define ALL(c) (c).begin(), (c).end()
#define sz(s) (s).size()
#define CLEAR(x) memset(x,0,sizeof x);

#define MP make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define X first
#define Y second

#define VI vector<int>
#define VS vector<string>
#define VII vector<PII>
#define VVI vector<VI>

#define PIII 3.1415926
#define PI 3.14
/*****************************************************************************/

using namespace std;

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int k,a,b;  cin >>k; cin >>a >>b; 
//	string 
	int x,i;
	x=a/k;
	for (i=a;;i++) {
		int o=x*k;
		if (o>=a && o<=b) {
			cout <<"OK";
			break;
		}
		if (o>b) {
			cout <<"NG";
			return 0;
		}
		x++;
	}
}
/******************************************************************************
******************************************************************************/


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

using namespace std;
#define sz(a) int(a.size())
#define ll  long long int
#define mod (long long)(1e9+7)
#define endl '\n'
#define ENGZ ios::sync_with_stdio(0);ios_base::sync_with_stdio(0);cin.tie(0) , cout.tie(0) ;
#define pi (acos(-1))
#define F first
#define S second

ll fp(ll n , ll p )
{
    if(p==0)
        return 1;
    if(p==1)
        return n ;
    ll res = fp(n,p/2)%mod ;
    res=((res)*(res))%mod ;
    if(p%2)
        res=(res*n)%mod ;
    return res ;
}


int main()
{
    ENGZ;
    string s ;
    cin>>s ;
    string a = "" , b = "" ;
    for(int i=0 ; i<sz(s) ; i++)
    {
        if(i%2){
            a+="0";
            b+="1";

        }
        else
        {
            a+="1";
            b+="0";
        }
    }
    int ans = 0 , ans1= 0 ;
    for(int i=0 ; i<sz(s) ; i++)
    {
        if(s[i] != a[i])ans++ ;
        if(s[i] != b[i])ans1++ ;
    }
        cout<<min(ans1,ans) <<endl ;


    return 0;
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/















vector<bool> matching(string x, string y) {
	int nx = x.size();
	int ny = y.size();

	vector<bool> res(6010, true);
	rep(st, 0, nx) {
		for (int i = 0; st + i < nx && i < ny; i++) {
			if (x[st + i] == '?') continue;
			if (y[i] == '?') continue;
			if (x[st + i] != y[i]) res[st] = false;
		}
	}

	return res;
}
//---------------------------------------------------------------------------------------------------
int solve(string A, string B, string C) {
	int na = A.size();
	int nb = B.size();
	int nc = C.size();

	auto ab = matching(A, B);
	auto bc = matching(B, C);
	auto ac = matching(A, C);

	int ans = inf;
	rep(a, 0,  na + 1) rep(b, 0, max(na, nb) + 1) if (ab[a] && bc[b] && ac[a + b]) {
		chmin(ans, max({ na, a + nb, a + b + nc }));
	}
	return ans;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	vector<string> v;
	rep(i, 0, 3) {
		string s; cin >> s;
		v.push_back(s);
	}
	sort(all(v));

	int ans = inf;
	do {
		chmin(ans, solve(v[0], v[1], v[2]));
	} while (next_permutation(all(v)));
	cout << ans << endl;
}







Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define ALL(x) (x).begin(),(x).end()
using namespace std;
const int MAXN = 200005;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";
    return os;
}
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    vector<int>A(n);
    for(int i=0;i<n;i++){
        cin >> A[i];
    }
    int flag = 1;
    while(k--&&flag){
        flag = 0 ;
        vector<int>B(n);
        for(int i=0;i<n;i++){
            int l = max(0,i-A[i]);
            int r = min(i+A[i],n-1);
            B[l]++;
            if(r+1<n)
                B[r+1]--;
        }
        for(int i=0;i<n-1;i++){
            B[i+1]+=B[i];
            if(B[i+1]!=n)
                flag=1;
        //    cout << B[i] <<" \n"[i=n-1];
        }
        if(B[0]!=n)
            flag = 1;
        A=B;
    }
    cout <<A<<endl;
    return 0;
}


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

void foo(int t){
	static int s = 0;
	if(s++)cout<<" ";
	cout<<t/60<<":";
	if(t%60 <= 9)cout<<"0"<<t%60;
	else cout<<t%60;
	
}

int main(){
	int N, M, h[110], k[110];
	int i = 0, j = 0, l = 0, s = 0;
	int a, b, temp = -1;
	
	
	cin>>N;
	for(i = 0; i < N; i++){
		cin>>a>>b;
		h[i] = a * 60 + b;
	}
	cin>>M;
	for(i = 0; i < M; i++){
		cin>>a>>b;
		k[i] = a * 60 + b;
	}
	
	
	while(j < N || l < M){
		if(j == N){
			if(temp != k[l]){
				temp = k[l];
				foo(temp);
			}l++;
		} else if (l == M){
			if(temp != h[j]){
				temp = h[j];
				foo(temp);
			}j++;
		} else {
			if(h[j] < k[l]){
				if(temp != h[j]){
					temp = h[j];
					foo(temp);
				}j++;
			} else if(h[j] > k[l]){
					if(temp != k[l]){
					temp = k[l];
					foo(temp);
				}l++;
			} else if(h[j] == k[l]){
					if(temp != h[j]){
					temp = h[j];
					foo(temp);
				}j++;l++;
			}
		}
		
	}cout<<endl;
	
	return 0;
}





Measured memory_bytes: 3104
#include <algorithm>
#include <iostream>
#include <string>

int main(int, char *[]) {
  int32_t a, b, c, k;
  std::cin >> a >> b >> c >> k;

  auto sum = 0;
  sum += std::min(a, k);
  k -= a;
  k -= b;
  if (k <= 0) {
    std::cout << sum << std::endl;
    return 0;
  }

  sum -= std::min(c, k);
  k -= c;

  std::cout << sum << std::endl;

  return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#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())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}

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

int main() {
    int a, b, c, count = 0;
    cin >> a >> b >> c;
    while (a <= b) {
        if (c % a == 0) {
            count += 1;
        }
        a++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3100
import sys
n=int(input())
#n,m=map(int,input().split())
a=list(map(int,input().split()))
ans=1
if 0 in a:
  print(0)
  sys.exit()
for i in range(n):
  ans*=a[i]
  if ans>10**18:
    ans=-1
    break
print(ans)

Measured memory_bytes: 21596
#include<bits/stdc++.h>
typedef long long int lld;
using namespace std;

int main()
{
    lld a, b, x, cnt = 0, start, last;
    cin >> a >> b >> x;

    start = a/x;
    last = b/x;

    cnt = last - start;
    if(a % x == 0)cnt++;

    cout << cnt;

    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	LL A,V,B,W,T;
	cin>>A>>V;
	cin>>B>>W;
	cin>>T;
	if (A==B){
		cout<<"YES"<<endl;
		return 0;
	}
	if (V<=W){
		cout<<"NO"<<endl;
		return 0;
	}
	LL AB=A-B;
	if (AB<0){
		AB=-AB;
	}
	if (T*(V-W)>=AB){
		cout<<"YES"<<endl;
		return 0;
	}
	cout<<"NO"<<endl;
	return 0;
}


Measured memory_bytes: 3120
a,b,c,d=map(int,input().split())

cnt=0
while 1:
    if cnt%2==0:
        c-=b
        cnt+=1
    else:
        a-=d
        cnt+=1
        
    if a<=0:
        print("No")
        break
    
    if c<=0:
        print("Yes")
        break

Measured memory_bytes: 9180
import bisect
from collections import deque

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))


def colorfind(a, colors):
    index = bisect.bisect_left(colors, a)
    return index


color = deque([])
for i in range(n):
    if i == 0:
        color.appendleft(a[i])
    elif color[0] >= a[i]:
        color.appendleft(a[i])
    else:
        colorindex = colorfind(a[i], color)
        color[colorindex - 1] = a[i]

print(len(color))



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

int main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while (a>0 || c>0)
    {
        c -= b;
        if (c<=0)
        {
            break;
        }
        a -= d;
        if (a<=0)
        {
            break;
        }
    }
    if (a<=0)
    {
        cout<<"No"<<endl;
    } else {
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3568
name = input().split()
n1 = name[0]; n2 = name[1]
lnum = input().split()
lnum1 = int(lnum[0]); lnum2 = int(lnum[1])
l1 = [n1, lnum1]
l2 = [n2, lnum2]
choosen = input()
if choosen == n1:
    print(l1[1]-1, end=" ")
    print(l2[1])
if choosen == n2:
    print(l1[1], end=" ")
    print(l2[1]-1)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> k(m), p(m);
    int s[10][10];

    for(int i=0; i<m; i++){
        cin >> k[i];
        for(int j=0;j<k[i];j++){
            cin >> s[i][j];
        }
    }
    for(int i=0;i<m;i++) cin >> p[i];
    int count = 0;
    for(int sw = 0; sw < 1 << n; sw++){
        int cc =0;
        for(int i=0;i<m;i++){
            int c=0;
            for(int j=0;j<k[i];j++){
                if((sw >> (s[i][j]-1)) & 1) c++;
            }
            if (c % 2 == p[i]) cc++;
        }
        if (cc == m) count++;
    }

    cout << count << endl;
}

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

using namespace std;

struct island{int x, y;} V[100005];

int tot, n, m;

bool comp(island a, island b)
{
    if (a.y==b.y)
        return a.x<b.x;
    return a.y<b.y;
}

int main()
{
    cin>>n>>m;
    for (int i=1; i<=m; i++)
        cin>>V[i].x>>V[i].y;
    sort(V+1, V+m+1, comp);
    int lastx=0;
    for (int i=1; i<=m; i++)
    {
        if (lastx>V[i].x)
            continue;
        tot++;
        lastx = V[i].y;
    }
    cout<<tot;
    return 0;
}


Measured memory_bytes: 1024