akhauriyash/Code-Regression huggingface dataset:
import math

X=int(input())
max_num=math.ceil(math.sqrt(X))
if max_num**2>X:
    max_num-=1

num=max_num**2

for i in range(2,num):
    for j in range(3,X):
        p=i**j
        if p<=X and p>num:
            num=p
        elif p>X:
            break
        elif p==X:
            print(X)
            exit()

print(num)

Measured memory_bytes: 3064
d,g = gets.chomp.split.map(&:to_i)
ps,cs = d.times.map{gets.chomp.split.map(&:to_i)}.transpose
ans = ps.inject(:+)
(2 ** d).times do |i|
  sum = 0
  cnt = 0
  num = 0
  d.times do |j|
    if i[j] == 1
      cnt += ps[j]
      sum += (ps[j] * 100 * (j+1) + cs[j])
    else
      num = j
    end
  end

  if sum < g
    temp = ((g - sum).to_f / (100 * (num+1)) ).ceil
    if temp < ps[num]
      cnt += temp
      ans = cnt if ans > cnt
    end
  else
    ans = cnt if ans > cnt
  end
end

puts ans


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
const ll MOD = 998244353;
const ll INF = 1e18;
using namespace std;

vector<vector<int>> edges;
ll depth[300000];
vector<int> top;
bool vis[300000];
ll len = 0, cyc = 0, f = -1;
ll ans = -1;
ll n;
ll k;
void dfs(int u){
    vis[u] = true;
    if(u == 1)  depth[u] = 0;

    if(len == k){
        ans = u;
    }
    len++;

    for(auto v : edges[u]){
        if(!vis[v]) depth[v] = depth[u] + 1, dfs(v);
        else{
            f = v;
            cyc = depth[u] - depth[v] + 1;
        }
    }

    if(f != -1 and depth[u] >= depth[f])
        top.push_back(u);
}

main(){    
    #ifdef XOX
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\Input.txt", "r", stdin);
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\OPT.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    cin >> n >> k;
    edges.clear();
    edges.resize(n + 1);
    memset(depth, 0, sizeof(depth));
    memset(vis, false, sizeof(vis));

    ll tmp;
    for(int i = 1; i <= n; i++){
        cin >> tmp;
        edges[i].push_back(tmp);
    }
    
    dfs(1);
    if(ans != -1){
        cout << ans;
        return 0;
    }

    k -= len;
    k %= cyc;
    cout << top[cyc - 1 - k];
    
}

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

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

using namespace std;

int main(){
  valarray<int> ab(2), cd(2);
  cin>>ab[0];
  cin>>ab[1];
  cin>>cd[0];
  cin>>cd[1];

  cout<<ab.min()+cd.min();
  
  return 0;
}


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

N,M,K=map(int,input().split())

P=[i for i in range(N+1)]
size=[1 for i in range(N+1)]

def find(a):
    if a==P[a]:
        return a
    else:
        return find(P[a])
        
def union(b,c):
    B=find(b)
    C=find(c)
    if size[C]>size[B]:
        P[B]=P[C]
        size[C]+=size[B]
    else:
        P[C]=P[B]
        size[B]+=size[C]
G=[0 for i in range(N+1)]
for i in range(M):
    a,b=map(int,input().split())
    G[a]+=1
    G[b]+=1
    union(a,b)
#print(P)
PP=[]
for i in range(N+1):
    PP.append(find(P[i]))
#print(PP)
PPP=[0 for i in range(N+1)]
for i in range(1,N+1):
    PPP[PP[i]]+=1
#print(PPP)

B=[[]for i in range(N+1)]
for i in range(K):
    c,d=map(int,input().split())
    B[c].append(d)
    B[d].append(c)
#print(G)
#print(B)
ans=[]
for i in range(1,N+1):
    ANS=PPP[PP[i]]-1-G[i]
    for j in B[i]:
        if PP[j]==PP[i]:
            ANS-=1
    ans.append(ANS)
print(*ans)

Measured memory_bytes: 123440
import java.util.*
import kotlin.*

import java.io.InputStream
import java.lang.NumberFormatException
import java.lang.StringBuilder


fun main(args: Array<String>) {
    Program().solve()
}

class Program {
    fun solve() {
        val sc = FastScanner()
        val n = sc.nextInt()
        val k = sc.nextInt()
        val q = sc.nextInt()
        val a = Array(q) { sc.nextInt() }

        val s = Array(n) { 0 }

        for (i in 0 until q) {
            s[a[i] - 1]++
        }

        val sj = StringBuilder()

        for (i in 0 until n) {
            sj.appendln(if (k - (q - s[i]) > 0) "Yes" else "No")
        }

        print(sj.toString())
    }
}


class FastScanner {
    companion object {
        val input: InputStream = System.`in`
        val buffer = ByteArray(1024) { 0 }
        fun isPrintableChar(c: Int): Boolean = c in 33..126
    }

    var ptr = 0
    var buflen = 0
    private fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = input.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }

    private fun readByte(): Int = if (hasNextByte()) buffer[ptr++].toInt() else -1

    private fun skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++
    }

    fun hasNext(): Boolean {
        skipUnprintable()
        return hasNextByte()
    }

    fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b)
            b = readByte()
        }
        return sb.toString()
    }

    fun nextInt(): Int {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var b = readByte()
        // '-' = 45
        val minus = b == 45
        if (minus) {
            b = readByte()
        }

        // '0' = 48 '9' = 57
        if (b !in 48..57) {
            throw NumberFormatException()
        }

        while (true) {
            if (b in 48..57) {
                n *= 10
                n += b - 48
            } else if (b == -1 || !isPrintableChar(b)) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextDouble(): Double = next().toDouble()
}


Measured memory_bytes: 39056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;cin>>a>>b;
    int i=1;
    bool f = false;
    for(; i<=100000; i++){
        if((int)(i*0.08)==a&&(int)(i*0.1)==b){f=true;break;}
    }
    if(f)cout<<i<<endl;
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n,x,y,l1,l2,sum=0;
    cin>>n;
    x=n/500;
    n=n%500;
    y=n/5;
	l1=1000*x;
	l2=5*y;
	sum=l1+l2;
	cout<<sum;	
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    char s[10];
    int ans[10];
    int i=0,j=0;
    for(i=0;i<10;i++)ans[i]=2;
    cin>>s;

for(i=0;i<10;i++){
    if(s[i]=='0'){
        ans[j]=0;
        j++;
    }else if(s[i]=='1'){
        ans[j]=1;
        j++;
    }else if(s[i]=='B' && j>0){
        j--;
        ans[j]=2;
    }
    
}
for(i=0;i<10;i++){
   if(ans[i]!=2) cout<<ans[i];
}
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    int n; cin >> n;
    int cnt[n + 5];
    memset(cnt, 0, sizeof cnt);
    for (int i = 2; i <= n; i++) {
        int x; cin >> x;
        cnt[x]++;
    }

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

Measured memory_bytes: 4400
N = int(input())
A = list(map(int, input().split()))
even_list = [i for i in A if i % 2 == 0]
if len(even_list) == 0:
    print('APPROVED')
else:
    cond_list = [i for i in even_list if (i % 3 == 0) or (i %5 ==0)]
    if len(even_list) == len(cond_list):
        print('APPROVED')
    else:
        print('DENIED')


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

namespace ABC127
{
    class D
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split(' ').Select(t => int.Parse(t)).ToArray();
            int N = a[0], M = a[1];

            List<long> A = Console.ReadLine().Split(' ').Select(t => long.Parse(t)).ToList();
            A.Sort();

            List<int[]> list = new List<int[]>();
            for (int i = 0; i < M; i++)
            {
                int[] d = Console.ReadLine().Split(' ').Select(t => int.Parse(t)).ToArray();
                list.Add(d);
            }

            int index = 0;
            foreach(int[] r in list.OrderByDescending(x => x[1]))
            {
                int C = r[1], B = r[0];
                for (int j = 0; j < B; j++)
                {
                    if (index >= A.Count) goto Finish;
                    if (A[index] < C)
                    {
                        A[index] = C;
                    }
                    index++;
                }                
            }

            Finish:

            long sum = A.Sum();
            Console.WriteLine(sum);
        }

    }
}


Measured memory_bytes: 33712
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static class Team implements Comparable<Team> {
		int team_num;
		int ac_num;
		int time;
		
		boolean[] ac_ed;
		int[] penalty;

		public Team(int team_num, int ac_num, int time, boolean[] ac_ed, int[] penalty) {
			super();
			this.team_num = team_num;
			this.ac_num = ac_num;
			this.ac_ed = ac_ed;
			this.penalty = penalty;
			this.time = time;
		}
		
		void answer(int number, int time){
			if(ac_ed[number]){
				return;
			}
			ac_ed[number] = true;
			ac_num++;
			this.time += time + penalty[number] * 20;
			penalty[number] = 0;
		}
		
		void wrong(int number){
			if(ac_ed[number]){
				return;
			}
			penalty[number]++;
		}

		@Override
		public int compareTo(Team o) {
			if (this.ac_num > o.ac_num) {
				return -1;
			} else if (this.ac_num < o.ac_num) {
				return 1;
			} else if (this.time < o.time) {
				return -1;
			} else if (this.time > o.time) {
				return 1;
			} else {
				return o.team_num - this.team_num;
			}
		}

	}

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

		while (true) {
			final int M = sc.nextInt();
			final int T = sc.nextInt();
			final int P = sc.nextInt();
			final int R = sc.nextInt();

			if(M == 0 && T == 0 && P == 0 && R == 0){
				break;
			}
			
			Team[] team = new Team[T];
			for(int i = 0; i < T; i++){
				team[i] = new Team(i + 1, 0, 0, new boolean[P], new int[P]);
			}
			
			for (int count = 0; count < R; count++) {
				final int m = sc.nextInt();
				final int t = sc.nextInt();
				final int p = sc.nextInt();
				final int j = sc.nextInt();
				
				boolean ac = j == 0;
				if(ac){
					team[t - 1].answer(p - 1, m);
				}else{
					team[t - 1].wrong(p - 1);
				}
			}
			
			Arrays.sort(team);
			
			for(int i = 0; i < T; i++){
				System.out.print(team[i].team_num/* + "(" + team[i].ac_num + ")"*/);
				
				if(i != T - 1 && team[i+1].ac_num == team[i].ac_num && team[i+1].time == team[i].time){
					System.out.print("=");
				}else if(i != T - 1){
					System.out.print(",");
				}
			}
			
			System.out.println();
		}
	}
}

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

int main()
{ 
  int n, m, x, y, max_x = -100, min_y = 100, a;
  bool flag;

  cin >> n >> m >> x >> y;
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    max_x = max(a, max_x);
  }
  for (int i = 0; i < m; i++)
  {
    cin >> a;
    min_y = min(a, min_y);
  }
  cout << (max(x, max_x) < min(y, min_y) ? "No War" : "War") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}


int main() {
	int n; cin >> n;
	vector<int> a(n);
	Int num, cnt = 0;

	for (int i = 0; i < n; i++) {
		cin >> num;
	//	cout << num;
		while (num % 2 == 0) {
			cnt++;
			num /= 2;
		}
		
	}
	cout << cnt;


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cassert>
using namespace std;
string s,t,u;
int cnt[50] = {};
int main(){
	cin >> s;
	long long i,n,k,ans = 0;
	cin >> k;
	n = s.size();
	for(i=0;i<n;i++){
		cnt[s[i] - 'a']++;
	}
	int num = 0;
	for(i=0;i<26;i++){
		if(cnt[i]) num++;
	}
	if(num==1){
		cout << n*k/2 << endl;
		return 0;
	}
	int j = -1;
	for(i=1;i<n;i++){
		if(s[i]!=s[i - 1]){
			j = i;
			break;
		}
	}
	for(i=0;i<j;i++){
		t.push_back(s[i]);
	}
	for(i=j;i<n;i++){
		u.push_back(s[i]);
	}
	string r = u + t;
	assert((t.size() + u.size())==n);
	assert(r.size()==n);
	for(i=1;i<n;i++){
		if(r[i]==r[i - 1]){
			r[i] = 'A';
			ans++;
		}
	}
	ans *= (k - 1);
	for(i=1;i<t.size();i++){
		if(t[i]==t[i - 1]){
			t[i] = 'A';
			ans++;
		}
	}
	for(i=1;i<u.size();i++){
		if(u[i]==u[i - 1]){
			u[i] = 'A';
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main(){
	IOS;
	int n;
	cin>>n;
	ll sum=0;
	for(int i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0)
		sum+=i;
	}
	cout<<sum;
	}

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

int main(){
    int N;
    cin >> N;
    string names[N];
    long number[5];
    for (int i = 0; i < 5; i++) {
        number[i] = 0;
    }
    for (int i = 0; i < N; i++) {
        cin >> names[i];
        switch (names[i][0]) {
            case 'M':
                number[0]++;
                break;
            case 'A':
                number[1]++;
                break;
            case 'R':
                number[2]++;
                break;
            case 'C':
                number[3]++;
                break;
            case 'H':
                number[4]++;
                break;
        }
    }
    long result = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = i + 1; j < 4; j++) {
            for (int k = j + 1; k < 5; k++) {
                result += number[i] * number[j] * number[k];
            }
        }
    }
    cout << result << endl;
}


Measured memory_bytes: 6144
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();

int main(){
  string a;
  cin>>a;
  if(a[2]==a[3]&&a[4]==a[5]){
    cout<<"Yes"<<"\n";  
  }
  else{
    cout<<"No"<<"\n";  
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
#include <utility>
#include <map>
#include <algorithm>
#include <set>
using namespace std;
using P = pair<int,int>;
using ll = long long;
constexpr int MOD=1000000007;
constexpr int MAX=510000;
long long fac[MAX], finv[MAX], inv[MAX];
bool COMinited = false;
long long COM(int n, int k) {
  if (COMinited == false) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i - 1] * i % MOD;
      inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
      finv[i] = finv[i - 1] * inv[i] % MOD;
    }
    COMinited = true;
  }
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
long long modinv(long long a, long long mod) { return modpow(a, mod - 2, mod); }
int n,a,b,c,d;
vector<vector<int>> dp(1000+1,vector<int>(1000+2,-1));
ll solve(int s,int t){
    if(dp[s][t]!=-1)return dp[s][t];
    ll ret=0;
    ret+=solve(s,t+1);
    for(int i=c;i<=d;i++){
        if(s<t*i)break;           
        ret+=COM(s,t*i)*fac[t*i]%MOD*modinv(modpow(fac[t],i,MOD),MOD)%MOD*modinv(fac[i],MOD)%MOD*solve(s-t*i,t+1)%MOD;
        ret%=MOD;
    }
    dp[s][t]=ret;
    return ret;
}
int main(){
    cin>>n>>a>>b>>c>>d;
    for(int i=a;i<=b+1;i++)dp[0][i]=1;
    for(int i=1;i<=n;i++){
        dp[i][b+1]=0;
    }
    cout<<solve(n,a)<<endl;
}


Measured memory_bytes: 16256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,c;
cin >>n>>m>>c;
vector<int>b(m);
for(int i =0;i<m;i++){
cin >> b.at(i);
}
vector<vector<int>>a(n,vector<int>(m));
for(int i =0;i<n;i++){
for(int j =0;j<m;j++){
cin >> a.at(i).at(j);
}
}
int output=0;
for(int i =0;i<n;i++){
int num = 0;
for(int j =0;j<m;j++){
num += a.at(i).at(j) * b.at(j);
}
num += c;
if(num>0){
output ++;
}
}

cout << output <<endl; 
}

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

const unsigned int B = 9973;

typedef struct node {
  struct node *next;
  char key[21]; //  char *key;
  int value;
} Node;

unsigned int compute_hash(char *a)
{
  unsigned int hash = 0;
  int len = strlen(a);
  for (int i=0; i<len; i++) hash = hash * B + a[i];
  return hash;
}

int main(){
  int n, i, x, q, hash;
  char buf[256];
  char key[21];
  char *p1, *p2;
  fgets(buf, 256, stdin);
  n = atoi(buf);
  Node **a = (Node**)malloc(sizeof(Node*)*n/2);
  for (i = 0; i < n/2; i++)  a[i] = NULL;
  for (i = 0; i < n; i++) {
    fgets(buf, 256, stdin);
    q = atoi(buf);
    p1 = index(buf, ' ') + 1;
    if (q==0) { // insert
      p2 = index(p1, ' ');
      strncpy(key, p1, p2-p1);
      key[p2-p1] = '\0';
      hash = compute_hash(key)%(n/2);
      x = atoi(p2);
      if (a[hash]==NULL) {
	a[hash] = (Node*)malloc(sizeof(Node));
	a[hash]->next = NULL;
	//	a[hash]->key = (char*)malloc(strlen(buf)+1);
	strcpy(a[hash]->key, key);
	a[hash]->value = x;
	continue;
      }
      
      Node *ptr = a[hash];
      Node *prev = ptr;
      while (ptr) {
	if (strcmp(ptr->key, key)==0) {
	  ptr->value = x;
	  break;
	}
	prev = ptr;
	ptr = ptr->next;
      }
      if (ptr==NULL) {
	ptr = (Node*)malloc(sizeof(Node));
	ptr->next = NULL;
	//	ptr->key = (char*)malloc(strlen(buf)+1);
	strcpy(ptr->key, key);
	ptr->value = x;
	prev->next = ptr;
      }
      
    } else if (q==1) { // find
      p2 = index(p1, '\n');
      strncpy(key, p1, p2-p1+1);
      key[p2-p1] = '\0';
      hash = compute_hash(key)%(n/2);
      Node *ptr = a[hash];
      while (ptr) {
	if (strcmp(ptr->key,key)==0) {
	  int b = ptr->value;
	  int j;
	  for (j=1; j*10<=b; j*=10);
	  for (; j>0; j/=10) {
	    putc_unlocked('0'+b/j, stdout);
	    b %= j;
	  }
	  putc_unlocked('\n', stdout);
	  break;
	}
	ptr = ptr->next;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 11768
from itertools import accumulate

n, k = map(int, input().split())
a = list(map(int, input().split()))

cnt = 1
while cnt <= k and min(a) < n:
    li = [0] * (n + 1)
    for i, e in enumerate(a):
        l = max(0, i - e)
        r = min(n, i + e + 1)
        li[l] += 1
        li[r] -= 1

    a = list(accumulate(li))[:-1]

    cnt += 1

print(*a)


Measured memory_bytes: 180988
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  auto n = readln.chomp.to!int;
  auto s = new int[](n);
  foreach (i; 0..n) {
    s[i] = readln.chomp.to!int;
  }

  s = sort(s).array;
  int t;
  foreach (i; 0..n) {
    if (s[i] % 10) {
      t = s[i];
      break;
    }
  }

  auto sum = s.sum;
  if (sum % 10) {
    sum.writeln;
  } else if (t) {
    writeln(sum - t);
  } else {
    writeln("0");
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define endl '\n'
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    vector<bool> dp(1000010, true);
    int ans = 0;
    rep(i, n)
    {
        if(dp[v[i]]==false){
            continue;
        }
        if (i + 1 < n && v[i] == v[i + 1])
        {
            dp[v[i]] = false;
        }
        ans += dp[v[i]];
        for (int j = v[i]; j <= 1000000; j += v[i])
        {
            dp[j] = false;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4336
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Console.WriteLine(Solve());
		Out.Flush();
	}
	int Solve()
	{
		var N = F();
		var D = G();
		var cnt = new int[13];
		foreach (var d in D) cnt[d]++;
		var t = 0;
		if (cnt[0] > 0 || cnt[12] > 1) return 0;
		for (var i = 1; i < 12; i++)
		{
			if (cnt[i] > 2) return 0;
			if (cnt[i] > 0) t++;
		}
		var max = 0;
		for (var i = 0; i < (1 << t); i++)
		{
			var s = new bool[24];
			s[0] = true;
			s[12] = cnt[12] > 0;
			var j = 0;
			for (var k = 1; k < 12; k++)
			{
				if (cnt[k] == 0) continue;
				if (cnt[k] == 2) s[k] = s[24 - k] = true;
				else if ((i & (1 << (j++))) != 0) s[k] = true;
				else s[24 - k] = true;
			}
			var l = 23;
			while (!s[l]) l--;
			var min = 24 - l;
			j = 0;
			while (true)
			{
				var k = j + 1;
				while (k < 24 && !s[k]) k++;
				min = Min(min, k - j);
				if ((j = k) >= l) break;
			}
			max = Max(max, min);
		}
		return max;
	}
}


Measured memory_bytes: 13396
n = int(input())
p = [int(_) for _ in input().split()]
c = 0
for i in range(1, n-1):
    if p[i+1] > p[i] and p[i] > p[i-1]:
        c += 1
    elif p[i-1] > p[i] and p[i] > p[i+1]:
        c += 1
print(c)

Measured memory_bytes: 38384
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
#include <functional>

using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 9901 //1000000007LL
#define rep(i,a,n) for (int i=a ; i<n ; i++)
#define per(i,a,n) for (int i=n-1 ; i>=a ; i--)
#define LLINF 100000000000000005LL
#define INF (int)1e9+1
#define endl '\n'
#define pb push_back

// debug 도구

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
    return '"' + s + '"';
}

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

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

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto& x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}\n";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)

// debug 도구 end

using llong = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VPII = vector<pair<int, int>>;
using VLL = vector<long long>;
using PII = pair<int, int>;

int main()
{
    IOS;

    int w, a, b;
    cin >> w >> a >> b;
    if (a <= b && a + w <= b) cout << b - a - w;
    else if (b <= a && b + w <= a) cout << a - b - w;
    else cout << 0;
    cout << endl;

    return 0;
}

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

int main() {
  string str;
  cin>>str;
  
  int i;
  int sum=0;
  for(i=0;i<str.size();i++){
    if(str.at(i)=='1')sum++;
  }
  cout<<sum<<endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 1;

vector<int> a;
vector<vector<int>> graph;
vector<int> dp;
vector<int> ans;

void DFS(int v, int parent_v = -1){
    int update = lower_bound(dp.begin(), dp.end(), a[v]) - dp.begin();
    int previous = dp[update];
    dp[update] = a[v];
    ans[v] = lower_bound(dp.begin(), dp.end(), INF) - dp.begin() - 1;

    for(int child_v : graph[v]){
        if(child_v == parent_v) continue;

        DFS(child_v, v);
    }
    dp[update] = previous;
}

int main(){
    int n;
    cin >> n;
    a.resize(n);
    graph.resize(n);
    ans.resize(n);

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

    for(int i=0; i<n-1; i++){
        int u, v;
        cin >> u >> v;
        u -= 1;
        v -= 1;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    dp.assign(n+1, INF);
    dp[0] = -INF;

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

Measured memory_bytes: 28016
import java.util.Scanner;

public class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long [] dp = new long[N+1];
        dp[0] = 2;
        dp[1] = 1;
        for (int i=2;i<=N;i++){
            dp[i] = dp[i-1] + dp[i-2];
        }
        System.out.println(dp[N]);
    }
}

Measured memory_bytes: 22100
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;

ll my_gcd(ll a, ll b){
	return (b==0) ? a : my_gcd(b, a%b);
}

ll my_lcm(ll a, ll b){
	return a*b / my_gcd(a,b);
}

ll factorial(ll a){
	ll ans = 1;
	for(ll i=a; i>0; i--){
		ans *= i;
	}
	return ans;
}

ll pow(ll a, ll b) {
	ll a_powered = 1;
	for (int i=0; i<b; i++) { a_powered *= a;
	}
	return a_powered;
}


int main(int argc, char *argv[]){
	int N, D;
	cin >> N >> D;

	int bunbo = 2*D + 1;
	int ans = (N + (bunbo - 1)) / bunbo;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
using namespace std;
const ll INF = 1e10;
int n;
ll c,ans,now,x,v,mx[100005],mx2[100005];
vector<ll> xs(100005),vs(100005);
int main(){
  cin>>n>>c;
  for(int i=1;i<=n;i++){
    cin>>x>>v;
    xs[i]=x;
    vs[i]=vs[i-1]+v;
  }
  xs[n+1]=c;
  vs[n+1]=vs[n];
  for(int i=1;i<=n;i++){
    mx[i]=max(mx[i-1],vs[i]-xs[i]);
    mx2[i]=max(mx2[i-1],vs[i]-2*xs[i]);
  }
  for(int j=n+1;j>0;j--){
    ll d=vs[n]-vs[j-1]-(c-xs[j]);
    ans=max(ans,d+mx[j-1]-(c-xs[j]));
    ans=max(ans,d+mx2[j-1]);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

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

	Scanner sc = new Scanner(System.in);

	void run() {
		String s = sc.next();		
		String k = "keyence";
		
		int f=0;
		int b=0;
		for(int i = 0; i < Math.min(s.length(), k.length() );i++){
			if(s.charAt(i) == k.charAt(i)){
				f++;
			}else{
				break;
			}
		}

		for(int i = 0; i < Math.min(s.length(), k.length() );i++){
			if(s.charAt(s.length()-i-1) == k.charAt(k.length()-i-1)){
				b++;
			}else{
				break;
			}
		}

		if(f+b >= k.length()){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
	

	
}


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

int dir[2][2] = {{0,1},{1,0}};
const int maxn = 85;
int t[maxn][maxn];
long long ans;

struct STA {
	int x,y;
	long long val;
	STA() {}
	STA(int x,int y,int val):x(x),y(y),val(val) {}
	void display() {
		cout << x << " " << y << endl;
	}
};
bool app[maxn][maxn][13000];

int H,W;
inline bool isIn(int x,int y) {
	return (x>=1 && x<=H && y>=1 && y<=W);
}

void bfs(int x,int y) {
	STA now;
	queue<STA> list;
	list.push({x,y,t[x][y]});
	while(!list.empty()) {
		now = list.front();
		list.pop();
		if(now.x == H && now.y == W) ans = min(now.val,ans);
		else {
			if(app[now.x][now.y][now.val]) continue;
			app[now.x][now.y][now.val] = 1;
			for(int i=0; i<2; i++) {
				x = now.x + dir[i][0];
				y = now.y + dir[i][1];
				if(isIn(x,y)) {
					list.push({x,y,now.val+(long long int)t[x][y]});
					list.push({x,y,abs(now.val-(long long int)t[x][y])});
				}
			}
		}
	}
}

int main() {
	int tp;
	ans = INT_MAX;
	cin >> H >> W;
	for(int i=1; i<=H; i++)
		for(int j=1; j<=W; j++)
			cin >> t[i][j];
	for(int i=1; i<=H; i++)
		for(int j=1; j<=W; j++) {
			cin >> tp;
			t[i][j] = abs(tp-t[i][j]);
		}
	bfs(1,1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 105104
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> a;

int main()
{
	ll n,m,tmp;
	ll ans;

	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> tmp;
		a.push_back(tmp);
	}

	ll sum = accumulate(a.begin(), a.end(), 0);

	if (sum <= n) {
		ans = n - sum;
		cout << ans << endl;
	}
	else {
		ans = -1;
		cout << ans << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3704
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
using namespace std;

const int INF = INT_MAX / 3;

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()


double EPS = 1e-10;

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) return 0;
	return a + b;
}

struct P {
	double x, y;
	P() {}
	P(double x, double y) : x(x), y(y) {
	}
	P operator +(P p) {
		return P(add(x, p.x), add(y, p.y));
	}
	P operator -(P p) {
		return P(add(x, -p.x), add(y, -p.y));
	}
	P operator *(double d) {
		return P(d*x, d*y);
	}
	double dot(P p) {
		return add(x*p.x, y*p.y);
	}
	double det(P p) {
		return add(x*p.y, -y*p.x);
	}
	void print() {
		printf("%.10lf %.10lf \n", x, y);
		return;
	}
};

double dist(P p1, P p2) {
	double dx = p1.x - p2.x;
	double dy = p1.y - p2.y;
	return sqrt(dx*dx + dy*dy);
}

bool x_asc(const P& left, const P& right) {
	return left.x < right.x;
}

bool y_asc(const P& left, const P& right) {
	return left.y < right.y;
}

void merger(vector<P> &pointList, int start, int m, int end) {
	vector<P> tmp(end - start + 1);
	int i = start;
	int j = m + 1;
	for (int k = 0; k<end - start + 1; k++) {

		if (i == m + 1) {
			tmp[k] = pointList[j];
			j++;
			continue;
		}
		if (j == end + 1) {
			tmp[k] = pointList[i];
			i++;
			continue;
		}
		if (pointList[i].y >= pointList[j].y) {
			tmp[k] = pointList[j];
			j++;
			continue;
		}
		if (pointList[i].y < pointList[j].y) {
			tmp[k] = pointList[i];
			i++;
			continue;
		}
	}

	for (int i = start; i<end + 1; i++) {
		pointList[i] = tmp[i-start];
	}
}

double closestPoint(vector<P> &pointList, int start, int end) {
	int n = end - start + 1;
	int m = (start+end) / 2;
	double center = pointList[m].x;
	double d;
	if (start == end) return INF;
	d = min(closestPoint(pointList, start, m), closestPoint(pointList, m + 1, end));
	merger(pointList, start, m, end);

	vector<P> rangeList;
	for (int i = start; i<end + 1; i++) {
		if (fabs(pointList[i].x - center) >= d) continue;

		for (int j = rangeList.size() - 1; j>-1; j--) {
			double dd = dist(rangeList[j], pointList[i]);
			if (pointList[i].y - rangeList[j].y > d) break;
			d = min(d, dd);
		}
		rangeList.push_back(pointList[i]);

	}
	return d;
}

int main() {
	int n;
	scanf("%d", &n);
	vector<P> pointList(n);
	REP(i, n) {
		scanf("%lf", &pointList[i].x);
		scanf("%lf", &pointList[i].y);
	}

	sort(ALL(pointList), x_asc);

	printf("%.10lf \n", closestPoint(pointList, 0, pointList.size() - 1));
	return 0;
}

Measured memory_bytes: 5876
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


h,w,n = list(map(int, input().split()))
rr,cc = list(map(int, input().split()))
rr -= 1
cc -= 1
s = input()
t = input()
def sub(s,t,init,limit):
    c = init
    for ss,tt in zip(s,t):
        if ss:
            c += 1
            if c>=limit:
                ans = True
                break
        if tt:
            c -= 1
            c = max(0, c)
    else:
        ans = False
    return ans
v1 = sub([item=="U" for item in s], [item=="D" for item in t], h-1-rr, h)
v2 = sub([item=="D" for item in s], [item=="U" for item in t], rr, h)
v3 = sub([item=="L" for item in s], [item=="R" for item in t], w-1-cc, w)
v4 = sub([item=="R" for item in s], [item=="L" for item in t], cc, w)
if v1 or v2 or v3 or v4:
    ans = "NO"
else:
    ans = "YES"
print(ans)

Measured memory_bytes: 111212
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		// small
		
		int[] D = new int[N];
		D[0] = 1;
		for(int i=1;i<N;i++){
			D[i] = Math.Min(D[i-1]+2,A[i]);
		}
		
//Console.WriteLine("D:" + String.Join(" ",D));
		
		long mod = (long)1e9+7;
		long ans = 1;
		
		int t=0;
		for(int i=0;i<N;i++){
			while(t<N-1 && D[t] > (t-i)*2 ){
				t++;
			}
//Console.WriteLine("i:{0},t:{1}",i,t);
			ans *= (t + 1 - i);
			if(ans >= mod) ans %= mod;
		}
		Console.WriteLine(ans);
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}
	

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;

#define int ll
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pi> vp;
typedef vector<pl> vpl;

int n, k;
const int mod = 1e9 + 7;

void f(int& x){
    if (x >= mod) x%= mod;
}

struct M{
    vector<vi> a;

    M(int n){
        a.resize(n, vi(n, 0));
    }

    M(int n, int x){
        a.resize(n, vi(n, 0));
        for (int i = 0; i < n; ++i)
            a[i][i] = 1;
    }

    M operator* (const M& b) const {
        M c(n);

        for (int i = 0; i < n; ++i){
            for (int j = 0; j < n; ++j){
                for (int k = 0; k < n; ++k){
                    int y = a[i][k] * b.a[k][j];
                    f(y);
                    c.a[i][j] += y;
                    f(c.a[i][j]);
                }
            }
        }

        return c;
    }
};

M stepen(M a, int s){
    if (s == 0)
        return M(n, 1);

    if (s == 1)
        return a;

    M tmp = stepen(a, s / 2);
    tmp = tmp * tmp;
    if (s & 1)
        tmp = tmp * a;
    return tmp;
}    


signed main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr); 
    cout.tie(nullptr); 
    cerr.tie(nullptr);    

    cin >> n >> k;

    M a(n);
    for (int i = 0; i < n; ++i){
        for (int j = 0; j < n; ++j){
            cin >> a.a[i][j];
        }
    }

    M sol = stepen(a, k);
    int s = 0;
    for (int i = 0; i < n; ++i){
        for (int j = 0; j < n; ++j){
            s += sol.a[i][j];
            f(s);
        }
    }

    cout << s << '\n';
}   

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	int n, x, y, z;
	cin >> n;
	cin >> x;
	int a=1, b=0, cnt=0, muri=0;
	rep(i, n-1)
	{
		cin >> y;
		if(cnt==0)
		{
			if(y==x) a++;
			else
			{	
				z=y-x;
				if(z==1) cnt=1, b++;
				else if(z==-1) cnt=-1, b++;
				else
				{
					muri=1;
					break;
				}
			}
		}
		else
		{
			if(y==x) a++;
			else
			{
				if(y!=x+cnt)
				{
					muri=1;
					break;
				}
				else b++;
			}
		}
	}
	if(muri==1) cout << "No" << endl;
	else
	{
		if(cnt==0)
		{
			if(x==n-1 || x<=n/2) cout << "Yes" << endl;
			else cout << "No" << endl;
		}
		else if(cnt==1)
		{
			z=x+1-a;
			if(z>=1 && z<=b/2) cout << "Yes" << endl;
			else cout << "No" << endl;
		}
		else
		{
			z=x-b;
			if(z>=1 && z<=a/2) cout << "Yes" << endl;
			else cout << "No" << endl;
		}
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  int ma=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      int diff=abs(A.at(i)-A.at(j));
      if(diff>ma){
        ma=diff;
      }
    }
  }
  cout << ma << endl;
  return 0;
}


Measured memory_bytes: 256
def gcd(m, n):
  x=max(m, n)
  y=min(m, n)
  while x%y!=0:
    z=x%y
    x=y
    y=z
  else:
    return(y)

A,B=map(int, input().split())
print(int(A*B / gcd(A, B)))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, greater_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	int n;
	string s;
	cin >> n >> s;
	ll ans = 0;
	vl R(n + 1, 0), G(n + 1, 0), B(n + 1, 0);
	for (int i = n - 1;i >= 0;i--) {
		R[i] = R[i + 1];
		G[i] = G[i + 1];
		B[i] = B[i + 1];
		R[i] += (s[i] == 'R');
		G[i] += (s[i] == 'G');
		B[i] += (s[i] == 'B');
	}
	for (int i = 0;i < n;i++) {
		for (int j = i + 1;j < n;j++) {
			if (s[i] != s[j]) {
				int k = j - i + j;
				if (s[i] != 'B' && s[j] != 'B') {
					ans += B[j + 1];
					if (k < n && s[k] == 'B')
						ans--;
				}
				if (s[i] != 'R' && s[j] != 'R') {
					ans += R[j + 1];
					if (k < n && s[k] == 'R')
						ans--;
				}
				if (s[i] != 'G' && s[j] != 'G') {
					ans += G[j + 1];
					if (k < n && s[k] == 'G')
						ans--;
				}
			}
		}
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3748
def convert(s): 
  
    # initialization of string to "" 
    new = "" 
  
    # traverse in the string  
    for x in s: 
        new += x  
  
    # return string  
    return new 
n=input()
ans=0
for i in range(len(n)):
  for j in range(len(n)-i):
    if j==len(n)-i-1:
      ans+=int(n[i])*(2**(len(n)-j-1))*(10**j)
    else:
      ans+=int(n[i])*(2**(len(n)-j-2))*(10**j)
print(ans)

Measured memory_bytes: 38256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	
      	long[] arr = new long[n];

      	for(int i = 0; i<n; i++){
          arr[i] = sc.nextInt();
        }
		long pre = 0;
      	long now = 0;
      	long sum = 0;
      	for(int i = 0; i<n; i++){
          if (i == 0){
            continue;
          }
          now = arr[i];
          pre = arr[i-1];
          if(now > pre){
            continue;
          }
          long step = pre - now;
          sum += step;
          arr[i] = pre;
        }
      System.out.println(sum);
    }
}

Measured memory_bytes: 62416
#include<stdio.h>

int gcd(int x, int y);

int main()
{
  int a, b;
  scanf("%d %d",&a, &b);
  printf("%d\n", gcd(a, b));

  return 0;
}

int gcd(int x,int y){
  return y ? gcd(y, x%y) : x;
}


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

using namespace std;

int main(){
    int n, k; cin >> n >> k;

    int arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];

    int dp[k+1];

    memset(dp, 0, sizeof dp);

    // init
    for (int i = 0; i < n; i++){
            dp[arr[i]] = 1;
    }

    for (int i = arr[0]; i <= k; i++){
        if (!dp[i]){
            bool f = false;
            for (int j = 0; j < n and arr[j] <= i; j++){
                if (!dp[i-arr[j]]){
                    f = true; break;
                }
            }

            if (f) dp[i] = 1;
        }
    }

    if (dp[k]) cout << "First";
    else cout << "Second";
    cout << endl;


    
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define debug(x) cerr << "\n" \
                      << #x << " = " << x << ".\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define print(xx) cout << (xx) << endl
using namespace std;
#define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
const int INF = ((1LL << 30) + (1LL << 29));
const ll MOD = 1000000007;

/* 
*/

//=================================================
int N;
//=================================================
void input()
{
    cin>>N;
}

//=================================================
void solve()
{
    cout<<3 * N * N<<endl;


}

//=================================================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define IOS cin.tie(NULL);cout.tie(NULL)
#define F first
#define S second
#define pb push_back
using namespace std;

int main() {
	IOS;
	ll n,ans,key1,key2;
	cin>>n;
	ll arr[n+1];
	for(ll i=0;i<n;i++){
		cin>>arr[i];
		if(i==0){
			key1=0;
			ans=key1;
		} else if(i==1){
			key2=abs(arr[i]-arr[i-1]);
			ans=key2;
		}else{
			ans= min(key1+abs(arr[i]-arr[i-2]),key2+abs(arr[i]-arr[i-1]));
			key1=key2;
			key2=ans;
		}
	}
	cout<<ans;

}


Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	p := make([]float64, n)
	for i := 0; i < n; i++ {
		p[i], _ = strconv.ParseFloat(Scanner(), 64)
	}
	dp := make([][]float64, n+1)
	for i := 0; i < n+1; i++ {
		dp[i] = make([]float64, n+1)
	}
	dp[0][0] = 1
	for i := 1; i < n+1; i++ {
		dp[i][0] = dp[i-1][0] * (1. - p[i-1])
		for j := 1; j < n+1; j++ {
			dp[i][j] = dp[i-1][j-1]*p[i-1] + dp[i-1][j]*(1.-p[i-1])
		}
	}
	ans := 0.
	for j := 0; j < n+1; j++ {
		if j > n-j {
			ans += dp[n][j]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 75392