akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

N, K = [int(x) for x in input().strip().split()]
ans = 0
for n in range(1, N + 1):
  ans_ = 1 / N
  score = n
  while score < K:
    ans_ *= 1 / 2
    score *= 2
  ans += ans_
else:
  print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();

        int num = Integer.valueOf(line).intValue();
        line = sc.nextLine();

        int i = 0;
        double db = 0.0;
        while(i != num){
            String[] input = line.split(" ", 0);
            db += 1.0/Double.parseDouble(input[i]);
          i++;
        }
        System.out.println(1.0/db);   
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
	long long h, cnt=1;
	cin >> h;

	long long ans = 0;
	while(h>1){
		h /= 2;
		cnt++;
	}
	for(int i=0;i<cnt;i++){
		ans += pow(2.0, i);
	}
	cout << ans << endl;
}

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

int main(){
  string a;
  cin >> a;
  int n=a.length();
  int r=0;
  char x;
  
  for(int i=0;i<n;i++){
   x=a[i];
    
    if(x=='1'){
    	r++;
    }
  }
  cout << r;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

template<ll LOG=60>
struct doubling {
    // nxt[i][j] = (j番目の要素に関数fを2^i回適用した要素は何番目の要素か)
    vector<vector<ll>> nxt; 
    doubling(vector<ll> nxt0) : nxt(LOG, vector<ll>(nxt0.size())) {
        REP(i, nxt0.size()) nxt[0][i] = nxt0[i];
        FOR(k, 1, LOG) REP(j, nxt0.size()) nxt[k][j] = nxt[k-1][nxt[k-1][j]];
    }
    // x番目の要素に関数fをk回適用した要素は何番目の要素か？
    ll query(ll x, ll k) {
        for(ll i=LOG-1; i>=0; --i) if(k&1LL<<i) x = nxt[i][x];
        return x;
    }
};

int main() {
    ll n;
    cin >> n;
    vector<ll> x(n);
    REP(i, n) cin >> x[i];
    ll l;
    cin >> l;

    // x[j] <= x[idx] + l であるような最大のj に移動できる
    vector<ll> nxt0(n);
    REP(i, n) nxt0[i] = upper_bound(ALL(x), x[i]+l) - x.begin() - 1;
    doubling<60> dbl(nxt0);

    ll q;
    cin >> q;
    while(q--) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        if(a > b) swap(a, b);

        ll ret = 0;
        for(ll i=59; i>=0; --i) {
            if(dbl.nxt[i][a] < b) {
                ret += 1LL<<i;
                a = dbl.nxt[i][a];
            }
            if(dbl.nxt[0][a] >= b) {
                ret++;
                break;
            } 
        }
        cout << ret << endl;
    }

    return 0;
}


Measured memory_bytes: 50432
#include <iostream>
#include <vector>
#include <cmath>

bool isPrime(int n)
{
	if (n < 2)
		return false;
	if (n == 2)
		return true;
	if (n % 2 == 0)
		return false;

	const int v = std::sqrt(n);
	for (int i = 3; i <= v; i += 2)
	{
		if ( n % i == 0 )
			return false;
	}
	return true;
}


int main(int argc, char* argv[])
{
	int n = 0;
	std::cin >> n;
	std::vector<int> list(n);
	for (int i = 0; i < n; ++i)
		std::cin >> list[i];

	int cnt = 0;
	for (int i = 0; i < n; ++i)
	{
		bool prime = true;
		prime = isPrime(list[i]);
		if (prime)
			++cnt;
	}

	std::cout << cnt << std::endl;

	return 0;
}

Measured memory_bytes: 3076
x = input().split()
H = int(x[0])
N = int(x[1])
A = input().split()
A = [int(l) for l in A]
T = "No"
for i in range(N):
    H = H - A[i]
    if H <= 0:
        T = "Yes"
        break
print(T)

Measured memory_bytes: 13964
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

for num in b:
  for x in range(3):
    for y in range(3):
      if a[x][y] == num:
        a[x][y] = 0

if sum(a[0]) == 0 or sum(a[1]) == 0 or sum(a[2]) == 0:
  print("Yes")
elif sum([a[0][0],a[1][1],a[2][2]]) == 0 or sum([a[2][0],a[1][1],a[0][2]]) == 0:
  print("Yes")
elif sum([a[0][0],a[1][0],a[2][0]]) == 0 or sum([a[0][1],a[1][1],a[2][1]]) == 0 or sum([a[0][2],a[1][2],a[2][2]]) == 0:
  print("Yes")                                                 
else:
  print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;



int main(int argc, char *argv[])
{
	int n, m;
	int ans;

	//input
	cin >> n >> m;

	int max_l = 1;
	int min_r = n;
	for (int i = 0; i < m; i++){
		int l, r;

		cin >> l >> r;

		if (max_l < l){
			max_l = l;
		}
		if (r < min_r){
			min_r = r;
		}
	}

	//calc
	ans = min_r - max_l + 1;
	if (ans < 0){
		ans = 0;
	}


	//ans
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
//#include <string.h>

int main() {
    int n, b, f, ro, v, value;
    int r[120];

    for (int k = 0; k < 120; ++k) {
        r[k] = 0;
    }

    scanf("%d\n", &n);

    for (int i = 0; i < n; ++i) {
        if (i == n-1)
            scanf("%d %d %d %d", &b, &f, &ro, &v);
        else
            scanf("%d %d %d %d\n", &b, &f, &ro, &v);

        value = ((b-1) * 30) + ((f-1) * 10) + ro;
        r[value - 1] += v;
    }

    for (int j = 0; j < 120; ++j) {
        printf(" %d", r[j]);

        if ((j+1) % 10 == 0 && j != 119)
            printf("\n");

        if ((j+1) % 30 == 0 && j != 119)
            printf("####################\n");
    }

    printf("\n");

    return 0;
}


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

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

    //各商品は100万個存在する
    //xは最大で10万
    
    int num = x / 100; //この数だけ商品を買うことができる
    //numまでの間に条件を満たせばよい
    int under2 = x % 100;
    int tmp = 0;
    for (int karen = 0; karen < num; karen++){
        if (under2 >= 5){
            under2 -= 5;
            continue;
        }
        switch(under2){
            case 4:
                under2 -= 4;
                break;
            case 3:
                under2 -= 3;
                break;
            case 2:
                under2 -= 2;
                break;
            case 1:
                under2 -= 1;
                break;
        }
        if (under2 == 0){
            break;
        }
    }
    char ans;
    if (under2 == 0){
        ans = '1';
    }
    else{
        ans = '0';
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//  Created by Sengxian on 2017/7/1.
//  Copyright (c) 2017年 Sengxian. All rights reserved.
//  
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
inline int readInt() {
	int n = 0, ch = getchar();
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) n = n * 10 + ch - '0', ch = getchar();
	return n;
}

const int MAX_N = 200000 + 3;
int n, a[MAX_N * 2];

int main() {
	n = readInt();
	int l = MAX_N, r = MAX_N;
	for (int i = 0; i < n; ++i)
		if ((n & 1) ^ (i & 1)) a[--l] = readInt();
		else a[r++] = readInt();
	for (int i = l; i < r; ++i) printf("%d%c", a[i], i + 1 == r ? '\n' : ' ');
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
int main()
{
    int h, w;
    cin >> h >> w;
    int count = 0;
    vector<vector<char>> field(h, vector<char>(w));
    for(int i = 0; i < h; i++)
    {
        for(int j = 0; j < w; j++)
        {
            cin >> field[i][j];
            if(field[i][j] == '#') count++;
        }
    }
    queue<P> que;
    que.push(P(0, 0));
    vector<vector<int>> d(h, vector<int>(w, -1));
    vector<int> dx = {1, 0, -1, 0};
    vector<int> dy = {0, -1, 0, 1};
    d[0][0] = 1;
    while(!que.empty())
    {
        P p = que.front();
        que.pop();
        for(int i = 0; i < 4; i++)
        {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if(nx >= 0 && nx < h && ny >= 0 && ny < w && field[nx][ny] == '.' && d[nx][ny] == -1)
            {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    if(d[h-1][w-1] == -1) cout << -1 << endl;
    else cout << h * w - d[h-1][w-1] - count << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll x;
  cin >> x;
  ll res=100;
  ll ans=0;
  for(int i=0; ;++i) {
    if(res>=x) break;
    res=res+res/100;
    ans++;
  }
  cout << ans << endl;
  return 0;
}
  
  


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

int main() {
	int N;
	cin >> N;
	int count = 0;
	vector<int64_t>bou(N);
	for(int i=0;i<N;i++){
		cin >> bou.at(i);
	}
	sort(bou.begin(),bou.end());
	for(int i=0;i<N-2;i++){
		for(int j=i+1;j<N-1;j++){
			if(bou.at(i)==bou.at(j)){
				continue;
			}
			for(int k=j+1;k<N;k++){
				if(bou.at(j)==bou.at(k)){
					continue;
				}
				if(bou.at(i)+bou.at(j)>bou.at(k)){
					count++;
				}
			}
		}
	}
	cout << count << endl;
}
	

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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> h(N);
  rep(i,N){
    cin >> h[i];
  }
  int ans = 0;
  rep(i,N){
    if(h[i] >= K) ans++;
  }
  cout << ans <<endl;
 }

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 1e5+7;


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

	int n, len;
	cin >> n >> len;
	vector<string> a(n);
	for(int i=0 ;i<n; i++){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for(int i=0; i<n; i++){
		cout << a[i];
	}
	cout << '\n';
	return 0;
}


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


int main(){
    vector<int> A(3);
    cin >> A[0] >> A[1] >> A[2];
    
    sort(A.begin(), A.end());
    
    int ans=0;
    if(((A[2]-A[1])%2==0&&((A[2]-A[0])%2==0)) || ((A[2]-A[1])%2==1&&(A[2]-A[0])%2==1)){
        ans += A[2]-A[1];
        ans += ((A[2]-A[0])-(A[2]-A[1]))/2;
    }
    else {
        A[2]++;
        A[1]++;
        ans++;
        ans += A[2]-A[1];
        ans += ((A[2]-A[0])-(A[2]-A[1]))/2;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
  
using namespace std;
  
double EPS = 1e-6;
  
double add(double a,double b){
  if(abs(a+b)<EPS*(abs(a)+abs(b)))return 0;
  return a+b;
}
  
struct point{
  double x,y;
  point() {}
  point(double x,double y):x(x),y(y){
  }
  point operator + (point p){
    return point(add(x,p.x),add(y,p.y));
  }
  point operator - (point p){
    return point(add(x,-p.x),add(y,-p.y));
  }
  point operator * (double d){
    return point(x*d,y*d);
  }
  point operator / (double d){
    return point(x/d,y/d);
  }
};
  
double dist(point a,point b){
    return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}

int main(void){
    int n,x,y,v;
    vector<point>P;
    vector<double>V;
     
    while(cin >> n,n){
        P.clear();
        V.clear();
         
        for(int i=0;i<n;i++){
            cin >> x >> y >> v;
            P.push_back(point(x,y));
            V.push_back(v);
        }
        
        double r=0.975;
        point now(0,0);
         
        for(double d=10;d>EPS;d*=r){
            int mx=0;
            double mxd=0;
             
            for(int j=0;j<P.size();j++)
                if(dist(now,P[j])/V[j]>mxd)
		  mx=j,mxd=dist(now,P[j])/V[j];
             
            now=now+((P[mx]-now)/dist(P[mx],now)*d);
        }
         
        double ans=0;
        for(int i=0;i<P.size();i++){
	  ans=max(ans,dist(now,P[i])/V[i]);
        }
        printf("%.8f\n",ans);
    }
    return 0;
}

Measured memory_bytes: 1248
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,m=0,x=0;
    cin>>n>>m;
    priority_queue<int> pq;
    for(int i=0;i<n;++i)
    {
    	cin>>x;
    	pq.push(x);
    }
    while(m--)
    {
    	int tp=pq.top();pq.pop();
    	tp/=2;pq.push(tp);
    }
    lli sum=0ll;
    while(!pq.empty())
    {
    	sum+=pq.top();pq.pop();
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 892
#include<stdio.h>
int main(void){
	int n,i,j,q,b,e,k,count=0;
	int a[1000];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d %d %d",&b,&e,&k);
		for(j=b;j<e;j++){
			if(a[j]==k){
				count++;
			}
		}
		printf("%d\n",count);
		count=0;
	}
	return 0;
}


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

using namespace std;

int main()
{
    int a,b;

    cin >> a >> b;

    int cnt = 0;
    for(int i = a;i <= b;i++){
        string str = to_string(i);
        string test = str;
        reverse(str.begin(),str.end());
        if(str == test) cnt++;   
    }
    cout << cnt << endl;
    return 0;
}

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

int main(){
  string S;
  cin >> S;
  char c = S[0];
  int ans = 0;
  for(int i = 1; i < S.size(); i++){
    if(c != S[i]){
      ans++;
      c = S[i];
    }
  }
  cout << ans << endl;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool a = true,b = true,c = true;
  for(int i=0;i<n/2;i++){
    if(s.at(i) != s.at(n-1-i))
      a = false;
  }
  for(int i=0;i<n/4;i++){
    if(s.at(i) != s.at(n/2-1-i))
      b = false;
  }
  for(int i=0;i<n/4;i++){
    if(s.at(n-1-i) != s.at(n/2+1+i))
      c = false;
  }
  if(a && b && c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;
int h, w, k;
ll dp[101][10];
ll dp2[10];

int main(int argc, char const* argv[])
{
  cin >> h >> w >> k;
  for(int i = 0; i < h + 1; i++){
    for(int j = 1; j <= w; j++){
      dp[i][j] = 0;
    }
  }
  dp2[0] = 1;
  dp2[1] = 1;
  for(int i = 2; i <= w; i++){
    dp2[i] = (dp2[i - 1] + dp2[i - 2]) % mod;
  }
  dp[0][1] = 1;
  for(int i = 1; i <= h; i++){
    for(int j = 1; j <= w; j++){
      ll pos = 0;
      pos = (dp2[j - 1] * dp2[w - j]) % mod;
      dp[i][j] = dp[i-1][j] * pos % mod;
      if(j > 1){
        ll pos = 0;
        pos = (dp2[j - 2] * dp2[w - j]) % mod;
        dp[i][j] = (dp[i][j] + dp[i-1][j-1] * pos) % mod;
      }
      if(j < w){
        ll pos = 0;
        pos = (dp2[j - 1] * dp2[w - j - 1]) % mod;
        dp[i][j] = (dp[i][j] + dp[i-1][j+1] * pos) % mod;
      }
    }
  }
  cout << dp[h][k] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const int MAX_N = 10010;
const int MAX_A = 1000010;
const int mod = 1e9 + 7;


ll calc(ll a, ll b, ll p)
{
	if (b == 0) return 1;
	if (b % 2 == 0)
	{
		ll d = calc(a, b / 2, p);
		return (d * d) % p;
	}
	else
		return (a * calc(a, b - 1, p)) % p;
}

vector<ll> lcm(MAX_A, 0); 
void f(ll n)
{
	ll x = n;
	for(ll i = 2; i * i <= n; i++)
	{
		ll cnt = 0;
		while (x % i == 0)
		{
			cnt++;
			x /= i;
		}
		lcm[i] = max(lcm[i], cnt);
	}
	if (x != 0)
		lcm[x] = max(lcm[x], 1ll); 
}

signed main(void)
{
	int n;
	cin >> n;
	int a[n];
	ll ans, l;

	rep(i, n) 
	{
		cin >> a[i];
		f(a[i]);
	}
	l = 1;
	for(int i = 1; i < MAX_A; i++)
	{
		rep(j, lcm[i])
		{
			l *= i;
			l %= mod;
		}
	}
	ans = 0;
	rep(i, n)
	{
		ans += l * calc(a[i], mod - 2, mod);
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,m,d,w,a,b,c,dp[N],sn[N],rt[N],sz[N],tp[N],fa[N],L,ans,h[N];
struct E{
	int l,to,w,c;
}e[N<<1];
struct P{
	int ls,rs,w,s;
}tr[3000005];
void Ad(int nt,int ot,int z,int y){
	tr[nt]=tr[ot];
	tr[nt].w+=w;
	if(z==y){
		tr[nt].s++;
		return;
	}
	int mid=z+y>>1;
	if(d<=mid)Ad(tr[nt].ls=++L,tr[ot].ls,z,mid);
	else Ad(tr[nt].rs=++L,tr[ot].rs,mid+1,y);
}
void Qr(int zt,int yt,int lt,int z,int y){
	if(z==y){
//		printf("%d_%d_\n",z,tr[yt].s);
		ans-=tr[zt].w+tr[yt].w-(tr[lt].w<<1);
		ans+=b*(tr[zt].s+tr[yt].s-(tr[lt].s<<1));
		return;
	}
	int mid=z+y>>1;
	if(a<=mid)Qr(tr[zt].ls,tr[yt].ls,tr[lt].ls,z,mid);
	else Qr(tr[zt].rs,tr[yt].rs,tr[lt].rs,mid+1,y);
}
void se(int x,int f){
	sz[x]=1;
	for(int i=h[x];i;i=e[i].l){
		if(e[i].to!=f){
			d=e[i].c;w=e[i].w;
			Ad(rt[e[i].to]=++L,rt[x],1,n);
//			printf("%d %d",i,e[i].to);
			se(e[i].to,x);
			sz[x]+=sz[e[i].to];
			if(sz[e[i].to]>sz[sn[x]])sn[x]=e[i].to;
		}
	}
}
void dfs(int x,int f,int T){
	tp[x]=T;dp[x]=dp[f]+1;
	fa[x]=f;
	if(sn[x])dfs(sn[x],x,T);
	for(int i=h[x];i;i=e[i].l){
		if(e[i].to!=f&&e[i].to!=sn[x])dfs(e[i].to,x,e[i].to);
	}
}
int lca(int x,int y){
	while(tp[x]!=tp[y]){
		if(dp[tp[x]]<dp[tp[y]])swap(x,y);
		x=fa[tp[x]];
	}
	return dp[x]<dp[y]? x:y;
}
int main(){
	int x,y;
	scanf("%d %d",&n,&m);
	for(int i=1;i<n;++i){
		scanf("%d %d %d %d",&x,&y,&c,&w);
		e[i<<1].w=e[i<<1|1].w=w;
		e[i<<1].c=e[i<<1|1].c=c;
		e[i<<1].to=y;e[i<<1].l=h[x];h[x]=i<<1;
		e[i<<1|1].to=x;e[i<<1|1].l=h[y];h[y]=i<<1|1;
	}
	se(1,0);dfs(1,0,1);
	for(int i=1;i<=m;++i){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		int z=lca(c,d);ans=0;
		Qr(rt[c],rt[d],rt[z],1,n);
		ans+=tr[rt[c]].w+tr[rt[d]].w-(tr[rt[z]].w<<1);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 40704
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;
#define int long long
#define endl '\n'
typedef long long ll;


const double PI=acos(-1);
typedef complex<double> base;
inline void fft (vector<base> & a, bool invert) {
	int n=(int) a.size();
	for (int i=1, j=0; i<n; ++i) {
		int bit=n>>1;
		for (;j>=bit;bit>>=1)
			j-=bit;
		j+=bit;
		if(i<j)
			swap(a[i],a[j]);
	}
	for (int len=2; len<=n; len<<=1) {
		double ang = 2*PI/len * (invert ? -1 : 1);
		base wlen(cos(ang), sin(ang));
		for (int i=0; i<n; i+=len) {
			base w(1);
			for (int j=0; j<len/2; ++j) {
				base u=a[i+j], v=a[i+j+len/2]*w;
				a[i+j]=u+v;
				a[i+j+len/2]=u-v;
				w*=wlen;
			}
		}
	}
	if (invert)
		for(int i=0;i<n;++i)
			a[i]/=n;
}

// a, b => coefs to multiply,  res => resulting coefs
// a[0], b[0], res[0] = coef x^0
inline void multiply (const vector<int> & a, const vector<int> & b, vector<int> & res) {//change res to ll if needed
	if(a.size() * b.size() <= 256) {
		res.resize(a.size() + b.size()+1, 0);
		for(int i = 0; i < (int)a.size(); i++)
			for(int j = 0; j < (int)b.size(); j++)
				res[i + j] += 1LL * a[i] * b[j];
		while(res.size()>1 && res.back() == 0) res.pop_back();
		return;
	}
	vector<base> fa (a.begin(), a.end()),  fb (b.begin(), b.end());
	size_t n=1;
	while (n<max(a.size(),b.size())) n<<=1;
	n<<=1;
	fa.resize(n),fb.resize(n);
	fft (fa,false);  fft(fb,false);
	for (size_t i=0; i<n; ++i)
		fa[i]*=fb[i];
	fft (fa, true);
	res.resize (n);
	for(size_t i=0; i<n; ++i)
		res[i]=(int)(fa[i].real()>0 ? fa[i].real()+0.5 : fa[i].real()-0.5);
	while(res.size()>1 && res.back() == 0) res.pop_back();
}

const int p = 200003;
const int g = 2;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	vector<int> arr;
	for(int i = 0; i < n; ++i) {
		int val;
		cin >> val;
		if(val > 0) arr.push_back(val);
	}
	n = arr.size();

	vector<int> order(2*p,0);
	int powG = g;
	for(int i = 1; i < 2*p; ++i) {
		order[i] = powG;
		powG = (powG * g) % p;
	}
	vector<int> inv(p,0);
	for(int i = 1; i < p; ++i) {
		inv[order[i]] = i;
	}
	vector<int> cnts(p,0);
	for(int val : arr) {
		++cnts[inv[val]];
	}
	vector<int> product;
	multiply(cnts,cnts,product);
	int res = 0;
	for(int i = 0; i < product.size(); ++i) {
		res += order[i] * product[i];
	}
	for(int val : arr) {
		res -= (val*val)%p;
	}
	cout << res/2;
}


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

int mod = 1e9+7;

int main()
{
    int n;
    cin>>n;
    long long sum=1;
    for(int i=1;i<=n;i++)
    {
        sum*=i;
        sum=sum%mod;
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int n,p;
ll dp[51][2];
int main(void){
    scanf("%d%d",&n,&p);
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        ll a;
        scanf("%lld",&a);
        for(int j=0;j<2;j++){
            dp[i+1][j]+=dp[i][j];
            dp[i+1][(j+a)%2]+=dp[i][j];
        }
    }
    printf("%lld\n",dp[n][p]);
}

Measured memory_bytes: 256
/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    ll n;
    cin>>n;

    n = (1000-(n%1000))%1000;


        
        
    cout<<n;











    return 0;
}       

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007
#define MAX_N 100000
#define MAX_P 200005
int fact[MAX_P];
int fact_i[MAX_P];
int extgcd(int a,int b,int& x,int& y){
  int d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
int mod_inverse(int a,int m){
  int x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}

void init(int p){
  fact[0]=1;
  for(int i=1;i<MAX_P;i++) fact[i]=(fact[i-1]*i)%p;
  fact_i[0]=1;
  for(int i=1;i<MAX_P;i++) fact_i[i]=(fact_i[i-1]*mod_inverse(i,p))%p;
}

struct UnionFind{
  vector<int> r,p;
  vector<vector<int> > v;
  UnionFind(){}
  UnionFind(int size){init(size);}
  void init(int size){
    r.resize(size,0);
    p.resize(size,0);
    v.resize(size);
    for(int i=0;i<size;i++){
      r[i]=1,p[i]=i;
      v[i].resize(1,i);
    }
  }
  bool same(int x,int y){
    return p[x]==p[y];
  }
  void unite(int x,int y){
    x=p[x];y=p[y];
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    for(int i=0;i<(int)v[y].size();i++){
      p[v[y][i]]=x;
      v[x].push_back(v[y][i]);
    }
    v[y].clear();
  }
};


signed main(){
  int n,x,y;
  cin>>n>>x>>y;
  int c[n],w[n];
  for(int i=0;i<n;i++) cin>>c[i]>>w[i];
  UnionFind uf(n);
  map<int,int> m;
  for(int i=0;i<n;i++)
    if(!m.count(c[i])||w[i]<w[m[c[i]]]) m[c[i]]=i;
  if((int)m.size()==1){
    cout<<1<<endl;
    return 0;
  }
  int s1=0;
  for(int i=0;i<n;i++)
    if(w[i]<w[s1]) s1=i;
  int s2=-1;
  for(int i=0;i<n;i++){
    if(c[i]==c[s1]) continue;
    if(s2<0||w[i]<w[s2]) s2=i;
  }
  for(int i=0;i<n;i++){
    if(w[m[c[i]]]+w[i]<=x)
      uf.unite(i,m[c[i]]);
    if(c[i]!=c[s1]&&w[i]+w[s1]<=y)
      uf.unite(i,s1);
    if(c[i]!=c[s2]&&w[i]+w[s2]<=y)
      uf.unite(i,s2);
  }
  init(MOD);
  int ans=1;
  for(int i=0;i<n;i++){
    if(uf.p[i]!=i) continue;
    //cout<<uf.r[i]<<":"<<endl;
    (ans*=fact[uf.r[i]])%=MOD;
    map<int,int> m2;
    for(int j=0;j<(int)uf.v[i].size();j++)
      m2[c[uf.v[i][j]]]++;
    for(auto j:m2) (ans*=fact_i[j.second])%=MOD;//,cout<<j.second<<endl;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 38132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
  ll N, M, K;
  cin >> N >> M >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A.at(i);
  vector<ll> B(M);
  rep(i, M) cin >> B.at(i);
  vector<ll> SA(N+2, 0);
  vector<ll> SB(M+2, 0);
  rep(i, N){
    SA.at(i+1) = SA.at(i) + A.at(i);
  }
  rep(i, M){
    SB.at(i+1) = SB.at(i) + B.at(i);
  }
  SA.at(N+1) = INF;
  SB.at(M+1) = INF;
  ll ans = 0;
  rep(i, N+1){
    if(SA.at(i) > K){
      break;
    }
    ll res = K - SA.at(i);
    ll l = 0;
    ll r = M+1;
    // SB.at(l) <= res < SB.at(r)
    while(r-l > 1){
      ll c = (l+r)/2;
      if(SB.at(c) <= res){
        l = c;
      }
      else{
        r = c;
      }
    }
    chmax(ans, i+l);
  }
  cout << ans << endl;
}

Measured memory_bytes: 9592
import math
a,b,C=map(int,input().split())

S=(a*b*math.sin(C/180*math.pi))/2
L=a+b+math.sqrt(a**2+b**2-2*a*b*math.cos(C/180*math.pi))
h=2*S/a

print(S)
print(L)
print(h)


Measured memory_bytes: 5704
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl;
// *min_element(c + l, c + r) *max_element(c + l, c + r)
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// struct Edge {
//   int to, id;
//   Edge(int to, int id): to(to), id(id) {}
// };

int main() {
    string S,T;cin>>S>>T;
    int N = S.size(),M = T.size();
    vector<vector<int>> plc(26,vector<int>());
    rep(i,N) plc[S[i]-'a'].push_back(i);
    int now = 0;
    ll cnt = 0;

    rep(i,M) {
        int num = T[i] - 'a';
        if(plc[num].size()==0) {
            cout<<-1<<endl;
            return 0;
        }
        int loc = lower_bound(plc[num].begin(),plc[num].end(),now) - plc[num].begin();
        if(loc == plc[num].size()) {
            now = plc[num][0]+1;
            cnt++;
        } else {
            now = plc[num][loc]+1;
        }
    }
    cout<<cnt*N+now<<endl;
}

Measured memory_bytes: 4252
#include<stdio.h>
int main()
{
    long long int n;
    long long int total=0;
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
        {
            total=total+i;
        }
    }
    printf("%lld\n",total);
    return 0;
}


Measured memory_bytes: 1728
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		int min = 1000, max = 0;
		for(int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		for(int i = 0; i < a.length; i++) {
			if(a[i] < min) min = a[i];
			if(a[i] > max) max = a[i];
		}
		System.out.println(max - min);
	}

}

Measured memory_bytes: 21716
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);
        int c = int.Parse(s[2]);
        Console.WriteLine(b - a == c - b ? "YES" : "NO");
    }
}


Measured memory_bytes: 11092
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define INFLL 1000000000000000000LL
#define MOD 1000000007
#define PI acos(-1)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>

using namespace std;

// clang-format on

main {
  int n;
  cin >> n;
  vi a(3 * n);
  rep(i, 3 * n) cin >> a[i];
  priority_queue<int, vector<int>, greater<int>> l;
  priority_queue<int> r;
  int la = 0, ra = 0;
  rep(i, n) {
    la += a[i];
    ra += a[2 * n + i];
    l.push(a[i]);
    r.push(a[2 * n + i]);
  }
  vi ld(n + 1), rd(n + 1);
  ld[0] = la;
  rd[n] = ra;
  for (int i = n; i < 2 * n; i++) {
    l.push(a[i]);
    la += a[i] - l.top();
    l.pop();
    ld[i - n + 1] = la;
    r.push(a[3 * n - i - 1]);
    ra += a[3 * n - i - 1] - r.top();
    r.pop();
    rd[2 * n - i - 1] = ra;
  }
  vi s(n + 1);
  rep(i, n + 1) s[i] = ld[i] - rd[i];
  cout << *max_element(all(s)) << endl;
  bye;
}


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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (ll i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

int cnt = 0;


void solve()
{
	ll n, m; cin >> n;
	multiset<string> a, b;
	forn(i, n) 
	{
		string x; cin >> x;
		a.insert(x);
	}
	cin >> m;
	forn(i, m)
	{
		string x;
		cin >> x;
		b.insert(x);
	}
	ll res = 0;
	for(auto x: a)
	{
		ll cnt = a.count(x);
		res = max(res, cnt - (ll)b.count(x));
	}
	cout << res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n, m;
ll X;

pair<int,pp> e[2010];
bool mu[2010];

int par[1010];
int root(int x){ return x==par[x]?x:par[x]=root(par[x]); }

const ll mod = int(1e9)+7;

ll Pow(ll b, ll e){
	ll ret=1;
	while(e){
		if(e&1) (ret*=b)%=mod;
		(b*=b)%=mod; e>>=1;
	}
	return ret;
}

vector<pp> te[1010];
int tp[1010];
int pd[1010];
int dep[1010];
void dfs(int x){
	for(auto tmp:te[x]){
		int y,d; tie(y,d)=tmp;
		if(tp[x]==y) continue;
		tp[y]=x; pd[y]=d; dep[y]=dep[x]+1;
		dfs(y);
	}
}

ll ans;

int pmax(int a, int b){
	int ret=0;
	while(dep[a]>dep[b]) ret=max(ret,pd[a]),a=tp[a];
	while(dep[a]<dep[b]) ret=max(ret,pd[b]),b=tp[b];
	while(a!=b){
		ret=max(ret,pd[a]);
		ret=max(ret,pd[b]);
		a=tp[a]; b=tp[b];
	}
	return ret;
}

ll nc[2010];

int main()
{
	read(n, m, X);
	for(int i=1; i<=m; ++i){
		int a, b, w; read(a, b, w);
		e[i]={w, {a, b}};
	}
	sort(e+1, e+m+1);
	ll mst = 0;
	for(int i=1; i<=n; ++i) par[i]=i;
	for(int i=1; i<=m; ++i){
		int w=e[i].x, a, b; tie(a,b)=e[i].y;
		if(root(a) != root(b)){
			te[a].eb(b,w); te[b].eb(a,w);
			par[root(a)]=root(b);
			mst += w;
			mu[i]=1;
		}
	}
	if(mst == X){
		(ans += Pow(2, m) - Pow(2, m-(n-1)+1)) %= mod;
	}
	dfs(1);
	int nn = 0;
	for(int i=1; i<=m; ++i) if(!mu[i]) nc[nn++] = mst+e[i].x-pmax(e[i].y.x, e[i].y.y);
	sort(nc, nc+nn);
	for(int i=0; i<nn; ++i){
		if(nc[i] == X){
			(ans += Pow(2, m-n-i+1)) %= mod;
		}
	}
	printf("%lld\n", (ans%mod+mod)%mod);
	return 0;
}


Measured memory_bytes: 384
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   998244353
#define    inf  9223372026854775807
#define    ninf   -inf
#define    ima   2047483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(12)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
#define    fbo    find_by_order
#define    ook    order_of_key
#define    upb    upper_bound
#define    lowb   lower_bound 
#define    lte(v,x)   upb(all(v),x)-v.be()
#define    gte(v,x)   v.end()-lowb(all(v),x)
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(x==0)return 0;if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}
inline ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}





int main()
{       io 
int testcases=1;      //  cin>>testcases;
while(testcases--)
{


ll r;
cin>>r;
cout<<3*r*r;















}return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define MOD 1000000007
using namespace std;
typedef pair<int, int> pii;



int main() {
	int sec = 0;
	REP(i, 4) {
		int t;
		scanf("%d", &t);
		sec += t;
	}
	printf("%d\n%d\n", sec/60, sec%60);
	return 0;
}

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int x,y;
    char z;
    cin>>x>>z>>y;
    if (z=='+')
        cout<<x+y<<endl;
    else
        cout<<x-y<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 

//     String[] nyu=sc.nextLine().split(" ");

     String nyu=sc.nextLine();
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu[2]);
int D=Integer.parseInt(nyu);
nyu=sc.nextLine();
int E=Integer.parseInt(nyu);
nyu=sc.nextLine();
int F=Integer.parseInt(nyu);
nyu=sc.nextLine();
int G=Integer.parseInt(nyu);



//StringBuffer sb = new StringBuffer(nyu);
//		String dst = sb.reverse().toString();

//     String nyu2=sc.nextLine();
//int E=Integer.parseInt(nyu2);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(nyu){
case "H H":
System.out.println("H") ;
break;

case "D D":
System.out.println("H") ;
break;

case "H D":
System.out.println("D") ;
break;

case "D H":
System.out.println("D") ;
break;


default:
System.out.println("NO") ;

break;
}
*/

//int res=Math.min((A*B),C);

//for(String tem:bo){
//if(tem.equals(nyu))res="vowel";
//}
//int res=0;
//for(int i=0;i<300;i++){
//if(num[i]==1)res=i;
//}

//char[] c = nyu.toCharArray();


//System.out.println(nyu+"-"+line_r_2+"-"+nyu2+"-"+line_r_1);



if(D<=E){
//double res=Math.ceil((AB)/2);

System.out.println(D*F);
//}else if(B<A){
//System.out.println("Alice");

}else{
System.out.println(E*F+(D-E)*G);
}




	}
}

Measured memory_bytes: 23764
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  ll n;
  cin >> n;
  vll v(n);
  rep(i, n) cin >> v[i];
  sort(all(v));
  ld ans = v[0];
  for(ll i = 1;i < n;i++)
  {
    ans += v[i];
    ans /= 2.;
  }
  fin(ans);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
readInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine

main :: IO ()
main = do
  (n:m:_) <- fmap (map read . words) getLine :: IO [Int]
  -- gs <- replicateM m $ fmap (map read . words) getLine :: IO [[Int]]
  gs <- replicateM m $ readInts
  -- gs <- read2dInts
  print . solve' 0 . sortBridge $ gs

sortBridge = sortBy (\x y -> (x !! 1) `compare` (y !! 1))
isDivided i ds = (ds !! 0) <= i && (ds !! 1) > i

solve' :: Int -> [[Int]] -> Int
solve' i [] = i
solve' i gs = solve' (i + 1) $ filter (not . isDivided bridge) gs
  where
    bridge = (head gs) !! 1 - 1


Measured memory_bytes: 60796
package main

import "fmt"

func main() {
	var a, b int
	var op string
	fmt.Scanf("%d %s %d", &a, &op, &b)

	if op == "+" {
		fmt.Println(a + b)
	}

	if op == "-" {
		fmt.Println(a - b)
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>

#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define ll long long int

using namespace std;

int main(void) {
    int n,k;
    while(cin>>n>>k && n>0){
        vector<int> a;
        bool f=0;
        REP(i,k){
            int c;
            cin >> c;
            if (c>0)
                a.push_back(c);
            else
                f=1;
        }
        sort(a.begin(),a.end());
        vector<int> l,c;
        int s=1;
        FOR(i,1,k-f-1){
            if (a[i]-a[i-1]==1){
                s++;
            }
            else{
                l.push_back(s);
                s=1;
                if (a[i]-a[i-1]==2){
                    c.push_back(1);
                }else{
                    c.push_back(0);
                }
            }
        }
        if (s>1){
            l.push_back(s);
        }
        int ans = 0;
        REP(i,l.size()){
            ans = max(ans,l[i]);
        }
        if(f){
            REP(i,c.size()){
                if(c[i]){
                    ans = max(ans,l[i]+l[i+1]+1);
                }
            }
        }
        cout << ans << endl;
    }
    
    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N, P;
    cin >> N >> P;
    string s;
    cin >> s;
    reverse(all(s));
    LL res = 0;
    if(P == 2) {
        for(int i = 0; i < s.size(); ++i) {
            if((s[i] - '0') % 2 == 0) {
                res += N - i;

            }
        }
        cout << res << endl;
        return 0;
    }
    if(P == 5) {
        for(int i = 0; i < s.size(); ++i) {
            if(s[i] == '0' || s[i] == '5') {
                res += N - i;

            }
        }
        cout << res << endl;
        return 0;
    }
    map<int, LL> mp;
    int t = 0;
    int d = 1;
    for(int i = 0; i < s.size(); ++i) {
        t += (s[i] - '0') * d;
        t %= P;
        mp[t]++;
        d *= 10;
        d %= P;

    }

    res += mp[0] * (mp[0] + 1) / 2;
    /*
    int l = 1, r = 2018;
    while(l <= r) {
        res += mp[l] * mp[r];
        ++l; --r;

    }*/
    for(int i = 1; i < P; ++i) {
        res += mp[i] * (mp[i] - 1) / 2;

    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 1044