akhauriyash/Code-Regression huggingface dataset:
N, M = list(map(int, input().split()))
q = []
for i in range(M):
    tmps, tmpm = list(map(int, input().split()))
    q.append((tmps, tmpm))

flag = 0

ans = [-1] * N
cnt = [0] * N

for t in q:
    s, c = t[0]-1, t[1]
    if cnt[s] == 0:
        ans[s] = c
        cnt[s] += 1
    elif ans[s] != c:
        flag = 1

for i in range(len(ans)):
    if ans[0] == 0:
        if len(ans) == 1:
            continue
        else:
            flag = 1
    elif ans[0] == -1:
        if len(ans) == 1:
            ans[0] = 0
        else:
            ans[0] = 1
    elif ans[i] == -1:
        ans[i] = 0


if flag == 1:
    print(-1)
else:
    print("".join(map(str, ans)))


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int Bubble(int a[], int n)
{
	int sew = 0;
	int flag = 1;
	for (int i = 0; flag; i++)
	{
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--)
		{
			if (a[j] < a[j - 1])
			{
				swap(a[j], a[j - 1]);
				flag = 1;
				sew++;
			}
		}
	}
	return sew;
}
int main()
{
	int a[100], n, sew;
	cin >> n;
	for (int i = 0; i < n ; i++)
	{
		cin >> a[i];
	}
	sew = Bubble(a, n);
	for (int i = 0; i < n ; i++)
	{
		if (i)
		{
			cout << " ";
		}
		cout << a[i];
	}
	cout << endl;
	cout << sew << endl;
	return 0;
}


Measured memory_bytes: 3096
#include <stdio.h>

int main(){
   long n,m,a,i,s;

   scanf("%ld %ld",&n,&m);
   for (s=i=0;i<m;i++) {
      scanf("%ld",&a);
      s+=a;
   }
   if (s>n) puts("-1");
   else     printf("%ld\n",n-s);
   return 0;
}


Measured memory_bytes: 1728
"""
B - Two Colors Card Game
"""
n = int(input())
n_i = {}
for i in range(n):
    _str = input()
    if _str in n_i:
        n_i[_str] += 1
    else:
        n_i[_str] = 1
#print(n_i)

m = int(input())
m_i = {}
for i in range(m):
    _str = input()
    if _str in m_i:
        m_i[_str] += 1
    else:
        m_i[_str] = 1
#print(m_i)

for n in n_i.keys():
    # 同じ文字列がいたら引く
    if n in m_i.keys():
        #print("%s %d - %d" % (n, n_i[n], m_i[n]))
        n_i[n] -= m_i[n]

#print(n_i)

if max(n_i.values()) > 0:
    print(max(n_i.values()))
else:
    print(0)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int size = sc.nextInt();
        List<Integer> xs = new ArrayList<>(size);
        for (int i = 0; i < size; i++) {
            xs.add(sc.nextInt());
        }

        int n = 0;
        while (true) {
            if (xs.stream().allMatch((x) -> x % 2 == 0)) {
                xs = xs.stream().map((x) -> x / 2).collect(Collectors.toList());
                n++;
            }
            else {
                break;
            }
        }

        System.out.println(n);
    }
}


Measured memory_bytes: 26580
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll A,B,C,D;
ll GCD(ll A,ll B){return A? GCD(B%A,A):B;}
int main(){
	scanf("%lld%lld%lld%lld",&A,&B,&C,&D);
	ll gcd=GCD(C,D),lcm=C*D/gcd;
	ll C1=(A-1)/C,C2=B/C;
	ll D1=(A-1)/D,D2=B/D;
	ll l1=(A-1)/lcm,l2=B/lcm;
	printf("%lld\n",B-A+1-(C2-C1)-(D2-D1)+(l2-l1));
	return 0;
}

Measured memory_bytes: 128
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>

#pragma warning( disable: 4996 )

using namespace std;

typedef long long ll;

#define INF 100000000
#define EPS 1e-9

#define MAX_N 50
#define MAX_R 50

int n, r;
int p[MAX_R];
int c[MAX_R];
vector<int> ans_list;

int main(){
	
	while (true){
	
		cin >> n >> r;

		if (n == 0 && r == 0)
			break;

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

		int ans[MAX_N];
		for (int i = 0; i < n; i++){
			ans[i] = n - i;
		}
		int tmp[MAX_N];

		for (int i = 0; i < r; i++){
			
			for (int j = 0; j < c[i]; j++){
				tmp[j] = ans[p[i] - 1 + j];
			}

			for (int j = p[i]-2; j >= 0; j--){
				ans[j + c[i]] = ans[j];
			}

			for (int j = 0; j < c[i]; j++){
				ans[j] = tmp[j];
			}

		}

		ans_list.push_back(ans[0]);
	
	}

	for (int i = 0; i < ans_list.size(); i++){
		cout << ans_list[i] << endl;
	}


	return 0;

}

Measured memory_bytes: 1220
(defun f(x)
    (if (< x 10) 
        x
        (+ (rem x 10) (f (floor (/ x 10))))))
(defun g (x a b)
    (and (>= x a) (<= x b)))
(let ((n (read))
      (a (read))
      (b (read))
      (ans 0))
      

      (loop :for i :from 1 :to n :do (when (g (f i) a b) (setf ans (+ ans i))))
      (princ ans)
      )

Measured memory_bytes: 13668
n=int(input())
s=[int(input()) for _ in range(n)]
s.sort()
ss = sum(s)
if ss % 10 != 0:
    print(ss)
else:
    flag = 1
    for i in range(n):
        if s[i] % 10 != 0:
            print(ss-s[i])
            flag = 0
            break
    if flag == 1:
        print(0)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(i, x.size()) cerr << x[i] << (i == x.size() - 1 ? "\n" : " ")
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K;
string S,T;
//=============================
void input()
{
    cin>>N>>M;
}
//=============================
void func(){}
//=============================
void solve()
{
    cout<<N*M-N-M+1<<endl;
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
unsigned bucket[1000001];

int main(){
    unsigned N;
    scanf("%u", &N);
    unsigned A[N];
    for(int i = 0; i < N; ++i){
        scanf("%u", A + i);
        bucket[A[i]]++;
    }
    unsigned answer = 0;
    for (size_t i = 0; i < N; i++){
        if(bucket[A[i]] > 1) continue;
        if(A[i] == 1){
            answer++;
            continue;
        }
        if(bucket[1] > 0) continue;
        bool flag = true;
        for (size_t j = 2; j*j <= A[i]; j++){
            if(!(A[i]%j) && (bucket[j] > 0 || bucket[A[i]/j] > 0)){
                flag = false;
                break;
            }
        }
        if(flag) answer++;
    }
    printf("%u\n", answer);
	return 0;
}

Measured memory_bytes: 6392
#include<bits/stdc++.h>
using namespace std;
bool check(int x) {
	int num=0;
	while(x>0) {
		num++;
		x/=10;
	}
	return num%2;
}
int main() {
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)
		if(check(i)) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define enQue(x) (x*10 + (x%10))

long long int hoge(int k){
  long long int num;
  int i,j;
  long long int lunNum[k];
  if(k < 10) return k;
  for( i =0;i<9;i++){
    lunNum[i] = i+1;
  }
  i = 0;
  j = 9;
  while(j < k){
    num = lunNum[i];
    
    if(num % 10 != 0){
      lunNum[j] = enQue(num)-1;
      j++;
    }
    
    lunNum[j] = enQue(num);
    j++;
    
    if(num % 10 != 9){
      lunNum[j] = enQue(num)+1;
      j++;
    }
    i++;
  }
  return lunNum[k-1];
}

int main(){
  int k;
  scanf("%d",&k);
  printf("%lld",hoge(k));
}

Measured memory_bytes: 896
import statistics

n = int(input())
a = [int(n) for n in input().split(" ")]

sub_a = [a_n - i - 1 for i, a_n in enumerate(a)]
median = statistics.median(sub_a)
print(int(sum([abs(sub_a_n-median) for sub_a_n in sub_a])))

Measured memory_bytes: 28096
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
	int main()
	{
		std::ios::sync_with_stdio(false);
		
		ll h,w,k;
		cin>>h>>w>>k;
		char a[h][w];
			
		for(ll i=0; i<h; i++) {
			for(ll j=0; j<w; j++) {
				cin>>a[i][j];
			}
		}
		ll count = 0;
		ll ans = 0;
		for(ll i=0; i<(1<<h); i++) {
			for(ll j=0; j<(1<<w); j++) {
				count = 0;
				for(ll r=0; r<h; r++) {
					for(ll c=0; c<w; c++) {
						if(i&(1<<r) || j&(1<<c)) {
							continue;
						}
						if(a[r][c] == '#') {
							count++;
						}
					}
				}
				if(count == k) {
					ans += 1;
				}
			}
		}

		cout<<ans<<endl;


		return 0;
	}


Measured memory_bytes: 3580
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int x,y;
	cin>>x>>y;
	if(x>y) cout<<"a > b"<<endl;
	else if (x<y) cout<<"a < b"<<endl;
	else if(x==y) cout<<"a == b"<<endl;
	return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    int c = 0;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        if (h >= k) {
            c++;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define TILES 6

typedef struct{
	int up;
	int front;
	int right;
	int left;
	int back;
	int bottom;
}dice;

int DiceRoll(dice* p, char c);

int main(void){
	dice a = {0, 0, 0, 0, 0, 0};
	int i=0;
	char command = 'a';
	char line[101] = {0};
  
	// dice label setup 
    scanf("%d %d %d %d %d %d", &a.up, &a.front, &a.right, &a.left, &a.back, &a.bottom);

	scanf("%s", line);
    for(i=0;line[i]!='\0';i++) DiceRoll(&a, line[i]);
 
	printf("%d\n", a.up);
    return 0;
}

int DiceRoll(dice* p, char c){
	int tmp = -1;
	
	switch(c){
	case 'E':
		tmp = p->up;
		p->up = p->left;		// up <- left
		p->left = p->bottom;	// left <- bottom
		p->bottom = p->right;	// bottom <- right
		p->right = tmp;			// right <- up
		break;
	case 'N':
		tmp = p->up;
		p->up = p->front;		// up <- front
		p->front = p->bottom;	// front <- bottom
		p->bottom = p->back;	// bottom <- back
		p->back = tmp;			// back <- up
		break;
	case 'S':
		tmp = p->up;
		p->up = p->back;		// up <- back
		p->back = p->bottom;	// back <- bottom
		p->bottom = p->front;	// bottom <- front
		p->front = tmp;			// front <- up
		break;
	case 'W':
		tmp = p->up;
		p->up = p->right;		// up <- right
		p->right = p->bottom;	// right <- bottom
		p->bottom = p->left;	// bottom <- left
		p->left = tmp;			// left <- up
		break;
	case 'R':
		tmp = p->front;
		p->front = p->left;		// front <- left
		p->left = p->back;		// left <- back
		p->back = p->right;		// back <- right
		p->right = tmp;			// right <- front
		break;
	case 'L':
		tmp = p->front;
		p->front = p->right;	// front <- right
		p->right = p->back;		// right <- back
		p->back = p->left;		// back <- left
		p->left = tmp;			// left <- front
		break;
	default:
		break;
	}

	return 0;
}

Measured memory_bytes: 596
import java.util.Arrays;
import java.util.Scanner;

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

        scanner.nextLine();

        final String[] sp = scanner.nextLine().split(" ");
        final int[] scores = Arrays.stream(sp).mapToInt(Integer::parseInt).toArray();

        Arrays.sort(scores);

        final int min = scores[scores.length / 2 - 1];
        final int max = scores[scores.length / 2];

        System.out.println(max - min);
    }
}

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

stack <int> st;

int solve(string str){
    int b = st.top(); st.pop();
    int a = st.top(); st.pop();
    if(str=="+")return a+b;
    else if(str=="-")return a-b;
    else if(str=="*")return a*b;
    else if(str=="/")return a/b;
    else return 0;
}

int main(){
    string str;
    while(cin>>str){
        if(str=="+"||str=="-"||str=="*"||str=="/")
            st.push(solve(str));
        else st.push(atoi(str.c_str()));
        if(getchar()=='\n'){
            cout << st.top() << endl;
            return 0;
        }
    }
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define mp make_pair
#define endl "\n"
#define N 100001
#define INF 1e9


int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    
    string s ;
    cin >> s ;
    ll n = s.length() , curr=1  , i , j=0 ;
    if(s[0]=='0' || s[n-1]=='1'){cout << -1 ; return 0 ;}
    for(i=1 ; i<n-1 ; i++){
         if(s[i-1]!=s[n-1-i]){cout << -1 ; return 0 ;}
    }
    
    for(i=2 ; i<=n ; i++){
        cout << curr << " " << i << endl ;
        if(s[j++]=='1')curr = i ;
    }


    return 0 ;
    
}


Measured memory_bytes: 1616
import java.util.*;

public class Main {

    int INF = Integer.MAX_VALUE;

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextInt();
        long A = sc.nextInt();
        long B = sc.nextInt();
        long C = sc.nextInt();
        long D = sc.nextInt();
        for (int k = 0; k <= N; k++) {
            if (((k * C - (N - 1 - k) * D) <= (B - A)) && ((B - A) <= (k * D - (N - 1 - k) * C))) {
                System.out.println("YES");
                return;
            }
        }
        System.out.println("NO");
    }
}


Measured memory_bytes: 23124
# -*- coding: utf-8 -*-
import sys

n= int(input())
#tmp= float(input())
#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))

hoge=""
for i in range(1,n+1):
    if(i%3==0):
        hoge+=" "+str(i)
    else:
        x=i
        while(x>=1):
            if(x%10==3):
                hoge+=" "+str(i)
                break;
            x=x//10
print(hoge)



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

using namespace std;

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
const int INF=1e+9;
const ll INFLL=1e+17;
int N,K;
int a[5010],dp[5010][5010];
bool C(int i){
  if(a[i]>=K) return true;
  
  fill(dp,0);
  rep1(j,N){
    rep(k,K){
      if(j-1==i||k-a[j-1]<0) dp[j][k]=dp[j-1][k];
      else dp[j][k]=std::max(dp[j-1][k],dp[j-1][k-a[j-1]]+a[j-1]);
    }
  }
  if(dp[N][K-1]>=K-a[i]) return true;
  else return false;
}
int bina(int l,int r){
  int lb=l-1,ub=r+1;
  while(ub-lb>1){
    int mid=(lb+ub)/2;
    if(C(mid)) ub=mid;
    else lb=mid;
  }
  return ub;
}
int solve(){
  std::sort(a,a+N);
  return bina(0,N-1);
}
int main(){
  cin>>N>>K;
  rep(i,N) cin>>a[i];
  prin(solve());
  return 0;
}


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

string in;


void init(){
  in="";
}

bool input(){
  if(cin>>in){
    return 1;
  }else{
    return 0;
  }
}

bool judge(char c){
  switch(c){
    case 'i':
    case 'w':
    case '(':
    case ')':
      return 1;
    default:
      return 0;
  }
}


int solve(){
  int ans=0;
  if(in.size()%2==1){
    switch(in[in.size()/2]){
      case 'i':
      case 'w':
        break;
      default :
        ans++;
        break;
    }
  }
  for(int i=0;i<in.size()/2;i++){
    switch(in[i]){
      case 'i':
        if(in[in.size()-1-i]!='i'){
          ans++;
        }
        break;
      case 'w':
        if(in[in.size()-1-i]!='w'){
          ans++;
        }
        break;
      case '(':
        if(in[in.size()-1-i]!=')'){
          ans++;
        }
        break;
      case ')':
        if(in[in.size()-1-i]!='('){
          ans++;
        }
        break;
      default:
        if(judge(in[in.size()-1-i])){
          ans++;
        }else{
          ans+=2;
        }
        break;
    }
  }
  return ans;
}


int main(){
  init();
  input();
  cout<<solve()<<endl;
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
vector<vector<ll>> v;
bool used[700];
vector<ll> dfs(ll now){
    vector<ll> ret = {now};
    used[now] = 1;
    for(ll next : v[now]){
        if(!used[next]){
            vector<ll> tmp = dfs(next);
            for(ll u : tmp) ret.push_back(u);
        }
    }
    return ret;
}
bool bip(ll now, map<ll, bool> &m, bool which, pair<ll, ll> &count){
    (which ? count.first : count.second)++;
    m[now] = which;
    for(ll next : v[now]){
        if(m.find(next) == m.end()){
            if(!bip(next, m, !which, count)){
                return false;
            }
        }else if(m[next] == which){
            return false;
        }
    }
    return true;
}
int main(){
    ll N, M;
    vector<pair<ll, ll>> num;
    cin >> N >> M;
    vector<vector<ll>> e(N);
    v.resize(N);
    for(ll i = 0; i < M; i++){
        ll a, b;
        cin >> a >> b;
        e[--a].push_back(--b);
        e[b].push_back(a);
    }
    for(ll i = 0; i < N; i++){
        bool exist[N] = {};
        exist[i] = true;
        for(ll u : e[i]) exist[u] = true;
        for(ll j = 0; j < N; j++) if(!exist[j]) v[i].push_back(j);
    }
    for(ll i = 0; i < N; i++){
        if(used[i]) continue;
        vector<ll> tmp = dfs(i);
        map<ll, bool> m;
        pair<ll, ll> count;
        if(!bip(i, m, true, count)){
            cout << -1 << endl;
            return 0;
        }
        num.push_back(count);
    }
    bool dp[N + 1] = {true};
    for(auto p : num){
        bool nextdp[N + 1] = {};
        for(ll i = 0; i <= N; i++){
            if(dp[i]){
                nextdp[i + p.first] = true;
                nextdp[i + p.second] = true;
            }
        }
        for(ll i = 0; i <= N; i++) dp[i] = nextdp[i];
    }
    ll ans = M;
    auto func = [](ll a){return a ? a * (a - 1) / 2 : 0;};
    for(ll i = 0; i <= N; i++) if(dp[i]) ans = min(ans, func(i) + func(N - i));
    cout << ans << endl;
    return 0;
}

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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

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

  rep(k, K)
  {
    int n_count = 0;
    vector<int> l(N + 1, 0);
    rep(i, N)
    {
      if (A[i] != 0)
      {
        int left = std::max(i - A[i], 0);
        int right = std::min(i + A[i] + 1, N);
        l[left]++;
        l[right]--;
      }
      else
      {
        l[i]++;
        l[i + 1]--;
      }
    }
    int sum = 0;
    rep(i, N)
    {
      sum += l[i];
      A[i] = sum;
      if (A[i] == N)
        n_count++;
    }
    if (n_count == N)
    {
      break;
    }
  }

  rep(i, N - 1)
  {
    cout << A[i] << " ";
  }
  cout << A[N - 1] << endl;

  return 0;
}


Measured memory_bytes: 4828
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    string ans = n == m ? "Yes" : "No";
    PUTS(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
int main() {
  ll n;cin>>n;
  vector<ll> a(n-1),b(n-1),c(n-1);
  rep(i,n-1) cin>>a[i]>>b[i]>>c[i],a[i]--,b[i]--;
  ll q,k;cin>>q>>k;k--;
  vector<ll> x(q),y(q);
  vector<pair<ll,ll>> g[n];
  rep(i,n-1){
    g[a[i]].push_back({b[i],c[i]});
    g[b[i]].push_back({a[i],c[i]});
  }
  vector<ll> to_k(n,-1);
  queue<ll> que;
  que.push(k);
  to_k[k]=0;
  while(!que.empty()){
    auto tmp=que.front();
    que.pop();
    for(auto c:g[tmp]){
      if(to_k[c.first]==-1){
        to_k[c.first]=to_k[tmp]+c.second;
        que.push(c.first);
      }
    }
  }
  rep(i,q){
    ll x,y;cin>>x>>y;x--;y--;
    cout<<to_k[x]+to_k[y]<<endl;
  }
}

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

int main() {
	long long h,w,k,l,p,q,a,b,c,d,e,f,g,j,m,n,o,r;
	cin>>h>>w;
	if((h*w)%3==0)cout<<0<<endl;
	else if(h==2||w==2)cout<<1<<endl;
	else{
		a=max(h*(w/3),(w-w/3)*(h/2));
		b=min(h*(w/3),(w-w/3)*(h/2));
		c=max(h*(w/3+1),(w-w/3-1)*(h/2));
		d=min(h*(w/3+1),(w-w/3-1)*(h/2));
		k=max(a,(w-w/3)*(h-h/2));
		l=min(b,(w-w/3)*(h-h/2));
		p=max(c,(w-w/3-1)*(h-h/2));
		q=min(d,(w-w/3-1)*(h-h/2));
		e=max(w*(h/3),(h-h/3)*(w/2));
		f=min(w*(h/3),(h-h/3)*(w/2));
		g=max(w*(h/3+1),(h-h/3-1)*(w/2));
		j=min(w*(h/3+1),(h-h/3-1)*(w/2));
		m=max(e,(h-h/3)*(w-w/2));
		n=min(f,(h-h/3)*(w-w/2));
		o=max(g,(h-h/3-1)*(w-w/2));
		r=min(j,(h-h/3-1)*(w-w/2));
		cout<<min(h,min(w,min((k-l),min(p-q,min(m-n,o-r)))))<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
using namespace std;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define lld long double
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> vp;
typedef vector<tuple<ll, ll, ll>> vt;
//vector<vector<ll>> vv(n, vector<ll>(n));

int main()
{
	int n;
	cin >> n;
	if (n / 10 == 9 || n % 10 == 9) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
	ll n;
	cin >> n;
  ll a = n/2;
  if (n%2 == 0) a--;
	cout << a << endl;
  return 0;
}

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

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;

ll ind;
vector<vi> trees;
vector<vi> e;

vector<bool> seen;
vi a;

void dfs(ll v,ll l){
	seen[v] =true;
    trees[ind].push_back(a[v]);
	rep(i,0,e[v].size())
		if(e[v][i]!=l) dfs(e[v][i], v);
}


int main(){
	cin.sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
	seen.resize(n);
	e.resize(n);
	a.resize(n);
    rep(i,0,n) cin>>a[i];
	rep(i,0,m){
		ll a,b;
		cin>>a>>b;
        e[a].push_back(b);
        e[b].push_back(a);
	}
	ind = -1;
    rep(i,0,n){
		if(seen[i]) continue;
        ind++;
        trees.push_back(vi(0));
        dfs(i,-1);
    }

    if(trees.size()==1) {
		cout<<0<<endl;
		return 0;
    }

    ll ans = 0;

	vi allCosts;
    rep(i,0,trees.size()){
		sort(all(trees[i]));
        ans += trees[i][0];
        rep(j,1,trees[i].size()) allCosts.push_back(trees[i][j]);
    }

    sort(all(allCosts));
    ll left = trees.size()-2;
    if(allCosts.size()<left){
		cout<<"Impossible"<<endl;
		return 0;
    }
	rep(i,0,left)
		ans+=allCosts[i];
		cout<<ans<<endl;
}


Measured memory_bytes: 10548
<?php
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}
function be_able_to_reach($from, $to)
{
  $time = $to[0] - $from[0];
  $distance = abs($to[1] - $from[1]) + abs($to[2] - $from[2]);
  #var_dump($time,$distance);
  if($distance > $time) return false;
  if($distance % 2 == 0 && $time % 2 == 0) return true;
  if($distance % 2 == 1 && $time % 2 == 1) return true;
  return false;
}

$scan = new Scanner();
$A = $scan->nextInt();
$B = $scan->nextInt();
$cost = 0;
if($A >= 13) $cost = $B;
elseif($A >= 6) $cost = $B/2;
else $cost = 0;
print($cost);

Measured memory_bytes: 4604
import java.util.*;
import java.lang.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long A = sc.nextLong();
    long B = sc.nextLong();
    sc.close();
    long C = A + B;
    long div = (N / C) * A;
    long mod = Math.min(N % (A + B), A);

    System.out.println(div + mod);
  }
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int n, k;

ll modpow(ll a, ll b) {
  ll r = 1;
  while (b) {
    if (b & 1) r = r * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return r;
}

ll dp[200005];

main() {
  cin >> n >> k;
  ll ans = 0;
  for (int i = 1; i <= k; i++) dp[i] = modpow(k / i, n);

  for (int i = k; i > 0; --i)
    for (int j = 2; j < k / i + 1; ++j) dp[i] -= dp[i * j];

  rep(i, k + 1) ans += dp[i] * i, ans %= mod;

  cout << ans << endl;
}


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

int main(){
  map< string, int > m;
  string tmp;
  string max_len = "";

  while(cin >> tmp){
    m[tmp] += 1;
    if(max_len.length() < tmp.length()) max_len = tmp;
  }

  map< string, int >::iterator it, it_max_fre = m.begin();
  for(it = m.begin(); it != m.end(); it++){
    if(it_max_fre->second < it->second) it_max_fre = it;
  }

  cout << it_max_fre->first << " " << max_len << endl;
}

Measured memory_bytes: 3120
def examA():
    N = I()
    if N==1:
        ans = "Hello World"
    elif N==2:
        A = I(); B = I()
        ans = A + B
    try:
        print(ans)
    except:
        print()
    return

def examB():
    N, T = LI()
    ans =  10**9
    for _ in range(N):
        c, t = LI()
        if T>=t and ans>c:
            ans = c
    if ans==10**9:
        ans = "TLE"
    print(ans)
    return

def examC():
    N = I()
    X, Y, H = [0]*N, [0]*N, [0]*N
    for i in range(N):
        X[i], Y[i], H[i] = LI()
    for x in range(101):
        for y in range(101):
            curH = 0; flag = True; keep = []
            for i in range(N):
                if H[i]==0:
                    keep.append(i)
                    continue
                now = H[i] + abs(x-X[i]) + abs(y-Y[i])
                if curH==0:
                    curH = now
                else:
                    if curH!=now:
                        flag = False
                        break
            for i in keep:
                now = abs(x-X[i]) + abs(y-Y[i])
                if now<curH:
                    flag = False
                    break
            if flag:
                ans = [x,y,curH]
                break
    print(" ".join(map(str,ans)))
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()


Measured memory_bytes: 3572
N, A, B =  map(int, input().split())

ans = 0
if (B-A) % 2 == 0:
    ans = (B-A) // 2
else:
    if N-B < A-1:
        ans = N-B+1+(-A+B-1)//2
    else:
        ans = A+(B-A-1)//2
print(ans) 

Measured memory_bytes: 2940
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N];
		double num = 0;
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			num += a[i];
		}
		num = num / (double)N;
		
		double ans_dist = Integer.MAX_VALUE;
		int ans = 0;
		for(int i = 0; i < N; i++) {
			if(Math.abs(num - (double)a[i]) < ans_dist) {
				ans_dist = Math.abs(num - (double)a[i]);
				ans = i;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
from math import ceil

N, A, B = map(int, input().split())
h = [int(input()) for _ in range(N)]
h = sorted(h)

max(h)

l = 0
r = ceil(max(h) / B) + 1

ans = float('inf')
while l < r:
    t = 0
    cnt = (l + r) // 2
    for i in range(N):
        if h[i] > cnt * B:
            t += ceil((h[i] - cnt * B) / (A - B))
    if t <= cnt:
        ans = min(ans, cnt)
        r = cnt
    else:
        l = cnt + 1

print(ans)


Measured memory_bytes: 8280
import java.util.Scanner;

/**
 * Water Bottle
 */
public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int A = sc.nextInt();
            int B = sc.nextInt();
            int X = sc.nextInt();

            double d;
            if (X * 2 >= A * A * B) {
                double z = (double) (A * A * B - X) / A / A * 2;
                d = Math.atan(z / A) * 180 / Math.PI;
            } else {
                double z = (double) (X) / A / B * 2;
                d = Math.atan(B / z) * 180 / Math.PI;
            }

            System.out.println(d);
        }
    }

}


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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> vecx(N+1);
  vector<int> vecy(M+1);
  cin>>vecx.at(0)>>vecy.at(0);
  
  for(int i=1;i<N+1;i++)
    cin>>vecx.at(i);
  for(int i=1;i<M+1;i++)
    cin>>vecy.at(i);
  
  sort(vecx.begin(),vecx.end());
  sort(vecy.begin(),vecy.end());
  
  if(vecx.back()<vecy.at(0))
    cout<<"No War"<<endl;
  else
    cout<<"War"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _int128
#define ld long double
long double PI =3.14159265358979323846;
using ll = unsigned long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(5e5)+5;




int main()
{
    idfc;

    int x,y;
    cin>>x>>y;
    int i;
    int tot;
    for(i=0;i<=x;i++)
    {
        tot=(i*2)+((x-i)*4);
        if(tot==y)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";


    return 0;
}

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

struct node
{
	int x, y, w;

	node() = default;

	node(int x, int y, int w)
		: x(x), y(y), w(w)
	{
	}
};

int u[4][2]= {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
int n, m, cnt;
bool g[50][50], v[50][50];
queue<node> q;

int main()
{
	int i, j, x, y;
	node k;
	char ch;
	cin >> n >> m;

	for (i=0; i<n; ++i)
		for (j=0; j<m; ++j)
		{
			cin >> ch;
			if ((g[i][j]=ch=='.')) ++cnt;
		}

	q.push(node(0, 0, 0));
	v[0][0]=true;

	while (!q.empty())
	{
		k=q.front();
		q.pop();
		if (k.x==n-1&&k.y==m-1) break;

		for (i=0; i<4; ++i)
		{
			x=k.x+u[i][0];
			y=k.y+u[i][1];

			if (x>=0&&x<n&&y>=0&&y<m&&g[x][y]&&!v[x][y])
			{
				q.push(node(x, y, k.w+1));
				v[x][y]=true;
			}
		}
	}

	if (k.x==n-1&&k.y==m-1)
		cout << cnt-k.w-1 << endl;
	else
		cout << "-1" << endl;

	return 0;
}

Measured memory_bytes: 256
#                         author:  kagemeka 
#                         created: 2019-11-10 12:28:14(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():
    a, b = (int(x) for x in sys.stdin.readline().split())
    if (a * b) % 2 != 0:
        ans = 'Yes'
    else:
        ans = 'No'
    
    print(ans)


if __name__ == "__main__":
    # execute only if run as a script
    main()


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

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

using namespace std;

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int h,w,c,grid[8][8];
bool vis[8][8];


int Count(int x,int y, int col){
	int cnt=1;
	vis[y][x]=true;
	
	rep(i,4){
		int nx=x+dx[i],ny=y+dy[i];
		if(0<=nx && 0<=ny && nx<w && ny<h &&
			grid[ny][nx]==col && !vis[ny][nx])cnt+=Count(nx,ny,col);
	}
	return cnt;
}


void rec(int x,int y, int col){
	int tmp=grid[y][x],cnt=1;
	grid[y][x]=col;
	
	rep(i,4){
		int nx=x+dx[i],ny=y+dy[i];
		if(0<=nx && 0<=ny && nx<w && ny<h && grid[ny][nx]==tmp)rec(nx,ny,col);
	}
}

int solve(int n){
	int ans=0;
	if(n==5){
		if(grid[0][0]!=c)rec(0,0,c);
		fill(vis[0],vis[8],false);
		return Count(0,0,c);
	}
	
	int tmp[8][8];
	rep(i,8)rep(j,8)tmp[i][j]=grid[i][j];
	for(int i=1;i<7;i++){
		if(grid[0][0]!=i)rec(0,0,i);
		ans=max(ans,solve(n+1));
		
		rep(j,8)rep(k,8)grid[j][k]=tmp[j][k];
	}
	return ans;
}

int main(void){
	
	while(cin >> h >> w >> c,h|w|c){
		fill(grid[0],grid[8],0);
		rep(i,h)rep(j,w)cin >> grid[i][j];
		
		cout << solve(1) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e10;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 




////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////
int n,u,v,da[110000], dt[110000];vector<int> g[110000];
bool isPath[110000];

bool dfsA(int node, int par){
  bool ret = false;
  rep(i,g[node].size()){
    int to = g[node][i];
    if(to == par)continue;
    da[to] = da[node]+1;
    ret = dfsA(to, node) || ret;
  }
  ret = ret || (node == u);
  if(ret)isPath[node] = true;
  return ret;
}

void dfsT(int node, int par){
  rep(i,g[node].size()){
    int to = g[node][i];
    if(to == par)continue;
    dt[to] = dt[node]+1;
    dfsT(to, node);
  }
}

int ans = 0;

signed main(){
  cin>>n>>u>>v;u--;v--;
  rep(i,n-1){
    int a,b;cin>>a>>b;a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfsA(v, -1);
  dfsT(u, -1);
  int node, mx = -1;
  ans = 0;
  //cout << ans << endl;
  rep(i,n){
    if(da[i] > dt[i]){
      chmax(ans, dt[i] + (da[i] - dt[i] - 1));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 13056
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define rep(i,n) for(long long int i=0;i<(long long int)(n);i++)
using namespace std;

struct UnionFind {
    vector<int> par, size; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i,size[i]=1;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry;//xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        size[ry]+=size[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
  
   int count(int x){
       return size[root(x)];
   }
};

int main() {
    int N, M,K;
    cin >> N >> M >>K;
  vector<vector<int>> vm(N);
  vector<vector<int>> vk(N);

    UnionFind un(N);
     int  x, y;
    for(int i = 0; i < M; i++) {
        
        cin >> x >> y;
      vm.at(x-1).push_back(y-1);
    vm.at(y-1).push_back(x-1);
        un.unite(x-1, y-1); // xの木とyの木を併合する
    }

  
  
    rep(i,K){
    cin>>x>>y;
    vk.at(x-1).push_back(y-1);
    vk.at(y-1).push_back(x-1);
  }
    for(int i=0;i<N;i++){
      int k=0;
      rep(j,vk.at(i).size()){
        if(un.same(vk.at(i).at(j),i)){
          k++;
        }
      }
      cout << un.count(i)-1-vm.at(i).size()-k<< ' ';
    }

    
    return 0;
}


Measured memory_bytes: 12920
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
const int dm = 1400000;
char dn[dm], * di = dn;
const int MAX = 20000;
class unko {
public:
	char C[MAX * 7 + 10];
	int K[MAX + 10];
	constexpr unko() : C(), K() {
		auto di = C + 3;
		C[0] = '0';
		C[0] = ' ';
		C[0] = '\n';
		K[0] = 0;
		K[1] = 3;
		rep1(i, MAX) {
			int X = i;
			int keta = 0;
			char c[10] = {};
			while (X) {
				*(c + keta) = '0' + X % 10;
				X /= 10;
				keta++;
			}
			for (int j = keta - 1; j >= 0; j--)* di++ = (*(c + j));
			*di++ = ' ';
			*di++ = '\n';
			K[i + 1] = K[i] + keta + 2;
		}
	}
};
constexpr unko f;
inline void putint(int X) {
	if (X > 20000) {
		int ue = X / 10;
		for (auto i = f.C + f.K[ue]; *i != ' '; i++) *di++ = *i;
		*di++ = '0' + X % 10;
		*di++ = ' ';
	}
	else for (auto i = f.C + f.K[X]; *i != '\n'; i++)* di++ = *i;
}

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


	int N = getint(), K = getint();

	int A[200001];
	rep(i, N) A[i] = getint();
	ll owa = ll(N) * N;

	rep(p, K) {
		int B[200001] = {};
		rep(i, N) {
			B[max(0, i - A[i])]++;
			B[min(N, i + A[i] + 1)]--;
		}
		ll kei = B[0];
		A[0] = B[0];
		rep1(i, N - 1) {
			kei += (A[i] = A[i - 1] + B[i]);
		}
		if (kei == owa) break;
	}

	rep(i, N) putint(A[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 6768
//By Huseyn Hajiyev
#include <bits/stdc++.h>
#define FAST_READ ios_base::sync_with_stdio(false);
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define VI vector<int>
#define VIL vector<long long>
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define huscout(n) cout<<n<<endl
#define husscanint(n) scanf("%d",&n)
#define husscanll(n) scanf("%lld",&n)
#define husscandouble(n) scanf("%lf",&n)
#define husprintint(n)  printf("%d",n)
#define husprintll(n) printf("%lld",n)
#define MAXN 200010

using namespace std;

char alphabet[]={'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'};

string S;

int main(){
FAST_READ;
cin>>S;
ll sig=1;
char nott;
sort(all(S));
for(ll i=0;i<26;i++)
{
 if(!binary_search(all(S),alphabet[i])){sig=0;nott=alphabet[i];break;}
 else sig=1;
}

if(sig==1)cout<<"None"<<endl;
else cout<<nott<<endl;


return 0;
}


Measured memory_bytes: 512
N, D = map(int, input().split())
X = [0]*N
for i in range(0, N):
    X[i] = list(map(int, input().split()))
s = 0
for i in range(0, N):
    for j in range(i, N):
        t = 0
        for k in range(0, D):
            t = t+(X[i][k]-X[j][k])**2
        for l in range(1, t+1):
            if l**2 == t:
                s = s+1
                break
print (s)

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

int main() {
  string s, t;
  int ans = 0;
  cin >> s >> t;
  for (int i = 0; i < s.size(); i++)
  {
    if (s[i] != t[i])
    {
      ans++;
    }
    
  }
  cout << ans <<endl;

  return 0;
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=200005;
ll f[N],p[N],ans[N],n,cnt,Q,q;

int main(){
	read(n),read(Q);
	p[++cnt]=n;
	rep(i,1,Q){
		read(q);
		while(cnt&&p[cnt]>=q) cnt--;
		p[++cnt]=q;
	}
	f[cnt]=1;
	per(i,cnt,2){
		ll x=p[i],v=f[i];
		while(x>p[1]){
			ll k=lower_bound(p+1,p+cnt+1,x)-p-1;
			f[k]+=x/p[k]*v,x%=p[k];
		}
		ans[x]+=v;
	}
	ans[p[1]]+=f[1];
	per(i,n,1) ans[i]+=ans[i+1];
	rep(i,1,n) printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

typedef long long ll;

bool isPrime(int n) {
	if (n <= 1) return false;
	for (int i = 2; i*i <= n; ++i) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

int main() {
	int a, d, n;
	while ( cin >> a >> d >> n, a || d || n ) {
		int cnt = 0;
		int ans = 0;
		for (ll i = a;; i += d) {
			if (isPrime(i)) {
				if (++cnt == n) {
					ans = i;
					break;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){

	long long a[300000];
	long long s, t;
	int n;
	s = 0;

	scanf("%d %lld", &n,&t);

	for (int i = 0; i < n; i++){
		scanf("%lld", &a[i]);
		if (i == 0)s = s + t;
		else{
			if (a[i] - a[i - 1] < t)s = s + a[i] - a[i - 1];
			else s = s + t;
		}
	}
	printf("%lld\n", s);

	return 0;
}



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

int main(void) {
    string s, ans = "";

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    for (int i = 0; i < s.length(); i += 2) {
        ans += s[i];
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 592
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer([]byte{}, 1000000000)
	sc.Scan()
	sped := strings.Split(sc.Text(), " ")
	n := toInt(sped[0])
	k := toInt(sped[1])
	q := toInt(sped[2])
	members := make([]int, 0, n)
	for i := 0; i < n; i++ {
		members = append(members, k)
	}
	answers := make([]int, len(members))
	for i := 0; i < q; i++ {
		sc.Scan()
		num := toInt(sc.Text())
		answers[num-1] = answers[num-1] + 1
	}
	for i := range members {
		ans := answers[i]
		point := q - ans
		members[i] -= point
	}
	for _, num := range members {
		if num > 0 {
			fmt.Print("Yes\n")
		} else {
			fmt.Print("No\n")
		}
	}

}

func toInt(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return i
}


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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

struct UF{
	vector<int> p;
	UF() {}
	UF(int n) : p(n, -1) {}
	int find(int a){ return p[a] < 0 ? a : p[a] = find(p[a]); }
	void unite(int a, int b) {
		a = find(a); b = find(b);
		if (a == b) return;
		if (-p[a] < -p[b]) swap(a, b);
		p[a] += p[b]; p[b] = a;
	}
	bool root(int a){ return p[a] < 0; }
	bool same(int a, int b){ return find(a) == find(b); }
	int size(int a){ return -p[find(a)]; }
};

int main()
{

	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m;
	cin >>n >>m;
	VI a(m), b(m);
	rep(i,m){
		cin >>a[i] >>b[i];
		a[i]--; b[i]--;
	}
	int ans =0;
	rep(i,m){
		UF ufz(n);
		rep(j,m) if(i !=j) ufz.unite(a[j],b[j]);
		if(ufz.size(0) != n ) ans++;
		
	}
	cout << ans <<"\n";
	return 0;

}


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

typedef pair<int, int> pii;

int main() {

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

    double ret = -1;
    pii ans;
    for(int wa = 0; wa <= f; wa += 100*a) {
        for(int wb = 0; wa + wb <= f; wb += 100*b) {
            if(wa + wb <= 0) continue;
            for(int sc = 0; wa + wb + sc <= f; sc += c) {
                for(int sd = 0; wa + wb + sc + sd <= f; sd += d) {
                    double w = wa + wb;
                    double s = sc + sd;
                    if(w/100 * e < s) continue;
                    if(ret < 100 * s / (w + s)) {
                        ret = 100 * s / (w + s);
                        ans = {w + s, s};
                    }
                }
            }
        }
    }


    cout << ans.first << " " << ans.second << endl;

    return 0;
}

Measured memory_bytes: 256