akhauriyash/Code-Regression huggingface dataset:
//😄😄😄😄😄😄😄😄😄😄😄😄😄
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define vp vector<pi>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define For(i,a,b) for(int i=a;i<b;i++)
#define debug(x) cout<<"DEBUG------> "<<x<<endl
#define endl "\n"
#define all(x) x.begin(),x.end()


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	char a; cin >> a;
	if (isupper(a)) {
		cout << "A";
	}
	else
		cout << "a";
	cout << endl;

	return 0;
}


Measured memory_bytes: 3684
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <list>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <cstring>
#include <cmath>
#include <string>
#define N 1005
#define INF (1 << 30)
typedef long long ll;
using namespace std;

int main()
{
	int weight[N];
	int sorted[N];
	int idx[40005];
	int n, x = INF, ans = 0;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", weight + i);
		sorted[i] = weight[i];
		if (x > weight[i])
			x = weight[i];
	}
	sort(sorted, sorted + n);
	for (int i = 0; i < n; ++i)
		idx[sorted[i]] = i;
	bool visited[N]{ false };
	for (int i = 0; i < n; ++i)
	{
		if (visited[i] || i == idx[weight[i]])
			continue;
		int Min = weight[i], num = 1, sum1 = weight[i];
		int j = i;
		while (true)
		{
			visited[j] = true;
			j = idx[weight[j]];
			if (visited[j])
				break;
			Min = min(Min, weight[j]);
			sum1 += weight[j];
			++num;
			
		}
		ans += min(Min + (num + 1) * x, (num - 2) * Min) + sum1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3248
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = sum(b)
x=-1
for i in a:
    if x+1==i:
        ans+=c[x-1]
    x = i
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;
int cnt[26];

int main(){
  int n;
  cin>>n;
  map<int,int>mp;
  for(int i=0;i<n;i++){
     int a;
     cin>>a;
     mp[a]++;
  }
  int h=0;
  int w=0;
  for(auto i:mp){
     if(i.second>=4){
        if(i.first>=h){
           if(i.first>=w){
              h=i.first;
              w=i.first;
           }
           else{
              h=i.first;
           }
        }
     }
     else if(i.second>=2 && i.second<4){
        if(i.first>=h){
           if(i.first>=w){
              h=w;
              w=i.first;
           }
           else{
              h=i.first;
           }
        }
     }
     else continue;
  }
  long long ans=0;
  ans=(long long)h*w;
  cout<<ans<<endl;

   
}

Measured memory_bytes: 4992
program EDPCE
    implicit none
    integer(8)::N,W,i,j,inf,vmax,dp(1000000,100),ans
    integer(8),allocatable,dimension(:)::wi,vi
    read*,N,W
    allocate(wi(N))
    allocate(vi(N))
    read(5,*)(wi(i),vi(i),i=1,N)

    inf=W+1000
    vmax=N*maxval(vi)
    ans=0

    do i=1,N
        do j=1,vmax
            if(i==1)then
                if(j<=vi(i))then
                    dp(j,i)=wi(i)
                    if(dp(j,i)<=W)ans=max(ans,j)
                else
                    dp(j,i)=inf
                end if
            else
                if(j<=vi(i))dp(j,i)=min(dp(j,i-1),Wi(i))
                if(j>vi(i))dp(j,i)=min(dp(j,i-1),dp(j-vi(i),i-1)+wi(i))
                if(dp(j,i)<=W)ans=max(ans,j)
            end if
        end do
    end do

    print'(i0)',ans
end program EDPCE

Measured memory_bytes: 285696
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
const int N=200005;
int n,t,a[N],b[N];
long long ans;
int pre(int i){
	return i>1?i-1:n;
}
int sub(int i){
	return i<n?i+1:1;
}
struct data{
	int x,v;
	bool operator < (const data &n) const{
		return v<n.v;
	}
};
priority_queue<data> q;
bool check(int x){
	return b[x]>a[x];
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
		if(a[i]>b[i]){
			puts("-1");
			return 0;
		}
	}
	for(int i=1;i<=n;i++){
		if(check(i)){
			q.push((data){i,b[i]});
		}
	}
	while(!q.empty()){
		int now=q.top().x;
		q.pop();
		t=(b[now]-a[now])/(b[pre(now)]+b[sub(now)]);
		if(!t){
			puts("-1");
			return 0;
		}
		ans+=t;
		b[now]-=t*(b[pre(now)]+b[sub(now)]);
		if(check(now)){
			q.push((data){now,b[now]});
		}
	}
	for(int i=1;i<=n;i++){
		if(a[i]!=b[i]){
			puts("-1");
			return 0;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

typedef long long int llint;

int main()
{
	llint length; cin >> length;
    vector <llint> vct (length);
    for (llint &i : vct) cin >> i;
    size_t ans = 0;
    for (llint i = 0 ; i <= vct.size() - 1 ; i++)
    {
        if (i && (vct[i] - vct[i - 1] > 1)) return printf("-1") && 0;
    };
    if (vct.front() != 0) return printf("-1") && 0;
    for (auto it = next(vct.begin()); it != vct.end(); ++it)
    {
        ans += (((*it - (*prev(it))) == 1) ? 1 : *it);
    };
    cout << ans;
}

Measured memory_bytes: 1920
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int64_t k;
	cin >> k;

	int64_t res = 0;
	for(int64_t a = 1; a <= k; a++) {
		for(int64_t b = 1; b <= k; b++) {
			for(int64_t c = 1; c <= k; c++) {
				int64_t g = __gcd(a, __gcd(b, c));
				res += g;
			}
		}
	}

	cout << res << '\n';
}

Measured memory_bytes: 3652
package main

import (
	"fmt"
	"sort"
)

func main() {

	var A,B,K int

	fmt.Scan(&A,&B,&K)

	max :=0

	if A<B{

		max = A

	}else{

		max = B
	}

	var result[] int

	for i:=1;i<=max;i++{

		if A%i==0 && B%i==0{

			result = append(result,i)
		}

	}

	sort.Sort(sort.IntSlice(result))

	index := len(result)-K

	fmt.Println(result[index])

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int ans = 0;
	function<void(long long)> Dfs = [&](long long v) {
		if (v != 0) {
			string tmp = to_string(v);
			if (tmp.find("3") != string::npos && tmp.find("5") != string::npos && tmp.find("7") != string::npos) ans++;
		}
		if (v * 10 + 3 <= n) Dfs(v * 10 + 3);
		if (v * 10 + 5 <= n) Dfs(v * 10 + 5);
		if (v * 10 + 7 <= n) Dfs(v * 10 + 7);
	};
	Dfs(0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3716
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, k := nextInt(), nextInt()
	s := next()

	ans := 0
	for i := 1; i < n; i++ {
		if s[i] == s[i-1] {
			ans++
		}
	}

	puts(min(ans+2*k, n-1))
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=1000005;
//i_am_noob
int n,a[maxn],fact_v2[maxn];
string str;
bool ans=false,flag=false;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> str;
	rep(n) a[i]=str[i]-'1';
	fact_v2[0]=0;
	rep2(i,1,maxn) fact_v2[i]=fact_v2[i-1]+__builtin_ctz(i);
	rep(n) if(a[i]==1){
		flag=true;
		ans^=(fact_v2[n-1]-fact_v2[i]-fact_v2[n-1-i]==0);
	}
	if(flag){
		print1(ans);
		return 0;
	}
	rep(n) if(a[i]==2) ans^=(fact_v2[n-1]-fact_v2[i]-fact_v2[n-1-i]==0);
	print1(ans*2);
	return 0;
}


Measured memory_bytes: 16924
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
typedef long long int lli; 
int main(void){
    // Here your code !
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    
    int ans = 0;
    int t = 0;
    for(int i = 0; i < s.size(); i++){
        if(t <= 0){
            t++;
            if(s[i] == 'p'){
                ans--;
            }
        }else{
            if(s[i] == 'p'){
                t--;
            }else{
                t--;
                ans++;
            }
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,x=1;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		if(x*2<x+k)x*=2;
		else x+=k;
	}
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

const int MAX = 202020;
const int MOD = 998244353;
ll fac[MAX], finv[MAX], inv[MAX];

void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a, ll n) {
	ll res = 1;
	a %= MOD;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

ll N, M, K;


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

	cin >> N >> M >> K;
	ll ans = 0;
	combinit();
	for (int i = 0; i <= K; i++) {
		ll tmp = M*modpow(M-1,N-i-1);
		tmp %= MOD;
		tmp *= comb(N-1,i);
		tmp %= MOD;
		ans += tmp;
		ans %= MOD;
	}
	puts(ans);
	
	return 0;
}

Measured memory_bytes: 8384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
vector<int> l(8,0);
int ans=1e9,n,a,b,c;

int dfs(int aa,int bb,int cc,int ad,int i){
  if(i==n){
    if(aa&&bb&&cc) ans=min(ans,abs(cc-c)+abs(bb-b)+abs(aa-a)+ad);
    return 0;
  }
  dfs(aa,bb,cc,ad,i+1);
  dfs(aa+l.at(i),bb,cc,(aa?ad+10:ad),i+1);
  dfs(aa,bb+l.at(i),cc,(bb?ad+10:ad),i+1);
  dfs(aa,bb,cc+l.at(i),(cc?ad+10:ad),i+1);
}

int main(){
  cin>>n>>a>>b>>c;
  REP(i,n) cin>>l.at(i);
  dfs(0,0,0,0,0);
  cout<<ans;
}

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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  cout << s + (s[(int)s.size() - 1] == 's' ? "es" : "s") << '\n';
  return 0;
}

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

int main(){
    long long N,A,B,t1,t2;
    cin>>N>>A>>B;

    int ans = 0;
    for(int i = 1 ; i <= N ;i++){
        t1 = 0;
        t2 = i;
        while(t2){
            t1 += t2%10;
            t2 /= 10;
        }
        if(A <= t1 && t1 <= B)
            ans+=i;
    }
    cout<<ans;
}

Measured memory_bytes: 256
r,c = map(int,input().split())
table1 = list()
table2 = list()
for i in range(r):
    table1.append(list(map(int,input().split())))
    table1[i].append(sum(table1[i]))
    print(" ".join(list(map(str,table1[i]))))
for j in range(c+1):
    sum = 0
    for i in range(r):
        sum += table1[i][j]
    table2.append(sum)
print(" ".join(list(map(str,table2))))


Measured memory_bytes: 5676
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>
#include<tuple>
#include<stack>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tpl;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 1500

const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {


	string a, b, c;
	cin >> a >> b >> c;
	reverse(a.begin(), a.end());
	reverse(b.begin(), b.end());
	reverse(c.begin(), c.end());
	int now = 0;
	while (true)
	{
		if (now == 0)
		{		
			if (a.size() == 0)
			{
				cout << 'A' << endl;
				return 0;
			}
			char ch = a.back();
			a.pop_back();
			now = ch - 'a';
		}
		else if (now == 1)
		{
			if (b.size() == 0)
			{
				cout << 'B' << endl;
				return 0;
			}
			else
			{
				char ch = b.back();
				b.pop_back();
				now = ch - 'a';
			}

		}
		else
		{
			if (c.size() == 0)
			{
				cout << 'C' << endl;
				return 0;
			}
			else
			{
				char ch = c.back();
				c.pop_back();
				now = ch - 'a';
			}
		}
	}
	
	


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;

// AtCoder
const i64 CYCLES_PER_SEC = 2800000000;

struct Timer {
	i64 start;
	Timer(){reset();}
	void reset(){start=getCycle();}
	inline double get(){return (double)(getCycle()-start)/CYCLES_PER_SEC;}
	inline i64 getCycle(){
		u32 low,high;
		__asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
		return ((i64)low)|((i64)high<<32);
	}
};

Timer timer;


uint32_t xor128(){
  static uint32_t x = 123456789;
  static uint32_t y = 362436069;
  static uint32_t z = 521288629;
  static uint32_t w = 88675123;
  uint32_t t = x ^ (x << 11);
  x = y; y = z; z = w;
  return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}

//INSERT ABOVE HERE
const int A = 26;
const int MAX_D = 365;
int cs[A+1];
int s[MAX_D+1][A+1];
int ts[MAX_D+1];

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

  int D;
  cin>>D;

  for(int j=1;j<=A;j++) cin>>cs[j];

  for(int i=1;i<=D;i++)
    for(int j=1;j<=A;j++)
      cin>>s[i][j];

  {
    vector<int> ls(A+1,0);
    for(int i=1;i<=D;i++){
      vector<int> ss(A+1,0);
      for(int j=1;j<=A;j++)
        ss[j]=s[i][j]+cs[j]*(i-ls[j]);
      ts[i]=max_element(ss.begin()+1,ss.end())-ss.begin();

      ls[ts[i]]=i;
    }
  }

  auto calcScore=[&]()->int{
    int res=0;
    vector<int> ls(A+1,0);
    for(int i=1;i<=D;i++){
      res+=s[i][ts[i]];
      ls[ts[i]]=i;
      for(int j=1;j<=A;j++)
        res-=cs[j]*(i-ls[j]);
    }
    return res;
  };

  int iter_num = 0;
  int tmpScore=calcScore();


  double start_temp = 2000, end_temp = 100;

  const double LIM = 2.0;
  while(timer.get()<LIM){
    iter_num++;
    int d=xor128()%D+1;
    int q=xor128()%A+1;

    int p=ts[d];
    ts[d]=q;

    int nxtScore=calcScore();

    double temp = start_temp + (end_temp - start_temp) * timer.get() / LIM;
    double prob = exp((nxtScore-tmpScore)/temp);

    const int INF = 1<<30;
    if(prob > (xor128()%INF)/(double)INF){
      tmpScore=nxtScore;
    }else{
      ts[d]=p;
    }
  }

  cerr<<iter_num<<endl;
  cerr<<tmpScore<<":"<<calcScore()<<endl;
  for(int i=1;i<=D;i++) cout<<ts[i]<<newl;
  return 0;
}


Measured memory_bytes: 4328
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
typedef long long LL;
typedef pair<double,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={0,0,1,1,1,-1,-1,-1};
int dy[]={1,-1,1,0,-1,1,0,-1};

vector<double> fact;
 
double combi(int n,int r){
    if(n<r||n<0||r<0) return 0;
    return fact[n]/fact[n-r]/fact[r];
}
 
 
void set_combi(){
    double s=1.0;
    fact.push_back(1.0);
    for(int i=1;i<=50;i++){
        s*=i;
        fact.push_back(s);
    }
}

double fpow(double a, int n){
    double x = 1;
    while(n > 0){
        if(n&1){
            x=x*a;
        }
        a=a*a;
        n >>= 1;
    }
    return x;
}

int main(){
    set_combi();
    int n,m,l;cin >> n >> m >> l;
    vector<LL> p(n),t(n),v(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i] >> t[i] >> v[i];
    }
    vector<vector<double>> d(n,vector<double>(m+1,0.0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= m; j++) {
            d[i][j] = combi(m,j) * fpow(p[i]/100.,j) * fpow((100-p[i])/100.,m-j);
        }
    }
    for (int i = 0; i < n; i++) {
        double ans = 0.0;
        for (int j = 0; j <= m; j++) {
            double pp = d[i][j];
            for (int k = 0; k < n; k++) {
                if(i==k) continue;
                double tmp = 0.0;
                for (int c = 0; c <= m; c++) {
                    if(c * t[k] * v[k] * v[i] + l * v[i] <= j * t[i] * v[k] * v[i] + l * v[k]) continue;
                    tmp += d[k][c];
                }
                pp *= tmp;
            }
            ans += pp;
        }
        cout << setprecision(30) << fixed << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3328
#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

class Vec2;

double SqrMagnitude(const Vec2& v);

double Magnitude(const Vec2& v);

double Dot(const Vec2& v1, const Vec2& v2);


struct Vec2 {
    double x, y;
    Vec2() = default;
    Vec2(double in_x, double in_y)
        : x {in_x}, y {in_y} {};
    Vec2(const Vec2&) = default;
    Vec2(Vec2&&) = default;

    Vec2 normalized() {
        double mag = Magnitude(*this);
        return {x /= mag, y /= mag};
    }

    Vec2 operator-() {
        return {-x, -y};
    }

    Vec2 operator+(const Vec2& rhs) {
        return {x + rhs.x, y + rhs.y};
    }

    Vec2 operator-(const Vec2& rhs) {
        return {x - rhs.x, y - rhs.y};
    }

    Vec2 operator*(double rhs) {
        return {x * rhs, y * rhs};
    }

    Vec2 operator/(double rhs) {
        return {x / rhs, y / rhs};
    }

    Vec2& operator+=(const Vec2& rhs) {
        x += rhs.x;
        y += rhs.y;
        return *this;
    }

    Vec2& operator-=(const Vec2& rhs) {
        x -= rhs.x;
        y -= rhs.y;
        return *this;
    }

    Vec2& operator*=(double rhs) {
        x *= rhs;
        y *= rhs;
        return *this;
    }

    Vec2& operator/=(double rhs) {
        x /= rhs;
        y /= rhs;
        return *this;
    }
};

inline Vec2 operator*(double s, const Vec2& v) {
    return {s * v.x, s * v.y};
}



inline double SqrMagnitude(const Vec2& v) {
    return Dot(v, v);
}

inline double Magnitude(const Vec2& v) {
    return sqrt(SqrMagnitude(v));
}

inline double Dot(const Vec2& v1, const Vec2& v2) {
    return v1.x * v2.x + v1.y * v2.y;
}

int main() {
    Vec2 p1, p2;
    cin >> p1.x >> p1.y >> p2.x >> p2.y;

    Vec2 p_12 {(p2 - p1).normalized()};

    int n;
    cin >> n;

    cout << fixed << setprecision(10);

    for(Vec2 q_in; cin >> q_in.x >> q_in.y;) {
        Vec2 v_p1_q = q_in - p1;
        Vec2 q_proj = p1 + p_12 * Dot(v_p1_q, p_12);

        Vec2 v_out = q_in + (q_proj - q_in) * 2;

        cout << v_out.x << ' ' << v_out.y << '\n';
    }

    return 0;
}

Measured memory_bytes: 3272
n = int(input())
x = []
y = []
ans = 0

for _ in range(n):
    a, b = map(int, input().split())
    x.append(a)
    y.append(b)

for i in range(n):
    for j in range(1, n-i):
        ans += ((x[i]-x[i+j])**2 + (y[i]-y[i+j])**2)**0.5
      
print(ans*2/n)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  vector<int>B(N);
  for(int i=0;i<N;i++){
    cin>>B.at(i);
  }
  int sum;
  int kotae=0;
  for(int i=0;i<N;i++){
    sum=0;
    for(int j=0;j<=i;j++){
      sum+=A.at(j);
    }
    for(int j=i;j<N;j++){
      sum+=B.at(j);
    }
    //cout<<sum<<endl;
    kotae=max(kotae,sum);
  }
  cout <<kotae<<endl;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI d(n);
  rep(i,n) cin >> d[i];
  sort(all(d));
  cout << d[n/2] - d[n/2 - 1] << endl;
  return 0;
}


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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, K; cin >> N >> K;
	if (K == 1) {
		cout << 0 << endl;
	} else {
		cout << N - K << endl;
	}

	return 0;
}


Measured memory_bytes: 256
package main

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

func newScanner() *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	return scanner
}

func scanInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func scanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}
	return a
}

func scanString() string {
	if sc.Scan() {
		return sc.Text()
	}
	panic(sc.Err())
}

var sc = newScanner()

func main() {
	n, m := scanInt(), scanInt()
	h := scanInts(n)
	t := make([]bool, n)
	for i := 0; i < n; i++ {
		t[i] = true
	}

	for i := 0; i < m; i++ {
		a, b := scanInt(), scanInt()
		a--
		b--
		if h[a] < h[b] {
			t[a] = false
		}else if h[a] > h[b] {
			t[b] = false
		} else {
			t[a], t[b] = false,false
		}
	}
	var ans int
	for i := 0; i < n; i++ {
		if t[i] {
			ans++
		}
	}

	fmt.Println(ans)
}

Measured memory_bytes: 5512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

const int inf = (int)1e9 + 7;

int main ()
{
    ios_base::sync_with_stdio (false);
    cin.tie (NULL);

    string s;

    cin >> s;

    int l = 0, r = s.size () - 1;

    int ans = 0;

    while (l < r)
    {
        if (s[l] == s[r])
        {
            l++;
            r--;
        }
        else if (s[l] == 'x')
        {
            l++;
            ans++;
        }
        else if (s[r] == 'x')
        {
            r--;
            ans++;
        }
        else
        {
            cout << -1 << endl;

            return 0;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;

	double ans = 0;
	rep(i, n) {
		int a;
		cin >> a;
		ans += 1.0 / a;
	}

	cout << fixed << setprecision(8);
	cout << 1 / ans << endl;

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    string n;
    int N;
    int k;
    cin >> n;
    cin >> k;
    N = n.size();//何桁あるか
    long long ans = 0;
    if(k == 1){
        ans += (N - 1) * 9;
        ans += (n.at(0) - '0');
        cout << ans << endl;
    }
    if(k == 2){
        for(int i = 1; i < N - 1; i++){
            ans += (9 * (i * 9));//1桁目は何か、2桁目をどこに入れるか、2桁目は何か
        }
        ans += (n.at(0) - '1') * (N - 1) * 9;
        bool ck = false;
        for(int i = 1; i < N; i++){
            if(!ck){
            ans += (n.at(i) - '0');  
                if(n.at(i) != '0'){
                    ck = true;
                }
            }
            else{
                ans += 9;
            }
        }
        if(ans < 0){
            ans = 0;
        }
        cout << ans << endl;
    }
    if(k == 3){
        for(int i = 2; i < N - 1; i++){
            ans += (i * (i - 1) * 9 * 9 * 9 / 2);//1桁目は何か、2桁目をどこに入れるか、2桁目は何か、3桁目をどこに入れるか、3桁目は何か
        }
        ans += (n.at(0) - '1') * (N - 1) * 9 * (N - 2) * 9 / 2;
        int M = N - 1;
        for(int j = 1; j < M; j++){
            if(n.at(j) == '0'){
                continue;
            }
        for(int i = 1; i < M - j; i++){
            ans += (9 * (i * 9));//1桁目は何か、2桁目をどこに入れるか、2桁目は何か
        }
        ans += (n.at(j) - '1') * (M - 1) * 9;
        bool ck = false;
        for(int i = j; i < M; i++){
            if(!ck){
            ans += (n.at(i + 1) - '0');  
                if(n.at(i + 1) != '0'){
                    ck = true;
                }
            }
            else{
                ans += 9;
            }
        }
        break;
        }
        if(ans < 0){
            ans = 0;
        }
        cout << ans << endl;

    }
    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int maxL = 0;
        int minR = Integer.MAX_VALUE;
        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            maxL = Math.max(maxL, sc.nextInt());
            minR = Math.min(minR, sc.nextInt());
        }

        System.out.println(Math.max(0, minR - maxL + 1));
    }
}

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

#define N 10000000

void maxHeapify(int*, int);
void buildMaxHeap(int*);
int heapExtractMax();
void maxHeapInsert(int);
void heapIncreaseKey(int, int);

unsigned int *A;
int num = 0;

int main(){
  char str[10];
  int i = 0;

  A = malloc(sizeof(int)*N+1);
  
  while(1){
    scanf("%s", str);
    if(strcmp(str, "insert") == 0){
      scanf("%d", &i);
      maxHeapInsert(i);
      //printf("insert %d done\n", i);
    }
    if(strcmp(str, "extract") == 0){
      printf("%d\n", heapExtractMax());
      // printf("done\n");
    }
    if(strcmp(str, "end") == 0){
      break;
    }
    /*
    for(i = 1; i <= num; i++){
      printf(" %d", A[i]);
    }
    printf("\n");
    */
  }
  return 0;
}

void maxHeapify(int* A, int i){
  int l, r, largest, temp;

  l = 2*i;
  r = 2*i+1;

  if (l <= num && A[l] > A[i]){
    largest = l;
  }
  else{
    largest = i;
  }

  if(r <= num && A[r] > A[largest]){
    largest = r;
  }

  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(A, largest);
  }
}

void buildMaxHeap(int *A){
  int i;
  
  for(i = num/2; i > 0; i--){
    maxHeapify(A, i);
  }
}

int heapExtractMax(){
  int max;
  
  if(num < 1){
    return -1;
  }
    max = A[1];
    A[1] = A[num];
    num--;
    maxHeapify(A,1);
    return max;
}

void maxHeapInsert(int key){
  int i;

  num++;
  A[num] = -2100000000;
  /*  
  printf("maxheapInsert\n");
  for(i = 1; i <= num; i++){
    printf(" %d", A[i]);
  }
  printf("\n");
  */
  
  heapIncreaseKey(num, key);
}

void heapIncreaseKey(int i, int key){
  int temp;
  
    A[i] = key;
    // printf("input %d\n", A[i]);
    while(i > 1 && A[i/2] < A[i]){
      temp = A[i];
      A[i] = A[i/2];
      A[i/2] = temp;
      
      i = i/2;
    }
    /*
      printf("maxIncreaseKey\n");
      for(i = 1; i <= num; i++){
      printf(" %d", A[i]);
      }
      printf("\n");
*/
}



Measured memory_bytes: 5584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

string s;
map<char, int> m;

int main() {
    cin >> s;
    for (int i = 0; i < s.length(); ++i)
        m[s[i]] = 1;
    if ((m['N']^m['S']) == 1)
        cout << "No\n";
    else if ((m['E']^m['W']) == 1)
        cout << "No\n";
    else
        cout << "Yes\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n;
    cin >> n;
    int v[n+1] = {};
    fore(i,1,n+1) {
        cin >> v[i];
        v[i] += v[i-1];
    }
    int mn = 1e9;
    fore(i,1,n) {
        int a = v[i];
        int b = v[n]-v[i];
        mn = min(mn, abs(b-a));
    }
    cout << mn << endl;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  while (true) {
    C -= B;
    if (C <= 0) break;
    A -= D;
    if (A <= 0) break;
  }

  if (C <= 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3652
# AOJ 0184 Tsuruga Castle
# Python3 2018.6.19 bal4u

while True:
	n = int(input())
	if n == 0: break
	f = [0]*7
	for i in range(n):
		a = int(input())
		if a >= 60: f[6] += 1
		else: f[a//10] += 1
	print(*f, sep='\n')


Measured memory_bytes: 5624
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define ii pair<int,int>
#define st first
#define nd second
#define N 200005
#define inf 1000000000
#define MOD 1000000007
#define sz(x) ((int)x.size())
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
using namespace std;

int dp[62][2][2][2];

int mul(int x,int y) {
	
	return (ll)x*y%MOD;

}

int add(int x,int y) {

	x+=y;

	if(x>=MOD) x-=MOD;
	if(x<0) x+=MOD;

	return x;

}

int solve(ll l,ll r) {

	dp[61][0][0][0]=1;

	for(int i=61;i>0;i--) {

		for(int a=0;a<2;a++) {

			for(int b=0;b<2;b++) {

				for(int c=0;c<2;c++) {

					// put 1,1

					if(a || (r>>(i-1))&1) 
						dp[i-1][a][b || !((l>>(i-1))&1)][1]=add(dp[i-1][a][b || !((l>>(i-1))&1)][1],dp[i][a][b][c]);

					// put 1,0

					if(c && (b || !((l>>(i-1))&1)) && (a || (r>>(i-1))&1))
						dp[i-1][a][b][c]=add(dp[i-1][a][b][c],dp[i][a][b][c]);

					// put 0,0 

					if((b || !((l>>(i-1))&1)))
						dp[i-1][(a || (r>>(i-1))&1)][b][c]=add(dp[i-1][(a || (r>>(i-1))&1)][b][c],dp[i][a][b][c]);

				}

			}

		}

	}

	int res=0;

	for(int a=0;a<2;a++) {

		for(int b=0;b<2;b++) {

			res=add(res,dp[0][a][b][1]);

		}

	}

	return res;

}

int main(int arg,char* argv[]) {

	ll l,r;

	cin>>l>>r;

	cout<<solve(l,r);

}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();

		List<Edge> edges = new ArrayList<>();
		long INF = Long.MAX_VALUE / 2;
		for(int i=0; i<M; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			long c = sc.nextLong();

			edges.add(new Edge(a, b, -c));
		}

		BF bf = new BF(N, edges, INF);
		long[] weights = bf.getMinWeightArray(1);
		long ans = weights[N-1];

		boolean[] negative = new boolean[N];
		Arrays.fill(negative, false);
		for(int i=0; i<N; i++) {
			for(int j=0; j<edges.size(); j++) {
				Edge e = edges.get(j);

				if(weights[e.from-1] == INF)
					continue;

				//すでに最短の重みの和になっているにもかかわらず、更新する場合負の閉路
				if(weights[e.to-1] > weights[e.from-1] + e.weight) {
					weights[e.to-1] = weights[e.from-1] + e.weight;
//					System.out.println("weights[" + (e.to-1) + "] = " + (weights[e.from-1] + e.weight));
					negative[e.to-1] = true;
				}

				//負の閉路を通ってたどり着ける
				if(negative[e.from-1]) {
					negative[e.to-1] = true;
				}
			}
		}

		if(negative[N-1]) {
			System.out.println("inf");
		}else {
			System.out.println(-ans);
		}

	}

	public static class BF{
		int V;
		List<Edge> edges;
		long[] weights;
		long INF;

		public BF(int V, List<Edge> e, long INF) {
			this.V = V;
			edges = e;
			weights = new long[V];
			this.INF = INF;
		}

		//負の辺ありの最短距離の重み(ベルマンフォード法)(O(VE))
		public long getMinWeight(int start, int goal) {
			Arrays.fill(weights, INF);
			weights[start-1] = 0;

			for(int i=0; i<V; i++) {
				for(int j=0; j<edges.size(); j++) {
					Edge e = edges.get(j);

					if(weights[e.from-1] == INF)
						continue;

					if(weights[e.to-1] > weights[e.from-1] + e.weight) {
						weights[e.to-1] = weights[e.from-1] + e.weight;

						//負の閉路判定(あるときINFを返す)
						if(i == V-1) {
							return INF;
						}
					}
				}
			}

			return weights[goal-1];
		}

		//負の辺ありの最短距離の重みの集合(ベルマンフォード法)(O(VE))
		public long[] getMinWeightArray(int start) {
			Arrays.fill(weights, INF);
			weights[start-1] = 0;

			for(int i=0; i<V-1; i++) {
				for(int j=0; j<edges.size(); j++) {
					Edge e = edges.get(j);

					if(weights[e.from-1] == INF)
						continue;

					if(weights[e.to-1] > weights[e.from-1] + e.weight) {
						weights[e.to-1] = weights[e.from-1] + e.weight;
//						System.out.println("weights[" + (e.to-1) + "] = " + (weights[e.from-1] + e.weight));

//						//負の閉路判定(あるときは空の配列を返す)
//						if(i == V-1) {
//							return new long[0];
//						}
					}
				}
			}

			return weights;
		}
	}

	//エッジを表すクラス(一般的なグラフのエッジとは異なる)
	public static class Edge{
		int from;
		int to;
		long weight;

		public Edge(int f, int t, long w) {
			from = f;
			to = t;
			weight = w;
		}
	}

}


Measured memory_bytes: 28356
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
	int n,a,x;
	cin>>n>>a;
	ll f[60][2600];
	memset(f,0,sizeof(f));
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		cin>>x;
		for(int j=i;j>0;j--){
			for(int k=x;k<=2500;k++){
				f[j][k]+=f[j-1][k-x];
			}
		}
	}
	ll ans=0;
	for(int i=1;i<=n;i++)	ans+=f[i][a*i];
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<vector<pair<int, int>>> V(N);
  for (int i = 0, a; cin >> a; i++)
    for (int j = 0, x, y; j < a && cin >> x >> y; j++) V.at(i).push_back({--x, y});

  int ans = 0;
  for (int bit = 0; bit < 1 << N; bit++) {
    for (int i = 0; i < N; i++) if (bit >> i & 1)
      for (auto v : V.at(i)) if (bit >> v.first & 1 ^ v.second) goto NG;
    ans = max(ans, __builtin_popcount(bit));
    NG:;
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
#include<map>
#include<cstdio>
#include<vector>

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

using namespace std;

template<class T>
class FenwickTree{
	vector<T> a;
public:
	FenwickTree(int n):a(n){}
	T sum(int i,int j)const{
		if(i==0){
			T s=0;
			for(;j>=0;j=(j&(j+1))-1) s+=a[j];
			return s;
		}
		return sum(0,j)-sum(0,i-1);
	}
	void add(int i,T v){
		for(;i<a.size();i|=i+1) a[i]+=v;
	}
};

int calc(int n,const FenwickTree<int> &ft,int x){
	int lo=0,hi=n-1;
	while(lo<hi){
		int mi=(lo+hi)/2;
		if(ft.sum(0,mi)<x) lo=mi+1; else hi=mi;
	}
	return lo;
}

int main(){
	for(int nq,lim;scanf("%d%d",&nq,&lim),nq;){
		int n=0,m=0;

		map<int,int> f;
		static int id[400000];

		FenwickTree<int> ft(nq);
		rep(_,nq){
			int q,x; scanf("%d%d",&q,&x);
			if(q==0){
				ft.add(m,1);
				f[x]=m;
				id[m]=x;
				m++;
				n++;
				if(n>lim){
					ft.add(calc(nq,ft,1),-1);
					n--;
				}
			}
			else if(q==1){
				ft.add(calc(nq,ft,x),-1);
				n--;
			}
			else if(q==2){
				printf("%d\n",id[calc(nq,ft,x)]);
			}
			else{
				ft.add(f[x],-1);
				n--;
			}
		}
		puts("end");
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int l,r,d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; i++)
    {
        if (i % d == 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;


int main() {
int N;
cin>>N;
int A[N];
rep(i,N){
  cin>>A[i];
}
ll sum,min_=10000000000000;
rep2(m,-100,101){
  sum=0;
  rep(i,N){
    sum+=(ll)powl(A[i]-m,2);
  }
  min_=min(min_,sum);

}
cout<<min_<<endl;
return 0;
}

Measured memory_bytes: 3604
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cmath>

using namespace std;

int main() {

	string str, s;
	long long a, b, r, count = 0, flag = 0, f = 0, n = 0,ct = 0;
	cin >> str >> a;

	r = str.size();

	str = str + str;

	for (int i = 0; i < str.size(); i++) {
		if (str[i] == str[i + 1]) {
			count++;
			i++;
		}
	}


	for (int i = 0; i < str.size(); i++) {
		if (str[i] == str[i + 1]) {
			ct++;
		}
	}

	if (ct == r * 2 - 1)n = 1;

	b = count;

	if (count % 2 == 1) {
		flag = 1;
		count++;
	}

	count = count / 2;


	if (n == 1) {
		cout << a * r / 2 << endl;
	}
	else if (flag == 0) {
		cout << count * a << endl;
	}
	else if (flag == 1) {
		cout << count * a - 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
#define fs first
#define sc second
#define mp make_pair
#define L(x) (1<<x)
#define next Next
#define index Index
using namespace std;
const int inf=1e9+10;
const ll llinf=1e17+10;
const int maxn=2e5+10;
const int maxm=1e6+10;
const int maxk=29;
const int mod=1e9+7;
int n;
int num[maxn];
int main()
{
    //freopen("in.txt","r",stdin);
    while (~scanf("%d",&n))
    {
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&num[i]);
        }
        num[0]=num[n+1]=0;
        int sum=0;
        for(int i=0;i<=n;i++)
        {
            sum+=abs(num[i]-num[i+1]);
        }
        for(int i=1;i<=n;i++)
        {
            int ans=sum-abs(num[i-1]-num[i])-abs(num[i]-num[i+1])+abs(num[i-1]-num[i+1]);
            printf("%d\n",ans);
        }
    }
    return 0;
}


Measured memory_bytes: 1664
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		for (;;) {
			int n = sc.nextInt();
			if (n == 0) {
				break;
			}
			int[] value = new int[n+1];
			value[0] = 0;
			for (int i = 1; i < n+1; i++) {
				value[i] = sc.nextInt() + value[i-1];
			}
			int max = -Integer.MAX_VALUE;
			for (int i = 0; i < n+1; i++) {
				for (int j = i+1; j < n+1; j++) {
					max = Math.max(value[j] - value[i], max);
				}
			}
			System.out.println(max);
		}
	}

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

Measured memory_bytes: 12000
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
typedef long long int ll;
typedef unsigned long long int ull;
int asc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){int x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}
int main(){
    int n,m;scanf("%d %d",&n,&m);
    int a[n],b[n];for(int i=0;i<n;i++)scanf("%d %d",&a[i],&b[i]);
    int c[m],d[m];for(int i=0;i<m;i++)scanf("%d %d",&c[i],&d[i]);

    int dest,min,index;
    for(int i=0;i<n;i++){
        min=999999999;
        for(int j=0;j<m;j++){
            dest=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(min>dest){
                min=dest;
                index=j+1;
            }
        }
        printf("%d\n",index);
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b;
	cin>>a>>b;
	for(int i=1;;i++)
	{
		a*=2;
		if(a>b)
		{
				cout<<i;
				return 0;}
	}
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <vector>
#include <climits>
 
int main() {
	// your code goes here
  int n,k;
  cin>>n>>k;
  vector<int> val(n+1 , 0);
  for(int i=1;i<=n;i++){
    cin>>val[i];
  }
  vector<int> dp(n+1 , 0);
  dp[1]=0;
  dp[2]=abs(val[1]-val[2]);
  
  for(int i=3;i<=n;i++){
  	dp[i]=INT_MAX;
  	for(int j=1;j<=k && i>=j+1;j++){
    dp[i]=min(dp[i-j]+abs(val[i]-val[i-j]),dp[i]);
  	}
  }
  cout<<dp[n]<<endl;
  return 0;
	
}


Measured memory_bytes: 3972
c = []
3.times{ c << gets.split.map(&:to_i) }

(0..100).any? do |a1|
  a = []
  b = []
  3.times do |n|
    b[n] = c[0][n] - a1
  end
  a[1] = c[1][0] - b[0]
  a[2] = c[2][0] - b[0]
  [1,2].all? { |i| [1,2].all? { |j| c[i][j] == a[i] + b[j] }}
end.tap { |ans| puts ans ? 'Yes' : 'No' }

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;

int main() {
  string S;
  cin >> S;
  
  if (S.at(3) == '7') S.at(3) = '8';
  
  cout << S << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;
using llong = long long;
const int MOD=1000000007;


int calc_sum(int a){
    int ret = 0;
    while (a != 0){
        ret += a % 10;
        a /= 10;
    }

    return ret;
}


int main(int argc, char**argv){
    int n;
    cin >> n;
    if (n % calc_sum(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}







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


int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < n-k; i++) {
        if (a.at(i) < a.at(i+k)) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 4816
x1, y1, x2, y2 = map(int, input().split())
a = abs(x1-x2)
b = abs(y1-y2)
if y2 - y1 >=0:
    if x2 - x1 >=0:
        x3 = x2 - b
        y3 = y2 + a
        x4 = x1 - b
        y4 = y1 + a
    else:
        x3 = x2 - b
        y3 = y2 - a
        x4 = x1 - b
        y4 = y1 - a
else:
    if x2 - x1 <=0:
        x3 = x2 + b
        y3 = y2 - a
        x4 = x1 + b
        y4 = y1 - a
    else:
        x3 = x2 + b
        y3 = y2 + a
        x4 = x1 + b
        y4 = y1 + a
print(x3, y3, x4, y4)

Measured memory_bytes: 3064
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int[] param = new int[n];
    
    for(int i=0 ; i<n ; i++){
      param[i] = sc.nextInt();
    }
    
    Arrays.sort(param);
    
    int count = 1;
    
    for(int i=1 ; i<n ; i++){
      if(param[i]>param[i-1]){
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int ind;
  for(int i=0;i<5;i++)
  {
    int c;
    cin>>c;
    if(c==0)
    {
      ind=i+1;
    }
  }
  cout<<ind;
  return 0;
}

Measured memory_bytes: 3620