akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class BGoodDistance
    {
        static void Main(string[] args)
        {
            var nd = Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToList();
            int n = nd[0];
            int d = nd[1];

            var xList = new List<List<int>>();
            for (int i = 0; i < n; i++)
            {
                xList.Add(Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToList());
            }

            int answerCount = 0;
            for (int i = 0; i < xList.Count; i++)
            {
                for (int j = 0; j < xList.Count; j++)
                {
                    if (j <= i) { continue; }

                    double distance = 0;
                    for (int k = 0; k < d; k++)
                    {
                        distance += Math.Pow(xList[i][k] - xList[j][k], 2.0);
                    }
                    distance = Math.Sqrt(distance);

                    if ((int)distance == distance)
                    {
                        answerCount++;
                    }
                }
            }

            Console.WriteLine(answerCount);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11348
#include <stdio.h>

#define max 100005
#define nil -1

typedef struct { int p, l, r;} Node;

Node T[max];
int n, D[max];


void print(int u) {
    int i,c;
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].p);
    printf("depth = %d, ",D[u]);
    
    if( T[u].p == nil ) printf("root, ");
    else if( T[u].l == nil ) printf("leaf, ");
    else printf("internal node, ");
    
    printf("[");
    
    for(i=0, c=T[u].l; c != nil; i++, c=T[c].r) {
        if(i) printf(", ");
        printf("%d",c);
    }
    printf("]\n");
}

void rec(int u, int p) {
    D[u] = p;
    if(T[u].r != nil) rec(T[u].r,p);
    if(T[u].l != nil) rec(T[u].l,p+1);
}

int main(void) {
    int i,j,d,v,c,l,r;
    scanf("%d",&n);
    for(i=0;i<n;i++) T[i].p = T[i].l = T[i].r = nil;
    for(i=0;i<n;i++) {
        scanf("%d %d",&v,&d);
        for(j=0;j<d;j++) {
            scanf("%d",&c);
            if(j==0) T[v].l=c;
            else T[l].r =c;
            l = c;
            T[c].p = v;
        }
    }
    for(i=0;i<n;i++) {
        if(T[i].p == nil) r = i;
    }
    
    rec(r,0);
    
    for(i=0;i<n;i++) print(i);
    
    return 0;
}



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

int main() {

  int n;
  cin >> n;
  int k;
  cin >> k;
  vector<int> tree(n);
  for(int i=0; i<n; i++) cin >> tree.at(i);
  
  sort(tree.begin(),tree.end());
  
  int ans=1000000001;
  for(int i=0; i<n-k+1; i++) {
    ans=min(ans, tree.at(k-1+i)-tree.at(i));
  }
  
  cout << ans << endl;
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#include <unordered_set>

#define _USE_MATH_DEFINES
#include <math.h>


#include <vector>
#include <list>

#include <set>
#include <map>

#include <unordered_map>

#include <queue>
#include <stack>

#include <string>

#include <vector>

#define sqr(x) (x) * (x)

#include <algorithm>
#include <functional>

#include <bitset>

#include <functional>

#include <chrono>

typedef unsigned int u32;
typedef int i32;

typedef unsigned long long int u64;
typedef long long int i64;

typedef uint16_t u16;
typedef int16_t i16;

typedef uint8_t u8;
typedef int8_t i8;


using namespace std;
using namespace std::chrono;

struct less_key
{
    bool operator() (pair<i64, i64> p1, pair<i64, i64> p2)
    {
        return p1.first > p2.first || (p1.first == p2.first && p1.second < p2.second);
    }
};

struct pair_hash {
public:
    std::size_t operator()(const std::pair<u64, u64> &x) const
    {
        return std::hash<u64>()(x.first) ^ std::hash<u64>()(x.second);
    }
};
#include <random>

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

// del

const i64 MAXN = 100005;

i64 n;
vector<pair<string, pair<i64, i64>>> a;


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> n;

    for (i64 i = 0; i < n; i++) {
        string s;
        i64 r;
        cin >> s >> r;

        a.push_back({ s, {-r, i + 1} });
    }

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

    for (auto t : a) {
        cout << t.second.second << endl;
        //cout << t.first << " " << -t.second << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
   int n;
   cin >>n;
   vector<pair<int ,int>> a(n);
   for(int  i=0;i<n;i++){
     int  aa ,b;
     cin >> aa >> b;
     a.at(i)=make_pair(aa,b);
   }
   double z=0.000;

      for(int i=0;i<n;i++){
     for(int j=i+1;j<n;j++){
        z += pow(pow(a.at(i).first-a.at(j).first,2)+pow(a.at(i).second-a.at(j).second,2),0.5);
        
     }
   }
 z*=(n+(n-2));
 z/=n;
 z/=(n-1);
cout << fixed << setprecision(10);
 cout << z << endl;



 }


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

int main()
{
    int n,i,mod;
    long long int ans=1;
    mod=(int)(pow(10,9)+0.05+7);
    scanf("%d",&n);
    for(i=2;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int N, D; cin >> N >> D;
    int res = N / (1 + D + D);
    if (N % (1 + D + D) == 0) cout << res << endl;
    else cout << res + 1 << endl;
}


Measured memory_bytes: 256
/*
гонфлад
*/
#pragma ARCENIY_KIRILLOV_UVIDEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rep(i, n) for (int i = 0; i < n; i++)
#define per(i, n) for (int i = n - 1; i > -1; i--)
#define rer(i, x, n) for (int i = x; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef long double ld;
const int mod = 1e9 + 7;

main(){
    int h, w;
    cin >> h >> w;
    char c[h][w];
    int dp[h + 1][w + 1];
    for (int i = 0; i <= h; i++){
        for (int j = 0; j <= w; j++){
            if (i < h && j < w)
                cin >> c[i][j];
            dp[i][j] = 0;
        }
    }

    dp[h-1][w-1] = 1;
    for (int i = h - 1; i > -1; i--){
        for (int j = w - 1; j > -1; j--){
            if (c[i][j] == '#') continue;
            if (c[i+1][j] == '.'){
                if (c[i][j+1] == '.')
                    dp[i][j] = (dp[i + 1][j] + dp[i][j + 1])%mod;
                else
                    dp[i][j] = dp[i+1][j];
            }else{
                if (c[i][j+1] == '.')
                    dp[i][j] = dp[i][j + 1];
            }
        }
    }
    cout << dp[0][0];

}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, count = 0;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=1;i<n;i++){
        if(a[i-1] == a[i]){
            if(i != n-1) {a[i] = a[i+1] + 1;}
            count++;
        }
    }
    cout << count << endl;
}

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

string S[2000];
int x[2000][2000];
int z[2000][2000];
queue<int> Q;
queue<int> R;

int main() {
	int n, m;
	char T[10] = { '.','1','2','3','4','5','6','7','8','9' };
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
		for (int j = 0; j < m; j++) {
			for (int k = 0; k < 10; k++) {
				if (S[i][j] == T[k]) {
					x[i][j] = k;
				}
			}
		}
	}
	int t = 1;
	int p = 0;
	int sum = 0;
	memset(z, 0, sizeof(z));
	t = 0;
	sum++;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (x[i][j] >= 1) {
				p = 0;
				for (int k = -1; k <= 1; k++) {
					for (int l = -1; l <= 1; l++) {
						if (x[i + k][j + l] == 0) {
							p++;
						}
					}
				}
				if (p >= x[i][j]) {
					z[i][j] = 1;
					Q.push(i * 1000 + j);
				}
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (z[i][j] == 1) {
				x[i][j] = 0;
			}
		}
	}

	int c, d;

	while (sum==0 || !Q.empty()) {
		sum++;
		while (!Q.empty()) {
			c = Q.front() / 1000;
			d = Q.front() % 1000;
			for (int i = -1; i <= 1; i++) {
				for (int j = -1; j <= 1; j++) {
					if (x[c + i][d + j] >= 1) {
						p = 0;
						for (int k = -1; k <= 1; k++) {
							for (int l = -1; l <= 1; l++) {
								if (x[c + i + k][d + j + l]==0) {
									p++;
								}
							}
						}
						if (p >= x[c + i][d + j] && x[c + i][d + j] != 10) {
							x[c + i][d + j] = 10;
							R.push((c + i) * 1000 + (d + j));
						}
					}
				}
			}
			Q.pop();
		}
		while (!R.empty()) {
			c = R.front() / 1000;
			d = R.front() % 1000;
			x[c][d] = 0;
			Q.push(R.front());
			R.pop();
		}
	}

	cout << sum-1 << endl;
	return 0;
}

Measured memory_bytes: 27572
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int n, c, k;
int t[100010];
signed main() {
    cin >> n >> c >> k;
    rep(i,0,n) cin >> t[i];
    sort(t, t+n, greater<int>());

    int cur = -1;
    int pp = 0, ans = 0;
    rep(i,0,n) {
        if(cur == -1 || cur - k > t[i]) {
            // printf("debug: i = %lld, val = %lld\n", i, t[i]);
            ans++;
            cur = t[i];
            pp = 1;
        }
        else {
            // printf("pass: i = %lld, val = %lld\n", i, t[i]);
            pp++;
        }

        if(pp == c) {
            cur = -1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int counter[101] = {0};

int main(){
	int e;
	for(int i = 0; i < 12;i++){
		scanf("%d",&e);
		counter[e]++;
	}
	bool ok = true;
	for(int i = 1; i <= 100; i++){
		if(counter[i] % 4 != 0){
			ok = false;
		}
	}
	printf("%s\n", ok ? "yes" : "no");
	return 0;
}



Measured memory_bytes: 2628
#include <iostream>
#include <assert.h>
#include <vector>
#include <algorithm>
//#include <functional>
//#include <cmath>

int main(){
    int64_t L,R;
    std::cin >> L >> R;

    //i*j mod 2019 = (i mod 2019 * j mod 2019) mod 2019
    //if R >= ((L / 2019) + 1 ) * 2019 -> min(i*j mod 2019) = 0
    //else min(i*j mod 2019) = L*(L+1) / mod 2019
    int64_t div = L / 2019;
    int64_t next_mod = (div + 1) * 2019;
    if(R >= next_mod){
        std::cout << 0;
    }
    else{
        int64_t min_mod = 2019;
        for(int64_t i = L; i < R; i++){
            for(int64_t j = i + 1; j <= R; j++){
                min_mod = std::min(min_mod, (i * j) % 2019);
                if(min_mod == 0){
                    std::cout << 0;
                    return 0;
                }
            }
        }
        std::cout << min_mod;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(2e2 + 5);
const int W = (int)(1e5 + 5);
const int LOG = (int)(20);

int n, wl;
lli dp[N][W], w[N], v[N];

lli f(int x, int we) {
	if(we > wl)
		return INT_MIN;
	if(dp[x][we] != -1)
		return dp[x][we];
	if(x == n + 1)
		return 0;
	return dp[x][we] = max(f(x + 1, we + w[x]) + v[x], f(x + 1, we));
}

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);
	
	memset(dp, -1, sizeof dp);
	cin >> n >> wl;
	for(int i = 1; i <= n; i++)
		cin >> w[i] >> v[i];
	cout << (f(1, 0));
}

Measured memory_bytes: 160512
H, W = map(int, input().split())
s_list = []
for i in range(H):
    s = list(input())
    s_list.append(s)
direction = [[-1, 0], [0, -1], [1, 0], [0, 1]]
for i in range(H):
    for j in range(W):
        if s_list[i][j]=="#" :
            ans = "No"
            for x,y in direction:
                if 0 <=i+x<= H-1 and 0 <=j+y<= W-1 and s_list[i+x][j+y]=="#":
                    ans = "Yes"
            if ans=="No":
                print(ans)
                exit()
print("Yes")

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

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

    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    string ans;
    while(true){
        C-=B;
        A-=D;
        if(C<=0){
            ans = "Yes";
            goto output;
        }
        if(A<=0){
            ans = "No";
            goto output;
        }
        

    }

    output:
    cout<<ans<<"\n";

	
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int determinant(int n) {
	int i = 0;
	while (1) {
		i++;
		if (i * 400 > n) {
			return i - 1;
		}
		else if (i * 400 >= 3200) {
			return 10;
		}
	}
}
int main() {
	int n;
	cin >> n;
	vector<int>color(8);
	int all = 0;
	rep(i, n) {
		int co;
		cin >> co;
		int j = determinant(co);
		if (j == 10) {
			all++;
		}
		else {
			color[j]++;
		}
	}
	int count = 0;
	rep(i, 8) {
		if (color[i] > 0) {
			count++;
		}
	}
	int Min = count;
	if (count == 0 && all > 0) {
		Min++;
	}
	int Max =  count + all;
	cout << Min << " " << Max << endl;
}

Measured memory_bytes: 256
import math
import sys

pena=0
N,M=map(int,input().split())
AClist=[0]*N
penalist=[0]*N
for i in range(M):
    pm,sm=input().split()
    pm=int(pm)
    if sm=="AC":
        AClist[pm-1]=1
    else:
        if AClist[pm-1]==0:
            penalist[pm-1]+=1
for i in range(N):
    if AClist[i]==1:
        pena+=penalist[i]



print(AClist.count(1),pena)


Measured memory_bytes: 45688
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, long long> P; // {to, cost}

int n;
const int N = 100010;
vector<P> G[N];
vector<int> Color(N);

void dfs(int now, int pre, int color, long long acost){ // accumlate_cost
    Color[now] = color; 
    for(int i = 0; i < G[now].size(); i++){
        P p = G[now][i];
        if(p.first == pre) continue;
        long long to_acost = p.second + acost;
        if(to_acost % 2 == acost % 2 ) dfs(p.first, now, color, to_acost);
        else dfs(p.first, now, (color == 1 ? 0 : 1), to_acost);
    }
}


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

    cin >> n;
    for(int i = 0; i < n - 1; i++){
        int a, b;
        long long c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }
    
    Color.resize(n);
    
    dfs(0, -1, 1, 0);

    for(int i = 0; i < n; i++){
        cout << Color[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 11392
#include <iostream>

using namespace std;

int main(){
  int c[3][3];

  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>c[i][j]; 
    } 
  }

  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      if((c[i][j]-c[i+1][j])!=(c[i][j+1]-c[i+1][j+1])){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  for(int i=0;i<2;i++){
    if((c[0][i]-c[2][i])!=(c[0][i+1]-c[2][i+1])){
      cout<<"No"<<endl; 
      return 0;
    } 
  }

  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      if((c[j][i]-c[j][i+1])!=(c[j+1][i]-c[j+1][i+1])){
        cout<<"No"<<endl; 
        return 0;
      } 
    } 
  }

  for(int i=0;i<2;i++){
    if((c[i][0]-c[i][2])!=(c[i+1][0]-c[i+1][2])){
      cout<<"No"<<endl;
      return 0;
    }
  }

  cout<<"Yes"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int n, m, q;
vector<int> a, b, c, d;

ll calc_score(const vector<int> &x){
    ll res = 0;
    for(int i=0; i<q; i++){
        if(x[b[i]] - x[a[i]] == c[i]) res += d[i];
    }
    return res;
}

ll dfs(vector<int> &A){
    if(A.size() == n){
        return calc_score(A);
    }

    ll res = 0;
    int last = (A.empty() ? 0 : A.back());
    for(int i=last; i<m; i++){
        A.push_back(i);
        res = max(res, dfs(A));
        A.pop_back();
    }
    return res;
}

int main(void){
    
    cin >> n >> m >> q;
    a.resize(q); b.resize(q); c.resize(q); d.resize(q);
    for(int i=0; i<q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }

    vector<int> zzz;
    cout << dfs(zzz) << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>

int main(){
   std::string S;
   std::cin >> S;
   std::string ref0, ref1;
   for (int i=0; i<S.size(); i++){
      std::string temp0, temp1;
      if (i%2 == 0){
         temp0 = "0";
         temp1 = "1";
      } else{
         temp0 = "1";
         temp1 = "0";
      }
      ref0 = ref0 + temp0;
      ref1 = ref1 + temp1;
   }
   int cnt0 = 0, cnt1 = 0;
   for (int i=0; i<S.size(); i++){
      if (S.at(i) != ref0.at(i)){
         cnt0++;
      }
      if (S.at(i) != ref1.at(i)){
         cnt1++;
      }
   }
   if (cnt0 < cnt1)
      std::cout << cnt0 << std::endl;
   else
      std::cout << cnt1 << std::endl;
}



Measured memory_bytes: 904
#include<bits/stdc++.h>
#define ll long long int
#define pii <pair<ll,ll>>
using namespace std;

void solve()
{
    ll a,b,c;
    cin >> a >> b >> c;
    ll d=b+c;
    if(d<=a)
    {
        cout << "0" << endl;
    }
    else
    {
        cout << d-a << endl;
    }
}

int main()
{
     solve();
     return 0;
}


Measured memory_bytes: 256
S = input()
mod = [0 for _ in range(len(S))]
mod[0] = int(S[-1])
for i in range(1, len(S)):
    mod[i] = (mod[i - 1] + pow(10, i, 2019) * int(S[-1 - i])) % 2019
ans = 0
res = [0 for _ in range(2019)]
for i in range(len(S)):
    ans += res[mod[i]]
    res[mod[i]] += 1
print(ans + res[0])

Measured memory_bytes: 87248
#include<bits/stdc++.h>
using namespace std;
const int B=1000;
char latte[3000001];
string s[100000],_s[100000];
int n;
struct data{
    int id,l,r;
    data(int a,int b,int c):id(a),l(b),r(c){}
};

vector<data>v[100000];

void get(int a,int b,int &cur,int &sum){
    sum=cur=0;
    while(cur<(int)v[a].size()&&b-sum>=v[a][cur].r-v[a][cur].l){
        sum+=v[a][cur].r-v[a][cur].l;
        cur++;
    }
}


void div(int a,int b,vector<data>&X){
    int cur,sum;
    get(a,b,cur,sum);
    for(int i=(int)v[a].size()-1;i>cur;i--){
        //if(v[a].size()==0)continue;
        X.push_back(v[a].back());
        v[a].pop_back();
    }
    if(b==sum){
        //if(v[a].size()==0)return;
        X.push_back(v[a].back());
        v[a].pop_back();
    }
    else{
    //if(v[a].size()==0)return;
        data d=v[a].back();v[a].pop_back();
        v[a].push_back(data(d.id,d.l,d.l+b-sum));
        X.push_back(data(d.id,d.l+b-sum,d.r));
    }
}

void query1(){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    a--;b--;c--;d--;

    vector<data>X,Y;

    div(a,b,X);
    div(c,d,Y);

    for(int i=(int)Y.size()-1;i>=0;i--)v[a].push_back(Y[i]);
    for(int i=(int)X.size()-1;i>=0;i--)v[c].push_back(X[i]);
}

void query2(){
    int a,b;char c;
    scanf("%d%d %c",&a,&b,&c);
    a--;b--;

    int cur,sum;
    get(a,b,cur,sum);
    //if(cur>=v[a].size())return;
    int id=v[a][cur].id;
    int l=v[a][cur].l;
    int r=v[a][cur].r;
    //if(b-sum+l>=s[id].size())return;
    s[id][b-sum+l]=c;
}

void update(int query){
    for(int i=0;i<n;i++)v[i].clear();
    for(int i=0;i<n;i++)v[i].push_back(data(i,0,s[i].size()));

    for(int qry=0;qry<query;qry++){
        int type;scanf("%d",&type);
        if(type==1)query1();
        else query2();


    }



    for(int i=0;i<n;i++){
        _s[i]="";
        for(int j=0;j<v[i].size();j++){
            int id=v[i][j].id,l=v[i][j].l,r=v[i][j].r;
            if(r-l+l>s[id].size())continue;
            _s[i]+=s[id].substr(l,r-l);
        }
    }

    for(int i=0;i<n;i++)s[i]=_s[i];

}
int main(){
    int q;
    scanf("%d%d",&n,&q);
    for(int i=0;i<n;i++){
        scanf("%s",latte);
        s[i]=latte;
    }

    for(int i=0;i<(q+B-1)/B;i++){
        update(min(B,q-i*B));
    }
    for(int i=0;i<n;i++)printf("%s\n",s[i].c_str());

    return 0;
}

Measured memory_bytes: 18312
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nk = readln.split.to!(int[]);
    auto N = nk[0];
    auto K = nk[1];

    double r = 0;
    foreach (n; 1..(N+1)) {
        double x = 1.0 / N.to!double;
        while (n < K) {
            n *= 2;
            x /= 2;
        }
        r += x;
    }
    writefln("%0.12f", r);
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
using namespace std;
int main(){
	string a;
	cin>>a;
	char d,b;
	d=a[0];
	b=a[a.size()-1];
	a.erase(0,1);
	a.erase(a.size()-1,1);
	cout<<d<<a.size()<<b;   
	return 0;
}

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

int main(){
    int n,ave;
    cin >> n >> ave;
    vector<int> x(n);
    for(int i=0; i<n; i++){
        cin >> x.at(i);
        x.at(i) -= ave;
    }
    vector<vector<ll>> dp(n,vector<ll>(5000,0));
    dp.at(0).at(x.at(0)+2500)++;
    dp.at(0).at(2500)++;
    for(int j=1; j<n; j++){
        for(int k=0; k<5000; k++){
            dp.at(j).at(k) += dp.at(j-1).at(k);
            if(k-x.at(j)>=0 && k-x.at(j)<5000){
                dp.at(j).at(k) += dp.at(j-1).at(k-x.at(j));
            }
        }
    }
    /*
    for(int i=0; i<10; i++){
        for(int j=2500; j<2501; j++){
            cout << dp.at(i).at(j) << " ";
        }
        cout << endl;
    }*/
   cout << dp.at(n-1).at(2500) -1 << endl;
}

Measured memory_bytes: 5268
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <unordered_map>
#include <complex>
#include <algorithm>

using namespace std;
using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using i32 = int_fast32_t;
using u32 = uint_fast32_t;

#define int i64

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; }
const int INF = 1LL << 60;
const int MOD = 1e9 + 7;
const int MAX = 2 * 1e5 + 10;

int modpow(int a, int n, int mod) {
    int res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int modInverse(int n, int p) { 
    return modpow(n, p-2, p); 
} 
  
int nCrModP(int n, int r, int p) { 
   if (r==0) 
      return 1; 
  
   vector<int> fac(n + 1);
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 

static int C(int n, int r, int p) {
	int ret = 1;
	while(true){
		if(r == 0)break;
		int N = n % p;
		int R = r % p;
		if(N < R)return 0;
 
		for(int i = 0;i < R;i++){
			ret = ret * (N-i) % p;
		}
		int imul = 1;
		for(int i = 0;i < R;i++){
			imul = imul * (i+1) % p;
		}
		ret = ret * modInverse(imul, p) % p;
		n /= p; r /= p;
	}
	return ret;
}

signed main() {
	int n, a, b;
	cin >> n >> a >> b;

	int res = (modpow(2, n, MOD) - 1) % MOD;

	int cna = C(n, a, MOD);
	int cnb = C(n, b, MOD);

	res = (res + MOD - cna) % MOD;
	res = (res + MOD - cnb) % MOD;

	cout << res << endl;
	
	return 0;
}


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

using namespace std;


int main(){
    
    int N,M;
    cin >> N;
    vector<int> S(N,0);

    for(int i{0}; i < N; i++){
        cin >> S[i];
    }
    int count = 0;
    int temp;

    cin >> M;
    
    for(int i{0}; i<M ;i++){
        cin >> temp;
        for(int k{0}; k<N ;k++){
            if(S[k]==temp){
                count ++;
                break;
            }
        }
    }
    
    cout << count << endl;

}


Measured memory_bytes: 3108
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
struct P : IEquatable<P>
{
	public readonly int Player, Left, Card;
	public P(int p, int q, int r) { Player = p; Left = q; Card = r; }
	public bool Equals(P p) => Player == p.Player && Left == p.Left && Card == p.Card;
	public override bool Equals(object obj) => obj is P && Equals((P)obj);
	public override int GetHashCode() => Player.GetHashCode() ^ Left.GetHashCode() ^ Card.GetHashCode();
}
class K
{
	int[] G() => ReadLine().Split().Select(int.Parse).ToArray();
	public K()
	{
		a = G();
		N = a[0];
		Y = a[2];
		a = G();
		WriteLine(Calc(0, 0, Y));
	}
	int N, Y;
	readonly int[] a;
	readonly Dictionary<P, int> memo = new Dictionary<P, int>();
	readonly Func<int, int, int>[] c = { Max, Min };
	// 次に p さんがカードを引き, a[q], ..., a[N - 1] のカードが残っていて,
	// p さんでないプレイヤーは r のカードを持っているときの, p さんにとっての最適なスコア
	int Calc(int p, int q, int r)
	{
		var k = new P(p, q, r);
		if (!memo.ContainsKey(k))
		{
			memo[k] = Abs(a[N - 1] - r);
			for (var i = q; i < N - 1; i++) memo[k] = c[k.Player](memo[k], Calc(1 - p, i + 1, a[i]));
		}
		return memo[k];
	}
}


Measured memory_bytes: 14176
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <cmath>

using namespace std;

string solve(string s){
  int count=0;
  string res;
  //new char
  res.push_back(s[0]);
  count++;
  for(int i=1;i<s.size();i++){
    //the same char 
    if(*res.rbegin()==s[i])
        count++;
    //not the same
    else {
      char a=*res.rbegin();
      res.resize(res.size()-1);
      res.append(to_string(count));
      res.push_back(a);
      count=1;
      res.push_back(s[i]);
    }
//    printf("[%c]",s[i]);
  }
  char a=*res.rbegin();
  res.resize(res.size()-1);
  res.append(to_string(count));
  res.push_back(a);
  return res;
}

/*
//20*(100+100*2^20)/2=10*(100+100*1024*1024)=1000+10^9<=c10^9
string solve(string s){
int count=0;
string res;
//new char
res.push_back(s[0]);
count++;
for(int i=1;i<s.size();i++){
//the same char 
if(*res.rbegin()==s[i])
count++;
//not the same
else {
char a=*res.rbegin();
res.erase(res.size()-1);
res.push_back(count+'0');
res.push_back(a);
count=1;
res.push_back(s[i]);
}
}

if(count==0)
count++;
char a=*res.rbegin();
res.erase(res.size()-1);
res.push_back(count+'0');
res.push_back(a);
return res;
}
 */
//num<=20, str.size()<=100
int main(int args, char *argc[]){
  int num;
  while(cin>>num,num){
    string s;
    cin>>s;

    string res;
    res=s;
    for(int i=0;i<num;i++){
      res=solve(res);
 //     cout<<res<<endl;
    }
    cout<<res<<endl;
  }
  return 0;
}


Measured memory_bytes: 3348
#include<bits/stdc++.h>
using namespace std;
int main(){

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

  int m;
  cin>>m;
  string t[101];
  for(int i=0;i<m;i++){
    cin>>t[i];
  }

  int cnt[101]={ };
	  

  for(int i=0;i<n;i++){
    cnt[i]=0;
    for(int j=0;j<n;j++){
      if(s[i]==s[j]){
	cnt[i]++;
      }
    }
  }
  
  for(int i=0;i<n;i++){    
    for(int k=0;k<m;k++){
      if(s[i]==t[k]){
	cnt[i]--;
      }
    }
  }
  sort(cnt,cnt+n);

  if(cnt[n-1]<0){
    cout<<0<<endl;
  }else{
    cout<<cnt[n-1]<<endl;
  }
  
  
  return 0;
}


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

const int INF = 1e9;

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

	int n;
	cin >> n;
	map<int, int> mp;
	vector<int> arr(n);
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		mp[arr[i]]++;
	}
	sort(arr.begin(), arr.end());
	int resp = 0;
	for (int i = 0; i < n; i++) {
		int val = arr[i];
		for (int j = val * 2; j <= arr[n - 1]; j += val) {
			mp[j]++;
		}
		if (mp[val] == 1)
			resp++;
	}
	cout << resp << endl;

	return 0;
}

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

int main() {
  int N,A;
  cin>>N>>A;
  if(A>=499){
      cout<<"Yes"<<endl;
  }else if(N%500<=A%500){
      cout<<"Yes"<<endl;
  }else{
      cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

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

using namespace std;

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

int n;
int a[200000];
int b[200001];

void add(int i, int x){
	while(i <= n){
		b[i] += x;
		i += i & -i;
	}
}

int sum(int i){
	int s = 0;
	while(i > 0){
		s += b[i];
		i -= i & -i;
	}
	return s;
}

int main(){
	scanf("%d", &n);
	rep(i, n){
		scanf("%d", &a[i]);
	}

	vector<P> v;
	rep(i, n){
		v.push_back(P(a[i], i));
	}
	sort(v.begin(), v.end());
	a[v[0].second] = 0;
	rep(i, n - 1){
		a[v[i + 1].second] = a[v[i].second] + (v[i].first != v[i + 1].first);
	}

	ll ans = 0;
	for(int i = n - 1; i >= 0; --i){
		ans += sum(a[i]);
		add(a[i] + 1, 1);
	}
	printf("%lld\n", ans);
	return 0;
}

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

// 約数の個数を数える
int div_count(int n) {
  int c = 0;
  int k;
  for (k=1; k<=n; k++) {
    if (n%k == 0) c++;
  }
  return c;
}

int main() {
  int N;
  cin >> N;
  
  int ans = 0;
  for (int i=1; i<=N; i+=2) {
    int num = div_count(i);
    if (num == 8) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
module ModInt
  MOD = 10 ** 9 + 7

  def to_mod(a); a % MOD; end
  def add(a, b); (a + b) % MOD; end
  def sub(a, b); (a - b) % MOD; end
  def mul(a, b); (a * b) % MOD; end
  def inv(a); a.pow(MOD - 2, MOD); end
  def div(a, b); mul(a, inv(b)); end
end

class FactTable
  include ModInt

  def initialize(n)
    @fact = [1] * (n + 1)
    @finv = [1] * (n + 1)
    2.upto(n) { |i| @fact[i] = mul(@fact[i - 1], i) }
    @finv[n] = inv(@fact[n])
    n.downto(3) { |i| @finv[i - 1] = mul(@finv[i], i) }
  end

  def nCk(n, m)
    mul(mul(@fact[n], @finv[m]), @finv[n - m])
  end
end

SNG = 10**20r # 特異点
INF = 10**19r

n = gets.to_i
iwashi = n.times.map do
  a,b = gets.split.map(&:to_r)
  if b == 0
    if a == 0
      SNG
    else a > 0
      INF
    end
  else
    Rational(a/b)
  end
end

def inv(a)
  if a == SNG
    SNG
  elsif a == 0r
    INF
  elsif a == INF
    0r
  else
    -1r/a
  end
end

cnt = iwashi.tally
# bad = iwashi.map{|v|inv(v)}
seen = Hash.new(-1)

MOD = 1000000007
include ModInt

ans = 1
cnt.each do |key,num|
  next if seen[key] == 1
  next if key == SNG
  seen[key] = 1

  # 嫌いな相手はいるか？
  bad = inv(key)
  if cnt.has_key?(bad)
    seen[bad] = 1
    a = add(2.pow(num, MOD), 2.pow(cnt[bad], MOD))
    a = sub(a, 1)
    ans = mul(ans, a)
  else
    a = 2.pow(num, MOD)
    ans = mul(ans, a)
  end
end

# 特異点イワシ
if cnt.has_key?(SNG)
  ans += cnt[SNG]
end

# 何も選ばない場合を引く
ans = sub(ans,1)

puts ans

# pp cnt
# pp cnt.keys.map{|v|inv v}
# pp seen

Measured memory_bytes: 49380
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

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

signed main(){
    FastIO;
    int x,n;
    cin>>x>>n;
    map<int,int>ok;
    int mini=1e9,num=1e9;
    rep(i,1,n){
        int a;
        cin>>a;
        ok[a]=1;
    }
    rep(a,-200,200) if(!ok.count(a)){
        if(abs(a-x)==mini){
            num=min(num,a);
        }
        if(abs(a-x)<mini){
            mini=abs(a-x);
            num=a;
        }
    }
    cout<<num;
    return 0;
}


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


int main() {

  int N, M;
  cin >> N >> M;
  
  int sum = 0;
  
 vector<int> vec(N);
 for (int i = 0; i < N; i++) {
   cin >> vec.at(i);
   sum += vec.at(i);
 }

 sort(vec.begin(), vec.end()); //小さい順にソートする
 reverse(vec.begin(), vec.end()); //逆順にする 
  
  bool count = 1;
  

   if (sum%(4*M) == 0 && vec.at(M-1) < sum / (4*M) ) {
     count = 0;
   }
  else if (sum%(4*M) != 0 && vec.at(M-1) <= sum / (4*M) ) {
     count = 0;
   }
  else count = 1; 

 
  if (count) cout << "Yes" << endl;
  else cout << "No" << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;
int main() {

    int R[MAX], n;
    cin >> n;
    for( int i = 0; i < n; i++) cin >> R[i];

    int maxv = -2000000000; //十分に小さい値を初期値に決定
    int minv = R[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3876
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const ll INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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(a>b){a=b;return 1;}return 0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin>>N;
    vector<int> x(N);
    vector<vector<int>> tree(N);
    REP(i,N-1) {
        int p;
        cin>>p;
        tree[p-1].push_back(i+1);
    }
    cin>>x;

    function<int(int)> dfs=[&](int v) {
        int ret=0;
        bitset<5001> dp;
        dp=1;
        int idx=0;
        FORE(w,tree[v]) {
            int s=dfs(w);
            dp=(dp<<(s-x[w]))|(dp<<(x[w]));
            ret+=s;
        }
        bool possible=false;
        int weight=0;
        REPR(i,x[v]) {
            if(dp[i]) {
                possible=true;
                weight=x[v]-i;
                break;
            }
        }
        if(!possible) {
            cout<<"IMPOSSIBLE"<<endl;
            exit(0);
        }
        return ret+weight;
    };
    dfs(0);
    cout<<"POSSIBLE"<<endl;
    return 0;
}



Measured memory_bytes: 1664
H, W = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]


def next(h, w):
    if h % 2 == 0:
        if w == W - 1:
            return (h + 1, w)
        else:
            return (h, w + 1)
    else:
        if w == 0:
            return (h + 1, w)
        else:
            return (h, w - 1)


ans = []
for i in range(H):
    for j in range(W):
        if i == H - 1 and j == W - 1:
            break
        if i % 2 == 0:
            h, w = i, j
        else:
            h, w = i, W - 1 - j
        if a[h][w] % 2 == 1:
            hn, wn = next(h, w)
            a[h][w] -= 1
            a[hn][wn] += 1
            ans.append("{} {} {} {}".format(h + 1, w + 1, hn + 1, wn + 1))
    else:
        continue
    break
print(len(ans))
for ai in ans:
    print(ai)


Measured memory_bytes: 16380
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repl(i, l, r) for (int i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> a(n);
	rep(i, n) scanf("%d", &a[i]);
	rep(i, k) {
		vector<int> p(n);
		rep(j, n) {
			p[max(0, j - a[j])]++;
			if (j + a[j] + 1 <= n - 1) p[j + a[j] + 1]--;
		}
		bool ch = 1;
		if (p[0] != n) ch = 0;
		rep(j, n - 1) {
			p[j + 1] += p[j];
			if (p[j + 1] != n) ch = 0;
		}
		a = p;
		if (ch) break;
	}
	rep(i, n) {
		if (i) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>

int main(void) {
    int a[3];
    for (int i=0; i<3; i++) std::cin >> a[i];
    std::sort(a, a+3);
    std::cout << (10 * a[2] + a[1]) + a[0] << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <limits>

using namespace std;

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);

  int n;
  cin >> n;

  vector<tuple<int, int>> points(n);
  for (auto& [x, y]: points) {
    cin >> x >> y;
  }

  auto max1 = numeric_limits<int>::min();
  auto min1 = numeric_limits<int>::max();
  for (const auto& [x, y]: points) {
    max1 = max(max1, x + y);
    min1 = min(min1, x + y);
  }

  const auto cand1 = max1 - min1;

  auto max2 = numeric_limits<int>::min();
  auto min2 = numeric_limits<int>::max();
  for (const auto& [x, y]: points) {
    max2 = max(max2, x - y);
    min2 = min(min2, x - y);
  }

  const auto cand2 = max2 - min2;

  cout << max(cand1, cand2) << '\n';
  
  return 0;
}

Measured memory_bytes: 4464
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int now = 1;
		int cnt = 0;

		while (now < b) {
			now += a - 1;
			cnt++;
		}

		System.out.println(cnt);

		sc.close();
	}
}

Measured memory_bytes: 21716
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let _n: u32 = read();
    let s: String = read();
    // 使用可能なPINの数
    let mut pin_count: u32 = 0;
    let num_str = vec!['0','1','2','3','4','5','6','7','8','9'];

    // 000-999の暗証番号について調べる.
    for digit100 in 0..10
    {
        for digit10 in 0..10
        {
            for digit1 in 0..10
            {
                let mut valid_digit = vec![false, false];

                for ch in s.chars()
                {
                    if !valid_digit[0] && !valid_digit[1] && ch == num_str[digit100] { valid_digit[0] = true; continue; }
                    if valid_digit[0] && !valid_digit[1] && ch == num_str[digit10] { valid_digit[1] = true; continue; }
                    // このPINは選ばれる
                    if valid_digit[0] && valid_digit[1] && ch == num_str[digit1] {
                        pin_count += 1;
                        break;
                    }
                }
            }
        }
    }

    // 結果を出力
    println!("{}", pin_count);
}


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

int main() {
    int N;
    cin >> N;
    int mi = N+1, res = 0;
    for (int i = 0; i < N; ++i) {
        int p; cin >> p;
        mi = min(mi, p);
        if (mi== p) ++res;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}

void solve()
{
	int  n , k  ; 
	cin>>n>>k ;
	int d_c = 0 ;
	while(n){
		d_c++ ;
		n /= k ;
	}
	cout<<d_c<<endl;
}
 
int main() {
    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    // ios_base::sync_with_stdio(0);
    // cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    // cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

constexpr char BLACK = '#';
constexpr char WHITE = '.';

int main(void) {
    using std::cin;
    using std::cout;
    using std::string;
    using std::vector;

    int H, W;
    vector<string> a;

    cin >> H >> W;
    a.resize(H);
    for (auto &ai : a) cin >> ai;

    bool changed = true;  // 更新フラグ
    while (changed) {
        changed = false;

        for (int i = 0; i < H; ++i) {  // 空行を探す
            auto it = std::find(a.at(i).begin(), a.at(i).end(), BLACK);
            if (it == a.at(i).end()) {  // 黒が見つからないければ，行iを削除
                a.erase(a.begin() + i);
                --i;
                --H;
                changed = true;
            }
        }

        for (int i = 0; i < W; ++i) {  // 空列を探す
            bool black_exist = false;
            for (int j = 0; j < H; ++j) {
                if (a.at(j).at(i) == BLACK) {
                    black_exist = true;
                    break;
                }
            }
            if (!black_exist) {
                for (int j = 0; j < H; ++j) {  // 列iを削除
                    a.at(j).erase(a.at(j).begin() + i);
                }
                --i;
                --W;
                changed = true;
            }
        }
    }

    for (int i = 0; i < H; ++i) {
        cout << a.at(i) << '\n';
    }

    return 0;
}

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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main(){
    string n;
    cin >> n;
    if(n[0]=='7'||n[1]=='7'||n[2]=='7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=300000;

int main()
{
    FasterIO;

    int n, m, k;
    string A, B, C;
    cin>>A>>B>>n>>m>>C;
    if(C==A) n--;
    else     m--;
    cout<<n<<' '<<m<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string ch,ch1 ;
int n , m , dp[4000][4000] ;
int lcs(int i,int j)
{
    if(i == n || j == m) return 0 ;
    if(dp[i][j] != -1) return dp[i][j] ;
    int x , y ;
    if(ch[i]==ch1[j]) return dp[i][j] = 1 + lcs(i+1,j+1) ;
    x = lcs(i+1,j) ;
    y = lcs(i,j+1) ;
    return dp[i][j] = max(x,y) ;
}
int main()
{
    cin>>ch>>ch1 ;
    memset(dp,-1,sizeof(dp)) ;
    n = ch.size() ; m = ch1.size() ;
    int l = lcs(0,0) ;
    int i = 0 , j = 0 ;
    while(i < n && j < m)
    {
        if(ch[i]==ch1[j])
        {
            printf("%c",ch[i]) ;
            i++ ; j++ ;
        }
        else if(dp[i+1][j] >= dp[i][j+1]) i++ ;
        else j++ ;
    }
  //  cout<<l<<endl ;
}



Measured memory_bytes: 62976