akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, k;
	cin >> n >> k;
	vector<int>height(n);
	for (int i = 0; i < n; i++)
	{
		int d;
		cin >> d;
		height[i] = d;
	}
	vector<int>dp(n);
	dp[0] = 0;
	for (int i = 1; i < n; i++)
	{
		dp[i] = INT_MAX;
		for (int j = 1; j <= k; j++)
		{
			if (i - j >= 0)
			{
				//cout << height[i - j] << "  " << height[i] << "   " << dp[i - j] << endl;
				dp[i] = min(dp[i], abs(height[i - j] - height[i]) + dp[i - j]);
			}
		}
	}
	// for (int i = 0; i < n; i++)
	// {
	// 	cout << dp[i] << "  ";
	// }
	// cout << endl;
	cout << dp[n - 1];
	return 0;
}

Measured memory_bytes: 4028
#include<cstdio>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;


void max_u(int&m, int v)
{
	if(m<v) m=v;
}


struct p_t
{
	int x, y, c;
};

int solve(vvi&f, int w, int h, int sx, int sy)
{
	queue<p_t> q;
	vvi c(h+2);
	int ret=0;
	int vx[]={ 0, 1, 0,-1};
	int vy[]={ 1, 0,-1, 0};

	for(auto&mc:c) mc.assign(w+2, -1);
	p_t p={sx, sy, 0};
	c[sy][sx]=0;
	q.emplace(p);
	while(!q.empty())
	{
		p=q.front();
		q.pop();

		max_u(ret, p.c);
		for(int i=0;i<4;i++)
		{
			int nx=p.x+vx[i];
			int ny=p.y+vy[i];
			if(f[ny][nx]) continue;
			if(c[ny][nx]>=0) continue;
			p_t np={nx, ny, p.c+1};
			c[ny][nx]=p.c+1;
			q.push(np);
		}
	}
	return ret;
}


int main(void)
{
	int h, w;
	while(scanf("%d%d\n", &h, &w)==2)
	{
		vvi f(h+2);

		for(auto&mf:f) mf.assign(w+2, 1);

		for(int y=1;y<=h;y++)
		{
			char s[20+4];
			scanf("%[.#]\n", s+1);

			for(int x=1;x<=w;x++)
			{
				if(s[x]=='.') f[y][x]=0;
			}
		}
		int ans=0;
		for(int y=1;y<=h;y++)
		{
			for(int x=1;x<=w;x++)
			{
				if(f[y][x]) continue;
				max_u(ans, solve(f, w, h, x, y));
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int devide3(int x){
  if(x % 3 == 0){
    return 1;
  }else{
    return 0;
  }
}
int mod10(int x){
  while(1){
    if(x != 0){
      if(x % 10 == 3){
	return 1;
      }else{
	x= x / 10;
      }
    }else{
      return 0;
      break;
    }
  }
}
int main(){
  int n;
  cin >> n;
  for(int i = 1;i <= n; i++){
    if((devide3(i))||(mod10(i))){
      cout << " " << i;
    }
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3068
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    long a = sc.nextLong() - 1;
    long b = sc.nextLong();
    long c = sc.nextInt();
    long d = sc.nextInt();
    long final_a = 0;
    long final_b = 0;
    long ac = 0;
    long ad = 0;
    long bc = 0;
    long bd = 0;
    long acd = 0; 
    long bcd = 0;

    long cd = lcm(c, d);

    ac = a / c;
    ad = a / d;
    bc = b / c;
    bd = b / d;
    acd = a / cd;
    bcd = b / cd;

    final_a = a - ac - ad + acd;
    final_b = b - bc - bd + bcd;

    System.out.println(final_b - final_a);



    

    
    
    }
    
    static long lcm (long a, long b) {
        long temp;
        long c = a;
        c *= b;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return (long)(c/b);
    }
}

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

using namespace std;
int a[100];
int main()
{
    int z,s=0;
    scanf("%d",&z);
    for(int i=0;i<z;i++) scanf("%d",&a[i]);
    for(int i=1;i<z;i++){
        if(a[i]==a[i-1]){
            s++;
            i++;
        }
    }
    printf("%d",s);
    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 rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    rrep(i, n - 1) {
        if (h[i] <= h[i + 1]) continue;
        if (h[i] - 1 == h[i + 1])
            h[i]--;
        else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef std::vector<int> vi;
typedef std::vector<long long> vll;

#define pub push_back
#define pob pop_back
#define mp make_pair
#define ff first
#define ss second
#define umap unordered_map
#define uset unordered_set

#define forn(i, n)     for(ll i = 0; i< (ll)n; i++)
#define forf(i, x, y)  for(ll i=(x); i<=(ll)y; i++)
#define forb(i, x, y)  for(ll i=(x); i>=(ll)y; i--)
#define lpt() 		   ll T; std::cin>>T; while(T--)

#define nl "\n"
#define newl std::cout<<"\n";
#define bug(x) std::cerr<<"debug "<<#x<<" : "<<x<<"\n";
#define all(x) x.begin(),x.end()
#define fastio() ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);

template<typename X> std::ostream& operator<< (std::ostream& out, std::vector<X> v)
{ for(auto &i : v) out<<i<<" "; return out; }
template<typename X, typename Y> std::ostream& operator<< (std::ostream& out, std::pair<X,Y> p)
{ out<<p.first<<" "<<p.second; return out; }

static const long long mod = 1000000007;

using namespace std;

ll mem[100000];
vi v;

ll cost(ll i)
{
	if(mem[i] != -1)
		return mem[i];
	return mem[i] = min(abs(v[i+1] - v[i])+cost(i + 1),abs(v[i+2] - v[i])+cost(i + 2));
}

int main()
{fastio();
	
	int n;
	cin>>n;
	forn(i,n)
	{
		ll temp;
		cin>>temp;
		v.pub(temp);
	}
	memset(mem,-1,sizeof mem);
	mem[n-2] = abs(v[n-2] - v[n-1]);
	mem[n-1] = 0;

	cout<<cost(0)<<nl;

return 0;}


Measured memory_bytes: 3960
#include <iostream>
#include <stdlib.h>
#include <math.h>

using namespace std;
int input[10000];

int main(void){
    int index = 0;
    while(1){
        cin >> input[index];
        if(input[index] == 0){
            break;
        }
        ++index;
    }
    
    for(int i = 0;i < index;++i){
        cout << "Case " << i + 1 << ": " << input[i] << endl;
    }
    
    return 0;
}



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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------

int main() {
    ll n, m;
    cin >> n >> m;
    ll x[n], y[n], z[n];
    rep(i, n) cin >> x[i] >> y[i] >> z[i];

    ll Max = -LINF;

    rep(p, 8) {
        int t = p;
        int i = t % 2;
        t /= 2;
        int j = t % 2;
        t /= 2;
        int k = t % 2;

        ll value[n] = {};

        rep(e, n) {
            if (i == 1) value[e] += x[e];
            else value[e] -= x[e];
            if (j == 1) value[e] += y[e];
            else value[e] -= y[e];
            if (k == 1) value[e] += z[e];
            else value[e] -= z[e];
        }
        sort(value, value + n);
        reverse(value, value + n);
        ll sum = 0;
        rep(e, m) sum += value[e];
        Max = max(Max, sum);

    }

    cout << Max << endl;

    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    print(n**3)
    return

#B
def B():
    n = II()
    a = LI()
    b = LI()
    c = LI()
    ans = 0
    for i in range(n):
        ans += b[a[i] - 1] + (c[a[i] - 1] if i != n - 1 and a[i] + 1 == a[i + 1] else 0)
    print(ans)
    return

#C
def C():
    n = II()
    b = LI()
    ans = b[0]
    for i in range(n-2):
        if b[i] >= b[i + 1]:
            ans += b[i + 1]
        else:
            ans += b[i]
    print(ans+b[-1])
    return

#D
def D():
    n, k = LI()
    s = S()
    a = []
    for i in range(n):
        if i == n - 1:
            a.append(s[i])
        elif s[i] != s[i + 1]:
            a.append(s[i])
    print(min(n - 1, n - len(a) + 2 * k))
    return

#E
def E():
    return

#F
def F():
    return


#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 39152
N = int(input())
 
def prime_factorization(N):
  n = int(N**0.5)+1
  numList = [i if i != 1 else 2 for i in range(1, n, 2) ]
  primeList = [2]
  ansDict = {}
  idx = 0
  for data in numList:
    for x in primeList:
      if (data%x != 0 or x == 2):
        count = 0
        while N%data == 0:
          count += 1
          N //= data
        if count > 0:
          ansDict[data] = count
        if N == 1:
          return ansDict
        if x != 2:
          primeList.append(data)
        break
  if N != 1:
    ansDict[N] = 1
  
  return ansDict 

if N <= 1:
  print(0)
  exit()
  
ansDict = prime_factorization(N)
ansCount = 0
for p,v in ansDict.items():
  e = 1
  while e <= v:
    ansCount += 1
    v -= e 
    e += 1  

print(ansCount)

Measured memory_bytes: 28876
#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 pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n, k; cin >> n >> k;
    double ans = 0.0;
    for(int i = 1; i <= n; i++){
        double tmp = 1.0/n;
        int cur = i;
        while(cur < k){
            cur *= 2;
            tmp /= 2;
        }
        ans += tmp;
    }
    cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 256
INF=float("inf")
N=int(input())
a=list(map(int, input().split()))
cum = [0]*(N+1)
for i in range(1, N+1):
    cum[i] = cum[i-1] + a[i-1]
s = sum(a)
ans = INF
for i in range(1, N):
    ans = min(ans, abs(cum[i] - (s - cum[i])))
print(ans)

Measured memory_bytes: 100420
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    public static void Main()
    {
        long i = 100;
        var n = long.Parse(ReadLine());
        long count = 0;
        while(i < n)
        {
            i += (long)(i / 100d);
            count++;
        }
        WriteLine($"{count}");
    }
}

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

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

	int l=a[n/2 -1],	r=a[n/2];

	int ans=0;
	for(int i=l+1;i<=r;i++)ans++;

	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    int m = 1 << n;

    vector<array<int, 2>> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i][0];
        a[i][1] = 0;
    }

    for (int k = 0; k < n; k++) {
        int l = 1 << k;
        for (int h = l; h < m; h += l * 2) {
            for (int i = h; i < h + l; i++) {
                int j = i ^ l;
                if (a[i][0] >= a[j][0]) {
                    a[i][1] = max(a[i][1], a[j][0]);
                } else {
                    a[i][1] = max(a[j][1], a[i][0]);
                    a[i][0] = a[j][0];
                }
            }
        }
    }

    int r = 0;
    for (int i = 1; i < m; i++) {
        r = max(r, a[i][0] + a[i][1]);
        cout << r << '\n';
    }
    cout << flush;

    return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


const int SIZE = 201;
const int NONE = -1;

int H[SIZE];
int R[SIZE];
int N;
int dp[1002][1002];

int solve( int hh, int rr ) {
    int& res = dp[hh][rr];
    if ( res != NONE ) return res;
    int maxd = 0;
    for ( int i = 0; i < N; ++ i ) {
        if ( H[i] < hh && R[i] < rr ) {
            maxd = max( maxd, 1 + solve( H[i], R[i] ) );
        }
    }
    return res = maxd;
}

int main() {
    int n, m;
    while ( cin >> n && n ) {
        for ( int i = 0; i < 1002; ++ i ) {
            for ( int j = 0; j < 1002; ++ j ) {
                dp[i][j] = NONE;
            }
        }
        for ( int i = 0; i < n; ++ i ) {
            cin >> H[i] >> R[i];
        }
        cin >> m;
        for ( int i = n; i < n+m; ++ i ) {
            cin >> H[i] >> R[i];
        }
        N = n + m;
        cout << solve( 1001, 1001 ) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
import fractions
N=int(input())
A=list(map(int,input().split()))
A.sort()
minhp=0
mi=float("inf")
for i in range(N-1):
    minhp=fractions.gcd(A[0],A[i+1])
    if mi>minhp:
        mi=minhp
print(mi)

Measured memory_bytes: 88300
#include<iostream>
#include<algorithm>
#include<cstdio> 
#include<cstring>
#include<cmath>
#include<map>
#include<queue> 
#include<vector>
#define LL long long
using namespace std;
vector<LL> a[110000];
LL n,f[110000],d[110000],p,ans,i,tt,o,ff[110000][30],b[110000],pp,tot; 
void dfs(LL x) {
	int p = a[x].size();
	for (int i = 0; i < p; i++) {
		d[a[x][i]] = d[x] + 1;
		ff[a[x][i]][0] = x;
		dfs(a[x][i]);
	}
}
void init()
{
  LL i,j;
  //p[i][j]表示i?点的第2^j祖先
  for(j=1;(1<<j)<=n;j++)
    for(i=1;i<=n;i++)
      if(ff[i][j-1]!=-1)
        ff[i][j]=ff[ff[i][j-1]][j-1];//i的第2^j祖先就是i的第2^(j-1)祖先的第2^(j-1)祖先
}
int lca(int a,int b)//最近公共祖先
{
  int i,j;
  if(d[a]<d[b])swap(a,b);
  for(i=0;(1<<i)<=d[a];i++);
  i--;
  //使a，b?点的深度相同
  for(j=i;j>=0;j--)
    if(d[a]-(1<<j)>=d[b])
      a=ff[a][j];
  if(a==b)return a;
  //倍?法，?次向上?深度2^j，找到最近公共祖先的子?点
  for(j=i;j>=0;j--)
  {
    if(ff[a][j]!=-1&&ff[a][j]!=ff[b][j])
    {
      a=ff[a][j];
      b=ff[b][j];
    }
  }
  return ff[a][0];
}
int main() {
	scanf("%lld", &n);
	for (i = 2; i <= n; i++) {
		scanf("%lld", &f[i]);
		a[f[i]].push_back(i);
	}
	for (i = 1; i <= n; i++) sort(a[i].begin(), a[i].end());
	//for (i = 0; i < a[2].size(); i++) cout<<a[2][i]<<" ";cout<<endl;
	d[1] = 0;
	dfs(1);
	queue<LL> q;
	while (!q.empty()) q.pop();
	q.push(1); 
	while (!q.empty()) {
		int p = q.front();  q.pop();
		b[++pp] = p;
		int pp = a[p].size();
		for (int i = 0; i < pp; i++) {
			q.push(a[p][i]); 
		}
	}
	init(); ff[1][0] = -1;
	ans = 0;
	//for (i = 1; i <= pp; i++) cout<<b[i]<<" "; cout<<endl;
	for (i = 1; i < pp; i++) {
		p = lca(b[i], b[i + 1]);
		tot = (d[b[i]] - d[p]) + (d[b[i + 1]] - d[p]);
		ans = ans + tot;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 39392
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
int main(){
    int n;
    cin>>n;
    int a=n%10;
    if(a==3){
        cout<<"bon"<<endl;
        return 0;
    }
    if(a==1||a==6||a==8||a==0){
        cout<<"pon"<<endl;
        return 0;
    }
    else cout<<"hon"<<endl;
}

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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Point{
	double x,y;
	Point(){}
	Point(double x,double y):x(x),y(y){}
	Point& operator+=(Point p){
		x+=p.x,y+=p.y;
		return *this;
	}
	Point& operator-=(Point p){
		x-=p.x,y-=p.y;
		return *this;
	}
	Point& operator*=(double c){
		x*=c,y*=c;
		return *this;
	}
	Point& operator/=(double c){
		x/=c,y/=c;
		return *this;
	}
};
Point operator+(Point a,Point b){
	return a+=b;
}
Point operator-(Point a,Point b){
	return a-=b;
}
Point operator*(Point a,double c){
	return a*=c;
}
Point operator*(double c,Point a){
	return a*=c;
}
Point operator/(Point a,double c){
	return a/=c;
}
bool operator==(Point a,Point b){
	return abs(a.x-b.x)<EPS && abs(a.y-b.y)<EPS;
}
bool operator!=(Point a,Point b){
	return !(a==b);
}

double Dot(Point a,Point b){
	return a.x*b.x+a.y*b.y;
}
double Cross(Point a,Point b){
	return a.x*b.y-a.y*b.x;
}

void solve()
{
	Point a,b,c,d;
	cin>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y>>d.x>>d.y;
	if(Cross(a-b,c-d)==0)
		cout<<2<<endl;
	else if(Dot(a-b,c-d)==0)
		cout<<1<<endl;
	else
		cout<<0<<endl;
}

int main()
{
	int q; cin>>q;
	rep(_,q) solve();
}

Measured memory_bytes: 1232
import sys
input = sys.stdin.buffer.readline
from collections import deque
import bisect

def main():
    N,M,V,P = map(int,input().split())
    a = sorted(list(map(int,input().split())),reverse=True)
    r = a[P-1]
    l = a[P-1]-M-1
    
    while r-l > 1:
        mid = (r+l)//2
        count = 0
        for x,num in enumerate(a):
            if x < P-1:
                count += M
            else:
                if num > mid:
                    count += max(mid+M-num,0)
                else:
                    count += M
        if count >= M*V:
            r = mid
        else:
            l = mid

    a.reverse()     
    print(N-bisect.bisect_left(a,r))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 12764
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long x = sc.nextLong();
		long A[] = new long[N];
		for (int i=0;i<N;i++) {
			A[i] = sc.nextLong();
		}
		long count =0;
		for (int i=1;i<N;i++) {
			if(A[i]+A[i-1]>x) {
				long temp = A[i]+A[i-1]-x;
				count +=temp;
				if (A[i-1]>x) {
					A[i] =0;
				} else {
					A[i]-=temp;
				}

			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 50288
N = int(input())
if N <= 1:
    print('0')
    exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

r = 0
for n, i in factorization(N):
    m = 1
    while i >= m:
        i -= m
        m += 1
        r += 1
print(r)

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

using namespace std;

int factorial(int n){
    if (n == 0)
        return 1;
    return n * factorial(n - 1);
}

int main(){
    int n;
    cin >> n;
    vector<int> X(n), Y(n);
    for (int i = 0; i < n; i++)
        cin >> X[i] >> Y[i];

    double sum = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            sum += sqrt((X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j]));
        }
    }

    cout << setprecision(20) << sum / n << endl;
    
}

Measured memory_bytes: 256
fun main() {
    val s = readLine()?.toLong() ?: return
    val (x1, x2) = listOf(1e9.toLong(), 1L)

    val y2 = s / x1 + if (s % x1 == 0L) {
        0
    } else {
        1
    }
    val y1 = x1 * y2 - s
    println("0 0 $x1 $y1 $x2 $y2")
}

Measured memory_bytes: 37784
N, M = map(int, input().split())
A = []
for _ in range(M):
    A.append(tuple(map(int, input().split())))
P = tuple(map(int, input().split()))
import itertools
def hantei(A, RETU, P):
    for i in range(len(A)):
        count = 0
        for k in RETU:
            if k in A[i][1:]:
                count += 1
        if not count % 2 == P[i]:
            return False
    return True
ans = 0
for i in range(1, N + 1):
    for k in itertools.combinations(range(1, N + 1), i):
        if hantei(A, k, P):
            ans += 1
if hantei(A, [0], P):
    ans += 1
print(ans)

Measured memory_bytes: 9232
def b():
    h, w = map(int, input().split())
    if (h == 1) or (w == 1):
        print("1")
    else:
        ki = int(h / 2) + h % 2
        gu = int(h / 2)

        sum_ki = ki * (int(w / 2) + w % 2)
        sum_gu = gu * (int(w / 2))
        print(sum_ki + sum_gu)


def c():
    a, b, c = map(int, input().split())
    ab = 4 * a * b
    a_b_c = c - (a + b)
    a_b_c_2 = a_b_c ** 2
    if a_b_c <= 0:
        print("No")
    else:
        if ab < a_b_c_2:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    b()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll power(ll x, ll m){
    if(m == 0) return 1;
    if(m == 1) return x;
    if(m % 2 == 0){
        return power(x*x,m/2);
    }else{
        return power(x*x,m/2)*x;
    }
}

int main(){
    ll m,k; cin >> m >> k;
    ll M = power(2,m);
    if(k==0){
        rep(i,M){
            cout << i << " " << i << " ";
        }
        return 0;
    }else if(k==1){
        if(m>1){
            ll a = 2, b = 3;
            cout << k << " " << a << " " << b << " ";
            rep(i,M){
                if(i==a || i==b || i==k) continue;
                cout << i << " ";
            }
            cout << k << " ";
            for(ll i=M-1; i>=0; i--){
                if(i==a || i==b || i==k) continue;
                cout << i << " ";
            }
            cout << b << " " << a << " ";
            return 0;
        }
    }else{
        
        ll a=-1,b;
        ll bit=1;
        while(1){
            if(k == (1<<bit)){
                a = 1;
                b = k+1;
                break;
            }
            if(k & (1<<bit)){
                a = 1<<bit;
                b = a^k;
                break;
            }
            bit++;
        }
        if(M > max({a,b,k})){
            if(a != -1){
                cout << k << " " << a << " " << b << " ";
                rep(i,M){
                    if(i==a || i==b || i==k) continue;
                    cout << i << " ";
                }
                cout << k << " ";
                for(ll i=M-1; i>=0; i--){
                    if(i==a || i==b || i==k) continue;
                    cout << i << " ";
                }
                cout << b << " " << a << " ";
                return 0;
            }
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        string s;
        cin >> s;
        bool flag = true;
        ll cnt = 0;
        for(i = 0; i < s.size() ; i += 2){
            if(s[i] != 'h')
            {
                flag = false;
            }
            cnt++;
        }
        for(i = 1; i < s.size() ; i += 2){
            if(s[i] != 'i'){
                flag = false;
            }
            cnt--;
        }
        if(!flag || cnt != 0){
            cout << "No";
        }
        else{
            cout << "Yes";
        }
    }
    return 0;
}

Measured memory_bytes: 3616
open Printf
open Scanf

let (++) = Int64.add
let (--) = Int64.sub
let ( ** ) = Int64.mul
let (//) = Int64.div
let (%%) = Int64.rem
let landl = Int64.logand
let lorl = Int64.logor
let lnotl = Int64.lognot
let lxorl = Int64.logxor
let lsll = Int64.shift_left
let lsrl = Int64.shift_right_logical
let long = Int64.of_int
let succl = Int64.succ
let predl = Int64.pred

let read_int _ = scanf " %d " (fun x -> x)
let read_long _ = scanf " %Ld " (fun x -> x)
let read_str _ = scanf " %s " (fun x -> x)
let read_double _ = scanf " %f " (fun x -> x)
let read_pair _ = scanf " %d %d " (fun n q -> (n,q))

let explode s =
  let rec exp i l =
    if i < 0 then l else exp (i - 1) (s.[i] :: l) in
  exp (String.length s - 1) []

let cnt s =
  let rec cnt' accum c prev = function
    | [] -> List.rev accum
    | 'C' :: rest when prev = 'A' -> cnt' (c+1 :: accum) (c+1) 'C' rest
    | b :: rest -> cnt' (c::accum) c b rest in
  let l = cnt' [0] 0 'B' (explode s) in
  Array.of_list l

let () =
  let n,q = read_pair () in
  let s = read_str () in
  let ctr = cnt s in
  let queries = Array.init q read_pair in
  Array.iter (fun (l,r) -> printf "%d\n" (ctr.(r) - ctr.(l))) queries


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

//pair<int,int>;

int W,H;
vector<string> s(20);
int nextX[] = {1,0,-1,0};
int nextY[] = {0,1,0,-1};
vector<vector<int>> count_map(20,vector<int>(20,0));

bool range_check(int y,int x){
  if(y<0||x<0||y>=H||x>=W){
    return false;
  }
  return true;
}

void bfs(int y,int x){
  if(!range_check(y,x)){
    return;
  }
  //printf("%d %d",y,x);
  if(s[y][x]=='#'){
    //printf("aaa\n");
    return;
  }
  if(count_map[y][x]){
    return;
  }
  count_map[y][x]=1;
  queue<pair<int,int>> node;
  for(int i=0;i<4;i++){
    int ny = y+nextY[i],nx = x + nextX[i];
    if(!range_check(ny,nx)){
      continue;
    }
    if(s[ny][nx]=='.'){
      node.emplace(ny,nx);
    }
  }
  while(!node.empty()){
    pair<int,int> yx = node.front();
    node.pop();
    bfs(yx.first,yx.second);
  }
}

int main(){
  while(1){
    cin>>W>>H;
    if(W==0&&H==0){
      break;
    }
    for(int i=0;i<H;i++){
      cin>>s[i];
    }
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        if(s[i][j]=='@'){
          bfs(i,j);
        }
      }
    }
    int ans=0;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        //printf("%3d",count_map[i][j]);
        if(count_map[i][j]){
          ans++;
          count_map[i][j]=0;
        }
      }
      //cout<<endl;
    }
    cout<<ans<<endl;
  }
  return 0;
}



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

#define int long long
#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define reps(i, n) for (int (i) = 1; (i) <= (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL << (n))
typedef vector<int> vint;
typedef pair<int, int> pint;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct SetUp {
    SetUp() {
        cout << fixed << setprecision(20);
        cerr << fixed << setprecision(20);
    };
} setUp;

int N;
string S;
int mod = 1e9 + 7;
int has[3] = {114514, 1919, 810};

int tt[3][5500], cht[3][5500];
signed main() {
    cin >> N >> S;

    tt[0][0] = tt[1][0] = tt[2][0] = 1;
    cht[0][0] = cht[1][0] = cht[2][0] = 0;
    rep(j, 3) {
        reps(k, N) {
            tt[j][k] = tt[j][k - 1] * has[j];
            cht[j][k] = (cht[j][k - 1] * has[j] + S[k - 1]);
        }
    }

    int lb = 0, ub = N / 2 + 1;
    while (ub - lb > 1) {
        int i = (lb + ub) / 2;
        int t[3];
        rep(j, 2) { t[j] = tt[j][i]; }

        int ch[3];
        rep(j, 2) { ch[j] = cht[j][i]; }

        //あるハッシュ値がすでに存在したか
        unordered_set<int> mp[3];
        //ハッシュ値の履歴
        vint kh[3];
        bool fflag = false;
        for (int j = 0; j + i <= N; j++) {
            bool flag = true;
            rep(k, 2) {
                flag &= mp[k].count(ch[k]) > 0;
                kh[k].push_back(ch[k]);
                if (j >= i - 1) {
                    mp[k].insert(kh[k][j - (i - 1)]);
                }
                ch[k] = ch[k] * has[k] + S[j + i] - S[j] * t[k];
            }
            fflag |= flag;
        }
        if (fflag) { lb = i; }
        else { ub = i; }
    }
    cout << lb << endl;

}


Measured memory_bytes: 1100
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	string N;
	cin >> N;
	M = N.size();
	reverse(N.begin(), N.end());
	N.push_back('0');
	int ans = 0;
	rep(i, M + 1) {
		int n = N[i] - '0';
		if (n > 9) {
			N[i + 1]++;
		} else if (n > 5) {
			ans += 10 - n;
			N[i + 1]++;
		} else if (n == 5) {
			if (i < M && N[i + 1] >= '5') {
				ans += 10 - n;
				N[i + 1]++;
			} else {
				ans += n;
			}
		} else {
			ans += n;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define dump(x) cerr << #x << "=" << (x) << endl;
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r, S;
  cin >> r;
  S = int(pow(r, 2));

  cout << S << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void swap(int a[100000],int i,int j)
{
    int tmp = a[i];
    a[i] = a[j];
    a[j] = tmp;
    return;
}

int main()
{
    int n,p[100000],i,j,cnt = 0;

    scanf("%d",&n);
    for(i = 0;i < n; i++)scanf("%d",&p[i]);

    for (i = 0; i < n - 1; i++)
    {
        if(p[i] == i + 1)
        {
            cnt ++;
            swap(p,i,i + 1);
        }
    }
    if(p[i] == i + 1){cnt ++;}
    printf("%d",cnt);
}

Measured memory_bytes: 512
package main

import (
	"fmt"
)

func main() {
	var (
		num   int
		count = 0
		value = 0
		b     []int
		flag  = 0
	)
	fmt.Scan(&num)
	for i := 0; i < num; i++ {
		fmt.Scan(&value)
		b = append(b, value)
	}
	for {
		for i := 0; i < num; i++ {
			if b[i]%2 != 0 {
				flag = 1
				break
			}
			b[i] = b[i] / 2
		}
		if flag == 1 {
			break
		}
		count++
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
balls_color1, balls_color2 = input().split()
balls_count1, balls_count2 = map(int, input().split())

balls = {
    balls_color1: balls_count1,
    balls_color2: balls_count2
}

trash = input()
balls[trash] -= 1

print(balls[balls_color1], balls[balls_color2])

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

bool isnum(char a){
	return (a >= '0' && a <= '9');
}
string removezero(string a){
	string rst = "";
	bool flg = false;
	REP(i,a.size()){
		if(flg){
			rst += a[i];
		}else{
			if(a[i] != '0'){
				flg = true;
				rst += a[i];
			}
		}
		
	}
	return rst;
}
string getbiggerstr(string a,string b){
	a = removezero(a);
	b = removezero(b);
	if(a.size() < b.size()) return b;
	else if(a.size() > b.size()) return a;
	REP(i,a.size()){
		if(a[i] < b[i]) {
			return b;
		}else if(a[i] > b[i]){
			return a;
		}
	}
	return a;
}
int main(){
	int w,h;
	char g[70][70];
	string s[70][70];
	//cout << getbig("23900","23114") << endl;
	while(1){
		string ans = "";
		cin >> w >> h;
		if (w == 0 && h == 0) break;
		REP(i,h) REP(j,w) cin >> g[i][j];
		REP(i,h) REP(j,w) s[i][j] = "";
		REP(i,h){
			REP(j,w){
				if(!isnum(g[i][j])) continue;
				int lx = i; int ly = j-1;
				int ux = i-1; int uy = j;
				string l,r;
				if(lx >= 0 && ly >= 0) l = s[lx][ly];
				else l = "";
				if(ux >= 0 && uy >= 0) r = s[ux][uy];
				else r = "";
				l.pb(g[i][j]);
				r.pb(g[i][j]);
				s[i][j] = getbiggerstr(l,r);
				//cout << l << "??¨" << r << " big " << s[i][j] << endl;
				ans = getbiggerstr(s[i][j],ans);
			}
		}
		cout << ans << endl;

	}
}

Measured memory_bytes: 1380
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

lint tf[20][20];
  int main(){
     lint n;
     cin>>n;
     lint a[n];
     rep(i,n){
         string s;
         cin>>s;
         lint j=0;
         while(s[j]!='.'){
             if(j==(s.size()-1))break;
             j++;
         }
         lint f=9-(s.size()-1-j);
         rep(k,f)s+='0';
         string s1;
         rep(k,s.size()){
             if(s[k]=='.')continue;
             s1+=s[k];
         }
         a[i]=stoll(s1);
     }
     rep(i,n){
         lint count2=0,count5=0;
         while(a[i]%2==0){
             count2++;
             a[i]/=2;
         }
         while(a[i]%5==0){
             count5++;
             a[i]/=5;
         }
         count2=min(18LL,count2);
        count5=min(18LL,count5);
         tf[count2][count5]++;
     }
     lint ans=0;
     rep(i,19){
         rep(j,19){
             rep(k,19){
                 rep(l,19){
                     if(i+k<18||j+l<18)continue;
                     if(i==k&&j==l)ans+=tf[i][j]*(tf[k][l]-1);
                    else ans+=tf[i][j]*tf[k][l];
                 }
             }
         }
     }
    cout<<ans/2<<endl;
      }
      

Measured memory_bytes: 5032
#include <iostream>

using namespace std;

int main() {

  int a, b;
  cin >> a >> b;
  if(a <= 0 && 0 <= b){
    cout << "Zero";
  }else if(1 <= a){
    cout << "Positive";
  }else{
    if((abs(b) - abs(a) + 1) % 2 == 0){
      cout << "Positive";
    }else{
      cout << "Negative";
    }
  }
  return 0;
}


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

#define M 1046257
#define NIL (-1)
#define L 14

char H[M][L];

// 文字から数値に変換
int getChar(char ch) {
  if ( ch == 'A' ) return 1;
  else if ( ch == 'C' ) return 2;
  else if ( ch == 'G' ) return 3;
  else if ( ch == 'T' ) return 4;
  return 0;
}

// 文字列から数値へ変換して key を生成する
long long getKey(char str[]) {
  long long sum =0, p = 1, i;
  for(i=0;i<strlen(str);i++) {
    sum += p*(getChar(str[i]));
    p*= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]) {
  long long key, i, h;
  key = getKey(str); // 文字列を数値に変換
  for(i=0; ;i++) {
    h = (h1(key) + i*h2(key)) %M;
    if( strcmp(H[h],str) == 0) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str); // 文字列を数値に変換
  for(i=0; ; i++) {
    h = (h1(key) + i * h2(key)) %M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) {
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(void) {
  int i, n;
  char str[L], com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s %s",com,str); // より高速なscanfを使用
    if(com[0] == 'i') {
      insert(str);
    } else {
      if(find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
  return 0;
}



Measured memory_bytes: 16040
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <algorithm>
#include <cmath>
using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int main()
{
	int  high[3] = { 0 };
	for (int i = 0; i < 10; i++) {
		int n;
		cin >> n;
		if (n > high[0]) {
			high[2] = high[1];
			high[1] = high[0];
			high[0] = n;
		}
		else {
			if (n > high[1]) {
				high[2] = high[1];
				high[1] = n;
			}
			else {
				if (n > high[2]) high[2] = n;
			}
		}
	}
	printf("%d\n%d\n%d\n", high[0], high[1], high[2]);
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define INF 1020304050

void dfs(int now, vector<vector<int>> &g,vector<int> &lis,vector<int> &ind,vector<int> &anss,vector<int> &a)
{
  int i;
  int id=lower_bound(all(lis),a[now])-lis.begin();
  ind[now]=id;
  int memo=lis[ind[now]];
  lis[id]=a[now];
  int ida=lower_bound(all(lis),INF)-lis.begin();
  anss[now]=ida;
  rep(i,g[now].size())
  {
    if(anss[g[now][i]]==-1)
    {
      int ch=lis[ind[now]];
      dfs(g[now][i],g,lis,ind,anss,a);
      lis[ind[now]]=ch;
    }
  }
  lis[ind[now]]=memo;
}

int main()
{
  int n;cin>>n;
  vector<int> a(n);
  int i;
  rep(i,n)cin>>a[i];
  vector<int> u(n-1);
  vector<int> v(n-1);
  rep(i,n-1)
  {
    cin>>u[i]>>v[i];
    u[i]--;
    v[i]--;
  }
  vector<vector<int>> g(n);
  rep(i,n-1)
  {
    g[u[i]].emplace_back(v[i]);
    g[v[i]].emplace_back(u[i]);
  }
  vector<int> anss(n,-1);
  vector<int> lis(n+10,INF);
  vector<int> ind(n,-1);
  dfs(0,g,lis,ind,anss,a);
  rep(i,n)
  {
    cout<<anss[i]<<endl;
  }
}


Measured memory_bytes: 36212
#include<bits/stdc++.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include <cstdlib>
#include <climits>
#include <iomanip>
#include<iostream>
#include <sstream>  // for string streams
#include <string>  // for string
#include <stack> 
#include <cmath>
  #pragma comment(linker, "/STACK:2000000")
#pragma comment(linker, "/HEAP:2000000")
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define rep(i,a,b) for(int i = a; i <=b; i++)
  #define rep2(i,a,b) for(int i = a; i>=b; i--)
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define db long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
  void printprecise(double l,int precision) 
  {
    std::cout << std::fixed;
    std::cout << std::setprecision(precision);
    std::cout << l;
}

  vector<int> primes;
  
int32_t main()
{

  


   int n,k;
   cin >> n >> k;
   int arr[n];
   int ans=0 ;
   
   rep(i,0,n-1)
   {
    cin >> arr[i];
    if(arr[i] >= k)
    {
      ans++;
    }
   }

   cout << ans;

    return 0;
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();
    let v = i.read_vec::<isize>(n);
    let c = i.read_vec::<isize>(n);

    writeln!(o, "{}", solve(n, &v, &c)).unwrap();
}
fn solve(n: usize, v: &[isize], c: &[isize]) -> isize {
    let mut ans = 0;
    for i in 0..n {
        if v[i] >= c[i] {
            ans += v[i] - c[i];
        }
    }
    ans
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


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

int main() {
	ll k;
	cin >> k;
	if (k%2 == 0) {
		cout << -1 << endl;
		return 0;
	}
	if (k%5 == 0) {
		cout << -1 << endl;
		return 0;
	}

	ll s = k;
	ll cnt = 0;
	while (1) {
		if (s == 7) {
			cnt++;
			break;
		} else if (s%10 == 7) {
			s /= 10;
			cnt++;
		} else {
			s += k;
		}
		if (cnt > 999982) {
			cnt  =-1;
			break;
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 3604