akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
queue<unsigned long long>q;
unsigned long long k;
void BFS() {
	while ( ! q.empty() ) {
		int u=q.front()%10;
		if (u-1>=0) {
			k--;
			q.push(q.front()*10+u-1);
		}
		if (k==0) {
			cout<<q.back();
			return;
		}
		k--;
		q.push(q.front()*10+u);
		if (k==0) {
			cout<<q.back();
			return;
		}
		if (u+1<=9) {
			k--;
			q.push(q.front()*10+u+1);
		}
		if (k==0) {
			cout<<q.back();
			return;
		}
		q.pop();
	}
}
int main() {
	cin>>k;
	if (k<=9) {
		cout<<k;
		return 0;
	}
	k=k-9;
	for (int i=1; i<=9; i++) {
		q.push(i);
	}
	BFS();
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= 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
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  ll ans = INF64;

  for(int i = 0; i <= max(x, y)*2; i += 2) {
    ll tmp = c*i;
    tmp += a*(max(0ll, x-i/2)) + b*(max(0ll, y-i/2));
    chmin(ans, tmp);
  }
  cout << ans << endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[100000];

int main() {
    scanf("%d", &n);
    forn(i, n) scanf("%d", a + i);
    LL ans = 0, sum = 0;
    forn(i, n) {
        sum += a[i];
        if (i & 1) {
            if (sum > -1) {
                ans += sum + 1;
                sum = -1;
            }
        } else {
            if (sum < 1) {
                ans += 1 - sum;
                sum = 1;
            }
        }
    }
    LL ans2 = ans;
    ans = sum = 0;
    forn(i, n) {
        sum += a[i];
        if (!(i & 1)) {
            if (sum > -1) {
                ans += sum + 1;
                sum = -1;
            }
        } else {
            if (sum < 1) {
                ans += 1 - sum;
                sum = 1;
            }
        }
    }
    cout << min(ans, ans2) << endl;
    return 0;
}


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

int main() {
	int N, M, A, MOD = 1000000007;
	bool X[100010] = {};
	static long long DP[100010];
	cin >> N >> M;
	for (int i = 0; i < 100010; i++) X[i] = true;
	for (int i = 0; i < M; i++) cin >> A, X[A] = false;
	DP[0] = 1;
	if (X[1]) DP[1] = 1;
	else DP[1] = 0;
	for (int i = 2; i <= N; i++) {
		if (!X[i]) DP[i] = 0;
		else DP[i] = DP[i - 1] + DP[i - 2];
		DP[i] = DP[i] % MOD;
	}
	cout << DP[N];
}

Measured memory_bytes: 1152
from collections import defaultdict
d = defaultdict(int)

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

cnt = 0
for n in range(N):
  a,b = map(int, input().split())
  d[a] += b

d_sorted = sorted(d.items())
cnt = 0
for k,v in d_sorted:
  cnt += v
  if cnt >= K:
    ans = k
    break

print(ans)

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

int DP[3][100010];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	DP[0][0] = DP[1][0] = DP[2][0] = 0;
 	for (int i = 1 ; i <= n ; i++)
	{
		cin >> DP[0][i] >> DP[1][i] >> DP[2][i];
		DP[0][i] += max(DP[1][i - 1],DP[2][i - 1]);
		DP[1][i] += max(DP[0][i - 1],DP[2][i - 1]);
		DP[2][i] += max(DP[0][i - 1],DP[1][i -1]);
	}
	int ans = max(DP[0][n],max(DP[1][n],DP[2][n]));
	cout << ans << endl;
}

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

int facctorialMethod(int k)
{
  int sum = 1;
  for (int i = 1; i <= k; ++i)
  {
    sum *= i;
  }
  return sum;
}

int main()
{
  int N;
  cin >> N;
  vector<int> x(N), y(N);
  vector<int> P(N);
  rep(i, N)
  {
    cin >> x[i] >> y[i];
    P[i] = i;
  }
  double ans;
  do
  {
    rep(i, N - 1)
    {
      ans += pow(pow((x[P[i]] - x[P[i + 1]]), 2) + pow((y[P[i]] - y[P[i + 1]]), 2), (1.0 / 2.0));
     // cout << ans << endl;
    }
  } while (next_permutation(P.begin(), P.end()));

  //cout << ans / facctorialMethod(N) << endl;
  printf("%.12lf",ans / facctorialMethod(N));
}


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

using std::cin;
using std::cout;
using std::endl;

using std::vector;
using std::min;

const int INF = 1e8;

int backtrack(const vector<int>& t, const vector<vector<int>>& g,
              vector<bool>& used, int prev = -1, int sum = 0, int best = INF,
              size_t depth = 0) {

    if (depth >= t.size()) {
        return min(best, sum);
    }

    for (size_t i = 0; i < t.size(); i++) {
        if (used[i]) {
            continue;
        }
        used[i] = true;

        const int cost = prev == -1 ? 0 : g[t[prev]][t[i]];
        best = min(best, backtrack(t, g, used, i, sum + cost, best, depth + 1));

        used[i] = false;
    }

    return best;
}

int main(void) {
    int n, m, r;
    cin >> n >> m >> r;

    vector<int> town(r);
    for (int i = 0; i < r; i++) {
        int t;
        cin >> t;
        town[i] = t - 1;
    }

    vector<vector<int>> graph(n, vector<int>(n, INF));
    for (int i = 0; i < n; i++) {
        graph[i][i] = 0;
    }

    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        graph[a - 1][b - 1] = c;
        graph[b - 1][a - 1] = c;
    }

    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }

    vector<bool> used(town.size());
    cout << backtrack(town, graph, used) << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <vector>
#include <string.h>
#include <cmath>
using namespace std;

int main() {
	int n,m;
	
	string S, T,temp;
	cin >> S;
	cin >> T;
	n = S.length();
	m = T.length();
	m = abs(m - n);
	
	temp = T.erase(n);
	if (temp == S && m == 1)cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 3632
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

dy = [0, 1]
dx = [1, 0]

stack = [[0 for _ in range(w)] for _ in range(h)]

def dfs(y, x):
    stack[y][x] = 1
    if x == w-1 and y == h-1:
        return
    for i in range(2):
        ny = y + dy[i]
        nx = x + dx[i] 
        if ny < 0 or ny >= h or nx < 0 or nx >= w:
            continue
        if a[ny][nx] == "#":
            dfs(ny, nx)
            break
    return

dfs(0, 0)
for i in range(h):
    for j in range(w):
        if a[i][j] == "#" and stack[i][j] == 0:
            print('Impossible')
            exit()
print('Possible')

Measured memory_bytes: 3064
#include<stdio.h>
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}
int main() {
	long long int n, s[5000] = {},m,min=10000000,count=0,x;
	char str[3000];
	scanf("%lld%lld", &n,&m);
	if (m / 10 == 0) {
		n = 10 * n + m;
	}
	else if (m / 100 == 0) {
		n = 100 * n + m;
	
	}
	else {
		n = 1000 * n + m;
	}
	for (int i = 1; i <= 330; i++) {
		if (n == i * i) { printf("Yes"); return 0; }
	}
	printf("No");
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
	int h, w, i, j, k, a[83][83], b[83][83], s[81][81];
	bool dp[81][81][6450] = { false };

	scanf("%d%d", &h, &w);
	for (i = 1; i <= h; i++) for (j = 1; j <= w; j++) {
		scanf("%d", &a[i][j]);
	}
	for (i = 1; i <= h; i++) for (j = 1; j <= w; j++) {
		scanf("%d", &b[i][j]);
	}

	for (i = 1; i <= h; i++) for (j = 1; j <= w; j++) {
		s[i][j] = abs(a[i][j] - b[i][j]);
	}

	dp[1][0][0] = true;
	for (i = 1; i <= h; i++) for (j = 1; j <= w; j++) {
		for (k = 0; k <= 6430; k++) {
			if (dp[i - 1][j][k] || dp[i][j - 1][k]) {
				if (k + s[i][j] <= 6430) {
					dp[i][j][k + s[i][j]] = true;
				}
				dp[i][j][abs(k - s[i][j])] = true;
			}
		}
	}

	i = 0;
	while (!dp[h][w][i]) i++;

	printf("%d\n", i);

	return 0;
}

Measured memory_bytes: 41600
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;++i)
using namespace std;
int main(){
  int n;
  int a[201],b[201],c[201];
  cin>>n;
  rep(i,0,n) cin>>a[i]>>b[i]>>c[i];
  rep(i,0,n){
    int ca=0,cb=0,cc=0;
    rep(j,i+1,n){
      if(a[i]==a[j]){
	a[j]=0; ca=1;
      }
      if(b[i]==b[j]){
	b[j]=0; cb=1;
      }
      if(c[i]==c[j]){
	c[j]=0; cc=1;
      }
    }
    if(ca) a[i]=0;
    if(cb) b[i]=0;
    if(cc) c[i]=0;
  }
  rep(i,0,n) cout<<a[i]+b[i]+c[i]<<endl;
  return 0;
}

Measured memory_bytes: 3072
/**
*    created: 21.06.2020 23:42:49
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcount(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int x, y;
    cin >> x >> y;
    cout << x + y/2 << endl;
    return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
int main()
{
    int x,y,z;
    while(scanf("%d %d",&x,&y)!=EOF)
    {
        while(z=x%y)
        {
            x=y;
            y=z;
        }
        printf("%d\n",y);
        }
        return 0;
}


Measured memory_bytes: 1988
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from collections import deque
from collections import defaultdict
def main():
    N, P = MI()
    S_ = S()
    mod_list = defaultdict(int)
    ans = 0
    if P == 2 or P == 5:
        for i in range(N):
            num = int(S_[i])
            if num % P == 0:
                ans += i + 1

    else:
        num = 0
        point = 1
        for i in S_[::-1]:
            num += int(i) * point
            mod = int(num) % P
            mod_list[mod] += 1
            point *= 10
            point %= P
    values_ = mod_list.values()
    ans += mod_list[0]
    for value in values_:
        ans += (value - 1) * value // 2

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 76412
n = int(input())
TA = [list(map(int, input().split())) for _ in range(n)]

XY = [TA[0]]

for i in range(1, n):
    x0, y0 = XY[i-1]
    x1, y1 = TA[i]
    xq, xr = divmod(x0, x1)
    yq, yr = divmod(y0, y1)
    if xr != 0:
        xq += 1
    if yr != 0:
        yq += 1
    q = max(xq, yq)
    x1, y1 = x1*q, y1*q
    XY.append([x1, y1])
    
print(sum(XY[-1]))

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

// #include<cstdio>

int main(){
  int H, W;

  while(1){
    cin >> H >> W;
    if (H==0 && W==0) break;
    for (int i=0; i<H; i++){
      for (int j=0; j<W; j++){
	if (i==0 || j==0 || i==H-1 || j==W-1){
	  cout << '#';
	} else {
	  cout << '.';
	}
      }
      cout << "\n";
    }
    cout << "\n";
  }

  return 0;
}

Measured memory_bytes: 3100
from collections import defaultdict

N = int(input())
d = defaultdict(lambda:[])
for i in range(N):
    s,p = input().split(" ")
    p = int(p)
    d[s].append([p,i+1])

for i,k in sorted(d.items()):
    for j in sorted(k,reverse=True):
        print(j[1])

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

typedef long long LL;
const int S=(1<<20)+5;
char buf[S],*H,*T;
inline char Get()
{
    if(H==T) T=(H=buf)+fread(buf,1,S,stdin);
    if(H==T) return -1;return *H++;
}
inline LL read()
{
    LL x=0;char c=Get();
    while(!isdigit(c)) c=Get();
    while(isdigit(c)) x=x*10+c-'0',c=Get();
    return x;
}

const int N=100010;
LL a[N],b[N][2];
bool mask[3010];
int prm[3010],tot=0,n;
unordered_map<LL,int> cc;
unordered_map<LL,bool> fucked;

LL maxc(const LL &a,const LL &b){return cc[a]>cc[b]?a:b;}

void preprework()
{
    for(int i=2;i<=2200;i++)
    {
        if(mask[i]) continue;
        prm[++tot]=i;
        for(int j=i;j<=2200;j+=i)
            mask[j]=1;
    }
}

void prework()
{
    for(int i=1;i<=n;i++)
    {
        LL x=1,y=1;
        for(int j=1;j<=tot;j++)
        {
            if(a[i]%prm[j]) continue;
            int cnt=0;
            while(a[i]%prm[j]==0)
                a[i]/=prm[j],cnt++;
            if(!(cnt%=3)) continue;
            for(int k=1;k<=cnt;k++) x=x*prm[j];
            for(int k=cnt+1;k<=3;k++) y=y*prm[j];
        }
        LL t=(LL)sqrt(a[i]);
        if(t*t==a[i]) x=x*t*t,y=y*t;
        else x=x*a[i],y=y*a[i]*a[i];
        b[i][0]=x;b[i][1]=y;
        if(!cc.count(x)) cc[x]=1;
        else cc[x]++;
    }
}

int main()
{
    LL ans=0;n=read();
    for(int i=1;i<=n;i++) a[i]=read();
    preprework();prework();
    for(int i=1;i<=n;i++)
    {
        LL c1=b[i][0],c2=b[i][1];
        if(fucked[c1]||fucked[c2]) continue;
        LL x=maxc(c1,c2);fucked[x]=1;
        ans+=(x==1)?1:cc[x];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 20168
var
  n,m,i,t:longint;
  s,ss:string;

 function poss:boolean;//二分
  var
    m,head,tail:longint;
  begin
    head:=1;
    tail:=t;
    while head<=tail do
    begin
      m:=(head+tail) div 2;
      if m=sqrt(t) then exit(true);
      if m<sqrt(t) then head:=m+1
      else tail:=m-1;
    end;
    exit(false);
  end;

begin
  read(n,m);
  str(n,s);
  str(m,ss);
  s:=s+ss;
  val(s,t);
  if poss then write('Yes')
     else write('No');
end.

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

int main()
{

        int N;
        cin >> N;


        int p[N];
        for (int i = 0; i < N; ++i) {

                cin >> p[i];
        }

        sort(p, p+N);
        int pay = 0;
        for (int i = 0; i < N; ++i) {
                if (i == N-1) {
                        pay += (p[i] / 2);
                }
                else {
                        pay += p[i];
                }


        }
        cout << pay << endl;




}


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

int main()
{
	int64_t n, mod = 1000000007;
	cin >> n;

	int64_t dp[n + 1][4][4][4]{};
	for (int j = 0; j < 4; j++)
	{
		for (int k = 0; k < 4; k++)
		{
			for (int l = 0; l < 4; l++)
			{
				if (j == 0 && k == 2 && l == 1)
				{
					continue;
				}
				if (j == 0 && k == 1 && l == 2)
				{
					continue;
				}
				if (j == 2 && k == 0 && l == 1)
				{
					continue;
				}
				dp[3][j][k][l] = 1;
			}
		}
	}

	for (int i = 3; i < n; i++)
	{
		for (int j = 0; j < 4; j++)
		{
			for (int k = 0; k < 4; k++)
			{
				for (int l = 0; l < 4; l++)
				{
					for (int m = 0; m < 4; m++)
					{

						if (k == 0 && l == 2 && m == 1)
						{
							continue;
						}
						if (k == 0 && l == 1 && m == 2)
						{
							continue;
						}
						if (k == 2 && l == 0 && m == 1)
						{
							continue;
						}
						if (j == 0 && l == 2 && m == 1)
						{
							continue;
						}
						if (j == 0 && k == 2 && m == 1)
						{
							continue;
						}
						(dp[i + 1][k][l][m] += dp[i][j][k][l]) %= mod;
					}
				}
			}
		}
	}

	int64_t ans = 0;
	for (int j = 0; j < 4; j++)
	{
		for (int k = 0; k < 4; k++)
		{
			for (int l = 0; l < 4; l++)
			{
				(ans += dp[n][j][k][l]) %= mod;
			}
		}
	}

	cout << ans << endl;

	return 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 rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    string s; cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
count=[0]*n
flag=1
for j in range(1,30):
  for i in range(len(a)):
    if a[i]%(2**j)==0:
      count[i]+=1
      i/=2
    else:
      break  
print(min(count))

Measured memory_bytes: 39408
#include <cstdio>

using namespace std;
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d%d", &x, &y);
int main() {
  scii(A,B);sci(C);
  if((A==5&&B==5&&C==7)||(A==5&&C==5&&B==7)||(B==5&&C==5&&A==7))printf("YES\n");
  else printf("NO\n");
}

Measured memory_bytes: 256
N = int(input())
number = len(str(N))
count = 0

if number % 2 == 0:
    for i in range(1, number, 2):
        count += 10 ** i - 10 ** (i - 1)
    print(count)
else:
    for i in range(2, number, 2):
        count += 10 ** i - 10 ** (i - 1)
    print(N - count)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

int a[1000000];
int partition(int p, int r){
    int x = a[r];
    int i = p - 1;
    for(int j = p; j < r; j++){
        if(a[j] <= x){
            i++;
            swap(a[i], a[j]);
        }
    }
    swap(a[i+1], a[r]);
    return i + 1;
}

int main(){
    int n;
    cin >> n;
    rep(i, n) cin >> a[i];
    int ans = partition(0, n-1);
    rep(i, n){
        if(i) cout << " ";
        if(i == ans) cout << "[";
        cout << a[i];
        if(i == ans) cout << "]";
    }
    cout << endl;
}


Measured memory_bytes: 3484
#include <iostream>
#include <vector>

#define MAX_BIT 32

int main(){
    int N;
    unsigned int tmp, mask;
    std::vector<unsigned int> a, sol;
    std::vector<int> b(MAX_BIT, 0);
    scanf("%d", &N);

    for(int i = 0;i < N;++i){
        scanf("%u", &tmp);
        a.push_back(tmp);
    }

    for(int sft = 0;sft < MAX_BIT;++sft){
        mask = (unsigned int)1 << sft;
        for(int i = 0;i < a.size();++i){
            b[sft] += !!(a[i] & mask);
        }
    }

    for(int i = 0;i < a.size();++i){
        tmp = 0;
        for(int sft = 0;sft < MAX_BIT;++sft){
            mask = (unsigned int)1 << sft;
            tmp = tmp | (((b[sft] - !!(mask & a[i])) & 0x1) << sft);
        }
        sol.push_back(tmp);
    }

    for(int i : sol){
        printf("%d ", i);
    }
    
    return 0;
}

Measured memory_bytes: 5620
n = int(input())
b_integers = list(map(int, input().split()))

a_integers = [b_integers[0]]
for i in range(n-2):
    if b_integers[i] > b_integers[i+1]:
        a_integers.append(b_integers[i+1])
    else:
        a_integers.append(b_integers[i])
a_integers.append(b_integers[-1])
print(sum(a_integers))


Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,K,a[210000],na[210000],f[210000],gt,g[210000];
long long s[210000],ans;
inline bool cmp(int a,int b){
	return s[a]<s[b];
}
inline void add(int x){
	while (x<=gt){
		f[x]++;
		x+=x&(-x);
	}
}
inline void ask(int x){
	while (x){
		ans+=f[x];
		x-=x&(-x);
	}
}
int main(){
	scanf("%d%d",&n,&K);
	fo(i,1,n){
		scanf("%d",&a[i]);
		a[i]-=K;
	}
	fo(i,1,n) s[i]=s[i-1]+a[i];
	fo(i,0,n) na[i]=i;
	sort(na,na+n+1,cmp);
	g[na[0]]=gt=1;
	fo(i,1,n) g[na[i]]=(s[na[i]]!=s[na[i-1]])?++gt:gt;
	add(g[0]);
	fo(i,1,n){
		ask(g[i]);
		add(g[i]);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
#define inI(x) scanf("%d",&x)
#define inI2(x,y) scanf("%d %d",&x,&y)
#define inI3(x,y,z) scanf("%d %d %d",&x,&y,&z)
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
LL ans,d,dmg,ss,x,mm;
int n;
queue<pair<LL,LL> >q;
vector<pair<LL,LL> >mon;
int main()
{
    scanf("%d %lld %lld",&n,&d,&dmg);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld %lld",&x,&mm);
        mon.PB({x,mm});
    }
    sort(all(mon));
    for(int i=0;i<n;i++)
    {
        if(!q.empty())
        {
            while(q.front().F<mon[i].F)
            {
                ss-=q.front().S;
                q.pop();
                if(q.empty())break;
            }
        }
        if(ss>=mon[i].S)continue;
        else
        {
            LL k=(mon[i].S-ss+dmg-1)/dmg;
            ans+=k;
            ss+=k*dmg;
            q.push({mon[i].F+(d*2),k*dmg});
        }
    }
    printf("%lld",ans);
}


Measured memory_bytes: 6256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    ll ans = a[0];
    int cnt = 1;
    int idx = 1;
    while(1) {
        if (cnt == n-1) break;
        ans += a[idx];
        ++cnt;
        if (cnt&1) ++idx;
        //cout << cnt << " " << idx << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4816
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=2e5+5,MOD=1e9+7;
const ld EPS = 1e-9;

int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=(xx<<3)+(xx<<1)+ch-'0';ch=getchar();}
    return xx*ff;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
	fastio;

	int x; cin>>x;
	cout<<1+((1999-x)/200)<<ln;

	return 0;
}

Measured memory_bytes: 3692
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)


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

	if (s == "AKIHABARA" || s == "KIHABARA" || s == "AKIHBARA" || s == "AKIHABRA" ||
		s == "AKIHABAR" || s == "AKIHABR" || s == "AKIHBRA" || s == "AKIHBAR" ||
		s == "KIHABAR" || s == "KIHABRA" || s == "KIHBARA" || s == "AKIHBR" ||
		s == "KIHABR" || s == "KIHBAR" || s == "KIHBRA" || s == "KIHBR") {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    if(S[2] == S[3] && S[4]==S[5]){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}



void solve(){
    int n,m;
   cin >> n >> m;

   int t,p;
   priority_queue<pii> q;
   set<int> v;

   for(int i = 1;i<=n;i++){
    cin >> t >> p;
    q.push({p,t});
   }

   for(int i = m+1; i<=m+m; i++ )v.insert(i);
    //for(auto i:v)cout << i << endl;

    map<int, bool> vis;
    int ans = 0;

    while(v.size() && !q.empty()){
        auto x = q.top(); q.pop();
        int req = x.second + m;
        //cout << req << endl;
        auto l = v.lower_bound( req);
        if(l==v.end())continue;
        //cout << *l << endl;
        //cout << x.second << " " << x.first << endl;
        ans+=x.first;
        v.erase(*l);
    }
   cout << ans << endl; 
} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1777777777ll
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read(a,n) rep(i,n)cin>>a[i]

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

set<li> st;

int main() {
    li n;
    cin >> n;
    st.insert(n);
    li res = 1;
    while (true) {
        res++;
        if (n % 2 == 0) {
            n /= 2;
        } else {
            n = n * 3 + 1;
        }
        if (st.count(n) > 0) {
            cout << res << endl;
            return 0;
        }
        st.insert(n);
    }


    return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  deque<int> jewel;
  for (int i = 0; i < N; i++) {
    int num;
    cin >> num;
    jewel.push_back(num);
  }
  int ans = -1;
  for (int i = 0; i <= min(N, K); i++) {
    for (int j = 0; j <= min(N, K)-i; j++) {
      deque<int> jewel_copy = jewel;
      vector<int> tmp;
      for (int a = 0; a < i; a++) {
        tmp.push_back(jewel_copy.front());
        jewel_copy.pop_front();
      }
      for (int b = 0; b < j; b++) {
        tmp.push_back(jewel_copy.back());
        jewel_copy.pop_back();
      }
      sort(tmp.begin(), tmp.end());
      int value = 0, trash = K - i - j;
      for (auto x : tmp) {
        if (trash > 0 && x < 0) {
          trash--;
          continue;
        }
        value += x;
      }
      if (value > ans) ans = value;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define F first
#define S second

int A[505][505];

void dfs(int l,int r,int d){
	int m=(l+r)/2;

	for(int i=l;i<m;i++){
		for(int j=m;j<r;j++){
			A[i][j]=A[j][i]=d;
		}
	}

	if(l+1!=m)dfs(l,m,d+1);
	if(m+1!=r)dfs(m,r,d+1);
}

signed main(){
	int n;
	cin>>n;
	dfs(0,n,1);

	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			if(j!=i+1)cout<<' ';
			cout<<A[i][j];
		}
		cout<<endl;
	}
}

Measured memory_bytes: 2432
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}




signed main(){
    i64 n, k;
    cin >> n >> k;
    vector<i64> a(n);
    for(auto& x : a)
        cin >> x;
    sort(a.begin(), a.end());

    auto f = [&](i64 val){
        i64 cnt = 0;
        for(int i = 0; i < n; ++i){
            int dist = 0;
            if(a[i] == 0){
                dist = (val >= 0 ? (n - i - 1) : 0);
            }
            else if(a[i] > 0){
                int ok = i, ng = n;
                while(ng - ok > 1){
                    int j = (ok + ng) / 2;
                    (a[i] * a[j] <= val ? ok : ng) = j;
                }
                dist = ok - i;
            }
            else{
                int ok = n, ng = i;
                while(ok - ng > 1){
                    int j = (ok + ng) / 2;
                    (a[i] * a[j] <= val ? ok : ng) = j;
                }
                dist = (n - ok);
            }
            cnt += dist;
        }
        return cnt >= k;
    };

    i64 ng = -INF, ok = INF;
    while(abs(ok - ng) > 1){
        i64 mid = (ok + ng) / 2;
        (f(mid) ? ok : ng) = mid;
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 const ll inf=1e9+7;
string a,b,c;

ll mod(ll a)
{
	if(a<inf)return a;
	else 
	return a%inf;
}
 void test_cases()
{

ll w,a,b;
cin>>w>>a>>b;

if(a>b)
swap(a,b);

a=a+w;

w=b-a;

if(w<=0)cout<<0;
else
cout<<w;




}


int main()
{
    fast;
  ll t;
 // cin>>t;
 t=1;
  while(t--)
  test_cases();

  	
}

		
	
	
	
	


Measured memory_bytes: 3648
import sys
input = sys.stdin.readline

#input
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

#output
import numpy as np
A = np.array(A)
F = np.array(F)

A = np.sort(A)[::-1]
F = np.sort(F)
B = np.sum(A)
M = max([a*f for a, f in zip(A, F)])

def is_possible(x):
    return B - np.minimum(A, x//F).sum() <= K

left = -1
right = M
while left + 1 < right:
    mid = (left + right)//2
    if is_possible(mid):
        right = mid
    else:
        left = mid

print(right)

Measured memory_bytes: 34196
import string
import collections

N = int(input())

CountList = []

atoz = string.ascii_lowercase
for i in range(N):
    temp = ''
    s=input()
    CountList.append(''.join(sorted(s)))

str = collections.Counter(CountList)

count = 0
for s in str:
    count += sum(range(str[s]))

print(count)

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

int main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  vector<int> vec(N - 1, 0);
  int k;
  for (int i = 1; i <= N - 1; i++) {
    for (int j = i + 1; j <= N; j++) {
      k = min(j - i, abs(X - i) + 1 + abs(j - Y));
      vec.at(k - 1)++;
    }
  }
  for (int i = 0; i < N - 1; i++)
  	cout << vec.at(i) << endl;
}


Measured memory_bytes: 256
object Main extends App {
  type Dots = Array[Array[Char]]
  type Point = (Int, Int)

  val Seq(h, w) = scala.io.StdIn.readLine.split(" ").map(_.toInt).toSeq

  var s = ""
  for (_ <- 0 until h) {
    s += scala.io.StdIn.readLine + "\n"
  }

  val dots: Array[Array[Char]] = s.split("\n").map(_.toCharArray)

  for {
    y <- 0 until h
    x <- 0 until w
  } {
    if (dots(y)(x) == '#') print('#')
    else print(surrounds(y, x).flatMap(get(dots, _)).count(_ == '#').toString.charAt(0))
    if (x == w - 1) println()
  }

  def surrounds(h: Int, w: Int): Seq[Point] = (
    for {x <- -1 to 1; y <- -1 to 1} yield (x, y)
    ).filter(_ != (0, 0)).map(t => (h + t._1, w + t._2))

  def get(dots: Dots, point: Point): Option[Char] = try {
    Some(dots(point._1)(point._2))
  } catch {
    case _ => None
  }
}

Measured memory_bytes: 37172
import java.util.*;
public class Main{
	public static void main(String arg[]){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
			a[i]=sc.nextInt();
		Arrays.sort(a);
		int m=a.length/2;
		if(a[m]==a[m-1])
			System.out.println("0");
		else{
			if(a[m-1]!=a[m])
				System.out.println(a[m]-a[m-1]);
		}
	}
}

Measured memory_bytes: 50504
#![allow(unused_imports)]

//input
use proconio::input;
use proconio::marker::{Bytes, Chars};
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        n: String
    }
    let n: u32 = n.chars().map(|x| x.to_digit(10).unwrap()).sum();
    //tabで移動
    if n % 9 == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2356
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;

int main()
 {
 	int n,r,f=0;
 	cin>>n;
 	while(n!=0)
 	{
 		r=n%10;
 		n=n/10;
 		if(r==7)
 			f++;	
	 }
	 if(f==0)
	 	cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
 	return 0;
}
 	
 					

Measured memory_bytes: 3608
#include <iostream>
#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>
using namespace std;

int main(){
    int s;
    cin >> s;
    int a[1000000];
    a[0]=s;
    int end=0;
    for(int i=1;i<10000000&&end==0;i++){
        if(a[i-1]%2==0)a[i]=a[i-1]/2;
        else a[i]=3*a[i-1]+1;
        for(int j=0;j<i;j++){
            if(a[j]==a[i]){cout<<i+1<<endl;end++;}
        }
    }



}

Measured memory_bytes: 256
d, g = map(int, input().split())
pc = [list(map(int,input().split())) for _ in range(d)]
ans = g//100 + 1

for i in range(2**d):
    count = 0
    total = 0
    for j in range(d):
        if (i >> j) & 1 == 1:
            count += pc[j][0]
            total += (j+1)*100*pc[j][0] + pc[j][1]

    if total >= g:
        ans = min(ans, count)
    else:
        for k in reversed(range(d)):
            if ((i >> k) & 1) == 0:
                for _ in range(pc[k][0]):
                    if total >= g:
                        ans = min(ans, count)
                        break
                    count += 1
                    total += (k+1)*100

print(ans)

Measured memory_bytes: 9212
/*
    i have no idea
*/

#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;
typedef long long ll;

int main(){
    IOS;
    int n; cin >> n;
    ll a[n], cnt = 0, sum = 0;
    bool zr = false;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        if (a[i] < 0) cnt++;
        if (a[i] == 0) zr = true;
        a[i] = abs(a[i]);
        sum += a[i];
    }

    if (cnt%2 == 0 || zr){
        cout << sum;
    }
    else{
        ll m = *min_element(a, a+n);
        cout << sum - 2*m;
    }
}


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

const int N = 300 * 1000 + 5;
const int mod = 998244353;

long long fac[N];
int po(int x, int y) {
	if (y == 0)
		return 1;
	long long ans = po(x, y / 2);
	ans *= ans;
	ans %= mod;
	if (y % 2 == 1) {
		ans *= x;
		ans %= mod;
	}
	return ans;
}
int chs(int x, int y) {
	long long ans = fac[x];
	ans *= po(fac[y], mod - 2);
	ans %= mod;
	ans *= po(fac[x - y], mod - 2);
	ans %= mod;
	return ans;
}
int main() {
	int n;
	long long a, b, k, ans = 0;
	cin >> n >> a >> b >> k;
	fac[0] = 1;
	for (int i = 1; i <= n; i++) {
		fac[i] = fac[i - 1] * i;
		fac[i] %= mod;
	}
	for (int i = 0; i <= n; i++) {
		long long t = k - 1ll * a * i;
		if (t >= 0 && t % b == 0 && t / b <= n) {
			long long x = chs(n, i);
			x *= chs(n, t / b);
			x %= mod;
			ans += x;
			ans %= mod;
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  
  int x;
  cin >> x;
  
  double answer=1;
  for (int i=0; i<sqrt(x); i++) {
    if (i==0 || i==1) continue;
    else {
      int s=1;
      while (pow(i, s)<=x) s++;
      answer=max(answer, pow(i, s-1));
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;

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

        	long N = scan.nextLong();
        	long K = scan.nextLong();

        	scan.close();

        	long output = N*(N+1)*(N+2)/6 - (K-1)*K*(3*N-2*K+4)/6 + N - K + 2;

        	output %= 1000000007;

        	System.out.println(output);

        }

}

Measured memory_bytes: 35660
import math
import numpy as np
n = int(input())
fac = []
sqrt_n = math.sqrt(n)
for i in range(2, int(sqrt_n)):
    if not n % i:
        fac.append(0)
    while not n % i:
        n /= i
        fac[-1] += 1
if n > sqrt_n:
    fac.append(1)
num = 0
for f in fac:
    num += np.count_nonzero(f >= np.cumsum(range(1, f+1)))
print(num)

Measured memory_bytes: 27200
#include<iostream>
using namespace std;
int N, S;
int main(){
  while(cin >> N && N>0){
    int sum = 0;
    int min = 1001;
    int max = -1;
    for(int i=0;i<N;++i){
      cin >> S;
      sum += S;
      if(min>S) min = S;
      if(max<S) max = S;
    }
    int ans = (sum-max-min)/(N-2);
    cout << ans << endl;
  }
}
      



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

using namespace std;
#define endl "\n"
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef long long ll;
const double PI = acos(-1);
const int mod = 1e9 + 7;
const int INF = 1e9;
const int MAX=505, N=1e5+10;


int main(){
	ios_base::sync_with_stdio(0);
	//	cin.tie(0);
	int n;
	while(cin>>n){
		vector<ll>v(n);
		for(int i=0;i<n;i++){
			cin>>v[i];
			if(i)
				v[i]+=v[i-1];
		}
		map<ll,ll>mp;
		ll ans=0;
		for(int i=0;i<n;i++){
			if(v[i]==0)
				ans++;
			if(mp.size()&&mp.find(v[i])!=mp.end())
				ans+=mp[v[i]];
			mp[v[i]]++;
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 14336
import numpy as np
n,m,c=map(int,input().split())
b=np.array(list(map(int,input().split())))
ac=0
for _ in range(n):
    a=np.array(list(map(int,input().split())))
    if sum(a*b)+c >0:
        ac+=1
print(ac)


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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
  int x;
  cin >> x;
  if(x == 3){
      cout << "YES" <<endl; 
    }else if(x == 5){
        cout << "YES" << endl;
      }else if(x == 7){
          cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
          }
          return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
        var output = new StringBuilder();
        var loop = input[0] > input[1] ? input[0] : input[1];
        var str = (input[0] > input[1] ? input[1] : input[0]).ToString();
        for(var i = 0; i < loop; i++)
        {
            output.Append(str);
        }
        Console.WriteLine(output);
#if DEBUG
		Console.ReadKey();
#endif
    }
}

Measured memory_bytes: 13268
#include<stdio.h>
int main()
{
int a,b;
scanf("%d %d",&a,&b);
if(b%a==0)
    {
        printf("%d\n",a+b);
        //printf("As %d is a divisor of %d.\n",a,b);
    }
else
    printf("%d\n",b-a);
return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int s[200005];
int main(){
    int n,k;
    cin >> n >> k;
    int a;
    int ans=0;
    int tmp=0;
    for(int i=0;i<n;i++){
        cin >> a;
        if(s[a]==0)tmp++;
        s[a]++;
    }
    if(tmp<=k){
        cout << 0 << endl;
        return 0;
    }
    sort(s,s+n+1);
    int count=0;
    int i=0;
    while(count<tmp-k){
        if(s[i]>0){
            ans+=s[i];
            count++;
        }
        i++;
    }
    cout << ans;
}

Measured memory_bytes: 4408
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

int main() {
    int N, W;   cin >> N >> W;
    vector<int> w(N);
    vector<ll> v(N);
    for (int i = 0; i < N; i++)
        cin >> w[i] >> v[i];

    vector<vector<ll> > dp(N+1, vector<ll>(W+1, 0));

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W; j++) {
            if (j >= w[i])
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
            else 
                dp[i+1][j] = dp[i][j];
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 83064
#include <iostream>
#include <array>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
#include <fstream>
#include <string>
#include <random>
#include <queue>
#include <iomanip>
#include <functional>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <limits>
#include <functional>

#define FOR(x,n) for(int x = 0; x < n; x++)
#define PUT(x) cout << x << endl
#define DPUT(x) printf("%.15lf\n",x)
#define GET(x,y) std::get<x>(y)
#define CHMAX(x,y) x = std::max(x,y)
#define CHMIN(x,y) x = std::min(x,y)

using namespace std;

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;

const ll mod197 = 1000000007LL;
const ll INF = 200LL * 200 * 100000 + 10;

const double PI11 = 3.14159265359;

const int dis[5] = { 0,1,0,-1,0 };

const int disD[4] = { 0,1,1,0 };

int table[100002] = {};
bool eratos[100002] = {};

void eratosthenes() {

	fill(eratos, eratos + 100001, true);

	eratos[0] = false;
	eratos[1] = false;

	for (int i = 0; i < 100001; i++) {
		if (eratos[i]) {
			for (int j = 2; j * i < 100001; j++) {
				eratos[j * i] = false;
			}
		}
	}

	return;
}

void solve() {
	for (int i = 0; i < 100001; i++) {
		if (i % 2 && eratos[i] && eratos[(i + 1) / 2]) {
			table[i] = 1;
		}
	}


	for (int i = 0; i < 100001; i++) {
		table[i + 1] += table[i];
	}
}

int main(void) {

	eratosthenes();

	solve();

	int q;
	cin >> q;

	FOR(i,q){
		int l, r;
		cin >> l >> r;

		cout << table[r] - table[l - 1] << endl;
	
	}

	return 0;
}

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

const ll INF = 1LL<<60;

int main(){
	ll n;
	cin >> n;
	ll ans = INF;
	for (ll i = 1; i*i <= n; ++i) {
		if(n%i==0){
			ans = min(ans, i + n/i - 2);
		}
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
<?php
$moji = fgets(STDIN);

$waketa = preg_split('/[,.\s]/', $moji);

$renketu = '';
foreach ($waketa as $value) {
    if (strlen($value)>=3 && strlen($value)<=6) {
        $renketu = $renketu.$value.' ';
    }
}
if ($renketu!="") {
    $renketu=substr($renketu, 0, -1);
}
echo $renketu."\n";

Measured memory_bytes: 15236