akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	double a, b;
	cin >> a >> b;
	cout << ceil ((a + b)/2) << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())

if n <= k // 2:
    print(n)

else:
    sho = n // k
    n -= k * sho
        
    for i in range(1000000000000000000000):
        n = abs(n - k)
        if n <= k // 2:
            break

    print(n)

Measured memory_bytes: 2940
import math
def P(n, r):
    return math.factorial(n)//math.factorial(n-r)
def C(n, r):
    return P(n, r)//math.factorial(r)
S = input()[::-1]
N = len(S)
cnt = [0]*(N+1)
ans = 0
keta = 1
for i in range(N):
    cnt[i] = (cnt[i-1] + int(S[i])*keta)%2019
    keta *= 10
    keta %= 2019
cnt2 = [0]*2020
for i in cnt:
    cnt2[i] += 1
for i in cnt2:
    if i >= 2:
        ans += C(i,2)
print(ans)

Measured memory_bytes: 76180
#include <bits/stdc++.h>
using namespace std;
using llong = long long;

void fnInput(int& rnLeft, int& rnRigt)
{
  cin >> rnLeft >> rnRigt;
}
  
int fnRemainMin2019(int nLeft, int nRigt)
{
  if (nLeft + 2018 < nRigt) return 0;          // 2019 で割り切れる数が存在

  int nRemMin2019 = INT_MAX;

  for (int i = nLeft; i < nRigt; i++)
    for (int j = i + 1; j < nRigt + 1; j++)
    {
      int nRem2019 = (llong)i * j % 2019;
      nRemMin2019 = min(nRemMin2019, nRem2019);
    }

  return nRemMin2019;
}
  
int main()
{
  int nLeft, nRigt;
  fnInput(nLeft, nRigt);
  cout << fnRemainMin2019(nLeft, nRigt) << endl;

  return 0;
}

Measured memory_bytes: 256
S = input()
T = input()
s = list(S)
t = list(T)

s_len = len(s)
t_len = len(t)
ans = s[:]
question_num = 0
unrestorable = True
for i in range(s_len):
    si = (s_len-1) - i
    restorable = True
    if s_len - si >= t_len:
        for ti in range(t_len):
            w = s[si+ti]
            if w == "?" or w == t[ti]:
                continue
            restorable = False
    else:
        restorable = False
    if restorable:
        unrestorable = False
        for ti in range(t_len):
            ans[si+ti] = t[ti]
        break

for i in range(s_len):
    if ans[i] == "?":
        ans[i] = "a"

if unrestorable:
    print("UNRESTORABLE")
else:
    print(''.join(ans))


Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
#define repr(i ,n) for(int i=n;i>(int)(n);--i)
#define rep1(i ,n) for(int i=1;i<=(int)(n);++i)
#define ALL(a) a.begin(), a.end()
#define RSORT(a) sort(ALL(a),greater<>())
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define PRINT(x) cout << (x) << endl;
#define ENDL cout << endl;
using namespace std;
typedef long long int i64;
typedef unsigned long long u64;
template<class T> using V = vector<T>;
using VI = V<int>;
const int INF = 2e9;
const i64 MOD = 1e9 + 7;

template <class T> inline bool chmin(T& a, T b){if(a>b){a=b; return true;} return false;}
template <class T> inline bool chmax(T& a, T b){if(a<b){a=b; return true;} return false;}
struct Init_On{
    Init_On(){
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(16);
    }
};

signed main(){
    int n; cin >> n;
    vector<int> x(n);
    rep(i , n) cin >> x[i];
    int min = INF;
    auto a = min_element(ALL(x));
    auto b = max_element(ALL(x));
    int lhs = *a , rhs = *b;
    for(int i = lhs ; i <= rhs ; ++i){
        int sum = 0;
        rep(j , n){
            sum +=( i - x[j]) * ( i - x[j]);
        }
        if(min > sum) min = sum;
    }
    cout << min << endl;
}

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

int main() {
    int h,w;
    cin >> h >> w;
    
    vector<vector<char>> grid(h,vector<char>(w));
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        cin >> grid.at(i).at(j);
      }
    }

    const int dy[4]={0,1,0,-1};
    const int dx[4]={1,0,-1,0};
    
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if(grid.at(i).at(j)=='#'){
                bool can=false;
                for (int k = 0; k < 4; k++){
                    int ny=i+dy[k];
                    int nx=j+dx[k];
                    if(0<=ny && ny<h && 0<=nx && nx<w){
                        if(grid.at(ny).at(nx)=='#'){
                            can=true;
                        }
                    }
                }
                if(!can){
                    cout << "No" << endl;
                    exit(0);
                }
            }
        }
    }

    cout << "Yes" << endl;
    
}

Measured memory_bytes: 3632
N, A, B = map(int, input().split())
v = [int(i) for i in input().split()]

v.sort(reverse=1)

V = v[A-1]
print(sum(v[:A]) / A)

before = 0
after = 0
all = False
for i in range(A):
    if v[i] == V:
        if i == 0:
            all = True
        before = A - i
        break
for i in range(A, N):
    if v[i] == V:
        after += 1
    else:
        break

def C(n,k):
    ans = 1
    for i in range(k):
        ans *= (n-i)
    for i in range(1, k+1):
        ans //= i
    return ans

if all:
    ans = 0
    for i in range(before, min(B+1, before+after+1)):
        ans += C(before+after, i)
    print(ans)
else:
    print(C(before+after, before))

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

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	int ret = 0;
	for (int i = 0; i < n; i++)
	{
		while (a[i] > 0)
		{
			ret++;
			for (int j = i; j < n && a[j] > 0; j++)a[j]--;
		}
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
	int N;
	double r=0.0,t;
	string s;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>t>>s;
		if(s[0]=='B')
		{
			r+=t*380000.0;
		}
		else
		{
			r+=t;
		}
	}
	printf("%.5f\n",r);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fo(i,n) for(i=0;i<n;i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
vector<pair<int,int> >g[100005];
int vis[100005],color[100005];
void dfs(int v)
{
     vis[v]=1;
     for(int i=0;i<g[v].size();i++){
     	if(vis[g[v][i].first]==0)
     	{
     		if(g[v][i].second%2==0)color[g[v][i].first]=color[v];
     		else color[g[v][i].first]=1-color[v];
     		dfs(g[v][i].first);
     	}
     }
}


int main()
{
	int t,n,m,i,j,u,v;
	cin>>n;
	for(i=0;i<n-1;i++)
	{
		cin>>u>>v>>m;
         g[u].push_back({v,m});
         g[v].push_back({u,m});
	}
   color[1]=0;
   dfs(1);
   for(i=1;i<=n;i++)cout<<color[i]<<"\n";

}

Measured memory_bytes: 8704
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

int main() {
    string S;
    cin >> S;

    if (S == "SUN") cout << 7;
    else if (S == "MON") cout << 6;
    else if (S == "TUE") cout << 5;
    else if (S == "WED") cout << 4;
    else if (S == "THU") cout << 3;
    else if (S == "FRI") cout << 2;
    else if (S == "SAT") cout << 1;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;

int main()
{
	map<int, int> first;
	map<int, int> seq;
	char buf[128];
	int a, b;
	while (true)
	{
		cin.getline(buf, sizeof(buf));
		if (strlen(buf) == 0)
			break;
		sscanf(buf, "%d,%d", &a, &b);
		if (first.count(a) > 0)
			++first[a];
		else
			first.insert(make_pair(a, 1));
	}
	while (scanf("%d,%d", &a, &b) != EOF)
	{
		if (first.count(a) > 0)
		{
			if (seq.count(a) > 0)
				++seq[a];
			else
				seq.insert(make_pair(a, first[a]+1));
		}
	}
	for (map<int, int>::iterator it = seq.begin(); it != seq.end(); ++it)
		printf("%d %d\n", it->first, it->second);

	return 0;
}

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

int main(){
  int n,k;
  cin >>n >>k;
  int num[n] = {0};
  rep(i,k){
    int d;
    cin >>d;
    vector<int> a(d);
    rep(j,d){
      cin >>a[j];
      num[a[j]-1]++;
    }
  }
  int ans = 0;
  rep(i,n){
    if(!num[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3624
import itertools
N, M, Q = map(int, input().split())
query = []
for i in range(Q):
    query.append(list(map(int, input().split())))

As = list(itertools.combinations_with_replacement(range(1, M+1), N))
ans = 0
for a in As:
    point = 0
    for q in query:
        if a[q[1]-1] - a[q[0]-1] == q[2]:
            #print(a, " + ", q)
            point += q[3]
    ans = max(ans, point)
    #print(point)

#print(As)
#print(query)
print(ans)

Measured memory_bytes: 21608
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());

        double y = 0.0;
        int rate = 380000;

        for(int i=0; i<n; i++) {
            var spl = input.ReadLine().Split(' ');
            var x = spl[0];
            var u = spl[1];

            if(u == "JPY") {
                y += int.Parse(x);
            } else {
                y += double.Parse(x) * rate;
            }
        }

        return y;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 11220
#include <cstdio>
#define ll long long
ll mod = 1000000007;
ll big(ll b, ll p){
	if (p == 1) return b;
	ll h = big(b, p / 2);
	ll res = (h * h) % mod;
	if (p % 2 == 1) res = (res * b) % mod;
	return res;
}
int main(){
	ll n, m, k, ans = 1, x = 0, y = 0;
	scanf("%lld %lld %lld", &n, &m, &k);
	for (int i = 2; i < k; i++){
		ans *= (n * m) - i;
		ans %= mod;
	}
	for (int i = 1; i < n; i++){
		x += i * (n - i);
		x %= mod;
	}
	x = (x * m) % mod;
	x = (x * m) % mod;
	for (int i = 1; i < m; i++){
		y += i * (m - i);
		y %= mod;
	}
	y = (y * n) % mod;
	y = (y * n) % mod;
	ans = ans * (x + y) % mod;
	for (int i = k - 2; i > 1; i--){
		ans = (ans * big(i, mod - 2)) % mod;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

ll gcd(ll x, ll y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̒萔 (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int l,r, d;
    string s;
    cin >> l >> r >> d;
    int ans = 0;

    for (int i = l; i <= r; i++) {
        if (i % d == 0)
            ans++;
    }

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

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
ll gcd(ll x, ll y) {
    ll num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

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

int main(){
  string S;
  cin>>S;
  int num=0;
  if(S[0]=='A'){
    num++;
  }
  int num_1=0;
  int size=S.size();
  for(int i=2;i<size-1;i++){
    if(S[i]=='C'){
      num_1++;
    }
  }
  if(num_1==1){
    num++;
  }
  int num_2=0;
  for(int i=0;i<size;i++){
    if(isupper(S[i])) num_2++;
  }
  if(num_2==2) num++;

  if(num==3) cout<<"AC"<<endl;
  else cout<<"WA"<<endl;

}


Measured memory_bytes: 3564
#include<stdio.h>
#include<algorithm>
#include<queue>
using namespace std;
int m[210][210];
int p[1100];
int q[1100];
int dx[2][7]={{0,1,1,0,-1,-1,0},{0,1,1,0,-1,-1,0}};
int dy[2][7]={{1,0,-1,-1,-1,0,0},{1,1,0,-1,0,1,0}};
int ijk[210][210][6];
int v[210][210][6];
int ABS(int a){return max(a,-a);}
int main(){
	int sr,sc,gr,gc;
	scanf("%d%d%d%d",&sr,&sc,&gr,&gc);
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d%d",p+i,q+i);
	}
	int H,W;
	scanf("%d%d",&H,&W);
	for(int i=0;i<a;i++){
		m[p[i]+H][q[i]+W]=1;
	}
	for(int i=0;i<=2*H;i++)for(int j=0;j<=2*W;j++)for(int k=0;k<6;k++)
		ijk[i][j][k]=999999999;
	deque<pair<pair<int,int>,pair<int,int> > > Q;
	Q.push_back(make_pair(make_pair(0,0),make_pair(sr,sc)));
	ijk[sr+H][sc+W][0]=0;
	while(Q.size()){
		int cost=Q.front().first.first;
		int dir=Q.front().first.second;
		int row=Q.front().second.first;
		int col=Q.front().second.second;
		int ty=ABS(row)%2;
		Q.pop_front();
		if(v[row+H][col+W][dir])continue;
		v[row+H][col+W][dir]=1;
		int to=ABS(dir*row*col)%6;
		for(int i=0;i<7;i++){
			if(row+dx[ty][i]<-H||row+dx[ty][i]>H||col+dy[ty][i]<-W||
			col+dy[ty][i]>W)continue;
			int tr=row+dx[ty][i];
			int tc=col+dy[ty][i];
			if(m[tr+H][tc+W])continue;
			if(to==i){
				if(ijk[tr+H][tc+W][(dir+1)%6]>cost){
					ijk[tr+H][tc+W][(dir+1)%6]=cost;
					Q.push_front(make_pair(make_pair(cost,(dir+1)%6),make_pair(tr,tc)));
				}
			}else{
				if(ijk[tr+H][tc+W][(dir+1)%6]>cost+1){
					ijk[tr+H][tc+W][(dir+1)%6]=cost+1;
					Q.push_back(make_pair(make_pair(cost+1,(dir+1)%6),make_pair(tr,tc)));
				}
			}
		}
	}
	int ret=999999999;
	for(int i=0;i<6;i++)ret=min(ret,ijk[gr+H][gc+W][i]);
	if(ret>99999999)printf("-1\n");
	else printf("%d\n",ret);
}

Measured memory_bytes: 3188
import java.io.PrintWriter
import java.util.*

var n = 0
var c = 0L

fun main(args: Array<String>) = IO().exec {
    n = int()
    c = long()
    val x = LongArray(n)
    val v = LongArray(n)
    for (i in 0 until n) {
        x[i] = long()
        v[i] = long()
    }
    var ret = calc(x, v)
    x.reverse()
    for (i in 0 until n) x[i] = c - x[i]
    v.reverse()
    ret = Math.max(ret, calc(x, v))
    println(ret)
}

fun calc(x: LongArray, v: LongArray): Long {
    val cumv = Cum(v)
    val g = LongArray(n+1)
    for (i in 0 until n)
        g[i+1] = Math.max(g[i], cumv[0..i] - x[i])
    var ret = g[n]
    for (i in 0 until n) {
        ret = Math.max(ret, g[i] + cumv[i until n] - (c - x[i]) * 2)
    }
    return ret
}

class Cum(val a: LongArray) {
    val s = LongArray(a.size + 1)
    init {
        for (i in 0 until a.size) {
            s[i+1] = s[i] + a[i]
        }
    }
    operator fun get(range: IntRange): Long = s[range.last+1] - s[range.first]
}

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = PrintWriter(System.out)
    fun hasNextByte(): Boolean = if (ptr < buflen) true else {
        ptr = 0
        buflen = System.`in`.read(buffer)
        buflen > 0
    }
    fun readByte(): Byte = if (hasNextByte()) buffer[ptr++] else -1
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double = string().toDouble()
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}

Measured memory_bytes: 46472
#include "bits/stdc++.h"
using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int l[n];
  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }
  sort(l, l + n);

  int max = n-1;
  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += l[max];
    max--;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int a,b,i;
  int d=0;
  int c[10000];
  scanf("%d",&a);
  scanf("%d",&b);
  for(i=0;i<b;i++){
    scanf("%d",&c[i]);
    d+=c[i];
  }
  a=a-d;
  if(a<-1)
    a=-1;
  printf("%d",a);
  return 0;
}


Measured memory_bytes: 1764
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	Scanner sc = new Scanner(System.in);
	int n, k, s;
	int[][][] memo;
	public void run(){
		while(true){
			n = sc.nextInt();
			k = sc.nextInt();
			s = sc.nextInt();
			if(n==0 && k==0 && s==0) break;
			memo = new int[n+2][k+1][s+1];
			int ans = calc(n+1, 0, s);
			System.out.println(ans);
		}
	}
	public int calc(int nc, int kc, int sum){
		if(memo[nc][kc][sum] != 0) return memo[nc][kc][sum];
		
		int ans = 0;
		
		if(kc == k){
			if(sum == 0) {
				memo[nc][kc][sum] = 1;
				return 1;
			}
			else {
				memo[nc][kc][sum] = 0;
				return 0;
			}
		}
		else {
			for(int i = nc-1; i > 0; i--){
				if(sum-i >= 0) ans += calc(i, kc+1, sum-i);
			}
			memo[nc][kc][sum] = ans;
			return ans;
		}
	}
	
	public static void main(String[] args){
		new Main().run();
	}
	
}

Measured memory_bytes: 29648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
const int MOD = ((int)1e9)+7;
const int INF = (int)(1e9)+(int)(1e7);
const ll INFL = (ll)(1e18)+INF;
const double EPS = 1e-8;
using namespace std;
bool dp1[4001][16001],dp2[4001][16001];
int main()
{
    string s;
    cin >> s;
    s+="T";
    int x,y;
    cin >> x >> y;
    //座標 x-> 配列ではx+8000

    vector<int>mx,my;
    my.push_back(0);
    bool isx=true;
    int len=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='F'){
            len++;
        }
        else{
            if(isx){mx.push_back(len);isx=false;}
            else {my.push_back(len);isx=true;}
            len=0;
        }
    }
    
    /*rep(i,mx.size()){
        cout << mx[i] << ",";
    }
    cout << endl;
    rep(i,my.size()){
        cout << my[i] << ",";
    }
    cout << endl;*/
    if(mx.size()==0)mx.push_back(0);
    dp1[0][8000+mx[0]]=true;
    for(int i=1;i<mx.size();i++){
        for(int j=0;j<=16000;j++){
            if(j+mx[i]<=16000)dp1[i][j+mx[i]]|=dp1[i-1][j];
            if(j-mx[i]>=0)dp1[i][j-mx[i]]|=dp1[i-1][j];
        }
    }
    dp2[0][8000]=true;
    for(int i=0;i<my.size();i++){
        for(int j=0;j<=16000;j++){
            if(j+my[i]<=16000)dp2[i+1][j+my[i]]|=dp2[i][j];
            if(j-my[i]>=0)dp2[i+1][j-my[i]]|=dp2[i][j];
        }
    }

    if(dp1[mx.size()-1][x+8000]&&dp2[my.size()][y+8000]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }


    return 0;
}

Measured memory_bytes: 125184
#include <stdio.h>

int main(void){
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);

	if(a < b){
		if(b < c){
			printf("%d %d %d\n", a, b, c);
		} else{
			if(a < c){
			printf("%d %d %d\n", a, c, b);
			} else{
			printf("%d %d %d\n", c, a, b);
			}
		} 
	}else {
		if(a < c){
			printf("%d %d %d\n", b, a, c);
		} else{
			if(b < c){
			printf("%d %d %d\n", b, c, a);
			} else{
			printf("%d %d %d\n", c, b, a);
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1812
#include "bits/stdc++.h"
using namespace std;

#define rep(i,beg,end)   for (auto i=(beg);i<(end);i++)
#define rrep(i,beg,end)   for (auto i=(beg);i>=(end);i--)
#define all(cont)           begin(cont), end(cont)
#define rall(cont)           rbegin(cont), rend(cont)
using ll = long long;
using vi = vector<ll>;
using pii = pair<int, int>;
const ll INFMAX = LLONG_MAX;
const ll INFMIN = LLONG_MIN;
const ll MOD = 1000000007;


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) {
        cout << s << endl;
    }
    else {
        cout << "red" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n, l = map(int, input().split())

num = l + n - 1

cnt = 0
if l <= 0 and num <= 0 :
    for i in range(n - 1):
        cnt += l + i
elif l <= 0 and 0 < num:
    for i in range(n):
        cnt += l + i
else:
    for i in range(n - 1):
        cnt += l + i + 1
        
print(cnt)

Measured memory_bytes: 3060
s = input()
t = [-1]

for i in range(len(s)):
    if s[i] != "A" and s[i] != "G" and s[i] != "C" and s[i] != "T":
        t.append(i)
t.append(len(s))

ans = 0
for j in range(len(t) - 1):
    x = t[j+1] - t[j] - 1
    if x > ans:
        ans = x

print(ans)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x;
    for(int i=0; i<10000; i++){
        cin >> x;
        if(x==0){
            break;
        }
        cout << "Case" << " " << i+1 << ":" << " " << x << endl;
    }
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

// 入力
int N;
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    // 初期化は既に 0 に初期化される
    // 初期条件も既に 0 で OK

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][j], dp[i][k] + a[i][j]);
            }
        }
    }

    // 答え
    long long res = 0;
    for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	int m, f, r;
	while (1){
		cin >> m >> f >> r;
		if (m == -1 and f == -1 and r == -1) break;
		if (m == -1 or f == -1) cout << "F" << endl;
		else if (m + f >= 80) cout << "A" << endl;
		else if (m + f >= 65) cout << "B" << endl;
		else if (m + f >= 50 or r >= 50) cout << "C" << endl;
		else if (m + f >= 30) cout << "D" << endl;
		else cout << "F" << endl;
	}
}



Measured memory_bytes: 3124
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

	int count = 0;
	int divisors = 0;
	for (int i = 1; 2 * i + 1 <= n; i++) {
		for (int j = 0; j <= i; j++) {
			if ((2 * i + 1) % (2 * j + 1) == 0) divisors++;
			if (divisors > 8) break;
		}
		if (divisors == 8) count++;
		divisors = 0;
	}
	cout << count << endl;
	return 0;

}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー


Measured memory_bytes: 3516
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
            string s = Console.ReadLine();
            
            switch(s)
            {
                case "A":
                Console.WriteLine("T");
                break;
                case "T":
                Console.WriteLine("A");
                break;
                case "C":
                Console.WriteLine("G");
                break;
                case "G":
                Console.WriteLine("C");
                break;
            }
        }
    }
    //mcs Main.cs
    //mono Main.exe

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

int main() {
    ll N, M; cin >> N >> M;
    priority_queue<ll> A;
    for(int i = 0; i < N; i++){
        ll tmp; cin >> tmp;
        A.push(tmp);
    }

    for(int i = 0; i < M; i++){
        ll tmp = A.top(); 
        A.pop();
        A.push(tmp/2);
    }
    ll sum = 0;
    while(!A.empty()){
        sum += A.top();
        A.pop();
    }
    cout << sum << endl;
}

Measured memory_bytes: 1400
import java.util.Scanner;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static final long[] fal_rnd(int size){
		AtomicInteger l=new AtomicInteger(-1),r=new AtomicInteger(size);
		long[] res=new long[size];
		INS(size).unordered().parallel().mapToLong(Long::parseLong).forEach(v->res[ThreadLocalRandom.current().nextBoolean()?l.incrementAndGet():r.decrementAndGet()]=v);
		return res;
	}
	static final IntStream REPS(int v){
		return IntStream.range(0,v);
	}
	static final Stream<String> INS(long size){
		return StreamSupport.stream(Spliterators.spliterator(s,size,Spliterator.NONNULL&Spliterator.IMMUTABLE),false).limit(size);
	}
	public static void main(String __[]){
		int n;
		while (true) {
			n=s.nextInt();
			if(n==0)return;
			s.nextLine();
			String in=s.nextLine().replaceAll("[ rl]","").replaceAll("(uu|dd)","#").replaceAll("[^#]","");
			System.out.println(in.length());
		}
	}
}

Measured memory_bytes: 35092
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;



int main(){
    int n,k;
    cin >> n >> k;
    vector<int> A(n,0);

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

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

    int sum=0;
    for(int i=0;i<k;i++){
        sum+= A[i];
    }

    cout << sum << endl;
}

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

using namespace std;
typedef long long ll;
ll a[3];
int main() {

  for(int i = 0; i < 3; i++) cin >> a[i];

  ll M = 1e18;
  for(int i = 0; i < 3; i++) {
    if(a[i] % 2 == 0) {cout <<"0"<<endl; return 0;}
    M = min(M,a[(i+1)%3]*a[(i+2)%3]);
  }
  cout << M <<endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!
    val canMM1 = s.take(2).toInt() in 1..12
    val canMM2 = s.drop(2).toInt() in 1..12
    var a = "NA"
    if (canMM1) a = "MMYY"
    if (canMM2) a = "YYMM"
    if (canMM1 && canMM2) a = "AMBIGUOUS"
    print(a)
}

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

int divisor[105];

void mk_divisor( int num ) {
  for( int i=2; i*i<=num; ++i ) {
    while ( num % i == 0 ) {
      num /= i;
      divisor[i]++;
    }
  }
  if ( num != 1 ) divisor[num]++;
  return;
}

int main() {
  ll N;
  cin >> N;
  REP(i,N+1) {
    mk_divisor( i );
//    REP(j,N+1) cout << j << ":" << divisor[j] << ",  ";
//    cout << endl;
  }
//  REP(j,N+1) cout << j << ":" << divisor[j] << endl;
  int ans = 0;
  int o75, o25, o15, o5, o3;
  o75 = o25 = o15 = o5 = o3 = 0;
  REP(i,N+1) {
    if (divisor[i] >= 74) o75++;
    if (divisor[i] >= 24) o25++;
    if (divisor[i] >= 14) o15++;
    if (divisor[i] >= 4) o5++;
    if (divisor[i] >= 2) o3++;
  }
  // 75
  ans += o75;
  // 75 = 3 * 25
  if ( o3 > 1 )
    ans += o25 * (o3 - 1);
  // 75 = 15 * 5
  if ( o5 > 1 )
    ans += o15 * (o5 - 1);
  // 75 = 3 * 5 * 5
  if ( (o5 > 1) && (o3 > 2) )
    ans += o5 * (o5-1) / 2 * (o3 - 2);
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    ll N;
    cin >> N;
    ll odp = 0;
    for (ll d1 = 1; d1 * d1 < N; ++d1)
    {
        if (N % d1 == 0)
        {
            ll d2 = N / d1 - 1;
            if (d2 != 0 && N / d2 == N % d2)
                odp += d2;
        }
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll K;
    cin >> K;
    queue<ll> que;
    for(ll i=1;i<=9;++i)que.emplace(i);
    ll ans=1;
    for(ll i=0;i<K;++i){
        ans=que.front();
        que.pop();
        ll des=ans%10;
        if(des>=1&&des<=8){
            que.emplace(ans*10+des-1);
            que.emplace(ans*10+des);
            que.emplace(ans*10+des+1);
        }
        else if(des==0){
            que.emplace(ans*10+des);
            que.emplace(ans*10+des+1);
        }
        else {
            que.emplace(ans*10+des-1);
            que.emplace(ans*10+des);
        }
    }
    prt(ans);

    return 0;
}



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

int main()
{
    int N;
    cin >> N;
    int ac, wa, tle, re;
    ac = 0;
    wa = 0;
    tle = 0;
    re = 0;
    for (int i = 0; i < N; ++i)
    {
        string temp;
        cin >> temp;
        if (temp == "AC")
        {
            ++ac;
        }
        else if (temp == "WA")
        {
            ++wa;
        }
        else if (temp == "TLE")
        {
            ++tle;
        }
        else
        {
            ++re;
        }
    }

    cout << "AC"
         << " x " << ac << endl;
    cout << "WA"
         << " x " << wa << endl;
    cout << "TLE"
         << " x " << tle << endl;
    cout << "RE"
         << " x " << re << endl;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[N];
    ll ans = 1;
    ll P = 1e18;
    bool ok = true;
    bool zero = false;
    REP(i, 0, N) {
        cin >> A[i];
        if (A[i] == 0) {
            zero = true;
        }
    }
    if (zero) {
        cout << 0 << endl;
        return 0;
    }
    REP(i, 0, N) {
        if (ans != 0 && P / ans < A[i]) {
            ok = false;
        } else {
            ans *= A[i];
        }
    }
    if (ok) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}


Measured memory_bytes: 4408
use proconio::*;

fn run() {
    input! {
        s: String,
    }
    const MOD: usize = 2019;
    let mut dp = vec![0usize; MOD];
    dp[0] = 1;
    let mut pow = 1;
    let mut now = 0;
    let mut ans = 0;
    for d in s.chars().rev() {
        let d = d.to_digit(10).unwrap() as usize;
        now = (now + pow * d) % MOD;
        ans += dp[now];
        dp[now] += 1;
        pow = 10 * pow % MOD;
    }
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define int long long 
typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=200005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int N,K,A[MAXN];
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>K;
	FOR(i,1,N) cin>>A[i];
	FOR(i,1,N-K){
		int cur = A[K+i];
		int prev = A[i];
		if (cur > prev) cout<<"Yes\n";
		else cout<<"No\n";
	}
}


Measured memory_bytes: 5224
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define pb push_back
#define pii pair<long long,long long>
#define endl '\n'
#define N 100001
int mod=1000000007;
int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};
vector<int> parent(N),sz(N);
int modexp(int x,int n,int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        
        return modexp((x*x)%M,n/2,M);
    else                             
        return (x*modexp((x*x)%M,(n-1)/2,M))%M;
}
void make_set(int s)
{
    parent[s]=s;
    sz[s]=1;
}
int find_parent(int p)
{
    if(p==parent[p])
    return p;
    return parent[p]=find_parent(parent[p]);
}
void union_set(int a,int b)
{
    a=find_parent(a);b=find_parent(b);
    if(a!=b)
    {
        if(a<b)
        swap(a,b);
        parent[b]=parent[a];
        sz[a]+=sz[b];
    }
}
void solve()
{
    int h1,s1,h2,s2; cin>>h1>>s1>>h2>>s2;
    int x = ceil((double)h2/(double)s1) , y=ceil((double)h1/(double)s2);
    if(x<=y)
    cout<<"Yes";
    else
    cout<<"No";
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test; test=1;
    while(test--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 4676
from collections import deque

n,k=map(int,input().split())
A=list(map(int,input().split()))
for i in range(min(k,50)):
    P=[]
    M=[]
    cnt=0
    for a in range(n):
        if A[a]==n:
            cnt+=1
            continue
        P.append(a-A[a])
        M.append(a+A[a]+1)
    P.sort()
    M.sort()
    P=deque(P)
    M=deque(M)
    C=[]
    m=n
    for j in range(n):
        if P:
            while P[0]<=j:
                P.popleft()
                cnt+=1
                if not P:
                    break
        if M:
            while M[0]<=j:
                M.popleft()
                cnt-=1
                if not M:
                    break
        C.append(cnt)
        m=min(cnt,m)
    A=C
    if m==n:
        break
print(*A)

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
    fIO

    int k;
    cin >> k;

    cout << a[k - 1];


}








Measured memory_bytes: 256
from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    n = ii()
    ans = 0
    if n%2:
        print(0)
    else:
        tmp = n//2
        while tmp > 0:
            ans+=tmp//5
            tmp//=5

        
        print(ans)

    
main()


Measured memory_bytes: 2940
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<complex>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

int main(void) {
		int n;
		cin>>n;
		vector<string> s(n);
		REP(i, n) cin>>s[i];
		int c = 0;
		bool d = true;
		REP(i, n) {
			if(s[i] == "A") ++c;
			else --c;
			if(c < 0) d = false;
		}
		if(d && !c) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
}

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

int main(){
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<int> l(q), r(q);
  for (size_t i = 0; i < q; i++) {
    cin >> l[i] >> r[i];
  }
  vector<int> index;
  int tmp = 0;
  for (size_t i = 0; i < n-1; i++) {
    if(i!=0) tmp = index[i-1];
    if (s[i]=='A' && s[i+1]=='C') tmp++;
    index.push_back(tmp);
  }
  for (size_t i = 0; i < q; i++) {
    cout << index[r[i]-2]-index[l[i]-2] << endl;
  }
}

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

int main()
{
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int x = max({a,b,c});
    int ans = 0;
    ans = a + b + c - x;
    for(int i = 0; i < k; i++){
        x *= 2;
    }
    ans += x;
    cout << ans << endl;
}

Measured memory_bytes: 256
X = int(input())
lsx = [1]*(2*10**5)

for i in range(2,2*10**5):
    if lsx[i] == 1:
        for j in range(i,2*10**5//i):
            lsx[j*i] = 0

for i in range(X,2*10**5):
    if lsx[i] == 1:
        print(i)
        break

Measured memory_bytes: 68748
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;
string s;

int main() {
  int n,x;cin >>n>>x;
  std::vector<int> v(n);
  for(int i=0;i<n;++i) cin>>v[i];
  sort(v.begin(),v.end());
  int cnt=0;
  for(int j=0;j<n;++j) {
    if(x<0) break;
    x-=v[j];
    ++cnt;
  }
  if (x>0||x<0) --cnt;
  cout << max(cnt,0) << endl;
  return 0;
}

Measured memory_bytes: 256
<?php

$v = explode(" ",fgets(STDIN));
$tmp = $v[0];
$v[0] = $v[1];
$v[1] = $tmp;

$tmp = $v[0];
$v[0] = $v[2];
$v[2] = $tmp;

echo "{$v[0]} {$v[1]} {$v[2]}";

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

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

    int N;
    vector<double> V;
    double A;

    cin >> N;

    for(int i=0; i<N; ++i)
    {
        cin >> A;
        V.push_back(1/A);
    }

    double sum = accumulate(V.begin(), V.end(), 0.0);
  
  	cout << 1/sum << endl;

    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;

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

  set<int> ctn;
  bool flag = true;
  for (int i = 0; i < n; ++i) {
    int tmp;
    cin >> tmp;
    if (ctn.find(tmp) == ctn.end()) {
      ctn.insert(tmp);
      continue;
    }
    flag = false;
    break;
  }

  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main(){
	int D; cin >> D; 
	int C[30] = {}; 
	for(int i = 1; i <= 26; i++) cin >> C[i]; 
	int S[370][30] = {}; 
	for(int i = 1; i <= D; i++){
		for(int j = 1; j <= 26; j++){
			cin >> S[i][j]; 
		}
	}
	int ans[370] = {}; 
	int L[30] = {}; 
	for(int i = 1; i < D; i+= 2){
		int E[700] = {}; 
		for(int j = 1; j <= 676; j++){
			int p = (j - 1) % 26 + 1; // i日目
			int q = (j - 1) / 26 + 1; // i+1日目
			int M[30] = {}; 
			for(int k = 1; k <= 26; k++){
				M[k] = L[k]; 
			}
			E[j] += S[i][p] + C[p] * (i - M[p]) * min(365-i, 13); 
			M[p] = i; 
			E[j] += S[i+1][q] + C[q] * (i + 1 - M[q]) * min(365-i, 13);
		}
		int a = 0; int mx = -1145141919; 
		for(int j = 1; j <= 676; j++){
			if(E[j] > mx){
				a = j; mx = E[j]; 
			}
		}
		ans[i] = (a-1) % 26 + 1; ans[i+1] = (a-1) / 26 + 1; 
		L[(a-1) % 26 + 1] = i; L[(a-1) / 26 + 1] = i + 1; 
	}
	for(int i = D; i <= D; i++){
		int E[30] = {}; 
		for(int j = 1; j <= 26; j++){
			E[j] = S[i][j] + C[j] * (i - L[j]); 
		}
		int a = 0; int mx = -1145141919; 
		for(int j = 1; j <= 26; j++){
			if(E[j] > mx){
				a = j; mx = E[j]; 
			}
		}
		ans[i] = a; L[a] = i; 
	}
	for(int i = 1; i <= D; i++) cout << ans[i] << endl; 
}

Measured memory_bytes: 3656
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;
#define MAX 200000
#define INFTY (1<<30)

int main(){
    char com[20];
    priority_queue<int> P;
    
    while(1){
        scanf("%s", com);
        if (com[0] == 'e' && com[1] == 'n') break;
        if (com[0] == 'i'){
            int key; scanf("%d", &key);
            P.push(key);
        }else{
            printf("%d\n", P.top());
            P.pop();
        }
    }
}


Measured memory_bytes: 6976