akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
ll cnt1[4005],cnt2[4005],cnt3[4005]; 
int main() {
    fast();
   /* ll t;
    cin>>t;
    while(t--)
    {
       
    }*/
    ll n;
    string s;
    cin>>n>>s;
    for(ll i=n-1;i>=0;i--)
    {
        if(s[i]=='R')
        {
            cnt1[i]=cnt1[i+1]+1;
            cnt2[i]=cnt2[i+1];
            cnt3[i]=cnt3[i+1];
        }
       else if(s[i]=='G')
        {
            cnt2[i]=cnt2[i+1]+1;
            cnt1[i]=cnt1[i+1];
            cnt3[i]=cnt3[i+1];
        }
        else if(s[i]=='B')
        {
            cnt3[i]=cnt3[i+1]+1;
            cnt1[i]=cnt1[i+1];
            cnt2[i]=cnt2[i+1];
        }
    }
    ll sum=0;
    for(ll i=0;i<n;i++)
    {
        for(ll j=i+1;j<n;j++)
        {
            if(s[i]==s[j])
            continue;
            else if((s[i]=='R'&&s[j]=='B')||(s[i]=='B'&&s[j]=='R'))
            {
                ll x=j-i;
                sum+=cnt2[j+1];
                if(j+x<n)
                if(s[j+x]=='G')
                sum--;
                //cout<<i<<" "<<j<<" "<<sum<<endl;
            }
           else if((s[i]=='R'&&s[j]=='G')||(s[i]=='G'&&s[j]=='R'))
            {
                ll x=j-i;
                sum+=cnt3[j+1];
                if(j+x<n)
                if(s[j+x]=='B')
                sum--;
                //cout<<i<<" "<<j<<" "<<sum<<endl;
            }
            else if((s[i]=='G'&&s[j]=='B')||(s[i]=='B'&&s[j]=='G'))
            {
                ll x=j-i;
                sum+=cnt1[j+1];
                if(j+x<n)
                if(s[j+x]=='R')
                sum--;
                //cout<<i<<" "<<j<<" "<<sum<<endl;
            }
            
        }
    }
    ll x=0;
    sum=max(sum,x);
    cout<<sum;
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define int long long
#define INT_MAX INT64_MAX
#define INT_MIN INT64_MIN
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcount
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
signed main(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
}






Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = (A + B) / 2;
    if (Math.abs(A - K) == Math.abs(B - K)) {
      System.out.println(K);
    } else {
      System.out.println("IMPOSSIBLE");
    }
  }
}

Measured memory_bytes: 22996
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int a, b;
	cin >> a >> b;
	if (a <= b) {
		cout << a << endl;
	}
	else {
		cout << a - 1 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A, a = 0;
  cin >> N >> A;
  a = N % 500;
  
  if (A >= a) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  } 
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

class stick
{
public:
	ll cost;
	int used;

	stick(ll cost, int used)
	{
		this->cost = cost;
		this->used = used;
	};


};

bool compare(const stick& lhs, const stick& rhs)
{
	if (lhs.cost < rhs.cost) return true;

	return false;
};

typedef vector<stick> vs;

vs combine(int A, int N, vector<int>& L)
{
	vs v;

	for (int i = 1; i < (1 << N); i++)
	{
		ll length = 0;
		int count = 0;

		rep(j, N)
		{
			if ((i & (1 << j)))
			{
				length += L[j];
				count++;
			}
		}

		stick s = stick(abs(A - length) + 10 * (count - 1), i);
		
		v.push_back(s);
	}

	return v;
}

vs merge(vs& v1, vs& v2)
{
	vs v;

	for (auto x : v1)
	{
		for (auto y : v2)
		{
			bool flg = true;

			//同じ竹を使っている場合スキップ
			if (x.used & y.used) continue;

			stick s = stick(x.cost + y.cost, (x.used | y.used) & 255);

			v.push_back(s);
		}
	}

	return v;
}

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

	vector<int> L(N);
	rep(i, N) cin >> L[i];

	auto va = combine(A, N, L);
	auto vb = combine(B, N, L);

	auto vab = merge(va, vb);

	auto vc = combine(C, N, L);

	auto vabc = merge(vab, vc);

	sort(vabc.begin(), vabc.end(), compare);

	cout << vabc[0].cost << endl;

	return 0;
}

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        v.push_back(a);
    }
    auto v2 = v;
    sort(v2.begin(), v2.end());
    map<int, int> mp;
    for(int i=0;i<n;++i){
        mp[v2[i]] = i;
    }
    int ans = 0;
    for(int i=0;i<n;++i){
        if(i%2 != mp[v[i]]%2)ans++;
    }
    ans /= 2;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5752
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;	//using vi = vector<int>;
typedef vector<vector<int>> vvi;

#define rep(i, N) for (int i = 0; i < N; i++)

vvi memo(1000, vector<int>(1000));

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

	int max1 = 0;
	int max2 = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] > max1)max1 = a[i];
		else if (a[i] > max2) max2 = a[i];
	}

	for (int i = 0; i < n; i++) {
		if (a[i] == max1)cout << max2 << endl;
		else cout << max1 << endl;
	}

	return 0;
}


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

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

use std::collections::HashMap;

fn main() {
    let n = read::<u32>();
    let mut even = HashMap::new();
    let mut odd = HashMap::new();

    for i in 0..n {
        let v = read::<u32>();
        if i % 2 == 1 {
            *even.entry(v).or_insert(0) += 1
        } else {
            *odd.entry(v).or_insert(0) += 1
        }
    }

    let even_max = max_kv(&even);
    let odd_max = max_kv(&odd);

    if even_max.0 != odd_max.0 {
        println!("{}", n - odd_max.1 - even_max.1);
    } else {
        even.remove(&even_max.0);
        odd.remove(&odd_max.0);

        let even_max_2 = max_kv(&even);
        let odd_max_2 = max_kv(&odd);
        if even_max_2.1 > odd_max_2.1 {
            println!("{}", n - odd_max.1 - even_max_2.1);
        } else {
            println!("{}", n - odd_max_2.1 - even_max.1);
        }
    }
}

fn max_kv (map: &HashMap<u32, u32>) -> (u32, u32) {
    let mut max = (0, 0);
    for (k, v) in map {
        if max.1 < *v {
            max = (*k, *v);
        }
    }
    max
}

Measured memory_bytes: 8444
#include <cstdlib>
#include <cmath>
#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 <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int n;
	int w,h;
	while(cin>>n,n){
		cin>>w>>h;
		vvint vv;
		initvv(vv,h+1,w+1,0);
		rep(i,n){
			int a,b;
			cin>>a>>b;
			vv[b][a]=1;
		}
		vvint ww;
		initvv(ww,h+1,w+1,0);
		int s,t;
		cin>>s>>t;
		reep(i,1,h+1){
			reep(j,1,w+1){
				ww[i][j]=ww[i-1][j]+ww[i][j-1]-ww[i-1][j-1]+vv[i][j];
			}
		}
		int ans=0;
		reep(i,1,h+1-t+1){
			reep(j,1,w+1-s+1){
				ans=max(ans,ww[i+t-1][j+s-1]-ww[i-1][j+s-1]-ww[i+t-1][j-1]+ww[i-1][j-1]);
			}
		}
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1300
# -*- coding: utf-8 -*-
import sys
def make_divisors(n):
    divisors = [n]
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

N = int(input())

divs = make_divisors(N)
ans = len(make_divisors(N-1))

for d in divs:
    tn = N
    while tn>=d and tn%d==0:
        tn //= d
    if tn==1 or tn%d==1:
        ans += 1

if N==2:
    print(1)
else:
    print(ans)    

Measured memory_bytes: 39536
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;

int main(){
    ll K;
    cin >> K;
    queue<string> q;
    vs lunlun;

    for(int i=1; i<=9; i++){
        q.push(to_string(i));
        lunlun.push_back(to_string(i));
    }

    if(K < 9){
        cout << K << endl;
        return 0;
    }

    ll c = 9;
    string s;
    int num;
    while(c <= K){
        s = q.front();
        num = s.at(s.size()-1) - '0';
        q.pop();
        for(int i=0; i<10; i++){
            if(abs(num - i) <= 1){
                q.push(s + to_string(i));
                c++;
                lunlun.push_back(s + to_string(i));
            }
        }
    }
    cout  << lunlun.at(K-1) << endl;
}

Measured memory_bytes: 9460
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val D = in.next().toInt
  val c = new Array[Long](26+1)
  val s = Array.ofDim[Long](D+1, 26+1)

  for (i <- 1 to 26) {
    c(i) = in.next().toInt
  }
  for (d <- 1 to D) {
    for (i <- 1 to 26) {
      s(d)(i) = in.next().toInt
    }
  }


  /** functions **/
  def calcScore(t: Array[Int]): Long = {
    val last = new Array[Int](26+1)
    var res = 0L

    for (d <- 1 to D) {
      val ty = t(d)

      res += s(d)(ty)
      last(ty) = d

      for (i <- 1 to 26) {
        res -= c(i) * (d - last(i))
      }
    }

    res
  }


  /** solve **/
  val t = new Array[Int](D+1)
  for (d <- 1 to D) {
    t(d) = (d % 26 + 1)
  }


  for (d <- 1 to D) {
    pw.println(t(d))
  }
  pw.flush()
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


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

int f[2][2] = {{1,1},{0,1}};

int main() {
	int N;
	cin >> N;
	
	vector< int > a(N);
	for (int i=0; i<N; ++i) {
		char c;
		cin >> c;
		if (c == 'T') a[i] = 1;
		else a[i] = 0;
	}
	
	int c = f[a[0]][a[1]];
	for (int i=2; i<N; ++i) c = f[c][a[i]];
	puts(c == 0 ? "F" : "T");
}


Measured memory_bytes: 3088
import math

def fib(n):
  if n==1:
    return 1
  elif n<=0:
    return 0
  tmp1,tmp2=1,2
  for _ in range(n-2):
    tmp1,tmp2=tmp2,tmp1+tmp2
  return tmp2

n,m=map(int,input().split())
if m==0:
  print(fib(n)%1000000007)
  exit()
a=[int(input()) for _ in range(m)]
ans=1

if n==2 and a[0]==1:
  print(1)
  exit()

for i in range(m):
  if i==0 and a[0]==1:
    pass
  if i==0 and a[0]!=1:
    ans*=fib(a[i]-1)
  elif i>0 and a[i]-a[i-1]==2:
    pass
  elif i>0 and a[i]-a[i-1]!=2:
  	ans*=fib(a[i]-a[i-1]-2)
  ans%=1000000007
  
if n-a[-1]>1: 
  ans*=fib(n-a[-1]-1)
ans%=1000000007
print(ans)

Measured memory_bytes: 7096
n, l = map(int, input().split())
a = list(map(int, input().split()))

check_min = 0
index_min = n

for i in range(n-1):
    if check_min < a[i] + a[i+1]:
        check_min = a[i] + a[i+1]
        index_min = i

if check_min < l:
    print('Impossible')
else:
    print('Possible')
    for i in range(index_min):
        print(i+1)
    for i in range(n-2, index_min, -1):
        print(i+1)
    print(index_min+1)


Measured memory_bytes: 14060
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break

    cnt = 0

    for a in range(1, x // 3):
        for b in range(a + 1, x // 2):
            c = x - a - b
            if b < c <= n:
                cnt += 1

    print(cnt)


Measured memory_bytes: 5596
let n = read_int ()
let rec f n i j = if n < 10 then j else f (n / 10) (i + 1) @@ if n mod 10 = 9 then j else i + 1
let rec g s n i j = if n = 0 then s else g (s + if i = j then n mod 10 - 1 else if i > j then n mod 10 else 9) (n / 10) (i + 1) j
let _ = Printf.printf "%d\n" @@ g 0 n 0 @@ f n 0 ~-1

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

using namespace std;

typedef long long ll;

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

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

vector<bool> dp;

int main(void) {
    int X;
    cin >> X;

    dp.resize(X + 110, false);
    dp[0] = true;

    for (int i = 0; i < X; i++) {
        if (dp[i]) {
            dp[i + 100] = true;
            dp[i + 101] = true;
            dp[i + 102] = true;
            dp[i + 103] = true;
            dp[i + 104] = true;
            dp[i + 105] = true;
        }
    }

    if (dp[X]) {
        cout << "1" << endl;
    } else {
        cout << "0" << endl;
    }

    return 0;
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n) {
    cout << n * (n + 1) / 2 + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3136
H,W=(int(i) for i in input().split())
s = []
s.append('.'*(W+2))
for i in range(H):
    s.append('.'+input()+'.')
s.append('.'*(W+2))

ans ='Yes'
for i in range(1,H+1):
    for j in range(1,W+1):
        if s[i][j]=='#':
            if s[i-1][j]=='.' and s[i+1][j]=='.' and s[i][j-1]=='.' and s[i][j+1]=='.':
                ans = 'No'
                break

print(ans)

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] line = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();
		int[] locale = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();
		int[] dist = new int[line[1]];
		int ans =0;
		for (int i = 1; i < line[1]; i++) {
			dist[i - 1] = Math.abs(locale[i - 1] - locale[i]);
		}
		dist[line[1] - 1] = Math.abs(locale[line[1] - 1] - line[0]) + Math.abs(locale[0] - 0);

		Arrays.sort(dist);

		for (int i = 0; i < dist.length - 1; i++) {
			ans += dist[i];
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 72008
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int n,num,o;
int a[1000],f[200000];
int main()
{
scanf("%d",&n);
int num=1;
while (num<=n)
{
    o++;
    a[o]=num;
    num=num*9;
}
num=6;
while (num<=n)
{
    o++;
    a[o]=num;
    num=num*6;
}
f[0]=0;
for (int i=1;i<=n;i++)
    f[i]=10000000;
for (int i=1;i<=o;i++)
for (int j=a[i];j<=n;j++)
f[j]=min(f[j-a[i]]+1,f[j]);
printf("%d",f[n]);
    return(0);
}


Measured memory_bytes: 640
#include <stdio.h>

/*
380*5*0.8=1520
550*4*0.85=1870
850*3*0.88=2244
*/

int memo[3][51];

int tansaku(int pos,int nokori) {
	int i;
	int result=0x7fffffff;
	int nowresult;
	if(pos>=3)return (nokori==0)?0:0x10000000;
	if(memo[pos][nokori]>0)return memo[pos][nokori]-1;
	switch(pos) {
		case 0:
			for(i=0;nokori-i*2>=0;i++) {
				nowresult=tansaku(pos+1,nokori-i*2);
				nowresult+=1520*(i/5);
				nowresult+=380*(i%5);
				if(nowresult<result)result=nowresult;
			}
			break;
		case 1:
			for(i=0;nokori-i*3>=0;i++) {
				nowresult=tansaku(pos+1,nokori-i*3);
				nowresult+=1870*(i/4);
				nowresult+=550*(i%4);
				if(nowresult<result)result=nowresult;
			}
			break;
		case 2:
			for(i=0;nokori-i*5>=0;i++) {
				nowresult=tansaku(pos+1,nokori-i*5);
				nowresult+=2244*(i/3);
				nowresult+=850*(i%3);
				if(nowresult<result)result=nowresult;
			}
			break;
		default:
			return 0x10000000;
	}
	memo[pos][nokori]=result+1;
	return result;
}

int main(void) {
	int input;
	while(1) {
		scanf("%d",&input);
		if(input==0)break;
		input/=100;
		printf("%d\n",tansaku(0,input));
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(a) (a).begin(),(a).end()
#define PI 3.141592653589793238
#define INF 1050000000
#define INFL (long long)(4e18)

using vi = vector<int>;

template<class T>
struct Edge {
    int to;
    T cost;
    Edge() {};
    Edge(int to, T cost) : to(to), cost(cost) {};
};

template<class T>
class Graph {
    int n;
    bool directed;
    vector<vector<Edge<T>>> edges;
public:

    Graph(int n, bool directed) :n(n), directed(directed), edges(vector<vector<Edge<T>>>(n)){};
    Graph() {};

    void add(int from,int to, T cost) {
        edges[from].emplace_back(to, cost);
        if(!directed){
            edges[to].emplace_back(from,cost);
        }
    }

    int size() {
        return n;
    }
};


int main() {

    long long N,K;

    cin >> N >> K;

    vector<long long> A(N);

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

    vector<long long> V;

    vector<bool> visited(N);

    REP(i,N)visited[i] = false;

    long long a = 0;

    if(K<=N){
        int c = 0;
        while(K>c){
            a = A[a]-1;
            c++;
        }
        cout << a+1 << endl;
        return 0;
    }

    while(1){
        if(visited[a] == true)break;
        visited[a] = true;
        V.push_back(a);
        a = A[a]-1;
    }

    int c = 0;

    while(1){
        if(V[c] == a){
            break;
        }
        c++;
    }

    long long M = (K-c)%(V.size()-c);

    cout << V[c+M]+1 << endl;



}

Measured memory_bytes: 6896
#include <cstdio>
#include <algorithm>
#include <utility>
using namespace std;

int n,m;
pair<int,int> con[200],str[1000];

int main(){
	while(scanf("%d",&m), m != 0){
		for(int i = 0; i < m ; i++){
			scanf("%d%d",&con[i].first,&con[i].second);
		}
		scanf("%d",&n);
		for(int i = 0; i < n; i++){
			scanf("%d%d",&str[i].first,&str[i].second);
		}			
	
		sort(con,con+m);
		sort(str,str+n);
		
		pair<int,int> d;
		for(int i = 0; i < n; i++){
			int dx = str[i].first - con[0].first, dy = str[i].second - con[0].second;
			d = pair<int,int>(dx,dy);
			bool ok = true;
			for(int j = 1; j < m; j++){
				pair<int,int> rl(con[j].first + dx, con[j].second + dy);
				if(!binary_search(str,str+n,rl)){
					ok = false;
					break;
				}
			}
			if(ok){
				break;
			}
		}
		printf("%d %d\n",d.first,d.second);
	}
	return 0;
}

Measured memory_bytes: 2624
def main():
    target_num = input()
    target_list = list(map(int, input().split()))

    target_list.sort(reverse=True)

    result_a = 0
    result_b = 0
    a_flg = True
    for target in target_list:
        if a_flg:
            result_a += int(target)
            a_flg = False
        else:
            result_b += int(target)
            a_flg = True

    print(result_a - result_b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#define rep(n,i)  for(int i=0; i<(int)(n);i++)
#define all(v)  v.begin(),v.end()
using namespace std;

int jousu(int, int);
int jousu(int x, int y) {
	int z = 1;
	for (int i = 0; i < y; i++) {
		z *= x;
	}
	return z;
}
int kurai(int x, int y) {
	int z = (x%jousu(10,y)) / jousu(10, y-1);
	return z;
}
int keta(int x,int y) {
	int z = x;
	int w = 0;
	while (z != 0) {
		z /= y;
		w++;
	}
	return w;
}



int main() {
	int n, k;
	cin >> n >> k;
	cout << keta(n, k) << endl;
	
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main() {
  uint32_t N = 0;
  std::cin >> N;

  uint32_t max = 64;
  while (N < max) max /= 2;

  std::cout << max << std::endl;

  return 0;
}

Measured memory_bytes: 256
modulo=10**9+7
n, m=map(int, input().split())
a_list=[]
for i in range(m):
    a=int(input())
    a_list.append(a)
a_list.append(-1)
dp=[0 for i in range(n+1)]#0~n
dp[0]=1
if a_list[0]==1:
    dp[1]=0
    j=1
    for i in range(2, n+1):#10^5
        if i!=a_list[j]:
            dp[i]=(dp[i-2]+dp[i-1])%modulo
        else:
            j=j+1
else:
    dp[1]=1
    j=0
    for i in range(2, n+1):#10^5
        if i!=a_list[j]:
            dp[i]=(dp[i-2]+dp[i-1])%modulo
        else:
            j=j+1

print(dp[n]%modulo)


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int N;
vector<P> G[100000];
vector<bool> visit(100000, false);
vector<ll> dist(100000); // ある頂点から頂点Kまでの最短距離
int Q, K;

void dfs(int b, int c)
{
  visit[c] = true;
  REP(i, G[c].size())
  {
    int to = G[c][i].first;
    int d = G[c][i].second;
    if (to == b || visit[to])
      continue;
    dist[to] = dist[c] + d;
    dfs(c, to);
  }
}

int main()
{
  cin >> N;
  REP(i, N - 1)
  {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    a--, b--;
    G[a].push_back(P(b, c));
    G[b].push_back(P(a, c));
  }
  cin >> Q >> K;
  K--;
  dist[K] = 0;
  dfs(-1, K);
  REP(i, Q)
  {
    int x, y;
    cin >> x >> y;
    x--, y--;
    cout << dist[x] + dist[y] << endl;
  }
  return 0;
}

Measured memory_bytes: 17920
n=int(input())
s=list(input())
ls=[0 if i=='W' else 1 for i in s]
a=sum(ls)
#print(a)
l=[0]*n
for i in range(n):
    if ls[i]==1:
        a-=1
        l[i]=a
    elif ls[i]==0:
        a+=1
        l[i]=a-1
print(min(l))

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

#define pb push_back
#define PI 3.141592653589793238

int main()
{
	int n, m;
	cin>>n>>m;
	int sum = 0;
	for(int i = 0; i<m; i++)
	{
		int temp;
		cin>>temp;
		sum+=temp;
	}

	if(sum>n)
		cout<<-1<<endl;
	else
		cout<<n-sum<<endl;


}



Measured memory_bytes: 3616
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

const int N=1e4+100;
const int inf=1e9;
int dp[N];
int dig[N];
int mm[]={-1, 2,5,5,4,5,6,3,7,6};
bool here[12];
int p[N];
string s;

void solve(int n){
	FER(i,0,n+1)dp[i]=-inf;
	dp[0]=0;
	FER(i,1,n+1)FER(j,1,10)if(here[j]&&i-mm[j]>=0){
		if(dp[i-mm[j]]+1>=dp[i]){
			dp[i]=dp[i-mm[j]]+1;
			dig[i]=j;
			p[i]=i-mm[j];
		}
	}
}

void build(int n){
	while(n>0){
		s.pb(char(dig[n]+'0'));
		n=p[n];
	}
}

int main(){	
	fastio;
	int n;cin>>n;
	int m;cin>>m;
	FER(i,0,m){
		int k;cin>>k;
		here[k]=true;
	}
	memset(dp,-1,sizeof(dp));
	solve(n);
	build(n);
	//sort(s.rbegin(),s.rend());
	cout<<s<<endl;
	return 0;
}


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

int main(void)
{
    long N, K;
    cin >> N >> K;

    vector<int> h(N);
    for (int i = 0; i < N; i++) {
        cin >> h.at(i);
    }
    int count = 0;
    for (int x : h) {
        if (x >= K) {
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <climits>
#include <cmath>
#include <set>
#include <map>
#include <sstream>
#include <queue>
#include <stack>
#pragma GCC optimize(2)
using namespace std;

int main(){
	string s,t;
	cin>>s>>t;
	s=t+s;
	cout<<s;
	return 0;
}

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

typedef enum
{
	true = 1,
	false = 0
} bool;

void swap(int *xp, int *yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}

void sort(int arr[], int n)
{
   int i, j;
   for (i = 0; i < n-1; i++)  
       for (j = 0; j < n-i-1; j++) 
           if (arr[j] > arr[j+1])
              swap(&arr[j], &arr[j+1]);
}

bool isSub(char* a, char* b)
{
	for (int i = 0; a[i]; i++)
	{
		for (int j = 0; b[j]; j++)
		{
			if (a[j + i] != b[j])
				goto end;
			if (!a[i + j])
				return false;
		}
		return true;
		end:
		continue;
	}
	return false;
}

int main()
{
	char a[400], b[200];
	scanf("%s %s", a, b);
	int n = strlen(a);
	for (int i = 0; i < n; i++)
	{
		a[n + i] = a[i];
	}
	a[2*n] = '\0';
	
	if (isSub(a, b)) puts("Yes");
	else puts("No");
	
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int ans=0;
    string str;
    cin>>n;
    cin>>str;
    for(int i=0;i<n;++i){
        string str2;
        cin>>str2;
        bool flg=false;
        for(int j=0;j<str2.size();++j){
            for(int k=1;k<=str2.size()/2;++k){
                int num=1;
                int t=k;
                for(int l=0;l<str.size();++l){
                    if(str[0]==str2[j]){
                        if(t+j<=str2.size()){
                            //cout<<str[num]<<" "<<str2[t+j]<<" "<<t<<" "<<j<<endl;
                            if(str[num]==str2[j+t]){
                                num++;
                                t+=k;
                            }
                            else{
                                break;
                            }
                            if(num==str.size()&&!flg){
                                //cout<<"succes "<<k<<" "<<j<<" "<<t<<endl;
                                ans++;
                                flg=true;
                                break;
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;
#define f first
#define s second
#define int long long
#define dear_crush int32_t main()
#define bari_ja return 0
#define forn(i, n) for (int i = 0; i < n; i++)
#define INF 1e9+5
dear_crush
{

int n,W;

std::cin >> n>>W;

int wt[n];
int val[n];

forn(i, n){
	std::cin >> wt[i]>>val[i];
}

//n = sizeof(val)/sizeof(val[0]);
//cout<<n<<endl;
int K[n+1][W+1];

for(int i=0; i<=n; i++){

	for(int w=0; w<=W; w++){

		if(i==0 || w==0)
		K[i][w]=0;

		else if(wt[i-1]<=w)
		K[i][w] = max(K[i-1][w], K[i-1][w-wt[i-1]]+val[i-1]);

		else
		K[i][w]=K[i-1][w];
	}
}

cout<<K[n][W]<<endl;
return 0;
}


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

namespace ABC090 {
	class ABC090_A {
		static void Main(string[] args) {
			var input = new char[3][];
			for (int i = 0; i < input.Length; i++) {
				input[i] = Console.ReadLine().ToArray();
			}
			var sb = new StringBuilder();
			for (int i = 0; i < input.Length; i++) {
				sb.Append(input[i][i]);
			}
			Console.WriteLine(sb.ToString());
		}
	}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<int> dp(n+5, n);
  rep(i,n+5) dp[i] = i;
  for (int i = 0; i <= n; ++i) {
    for (int six = 6; i+six <= n; six*=6) {
      chmin(dp[i+six], dp[i]+1);
    }
    for (int nine = 9; i+nine <= n; nine*=9) {
      chmin(dp[i+nine], dp[i]+1);
    }
  }
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

vector<int> G[100];

int main() {
    int n;
    cin >> n;
    string s[n];
    rep(i,n)cin >> s[i];
    ll a[n], t[n], f[n], c[n];
    rep(i,n){
        a[i] = 0;
        t[i] = 0;
        f[i] = 0;
        c[i] = 0;
        int m = s[i].size();
        int flag = 0;
        rep(j,m){
            if(s[i][j] == '.'){
                flag = 1;
            }else{
                if(flag == 1){
                    c[i]++;
                }
                a[i] *= 10;
                a[i] += s[i][j] - '0';
            }
        }
        while(a[i] % 2 == 0){
            t[i]++;
            a[i] /= 2;
        }
        while(a[i] % 5 == 0){
            f[i]++;
            a[i] /= 5;
        }
        t[i] -= c[i];
        f[i] -= c[i];
        G[f[i]+50].push_back(t[i]);
        // cout << t[i] << ' ' << f[i] << endl;
    }

    rep(i,100)sort(G[i].begin(), G[i].end());

    ll ans = 0;

    rep(i,n){
        rep(j,100){
            if(G[j].size() == 0) continue;
            if(-(50-j)+f[i]<0) continue;
            ll mm = G[j].size();
            ll tmp = mm - (lower_bound(G[j].begin(),G[j].end(),-t[i]) - G[j].begin());
            /*
            if(tmp > 0){
                cout << i << ' ' << j << ' ' << tmp << endl;
            }
            */
            ans += tmp;
        }
        if(t[i]>=0&&f[i]>=0)ans--;
    }
    ans /= 2;
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 16920
import Foundation
var count = 0
let N = Int(readLine()!)!
for i in 0 ... N/4+1 {
    for j in 0 ... N/7+1 {
        if 4*i + 7*j == N {
            count += 1
        }
    }
}
if count == 0 {
    print("No")
} else {
    print("Yes")
}

Measured memory_bytes: 13072
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	vector<int> Nums;
	int now = 1;
	int cnt = 0;
	for(int i = 0; i < N; i++){
		if(S[i] == (char)('0' + now)){
			cnt++;
		} else {
			Nums.push_back(cnt);
			now = 1 - now;
			cnt = 1;
		}
	}
	if(cnt != 0) Nums.push_back(cnt);
	if(Nums.size() % 2 == 0) Nums.push_back(0);

	int Add = 2 * K + 1;
	vector<int> sum(Nums.size() + 1);
	for(int i = 0; i < Nums.size(); i++){
		sum[i + 1] = sum[i] + Nums[i];
	}

	int ans = 0;

	for(int i = 0; i < Nums.size(); i += 2){
		int left = i;
		int right = min(i + Add, (int)Nums.size());
		int tmp = sum[right] - sum[left];
		ans = max(tmp, ans);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1272
#include <stdio.h>
#include <math.h>
#define PI 3.14159265358

int main(void){
    double a, b, hour, minute, radh, radm, rad, ans;
    scanf("%lf %lf %lf %lf", &a, &b, &hour, &minute);
    radh = 2 * PI * (hour + minute / 60) / 12;
    radm = 2 * PI * minute / 60;
    rad = (radh - radm < PI) ? radh - radm : radm - radh;
    
    ans = sqrt(a * a + b * b - 2 * a * b * cos(rad));
    printf("%.10lf", ans);
    return 0;
}

Measured memory_bytes: 2544
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>

struct pair {
	int u;
	int v;
	int w;
};

const int mod = 1000000007;
pair *p;
int *c;
std::vector<pair*> *a;

void check(int n) {
	for (int i = 0; i < a[n].size(); i++) {
		if (a[n][i]->u == n) {
			if (c[a[n][i]->v] == -1) {
				c[a[n][i]->v] = (c[n] + a[n][i]->w) % 2;
				check(a[n][i]->v);
			}
		}
		else {
			if (c[a[n][i]->u] == -1) {
				c[a[n][i]->u] = (c[n] + a[n][i]->w) % 2;
				check(a[n][i]->u);
			}
		}
	}
}

int main() {
	int N;
	scanf("%d", &N);
	p = new pair[N - 1];
	c = new int[N];
	a = new std::vector<pair*>[N];
	for (int i = 0; i < N - 1; i++) {
		scanf("%d %d %d", &p[i].u, &p[i].v, &p[i].w);
		p[i].u--;
		p[i].v--;
		a[p[i].u].push_back(&p[i]);
		a[p[i].v].push_back(&p[i]);
	}
	for (int i = 0; i < N; i++) {
		c[i] = -1;
	}
	c[0] = 0;
	check(0);
	for (int i = 0; i < N; i++) {
		printf("%d\n", c[i]);
	}
}





Measured memory_bytes: 9216
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    ll n,k;cin>>n>>k;
    dump(n, k);
    vector<ll> a(n+1);
    rep(i, n) {
        cin>>a[i];
    }
    dump(a);

    while(k--){
        dump(k);
        vl b(n+1);
        rep(i, n){
            b[max(0LL, i-a[i])]++;
            b[min(n,   i+a[i]+1)]--;
        }
        rep(i, 1, n+1) b[i] += b[i-1];
        a = b;
        dump(a);
        if (accumulate(all(a), 0LL) == n * n) {
            break;
        }
    }
    rep(i, sz(a)-1) cout << a[i] << (i!=sz(a)-2 ? " " : "\n");

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 100000000000

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

	ll N;
	cin >> N;

	vector<ll> L(N);
	rep(i, N) {
		cin >> L[i];
	}

	sort(ALL(L));

	ll ans = 0;
	ll a, b, c;

	rep(i, N) {
		rep(j, N-i-1) {
			b = L[i];
			c = L[i+j+1];
			auto itr1 = upper_bound(ALL(L), c-b);
			a = itr1 - L.begin();
			ans += max((ll)0, i - a);
		}
	}

	cout << ans << "\n";

	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    string n;
    cin >> n;
    string ans = "NA";
    bool mb = false, ub = false;
    int mae = stoi(n.substr(0, 2));
    int usiro = stoi(n.substr(2, 2));
    if (1 <= mae && mae <= 12)mb = true;
    if (1 <= usiro && usiro <= 12)ub = true;
    if (mb && ub)ans = "AMBIGUOUS";
    else if (mb)ans = "MMYY";
    else if (ub)ans = "YYMM";

    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int A, B;
	cin >> A >> B;
	
	for (int x = B - A + 1; x <= B + A - 1;x++) {
		cout << x << ' ';
	}

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (T i : v) os << i << ' ';
    return os;
}
void co() { cout << endl; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << endl; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1000000001;
constexpr ll LINF = 1000000000000000001;
constexpr ll MOD = 1000000007;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void) {
    ll n, m;
    cin >> n >> m;
    scc_graph scc(n);
    while (m--) {
        ll a, b;
        cin >> a >> b;
        scc.add_edge(a, b);
    }

    auto v = scc.scc();
    co(v.size());
    for (auto i : v) co(i.size(), i);

    return 0;
}

Measured memory_bytes: 41080
#include <iostream>

using namespace std;

int main() {
	// write your code here
	string s1, s2;
	cin >> s1 >> s2;

	if (s1[0] == s2[2] && s1[2] == s2[0] && s1[1] == s2[1]) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}

	return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void in(T&t){cin>>t;}
template<class T,class... Ts>inline void in(T&t,Ts&...ts){cin>>t;in(ts...);}
template<class T>inline void out(T t){cout<<t<<endl;}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout<<t<<" ";out(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill(T&t,const V&v){for(auto &e:t)fill(e,v);}
constexpr long long INF = 1e18;

signed main(){
	int N,M;
	in(N,M);
	auto ac = mv(N);
	fill(ac,-1);
	auto wa = mv(N);
	int ans = 0;
	REP(i,M){
		int t;
		string s;
		in(t,s);
		t--;
		if(s == "AC"){
			if(ac[t]==-1)ac[t]=wa[t];
		}else{
			wa[t]++;
		}
	}
	int wanum = 0;
	REP(i,N)if(ac[i]!=-1){ans++;wanum+=ac[i];}
	out(ans,wanum);
}

Measured memory_bytes: 1792