akhauriyash/Code-Regression huggingface dataset:
type Matrix1 = [Int]
type Matrix2 = [Matrix1]

multiply :: Matrix2 -> Matrix1 -> Matrix1
multiply [] b = []
multiply (a:as) b = (calc a b):(multiply as b)
    where
        calc a b = sum $ map (\(a,b) -> a*b) $ zip a b

printMatrix :: Matrix1 -> IO ()
printMatrix = putStr.unlines.(map show)

addTail :: [a] -> a -> [a]
addTail a b = a ++ [b]

readA :: Int -> Int -> Matrix2 -> IO Matrix2
readA 0 _ a = return a
readA n m a = getLine >>= return.(map $ \n -> read n :: Int).words >>= (readA (n-1) m).(addTail a)

readB :: Int -> Matrix1 -> IO Matrix1
readB 0 b = return b
readB m b = getLine >>= return.(\n -> read n :: Int) >>= (readB (m-1)).(addTail b)

main :: IO ()
main = do
    [n, m] <- getLine >>= return.(map $ \n -> read n :: Int).words
    a <- readA n m []
    b <- readB m []
    printMatrix $ multiply a b



Measured memory_bytes: 7632
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<iomanip>
#include<string>
#include<math.h>
#define MOD 1000000007

using namespace std; 
long long l[90];
int main(){
    int n;
    cin>>n;
    l[0]=2;
    l[1]=1;
    for(int i=2;i<87;i++){
        l[i]=l[i-1]+l[i-2];
    }
    cout<<l[n]<<endl;

    return 0;
}


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

int main() {
    double a, b, h, m, x;
    cin >> a >> b >> h >> m;
    double c = 11.0/360.0*(60*h+m)*pi;
    x = pow((a * a + b * b - 2 * a * b * cos(c)),0.5);
    cout << fixed << setprecision(20) << x << endl;
    return 0;
}

Measured memory_bytes: 4316
N, M, L = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]
B = [list(map(int, input().split())) for i in range(M)]
C = [[0]*L for i in range(N)]
for i in range(N):
    for j in range(L):
        C[i][j] = str(sum(A[i][k]*B[k][j] for k in range(M)))
for line in C:
    print(*line)


Measured memory_bytes: 7276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

vec par(2e5+10);
map<ll,ll> si;
void init(ll n) {
  for(ll i=0;i<n;i++) {
    par[i]=i;
    si[i]++;
  }
}

ll root(ll x) {
  if(par[x]==x) {
    return x;
  }
  else {
    return par[x]=root(par[x]);
  }
}

ll size(ll x) {
  return si[root(x)];
}

bool same(ll x, ll y) {
  return root(x)==root(y);
}

void unite(ll x, ll y) {
  if(same(x,y)) return;
  ll temp=size(x);
  si[root(y)]+=temp;
  si[root(x)]=0;
  par[root(x)]=root(y);
}

int main() {
  ll n,m;
  cin >> n >> m;
  vec a(m),b(m);
  for(ll i=0;i<m;i++) {
    cin >> a[i] >> b[i];
    a[i]--,b[i]--;
  }
  init(n);
  for(ll i=0;i<m;i++) {
    unite(a[i],b[i]);
  }
  ll ans=1;
  for(ll i=0;i<n;i++) {
    ans=max(ans,size(i));
  }
  cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  vector<int> r(n);
  rep(i,n) r[i]=x[i];
  sort(r.begin(),r.end());
  for(int i=0;i<n;i++){
    if(x[i]<=r[(n/2)-1]) cout << r[n/2] << endl;
    else cout << r[(n/2)-1] << endl;
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, x[120], y[120], c[120];
vector<int> a[120];
pair<ll, ll> z;
void dfs(int x, int y, int d) {
	int s = 0;
	for (int i: a[x]) {
		if (i != y) {
			dfs(i, x, d + 1);
			s++;
		}
	}
	c[d] = max(c[d], s);
}
void upd() {
	ll u = 0, v = 1;
	while (c[u]) {
		v *= c[u++];
	}
	z = min(z, {u, v});
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf("%d%d", &x[i], &y[i]);
		a[x[i]].push_back(y[i]);
		a[y[i]].push_back(x[i]);
	}
	z = {n + 1, 0};
	for (int i = 1; i <= n; i++) {
		memset(c, 0, sizeof c);
		c[0] = 1;
		dfs(i, 0, 1);
		upd();
	}
	for (int i = 1; i < n; i++) {
		memset(c, 0, sizeof c);
		c[0] = 2;
		dfs(x[i], y[i], 1);
		dfs(y[i], x[i], 1);
		upd();
	}
	printf("%lld %lld\n", z.first, z.second);
	return 0;
}

Measured memory_bytes: 256
def counter(p):
    if p == 'A':
        return 1
    elif p == 'C':
        return 1
    elif p == 'G':
        return 1
    elif p == 'T':
        return 1
    else:
        return 0

count = 0
max_b = 0

S = input()
Sl = list(S)

for i in Sl:

    if counter(i) == 1:
        count += 1
    else:
        count = 0
    
    max_b = max(max_b,count)

print(max_b)

Measured memory_bytes: 3064
n = int(input())
if n == 1:
    print(1)
    exit()

l = list(range(1,n+1))
is_even=list(map(lambda x: x%2==0, l))
while is_even.count(True) > 1:
    l = list(map(lambda x: x/2, l))
    is_even=list(map(lambda x: x%2==0, l))

for i in range(n):
    if is_even[i]:
        print(i+1)


Measured memory_bytes: 3060
N = int(input())
l = [int(x) for x in input().split()] + [1000001]
l.sort()
ans = 0
t = 0
M = [False] * 10 ** 6
for i in range(N):
    if not M[l[i]-1]:
        if l[i] != l[i+1]:
            ans += 1
        t = l[i]
        while t <= 10 ** 6:
            M[t-1] = True
            t += l[i]
print(ans)

Measured memory_bytes: 32328
#include <cstdio>
#include <cstring>
#include <cmath>
#define PI 3.1415926535897932384626
using namespace std;
double a,b,n,m;
int main(void)
{
    scanf("%lf %lf %lf %lf",&a,&b,&n,&m);
    printf("%.15f\n",sqrt(a*a+b*b-2*a*b*cos(fabs(30*n-11*m/2)/180*PI)));
    return 0;
}


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

int main(){


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


	int answer;
	if(a<40){
		a=40;
	}
	if(b<40){
		b=40;
	}
	if(c<40){
		c=40;
	}
	if(d<40){
		d=40;
	}
	if(e<40){
		e=40;
	}
	answer=(a+b+c+d+e)/5;
	cout <<answer <<endl;





	/*
	int a,b,c,d,e; 
	cin >> a >> b >> c >> d >> e;
	int answer;


	if(a<0){
		answer=-a*c+e*b+d;
	      }

	if(a>0){
		answer=e*b-e*a;
	}
	cout << answer <<endl;
	*/

	return 0;
}



Measured memory_bytes: 3084
#include "bits/stdc++.h"
using namespace std;
int main() {
	int n, p;
	while (true) {
		cin >> n >> p;
		if (n == 0 && p == 0)break;
		vector<int> c(n, 0);
		int at = 0;
		int now = 0;
		while (true) {
			if (p != 0) {
				c[at]++; p--;
				if (c[at] == 1)now++;
				if (p == 0) {
					if (now == 1) {
						cout << at << endl;
						break;
					}
				}
			}
			else {
				p = c[at]; c[at] = 0;
				if (p != 0) now--;
			}
			at = (at + 1) % n;
		}
	}
}

Measured memory_bytes: 2960
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String s = sc.next();
			int i=0;
			int start=0;
			while(s.substring(i,i+1).compareTo(",")!=0)i++;
			int a = Integer.valueOf(s.substring(start,i));
			i++;
			start = i;
			while(s.substring(i,i+1).compareTo(",")!=0)i++;
			double b = Double.valueOf(s.substring(start,i));
			double c = Double.valueOf(s.substring(i+1,s.length()));
			
			if(b/(c*c)>=25){
				System.out.println(a);
			}
		}
			
	}
}

Measured memory_bytes: 17144
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	w := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&w[i])
	}
	d := make([]int, N-1)
	for i := 1; i < N; i++ {
		l := w[:i]
		r := w[i:]
		ls := sum(l)
		rs := sum(r)
		diff := ls - rs
		if diff < 0 {
			d[i-1] = -diff
			continue
		}
		d[i-1] = diff
	}
	sort.Sort(sort.IntSlice(d))
	fmt.Println(d[0])
}

func sum(a []int) int {
	var sum int
	for i := 0; i < len(a); i++ {
		sum += a[i]
	}
	return sum
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

vvi g;

ll memrec(ll i, vi &dp){
    if(dp[i] != -INF) return dp[i];
    ll ans = 0;
    for(auto NextNode: g[i]) chmax(ans, memrec(NextNode, dp)+1);
    return dp[i] = ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    ll n, m, ans = 0; cin >> n >> m;
    g.assign(n, vi(0));
    rep(i, m){
        ll x, y; cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
    }
    vi dp(n, -INF);
    for(ll i=0; i<n; i++) chmax(ans, memrec(i, dp));
    cout << ans << endl;
}

Measured memory_bytes: 8576
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
    ll n;
    cin >> n;
    /*ll n1 = n;
    for(int i = 16; i>0; i--)
    {
        if(n1 > s)
        {

            if(n % (ll)pow(26,i) == 0)
            {
                if(n == (ll)pow(26,i)) cout << "z";
                else
                {
                    char a = 'a' -2 + n / (ll)pow(26,i);
                    cout << a;
                }
                
            }
            else
            {
                char a = 'a' - 1 + n / (ll)pow(26,i);
                cout << a;
            }
            n %= (ll)pow(26,i);
        }
        else if(i == 0)
        {
            if(n % 26 == 0) cout << "z";
            else
            {
                char a = 'a' - 1 + n % 26;
                cout << a;
            }
        }
    }*/
    vector<char> v;
    int f = 1;
    while(f)
    {
        if(n<=26) f = 0;
        char a = 'a' - 1 + n%26;
        n /= 26;
        if(a < 'a')
        {
            a = 'z';
            n -= 1;
        }
        v.push_back(a);
    }
    int l = v.size();
    for (int i = l-1; i >= 0; i--) cout << v[i];
    cout <<"\n";
}


Measured memory_bytes: 3616
import math
n,m=map(int,raw_input().split())
a=[]
b=[]
for i in range(n):
	ia,ib=map(int,raw_input().split())
	a.append(ia)
	b.append(ib)
c=[]
d=[]
for i in range(m):
	ic,id=map(int,raw_input().split())
	c.append(ic)
	d.append(id)
for i in range(n):
	dist=10**9
	ans=0
	for j in range(m):
		ndist=abs(a[i]-c[j])+abs(b[i]-d[j])
		if ndist<dist:
			dist=ndist
			ans=j+1
	print ans


Measured memory_bytes: 2692
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
//#include <set>
//#include <map>
//#include <ctime>
//#include <cmath>
//#include <utility>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define ii InputInteger( );
#define f for(int i=0; i<n; i++)
int InputInteger( ){ int x; cin >> x; return x; }
const int Inf = 2147483647;
const char e = '\n';

void iv( vi& p ){ for( int& x: p ) cin >> x; }
void sa( vi& p ){ sort( p.begin(), p.end() ); }
void sd( vi& p ){ sort( p.begin(), p.end(), [](int a, int b){ return a > b; } ); }
void pv( const vi& p ){ for( int x: p ) cout << x << ' '; cout << e; }

int main()
{
	ios_base::sync_with_stdio( false );
	cin.tie( nullptr );
	string s;
	while( cin >> s )
	{
	    if(s == "Sunny") cout << "Cloudy";
	    else if(s == "Cloudy") cout << "Rainy";
	    else cout << "Sunny";
	    cout << e;
	}
	return 0;
}

// Kafe's Grandmaster Template 14th


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

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

    vector<int> r, g, b;
    rep(i,n){
        if(s[i] == 'R') r.emplace_back(i);
        else if(s[i] == 'G') g.emplace_back(i);
        else if(s[i] == 'B') b.emplace_back(i);
    }

    ll ans = (ll)r.size()*g.size()*b.size();
    for(int i=0;i<n-2;i++)for(int j=i+1;j<n-1; j++){
        if(j+j-i>=n) continue;
        if(s[i]==s[j]||s[i]==s[j+j-i]||s[j]==s[j+j-i])continue;
        else ans--;
    }

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

Measured memory_bytes: 3608
#include<iostream>
#include<math.h>
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<string.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 2005;
const int Mod=1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(a-b)-(a-b)/c*c<<endl;
    return 0;
}


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


int main()
{
    long H;
std::cin >> H;
    long keta=(double)std::log(H)/(double)std::log(2)+1;
    long sum=std::pow(2,keta)-1;
    std::cout << sum << std::endl;
    return 0;
}

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

int a, b, c;
string ans;

void in();
void solve();
void out();

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> a >> b >> c;
}

void solve(){
    int t = 0;
    if(a == b)
        t++;
    if(b == c)
        t++;
    if(a == c)
        t++;
    ans = "No";
    if(t == 1)
        ans = "Yes";
}

void out(){
    cout << ans;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long num = 1;
        long res = 0;
        while( h > 1) {
            res += num;
            num *= 2;
            h /= 2;
        }
        res += num;
        System.out.println(res);


    }

}


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

string s;
string res = "";

int main(){
  cin >> s;
  int n = s.size();
  rep(i, n){
    char a = s.at(i);
    if(a == '0'){
      res += '0';
    }else if(a == '1'){
      res += '1';
    }else if(a == 'B' && res.size() > 0){
      res = res.substr(0, res.size() - 1);
    }
  }
  cout << res << endl;
  return 0;
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int n;
string s;

const int mod=10007;

int dp[1001][8];

//a??\???,?????\???????????¶???b
int dfs(int a, int b)
{
    if(dp[a][b]>=0) return dp[a][b];

    if(a==n) return 1;

    //a??\????????¬??????
    int res=0;
    if(s[a]=='J') res=0;
    else if(s[a]=='O') res=1;
    else if(s[a]=='I') res=2;

    int ret=0;
    //????????\???????????¶????????????
    for(int i=1; i<=7; ++i)
    {
        //????????\?????¬????????????????????¨????????????
        //?????\??¨???????????§1????????????????????????(????????????)
        if((i>>res&1) && (b&i))
        {
            ret+=dfs(a+1,i);
            ret%=mod;
        }
    }

    return dp[a][b]=ret;
}

int main()
{
    cin >>n >>s;
    memset(dp,-1,sizeof(dp));
    cout << dfs(0,1) << endl;
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = 1e9;
const LL LLINF = 1e18;

void solve()
{
    int N; cin >> N;
    double sum = 0.0;
    vector<double> a(N);
    REP0(i, N)
    {
        cin >> a[i];
        sum += a[i];
    }

    int mean = round(sum/N);
    int ans = 0;
    REP0(i, N)
    {
        ans += (mean-a[i])*(mean-a[i]);
    }

    cout << ans << endl;

}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

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

int main(){
	double sum, a[10], n;

	while( scanf("%lf" , &n ) != EOF ){
		sum = n;
		a[0] = n;
		for(int i=1 ; i<10 ; ++i){
			a[i] = ( i%2 )? a[i-1]*2.0 : a[i-1]/3.0 ;
			sum += a[i];
		}
		printf("%.8f\n", sum);
	}
}

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

int main(void){
    int x,n;
    cin >> x >> n;
    vector<bool> is_p(101);
    rep(i,n) {
        int p;
        cin >> p;
        is_p[p] = true;
    }
    int res = -1;
    rep(i,102) {
        if (abs(x-i) < abs(res-x) && !is_p[i]) {
            res = i;
        }
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;

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; }

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

  ll sum = 0;
  for(int i=0; i<N; i++)
    {
      sum+=W[i];
    }

  ll tmp=0;
  for(int i=0; i<N; i++)
    {
      tmp+=W[i];
      if(tmp>sum/2)
	{
	  if(abs(tmp-(sum-tmp))>abs(tmp-W[i]-(sum+W[i]-tmp)))
	    tmp-=W[i];
	  
	  break;
	}
      
    }

  cout << abs(tmp-(sum-tmp)) << endl;
  
  
  
  

  return 0;
}


//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds; 
using namespace std;
#define int long long
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define mii map<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,b) for(ll (i)=0;i<(b);i++)
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define CLR(p) memset(p, 0, sizeof(p))
#define SET(p) memset(p, -1, sizeof(p))
#define DEBUG true
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
//typedef long long int ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> new_data_set; 
const int MAX=1e6+5;
#define MOD 1000000007
/*std::cout << std::fixed;
std::cout << std::setprecision(6);*/
//(a%mod-b%mod+mod)%mod



/************************************


 
*************************************/

vector<vector<ll>>v;
ll T=0;
ll cnt1=0,cnt0=0;
vector<ll>dep;
bool visited[MAX];
vector<ll>par;
vector<ll>tin,tout;
vector<ll>col;

int countDivisibles(int A, int B, int M) 
{ 
    
    if (A % M == 0) 
        return (B / M) - (A / M) + 1; 
  
    // A is not divisible by M 
    return (B / M) - (A / M); 
} 







signed main(){
    int t=1;
    // cin>>t;
    while(t--){
        int n;
        cin>>n;
        int a[n];
        int ans=0;
        mll m;
        rep(i,n){
            cin>>a[i];
            m[i+a[i]]++;
        }
        // for(auto it:m){
        //     cout<<it.F<<" "<<it.S<<" ## ";
        // }
        // cout<<endl;
        rep(i,n){
            // cout<<-i-a[i]<<" !! ";
            ans+=m[-a[i]+i];
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 27924
<?php
$n = explode(" ", trim(fgets(STDIN)));

$min = $n[1] - ($n[0] - 1);
$max =  $n[1] + ($n[0] - 1);

$answer = [];
for($i = $min; $i <= $max; $i++) {
    if($i >= -1000000 || $i <= 1000000) {
        array_push($answer, $i);
    }
}
echo implode(" ", $answer);

Measured memory_bytes: 3828
readints = lambda: list(map(int, input().split()))
n, m, k = readints()
a = readints()
b = readints()
a.insert(0, 0)
b.insert(0, 0)

ans = 0

j = m
tot = sum(b)
for i in range(n + 1):
  tot += a[i]
  while j >= 0 and tot > k:
    tot -= b[j]
    j -= 1
  if j < 0:
    break
  ans = max(ans, i + j)

print (ans)


Measured memory_bytes: 111176
package main

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

var (
	rdr   = bufio.NewReaderSize(os.Stdin, 1000000)
	reply string
)

func main() {
	in := nextSlice()
	solve(in)
}

func solve(buf []string) {
	var (
		a, _ = strconv.Atoi(buf[0])
		b, _ = strconv.Atoi(buf[1])
	)
	yesOrNo(a == b)
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

// ---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

// ---------------------------------------------------

func yesOrNo(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

func yesorNO(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

Measured memory_bytes: 640
n = int(input())
A = list(map(int, input().split()))
cnt = 0
i = 0
flag = 1
while flag:
    flag = 0
    for j in range(n-1,i,-1):
        if A[j] < A[j-1]:
            buff = A[j-1]
            A[j-1]=A[j]
            A[j] = buff
            flag = 1
            cnt += 1
    i += 1
for k in range(n):
    if k != n-1:
        print(A[k],"",end="")
    else:
        print(A[k])
print(cnt)


Measured memory_bytes: 5616
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

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

	int n;
	cin >> n;

	int a[n];
	set<int> rate;
	int tmp,num=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(tmp=a[i]/400,tmp<8) rate.insert(tmp);
		else					num++;
	}
	cout << (rate.size()==0?1:rate.size()) << " " << rate.size() + num << "\n";

	return 0;
}

Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    ld pi = acos(-1);
    cin >> n;
    cout << fixed << setprecision(9) << 2 * pi * n;
    return 0;
}


Measured memory_bytes: 3804
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long ans = 1;
    for(int i = 2; i <= N; i++) {
      if(isPrime(i)) {
        long power = 0;
        for(int j = 1; j < 10; j++) {
          if(N >= Math.pow(i, j)) {
            power += (long)(N / Math.pow(i, j));
          } else {
            break;
          }
        }
        ans = (ans * (power + 1)) % 1000000007;
      }
    }
    System.out.println(ans);
  }

  public static boolean isPrime(int n) {
    boolean flg = true;
    for(int i = 2; i <= Math.sqrt(n); i++) {
      if(n % i == 0) flg = false;
    }
    return flg;
  }
}

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

#define llint long long int
#define MOD 1000000007

using namespace std;

// a^n (mod p)
llint mod_pow(llint a, llint n, llint p)
{
    if (n == 0)
    {
        return 1;
    }
    else if (n % 2 == 0)
    {
        llint d = mod_pow(a, n / 2, p);

        return (d * d) % p;
    }
    else
    {
        return (a * mod_pow(a, n - 1, p)) % p;
    }
}
llint mod_inv(llint a, llint p)
{
    return mod_pow(a, p - 2, p);
}
int main()
{
    int N;

    cin >> N;

    llint sum1 = 0;
    llint sum2 = 0;

    for (int i = 0; i < N; i++)
    {
        llint A;

        cin >> A;

        sum1 = (sum1 + A) % MOD;
        sum2 = (sum2 + (A * A) % MOD) % MOD;
    }
    cout << ((((sum1 * sum1) % MOD - sum2 + MOD) % MOD) * mod_inv(2, MOD)) % MOD << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
//#include<fstream>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

/*ofstream fout("bcount.out");
ifstream fin("bcount.in");*/

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
    string s,t;
    cin>>s>>t;
    ll ans = 0;
    int n = (int)s.length();
    rep(i,0,n)
        ans += s[i] != t[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3768
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	lint a, b, k;
	cin >> a >> b >> k;

	cout << max(a - k, 0LL) << " ";
	cout << max(b - max(k - a, 0LL), 0LL) << "\n";

	return 0;
}

Measured memory_bytes: 256
const MAX_N: usize = 600;
const MAX_M: usize = MAX_N * MAX_N / 2;
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut edges = vec![vec![]; MAX_M];
    for _ in 0..m {
        let s: usize = sc.read::<usize>() - 1;
        let t: usize = sc.read::<usize>() - 1;
        edges[s].push(t);
    }
    let mut result = 1e10;
    for i in (0..n - 1).rev() {
        let mut dp = vec![1e10; n];
        dp[n - 1] = 0.0;
        for j in (0..n - 1).rev() {
            let mut sum = 0.0;
            let mut max_value = 0.0;
            for &x in edges[j].iter() {
                sum += (1.0 + dp[x]);
                assert!(j < x);
                // println!("x: {}", x);
                if max_value < 1.0 + dp[x] {
                    max_value = 1.0 + dp[x];
                }
            }
            let b = edges[j].len() as f32;
            //println!("{}", b);
            dp[j] = sum / b;
            if i == j && edges[j].len() > 1 {
                let tmp = (sum - max_value) / (b - 1.0);
                if dp[j] > tmp {
                    dp[j] = tmp;
                }
            }
            //println!("i: {}, j: {}, dp[{}]: {}, sum: {}", i, j, j, dp[j], sum);
        }
        if result > dp[0] {
            result = dp[0];
        }
    }
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 16764
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int dx[] ={ 0,1,0,-1};
const int dy[] ={-1,0,1, 0};

int main(){
	int n;
	while(cin >> n , n){
		long double dp[16][5][5] = {{{0.0}}};
		char map[5][5];
		rep(i,5)rep(j,5)map[i][j] = 'X';
		rep(i,3)rep(j,3)map[i+1][j+1] = ' ';
		int sx, sy , gx, gy ,bx , by;
		char s,t,b;
		cin >> s >> t >> b ;
		sy = (s-'A')/3 +1 ,sx = (s-'A')%3 +1;
		gy = (t-'A')/3 +1 ,gx = (t-'A')%3 +1;
		by = (b-'A')/3 +1 ,bx = (b-'A')%3 +1;
		
		map[by][bx] = 'X';
		dp[n][sy][sx] = 1.0;
		
		while(n){
			for(int y=1;y<=3;y++){
				for(int x=1;x<=3;x++){
					rep(i,4){
						int tx = x+dx[i], ty = y+dy[i] ;
						if(map[ty][tx] == 'X')ty = y , tx = x;
						dp[n-1][ty][tx] += dp[n][y][x] / 4.0;
					}
				}
			}
			n--;
		}
		printf("%.8Lf\n",dp[0][gy][gx]);
	}
}
	

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  ll n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> b(n, 0);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  int loc = 0;
  int f = 0, g = 0;
  for(int i = 0; i <= n; i++) {
    b[a[loc]]++;
    if(b[a[loc]] == 2){
      f = i + 1;
      g = loc;
      break;
    }
    loc = a[loc];
  }
  if(k <= f) {
   	loc = 0;
    for(int i = 0; i < k - 1; i++) {
      loc = a[loc];
      b[loc]++;
    }
    cout << a[loc] + 1 << endl;
  } else {
    k -= f;
    vector<int> c(n, 0);
    vector<int> road(n, 0);
    for(int i = 0; i < n; i++) {
      loc = a[loc];
      road[i] = loc;
      c[loc]++;
      if(c[loc] == 2){
        f = i;
        g = loc;
        break;
      }
    }
    k %= f;
    cout << road[k] + 1 << endl;
  }

  return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> P, Q;
    int tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        P.emplace_back(tmp);
    }
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        Q.emplace_back(tmp);
    }
    
    int cnt = 0;
    if (lexicographical_compare(P.begin(), P.end(), Q.begin(), Q.end()))
    {
        while (P != Q)
        {
            cnt += 1;
            next_permutation(P.begin(), P.end());
        }
        
    }else
    {
        if (P == Q)
        {
            cout << "0" << endl;
            return 0;
        }
        
        while (Q != P)
        {
            cnt += 1;
            next_permutation(Q.begin(), Q.end());
        }

    }

    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int n, k;
int x[100010];

void input(){
    cin >> n >> k;
    for(int i=0;i<n;i++) cin >> x[i];    
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    int ans = INF;
    for(int i=0;i<n-k+1;i++){
        if(abs(x[i]) >= abs(x[i+k-1])){
            ans = min(ans, abs(x[i+k-1])+abs(x[i] - x[i+k-1]));
        }
        else{
            ans = min(ans, abs(x[i])+abs(x[i] - x[i+k-1]));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
n = int(input())
A = []
B = []
for _ in range(n):
    a, b = tuple(map(int, input().split()))
    A.append(a)
    B.append(b)

A = sorted(A)
B = sorted(B)

if n%2==1:
    sa = A[n//2]
    lb = B[n//2]
    print(lb - sa + 1)
else:
    sal = A[n//2-1]
    sar = A[n//2]

    lbl = B[n//2-1]
    lbr = B[n//2]
    print((lbl + lbr) - (sal + sar) +1)


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

vector<bool> a(10001, true);

int main()
{
    a[0] = a[1] = false;
    for (int i = 2; i * i < a.size(); ++i) {
        for (int j = 2 * i; j < a.size(); j += i)
            a[j] = false;
    }

    int n;
    while (cin >> n) {
        int c = 0;
        for (int i = 1; i <= n; ++i)
            if (a[i] && a[n-i+1]) c++;
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  int n, i;
  int min = 1000000;
  int max = -1000000;
  long sum = 0;
  cin >> n;
  while (n > 0) {
    cin >> i;
    if (i < min) min = i;
    if (i > max) max = i;
    sum += i;
    n--;
  }
  printf("%d %d %ld\n", min, max, sum);
  return 0;
}

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

typedef long long int ll;
#define T int t,q; scanf("%d",&t); for(q=1;q<=t;q++)

int main(){

	string s;
	ll k;
	cin >> k;
	cin >> s;
	ll n=s.length();
	ll f=0;
	for(int i=0;i<n;i++){
	if(i>=k){f=1;break;}
	else cout << s[i];	
	}
	if(f)cout << "...";
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 3636
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n,m,a,b;
  cin>>n>>m>>a>>b;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  stack<int> st;
  for(int x:v){
    if(x<a) break;
    st.push(x);
  }
  if(n-st.size()<m)  while(st.size() && st.top()<=b) st.pop();
  cout<<st.size()<<endl;
  return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
const ll inf=1e8;
int main(void){
    ll h,n;
    cin>>h>>n;
    ll a[n],b[n];
    rep(0,i,n){
        cin>>a[i]>>b[i];
    }
    ll dp[h+1];
    dp[0]=0;
    rep(0,i,h)dp[i+1]=inf;
    rep(0,i,h){
        rep(0,j,n){
            ll x=i+a[j],y=b[j];
            x=min(h,x);
            dp[x]=min(dp[i]+y,dp[x]);
        }
    }
    cout<<dp[h]<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
//char a[55][55];
int dx[] = {1,0,-1,0,1,1,-1,-1};
int dy[] = {0,1,0,-1,1,-1,-1,1};
int main()
{
	dhoom;
	char x , y;
	cin >> x >> y;
	if(x > y)	
		cout << ">" << endl;
	else if(y>x)
		cout << "<" << endl;
  	else
      	cout << "=" <<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int ia = sc.nextInt();
		int ib = sc.nextInt();
		int ic = sc.nextInt();
		if(ia==ib){
			System.out.println(ic);
		}
		else if(ia==ic){
			System.out.println(ib);
		}
		else{
			System.out.println(ia);
		}
    }
}


Measured memory_bytes: 22868
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int sum = scanner.nextInt();
		int count = 0;
		
		int i = 0 , j = 0 , k = 0; 
		for(i = 0; i<=n ; i++){
			for(j = 0 ; j<=n ; j++){
				for(k = 0 ; k<=n ; k++){
					if(i+j+k<=sum){
						k = Math.min(n, sum-i-j);
						if(i+j+k<=sum){
							j = Math.min(n, sum-i-k);
							if(i+j+k<=sum){
								i = Math.min(n, sum-j-k);
							}
						}
					}else{
						break;
					}
					
					if( (i+j+k)==sum ) count++;
					//System.out.println("i="+i+" ,j="+j+" ,k="+k+" ,count="+count);
				}
			}
		}
		
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K;
	cin >> N >> K;
	VI H(N);
	REP(i, N)cin >> H[i];
	rSORT(H);
	int ans = 0;

	FOR(i, K, N)ans += H[i];
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 1792
primes = [0, 0] + [1] * 999999
for i in range(2, 1000):
    if primes[i]:
        for j in range(i*i, 1000000, i):
            primes[j] = 0

answer = [0] * 1000000
for i in range(2, 1000000):
    answer[i] += primes[i] + answer[i-1]

while True:
    try:
        n = int(input())
    except:
        break
    print(answer[n])



Measured memory_bytes: 52708
import math

N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

minABCDE = min(A,B,C,D,E)

print(N // minABCDE + math.ceil((N % minABCDE) / minABCDE) + 4)


Measured memory_bytes: 3060
import sys
from math import atan, degrees

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    a, b, x = map(int, readline().split())

    if x > a * a * b / 2:
        ans = atan(2 * (a * a * b - x) / (a ** 3))
    else:
        ans = atan(a * b * b / (2 * x))

    print(degrees(ans))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9256
//Running median
//keeping max heap for first half and min heap for second half
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n"
# define M_PI           3.14159265358979323846
ll  P=1000000007;
ll M=P;
ll power(ll a, ll b) {
    if(b == 0) return 1;
    ll x = power(a, b / 2);
    x = (x * x)%M;
    if(b%2) x = (x*a)%M;
    return x;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i,j,k,l,m,n,o,p,q,r,s,t;
    cin>>n;
    long double x=(n);
    x=(2*x*M_PI);
    cout<<fixed<<x<<endl;
    return 0;
}


Measured memory_bytes: 3784
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int cmp(const void *a,const void *b)
{
    return *(int *)a-*(int *)b;
}
int a[200500];
int t[200500];
int d[200500];
/*void quicksort(int *a,int l,int r)
{
    int i,j,t,temp;
    if(l>=r)
       return;

    temp=a[l];
    i=l;
    j=r;
    while(i!=j)
    {
        while(a[j]>=temp && i<j) j--;
        while(a[i]<=temp && i<j) i++;
        if(i<j)
        {
            t=a[i];
            a[i]=a[j];
            a[j]=t;
        }
    }
    a[l]=a[i];
    a[i]=temp;
    quicksort(a,l,i-1);
    quicksort(a,i+1,r);
}*/
int main (void)
{
    int n,k;
    scanf("%d%d",&n,&k);
    if(n==1)
    {
        printf("0\n");
        return 0;
    }
    memset(t,0,sizeof(t));
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        t[a[i]]++;
    }
    memset(d,0,sizeof(d));
    int num = 0;
    for(int i=1;i<=n;i++)
    {
        if(t[i])
            d[++num] = t[i];
    }
    qsort(d+1,num,sizeof d[0],cmp);
    int p = num - k;
    if(p<1)
    {
        printf("0\n");
        return 0;
    }
    int sum = 0;
    for(int i=1;i<=p;i++)
        sum+=d[i];
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 2940
#include <iostream>
#include <string>
int main(){
std::string S;
int n;

std::cin >> S;

if(S=="000")
std::cout << "0" << std::endl;

else if(S=="100"||S=="010"||S=="001")
std::cout << "1" << std::endl;

else if(S=="111")
std::cout << "3" << std::endl;

else
std::cout << "2" << std::endl;
}

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

int main() {
  int A1, A2, A3;
  scanf("%d%d%d", &A1, &A2, &A3);
  printf("%d", max({A1, A2, A3}) - min({A1, A2, A3}));
  return 0;
}


Measured memory_bytes: 256
class Node:
    def __init__(self, parent=-1, left=-1, right=-1):
        self.parent = parent
        self.left = left
        self.right = right


def preParse(u):
    """先行順巡回"""
    if u == -1:
        return
    print(" {}".format(u), end="")
    preParse(Nodes[u].left)
    preParse(Nodes[u].right)


def inParse(u):
    """中間順巡回"""
    if u == -1:
        return
    inParse(Nodes[u].left)
    print(" {}".format(u), end="")
    inParse(Nodes[u].right)


def postParse(u):
    """後行順巡回"""
    if u == -1:
        return
    postParse(Nodes[u].left)
    postParse(Nodes[u].right)
    print(" {}".format(u), end="")


n = int(input())
Nodes = []
for i in range(n):
    Nodes.append(Node())

for i in range(n):
    tmp = [int(_) for _ in input().split()]
    Nodes[tmp[0]].left = tmp[1]
    Nodes[tmp[0]].right = tmp[2]
    if tmp[1] != -1:
        Nodes[tmp[1]].parent = tmp[0]
    if tmp[2] != -1:
        Nodes[tmp[2]].parent = tmp[0]

# for i in range(n):
#     print(i, Nodes[i].parent, Nodes[i].left, Nodes[i].right)
# exit()
# root = -11
for i in range(n):
    if Nodes[i].parent == -1:
        root = i
        break

print("Preorder")
preParse(root)
print("")
print("Inorder")
inParse(root)
print("")
print("Postorder")
postParse(root)
print("")



Measured memory_bytes: 5616