akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
using namespace std;
using T = tuple<int,int,int>;//count,x,y
char board[8][8];

T place(bool turn){
    //turn==ture := 'o' else 'x'
    T ret(0,-1,-1);
    for(int i=0;i<8;i++){
        for(int j=0;j<8;j++){
            if(board[i][j]!='.') continue;
            int cnt = 0;
            int d[9]={0,-1,-1,1,1,0,1,-1,0};
            for(int k=0;k<8;k++){
                int dx=d[k],dy=d[k+1];
                int y=i,x=j;
                int temp=0;
                while(true){
                    x+=dx; y+=dy;
                    if(x<0||x>=8||y<0||y>=8) break;
                    if(board[y][x]=='.') break;
                    if(board[y][x]==(turn?'o':'x')){
                        cnt+=temp;
                        break;
                    }else{
                        temp++;
                    }
                }
            }
            // cout<<(turn?-cnt:cnt)<<' '<<i<<' '<<j<<endl;

            if(turn)ret = min(ret,T(-cnt,i,j));
            else ret = max(ret,T(cnt,i,j));
        }
    }
    if(turn)get<0>(ret)*=-1;
    return ret;
}

void emplace(T t,bool turn){
    int i,j;
    tie(ignore,i,j) = t;
    int d[9]={0,-1,-1,1,1,0,1,-1,0};
    board[i][j]=(turn?'o':'x');
    for(int k=0;k<8;k++){
        int dx=d[k],dy=d[k+1];
        int y=i,x=j;
        while(true){
            x+=dx; y+=dy;
            if(x<0||x>=8||y<0||y>=8) break;
            if(board[y][x]=='.') break;
            if(board[y][x]==(turn?'o':'x')){
                while(x!=j||y!=i){
                    x-=dx;y-=dy;
                    board[y][x]=(turn?'o':'x');
                }
                break;
            }else{
                continue;
            }
        }
    }
}

int main(){
    for(int i=0;i<8;i++){
        for(int j=0;j<8;j++) cin>>board[i][j];
    }
    bool flag = true;
    for(int i=0;i<64;i++){
        // for(int i=0;i<8;i++){
        //     for(int j=0;j<8;j++){
        //         cout<<board[i][j];
        //     }
        //     cout<<endl;
        // }cout<<endl;
        T t = place(i%2==0);
        if(get<0>(t)==0){
            if(!flag) break;
            else flag = false;
            continue;
        }
        flag=true;
        emplace(t, i%2==0);
    }
    for(int i=0;i<8;i++){
        for(int j=0;j<8;j++){
            cout<<board[i][j];
        }
        cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 3100
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int x, i = 0;
    cin >> x;
    long long int p = 100;
    for (; p < x; i++)
    {
        p += p / 100;
    }
    cout << i;
}

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

int n, i;
int main(){
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
//  freopen("in.txt", "r", stdin);
#endif // ONLINE_JUDGE
  cin >> n >> i;
  cout << n - i + 1 << '\n';
  return 0;
}


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

int main(void){
    int N, T, c, t;
    int res = 10000;
    cin >> N >> T;
    
    for (int i = 0; i < N; i++) {
        cin >> c >> t;
        if (t <= T && c <= res) res = c;
    }
    if (res == 10000) cout << "TLE" << endl;
    else cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define digit(x) floor(log10(x))+1
#define mod 1000000007
typedef long long ll;
typedef long double ld;
typedef vector<vector<ll>> matrix;
typedef vector<ll> arr;
typedef vector<string> vs;
typedef vector<pair<ll,ll>> pv;
#define in1(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define in3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define all(x) x.begin(),x.end()
#define debug(x) cerr << #x << " is " << x << endl;
int main(){
    fast;
    ld n,a,b,c,ans=0.0,d;
    cin>>n;
    ld x=n/3;
    cout<<fixed<<setprecision(12)<<x*x*x<<endl;
    return 0;
}


Measured memory_bytes: 384
n, l = input().split()
n = int(n)
l = int(l)
h = [int(s) for s in input().split()]


dp = [0]
for i, height in enumerate(h):
    hight_temp = height
    step = 10000000000
    start = i - l if i - l > 0 else 0
    for k in range(start, i):
        temp_step = abs(height - h[k]) + dp[k]
        step = step if step < temp_step else temp_step
        temp = temp_step

    if i != 0:
        dp.append(step)

print(dp.pop())

Measured memory_bytes: 57440
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

ll N;
ll X;
ll T;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> N;
    cin >> X;
    cin >> T;
    solve();
}

// 1 <= N,X,T <= 1000
// 入力は全て整数

// ll N, ll X, ll T
// N 個のたこ焼きを作るために必要な時間の最小値を整数で出力せよ。
void solve(){
    cout<<(N+X-1)/X*T<<endl;
}


Measured memory_bytes: 3620
#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);
  }
  int Ans=(int)pow(3, N);
  int pro=1;
  for(int i=0; i<N; i++){
    if(A.at(i)%2==0){
      pro*=2;
    }
  }
  Ans-=pro;
  cout << Ans << endl;
}

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

signed main(){

  int W,H; cin >> W >> H;
  vector<pair<int,int>> v;
  for(int i = 0; i < W+H; i++){
    int p; cin >> p;
    if(i < W) v.push_back({p,0});
    else v.push_back({p,1});
  }
  sort(v.begin(),v.end());

  int ans = 0;
  H++,W++;
  for(int i = 0; i < v.size(); i++){
    if(v[i].second == 0){
      ans += v[i].first * H;
      W--;
    }
    else {
      ans += v[i].first * W;
      H--;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6256
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double x[] = new double[n];
        double y[] = new double[n];

        for (int i = 0; i < n; i++) {
            x[i] = sc.nextDouble();
            y[i] = sc.nextDouble();
        }

        double sum = 0;

        for (int i = 0;  i < n; i++) {
            for (int j = i; j < n; j++) {
                sum += calcDiss(x[i], x[j], y[i], y[j]);
            }
        }

        System.out.println(sum * 2 / n);

    }
    
    static double calcDiss(double x1, double x2, double y1, double y2) {
        double res = 0;
        res += (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
        res = Math.sqrt(res);
        return res;
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h> 
#include <algorithm>  
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(long long int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;
/*vector<ll>g[1000001];
ll vis[1000005]={0};
map<ll,ll>y;
queue<ll>q ;*/
ll gcd(ll a, ll b){
    if(b%a==0) return a;
    else return gcd(b%a,a);
}
ll power(ll a, ll b){
    ll res=1;
    while(b)
    {
        if(b%2!=0) res=res*a;
        a=a*a;
        b=b/2;
    }
    return res;
}
/*void bfs(ll s)
{
       vis[s]=1;
       q.push(s);
       ll curr=q.front(); vis[curr]=1;
       while(!q.empty())
       {
              curr=q.front(); q.pop(); // vis[curr]=1;
              for(ll i=0;i<g[curr].size();i++)
              {
                     ll child=g[curr][i];
                     if(vis[child]==0) 
                     { 
                            q.push(child); 
                            vis[child]=1;
                     }
              }
       }
}
ll co=0;
ll dfs(ll curr)
{
       vis[curr]=1;
       for(ll i=0;i<g[curr].size();i++)
       {
              ll child=g[curr][i];
              if(vis[child]==0)
              {
                     co++;
                     dfs(child);
              }
       }
       return co;
}*/
signed main() 
{
    fast
    ll t;
    cin>>t;
    while(t--)
    {
         cout<<"ACL";
    }
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(void){
  int n;
  scanf("%d",&n);
  int result = 100000;
  int i;
  int temp;
  for(i=0;i<n;i++){
    result = result*1.05;
    //¢
    temp = result % 1000;
    if(temp !=0){
      result = result -temp;
      result = result+1000;
    }
  }
  printf("%d\n",result);
  return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    VI water, suger;
    FOR(i, 0, f)FOR(j, 0, f){
        int x = i * a * 100 + j * b * 100;
        int y = i * c + j * d;
        if(x <= f) water.push_back(x);
        if(y <= f) suger.push_back(y);
    }

    int ans_w = water.back();
    int ans_s = suger.front();
    for(auto w : water)for(auto s : suger){
        if(w + s > f || w + s == 0 || s > e * w / 100) continue;
        if((w + s) * ans_s < s * (ans_w + ans_s)){
            ans_w = w;
            ans_s = s;
        }
    }
    cout << ans_w + ans_s << " " << ans_s << "\n";
    return 0;
}


Measured memory_bytes: 1400
from sys import stdin
input = stdin.readline

n = int(input())
M = [['0']*n for _ in range(n)] # 0オリジンの隣接行列、0で初期化しておく

for _ in range(n):
    u, k, *vv = input().split()
    u = int(u)-1  # 0オリジンにする
    k = int(k)    # kは使わない
    for v in vv:
        v = int(v)-1  # 0オリジンにする
        M[u][v] = '1' #最後に出力するときstr型である必要があるので、str型で入力

for m in M:
    print(' '.join(m)) # 空白入れて出力


Measured memory_bytes: 5680
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }

using ll = long long;
const ll mod = LLONG_MAX;

int N,K;
int A[212345];
int rui[212345];
int ans;
int main(){
  cin>>N>>K;
  rep(i,N+1)rui[i]=INF;

  rep(i,N){
    cin>>A[i];
    if(rui[A[i]]==INF)rui[A[i]]=1;
    else rui[A[i]]++;
  }
  int syu=0;
  rep(i,N+1){
    if(rui[i]>0 && rui[i]<INF)syu++;
  }
  if(syu<=K){
    cout<<'0'<<endl;
  }else{

    sort(rui,rui+N+1);
    int z=syu-K;
    int idx=0;
    while(z>0){
      ans+=rui[idx];
      z--;idx++;
    }
    cout<<ans<<endl;
  }




}


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

using namespace std;

long long f(long long A, long long B, long long C) {
    if (A % 2 == 1 || B % 2 == 1 || C % 2 == 1) return 0;
    if (A == B && B == C) return 1e18;
    return f((B + C) / 2, (A + C) / 2, (A + B) / 2) + 1;

};


int main() {
    long long A, B, C;
    cin >> A >> B >> C;
    long long ans = f(A, B, C);

    if( ans >= 1e18 ){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    while(true){
      int m = sc.nextInt();
      int f = sc.nextInt();
      int r = sc.nextInt();
      int goukei = m + f;
      if(m == -1 && f == -1 && r == -1){
        break;
      }
      if((m == -1 || f == -1) || goukei < 30){
        System.out.println("F");
      }else if(goukei >= 80){
        System.out.println("A");
      }else if(goukei >= 65 && goukei < 80){
        System.out.println("B");
      }else if(goukei >= 50 && goukei < 65){
        System.out.println("C");
      }else{
        if(r >=50){
          System.out.println("C");
        }else{
          System.out.println("D");
        }
      }
    }
  }
}


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

#define pi 2*acos(0)
#define INF 1e16
#define MIN 1e-9
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define m_p make_pair
#define p_b push_back
#define n_p(a) next_permutation(all(a))
#define all(v) v.begin(),v.end()
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define rev(s) reverse(all(s))
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define mem(a,k) memset(a,k,sizeof a)
#define REP(i, a, b) for (int i = int(a); i <= int(b); i++)
#define u_b(X,V) upper_bound(X.begin(),X.end(),V)
#define l_b(X,V) lower_bound(X.begin(),X.end(),V)
#define cnt(s,c) count(all(s),c)

//bitwise helpers
#define isOn(S, j) (S & (1 << j))
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define lowBit(S) (S & (-S))
#define setAll(S, n) (S = (1 << n) - 1)

#define modulo(S, N) ((S) & (N - 1))
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define turnOffLastBit(S) ((S) & (S - 1))
#define turnOnLastZero(S) ((S) | (S + 1))
#define turnOffLastConsecutiveBits(S) ((S) & (S + 1))
#define turnOnLastConsecutiveZeroes(S) ((S) | (S - 1))

using namespace std;

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

    int n;

    cin >> n;

    double res = 0;
    for(int i = 0; i < n; i++) {
        double x;
        string u;
        cin >> x >> u;
        if(u == "BTC") {
            res += (380000.0 * x);
        }
        else {
            res += x;
        }
    }

    cout << setprecision(6) << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a==c&&b==d)
    printf("%d",b-a);
    else if(b<=c)
    printf("0");
    else if(d<=a)
    printf("0");

    else if(a<c&&c<b&&b<d)
    printf("%d",b-c);
    else if(c<a&&a<d&&d<b)
    printf("%d",d-a);
    else if((a<c&&c<d&&d<b)||(a==c&&c<d&&d<b)||(a<c&&c<d&&d==b))
    printf("%d",d-c);
    else if((c<a&&a<b&&b<d)||(c==a&&a<b&&b<d)||(c<a&&a<b&&b==d))
    printf("%d",b-a);
    return 0;
}

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

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

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr ll INF=1e18;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

vvl solve(const vvi& g,const vl& a,int u,int p)
{
	// udp[0][i]: uを根とする部分木をi回切断した場合の、uを含む連結成分がバッテリーだけのときのsumの最小値
	// udp[1][i]: uを根とする部分木をi回切断した場合の、uを含む連結成分のsumの最小値
	vvl udp(2,vl(1,INF));
	if(a[u]>0)
		udp[0][0]=a[u];
	udp[1][0]=a[u];
	for(int v:g[u]) if(v!=p){
		vvl vdp=solve(g,a,v,u);
		int usize=udp[0].size(),vsize=vdp[0].size();
		vvl dp(2,vl(usize+vsize,INF));
		rep(i,usize) rep(j,vsize){
			// u-v間を切断しない
			chmin(dp[0][i+j],udp[0][i]+vdp[0][j]);
			chmin(dp[1][i+j],udp[1][i]+vdp[1][j]);
			// u-v間を切断する
			if(vdp[0][j]!=INF||vdp[1][j]<0){
				chmin(dp[0][i+j+1],udp[0][i]);
				chmin(dp[1][i+j+1],udp[1][i]);
			}
		}
		udp=dp;
	}
	return udp;
}

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int n;cin>>n&&n;){
		vl a(n);
		rep(i,n) cin>>a[i];
		vvi g(n);
		rep(i,n-1){
			int u,v; cin>>u>>v; u--,v--;
			g[u].push_back(v);
			g[v].push_back(u);
		}

		vvl dp=solve(g,a,0,-1);
		int res=n-1;
		rep(i,n){
			if(dp[0][i]!=INF)
				chmin(res,i);
			if(dp[1][i]<0)
				chmin(res,i);
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 2176
// Etavioxy
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
#define il inline
#define rep(i,s,t) for(register int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(register int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define pt(x) putchar(x)
using namespace std;
il int ci(){
	register char ch; int f=1;
	while(!isdigit(ch=getchar())) f=ch=='-'?-1:1;
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(x*10)+(ch^'0');
	return f*x;
}

enum{N=200023};

char s[N];
int a[N],cnt[N];

int main(){
	int n=ci(), p=ci();
	scanf("%s",s+1);
	ll ans=0;
	if( p==2 ){
		rep(i,1,n) if( (s[i]&1)==0 ) ans+=i;
	}else if( p==5 ){
		rep(i,1,n) if( s[i]=='0' || s[i]=='5' ) ans+=i;
	}else{
		int pow10 = 1;
		rev_rep(i,n,1){
			a[i]=(a[i+1]+(s[i]-'0')*pow10)%p;
			pow10 = pow10*10%p;
		}
		cnt[0]=1;
		rep(i,1,n){
			ans+=cnt[a[i]];
			cnt[a[i]]++;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(long long a, long long b, long long c, long long d) {
    ll x = b - b / c - b / d + b / lcm(c, d);
    ll y = a - 1 - (a - 1) / c - (a - 1) / d + (a - 1) / lcm(c, d);
    // a,bそれぞれの割り切れる数は、c,dで割った小数点以下切り捨てで求める。
    // 後は、c,dの最小公倍数の数だけ重複しているので戻す。

    cout << x - y << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);

    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    long long D;
    scanf("%lld", &D);
    func(A, B, C, D);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define MAXN 10000
int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);

    int par[MAXN];
    int n;
    int q;
    std::cin >> n;
    std::cin >> q;
    //initialize                                                                                                                                                                                                                    
    for(int i = 0; i < n; ++i){
        par[i] = i;
    }

    for(int i = 0; i < q; ++i){
        int op;
        std::cin >> op;
        if(op == 0){//union                                                                                                                                                                                                         
            int id1;
            int id2;
            std::cin >> id1;
            std::cin >> id2;
            while(par[id1] != id1) id1 = par[id1];
            while(par[id2] != id2) id2 = par[id2];
            par[id1] = id2;
        } else {
            int id1;
            int id2;
            std::cin >> id1;
            std::cin >> id2;
            while(par[id1] != id1) id1 = par[id1];
            while(par[id2] != id2) id2 = par[id2];
            if(id1 == id2) std::cout << 1 << "\n";
            else std::cout << 0 << "\n";
        }
    }
    return 0;
}



Measured memory_bytes: 3252
fn main(){
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let n: i32 = s.trim().parse().unwrap();
	let mut c = 0;
	let mut cd = 1;
	for i in 1..(n + 1) as usize {
		let mut cs = 0;
		let mut ns = i as i32;
		loop {
			if ns > 0 {
				if ns % 2 == 0 { cs += 1;}
			} else {
				break;
			}
			ns /= 2;
		}
		if c < cs {
			c = cs;
			cd = i as i32;
		}
	}
	println!("{}", cd);
}


Measured memory_bytes: 4352
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BBiteEating {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N, L;
        cin >> N >> L;

        int sum = 0;
        FOR(i, 1, N) {
            sum += L + i - 1;
        }

        int diff = INF;
        int res = 0;

        FOR(j, 1, N) {
            int tmp = 0;
            FOR(i, 1, N) {
                if (i == j) continue;
                tmp += L + i - 1;
            }
            if (abs(sum - tmp) < diff) {
                diff = abs(sum - tmp);
                res = tmp;
            }
        }
        cout << res << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BBiteEating solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, h, maxl = 0, count;
  bool flag;
  cin >> N;
  int *array;
  array = new int[N];
  for(int i = 0; i < N; i++){
    cin >> array[i];
    maxl = max(maxl,array[i]);
  }
  count = 0;
  for(int i = 1; i <= maxl; i++){
    flag = false;
    for(int j = 0; j < N; j++){
    	if(array[j] >= i){
          if(!flag){
            count++;
          }
          flag = true;
        }else{
          flag = false;
        }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
rsp = list(map(int,input().split()))
T = list(input())
ans = 0
for i in range(K):
    ans += rsp["spr".index(T[i])]
for i in range(K,N):
    if T[i] != T[i-K]:
        ans += rsp["spr".index(T[i])]
    else:
        T[i] = "z"
print(ans)

Measured memory_bytes: 4084
H, W, K = gets.split.map(&:to_i)
 
q = Array.new(H) do
  gets.chomp.split('').map{ |v| v == '#' } # . #
end
 
ans = 0
[false, true].repeated_permutation(H) do |h|
  [false, true].repeated_permutation(W) do |w|
    count = 0
    H.times do |i|
      W.times do |j|
        count += 1 if q[i][j] && !h[i] && !w[j]
      end
    end
    ans += 1 if count == K
  end
end
 
puts ans

Measured memory_bytes: 14340
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		if (a < b && b < c) {
			out.println("Yes");
		} else {
			out.println("No");
		}
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}


Measured memory_bytes: 26336
N = int(input())
towers = list(map(int, input().split()))


for i in reversed(range(len(towers))):
    if len(towers) <= i+1:
        continue

    if towers[i] > towers[i+1]:
        towers[i] -= 1

# print(towers)

for i in range(1, len(towers)):
    if towers[i-1] > towers[i]:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 14396
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
      ll h, w;
      cin >> h >> w;
      if(h == 1 || w == 1){
        cout << 1 << endl;
      }
      else if((h*w)%2){
        cout << ((h*w)/2)+1 << endl;
      }else{
        cout << (h*w)/2 << endl;
      }

}   

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

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

    vector<long long int> pow10(20, 1);
    for(int i=0; i+1<16; i++){
        pow10[i+1] = pow10[i] * 10;
    }

    vector<long long int> snuke(k);
    snuke[0] = 1;

    for(int i=1; i<k; i++){
        long long int next = snuke[i-1] + 1;

        long long int s = 0;
        vector<long long int> digit;
        while(next > 0){
            digit.push_back(next % 10LL);
            s += next % 10LL;
            next /= 10LL;
        }
        int n = digit.size();

        long long int ans = snuke[i-1] + 1;// no change
        long long int sa = s;

        long long int test = snuke[i-1] + 1;
        long long int st = s;

        for(int d=0; d<n; d++){// digit change
            while(digit[d] < 9){
                test     += pow10[d];
                digit[d] += 1;
                st       += 1;
                //cout << test << " ";

                if(test * sa < ans * st){
                    ans = test;
                    sa = st;
                }
            }
            //cout << endl;
        }
        snuke[i] = ans;
    }

    for(int i=0; i<k; i++){
        cout << snuke[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3524
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
using namespace std;

int main(){

 int x1,x2,y1,y2;
 cin>>x1>>y1>>x2>>y2;

 cout<<x2+y1-y2<<" "<<y2+x2-x1<<" "<<x1+y1-y2<<" "<<y1+x2-x1<<endl;

    

return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()
#define MOD 1000000007

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
    if (a % b == 0) {
        return(b);
    }
    else {
        return(gcd(b, a % b));
    }
}

template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

int main(void) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans= a * c;
    ans = max(ans, a * d);
    ans = max(ans, b * d);
    ans = max(ans, b * c);
    cout << ans;
}



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

#define int long long
#define REP(i, l, r) REPEAT(i,l,r,true) // [l, r)
#define rep(i, n) REP(i,0,n)           // [0, n)
#define REPEAT(i, l, r, condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second

#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n, l, r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...) true
#define showlr(n,l,r) true
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int, int>;

struct io {
    io() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.tie(0);
        cout << fixed << setprecision(20);
    }
} io;

template<class T>
istream &operator>>(istream &is, vector<T> &v) {
    for (T &e:v)is >> e;
    return is;
}

template<class T>
ostream &operator<<(ostream &os, vector<T> v) {
    os << "{";
    for (T &e:v)os << e << (v.size() - (int) (&e - &v[0]) > 1 ? ", " : "");
    os << "}";
    return os;
}

void _DEBUG() {}

template<typename H, typename... T>
void _DEBUG(H a, T...b) {
    cerr << a << (sizeof...(b) ? "," : "\n");
    _DEBUG(b...);
}

inline void in() {}

template<typename H, typename... T>
void in(H &a, T &... b) {
    cin >> a;
    in(b...);
}

inline void out() {}

template<typename H, typename... T>
void out(H a, T... b) {
    cout << a << (sizeof...(b) ? " " : "\n");
    out(b...);
}

template<class T>
void resz(int n, T &v) { v.resize(n); }

template<class H, class... T>
void resz(int n, H &a, T &... b) {
    a.resize(n);
    resz(n, b...);
}

template<typename V, typename H>
void resize(vector<V> &v, const H a) { v.resize(a); }

template<typename V, typename H, typename... T>
void resize(vector<V> &v, const H &a, const T... b) {
    v.resize(a);
    for (auto &v:v) resize(v, b...);
}

const int INF = 1LL << 55;
const int MOD = 1000000007;
const double EPS = 1e-8;

/*------------end of definitions------------*/

int N, D;

signed main() {

    in(N, D);
    int res = 0;
    for (int i = 0; i < N; i += 2 * D + 1) {
        res++;
    }
    out(res);

    return 0;
}


Measured memory_bytes: 256
mod = 1000000007
N = int(input())
A = list(map(lambda x: int(x) % mod, input().split(" ")))

"""
累積話を計算しておく: O(N)
"""
_sum = 0
for i in range(N):
    _sum += A[i]
    _sum %= mod

"""
1重ループ内で下記を行う: O(N)

- 端のブロックを累積和から崩す（減算）
- 端のブロックと累積和をかける
- modをとる
"""
ans = 0
for i in range(N):
    # 累積和の端のブロックを崩す
    _sum -= A[i]

    ans += A[i] * _sum
    ans %= mod

print(ans)


Measured memory_bytes: 93488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    int H, W;
    cin >> H >> W;

    vector<vector<int>> field(H, vector<int>(W, 0));
    for(int i=0;i<H;i++){
        string line;
        cin >> line;
        for(int j=0;j<W;j++){
            if(line[j] == '#'){
                field[i][j] = 3;
            }
        }
    }

    for(int j=0;j<W;j++){
        for(int i=0;i<H;i++){
            if(j == 0){
                field[i][j] = 1;
            }else if(j == W-1){
                field[i][j] = 2;
            }else{
                if(i%2 == 0){
                    field[i][j] |= 1;
                }else{
                    field[i][j] |= 2;
                }
            }
        }
    }

    for(int k=1;k<=2;k++){
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(field[i][j]&k){
                    cout << '#';
                }else{
                    cout << '.';
                }
            }
            cout << endl;
        }
        if(k == 2) break;
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
S = input()
T = input()
n = len(S)
m = len(T)

flag = 0
ans = 'UNRESTORABLE'
for i in range(n - m + 1):
    for j in range(m):
        if S[i + j] != '?' and S[i + j] != T[j]:
            break
    else:
        S2 = S[: i] + T + S[i + m :]
        flag = 1
if flag:
    ans = S2.replace('?', 'a')
        
print(ans)

Measured memory_bytes: 3064
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

int main(void){
	int k=nextint();
	int a=7%k;
	for(int i=1; i<=k; i++){
		if(a==0){
			printf("%d\n", i);
			return 0;
		}
		a=(a*10+7)%k;
	}
	puts("-1");
}


Measured memory_bytes: 1604
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)

int main()
{
    int n, t, a;
    long long tm[100001];
    cin >> n;
    cin >> t >> a;
    a *= 1000;
    REP(i, n){
        int h;
        cin >> h;
        tm[i] = 1000 * t - 6 * h;
    }
    int nearIdx = -1;
    int minDist = 9000000;
    REP(i, n){
        if (abs(tm[i] - a) < minDist ){
            nearIdx = i;
            minDist = abs(tm[i] - a);
        }
    }
    cout << nearIdx + 1 << endl;
}

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

using ll=long long;

int main() {
  string N; cin >>N;
  cout <<count(N.begin(),N.end(),'2') <<endl;
  return 0;
}


Measured memory_bytes: 3628
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] mod10min = Enumerable.Repeat(int.MaxValue,10).ToArray();
        int sum = 0;
        for (int i = 0; i < n; i++)
        {
            int a = int.Parse(Console.ReadLine());
            mod10min[a % 10] = Math.Min(mod10min[a % 10],a);
            sum += a;
        }
        int ind = 0;
        if (sum % 10 == 0) sum -= mod10min.Min(x => (x % 10 != 0 ? x : 100));
        Console.WriteLine(sum % 10 != 0 ? sum : 0);
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;

struct UF{
    vector<int> p, rank;
    int n;
    UF(int siz){
        n = siz;
        p.resize(n);
        rank.resize(n, 1);
        for(int i = 0; i < n; i++)  p[i] = i;
    }
    int findSet(int x){
        if(p[x] != x)   p[x] = findSet(p[x]);
        return p[x];
    }
    bool same(int x, int y){
        return findSet(x) == findSet(y);
    }
    void unite(int x, int y){
        x = findSet(x), y = findSet(y);
        if(x == y)  return;
        if(rank[x] < rank[y]){
            p[x] = y;
            rank[y] += rank[x];
        }else{
            p[y] = x;
            rank[x] += rank[y];
        }
    }
};

typedef pair<int,int> pii;

#define F first
#define S second

int main(){
    int n, a, b;
    cin >> n;
    UF uf(n);
    vector<pair<pii,int>> x, y;
    for(int i = 0; i < n; i++){
        cin >> a >> b;
        x.push_back({{a,b},i});
        y.push_back({{b,a},i});
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    priority_queue<pair<int,pii>> pq;
    for(int i = 0; i < n-1; i++){
        pq.push({-min(abs(x[i].F.F-x[i+1].F.F), abs(x[i].F.S-x[i+1].F.S)), {x[i].S, x[i+1].S}});
        pq.push({-min(abs(y[i].F.F-y[i+1].F.F), abs(y[i].F.S-y[i+1].F.S)), {y[i].S, y[i+1].S}});
    }
    ll ans = 0;
    while(!pq.empty()){
        pair<int,pii> p = pq.top(); pq.pop();
        int cost = -p.F, i = p.S.F, j = p.S.S;
        if(uf.same(i,j))    continue;
        ans += cost;
        uf.unite(i,j);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7980
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#include <cassert>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, r) for (int i = (l); i < (r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
struct IOSET{IOSET(){cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} ioset;

// Main Code
int main() {
    int n;
    ll d;
    cin >> n >> d;
    vector<ll> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    
    int ans = 0;
    rep(i, n) {
        if (x[i] * x[i] + y[i] * y[i] <= d * d) ++ans;
    }
    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6348
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string o,e;
    cin >> o >> e;
    for(int i = 0;i < min(o.size(),e.size());i++)
    {
        cout << o[i] << e[i];
    }
    if(o.size() > e.size())
    {
        cout << o[o.size() - 1];
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int R = in.Int();
            out.println(R * 2 * Math.PI);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

    }
}



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

int main() {
  int a3,a2,a1,s;
  cin >> s;
  a3 = s/100;
  a2 = (s-a3*100)/10;
  a1 = (s-a3*100-a2*10)/1;
  cout << a1 + a2 + a3 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main() {
	
	int n;
	double x1,y1,x2,y2,x3,y3,x4,y4,m1,m2;
	
	cin>>n;
	
	for(int i=0;i<n;i++){
		int p=0;
		cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4;
		if(x1==x2&&x3==x4){p=1;}
		else if(x1==x2||x3==x4){}
		else if((y2-y1)/(x2-x1)==(y4-y3)/(x4-x3))p=1;
		if(p==1)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  cin >> n;
  vi a(n);
  REP(i,n){
    cin>>a[i];
    ans+=a[i];
  }

  ll za=ans/n;

  ll ans0=0;
  REP(i,n){
    ans0+=(a[i]-za)*(a[i]-za);
  }
  
  za+=1;
  ll ans1=0;
  REP(i,n){
    ans1+=(a[i]-za)*(a[i]-za);
  }

  ans=min(ans0,ans1);

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

Measured memory_bytes: 256
from bisect import bisect_left as bl, bisect_right as br
N = int(input())
A = sorted([int(a) for a in input().split()])
B = sorted([int(a) for a in input().split()])
C = sorted([int(a) for a in input().split()])

ans = 0
for i in range(N):
    ans += bl(A, B[i]) * (N - br(C, B[i]))
print(ans)

Measured memory_bytes: 23244
#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
using namespace std;

ll MOD = 1000000007;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,s,k;
    cin>>n>>m>>s>>k;
    if(m+n < k)
    {
       cout<< n-k+m+n<<"\n";
    }
    else
      cout<<min(k,n)<<"\n";
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;
 
int main()
{
	char x, y, z;
    cin >> x >> y >> z;
	if(x==z) cout << "Yes" << endl;
  	else cout << "No" << endl;
  	return 0;
}

Measured memory_bytes: 256
<?php
 
function input($func = null) {
    if ($func === null) {
        return trim(fgets(STDIN));
    } else {
        return $func(trim(fgets(STDIN)));
    }
}
function input_array($func = null) {
    if ($func === null) {
        return explode(' ', input());
    } else {
        return array_map(function($v) use ($func) {
            return $func($v);
        }, explode(' ', input()));
    }
}

$heights = [1];
for ($i = 1; $i <= 50; $i++) {
    $heights[$i] = $heights[$i - 1] * 2 + 3;
}

// todo 複数形がわからない
$pattis = [1];
for ($i = 1; $i <= 50; $i++) {
    $pattis[$i] = $pattis[$i - 1] * 2 + 1;
}

$number_of_pattis = function($height, $level) use (&$number_of_pattis, $heights, $pattis) {
    if ($level === 0) {
        return $height;
    }
    if ($height <= 1) {
        return 0;
    }
    if ($height <= $heights[$level - 1] + 1) {
        return $number_of_pattis($height - 1, $level - 1);
    }
    if ($height === 1 + $heights[$level - 1] + 1) {
        return 1 + $pattis[$level - 1];
    }
    if ($height <= $heights[$level - 1] + 1 + $heights[$level - 1] + 1) {
        return $number_of_pattis($height - 1 - $heights[$level - 1] - 1, $level - 1) + 1 + $pattis[$level - 1];
    }
    return $pattis[$level - 1] * 2 + 1;
};

list($n, $x) = input_array('intval');
echo $number_of_pattis($x, $n) . "\n";

Measured memory_bytes: 4856